summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorTom Lane2007-03-23 19:53:52 +0000
committerTom Lane2007-03-23 19:53:52 +0000
commit547b6e537aa8bbae83a8a4c4d0d7f216390bdb9c (patch)
tree0a8e84561de60017cdbcb2080aa444706c1af404 /src/test
parent4c35ec53a9e8e9c5496b2e33c6b568c0cfbdb7e3 (diff)
Fix plancache so that any required replanning is done with the same
search_path that was active when the plan was first made. To do this, improve namespace.c to support a stack of "override" search path settings (we must have a stack since nested replan events are entirely possible). This facility replaces the "special namespace" hack formerly used by CREATE SCHEMA, and should be able to support per-function search path settings as well.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/plancache.out39
-rw-r--r--src/test/regress/sql/plancache.sql30
2 files changed, 69 insertions, 0 deletions
diff --git a/src/test/regress/expected/plancache.out b/src/test/regress/expected/plancache.out
index c38a06f123..a96ba2a5da 100644
--- a/src/test/regress/expected/plancache.out
+++ b/src/test/regress/expected/plancache.out
@@ -163,3 +163,42 @@ select cache_test_2();
10007
(1 row)
+--- Check that change of search_path is ignored by replans
+create schema s1
+ create table abc (f1 int);
+create schema s2
+ create table abc (f1 int);
+insert into s1.abc values(123);
+insert into s2.abc values(456);
+set search_path = s1;
+prepare p1 as select f1 from abc;
+execute p1;
+ f1
+-----
+ 123
+(1 row)
+
+set search_path = s2;
+select f1 from abc;
+ f1
+-----
+ 456
+(1 row)
+
+execute p1;
+ f1
+-----
+ 123
+(1 row)
+
+alter table s1.abc add column f2 float8; -- force replan
+execute p1;
+ f1
+-----
+ 123
+(1 row)
+
+drop schema s1 cascade;
+NOTICE: drop cascades to table s1.abc
+drop schema s2 cascade;
+NOTICE: drop cascades to table abc
diff --git a/src/test/regress/sql/plancache.sql b/src/test/regress/sql/plancache.sql
index f984a2e54f..e285c071f6 100644
--- a/src/test/regress/sql/plancache.sql
+++ b/src/test/regress/sql/plancache.sql
@@ -93,3 +93,33 @@ select cache_test_2();
create or replace temp view v1 as
select 2+2+4+(select max(unique1) from tenk1) as f1;
select cache_test_2();
+
+--- Check that change of search_path is ignored by replans
+
+create schema s1
+ create table abc (f1 int);
+
+create schema s2
+ create table abc (f1 int);
+
+insert into s1.abc values(123);
+insert into s2.abc values(456);
+
+set search_path = s1;
+
+prepare p1 as select f1 from abc;
+
+execute p1;
+
+set search_path = s2;
+
+select f1 from abc;
+
+execute p1;
+
+alter table s1.abc add column f2 float8; -- force replan
+
+execute p1;
+
+drop schema s1 cascade;
+drop schema s2 cascade;