*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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))
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));
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));
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));
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));