diff options
author | Tom Lane | 2004-12-21 18:33:36 +0000 |
---|---|---|
committer | Tom Lane | 2004-12-21 18:33:36 +0000 |
commit | ce8f15f67bf26d02e77d6f6a8d57fa1558964356 (patch) | |
tree | 2c5aaac20a7887e4b2d5a637dfed094137885299 | |
parent | d3a063de974472ea5ddc88547d7567f794eb20f3 (diff) |
exec_eval_simple_expr() needs to do CommandCounterIncrement() not just
GetTransactionSnapshot() to ensure ActiveSnapshot advances properly.
Sigh. Extend regression test so it reveals this error too.
-rw-r--r-- | src/pl/plpgsql/src/pl_exec.c | 6 | ||||
-rw-r--r-- | src/test/regress/expected/plpgsql.out | 12 | ||||
-rw-r--r-- | src/test/regress/sql/plpgsql.sql | 2 |
3 files changed, 19 insertions, 1 deletions
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index f14b24056a..d81da83747 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -3631,7 +3631,7 @@ exec_eval_simple_expr(PLpgSQL_execstate *estate, /* * We have to do some of the things SPI_execute_plan would do, - * in particular adjust ActiveSnapshot if we are in a non-read-only + * in particular advance the snapshot if we are in a non-read-only * function. Without this, stable functions within the expression * would fail to see updates made so far by our own function. */ @@ -3644,7 +3644,11 @@ exec_eval_simple_expr(PLpgSQL_execstate *estate, oldcontext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory); if (!estate->readonly_func) + { + CommandCounterIncrement(); ActiveSnapshot = CopySnapshot(GetTransactionSnapshot()); + } + /* * Finally we can call the executor to evaluate the expression */ diff --git a/src/test/regress/expected/plpgsql.out b/src/test/regress/expected/plpgsql.out index 1f11bbb75c..10df82cfc2 100644 --- a/src/test/regress/expected/plpgsql.out +++ b/src/test/regress/expected/plpgsql.out @@ -2089,5 +2089,17 @@ select sp_add_user('user2'); -1 (1 row) +select sp_add_user('user3'); + sp_add_user +------------- + 3 +(1 row) + +select sp_add_user('user3'); + sp_add_user +------------- + -1 +(1 row) + drop function sp_add_user(text); drop function sp_id_user(text); diff --git a/src/test/regress/sql/plpgsql.sql b/src/test/regress/sql/plpgsql.sql index 48618b9508..62aa354347 100644 --- a/src/test/regress/sql/plpgsql.sql +++ b/src/test/regress/sql/plpgsql.sql @@ -1802,6 +1802,8 @@ end$$ language plpgsql; select sp_add_user('user1'); select sp_add_user('user2'); select sp_add_user('user2'); +select sp_add_user('user3'); +select sp_add_user('user3'); drop function sp_add_user(text); drop function sp_id_user(text); |