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

Commit2e835a4

Browse files
committed
Fix the code that adds regclass constants to a plan's list of relation OIDs
that it depends on for replan-forcing purposes. We need to consider plain OIDconstants too, because eval_const_expressions folds a RelabelType atop a Constto just a Const. This change could result in OID values that aren't reallyfor tables getting added to the dependency list, but the worst-caseconsequence would be occasional useless replans. Per report from GabrieleMessineo.
1 parent19a6bac commit2e835a4

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

‎src/backend/optimizer/plan/setrefs.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/optimizer/plan/setrefs.c,v 1.141 2008/01/01 19:45:50 momjian Exp $
12+
* $PostgreSQL: pgsql/src/backend/optimizer/plan/setrefs.c,v 1.142 2008/06/17 14:51:32 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -63,6 +63,17 @@ typedef struct
6363
intrtoffset;
6464
}fix_upper_expr_context;
6565

66+
/*
67+
* Check if a Const node is a regclass value. We accept plain OID too,
68+
* since a regclass Const will get folded to that type if it's an argument
69+
* to oideq or similar operators. (This might result in some extraneous
70+
* values in a plan's list of relation dependencies, but the worst result
71+
* would be occasional useless replans.)
72+
*/
73+
#defineISREGCLASSCONST(con) \
74+
(((con)->consttype == REGCLASSOID || (con)->consttype == OIDOID) && \
75+
!(con)->constisnull)
76+
6677
#definefix_scan_list(glob,lst,rtoffset) \
6778
((List *) fix_scan_expr(glob, (Node *) (lst), rtoffset))
6879

@@ -694,7 +705,7 @@ fix_scan_expr_mutator(Node *node, fix_scan_expr_context *context)
694705
Const*con= (Const*)node;
695706

696707
/* Check for regclass reference */
697-
if (con->consttype==REGCLASSOID&& !con->constisnull)
708+
if (ISREGCLASSCONST(con))
698709
context->glob->relationOids=
699710
lappend_oid(context->glob->relationOids,
700711
DatumGetObjectId(con->constvalue));
@@ -722,7 +733,7 @@ fix_scan_expr_walker(Node *node, fix_scan_expr_context *context)
722733
Const*con= (Const*)node;
723734

724735
/* Check for regclass reference */
725-
if (con->consttype==REGCLASSOID&& !con->constisnull)
736+
if (ISREGCLASSCONST(con))
726737
context->glob->relationOids=
727738
lappend_oid(context->glob->relationOids,
728739
DatumGetObjectId(con->constvalue));
@@ -1391,7 +1402,7 @@ fix_join_expr_mutator(Node *node, fix_join_expr_context *context)
13911402
Const*con= (Const*)node;
13921403

13931404
/* Check for regclass reference */
1394-
if (con->consttype==REGCLASSOID&& !con->constisnull)
1405+
if (ISREGCLASSCONST(con))
13951406
context->glob->relationOids=
13961407
lappend_oid(context->glob->relationOids,
13971408
DatumGetObjectId(con->constvalue));
@@ -1489,7 +1500,7 @@ fix_upper_expr_mutator(Node *node, fix_upper_expr_context *context)
14891500
Const*con= (Const*)node;
14901501

14911502
/* Check for regclass reference */
1492-
if (con->consttype==REGCLASSOID&& !con->constisnull)
1503+
if (ISREGCLASSCONST(con))
14931504
context->glob->relationOids=
14941505
lappend_oid(context->glob->relationOids,
14951506
DatumGetObjectId(con->constvalue));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp