pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Ensure that expandTableLikeClause() re-examines the same table. 7+ messages / 1 participants [nested] [flat]
* pgsql: Ensure that expandTableLikeClause() re-examines the same table. @ 2020-12-01 19:03 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2020-12-01 19:03 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Ensure that expandTableLikeClause() re-examines the same table. As it stood, expandTableLikeClause() re-did the same relation_openrv call that transformTableLikeClause() had done. However there are scenarios where this would not find the same table as expected. We hold lock on the LIKE source table, so it can't be renamed or dropped, but another table could appear before it in the search path. This explains the odd behavior reported in bug #16758 when cloning a table as a temp table of the same name. This case worked as expected before commit 502898192 introduced the need to open the source table twice, so we should fix it. To make really sure we get the same table, let's re-open it by OID not name. That requires adding an OID field to struct TableLikeClause, which is a little nervous-making from an ABI standpoint, but as long as it's at the end I don't think there's any serious risk. Per bug #16758 from Marc Boeren. Like the previous patch, back-patch to all supported branches. Discussion: https://postgr.es/m/16758-840e84a6cfab276d@postgresql.org Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/f7f83a55bf6051818a0e4387d718867ecfa8561b Modified Files -------------- src/backend/nodes/copyfuncs.c | 1 + src/backend/nodes/equalfuncs.c | 1 + src/backend/nodes/outfuncs.c | 1 + src/backend/parser/gram.y | 1 + src/backend/parser/parse_utilcmd.c | 14 +++++++++++--- src/include/nodes/parsenodes.h | 1 + src/test/regress/expected/create_table_like.out | 21 +++++++++++++++++++++ src/test/regress/sql/create_table_like.sql | 8 ++++++++ 8 files changed, 45 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Ensure that expandTableLikeClause() re-examines the same table. @ 2020-12-01 19:03 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2020-12-01 19:03 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Ensure that expandTableLikeClause() re-examines the same table. As it stood, expandTableLikeClause() re-did the same relation_openrv call that transformTableLikeClause() had done. However there are scenarios where this would not find the same table as expected. We hold lock on the LIKE source table, so it can't be renamed or dropped, but another table could appear before it in the search path. This explains the odd behavior reported in bug #16758 when cloning a table as a temp table of the same name. This case worked as expected before commit 502898192 introduced the need to open the source table twice, so we should fix it. To make really sure we get the same table, let's re-open it by OID not name. That requires adding an OID field to struct TableLikeClause, which is a little nervous-making from an ABI standpoint, but as long as it's at the end I don't think there's any serious risk. Per bug #16758 from Marc Boeren. Like the previous patch, back-patch to all supported branches. Discussion: https://postgr.es/m/16758-840e84a6cfab276d@postgresql.org Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/dffc82a5b9d48bded63e1beed718b24bbf58c6a4 Modified Files -------------- src/backend/nodes/copyfuncs.c | 1 + src/backend/nodes/equalfuncs.c | 1 + src/backend/nodes/outfuncs.c | 1 + src/backend/parser/gram.y | 1 + src/backend/parser/parse_utilcmd.c | 14 +++++++++++--- src/include/nodes/parsenodes.h | 1 + src/test/regress/expected/create_table_like.out | 21 +++++++++++++++++++++ src/test/regress/sql/create_table_like.sql | 8 ++++++++ 8 files changed, 45 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Ensure that expandTableLikeClause() re-examines the same table. @ 2020-12-01 19:03 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2020-12-01 19:03 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Ensure that expandTableLikeClause() re-examines the same table. As it stood, expandTableLikeClause() re-did the same relation_openrv call that transformTableLikeClause() had done. However there are scenarios where this would not find the same table as expected. We hold lock on the LIKE source table, so it can't be renamed or dropped, but another table could appear before it in the search path. This explains the odd behavior reported in bug #16758 when cloning a table as a temp table of the same name. This case worked as expected before commit 502898192 introduced the need to open the source table twice, so we should fix it. To make really sure we get the same table, let's re-open it by OID not name. That requires adding an OID field to struct TableLikeClause, which is a little nervous-making from an ABI standpoint, but as long as it's at the end I don't think there's any serious risk. Per bug #16758 from Marc Boeren. Like the previous patch, back-patch to all supported branches. Discussion: https://postgr.es/m/16758-840e84a6cfab276d@postgresql.org Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/5f9b05ada1bb4b5576944227a2d330cde29683cb Modified Files -------------- src/backend/nodes/copyfuncs.c | 1 + src/backend/nodes/equalfuncs.c | 1 + src/backend/nodes/outfuncs.c | 1 + src/backend/parser/gram.y | 1 + src/backend/parser/parse_utilcmd.c | 14 +++++++++++--- src/include/nodes/parsenodes.h | 1 + src/test/regress/expected/create_table_like.out | 21 +++++++++++++++++++++ src/test/regress/sql/create_table_like.sql | 8 ++++++++ 8 files changed, 45 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Ensure that expandTableLikeClause() re-examines the same table. @ 2020-12-01 19:03 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2020-12-01 19:03 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Ensure that expandTableLikeClause() re-examines the same table. As it stood, expandTableLikeClause() re-did the same relation_openrv call that transformTableLikeClause() had done. However there are scenarios where this would not find the same table as expected. We hold lock on the LIKE source table, so it can't be renamed or dropped, but another table could appear before it in the search path. This explains the odd behavior reported in bug #16758 when cloning a table as a temp table of the same name. This case worked as expected before commit 502898192 introduced the need to open the source table twice, so we should fix it. To make really sure we get the same table, let's re-open it by OID not name. That requires adding an OID field to struct TableLikeClause, which is a little nervous-making from an ABI standpoint, but as long as it's at the end I don't think there's any serious risk. Per bug #16758 from Marc Boeren. Like the previous patch, back-patch to all supported branches. Discussion: https://postgr.es/m/16758-840e84a6cfab276d@postgresql.org Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/28bb8c496691e0fb60f49eac08b4dc1d8bdd6b4a Modified Files -------------- src/backend/nodes/copyfuncs.c | 1 + src/backend/nodes/equalfuncs.c | 1 + src/backend/nodes/outfuncs.c | 1 + src/backend/parser/gram.y | 1 + src/backend/parser/parse_utilcmd.c | 14 +++++++++++--- src/include/nodes/parsenodes.h | 1 + src/test/regress/expected/create_table_like.out | 21 +++++++++++++++++++++ src/test/regress/sql/create_table_like.sql | 8 ++++++++ 8 files changed, 45 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Ensure that expandTableLikeClause() re-examines the same table. @ 2020-12-01 19:03 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2020-12-01 19:03 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Ensure that expandTableLikeClause() re-examines the same table. As it stood, expandTableLikeClause() re-did the same relation_openrv call that transformTableLikeClause() had done. However there are scenarios where this would not find the same table as expected. We hold lock on the LIKE source table, so it can't be renamed or dropped, but another table could appear before it in the search path. This explains the odd behavior reported in bug #16758 when cloning a table as a temp table of the same name. This case worked as expected before commit 502898192 introduced the need to open the source table twice, so we should fix it. To make really sure we get the same table, let's re-open it by OID not name. That requires adding an OID field to struct TableLikeClause, which is a little nervous-making from an ABI standpoint, but as long as it's at the end I don't think there's any serious risk. Per bug #16758 from Marc Boeren. Like the previous patch, back-patch to all supported branches. Discussion: https://postgr.es/m/16758-840e84a6cfab276d@postgresql.org Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/d98e27dc6e41c911277812c46664d240c3eeba0e Modified Files -------------- src/backend/nodes/copyfuncs.c | 1 + src/backend/nodes/equalfuncs.c | 1 + src/backend/nodes/outfuncs.c | 1 + src/backend/parser/gram.y | 1 + src/backend/parser/parse_utilcmd.c | 14 +++++++++++--- src/include/nodes/parsenodes.h | 1 + src/test/regress/expected/create_table_like.out | 21 +++++++++++++++++++++ src/test/regress/sql/create_table_like.sql | 8 ++++++++ 8 files changed, 45 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Ensure that expandTableLikeClause() re-examines the same table. @ 2020-12-01 19:03 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2020-12-01 19:03 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Ensure that expandTableLikeClause() re-examines the same table. As it stood, expandTableLikeClause() re-did the same relation_openrv call that transformTableLikeClause() had done. However there are scenarios where this would not find the same table as expected. We hold lock on the LIKE source table, so it can't be renamed or dropped, but another table could appear before it in the search path. This explains the odd behavior reported in bug #16758 when cloning a table as a temp table of the same name. This case worked as expected before commit 502898192 introduced the need to open the source table twice, so we should fix it. To make really sure we get the same table, let's re-open it by OID not name. That requires adding an OID field to struct TableLikeClause, which is a little nervous-making from an ABI standpoint, but as long as it's at the end I don't think there's any serious risk. Per bug #16758 from Marc Boeren. Like the previous patch, back-patch to all supported branches. Discussion: https://postgr.es/m/16758-840e84a6cfab276d@postgresql.org Branch ------ REL9_6_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/f00c4400270f21905305a4648d1f3d57400a2e15 Modified Files -------------- src/backend/nodes/copyfuncs.c | 1 + src/backend/nodes/equalfuncs.c | 1 + src/backend/nodes/outfuncs.c | 1 + src/backend/parser/gram.y | 1 + src/backend/parser/parse_utilcmd.c | 14 +++++++++++--- src/include/nodes/parsenodes.h | 1 + src/test/regress/expected/create_table_like.out | 19 +++++++++++++++++++ src/test/regress/sql/create_table_like.sql | 8 ++++++++ 8 files changed, 43 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Ensure that expandTableLikeClause() re-examines the same table. @ 2020-12-01 19:03 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2020-12-01 19:03 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Ensure that expandTableLikeClause() re-examines the same table. As it stood, expandTableLikeClause() re-did the same relation_openrv call that transformTableLikeClause() had done. However there are scenarios where this would not find the same table as expected. We hold lock on the LIKE source table, so it can't be renamed or dropped, but another table could appear before it in the search path. This explains the odd behavior reported in bug #16758 when cloning a table as a temp table of the same name. This case worked as expected before commit 502898192 introduced the need to open the source table twice, so we should fix it. To make really sure we get the same table, let's re-open it by OID not name. That requires adding an OID field to struct TableLikeClause, which is a little nervous-making from an ABI standpoint, but as long as it's at the end I don't think there's any serious risk. Per bug #16758 from Marc Boeren. Like the previous patch, back-patch to all supported branches. Discussion: https://postgr.es/m/16758-840e84a6cfab276d@postgresql.org Branch ------ REL9_5_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/fb500296dfa6cffdd4dfdc8175e2173c6074f20a Modified Files -------------- src/backend/nodes/copyfuncs.c | 1 + src/backend/nodes/equalfuncs.c | 1 + src/backend/nodes/outfuncs.c | 1 + src/backend/parser/gram.y | 1 + src/backend/parser/parse_utilcmd.c | 14 +++++++++++--- src/include/nodes/parsenodes.h | 1 + src/test/regress/expected/create_table_like.out | 19 +++++++++++++++++++ src/test/regress/sql/create_table_like.sql | 8 ++++++++ 8 files changed, 43 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2020-12-01 19:03 UTC | newest] Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2020-12-01 19:03 pgsql: Ensure that expandTableLikeClause() re-examines the same table. Tom Lane <tgl@sss.pgh.pa.us> 2020-12-01 19:03 pgsql: Ensure that expandTableLikeClause() re-examines the same table. Tom Lane <tgl@sss.pgh.pa.us> 2020-12-01 19:03 pgsql: Ensure that expandTableLikeClause() re-examines the same table. Tom Lane <tgl@sss.pgh.pa.us> 2020-12-01 19:03 pgsql: Ensure that expandTableLikeClause() re-examines the same table. Tom Lane <tgl@sss.pgh.pa.us> 2020-12-01 19:03 pgsql: Ensure that expandTableLikeClause() re-examines the same table. Tom Lane <tgl@sss.pgh.pa.us> 2020-12-01 19:03 pgsql: Ensure that expandTableLikeClause() re-examines the same table. Tom Lane <tgl@sss.pgh.pa.us> 2020-12-01 19:03 pgsql: Ensure that expandTableLikeClause() re-examines the same table. 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