-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BACKPORT 2024.1][#22874] YSQL: Fix cascaded drops on columns
Summary: Commit 7c8343d / D35866 summary: Currently, when an object that a column depends on is dropped, the drop isn't correctly cascaded to the column in the DocDB table itself. Example: ``` yugabyte=# CREATE TABLE test_dropcolumn(a int, b int, c int); CREATE TABLE yugabyte=# CREATE TYPE test_dropcolumn_type AS (a int, b int); CREATE TYPE yugabyte=# ALTER TABLE test_dropcolumn ADD COLUMN d test_dropcolumn_type; ALTER TABLE yugabyte=# DROP TYPE test_dropcolumn_type CASCADE; NOTICE: drop cascades to column t of table person DROP TYPE yugabyte=# ALTER TABLE test_dropcolumn ADD COLUMN d int; ERROR: The column already exists: d ``` Although the PG metadata for the column is dropped, the column itself is not dropped in DocDB. This leads to an inconsistency between DocDB and PG. This diff fixes the issue by adding a YB drop for the column inside `doDeletion`. Note: this function is also used during `ALTER TABLE... DROP COLUMN`; however, alter table commands execute YB schema changes separately (see `YBCPrepareAlterTableCmd` and `YBCExecAlterTable`). So, an additional flag is added to skip the YB column drop in `doDeletion` in case it is being invoked by the alter table flow. Jira: DB-11776 Commit b81dbaa / D36329 summary: The test became flaky after commit 7c8343d fixed the logic for cascaded drops on columns. The test yb_feature_hash_types creates a domain and creates a table with a key column that has the domain as its type. However, since we currently don't support key column drops (#22902), the test fails when the cleanUpCustomEntities() function in BasePgSQLTest.java attempts to drop the domain (that has the key column as a dependant object) during cleanup. Moreover, the test is flaky because sometimes the table may be dropped before the domain, as the order of the drops depends on the pg_depend scan output, which isn't deterministic because pg_depend doesn't have a primary key and internally uses ybctid. Fix the test flakiness by dropping the table in yb_feature_hash_types before the test clean up logic. Jira: DB-12029 Original commits: 7c8343d / D35866 b81dbaa / D36329 Test Plan: yb_alter_table Reviewers: myang Reviewed By: myang Subscribers: yql Tags: #jenkins-ready Differential Revision: https://phorge.dev.yugabyte.com/D36286
- Loading branch information
1 parent
0d4eb40
commit 3bcaf41
Showing
13 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters