summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorTom Lane2011-04-09 18:40:09 +0000
committerTom Lane2011-04-09 18:40:09 +0000
commita19002d4e5da028ff7280554b281e402c609898b (patch)
treeac25f9dab75856d24d88a3a2bfac5faf34c25fba /src/backend
parent7c76906b7e24d9ea94a2b0e33396ebcac600437d (diff)
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')
-rw-r--r--src/backend/parser/parse_collate.c27
-rw-r--r--src/backend/parser/parse_func.c2
-rw-r--r--src/backend/parser/parse_target.c2
3 files changed, 7 insertions, 24 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;
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c
index a187287e283..ba699e9a1ed 100644
--- a/src/backend/parser/parse_func.c
+++ b/src/backend/parser/parse_func.c
@@ -1384,7 +1384,7 @@ ParseComplexProjection(ParseState *pstate, char *funcname, Node *first_arg,
fselect->fieldnum = i + 1;
fselect->resulttype = att->atttypid;
fselect->resulttypmod = att->atttypmod;
- /* resultcollid may get overridden by parse_collate.c */
+ /* save attribute's collation for parse_collate.c */
fselect->resultcollid = att->attcollation;
return (Node *) fselect;
}
diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c
index d53d1d9f008..52c6db2eb5c 100644
--- a/src/backend/parser/parse_target.c
+++ b/src/backend/parser/parse_target.c
@@ -1290,7 +1290,7 @@ ExpandRowReference(ParseState *pstate, Node *expr,
fselect->fieldnum = i + 1;
fselect->resulttype = att->atttypid;
fselect->resulttypmod = att->atttypmod;
- /* resultcollid may get overridden by parse_collate.c */
+ /* save attribute's collation for parse_collate.c */
fselect->resultcollid = att->attcollation;
if (targetlist)