Re: Select for update

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Havasvölgyi Ottó <h(dot)otto(at)freemail(dot)hu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Select for update
Date: 2005-07-28 12:02:24
Message-ID: 20050728120224.GA68845@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jul 28, 2005 at 01:22:31PM +0200, Havasvölgyi Ottó wrote:
> Is it normal that when I select for update a record, but I don't select all
> the fields, that the contents of fields not selected will be deleted:
>
> create table pidtest(pid integer, szoveg text) without oids;
>
> select pid from pistest where pid>5 for update;
>
> After committing (autocommit), the contents of the szoveg field for the
> locked rows will be erased.

Could you provide a complete test case? Works fine here:

CREATE TABLE pidtest (pid integer, szoveg text) WITHOUT OIDS;

INSERT INTO pidtest (pid, szoveg) VALUES (3, 'three');
INSERT INTO pidtest (pid, szoveg) VALUES (4, 'four');
INSERT INTO pidtest (pid, szoveg) VALUES (5, 'five');
INSERT INTO pidtest (pid, szoveg) VALUES (6, 'six');
INSERT INTO pidtest (pid, szoveg) VALUES (7, 'seven');

SELECT pid FROM pidtest WHERE pid > 5 FOR UPDATE;
pid
-----
6
7
(2 rows)

SELECT * FROM pidtest;
pid | szoveg
-----+--------
3 | three
4 | four
5 | five
6 | six
7 | seven
(5 rows)

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message germ germ 2005-07-28 12:32:03 problem inserting with sequence
Previous Message Richard Huxton 2005-07-28 11:33:57 Re: Select for update