Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita3d773a

Browse files
committed
Allow select oid,* from table. Allow * anywhere in target list.
1 parenta962c61 commita3d773a

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

‎src/backend/parser/analyze.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.16 1996/11/26 03:17:45 bryanh Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.17 1996/11/29 15:56:16 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1127,10 +1127,14 @@ transformTargetList(ParseState *pstate, List *targetlist)
11271127
* (eg. SELECT * FROM emp)
11281128
*/
11291129
if (att->relname!=NULL&& !strcmp(att->relname,"*")) {
1130-
if(lnext(targetlist)!=NULL)
1131-
elog(WARN,"cannot expand target list *, ...");
1132-
p_target=expandAllTables(pstate);
1130+
if (tail_p_target==NIL)
1131+
p_target=tail_p_target=expandAllTables(pstate);
1132+
else
1133+
lnext(tail_p_target)=expandAllTables(pstate);
11331134

1135+
while(lnext(tail_p_target)!=NIL)
1136+
/* make sure we point to the last target entry */
1137+
tail_p_target=lnext(tail_p_target);
11341138
/*
11351139
* skip rest of while loop
11361140
*/
@@ -1147,14 +1151,13 @@ transformTargetList(ParseState *pstate, List *targetlist)
11471151
/* tail_p_target is the target list we're building in the while
11481152
* loop. Make sure we fix it after appending more nodes.
11491153
*/
1150-
if (tail_p_target==NIL) {
1154+
if (tail_p_target==NIL)
11511155
p_target=tail_p_target=expandAll(pstate,att->relname,
11521156
att->relname,&pstate->p_last_resno);
1153-
}else {
1157+
else
11541158
lnext(tail_p_target)=
11551159
expandAll(pstate,att->relname,att->relname,
11561160
&pstate->p_last_resno);
1157-
}
11581161
while(lnext(tail_p_target)!=NIL)
11591162
/* make sure we point to the last target entry */
11601163
tail_p_target=lnext(tail_p_target);

‎src/backend/parser/gram.y

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.18 1996/11/28 05:46:08 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.19 1996/11/29 15:56:18 momjian Exp $
1414
*
1515
* HISTORY
1616
* AUTHORDATEMAJOR EVENT
@@ -1935,19 +1935,6 @@ res_target_list2:
19351935
{ $$ = lappend($1, $3); }
19361936
| res_target_el2
19371937
{ $$ = lcons($1, NIL); }
1938-
| '*'
1939-
{
1940-
ResTarget *rt = makeNode(ResTarget);
1941-
Attr *att = makeNode(Attr);
1942-
att->relname = "*";
1943-
att->paramNo = NULL;
1944-
att->attrs = NULL;
1945-
att->indirection = NIL;
1946-
rt->name = NULL;
1947-
rt->indirection = NULL;
1948-
rt->val = (Node *)att;
1949-
$$ = lcons(rt, NIL);
1950-
}
19511938
;
19521939

19531940
/* AS is not optional because shift/red conflict with unary ops */
@@ -1977,6 +1964,18 @@ res_target_el2: a_expr AS Id
19771964
$$->indirection = NULL;
19781965
$$->val = (Node *)att;
19791966
}
1967+
| '*'
1968+
{
1969+
Attr *att = makeNode(Attr);
1970+
att->relname = "*";
1971+
att->paramNo = NULL;
1972+
att->attrs = NULL;
1973+
att->indirection = NIL;
1974+
$$ = makeNode(ResTarget);
1975+
$$->name = NULL;
1976+
$$->indirection = NULL;
1977+
$$->val = (Node *)att;
1978+
}
19801979
;
19811980

19821981
opt_id: Id{ $$ = $1; }

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp