pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #14034: Select for update with inner select doesn't return value after committing by other transaction.
2+ messages / 2 participants
[nested] [flat]

* BUG #14034: Select for update with inner select doesn't return value after committing by other transaction.
@ 2016-03-18 14:09 Bronislav.Houdek@blackboard.com
  2016-03-22 21:57 ` Re: BUG #14034: Select for update with inner select doesn't return value after committing by other transaction. Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Bronislav.Houdek@blackboard.com @ 2016-03-18 14:09 UTC (permalink / raw)
  To: pgsql-bugs

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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #14034: Select for update with inner select doesn't return value after committing by other transaction.
  2016-03-18 14:09 BUG #14034: Select for update with inner select doesn't return value after committing by other transaction. Bronislav.Houdek@blackboard.com
@ 2016-03-22 21:57 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2016-03-22 21:57 UTC (permalink / raw)
  To: Bronislav.Houdek@blackboard.com; +Cc: pgsql-bugs

Bronislav.Houdek@blackboard.com writes:
> 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").

I've pushed a fix for this.  Thanks for the report!

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2016-03-22 21:57 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-03-18 14:09 BUG #14034: Select for update with inner select doesn't return value after committing by other transaction. Bronislav.Houdek@blackboard.com
2016-03-22 21:57 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox