pgsql: Refactor some code around ALTER TABLE [NO] INHERIT - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: Refactor some code around ALTER TABLE [NO] INHERIT
Date
Msg-id E1w2N5q-0007V9-2u@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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 <li.evan.chao@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/CAEoWx2kggo1N2kDH6OSfXHL_5gKg3DqQ0PdNuL4LH4XSTKJ3-g@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(-)


pgsql-committers by date:

Previous
From: Michael Paquier
Date:
Subject: pgsql: Add regression test for ALTER TABLE .. NO INHERIT on typed table
Next
From: Michael Paquier
Date:
Subject: pgsql: gen_guc_tables.pl: Improve detection of inconsistent data