pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Be sure to rewind the tuplestore read pointer in non-leader CTES 7+ messages / 1 participants [nested] [flat]
* pgsql: Be sure to rewind the tuplestore read pointer in non-leader CTES @ 2016-09-22 15:35 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2016-09-22 15:35 UTC (permalink / raw) To: pgsql-committers Be sure to rewind the tuplestore read pointer in non-leader CTEScan nodes. ExecInitCteScan supposed that it didn't have to do anything to the extra tuplestore read pointer it gets from tuplestore_alloc_read_pointer. However, it needs this read pointer to be positioned at the start of the tuplestore, while tuplestore_alloc_read_pointer is actually defined as cloning the current position of read pointer 0. In normal situations that accidentally works because we initialize the whole plan tree at once, before anything gets read. But it fails in an EvalPlanQual recheck, as illustrated in bug #14328 from Dima Pavlov. To fix, just forcibly rewind the pointer after tuplestore_alloc_read_pointer. The cost of doing so is negligible unless the tuplestore is already in TSS_READFILE state, which wouldn't happen in normal cases. We could consider altering tuplestore's API to make that case cheaper, but that would make for a more invasive back-patch and it doesn't seem worth it. This has been broken probably for as long as we've had CTEs, so back-patch to all supported branches. Discussion: <32468.1474548308@sss.pgh.pa.us> Branch ------ REL9_6_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/a88fe25f50ae9ce491fe10a90aeef2cbed6f2b9a Modified Files -------------- src/backend/executor/nodeCtescan.c | 4 ++++ src/test/isolation/expected/eval-plan-qual.out | 21 +++++++++++++++++++++ src/test/isolation/specs/eval-plan-qual.spec | 17 +++++++++++++++++ 3 files changed, 42 insertions(+) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Be sure to rewind the tuplestore read pointer in non-leader CTES @ 2016-09-22 15:35 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2016-09-22 15:35 UTC (permalink / raw) To: pgsql-committers Be sure to rewind the tuplestore read pointer in non-leader CTEScan nodes. ExecInitCteScan supposed that it didn't have to do anything to the extra tuplestore read pointer it gets from tuplestore_alloc_read_pointer. However, it needs this read pointer to be positioned at the start of the tuplestore, while tuplestore_alloc_read_pointer is actually defined as cloning the current position of read pointer 0. In normal situations that accidentally works because we initialize the whole plan tree at once, before anything gets read. But it fails in an EvalPlanQual recheck, as illustrated in bug #14328 from Dima Pavlov. To fix, just forcibly rewind the pointer after tuplestore_alloc_read_pointer. The cost of doing so is negligible unless the tuplestore is already in TSS_READFILE state, which wouldn't happen in normal cases. We could consider altering tuplestore's API to make that case cheaper, but that would make for a more invasive back-patch and it doesn't seem worth it. This has been broken probably for as long as we've had CTEs, so back-patch to all supported branches. Discussion: <32468.1474548308@sss.pgh.pa.us> Branch ------ master Details ------- http://git.postgresql.org/pg/commitdiff/96dd77d349424f270d129f8f40e75f762ddcca7d Modified Files -------------- src/backend/executor/nodeCtescan.c | 4 ++++ src/test/isolation/expected/eval-plan-qual.out | 21 +++++++++++++++++++++ src/test/isolation/specs/eval-plan-qual.spec | 17 +++++++++++++++++ 3 files changed, 42 insertions(+) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Be sure to rewind the tuplestore read pointer in non-leader CTES @ 2016-09-22 15:35 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2016-09-22 15:35 UTC (permalink / raw) To: pgsql-committers Be sure to rewind the tuplestore read pointer in non-leader CTEScan nodes. ExecInitCteScan supposed that it didn't have to do anything to the extra tuplestore read pointer it gets from tuplestore_alloc_read_pointer. However, it needs this read pointer to be positioned at the start of the tuplestore, while tuplestore_alloc_read_pointer is actually defined as cloning the current position of read pointer 0. In normal situations that accidentally works because we initialize the whole plan tree at once, before anything gets read. But it fails in an EvalPlanQual recheck, as illustrated in bug #14328 from Dima Pavlov. To fix, just forcibly rewind the pointer after tuplestore_alloc_read_pointer. The cost of doing so is negligible unless the tuplestore is already in TSS_READFILE state, which wouldn't happen in normal cases. We could consider altering tuplestore's API to make that case cheaper, but that would make for a more invasive back-patch and it doesn't seem worth it. This has been broken probably for as long as we've had CTEs, so back-patch to all supported branches. Discussion: <32468.1474548308@sss.pgh.pa.us> Branch ------ REL9_1_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/0183df5dc000fccf121c1a54504044578e43ec8e Modified Files -------------- src/backend/executor/nodeCtescan.c | 4 ++++ 1 file changed, 4 insertions(+) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Be sure to rewind the tuplestore read pointer in non-leader CTES @ 2016-09-22 15:35 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2016-09-22 15:35 UTC (permalink / raw) To: pgsql-committers Be sure to rewind the tuplestore read pointer in non-leader CTEScan nodes. ExecInitCteScan supposed that it didn't have to do anything to the extra tuplestore read pointer it gets from tuplestore_alloc_read_pointer. However, it needs this read pointer to be positioned at the start of the tuplestore, while tuplestore_alloc_read_pointer is actually defined as cloning the current position of read pointer 0. In normal situations that accidentally works because we initialize the whole plan tree at once, before anything gets read. But it fails in an EvalPlanQual recheck, as illustrated in bug #14328 from Dima Pavlov. To fix, just forcibly rewind the pointer after tuplestore_alloc_read_pointer. The cost of doing so is negligible unless the tuplestore is already in TSS_READFILE state, which wouldn't happen in normal cases. We could consider altering tuplestore's API to make that case cheaper, but that would make for a more invasive back-patch and it doesn't seem worth it. This has been broken probably for as long as we've had CTEs, so back-patch to all supported branches. Discussion: <32468.1474548308@sss.pgh.pa.us> Branch ------ REL9_3_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/73df86a37ba54e35ba8d9e09bc9fe5699b196829 Modified Files -------------- src/backend/executor/nodeCtescan.c | 4 ++++ src/test/isolation/expected/eval-plan-qual.out | 21 +++++++++++++++++++++ src/test/isolation/specs/eval-plan-qual.spec | 23 +++++++++++++++++++++++ 3 files changed, 48 insertions(+) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Be sure to rewind the tuplestore read pointer in non-leader CTES @ 2016-09-22 15:35 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2016-09-22 15:35 UTC (permalink / raw) To: pgsql-committers Be sure to rewind the tuplestore read pointer in non-leader CTEScan nodes. ExecInitCteScan supposed that it didn't have to do anything to the extra tuplestore read pointer it gets from tuplestore_alloc_read_pointer. However, it needs this read pointer to be positioned at the start of the tuplestore, while tuplestore_alloc_read_pointer is actually defined as cloning the current position of read pointer 0. In normal situations that accidentally works because we initialize the whole plan tree at once, before anything gets read. But it fails in an EvalPlanQual recheck, as illustrated in bug #14328 from Dima Pavlov. To fix, just forcibly rewind the pointer after tuplestore_alloc_read_pointer. The cost of doing so is negligible unless the tuplestore is already in TSS_READFILE state, which wouldn't happen in normal cases. We could consider altering tuplestore's API to make that case cheaper, but that would make for a more invasive back-patch and it doesn't seem worth it. This has been broken probably for as long as we've had CTEs, so back-patch to all supported branches. Discussion: <32468.1474548308@sss.pgh.pa.us> Branch ------ REL9_2_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/8552f9b903a099d82763460cb7ca28715d0ad2bb Modified Files -------------- src/backend/executor/nodeCtescan.c | 4 ++++ src/test/isolation/expected/eval-plan-qual.out | 21 +++++++++++++++++++++ src/test/isolation/specs/eval-plan-qual.spec | 23 +++++++++++++++++++++++ 3 files changed, 48 insertions(+) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Be sure to rewind the tuplestore read pointer in non-leader CTES @ 2016-09-22 15:35 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2016-09-22 15:35 UTC (permalink / raw) To: pgsql-committers Be sure to rewind the tuplestore read pointer in non-leader CTEScan nodes. ExecInitCteScan supposed that it didn't have to do anything to the extra tuplestore read pointer it gets from tuplestore_alloc_read_pointer. However, it needs this read pointer to be positioned at the start of the tuplestore, while tuplestore_alloc_read_pointer is actually defined as cloning the current position of read pointer 0. In normal situations that accidentally works because we initialize the whole plan tree at once, before anything gets read. But it fails in an EvalPlanQual recheck, as illustrated in bug #14328 from Dima Pavlov. To fix, just forcibly rewind the pointer after tuplestore_alloc_read_pointer. The cost of doing so is negligible unless the tuplestore is already in TSS_READFILE state, which wouldn't happen in normal cases. We could consider altering tuplestore's API to make that case cheaper, but that would make for a more invasive back-patch and it doesn't seem worth it. This has been broken probably for as long as we've had CTEs, so back-patch to all supported branches. Discussion: <32468.1474548308@sss.pgh.pa.us> Branch ------ REL9_5_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/c359178350ac7790437feb817c1fb523838abbd9 Modified Files -------------- src/backend/executor/nodeCtescan.c | 4 ++++ src/test/isolation/expected/eval-plan-qual.out | 21 +++++++++++++++++++++ src/test/isolation/specs/eval-plan-qual.spec | 17 +++++++++++++++++ 3 files changed, 42 insertions(+) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Be sure to rewind the tuplestore read pointer in non-leader CTES @ 2016-09-22 15:35 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2016-09-22 15:35 UTC (permalink / raw) To: pgsql-committers Be sure to rewind the tuplestore read pointer in non-leader CTEScan nodes. ExecInitCteScan supposed that it didn't have to do anything to the extra tuplestore read pointer it gets from tuplestore_alloc_read_pointer. However, it needs this read pointer to be positioned at the start of the tuplestore, while tuplestore_alloc_read_pointer is actually defined as cloning the current position of read pointer 0. In normal situations that accidentally works because we initialize the whole plan tree at once, before anything gets read. But it fails in an EvalPlanQual recheck, as illustrated in bug #14328 from Dima Pavlov. To fix, just forcibly rewind the pointer after tuplestore_alloc_read_pointer. The cost of doing so is negligible unless the tuplestore is already in TSS_READFILE state, which wouldn't happen in normal cases. We could consider altering tuplestore's API to make that case cheaper, but that would make for a more invasive back-patch and it doesn't seem worth it. This has been broken probably for as long as we've had CTEs, so back-patch to all supported branches. Discussion: <32468.1474548308@sss.pgh.pa.us> Branch ------ REL9_4_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/d3dd00e675712da13262149b3478ecbff91525fd Modified Files -------------- src/backend/executor/nodeCtescan.c | 4 ++++ src/test/isolation/expected/eval-plan-qual.out | 21 +++++++++++++++++++++ src/test/isolation/specs/eval-plan-qual.spec | 23 +++++++++++++++++++++++ 3 files changed, 48 insertions(+) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2016-09-22 15:35 UTC | newest] Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2016-09-22 15:35 pgsql: Be sure to rewind the tuplestore read pointer in non-leader CTES Tom Lane <tgl@sss.pgh.pa.us> 2016-09-22 15:35 pgsql: Be sure to rewind the tuplestore read pointer in non-leader CTES Tom Lane <tgl@sss.pgh.pa.us> 2016-09-22 15:35 pgsql: Be sure to rewind the tuplestore read pointer in non-leader CTES Tom Lane <tgl@sss.pgh.pa.us> 2016-09-22 15:35 pgsql: Be sure to rewind the tuplestore read pointer in non-leader CTES Tom Lane <tgl@sss.pgh.pa.us> 2016-09-22 15:35 pgsql: Be sure to rewind the tuplestore read pointer in non-leader CTES Tom Lane <tgl@sss.pgh.pa.us> 2016-09-22 15:35 pgsql: Be sure to rewind the tuplestore read pointer in non-leader CTES Tom Lane <tgl@sss.pgh.pa.us> 2016-09-22 15:35 pgsql: Be sure to rewind the tuplestore read pointer in non-leader CTES 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