Skip to content

Commit b066d9e

Browse files
committed
Clean up some code that had gotten a bit ugly through repeated revisions.
1 parent 27a4f06 commit b066d9e

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/backend/parser/analyze.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.297 2004/01/23 02:13:12 neilc Exp $
9+
* $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.298 2004/04/02 21:05:32 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -506,7 +506,8 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
506506
List *sub_namespace;
507507
List *icolumns;
508508
List *attrnos;
509-
List *attnos;
509+
List *icols; /* to become ListCell */
510+
List *attnos; /* to become ListCell */
510511
List *tl;
511512

512513
qry->commandType = CMD_INSERT;
@@ -665,39 +666,35 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
665666
/*
666667
* Prepare columns for assignment to target table.
667668
*/
669+
icols = icolumns;
668670
attnos = attrnos;
669-
/* cannot use foreach here because of possible lremove */
670-
tl = qry->targetList;
671-
while (tl)
671+
foreach(tl, qry->targetList)
672672
{
673673
TargetEntry *tle = (TargetEntry *) lfirst(tl);
674674
ResTarget *col;
675675

676-
/* must advance tl before lremove possibly pfree's it */
677-
tl = lnext(tl);
678-
679-
if (icolumns == NIL || attnos == NIL)
676+
if (icols == NIL || attnos == NIL)
680677
ereport(ERROR,
681678
(errcode(ERRCODE_SYNTAX_ERROR),
682679
errmsg("INSERT has more expressions than target columns")));
683680

684-
col = (ResTarget *) lfirst(icolumns);
681+
col = (ResTarget *) lfirst(icols);
685682
Assert(IsA(col, ResTarget));
686683

687684
Assert(!tle->resdom->resjunk);
688685
updateTargetListEntry(pstate, tle, col->name, lfirsti(attnos),
689686
col->indirection);
690687

691-
icolumns = lnext(icolumns);
688+
icols = lnext(icols);
692689
attnos = lnext(attnos);
693690
}
694691

695692
/*
696693
* Ensure that the targetlist has the same number of entries that were
697694
* present in the columns list. Don't do the check unless an explicit
698-
* columns list was given, though. statements.
695+
* columns list was given, though.
699696
*/
700-
if (stmt->cols != NIL && (icolumns != NIL || attnos != NIL))
697+
if (stmt->cols != NIL && (icols != NIL || attnos != NIL))
701698
ereport(ERROR,
702699
(errcode(ERRCODE_SYNTAX_ERROR),
703700
errmsg("INSERT has more target columns than expressions")));

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy