pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE 11+ messages / 1 participants [nested] [flat]
* pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE @ 2012-11-05 18:37 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 11+ messages in thread From: Tom Lane @ 2012-11-05 18:37 UTC (permalink / raw) To: pgsql-committers Fix handling of inherited check constraints in ALTER COLUMN TYPE. This case got broken in 8.4 by the addition of an error check that complains if ALTER TABLE ONLY is used on a table that has children. We do use ONLY for this situation, but it's okay because the necessary recursion occurs at a higher level. So we need to have a separate flag to suppress recursion without making the error check. Reported and patched by Pavan Deolasee, with some editorial adjustments by me. Back-patch to 8.4, since this is a regression of functionality that worked in earlier branches. Branch ------ master Details ------- http://git.postgresql.org/pg/commitdiff/5ed6546cf75623ba426942a3b71659a66cf7ed68 Modified Files -------------- src/backend/commands/tablecmds.c | 43 ++++++++++++++++++++++------- src/include/nodes/parsenodes.h | 1 + src/test/regress/expected/alter_table.out | 22 +++++++++++++++ src/test/regress/sql/alter_table.sql | 7 +++++ 4 files changed, 63 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 11+ messages in thread
* pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE @ 2012-11-05 18:37 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 11+ messages in thread From: Tom Lane @ 2012-11-05 18:37 UTC (permalink / raw) To: pgsql-committers Fix handling of inherited check constraints in ALTER COLUMN TYPE. This case got broken in 8.4 by the addition of an error check that complains if ALTER TABLE ONLY is used on a table that has children. We do use ONLY for this situation, but it's okay because the necessary recursion occurs at a higher level. So we need to have a separate flag to suppress recursion without making the error check. Reported and patched by Pavan Deolasee, with some editorial adjustments by me. Back-patch to 8.4, since this is a regression of functionality that worked in earlier branches. Branch ------ REL9_2_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/329057fd8f967d08190cd355333430c604418d81 Modified Files -------------- src/backend/commands/tablecmds.c | 43 ++++++++++++++++++++++------- src/include/nodes/parsenodes.h | 4 ++- src/test/regress/expected/alter_table.out | 22 +++++++++++++++ src/test/regress/sql/alter_table.sql | 7 +++++ 4 files changed, 65 insertions(+), 11 deletions(-) ^ permalink raw reply [nested|flat] 11+ messages in thread
* pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE @ 2012-11-05 18:37 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 11+ messages in thread From: Tom Lane @ 2012-11-05 18:37 UTC (permalink / raw) To: pgsql-committers Fix handling of inherited check constraints in ALTER COLUMN TYPE. This case got broken in 8.4 by the addition of an error check that complains if ALTER TABLE ONLY is used on a table that has children. We do use ONLY for this situation, but it's okay because the necessary recursion occurs at a higher level. So we need to have a separate flag to suppress recursion without making the error check. Reported and patched by Pavan Deolasee, with some editorial adjustments by me. Back-patch to 8.4, since this is a regression of functionality that worked in earlier branches. Branch ------ REL9_1_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/f43ca3c8945fb60ed409b7768b0ce5ee0437161e Modified Files -------------- src/backend/commands/tablecmds.c | 44 +++++++++++++++++++++++----- src/include/nodes/parsenodes.h | 4 ++- src/test/regress/expected/alter_table.out | 22 ++++++++++++++ src/test/regress/sql/alter_table.sql | 7 ++++ 4 files changed, 68 insertions(+), 9 deletions(-) ^ permalink raw reply [nested|flat] 11+ messages in thread
* pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE @ 2012-11-05 18:37 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 11+ messages in thread From: Tom Lane @ 2012-11-05 18:37 UTC (permalink / raw) To: pgsql-committers Fix handling of inherited check constraints in ALTER COLUMN TYPE. This case got broken in 8.4 by the addition of an error check that complains if ALTER TABLE ONLY is used on a table that has children. We do use ONLY for this situation, but it's okay because the necessary recursion occurs at a higher level. So we need to have a separate flag to suppress recursion without making the error check. Reported and patched by Pavan Deolasee, with some editorial adjustments by me. Back-patch to 8.4, since this is a regression of functionality that worked in earlier branches. Branch ------ REL9_0_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/8e344eacdccc3c069974cba61af42be60e50c764 Modified Files -------------- src/backend/commands/tablecmds.c | 40 +++++++++++++++++++++++------ src/include/nodes/parsenodes.h | 4 ++- src/test/regress/expected/alter_table.out | 22 ++++++++++++++++ src/test/regress/sql/alter_table.sql | 7 +++++ 4 files changed, 64 insertions(+), 9 deletions(-) ^ permalink raw reply [nested|flat] 11+ messages in thread
* pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE @ 2012-11-05 18:37 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 11+ messages in thread From: Tom Lane @ 2012-11-05 18:37 UTC (permalink / raw) To: pgsql-committers Fix handling of inherited check constraints in ALTER COLUMN TYPE. This case got broken in 8.4 by the addition of an error check that complains if ALTER TABLE ONLY is used on a table that has children. We do use ONLY for this situation, but it's okay because the necessary recursion occurs at a higher level. So we need to have a separate flag to suppress recursion without making the error check. Reported and patched by Pavan Deolasee, with some editorial adjustments by me. Back-patch to 8.4, since this is a regression of functionality that worked in earlier branches. Branch ------ REL8_4_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/4fa38136f7468ac3377a0041808bfb1d3e851d23 Modified Files -------------- src/backend/commands/tablecmds.c | 39 +++++++++++++++++++++++------ src/include/nodes/parsenodes.h | 4 ++- src/test/regress/expected/alter_table.out | 21 +++++++++++++++ src/test/regress/sql/alter_table.sql | 7 +++++ 4 files changed, 62 insertions(+), 9 deletions(-) ^ permalink raw reply [nested|flat] 11+ messages in thread
* pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE @ 2015-11-20 19:55 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 11+ messages in thread From: Tom Lane @ 2015-11-20 19:55 UTC (permalink / raw) To: pgsql-committers Fix handling of inherited check constraints in ALTER COLUMN TYPE (again). The previous way of reconstructing check constraints was to do a separate "ALTER TABLE ONLY tab ADD CONSTRAINT" for each table in an inheritance hierarchy. However, that way has no hope of reconstructing the check constraints' own inheritance properties correctly, as pointed out in bug #13779 from Jan Dirk Zijlstra. What we should do instead is to do a regular "ALTER TABLE", allowing recursion, at the topmost table that has a particular constraint, and then suppress the work queue entries for inherited instances of the constraint. Annoyingly, we'd tried to fix this behavior before, in commit 5ed6546cf, but we failed to notice that it wasn't reconstructing the pg_constraint field values correctly. As long as I'm touching pg_get_constraintdef_worker anyway, tweak it to always schema-qualify the target table name; this seems like useful backup to the protections installed by commit 5f173040. In HEAD/9.5, get rid of get_constraint_relation_oids, which is now unused. (I could alternatively have modified it to also return conislocal, but that seemed like a pretty single-purpose API, so let's not pretend it has some other use.) It's unused in the back branches as well, but I left it in place just in case some third-party code has decided to use it. In HEAD/9.5, also rename pg_get_constraintdef_string to pg_get_constraintdef_command, as the previous name did nothing to explain what that entry point did differently from others (and its comment was equally useless). Again, that change doesn't seem like material for back-patching. I did a bit of re-pgindenting in tablecmds.c in HEAD/9.5, as well. Otherwise, back-patch to all supported branches. Branch ------ master Details ------- http://git.postgresql.org/pg/commitdiff/074c5cfbfb4923158be9ccdb77420d6522d77538 Modified Files -------------- src/backend/catalog/pg_constraint.c | 19 ----- src/backend/commands/tablecmds.c | 73 +++++++++------- src/backend/utils/adt/ruleutils.c | 73 ++++++++++------ src/include/catalog/pg_constraint.h | 1 - src/include/utils/ruleutils.h | 2 +- src/test/regress/expected/alter_table.out | 130 ++++++++++++++++++++++++++++- src/test/regress/sql/alter_table.sql | 32 ++++++- 7 files changed, 252 insertions(+), 78 deletions(-) -- 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] 11+ messages in thread
* pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE @ 2015-11-20 19:55 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 11+ messages in thread From: Tom Lane @ 2015-11-20 19:55 UTC (permalink / raw) To: pgsql-committers Fix handling of inherited check constraints in ALTER COLUMN TYPE (again). The previous way of reconstructing check constraints was to do a separate "ALTER TABLE ONLY tab ADD CONSTRAINT" for each table in an inheritance hierarchy. However, that way has no hope of reconstructing the check constraints' own inheritance properties correctly, as pointed out in bug #13779 from Jan Dirk Zijlstra. What we should do instead is to do a regular "ALTER TABLE", allowing recursion, at the topmost table that has a particular constraint, and then suppress the work queue entries for inherited instances of the constraint. Annoyingly, we'd tried to fix this behavior before, in commit 5ed6546cf, but we failed to notice that it wasn't reconstructing the pg_constraint field values correctly. As long as I'm touching pg_get_constraintdef_worker anyway, tweak it to always schema-qualify the target table name; this seems like useful backup to the protections installed by commit 5f173040. In HEAD/9.5, get rid of get_constraint_relation_oids, which is now unused. (I could alternatively have modified it to also return conislocal, but that seemed like a pretty single-purpose API, so let's not pretend it has some other use.) It's unused in the back branches as well, but I left it in place just in case some third-party code has decided to use it. In HEAD/9.5, also rename pg_get_constraintdef_string to pg_get_constraintdef_command, as the previous name did nothing to explain what that entry point did differently from others (and its comment was equally useless). Again, that change doesn't seem like material for back-patching. I did a bit of re-pgindenting in tablecmds.c in HEAD/9.5, as well. Otherwise, back-patch to all supported branches. Branch ------ REL9_5_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/a35c5b7c1ffcde123b7b9b717608ed8357af870f Modified Files -------------- src/backend/catalog/pg_constraint.c | 19 ----- src/backend/commands/tablecmds.c | 53 +++++++----- src/backend/utils/adt/ruleutils.c | 73 ++++++++++------ src/include/catalog/pg_constraint.h | 1 - src/include/utils/ruleutils.h | 2 +- src/test/regress/expected/alter_table.out | 130 ++++++++++++++++++++++++++++- src/test/regress/sql/alter_table.sql | 32 ++++++- 7 files changed, 239 insertions(+), 71 deletions(-) -- 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] 11+ messages in thread
* pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE @ 2015-11-20 19:55 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 11+ messages in thread From: Tom Lane @ 2015-11-20 19:55 UTC (permalink / raw) To: pgsql-committers Fix handling of inherited check constraints in ALTER COLUMN TYPE (again). The previous way of reconstructing check constraints was to do a separate "ALTER TABLE ONLY tab ADD CONSTRAINT" for each table in an inheritance hierarchy. However, that way has no hope of reconstructing the check constraints' own inheritance properties correctly, as pointed out in bug #13779 from Jan Dirk Zijlstra. What we should do instead is to do a regular "ALTER TABLE", allowing recursion, at the topmost table that has a particular constraint, and then suppress the work queue entries for inherited instances of the constraint. Annoyingly, we'd tried to fix this behavior before, in commit 5ed6546cf, but we failed to notice that it wasn't reconstructing the pg_constraint field values correctly. As long as I'm touching pg_get_constraintdef_worker anyway, tweak it to always schema-qualify the target table name; this seems like useful backup to the protections installed by commit 5f173040. In HEAD/9.5, get rid of get_constraint_relation_oids, which is now unused. (I could alternatively have modified it to also return conislocal, but that seemed like a pretty single-purpose API, so let's not pretend it has some other use.) It's unused in the back branches as well, but I left it in place just in case some third-party code has decided to use it. In HEAD/9.5, also rename pg_get_constraintdef_string to pg_get_constraintdef_command, as the previous name did nothing to explain what that entry point did differently from others (and its comment was equally useless). Again, that change doesn't seem like material for back-patching. I did a bit of re-pgindenting in tablecmds.c in HEAD/9.5, as well. Otherwise, back-patch to all supported branches. Branch ------ REL9_4_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/47ea4614e94d459817063cf922f88a615f8cee76 Modified Files -------------- src/backend/commands/tablecmds.c | 37 +++++--- src/backend/utils/adt/ruleutils.c | 71 ++++++++++------ src/test/regress/expected/alter_table.out | 130 ++++++++++++++++++++++++++++- src/test/regress/sql/alter_table.sql | 32 ++++++- 4 files changed, 229 insertions(+), 41 deletions(-) -- 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] 11+ messages in thread
* pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE @ 2015-11-20 19:55 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 11+ messages in thread From: Tom Lane @ 2015-11-20 19:55 UTC (permalink / raw) To: pgsql-committers Fix handling of inherited check constraints in ALTER COLUMN TYPE (again). The previous way of reconstructing check constraints was to do a separate "ALTER TABLE ONLY tab ADD CONSTRAINT" for each table in an inheritance hierarchy. However, that way has no hope of reconstructing the check constraints' own inheritance properties correctly, as pointed out in bug #13779 from Jan Dirk Zijlstra. What we should do instead is to do a regular "ALTER TABLE", allowing recursion, at the topmost table that has a particular constraint, and then suppress the work queue entries for inherited instances of the constraint. Annoyingly, we'd tried to fix this behavior before, in commit 5ed6546cf, but we failed to notice that it wasn't reconstructing the pg_constraint field values correctly. As long as I'm touching pg_get_constraintdef_worker anyway, tweak it to always schema-qualify the target table name; this seems like useful backup to the protections installed by commit 5f173040. In HEAD/9.5, get rid of get_constraint_relation_oids, which is now unused. (I could alternatively have modified it to also return conislocal, but that seemed like a pretty single-purpose API, so let's not pretend it has some other use.) It's unused in the back branches as well, but I left it in place just in case some third-party code has decided to use it. In HEAD/9.5, also rename pg_get_constraintdef_string to pg_get_constraintdef_command, as the previous name did nothing to explain what that entry point did differently from others (and its comment was equally useless). Again, that change doesn't seem like material for back-patching. I did a bit of re-pgindenting in tablecmds.c in HEAD/9.5, as well. Otherwise, back-patch to all supported branches. Branch ------ REL9_3_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/64349f1d29dc6257551c7663526fc6633b45e90b Modified Files -------------- src/backend/commands/tablecmds.c | 43 ++++++---- src/backend/utils/adt/ruleutils.c | 71 ++++++++++------ src/test/regress/expected/alter_table.out | 130 ++++++++++++++++++++++++++++- src/test/regress/sql/alter_table.sql | 32 ++++++- 4 files changed, 232 insertions(+), 44 deletions(-) -- 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] 11+ messages in thread
* pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE @ 2015-11-20 19:55 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 11+ messages in thread From: Tom Lane @ 2015-11-20 19:55 UTC (permalink / raw) To: pgsql-committers Fix handling of inherited check constraints in ALTER COLUMN TYPE (again). The previous way of reconstructing check constraints was to do a separate "ALTER TABLE ONLY tab ADD CONSTRAINT" for each table in an inheritance hierarchy. However, that way has no hope of reconstructing the check constraints' own inheritance properties correctly, as pointed out in bug #13779 from Jan Dirk Zijlstra. What we should do instead is to do a regular "ALTER TABLE", allowing recursion, at the topmost table that has a particular constraint, and then suppress the work queue entries for inherited instances of the constraint. Annoyingly, we'd tried to fix this behavior before, in commit 5ed6546cf, but we failed to notice that it wasn't reconstructing the pg_constraint field values correctly. As long as I'm touching pg_get_constraintdef_worker anyway, tweak it to always schema-qualify the target table name; this seems like useful backup to the protections installed by commit 5f173040. In HEAD/9.5, get rid of get_constraint_relation_oids, which is now unused. (I could alternatively have modified it to also return conislocal, but that seemed like a pretty single-purpose API, so let's not pretend it has some other use.) It's unused in the back branches as well, but I left it in place just in case some third-party code has decided to use it. In HEAD/9.5, also rename pg_get_constraintdef_string to pg_get_constraintdef_command, as the previous name did nothing to explain what that entry point did differently from others (and its comment was equally useless). Again, that change doesn't seem like material for back-patching. I did a bit of re-pgindenting in tablecmds.c in HEAD/9.5, as well. Otherwise, back-patch to all supported branches. Branch ------ REL9_2_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/c49279dfd5275c9ede9e7faf7d183a76bab680b0 Modified Files -------------- src/backend/commands/tablecmds.c | 43 ++++++---- src/backend/utils/adt/ruleutils.c | 71 ++++++++++------ src/test/regress/expected/alter_table.out | 130 ++++++++++++++++++++++++++++- src/test/regress/sql/alter_table.sql | 32 ++++++- 4 files changed, 232 insertions(+), 44 deletions(-) -- 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] 11+ messages in thread
* pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE @ 2015-11-20 19:55 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 11+ messages in thread From: Tom Lane @ 2015-11-20 19:55 UTC (permalink / raw) To: pgsql-committers Fix handling of inherited check constraints in ALTER COLUMN TYPE (again). The previous way of reconstructing check constraints was to do a separate "ALTER TABLE ONLY tab ADD CONSTRAINT" for each table in an inheritance hierarchy. However, that way has no hope of reconstructing the check constraints' own inheritance properties correctly, as pointed out in bug #13779 from Jan Dirk Zijlstra. What we should do instead is to do a regular "ALTER TABLE", allowing recursion, at the topmost table that has a particular constraint, and then suppress the work queue entries for inherited instances of the constraint. Annoyingly, we'd tried to fix this behavior before, in commit 5ed6546cf, but we failed to notice that it wasn't reconstructing the pg_constraint field values correctly. As long as I'm touching pg_get_constraintdef_worker anyway, tweak it to always schema-qualify the target table name; this seems like useful backup to the protections installed by commit 5f173040. In HEAD/9.5, get rid of get_constraint_relation_oids, which is now unused. (I could alternatively have modified it to also return conislocal, but that seemed like a pretty single-purpose API, so let's not pretend it has some other use.) It's unused in the back branches as well, but I left it in place just in case some third-party code has decided to use it. In HEAD/9.5, also rename pg_get_constraintdef_string to pg_get_constraintdef_command, as the previous name did nothing to explain what that entry point did differently from others (and its comment was equally useless). Again, that change doesn't seem like material for back-patching. I did a bit of re-pgindenting in tablecmds.c in HEAD/9.5, as well. Otherwise, back-patch to all supported branches. Branch ------ REL9_1_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/60ba32cb5128571aec344288cc26986215becd67 Modified Files -------------- src/backend/commands/tablecmds.c | 47 ++++++----- src/backend/utils/adt/ruleutils.c | 71 ++++++++++------ src/test/regress/expected/alter_table.out | 125 ++++++++++++++++++++++++++++- src/test/regress/sql/alter_table.sql | 31 ++++++- 4 files changed, 226 insertions(+), 48 deletions(-) -- 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] 11+ messages in thread
end of thread, other threads:[~2015-11-20 19:55 UTC | newest] Thread overview: 11+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2012-11-05 18:37 pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE Tom Lane <tgl@sss.pgh.pa.us> 2012-11-05 18:37 pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE Tom Lane <tgl@sss.pgh.pa.us> 2012-11-05 18:37 pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE Tom Lane <tgl@sss.pgh.pa.us> 2012-11-05 18:37 pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE Tom Lane <tgl@sss.pgh.pa.us> 2012-11-05 18:37 pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE Tom Lane <tgl@sss.pgh.pa.us> 2015-11-20 19:55 pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE Tom Lane <tgl@sss.pgh.pa.us> 2015-11-20 19:55 pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE Tom Lane <tgl@sss.pgh.pa.us> 2015-11-20 19:55 pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE Tom Lane <tgl@sss.pgh.pa.us> 2015-11-20 19:55 pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE Tom Lane <tgl@sss.pgh.pa.us> 2015-11-20 19:55 pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE Tom Lane <tgl@sss.pgh.pa.us> 2015-11-20 19:55 pgsql: Fix handling of inherited check constraints in ALTER COLUMN TYPE 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