forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commite22e29c
committed
Fix handling of CREATE TABLE LIKE with inheritance.
If a CREATE TABLE command uses both LIKE and traditional inheritance,Vars in CHECK constraints and expression indexes that are absorbedfrom a LIKE parent table tended to get mis-numbered, resulting inwrong answers and/or bizarre error messages (though probably not anyactual crashes, thanks to validation occurring in the executor).In v12 and up, the same could happen to Vars in GENERATED expressions,even in cases with no LIKE clause but multiple traditional-inheritanceparents.The cause of the problem for LIKE is that parse_utilcmd.c supposedit could renumber such Vars correctly during transformCreateStmt(),which it cannot since we have not yet accounted for columns added viainheritance. Fix that by postponing processing of LIKE INCLUDINGCONSTRAINTS, DEFAULTS, GENERATED, INDEXES till after we've performedDefineRelation().The error with GENERATED and multiple inheritance is a simple oversightin MergeAttributes(); it knows it has to renumber Vars in inheritedCHECK constraints, but forgot to apply the same processing to inheritedGENERATED expressions (a/k/a defaults).Per bug #16272 from Tom Gottfried. The non-GENERATED variants of theissue are ancient, presumably dating right back to the addition ofCREATE TABLE LIKE; hence back-patch to all supported branches.Discussion:https://postgr.es/m/16272-6e32da020e9a9381@postgresql.org1 parent3a45ac0 commite22e29c
File tree
5 files changed
+241
-83
lines changed- src
- backend
- parser
- tcop
- include/parser
- test/regress
- expected
- sql
5 files changed
+241
-83
lines changed0 commit comments
Comments
(0)