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

Commitdb1071d

Browse files
committed
Fix some minor issues exposed by outfuncs/readfuncs testing.
A test patch to pass parse and plan trees through outfuncs + readfuncsexposed several issues that need to be fixed to get clean matches:Query.withCheckOptions failed to get copied; it's intentionally ignoredby outfuncs/readfuncs on the grounds that it'd always be NIL anyway instored rules. This seems less than future-proof, and it's not evensaving very much, so just undo the decision and treat the field likeall others.Several places that convert a view RTE into a subquery RTE, or similarmanipulations, failed to clear out fields that were specific to theoriginal RTE type and should be zero in a subquery RTE. Since readfuncs.cwill leave such fields as zero, equalfuncs.c thinks the nodes are differentleading to a reported mismatch. It seems like a good idea to clear out theno-longer-needed fields, even though in principle nothing should look atthem; the node ought to be indistinguishable from how it would look ifwe'd built a new node instead of scribbling on the old one.BuildOnConflictExcludedTargetlist randomly set the resname of someTargetEntries to "" not NULL. outfuncs/readfuncs don't distinguish thosecases, and so the string will read back in as NULL ... but equalfuncs.cdoes distinguish. Perhaps we ought to try to make things more consistentin this area --- but it's just useless extra code space forBuildOnConflictExcludedTargetlist to not use NULL here, so I fixed it fornow by making it do that.catversion bumped because the change in handling of Query.withCheckOptionsaffects stored rules.Discussion:https://postgr.es/m/17114.1537138992@sss.pgh.pa.us
1 parent09991e5 commitdb1071d

File tree

7 files changed

+17
-12
lines changed

7 files changed

+17
-12
lines changed

‎src/backend/nodes/outfuncs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3003,7 +3003,7 @@ _outQuery(StringInfo str, const Query *node)
30033003
WRITE_NODE_FIELD(rowMarks);
30043004
WRITE_NODE_FIELD(setOperations);
30053005
WRITE_NODE_FIELD(constraintDeps);
3006-
/*withCheckOptions intentionally omitted, see comment in parsenodes.h */
3006+
WRITE_NODE_FIELD(withCheckOptions);
30073007
WRITE_LOCATION_FIELD(stmt_location);
30083008
WRITE_LOCATION_FIELD(stmt_len);
30093009
}

‎src/backend/nodes/readfuncs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ _readQuery(void)
269269
READ_NODE_FIELD(rowMarks);
270270
READ_NODE_FIELD(setOperations);
271271
READ_NODE_FIELD(constraintDeps);
272-
/*withCheckOptions intentionally omitted, see comment in parsenodes.h */
272+
READ_NODE_FIELD(withCheckOptions);
273273
READ_LOCATION_FIELD(stmt_location);
274274
READ_LOCATION_FIELD(stmt_len);
275275

‎src/backend/optimizer/prep/prepjointree.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,10 +586,13 @@ inline_set_returning_functions(PlannerInfo *root)
586586
funcquery=inline_set_returning_function(root,rte);
587587
if (funcquery)
588588
{
589-
/* Successful expansion,replace thertable entry */
589+
/* Successful expansion,convert theRTE to a subquery */
590590
rte->rtekind=RTE_SUBQUERY;
591591
rte->subquery=funcquery;
592+
rte->security_barrier= false;
593+
/* Clear fields that should not be set in a subquery RTE */
592594
rte->functions=NIL;
595+
rte->funcordinality= false;
593596
}
594597
}
595598
}

‎src/backend/parser/analyze.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ BuildOnConflictExcludedTargetlist(Relation targetrel,
11161116
* the Const claims to be.
11171117
*/
11181118
var= (Var*)makeNullConst(INT4OID,-1,InvalidOid);
1119-
name="";
1119+
name=NULL;
11201120
}
11211121
else
11221122
{

‎src/backend/rewrite/rewriteHandler.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,15 +1582,18 @@ ApplyRetrieveRule(Query *parsetree,
15821582
rule_action=fireRIRrules(rule_action,activeRIRs);
15831583

15841584
/*
1585-
* Now, plug the view query in as a subselect,replacing the relation's
1586-
* original RTE.
1585+
* Now, plug the view query in as a subselect,converting the relation's
1586+
* original RTE to a subquery RTE.
15871587
*/
15881588
rte=rt_fetch(rt_index,parsetree->rtable);
15891589

15901590
rte->rtekind=RTE_SUBQUERY;
1591-
rte->relid=InvalidOid;
1592-
rte->security_barrier=RelationIsSecurityView(relation);
15931591
rte->subquery=rule_action;
1592+
rte->security_barrier=RelationIsSecurityView(relation);
1593+
/* Clear fields that should not be set in a subquery RTE */
1594+
rte->relid=InvalidOid;
1595+
rte->relkind=0;
1596+
rte->tablesample=NULL;
15941597
rte->inh= false;/* must not be set for a subquery */
15951598

15961599
/*

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO201809052
56+
#defineCATALOG_VERSION_NO201809181
5757

5858
#endif

‎src/include/nodes/parsenodes.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,8 @@ typedef struct Query
168168
List*constraintDeps;/* a list of pg_constraint OIDs that the query
169169
* depends on to be semantically valid */
170170

171-
List*withCheckOptions;/* a list of WithCheckOption's, which are
172-
* only added during rewrite and therefore
173-
* are not written out as part of Query. */
171+
List*withCheckOptions;/* a list of WithCheckOption's (added
172+
* during rewrite) */
174173

175174
/*
176175
* The following two fields identify the portion of the source text string

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp