7
7
*
8
8
*
9
9
* 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 $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -42,7 +42,8 @@ static Query *transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt);
42
42
static Query * transformCursorStmt (ParseState * pstate , SelectStmt * stmt );
43
43
static Query * transformCreateStmt (ParseState * pstate , CreateStmt * stmt );
44
44
45
- List * extras = NIL ;
45
+ List * extras_before = NIL ;
46
+ List * extras_after = NIL ;
46
47
47
48
/*
48
49
* parse_analyze -
@@ -57,6 +58,7 @@ parse_analyze(List *pl, ParseState *parentParseState)
57
58
{
58
59
QueryTreeList * result ;
59
60
ParseState * pstate ;
61
+ Query * parsetree ;
60
62
int i = 0 ;
61
63
62
64
result = malloc (sizeof (QueryTreeList ));
@@ -66,23 +68,40 @@ parse_analyze(List *pl, ParseState *parentParseState)
66
68
while (pl != NIL )
67
69
{
68
70
pstate = make_parsestate (parentParseState );
69
- result -> qtrees [ i ++ ] = transformStmt (pstate , lfirst (pl ));
71
+ parsetree = transformStmt (pstate , lfirst (pl ));
70
72
if (pstate -> p_target_relation != NULL )
71
73
heap_close (pstate -> p_target_relation );
72
74
73
- if (extras != NIL )
75
+ if (extras_before != NIL )
74
76
{
75
- result -> len += length (extras );
77
+ result -> len += length (extras_before );
76
78
result -> qtrees = (Query * * ) realloc (result -> qtrees , result -> len * sizeof (Query * ));
77
- while (extras != NIL )
79
+ while (extras_before != NIL )
78
80
{
79
- result -> qtrees [i ++ ] = transformStmt (pstate , lfirst (extras ));
81
+ result -> qtrees [i ++ ] = transformStmt (pstate , lfirst (extras_before ));
80
82
if (pstate -> p_target_relation != NULL )
81
83
heap_close (pstate -> p_target_relation );
82
- extras = lnext (extras );
84
+ extras_before = lnext (extras_before );
83
85
}
84
86
}
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
+
86
105
pl = lnext (pl );
87
106
pfree (pstate );
88
107
}
@@ -487,6 +506,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
487
506
Constraint * constraint ;
488
507
List * keys ;
489
508
Ident * key ;
509
+ List * blist = NIL ;
490
510
List * ilist = NIL ;
491
511
IndexStmt * index ;
492
512
IndexElem * iparam ;
@@ -553,7 +573,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
553
573
elog (NOTICE , "CREATE TABLE will create implicit sequence %s for SERIAL column %s.%s" ,
554
574
sequence -> seqname , stmt -> relname , column -> colname );
555
575
556
- ilist = lcons (sequence , NIL );
576
+ blist = lcons (sequence , NIL );
557
577
}
558
578
559
579
if (column -> constraints != NIL )
@@ -745,7 +765,8 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
745
765
}
746
766
747
767
q -> utilityStmt = (Node * ) stmt ;
748
- extras = ilist ;
768
+ extras_before = blist ;
769
+ extras_after = ilist ;
749
770
750
771
return q ;
751
772
}
0 commit comments