Skip to content

2.31.0.0-b187

@OlegLoginov OlegLoginov tagged this 22 Jun 09:39
Summary:
The following statements are enabled by this diff:
`ALTER TYPE <name> DROP ATTRIBUTE [IF EXISTS] <attname> [RESTRICT|CASCADE]`

If there's an existing composite type that has dropped attributes, `pg_upgrade` tool will
try to re-create that state by creating the type and then dropping the attribute.
So, `ALTER TYPE ... DROP ATTRIBUTE` should be supported, else the upgrade fails.

Also this statement can be generated by `ysql_dump` in the backup-restore pipeline.

From the implementation the `DROP ATTRIBUTE` operation is PG-side-only.
It does not delete any columns/data, but only marks the column as dropped.

Because the operation is PG-side-only, it is not propagated to DocDB. For a typed table
(`CREATE TABLE <tbl> OF <type>`) the DocDB schema would then silently diverge from the PG
catalog. So `DROP ATTRIBUTE` is rejected (even with `CASCADE`) when the type backs a typed
table, with the error `drop attribute on typed table is not supported yet`.
This case should be fixed by another diff.
(GHI: https://github.com/yugabyte/yugabyte-db/issues/30577).

The composite-type testing part was copied from the original PG regress test
`alter_table.sql` into the ported `yb.port.alter_table.sql`. The typed-table backup-restore
test and the regress expectations were updated to reflect the new guard.

Test Plan:
./yb_build.sh --java-test org.yb.pgsql.TestPgRegressPgTable#schedule[objectLocking=false-concurrentDDL=false]
./yb_build.sh --java-test org.yb.pgsql.TestPgRegressPgTable#schedule[objectLocking=true-concurrentDDL=false]
./yb_build.sh --java-test org.yb.pgsql.TestPgRegressPgTable#schedule[objectLocking=true-concurrentDDL=true]

./yb_build.sh  --java-test org.yb.pgsql.TestYbBackup#testDropUDTypeAttribute
./yb_build.sh  --java-test org.yb.pgsql.TestYbBackup#testTypedTableBackupRestore

Reviewers: sanketh, fizaa

Reviewed By: sanketh, fizaa

Subscribers: ybase, yql

Differential Revision: https://phorge.dev.yugabyte.com/D51880
Assets 2
Loading