ERROR: "ft1" is of the wrong type.
Kyotaro Horiguchi <horikyota.ntt@gmail.com>
From: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
To: pgsql-hackers@lists.postgresql.org
Date: 2021-02-16T09:14:15Z
Lists: pgsql-hackers
Attachments
- fix_ATWrongRelKindError_pg11.patch (text/x-patch) patch
- fix_ATWrongRelKindError_pg12.patch (text/x-patch) patch
- fix_ATWrongRelKindError_pg13.patch (text/x-patch) patch
- fix_ATWrongRelKindError.patch (text/x-patch) patch
Hello, If I invoked a wrong ALTER TABLE command like this, I would see an unexpected error. =# ALTER TABLE <foreign table> ATTACH PARTITION .... ERROR: "ft1" is of the wrong type The cause is that ATWrongRelkidError doesn't handle ATT_TABLE | ATT_ATT_PARTITIONED_INDEX. After checking all callers of ATSimplePermissions, I found that; The two below are no longer used. ATT_TABLE | ATT_VIEW ATT_TABLE | ATT_MATVIEW | ATT_INDEX The four below are not handled. ATT_TABLE | ATT_MATVIEW | ATT_INDEX | ATT_PARTITIONED_INDEX: ATT_TABLE | ATT_MATVIEW | ATT_INDEX | ATT_PARTITIONED_INDEX | ATT_FOREIGN_TABLE ATT_TABLE | ATT_PARTITIONED_INDEX: ATT_INDEX: The attached is just fixing that. I tried to make it generic but didn't find a clean and translatable way. Also I found that only three cases in the function are excecised by make check. ATT_TABLE : foreign_data, indexing checks ATT_TABLE | ATT_FOREIGN_TABLE : alter_table ATT_TABLE | ATT_COMPOSITE_TYPE | ATT_FOREIGN_TABLE : alter_table I'm not sure it's worth the trouble so the attached doesn't do anything for that. Versions back to PG11 have similar but different mistakes. PG11, 12: the two below are not used ATT_TABLE | ATT_VIEW ATT_TABLE | ATT_MATVIEW | ATT_INDEX the two below are not handled ATT_TABLE | ATT_MATVIEW | ATT_INDEX | ATT_PARTITIONED_INDEX ATT_TABLE | ATT_PARTITIONED_INDEX PG13: the two below are not used ATT_TABLE | ATT_VIEW ATT_TABLE | ATT_MATVIEW | ATT_INDEX the three below are not handled ATT_TABLE | ATT_MATVIEW | ATT_INDEX | ATT_PARTITIONED_INDEX ATT_TABLE | ATT_MATVIEW | ATT_INDEX | ATT_PARTITIONED_INDEX | ATT_FOREIGN_TABLE ATT_TABLE | ATT_PARTITIONED_INDEX PG10: ATT_TABLE | ATT_VIEW is not used (all values are handled) So the attached are the patches for PG11, 12, 13 and master. It seems that the case lines in the function are intended to be in the ATT_*'s definition order, but some of the them are out of that order. However, I didn't reorder existing lines in the attached. I didn't check the value itself is correct for the callers. regareds. -- Kyotaro Horiguchi NTT Open Source Software Center
Commits
-
Fix unexpected error messages for various flavors of ALTER TABLE
- 85a8c3a4b60f 11.13 landed
- b242e1d239df 12.8 landed
- 5226243459f1 13.4 landed
- 0c83eb2e0edb 14.0 landed
-
Revert per-index collation version tracking feature.
- ec4831470826 14.0 cited
-
Restructure ALTER TABLE execution to fix assorted bugs.
- 1281a5c907b4 13.0 cited