postgresql/src/backend/commands
Michael Paquier 1a7ccd2b33 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
2026-03-17 14:34:29 +09:00
..
aggregatecmds.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
alter.c SQL Property Graph Queries (SQL/PGQ) 2026-03-16 10:14:18 +01:00
amcmds.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
analyze.c Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
async.c Add callback for I/O error messages in SLRUs 2026-03-13 16:21:06 +02:00
cluster.c Reject ALTER TABLE .. CLUSTER earlier for partitioned tables 2026-03-16 17:48:39 +09:00
collationcmds.c Stop including {brin,gin}_tuple.h in tuplesort.h 2026-01-12 18:09:49 +01:00
comment.c pg_upgrade: Fix handling of pg_largeobject_metadata. 2026-02-09 14:58:02 -06:00
constraint.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
conversioncmds.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
copy.c Add COPY (on_error set_null) option 2026-03-03 07:37:12 +01:00
copyfrom.c Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
copyfromparse.c Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
copyto.c Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
createas.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
dbcommands.c Don't include wait_event.h in pgstat.h 2026-03-06 16:24:58 +01:00
define.c Remove #include <math.h> where not needed 2026-01-15 19:09:47 +01:00
discard.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
dropcmds.c SQL Property Graph Queries (SQL/PGQ) 2026-03-16 10:14:18 +01:00
event_trigger.c Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
explain.c Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
explain_dr.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
explain_format.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
explain_state.c Fix memory allocation size in RegisterExtensionExplainOption() 2026-03-02 13:14:15 +09:00
extension.c Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
foreigncmds.c CREATE SUBSCRIPTION ... SERVER. 2026-03-06 08:27:56 -08:00
functioncmds.c Add all required calls to TupleDescFinalize() 2026-03-16 11:45:49 +13:00
indexcmds.c Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
lockcmds.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
Makefile SQL Property Graph Queries (SQL/PGQ) 2026-03-16 10:14:18 +01:00
matview.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
meson.build SQL Property Graph Queries (SQL/PGQ) 2026-03-16 10:14:18 +01:00
opclasscmds.c Mark GiST inet_ops as opcdefault, and deal with ensuing fallout. 2026-01-08 14:03:56 -05:00
operatorcmds.c Require superuser to install a non-built-in selectivity estimator. 2026-02-09 10:07:31 -05:00
policy.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
portalcmds.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
prepare.c Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
proclang.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
propgraphcmds.c SQL Property Graph Queries (SQL/PGQ) 2026-03-16 10:14:18 +01:00
publicationcmds.c Allow table exclusions in publications via EXCEPT TABLE. 2026-03-04 15:56:48 +05:30
schemacmds.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
seclabel.c SQL Property Graph Queries (SQL/PGQ) 2026-03-16 10:14:18 +01:00
sequence.c Add all required calls to TupleDescFinalize() 2026-03-16 11:45:49 +13:00
sequence_xlog.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
statscmds.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
subscriptioncmds.c Remove trailing period from errmsg in subscriptioncmds.c. 2026-03-09 15:10:03 +05:30
tablecmds.c Refactor some code around ALTER TABLE [NO] INHERIT 2026-03-17 14:34:29 +09:00
tablespace.c Disallow CR and LF in database, role, and tablespace names 2026-02-23 11:19:13 -05:00
trigger.c Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
tsearchcmds.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
typecmds.c Make ALTER DOMAIN VALIDATE CONSTRAINT no-op when constraint is already validated 2026-02-24 10:58:36 +01:00
user.c Disallow CR and LF in database, role, and tablespace names 2026-02-23 11:19:13 -05:00
vacuum.c Introduce the REPACK command 2026-03-10 19:56:39 +01:00
vacuumparallel.c Don't include proc.h in shm_mq.h 2026-02-27 10:53:47 +01:00
variable.c Force standard_conforming_strings to always be ON. 2026-01-21 15:08:38 -05:00
view.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
wait.c Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00