* procedural language
*
* 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.
*
/*
* 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.
*/
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
*/
-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);
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);