summaryrefslogtreecommitdiff
path: root/src/test/regress
diff options
context:
space:
mode:
authorTom Lane2013-01-25 19:14:41 +0000
committerTom Lane2013-01-25 19:14:41 +0000
commit0d5fbdc157a17abc379052f5099b1c29a33cebe2 (patch)
treea0ebf81dc1b3770310ab3d503df81156512aaf7b /src/test/regress
parentd309be0fb7246cc2ebfbdcb2e4781f956c0d7d12 (diff)
Change plan caching to honor, not resist, changes in search_path.
In the initial implementation of plan caching, we saved the active search_path when a plan was first cached, then reinstalled that path anytime we needed to reparse or replan. The idea of that was to try to reselect the same referenced objects, in somewhat the same way that views continue to refer to the same objects in the face of schema or name changes. Of course, that analogy doesn't bear close inspection, since holding the search_path fixed doesn't cope with object drops or renames. Moreover sticking with the old path seems to create more surprises than it avoids. So instead of doing that, consider that the cached plan depends on search_path, and force reparse/replan if the active search_path is different than it was when we last saved the plan. This gets us fairly close to having "transparency" of plan caching, in the sense that the cached statement acts the same as if you'd just resubmitted the original query text for another execution. There are still some corner cases where this fails though: a new object added in the search path schema(s) might capture a reference in the query text, but we'd not realize that and force a reparse. We might try to fix that in the future, but for the moment it looks too expensive and complicated.
Diffstat (limited to 'src/test/regress')
-rw-r--r--src/test/regress/expected/plancache.out6
-rw-r--r--src/test/regress/sql/plancache.sql2
2 files changed, 4 insertions, 4 deletions
diff --git a/src/test/regress/expected/plancache.out b/src/test/regress/expected/plancache.out
index f0aa102334b..864f70f7b54 100644
--- a/src/test/regress/expected/plancache.out
+++ b/src/test/regress/expected/plancache.out
@@ -163,7 +163,7 @@ select cache_test_2();
10007
(1 row)
---- Check that change of search_path is ignored by replans
+--- Check that change of search_path is honored when re-using cached plan
create schema s1
create table abc (f1 int);
create schema s2
@@ -188,14 +188,14 @@ select f1 from abc;
execute p1;
f1
-----
- 123
+ 456
(1 row)
alter table s1.abc add column f2 float8; -- force replan
execute p1;
f1
-----
- 123
+ 456
(1 row)
drop schema s1 cascade;
diff --git a/src/test/regress/sql/plancache.sql b/src/test/regress/sql/plancache.sql
index 26848168f06..bc2086166b9 100644
--- a/src/test/regress/sql/plancache.sql
+++ b/src/test/regress/sql/plancache.sql
@@ -94,7 +94,7 @@ 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
+--- Check that change of search_path is honored when re-using cached plan
create schema s1
create table abc (f1 int);