|
7 | 7 | *
|
8 | 8 | *
|
9 | 9 | * IDENTIFICATION
|
10 |
| - * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.5 1996/08/06 16:37:58 scrappy Exp $ |
| 10 | + * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.6 1996/10/13 04:25:42 momjian Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -95,10 +95,11 @@ makeParseState() {
|
95 | 95 | pstate = malloc(sizeof(ParseState));
|
96 | 96 | pstate->p_last_resno = 1;
|
97 | 97 | pstate->p_target_resnos = NIL;
|
| 98 | + pstate->p_current_rel = NULL; |
98 | 99 | pstate->p_rtable = NIL;
|
99 | 100 | pstate->p_query_is_rule = 0;
|
100 | 101 | pstate->p_numAgg = 0;
|
101 |
| - pstate->p_aggs = NULL; |
| 102 | + pstate->p_aggs = NIL; |
102 | 103 |
|
103 | 104 | return (pstate);
|
104 | 105 | }
|
@@ -126,6 +127,8 @@ parse_analyze(List *pl)
|
126 | 127 | pstate = makeParseState();
|
127 | 128 | result->qtrees[i++] = transformStmt(pstate, lfirst(pl));
|
128 | 129 | pl = lnext(pl);
|
| 130 | + if (pstate->p_current_rel != NULL) |
| 131 | + heap_close(pstate->p_current_rel); |
129 | 132 | free(pstate);
|
130 | 133 | }
|
131 | 134 |
|
@@ -828,8 +831,8 @@ makeRangeTable(ParseState *pstate, char *relname, List *frmList)
|
828 | 831 | pstate->p_rtable = lappend(pstate->p_rtable, ent);
|
829 | 832 | }
|
830 | 833 | x = RangeTablePosn(pstate->p_rtable, relname);
|
831 |
| - pstate->parser_current_rel = heap_openr(VarnoGetRelname(pstate,x)); |
832 |
| - if (pstate->parser_current_rel == NULL) |
| 834 | + pstate->p_current_rel = heap_openr(VarnoGetRelname(pstate,x)); |
| 835 | + if (pstate->p_current_rel == NULL) |
833 | 836 | elog(WARN,"invalid relation name");
|
834 | 837 | }
|
835 | 838 |
|
@@ -1036,7 +1039,7 @@ makeTargetList(ParseState *pstate, List *cols, List *exprs)
|
1036 | 1039 | exprs = lnext(exprs);
|
1037 | 1040 | }
|
1038 | 1041 | } else {
|
1039 |
| - Relation insertRel = pstate->parser_current_rel; |
| 1042 | + Relation insertRel = pstate->p_current_rel; |
1040 | 1043 | int numcol;
|
1041 | 1044 | int i;
|
1042 | 1045 | AttributeTupleForm *attr = insertRel->rd_att->attrs;
|
@@ -1155,7 +1158,7 @@ transformTargetList(ParseState *pstate,
|
1155 | 1158 | i++;
|
1156 | 1159 | }
|
1157 | 1160 | sprintf(str, "=%s", val);
|
1158 |
| - rd = pstate->parser_current_rel; |
| 1161 | + rd = pstate->p_current_rel; |
1159 | 1162 | Assert(rd != NULL);
|
1160 | 1163 | resdomno = varattno(rd, res->name);
|
1161 | 1164 | ndims = att_attnelems(rd, resdomno);
|
@@ -1334,7 +1337,7 @@ make_targetlist_expr(ParseState *pstate,
|
1334 | 1337 | * append, replace work only on one relation,
|
1335 | 1338 | * so multiple occurence of same resdomno is bogus
|
1336 | 1339 | */
|
1337 |
| - rd = pstate->parser_current_rel; |
| 1340 | + rd = pstate->p_current_rel; |
1338 | 1341 | Assert(rd != NULL);
|
1339 | 1342 | resdomno = varattno(rd,name);
|
1340 | 1343 | attrisset = varisset(rd,name);
|
|
0 commit comments