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

Commit9432b6d

Browse files
committed
Do not assign output columns to junk attributes created from
GROUP BY or ORDER BY expressions in INSERT ... SELECT.
1 parent505b518 commit9432b6d

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

‎src/backend/parser/parse_target.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.38 1999/05/22 04:12:28 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.39 1999/05/23 21:42:09 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -32,16 +32,12 @@
3232

3333

3434
staticList*ExpandAllTables(ParseState*pstate);
35-
char*FigureColname(Node*expr,Node*resval);
36-
35+
staticchar*FigureColname(Node*expr,Node*resval);
3736
staticNode*SizeTargetExpr(ParseState*pstate,
3837
Node*expr,
3938
Oidattrtype,
4039
int32attrtypmod);
4140

42-
staticTargetEntry*
43-
MakeTargetEntryCase(ParseState*pstate,
44-
ResTarget*res);
4541

4642
/* MakeTargetEntryIdent()
4743
* Transforms an Ident Node to a Target Entry
@@ -66,8 +62,13 @@ MakeTargetEntryIdent(ParseState *pstate,
6662
Oidattrtype_target;
6763
TargetEntry*tent=makeNode(TargetEntry);
6864

69-
if (pstate->p_is_insert)
65+
if (pstate->p_is_insert&& !resjunk)
7066
{
67+
/* Assign column name of destination column to the new TLE.
68+
* XXX this is probably WRONG in INSERT ... SELECT case,
69+
* since handling of GROUP BY and so forth probably should use
70+
* the source table's names not the destination's names.
71+
*/
7172
if (pstate->p_insert_columns!=NIL)
7273
{
7374
Ident*id=lfirst(pstate->p_insert_columns);
@@ -79,7 +80,7 @@ MakeTargetEntryIdent(ParseState *pstate,
7980
elog(ERROR,"INSERT has more expressions than target columns");
8081
}
8182

82-
if (pstate->p_is_insert||pstate->p_is_update)
83+
if ((pstate->p_is_insert||pstate->p_is_update)&& !resjunk)
8384
{
8485
Oidattrtype_id;
8586
intresdomno_id,
@@ -208,7 +209,7 @@ MakeTargetEntryExpr(ParseState *pstate,
208209
type_mod=-1;
209210

210211
/* Process target columns that will be receiving results */
211-
if (pstate->p_is_insert||pstate->p_is_update)
212+
if ((pstate->p_is_insert||pstate->p_is_update)&& !resjunk)
212213
{
213214

214215
/*
@@ -870,7 +871,7 @@ ExpandAllTables(ParseState *pstate)
870871
* list, we have to guess.
871872
*
872873
*/
873-
char*
874+
staticchar*
874875
FigureColname(Node*expr,Node*resval)
875876
{
876877
switch (nodeTag(expr))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp