mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
Allow select oid,* from table. Allow * anywhere in target list.
This commit is contained in:
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.16 1996/11/26 03:17:45 bryanh Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.17 1996/11/29 15:56:16 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1127,10 +1127,14 @@ transformTargetList(ParseState *pstate, List *targetlist)
|
|||||||
* (eg. SELECT * FROM emp)
|
* (eg. SELECT * FROM emp)
|
||||||
*/
|
*/
|
||||||
if (att->relname!=NULL && !strcmp(att->relname, "*")) {
|
if (att->relname!=NULL && !strcmp(att->relname, "*")) {
|
||||||
if(lnext(targetlist)!=NULL)
|
if (tail_p_target == NIL)
|
||||||
elog(WARN, "cannot expand target list *, ...");
|
p_target = tail_p_target = expandAllTables(pstate);
|
||||||
p_target = expandAllTables(pstate);
|
else
|
||||||
|
lnext(tail_p_target) = expandAllTables(pstate);
|
||||||
|
|
||||||
|
while(lnext(tail_p_target)!=NIL)
|
||||||
|
/* make sure we point to the last target entry */
|
||||||
|
tail_p_target = lnext(tail_p_target);
|
||||||
/*
|
/*
|
||||||
* skip rest of while loop
|
* skip rest of while loop
|
||||||
*/
|
*/
|
||||||
@ -1147,14 +1151,13 @@ transformTargetList(ParseState *pstate, List *targetlist)
|
|||||||
/* tail_p_target is the target list we're building in the while
|
/* tail_p_target is the target list we're building in the while
|
||||||
* loop. Make sure we fix it after appending more nodes.
|
* loop. Make sure we fix it after appending more nodes.
|
||||||
*/
|
*/
|
||||||
if (tail_p_target == NIL) {
|
if (tail_p_target == NIL)
|
||||||
p_target = tail_p_target = expandAll(pstate, att->relname,
|
p_target = tail_p_target = expandAll(pstate, att->relname,
|
||||||
att->relname, &pstate->p_last_resno);
|
att->relname, &pstate->p_last_resno);
|
||||||
} else {
|
else
|
||||||
lnext(tail_p_target) =
|
lnext(tail_p_target) =
|
||||||
expandAll(pstate, att->relname, att->relname,
|
expandAll(pstate, att->relname, att->relname,
|
||||||
&pstate->p_last_resno);
|
&pstate->p_last_resno);
|
||||||
}
|
|
||||||
while(lnext(tail_p_target)!=NIL)
|
while(lnext(tail_p_target)!=NIL)
|
||||||
/* make sure we point to the last target entry */
|
/* make sure we point to the last target entry */
|
||||||
tail_p_target = lnext(tail_p_target);
|
tail_p_target = lnext(tail_p_target);
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.18 1996/11/28 05:46:08 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.19 1996/11/29 15:56:18 momjian Exp $
|
||||||
*
|
*
|
||||||
* HISTORY
|
* HISTORY
|
||||||
* AUTHOR DATE MAJOR EVENT
|
* AUTHOR DATE MAJOR EVENT
|
||||||
@ -1935,19 +1935,6 @@ res_target_list2:
|
|||||||
{ $$ = lappend($1, $3); }
|
{ $$ = lappend($1, $3); }
|
||||||
| res_target_el2
|
| res_target_el2
|
||||||
{ $$ = lcons($1, NIL); }
|
{ $$ = lcons($1, NIL); }
|
||||||
| '*'
|
|
||||||
{
|
|
||||||
ResTarget *rt = makeNode(ResTarget);
|
|
||||||
Attr *att = makeNode(Attr);
|
|
||||||
att->relname = "*";
|
|
||||||
att->paramNo = NULL;
|
|
||||||
att->attrs = NULL;
|
|
||||||
att->indirection = NIL;
|
|
||||||
rt->name = NULL;
|
|
||||||
rt->indirection = NULL;
|
|
||||||
rt->val = (Node *)att;
|
|
||||||
$$ = lcons(rt, NIL);
|
|
||||||
}
|
|
||||||
;
|
;
|
||||||
|
|
||||||
/* AS is not optional because shift/red conflict with unary ops */
|
/* AS is not optional because shift/red conflict with unary ops */
|
||||||
@ -1977,6 +1964,18 @@ res_target_el2: a_expr AS Id
|
|||||||
$$->indirection = NULL;
|
$$->indirection = NULL;
|
||||||
$$->val = (Node *)att;
|
$$->val = (Node *)att;
|
||||||
}
|
}
|
||||||
|
| '*'
|
||||||
|
{
|
||||||
|
Attr *att = makeNode(Attr);
|
||||||
|
att->relname = "*";
|
||||||
|
att->paramNo = NULL;
|
||||||
|
att->attrs = NULL;
|
||||||
|
att->indirection = NIL;
|
||||||
|
$$ = makeNode(ResTarget);
|
||||||
|
$$->name = NULL;
|
||||||
|
$$->indirection = NULL;
|
||||||
|
$$->val = (Node *)att;
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
opt_id: Id { $$ = $1; }
|
opt_id: Id { $$ = $1; }
|
||||||
|
Reference in New Issue
Block a user