aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_collate.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-04-09 14:40:09 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-04-09 14:40:09 -0400
commita19002d4e5da028ff7280554b281e402c609898b (patch)
treeac25f9dab75856d24d88a3a2bfac5faf34c25fba /src/backend/parser/parse_collate.c
parent7c76906b7e24d9ea94a2b0e33396ebcac600437d (diff)
downloadpostgresql-a19002d4e5da028ff7280554b281e402c609898b.tar.gz
postgresql-a19002d4e5da028ff7280554b281e402c609898b.zip
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.
Diffstat (limited to 'src/backend/parser/parse_collate.c')
-rw-r--r--src/backend/parser/parse_collate.c27
1 files changed, 5 insertions, 22 deletions
diff --git a/src/backend/parser/parse_collate.c b/src/backend/parser/parse_collate.c
index 8860679ccb9..3e557db2668 100644
--- a/src/backend/parser/parse_collate.c
+++ b/src/backend/parser/parse_collate.c
@@ -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;