Hi all,
I'm testing now RC2 against our application and I'm experiencing
intermittent errors. I isolated this test:
CREATE TABLE users (id_login SERIAL PRIMARY KEY, login TEXT
);
CREATE OR REPLACE FUNCTION sp_id_user ( TEXT )
RETURNS INTEGER AS $$
DECLARE a_login ALIAS FOR $1; my_id INTEGER;
BEGIN SELECT id_login INTO my_id FROM users WHERE login = a_login;
RETURN COALESCE(my_id, -1 );
END;
$$ LANGUAGE 'plpgsql'
STABLE;
CREATE OR REPLACE FUNCTION sp_test ( TEXT )
RETURNS INTEGER AS $$
DECLARE a_login ALIAS FOR $1; my_id INTEGER;
BEGIN my_id = sp_id_user( a_login ); RAISE NOTICE 'ID> %', my_id;
insert into users (login) values ( a_login );
my_id = sp_id_user( a_login ); RAISE NOTICE 'ID> %', my_id;
RETURN 0;
END;
$$ LANGUAGE 'plpgsql';
select sp_test('test1');
select sp_test('test2');
The call of the two above functions shall show:
ID> -1
ID> 1
ID> -1
ID> 2
instead I have:
test=# select sp_test('test1');
NOTICE: ID> -1
NOTICE: ID> 1 sp_test
--------- 0
(1 row)
test=# select sp_test('test2');
NOTICE: ID> -1
NOTICE: ID> -1 sp_test
--------- 0
(1 row)
some times I get:
test=# select sp_test('test1');
NOTICE: ID> -1
NOTICE: ID> -1 sp_test
--------- 0
(1 row)
test=# select sp_test('test2');
NOTICE: ID> -1
NOTICE: ID> -1 sp_test
--------- 0
(1 row)
Regards
Gaetano Mendola