|
7 | 7 | * |
8 | 8 | * |
9 | 9 | * IDENTIFICATION |
10 | | - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.91 2001/03/22 06:16:16 momjian Exp $ |
| 10 | + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.92 2001/04/17 00:32:58 tgl Exp $ |
11 | 11 | * |
12 | 12 | *------------------------------------------------------------------------- |
13 | 13 | */ |
@@ -486,16 +486,25 @@ fireRIRrules(Query *parsetree) |
486 | 486 |
|
487 | 487 | rel = heap_openr(rte->relname, lockmode); |
488 | 488 |
|
| 489 | + /* |
| 490 | + * Check to see if relation's OID matches the RTE. If not, the RTE |
| 491 | + * actually refers to an older relation that had the same name. |
| 492 | + * Eventually we might want to reparse the referencing rule, but |
| 493 | + * for now all we can do is punt. |
| 494 | + */ |
| 495 | + if (RelationGetRelid(rel) != rte->relid) |
| 496 | + elog(ERROR, "Relation \"%s\" with OID %u no longer exists", |
| 497 | + rte->relname, rte->relid); |
| 498 | + |
| 499 | + /* |
| 500 | + * Collect the RIR rules that we must apply |
| 501 | + */ |
489 | 502 | rules = rel->rd_rules; |
490 | 503 | if (rules == NULL) |
491 | 504 | { |
492 | 505 | heap_close(rel, NoLock); |
493 | 506 | continue; |
494 | 507 | } |
495 | | - |
496 | | - /* |
497 | | - * Collect the RIR rules that we must apply |
498 | | - */ |
499 | 508 | locks = NIL; |
500 | 509 | for (i = 0; i < rules->numLocks; i++) |
501 | 510 | { |
@@ -776,6 +785,19 @@ RewriteQuery(Query *parsetree, bool *instead_flag, List **qual_products) |
776 | 785 | */ |
777 | 786 | rt_entry_relation = heap_openr(rt_entry->relname, RowExclusiveLock); |
778 | 787 |
|
| 788 | + /* |
| 789 | + * Check to see if relation's OID matches the RTE. If not, the RTE |
| 790 | + * actually refers to an older relation that had the same name. |
| 791 | + * Eventually we might want to reparse the referencing rule, but |
| 792 | + * for now all we can do is punt. |
| 793 | + */ |
| 794 | + if (RelationGetRelid(rt_entry_relation) != rt_entry->relid) |
| 795 | + elog(ERROR, "Relation \"%s\" with OID %u no longer exists", |
| 796 | + rt_entry->relname, rt_entry->relid); |
| 797 | + |
| 798 | + /* |
| 799 | + * Collect and apply the appropriate rules. |
| 800 | + */ |
779 | 801 | rt_entry_locks = rt_entry_relation->rd_rules; |
780 | 802 |
|
781 | 803 | if (rt_entry_locks != NULL) |
|
0 commit comments