mirror of
https://github.com/postgres/postgres.git
synced 2025-09-05 02:22:28 +03:00
Adjust collation determination rules as per discussion.
Remove crude hack that tried to propagate collation through a function-returning-record, ie, from the function's arguments to individual fields selected from its result record. That is just plain inconsistent, because the function result is composite and cannot have a collation; and there's no hope of making this kind of action-at-a-distance work consistently. Adjust regression test cases that expected this to happen. Meanwhile, the behavior of casting to a domain with a declared collation stays the same as it was, since that seemed to be the consensus.
This commit is contained in:
@@ -289,10 +289,11 @@ assign_collations_walker(Node *node, assign_collations_context *context)
|
||||
case T_FieldSelect:
|
||||
{
|
||||
/*
|
||||
* FieldSelect is a special case because the field may have
|
||||
* a non-default collation, in which case we should use that.
|
||||
* The field's collation was already looked up and saved
|
||||
* in the node.
|
||||
* For FieldSelect, the result has the field's declared
|
||||
* collation, independently of what happened in the arguments.
|
||||
* (The immediate argument must be composite and thus not
|
||||
* collatable, anyhow.) The field's collation was already
|
||||
* looked up and saved in the node.
|
||||
*/
|
||||
FieldSelect *expr = (FieldSelect *) node;
|
||||
|
||||
@@ -304,24 +305,6 @@ assign_collations_walker(Node *node, assign_collations_context *context)
|
||||
if (OidIsValid(expr->resultcollid))
|
||||
{
|
||||
/* Node's result type is collatable. */
|
||||
if (expr->resultcollid == DEFAULT_COLLATION_OID)
|
||||
{
|
||||
/*
|
||||
* The immediate input node necessarily yields a
|
||||
* composite type, so it will have no exposed
|
||||
* collation. However, if we are selecting a field
|
||||
* from a function returning composite, see if we
|
||||
* can bubble up a collation from the function's
|
||||
* input. XXX this is a bit of a hack, rethink ...
|
||||
*/
|
||||
if (IsA(expr->arg, FuncExpr))
|
||||
{
|
||||
FuncExpr *fexpr = (FuncExpr *) expr->arg;
|
||||
|
||||
if (OidIsValid(fexpr->inputcollid))
|
||||
expr->resultcollid = fexpr->inputcollid;
|
||||
}
|
||||
}
|
||||
/* Pass up field's collation as an implicit choice. */
|
||||
collation = expr->resultcollid;
|
||||
strength = COLLATE_IMPLICIT;
|
||||
|
Reference in New Issue
Block a user