Refactor some code around ALTER TABLE [NO] INHERIT [NO] INHERIT is not supported for partitioned tables, but this portion of tablecmds.c did not apply the same rules as the other sub-commands, checking the relkind in the execution phase, not the preparation phase.
This commit refactors the code to centralize the relkind and other checks in the preparation phase for both command patterns, getting rid of one translatable string on the way. ATT_PARTITIONED_TABLE is removed from ATSimplePermissions(), and the child relation is checked the same way for both sub-commands. The ALTER TABLE patterns that now fail at preparation failed already at execution, hence there should be no changes from the user perspective except more consistent error messages generated. Some comments at the top of ATPrepAddInherit() were incorrect, CreateInheritance() being the routine checking the columns and constraints between the parent and its to-be-child. Author: Chao Li <[email protected]> Reviewed-by: Michael Paquier <[email protected]> Reviewed-by: Zsolt Parragi <[email protected]> Discussion: https://postgr.es/m/caeowx2kggo1n2kdh6osfxhl_5gkg3dqq0pdnul4lh4xstkj...@mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/1a7ccd2b332d5fafa9bf1121c82693c9a2a57298 Modified Files -------------- src/backend/commands/tablecmds.c | 33 ++++++++++++------------------- src/test/regress/expected/alter_table.out | 15 +++++++++++--- src/test/regress/expected/typed_table.out | 2 +- src/test/regress/sql/alter_table.sql | 8 ++++++-- 4 files changed, 32 insertions(+), 26 deletions(-)
