summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorTom Lane2007-10-11 18:05:27 +0000
committerTom Lane2007-10-11 18:05:27 +0000
commit82d8ab6fc4c1a0330c91022728e1e766db207069 (patch)
tree0bd9635d34da6c964d37fd4a725ead26a9a7340d /src/test
parent68b08b251239e9ec883156b0cba53316c88adb5f (diff)
Fix the plan-invalidation mechanism to treat regclass constants that refer to
a relation as a reason to invalidate a plan when the relation changes. This handles scenarios such as dropping/recreating a sequence that is referenced by nextval('seq') in a cached plan. Rather than teach plancache.c all about digging through plan trees to find regclass Consts, we charge the planner's setrefs.c with making a list of the relation OIDs on which each plan depends. That way the list can be built cheaply during a plan tree traversal that has to happen anyway. Per bug #3662 and subsequent discussion.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/plancache.out17
-rw-r--r--src/test/regress/sql/plancache.sql14
2 files changed, 31 insertions, 0 deletions
diff --git a/src/test/regress/expected/plancache.out b/src/test/regress/expected/plancache.out
index a96ba2a5da..d7d7be9252 100644
--- a/src/test/regress/expected/plancache.out
+++ b/src/test/regress/expected/plancache.out
@@ -202,3 +202,20 @@ drop schema s1 cascade;
NOTICE: drop cascades to table s1.abc
drop schema s2 cascade;
NOTICE: drop cascades to table abc
+-- Check that invalidation deals with regclass constants
+create temp sequence seq;
+prepare p2 as select nextval('seq');
+execute p2;
+ nextval
+---------
+ 1
+(1 row)
+
+drop sequence seq;
+create temp sequence seq;
+execute p2;
+ nextval
+---------
+ 1
+(1 row)
+
diff --git a/src/test/regress/sql/plancache.sql b/src/test/regress/sql/plancache.sql
index e285c071f6..fc57279d98 100644
--- a/src/test/regress/sql/plancache.sql
+++ b/src/test/regress/sql/plancache.sql
@@ -123,3 +123,17 @@ execute p1;
drop schema s1 cascade;
drop schema s2 cascade;
+
+-- Check that invalidation deals with regclass constants
+
+create temp sequence seq;
+
+prepare p2 as select nextval('seq');
+
+execute p2;
+
+drop sequence seq;
+
+create temp sequence seq;
+
+execute p2;