Commit 2e615931 authored by Bruce Momjian's avatar Bruce Momjian

I made several adjustments to my earlier patch to handle the

condition where the target label is ambiguous.
parent a576a60e
......@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.17 1998/05/29 14:00:19 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.18 1998/06/05 03:49:18 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -194,17 +194,32 @@ find_targetlist_entry(ParseState *pstate, SortGroupBy *sortgroupby, List *tlist)
* it will not be projected into the final tuple.
* daveh@insightdist.com 5/20/98
*/
if ( ! target_result) {
if ( ! target_result && sortgroupby->name) {
List *p_target = tlist;
Ident *missingTargetId = (Ident *)makeNode(Ident);
TargetEntry *tent = makeNode(TargetEntry);
/* Fill in the constructed Ident node */
missingTargetId->type = T_Ident;
missingTargetId->name = palloc(strlen(sortgroupby->name) + 1);
strcpy(missingTargetId->name, sortgroupby->name);
transformTargetId(pstate, missingTargetId, tent, missingTargetId->name, TRUE);
if (sortgroupby->range) {
Attr *missingTarget = (Attr *)makeNode(Attr);
missingTarget->type = T_Attr;
missingTarget->relname = palloc(strlen(sortgroupby->range) + 1);
strcpy(missingTarget->relname, sortgroupby->range);
missingTarget->attrs = lcons(makeString(sortgroupby->name), NIL);
transformTargetId(pstate, (Node*)missingTarget, tent, sortgroupby->name, TRUE);
}
else {
Ident *missingTarget = (Ident *)makeNode(Ident);
missingTarget->type = T_Ident;
missingTarget->name = palloc(strlen(sortgroupby->name) + 1);
strcpy(missingTarget->name, sortgroupby->name);
transformTargetId(pstate, (Node*)missingTarget, tent, sortgroupby->name, TRUE);
}
/* Add to the end of the target list */
while (lnext(p_target) != NIL) {
......
......@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.14 1998/05/29 14:00:23 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.15 1998/06/05 03:49:18 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -54,7 +54,7 @@ size_target_expr(ParseState *pstate,
*/
void
transformTargetId(ParseState *pstate,
Ident *ident,
Node *node,
TargetEntry *tent,
char *resname,
int16 resjunk)
......@@ -68,7 +68,7 @@ transformTargetId(ParseState *pstate,
* relation names (even though they can be stored in
* Ident nodes, too)
*/
expr = transformIdent(pstate, (Node *) ident, EXPR_COLUMN_FIRST);
expr = transformExpr(pstate, node, EXPR_COLUMN_FIRST);
type_id = exprType(expr);
if (nodeTag(expr) == T_Var)
type_mod = ((Var *) expr)->vartypmod;
......@@ -113,7 +113,7 @@ transformTargetList(ParseState *pstate, List *targetlist)
identname = ((Ident *) res->val)->name;
handleTargetColname(pstate, &res->name, NULL, identname);
resname = (res->name) ? res->name : identname;
transformTargetId(pstate, (Ident*)res->val, tent, resname, FALSE);
transformTargetId(pstate, (Node*)res->val, tent, resname, FALSE);
break;
}
case T_ParamNo:
......
......@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: parse_target.h,v 1.6 1998/05/29 14:07:50 thomas Exp $
* $Id: parse_target.h,v 1.7 1998/06/05 03:49:19 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -24,9 +24,8 @@
extern List *transformTargetList(ParseState *pstate, List *targetlist);
extern List *makeTargetNames(ParseState *pstate, List *cols);
extern void transformTargetId(ParseState *pstate, Ident *ident,
TargetEntry *tent, char *resname,
int16 resjunk);
extern void transformTargetId(ParseState *pstate, Node *node,
TargetEntry *tent, char *resname, int16 resjunk);
extern Node *coerce_target_expr(ParseState *pstate, Node *expr,
Oid type_id, Oid attrtype);
......
......@@ -58,3 +58,4 @@ hash_index
select_views
alter_table
portals_p2
junkfilter
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment