1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-29 10:41:53 +03:00

Fix *-qualification of named parameters in SQL-language functions.

Given a composite-type parameter named x, "$1.*" worked fine, but "x.*"
not so much.  This has been broken since named parameter references were
added in commit 9bff0780cf, so patch back
to 9.2.  Per bug #9085 from Hardy Falk.
This commit is contained in:
Tom Lane
2014-02-03 14:46:57 -05:00
parent c07702995a
commit 888b565704
3 changed files with 83 additions and 0 deletions

View File

@ -309,6 +309,11 @@ sql_fn_post_column_ref(ParseState *pstate, ColumnRef *cref, Node *var)
* (the first possibility takes precedence)
* A.B.C A = function name, B = record-typed parameter name,
* C = field name
* A.* Whole-row reference to composite parameter A.
* A.B.* Same, with A = function name, B = parameter name
*
* Here, it's sufficient to ignore the "*" in the last two cases --- the
* main parser will take care of expanding the whole-row reference.
*----------
*/
nnames = list_length(cref->fields);
@ -316,6 +321,9 @@ sql_fn_post_column_ref(ParseState *pstate, ColumnRef *cref, Node *var)
if (nnames > 3)
return NULL;
if (IsA(llast(cref->fields), A_Star))
nnames--;
field1 = (Node *) linitial(cref->fields);
Assert(IsA(field1, String));
name1 = strVal(field1);