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.
This commit is contained in:
parent
c21c658b36
commit
96b42de9a8
@ -3,7 +3,7 @@
|
|||||||
* procedural language
|
* procedural language
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.125 2004/12/19 20:20:17 tgl Exp $
|
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.126 2004/12/21 18:33:35 tgl Exp $
|
||||||
*
|
*
|
||||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||||
*
|
*
|
||||||
@ -3631,7 +3631,7 @@ exec_eval_simple_expr(PLpgSQL_execstate *estate,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* We have to do some of the things SPI_execute_plan would do,
|
* 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
|
* function. Without this, stable functions within the expression
|
||||||
* would fail to see updates made so far by our own function.
|
* 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);
|
oldcontext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
|
||||||
if (!estate->readonly_func)
|
if (!estate->readonly_func)
|
||||||
|
{
|
||||||
|
CommandCounterIncrement();
|
||||||
ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
|
ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Finally we can call the executor to evaluate the expression
|
* Finally we can call the executor to evaluate the expression
|
||||||
*/
|
*/
|
||||||
|
@ -2089,5 +2089,17 @@ select sp_add_user('user2');
|
|||||||
-1
|
-1
|
||||||
(1 row)
|
(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_add_user(text);
|
||||||
drop function sp_id_user(text);
|
drop function sp_id_user(text);
|
||||||
|
@ -1802,6 +1802,8 @@ end$$ language plpgsql;
|
|||||||
select sp_add_user('user1');
|
select sp_add_user('user1');
|
||||||
select sp_add_user('user2');
|
select sp_add_user('user2');
|
||||||
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_add_user(text);
|
||||||
drop function sp_id_user(text);
|
drop function sp_id_user(text);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user