diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-06-17 14:51:32 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-06-17 14:51:32 +0000 |
commit | 2e835a4961eab760d1b08aeebd40a755d507999f (patch) | |
tree | 74c89c85e3160e38893f674228fc184dbf739f43 /src | |
parent | 19a6bace9480bc51d61d87a8497b05b5c1ea04c1 (diff) | |
download | postgresql-2e835a4961eab760d1b08aeebd40a755d507999f.tar.gz postgresql-2e835a4961eab760d1b08aeebd40a755d507999f.zip |
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 OID
constants too, because eval_const_expressions folds a RelabelType atop a Const
to just a Const. This change could result in OID values that aren't really
for tables getting added to the dependency list, but the worst-case
consequence would be occasional useless replans. Per report from Gabriele
Messineo.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/optimizer/plan/setrefs.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c index 48331822a47..7bcbabd1010 100644 --- a/src/backend/optimizer/plan/setrefs.c +++ b/src/backend/optimizer/plan/setrefs.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/setrefs.c,v 1.141 2008/01/01 19:45:50 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/setrefs.c,v 1.142 2008/06/17 14:51:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -63,6 +63,17 @@ typedef struct int rtoffset; } fix_upper_expr_context; +/* + * Check if a Const node is a regclass value. We accept plain OID too, + * since a regclass Const will get folded to that type if it's an argument + * to oideq or similar operators. (This might result in some extraneous + * values in a plan's list of relation dependencies, but the worst result + * would be occasional useless replans.) + */ +#define ISREGCLASSCONST(con) \ + (((con)->consttype == REGCLASSOID || (con)->consttype == OIDOID) && \ + !(con)->constisnull) + #define fix_scan_list(glob, lst, rtoffset) \ ((List *) fix_scan_expr(glob, (Node *) (lst), rtoffset)) @@ -694,7 +705,7 @@ fix_scan_expr_mutator(Node *node, fix_scan_expr_context *context) Const *con = (Const *) node; /* Check for regclass reference */ - if (con->consttype == REGCLASSOID && !con->constisnull) + if (ISREGCLASSCONST(con)) context->glob->relationOids = lappend_oid(context->glob->relationOids, DatumGetObjectId(con->constvalue)); @@ -722,7 +733,7 @@ fix_scan_expr_walker(Node *node, fix_scan_expr_context *context) Const *con = (Const *) node; /* Check for regclass reference */ - if (con->consttype == REGCLASSOID && !con->constisnull) + if (ISREGCLASSCONST(con)) context->glob->relationOids = lappend_oid(context->glob->relationOids, DatumGetObjectId(con->constvalue)); @@ -1391,7 +1402,7 @@ fix_join_expr_mutator(Node *node, fix_join_expr_context *context) Const *con = (Const *) node; /* Check for regclass reference */ - if (con->consttype == REGCLASSOID && !con->constisnull) + if (ISREGCLASSCONST(con)) context->glob->relationOids = lappend_oid(context->glob->relationOids, DatumGetObjectId(con->constvalue)); @@ -1489,7 +1500,7 @@ fix_upper_expr_mutator(Node *node, fix_upper_expr_context *context) Const *con = (Const *) node; /* Check for regclass reference */ - if (con->consttype == REGCLASSOID && !con->constisnull) + if (ISREGCLASSCONST(con)) context->glob->relationOids = lappend_oid(context->glob->relationOids, DatumGetObjectId(con->constvalue)); |