Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f0cc132

Browse files
committed
Fix oversight in recent rowtype-handling improvements: transformTargetList
should recognize 'foo.*' when the star appears in A_Indirection, not only in ColumnRef. This allows 'SELECT something.*' to do what the user expects when the something is an expression yielding a row.
1 parent 57d2665 commit f0cc132

File tree

3 files changed

+211
-124
lines changed

3 files changed

+211
-124
lines changed

src/backend/parser/parse_func.c

+10-30
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.171 2004/06/16 01:26:45 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.172 2004/06/19 18:19:55 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -38,7 +38,6 @@ static Oid **argtype_inherit(int nargs, Oid *argtypes);
3838

3939
static int find_inheritors(Oid relid, Oid **supervec);
4040
static Oid **gen_cross_product(InhPaths *arginh, int nargs);
41-
static FieldSelect *setup_field_select(Node *input, char *attname, Oid relid);
4241
static void unknown_attribute(ParseState *pstate, Node *relref, char *attname);
4342

4443

@@ -1131,33 +1130,6 @@ make_fn_arguments(ParseState *pstate,
11311130
}
11321131
}
11331132

1134-
/*
1135-
* setup_field_select
1136-
* Build a FieldSelect node that says which attribute to project to.
1137-
* This routine is called by ParseFuncOrColumn() when we have found
1138-
* a projection on a function result or parameter.
1139-
*/
1140-
static FieldSelect *
1141-
setup_field_select(Node *input, char *attname, Oid relid)
1142-
{
1143-
FieldSelect *fselect = makeNode(FieldSelect);
1144-
AttrNumber attno;
1145-
1146-
attno = get_attnum(relid, attname);
1147-
if (attno == InvalidAttrNumber)
1148-
ereport(ERROR,
1149-
(errcode(ERRCODE_UNDEFINED_COLUMN),
1150-
errmsg("column \"%s\" of relation \"%s\" does not exist",
1151-
attname, get_rel_name(relid))));
1152-
1153-
fselect->arg = (Expr *) input;
1154-
fselect->fieldnum = attno;
1155-
fselect->resulttype = get_atttype(relid, attno);
1156-
fselect->resulttypmod = get_atttypmod(relid, attno);
1157-
1158-
return fselect;
1159-
}
1160-
11611133
/*
11621134
* ParseComplexProjection -
11631135
* handles function calls with a single argument that is of complex type.
@@ -1170,6 +1142,7 @@ ParseComplexProjection(ParseState *pstate, char *funcname, Node *first_arg)
11701142
Oid argtype;
11711143
Oid argrelid;
11721144
AttrNumber attnum;
1145+
FieldSelect *fselect;
11731146

11741147
/*
11751148
* Special case for whole-row Vars so that we can resolve (foo.*).bar
@@ -1205,7 +1178,14 @@ ParseComplexProjection(ParseState *pstate, char *funcname, Node *first_arg)
12051178
return NULL; /* funcname does not match any column */
12061179

12071180
/* Success, so generate a FieldSelect expression */
1208-
return (Node *) setup_field_select(first_arg, funcname, argrelid);
1181+
fselect = makeNode(FieldSelect);
1182+
fselect->arg = (Expr *) first_arg;
1183+
fselect->fieldnum = attnum;
1184+
get_atttypetypmod(argrelid, attnum,
1185+
&fselect->resulttype,
1186+
&fselect->resulttypmod);
1187+
1188+
return (Node *) fselect;
12091189
}
12101190

12111191
/*

0 commit comments

Comments
 (0)