diff options
| author | Tom Lane | 2007-11-30 18:38:34 +0000 |
|---|---|---|
| committer | Tom Lane | 2007-11-30 18:38:34 +0000 |
| commit | f0f18c7087e04a60e2612151401b07df87e51d96 (patch) | |
| tree | 37900cb71cee0dcbdb5f7b38157247cc81309c52 /src/test | |
| parent | 7c43106db263a7b54737bc576bb72caea8258a61 (diff) | |
Repair bug that allowed RevalidateCachedPlan to attempt to rebuild a cached
plan before the effects of DDL executed in an immediately prior SPI operation
had been absorbed. Per report from Chris Wood.
This patch has an unpleasant side effect of causing the number of
CommandCounterIncrement()s done by a typical plpgsql function to
approximately double. Amelioration of the consequences of that
will be undertaken in a separate patch.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/plancache.out | 40 | ||||
| -rw-r--r-- | src/test/regress/sql/plancache.sql | 19 |
2 files changed, 59 insertions, 0 deletions
diff --git a/src/test/regress/expected/plancache.out b/src/test/regress/expected/plancache.out index d7d7be92529..7ee11921c25 100644 --- a/src/test/regress/expected/plancache.out +++ b/src/test/regress/expected/plancache.out @@ -202,6 +202,7 @@ drop schema s1 cascade; NOTICE: drop cascades to table s1.abc drop schema s2 cascade; NOTICE: drop cascades to table abc +reset search_path; -- Check that invalidation deals with regclass constants create temp sequence seq; prepare p2 as select nextval('seq'); @@ -219,3 +220,42 @@ execute p2; 1 (1 row) +-- Check DDL via SPI, immediately followed by SPI plan re-use +-- (bug in original coding) +create function cachebug() returns void as $$ +declare r int; +begin + drop table if exists temptable cascade; + create temp table temptable as select * from generate_series(1,3) as f1; + create temp view vv as select * from temptable; + for r in select * from vv loop + raise notice '%', r; + end loop; +end$$ language plpgsql; +select cachebug(); +NOTICE: table "temptable" does not exist, skipping +CONTEXT: SQL statement "drop table if exists temptable cascade" +PL/pgSQL function "cachebug" line 3 at SQL statement +NOTICE: 1 +NOTICE: 2 +NOTICE: 3 + cachebug +---------- + +(1 row) + +select cachebug(); +NOTICE: drop cascades to rule _RETURN on view vv +CONTEXT: SQL statement "drop table if exists temptable cascade" +PL/pgSQL function "cachebug" line 3 at SQL statement +NOTICE: drop cascades to view vv +CONTEXT: SQL statement "drop table if exists temptable cascade" +PL/pgSQL function "cachebug" line 3 at SQL statement +NOTICE: 1 +NOTICE: 2 +NOTICE: 3 + cachebug +---------- + +(1 row) + diff --git a/src/test/regress/sql/plancache.sql b/src/test/regress/sql/plancache.sql index fc57279d985..26848168f06 100644 --- a/src/test/regress/sql/plancache.sql +++ b/src/test/regress/sql/plancache.sql @@ -124,6 +124,8 @@ execute p1; drop schema s1 cascade; drop schema s2 cascade; +reset search_path; + -- Check that invalidation deals with regclass constants create temp sequence seq; @@ -137,3 +139,20 @@ drop sequence seq; create temp sequence seq; execute p2; + +-- Check DDL via SPI, immediately followed by SPI plan re-use +-- (bug in original coding) + +create function cachebug() returns void as $$ +declare r int; +begin + drop table if exists temptable cascade; + create temp table temptable as select * from generate_series(1,3) as f1; + create temp view vv as select * from temptable; + for r in select * from vv loop + raise notice '%', r; + end loop; +end$$ language plpgsql; + +select cachebug(); +select cachebug(); |
