|
9 | 9 | * |
10 | 10 | * |
11 | 11 | * 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 $ |
13 | 13 | * |
14 | 14 | *------------------------------------------------------------------------- |
15 | 15 | */ |
@@ -63,6 +63,17 @@ typedef struct |
63 | 63 | intrtoffset; |
64 | 64 | }fix_upper_expr_context; |
65 | 65 |
|
| 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 | + |
66 | 77 | #definefix_scan_list(glob,lst,rtoffset) \ |
67 | 78 | ((List *) fix_scan_expr(glob, (Node *) (lst), rtoffset)) |
68 | 79 |
|
@@ -694,7 +705,7 @@ fix_scan_expr_mutator(Node *node, fix_scan_expr_context *context) |
694 | 705 | Const*con= (Const*)node; |
695 | 706 |
|
696 | 707 | /* Check for regclass reference */ |
697 | | -if (con->consttype==REGCLASSOID&& !con->constisnull) |
| 708 | +if (ISREGCLASSCONST(con)) |
698 | 709 | context->glob->relationOids= |
699 | 710 | lappend_oid(context->glob->relationOids, |
700 | 711 | DatumGetObjectId(con->constvalue)); |
@@ -722,7 +733,7 @@ fix_scan_expr_walker(Node *node, fix_scan_expr_context *context) |
722 | 733 | Const*con= (Const*)node; |
723 | 734 |
|
724 | 735 | /* Check for regclass reference */ |
725 | | -if (con->consttype==REGCLASSOID&& !con->constisnull) |
| 736 | +if (ISREGCLASSCONST(con)) |
726 | 737 | context->glob->relationOids= |
727 | 738 | lappend_oid(context->glob->relationOids, |
728 | 739 | DatumGetObjectId(con->constvalue)); |
@@ -1391,7 +1402,7 @@ fix_join_expr_mutator(Node *node, fix_join_expr_context *context) |
1391 | 1402 | Const*con= (Const*)node; |
1392 | 1403 |
|
1393 | 1404 | /* Check for regclass reference */ |
1394 | | -if (con->consttype==REGCLASSOID&& !con->constisnull) |
| 1405 | +if (ISREGCLASSCONST(con)) |
1395 | 1406 | context->glob->relationOids= |
1396 | 1407 | lappend_oid(context->glob->relationOids, |
1397 | 1408 | DatumGetObjectId(con->constvalue)); |
@@ -1489,7 +1500,7 @@ fix_upper_expr_mutator(Node *node, fix_upper_expr_context *context) |
1489 | 1500 | Const*con= (Const*)node; |
1490 | 1501 |
|
1491 | 1502 | /* Check for regclass reference */ |
1492 | | -if (con->consttype==REGCLASSOID&& !con->constisnull) |
| 1503 | +if (ISREGCLASSCONST(con)) |
1493 | 1504 | context->glob->relationOids= |
1494 | 1505 | lappend_oid(context->glob->relationOids, |
1495 | 1506 | DatumGetObjectId(con->constvalue)); |
|