Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ah1Ry-0000Z6-9z for pgsql-bugs@arkaria.postgresql.org; Fri, 18 Mar 2016 20:56:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1ah1Rx-00089V-N3 for pgsql-bugs@arkaria.postgresql.org; Fri, 18 Mar 2016 20:56:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1agv6P-00073s-5X for pgsql-bugs@postgresql.org; Fri, 18 Mar 2016 14:10:09 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1agv6K-0003UM-IH for pgsql-bugs@postgresql.org; Fri, 18 Mar 2016 14:10:08 +0000 MIME-Version: 1.0 Subject: BUG #14034: Select for update with inner select doesn't return value after committing by other transaction. To: pgsql-bugs@postgresql.org From: Bronislav.Houdek@blackboard.com Date: Fri, 18 Mar 2016 14:09:37 +0000 Message-ID: <20160318140937.2905.58185@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.9 (-) Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 14034 Logged by: Bronislav Houdek Email address: Bronislav.Houdek@blackboard.com PostgreSQL version: 9.5.1 Operating system: windows 7 64bit Description: We faced with this issue since 9.5 beta version and it is still reproducible in PostgreSQL 9.5.1 (result of SELECT version() = "PostgreSQL 9.5.1, compiled by Visual C++ build 1800, 64-bit"). Steps to reproduce: 1. prepare your tables and data (primary key and foreign key is not mandatory for reproducing this issue): CREATE TABLE public.table_a ( id integer NOT NULL, value text, CONSTRAINT primary_key PRIMARY KEY (id) ) WITH ( OIDS=FALSE ); ALTER TABLE public.table_a OWNER TO postgres; CREATE TABLE public.table_b ( id integer NOT NULL, value text, CONSTRAINT foreign_key FOREIGN KEY (id) REFERENCES public.table_a (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION ) WITH ( OIDS=FALSE ); ALTER TABLE public.table_b OWNER TO postgres; INSERT INTO table_a (id, value) VALUES (1, 'tableAValue'); INSERT INTO table_b (id, value) VALUES (1, 'tableBValue'); 2. use transaction number 1 and launch this sql statement and do not commit or rollback it, it is very important: UPDATE table_a SET value = 'tableAValue' WHERE id = 1 3. use transaction number 2 and launch this sql statement: SELECT TA.value AS ta_value, (SELECT TB.value FROM table_b TB where TA.id = TB.id) AS tb_value FROM table_a TA WHERE TA.id = 1 FOR UPDATE OF TA; This transaction will wait until the transaction number 1 will be finished. 4. Commit the transaction number 1. 5. Go to the transaction number 2 and verify output of SQL select statement. There will be columns and rows: (ta_value,tb_value) and ("tableAValue", "") - notice that value of column tb_value will be empty even if value in DB is "tableBValue". Expect columns and rows should be: (ta_value,tb_value) and ("tableAValue", "tableBValue"). Note: If you commit the transaction number 1 before executing transaction number 2 then it will work as it is expected with appropriate output. Thank you for you response, Bronislav Houdek. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs