Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita91c411

Browse files
committed
Prevent failure when RowExpr or XmlExpr is parse-analyzed twice.
transformExpr() is required to cope with already-transformed expressiontrees, for various ugly-but-not-quite-worth-cleaning-up reasons. However,some of its newer subroutines hadn't gotten the memo. This accounts forbug #7763 from Norbert Buchmuller: transformRowExpr() was overwriting thepreviously determined type of a RowExpr during CREATE TABLE LIKE INCLUDINGINDEXES. Additional investigation showed that transformXmlExpr had thesame kind of problem, but all the other cases seem to be safe.Andres Freund and Tom Lane
1 parente5e8ad3 commita91c411

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

‎src/backend/parser/gram.y

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11725,6 +11725,7 @@ makeXmlExpr(XmlExprOp op, char *name, List *named_args, List *args,
1172511725
x->args = args;
1172611726
/* xmloption, if relevant, must be filled in by caller*/
1172711727
/* type and typmod will be filled in during parse analysis*/
11728+
x->type = InvalidOid;/* marks the node as not analyzed*/
1172811729
x->location = location;
1172911730
return (Node *) x;
1173011731
}

‎src/backend/parser/parse_expr.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ static Expr *make_distinct_op(ParseState *pstate, List *opname,
8989
*function argument to the required type (via coerce_type())
9090
*can apply transformExpr to an already-transformed subexpression.
9191
*An example here is "SELECT count(*) + 1.0 FROM table".
92+
*3. CREATE TABLE t1 (LIKE t2 INCLUDING INDEXES) can pass in
93+
*already-transformed index expressions.
9294
* While it might be possible to eliminate these cases, the path of
9395
* least resistance so far has been to ensure that transformExpr() does
9496
* no damage if applied to an already-transformed tree. This is pretty
@@ -1663,7 +1665,13 @@ transformArrayExpr(ParseState *pstate, A_ArrayExpr *a,
16631665
staticNode*
16641666
transformRowExpr(ParseState*pstate,RowExpr*r)
16651667
{
1666-
RowExpr*newr=makeNode(RowExpr);
1668+
RowExpr*newr;
1669+
1670+
/* If we already transformed this node, do nothing */
1671+
if (OidIsValid(r->row_typeid))
1672+
return (Node*)r;
1673+
1674+
newr=makeNode(RowExpr);
16671675

16681676
/* Transform the field expressions */
16691677
newr->args=transformExpressionList(pstate,r->args);
@@ -1754,16 +1762,23 @@ transformMinMaxExpr(ParseState *pstate, MinMaxExpr *m)
17541762
staticNode*
17551763
transformXmlExpr(ParseState*pstate,XmlExpr*x)
17561764
{
1757-
XmlExpr*newx=makeNode(XmlExpr);
1765+
XmlExpr*newx;
17581766
ListCell*lc;
17591767
inti;
17601768

1769+
/* If we already transformed this node, do nothing */
1770+
if (OidIsValid(x->type))
1771+
return (Node*)x;
1772+
1773+
newx=makeNode(XmlExpr);
17611774
newx->op=x->op;
17621775
if (x->name)
17631776
newx->name=map_sql_identifier_to_xml_name(x->name, false, false);
17641777
else
17651778
newx->name=NULL;
17661779
newx->xmloption=x->xmloption;
1780+
newx->type=XMLOID;/* this just marks the node as transformed */
1781+
newx->typmod=-1;
17671782
newx->location=x->location;
17681783

17691784
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp