Two updates problem - Mailing list pgsql-general

From Yuri B. Lukyanov
Subject Two updates problem
Date
Msg-id 441354239.20050608213117@ulstu.ru
Whole thread Raw
Responses Strange transaction-id behaviour? (was Re: Two updates problem)  (Richard Huxton <dev@archonet.com>)
List pgsql-general
I have table:

--------------------------------------------
CREATE TABLE "public"."test" (
  "id" INTEGER,
  "text1" VARCHAR(25),
  "text2" VARCHAR(25)
) WITH OIDS;
INSERT INTO test VALUES (1, 'qwerty', '111');
INSERT INTO test VALUES (2, 'asdfgh', '222');
--------------------------------------------

and function:

--------------------------------------------
CREATE OR REPLACE FUNCTION "public"."test1" () RETURNS integer AS
$body$
BEGIN
   UPDATE test SET text1='qqq' WHERE id = 2;
RETURN 2;
END;
$body$
LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;
--------------------------------------------

When I do
SELECT test1();
it works fine and return "2".

But this thing don't work:
UPDATE test SET text2='test' WHERE id = (SELECT test1());
(rows affected: 0)

Why? There is two updates on the same row, but work only first update
(in the function). Maybe it's bug?

P.S.:
I'm using PostgreSQL 8.0.1 on Win32.
Sorry for my english.

___________________________________
Best regards, Yuri B. Lukyanov
7 июня 2005 г. 22:49:28
mailto:snaky@ulstu.ru


pgsql-general by date:

Previous
From: dong changyu
Date:
Subject: Re: vulnerability/SSL
Next
From: Dan Black
Date:
Subject: Re: Foreign keys and slow insert