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

Commitc273e8b

Browse files
committed
Add some defenses to guard against case where a rule refers to a table
or view that's been dropped and then recreated with the same name (but,perhaps, different columns). Eventually we'd like to support this butfor now all we can do is fail cleanly, rather than possibly coredumpingif we proceed using the obsolete rule.
1 parentcdcaec5 commitc273e8b

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

‎src/backend/rewrite/rewriteHandler.c

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* 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 $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -486,16 +486,25 @@ fireRIRrules(Query *parsetree)
486486

487487
rel=heap_openr(rte->relname,lockmode);
488488

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+
*/
489502
rules=rel->rd_rules;
490503
if (rules==NULL)
491504
{
492505
heap_close(rel,NoLock);
493506
continue;
494507
}
495-
496-
/*
497-
* Collect the RIR rules that we must apply
498-
*/
499508
locks=NIL;
500509
for (i=0;i<rules->numLocks;i++)
501510
{
@@ -776,6 +785,19 @@ RewriteQuery(Query *parsetree, bool *instead_flag, List **qual_products)
776785
*/
777786
rt_entry_relation=heap_openr(rt_entry->relname,RowExclusiveLock);
778787

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+
*/
779801
rt_entry_locks=rt_entry_relation->rd_rules;
780802

781803
if (rt_entry_locks!=NULL)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp