Skip to content

2.25.0.0-b367

@timothy-e timothy-e tagged this 25 Nov 12:51
Summary:
Support the following SQL commands
```lang=sql
ALTER TABLE <table> OF <type>;
ALTER TABLE <table> NOT OF;
```

This syntax makes a Postgres metadata only change, so enabling it is very straightforward. Nothing needs to reflect this change on DocDB.

=== Background ===

Since the PG surface area is very large, a lot of PG features were disabled when integrating with Yugabyte, especially ALTER TABLE commands.  `ALTER TABLE ... OF ...` is one of the commands that was disabled.

**PG15 Upgrade**
We haven't received any requests to support it, but it is required to support the pg15 upgrade of tables created with the `CREATE TABLE ... OF ...` syntax.

To upgrade, a dump from pg11 is taken, and a table of a specific type is dumped as a
```sql
CREATE TYPE simple_type AS (a INT);
CREATE TABLE simple_table (a INT);
ALTER TABLE simple_table OF simple_type;
```

When we restore this on to a pg15 cluster, we must be able to support this `ALTER` syntax, even though the user didn't use the syntax to create the table.

**Backup and Restore**
This also impacts backup and restore, because a dump is taken and restored. If a user had a table created with a type, and then restored that database, the restored table would not have been created with a type because the `ALTER TABLE ... OF ...` statement would have failed. With this change, it should succeed, so the restored table should match the original table.

This workflow is not specifically tested here, because we can already see `pg_restore` in action in the upgrade tests.
Jira: DB-14127

Test Plan:
```
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressPgTable'
./yb_build.sh release --cxx-test pg15_upgrade-test --gtest_filter Pg15UpgradeTest.CreateTableOf
```

Reviewers: fizaa, tfoucher, jason

Reviewed By: fizaa

Subscribers: jason, yql

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