Skip to content

Commit ff566b2

Browse files
committed
Modify raw parsetree representation returned by gram.y for SubLinks:
the oper field should be a valid Node structure so it can be dumped by outfuncs.c without risk of coredump. (We had been using a raw pointer to character string, which surely is NOT a valid Node.) This doesn't cause any backwards compatibility problems for stored rules, since raw unanalyzed parsetrees are never stored.
1 parent 610abfd commit ff566b2

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

src/backend/parser/gram.y

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.167 2000/04/07 13:39:34 thomas Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.168 2000/05/25 22:42:17 tgl Exp $
1515
*
1616
* HISTORY
1717
* AUTHOR DATE MAJOR EVENT
@@ -4153,7 +4153,7 @@ row_expr: '(' row_descriptor ')' IN '(' SubSelect ')'
41534153
{
41544154
SubLink *n = makeNode(SubLink);
41554155
n->lefthand = $2;
4156-
n->oper = lcons("=", NIL);
4156+
n->oper = (List *) makeA_Expr(OP, "=", NULL, NULL);
41574157
n->useor = false;
41584158
n->subLinkType = ANY_SUBLINK;
41594159
n->subselect = $6;
@@ -4163,7 +4163,7 @@ row_expr: '(' row_descriptor ')' IN '(' SubSelect ')'
41634163
{
41644164
SubLink *n = makeNode(SubLink);
41654165
n->lefthand = $2;
4166-
n->oper = lcons("<>", NIL);
4166+
n->oper = (List *) makeA_Expr(OP, "<>", NULL, NULL);
41674167
n->useor = true;
41684168
n->subLinkType = ALL_SUBLINK;
41694169
n->subselect = $7;
@@ -4173,8 +4173,8 @@ row_expr: '(' row_descriptor ')' IN '(' SubSelect ')'
41734173
{
41744174
SubLink *n = makeNode(SubLink);
41754175
n->lefthand = $2;
4176-
n->oper = lcons($4, NIL);
4177-
if (strcmp($4,"<>") == 0)
4176+
n->oper = (List *) makeA_Expr(OP, $4, NULL, NULL);
4177+
if (strcmp($4, "<>") == 0)
41784178
n->useor = true;
41794179
else
41804180
n->useor = false;
@@ -4186,8 +4186,8 @@ row_expr: '(' row_descriptor ')' IN '(' SubSelect ')'
41864186
{
41874187
SubLink *n = makeNode(SubLink);
41884188
n->lefthand = $2;
4189-
n->oper = lcons($4, NIL);
4190-
if (strcmp($4,"<>") == 0)
4189+
n->oper = (List *) makeA_Expr(OP, $4, NULL, NULL);
4190+
if (strcmp($4, "<>") == 0)
41914191
n->useor = true;
41924192
else
41934193
n->useor = false;
@@ -4436,7 +4436,7 @@ a_expr: c_expr
44364436
{
44374437
SubLink *n = (SubLink *)$4;
44384438
n->lefthand = lcons($1, NIL);
4439-
n->oper = lcons("=", NIL);
4439+
n->oper = (List *) makeA_Expr(OP, "=", NULL, NULL);
44404440
n->useor = false;
44414441
n->subLinkType = ANY_SUBLINK;
44424442
$$ = (Node *)n;
@@ -4463,7 +4463,7 @@ a_expr: c_expr
44634463
{
44644464
SubLink *n = (SubLink *)$5;
44654465
n->lefthand = lcons($1, NIL);
4466-
n->oper = lcons("<>", NIL);
4466+
n->oper = (List *) makeA_Expr(OP, "<>", NULL, NULL);
44674467
n->useor = false;
44684468
n->subLinkType = ALL_SUBLINK;
44694469
$$ = (Node *)n;
@@ -4487,7 +4487,7 @@ a_expr: c_expr
44874487
{
44884488
SubLink *n = makeNode(SubLink);
44894489
n->lefthand = lcons($1, NIL);
4490-
n->oper = lcons($2, NIL);
4490+
n->oper = (List *) makeA_Expr(OP, $2, NULL, NULL);
44914491
n->useor = false; /* doesn't matter since only one col */
44924492
n->subLinkType = $3;
44934493
n->subselect = $5;

src/backend/parser/parse_expr.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.76 2000/04/12 17:15:26 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.77 2000/05/25 22:42:18 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -324,23 +324,25 @@ transformExpr(ParseState *pstate, Node *expr, int precedence)
324324
else
325325
{
326326
/* ALL, ANY, or MULTIEXPR: generate operator list */
327-
char *op = lfirst(sublink->oper);
328327
List *left_list = sublink->lefthand;
329328
List *right_list = qtree->targetList;
329+
char *op;
330330
List *elist;
331331

332332
foreach(elist, left_list)
333333
lfirst(elist) = transformExpr(pstate, lfirst(elist),
334334
precedence);
335335

336+
Assert(IsA(sublink->oper, A_Expr));
337+
op = ((A_Expr *) sublink->oper)->opname;
338+
sublink->oper = NIL;
339+
336340
/* Combining operators other than =/<> is dubious... */
337341
if (length(left_list) != 1 &&
338342
strcmp(op, "=") != 0 && strcmp(op, "<>") != 0)
339343
elog(ERROR, "Row comparison cannot use '%s'",
340344
op);
341345

342-
sublink->oper = NIL;
343-
344346
/*
345347
* Scan subquery's targetlist to find values that will
346348
* be matched against lefthand values. We need to

src/include/nodes/primnodes.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: primnodes.h,v 1.41 2000/04/12 17:16:40 momjian Exp $
10+
* $Id: primnodes.h,v 1.42 2000/05/25 22:42:19 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -350,8 +350,8 @@ typedef struct Aggref
350350
* NOTE: lefthand and oper have varying meanings depending on where you look
351351
* in the parse/plan pipeline:
352352
* 1. gram.y delivers a list of the (untransformed) lefthand expressions in
353-
* lefthand, and sets oper to a one-element list containing the string
354-
* name of the operator.
353+
* lefthand, and sets oper to a single A_Expr (not a list!) containing
354+
* the string name of the operator, but no arguments.
355355
* 2. The parser's expression transformation transforms lefthand normally,
356356
* and replaces oper with a list of Oper nodes, one per lefthand
357357
* expression. These nodes represent the parser's resolution of exactly

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