Two updates problem

From: "Yuri B(dot) Lukyanov" <snaky(at)ulstu(dot)ru>
To: pgsql-general(at)postgresql(dot)org
Subject: Two updates problem
Date: 2005-06-08 17:31:17
Message-ID: 441354239.20050608213117@ulstu.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

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(at)ulstu(dot)ru

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dan Black 2005-06-08 17:39:53 Re: Foreign keys and slow insert
Previous Message dong changyu 2005-06-08 17:00:10 Re: vulnerability/SSL

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Treat 2005-06-08 17:33:25 Re: The Contrib Roundup (long)
Previous Message Alvaro Herrera 2005-06-08 17:22:30 Re: The Contrib Roundup (long)