Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 53b8ea5

Browse files
committed
Fix for serial creation.
1 parent 1adacc7 commit 53b8ea5

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

src/backend/parser/analyze.c

+32-11
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.88 1998/09/25 13:36:00 thomas Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.89 1998/10/28 16:06:54 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -42,7 +42,8 @@ static Query *transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt);
4242
static Query *transformCursorStmt(ParseState *pstate, SelectStmt *stmt);
4343
static Query *transformCreateStmt(ParseState *pstate, CreateStmt *stmt);
4444

45-
List *extras = NIL;
45+
List *extras_before = NIL;
46+
List *extras_after = NIL;
4647

4748
/*
4849
* parse_analyze -
@@ -57,6 +58,7 @@ parse_analyze(List *pl, ParseState *parentParseState)
5758
{
5859
QueryTreeList *result;
5960
ParseState *pstate;
61+
Query *parsetree;
6062
int i = 0;
6163

6264
result = malloc(sizeof(QueryTreeList));
@@ -66,23 +68,40 @@ parse_analyze(List *pl, ParseState *parentParseState)
6668
while (pl != NIL)
6769
{
6870
pstate = make_parsestate(parentParseState);
69-
result->qtrees[i++] = transformStmt(pstate, lfirst(pl));
71+
parsetree = transformStmt(pstate, lfirst(pl));
7072
if (pstate->p_target_relation != NULL)
7173
heap_close(pstate->p_target_relation);
7274

73-
if (extras != NIL)
75+
if (extras_before != NIL)
7476
{
75-
result->len += length(extras);
77+
result->len += length(extras_before);
7678
result->qtrees = (Query **) realloc(result->qtrees, result->len * sizeof(Query *));
77-
while (extras != NIL)
79+
while (extras_before != NIL)
7880
{
79-
result->qtrees[i++] = transformStmt(pstate, lfirst(extras));
81+
result->qtrees[i++] = transformStmt(pstate, lfirst(extras_before));
8082
if (pstate->p_target_relation != NULL)
8183
heap_close(pstate->p_target_relation);
82-
extras = lnext(extras);
84+
extras_before = lnext(extras_before);
8385
}
8486
}
85-
extras = NIL;
87+
extras_before = NIL;
88+
89+
result->qtrees[i++] = parsetree;
90+
91+
if (extras_after != NIL)
92+
{
93+
result->len += length(extras_after);
94+
result->qtrees = (Query **) realloc(result->qtrees, result->len * sizeof(Query *));
95+
while (extras_after != NIL)
96+
{
97+
result->qtrees[i++] = transformStmt(pstate, lfirst(extras_after));
98+
if (pstate->p_target_relation != NULL)
99+
heap_close(pstate->p_target_relation);
100+
extras_after = lnext(extras_after);
101+
}
102+
}
103+
extras_after = NIL;
104+
86105
pl = lnext(pl);
87106
pfree(pstate);
88107
}
@@ -487,6 +506,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
487506
Constraint *constraint;
488507
List *keys;
489508
Ident *key;
509+
List *blist = NIL;
490510
List *ilist = NIL;
491511
IndexStmt *index;
492512
IndexElem *iparam;
@@ -553,7 +573,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
553573
elog(NOTICE, "CREATE TABLE will create implicit sequence %s for SERIAL column %s.%s",
554574
sequence->seqname, stmt->relname, column->colname);
555575

556-
ilist = lcons(sequence, NIL);
576+
blist = lcons(sequence, NIL);
557577
}
558578

559579
if (column->constraints != NIL)
@@ -745,7 +765,8 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
745765
}
746766

747767
q->utilityStmt = (Node *) stmt;
748-
extras = ilist;
768+
extras_before = blist;
769+
extras_after = ilist;
749770

750771
return q;
751772
}

0 commit comments

Comments
 (0)