Skip to content

Commit

Permalink
[#8735] YSQL: Implement dropping primary key
Browse files Browse the repository at this point in the history
Summary:
In #1104 / D10057 we implemented `ALTER TABLE ADD PRIMARY KEY` command.

This diff extends that work to implement `ALTER TABLE DROP CONSTRAINT pkey`.

We cannot drop primary key of:
* Partitioned tables and table partitions.
* Tables having rules.

Note that just like `ALTER TABLE ADD PRIMARY KEY`, this is designed for database setup and ORM migrations, and does not guarantee data safety when the table is being concurrently modified!

---

Resolves #8735

Test Plan:
ybd --java-test 'org.yb.pgsql.TestPgAlterTableChangePrimaryKey'

`TestPgAlterTableAddPrimaryKey` has been tweaked into `TestPgAlterTableChangePrimaryKey` which tests both adds and drops.

Reviewers: mihnea, tverona, neil, jason, myang, dmitry

Reviewed By: dmitry

Subscribers: yql

Differential Revision: https://phabricator.dev.yugabyte.com/D17939
  • Loading branch information
frozenspider committed Jul 29, 2022
1 parent a28f983 commit 6c9d8e8
Show file tree
Hide file tree
Showing 5 changed files with 613 additions and 258 deletions.
6 changes: 6 additions & 0 deletions java/yb-pgsql/src/test/java/org/yb/pgsql/BasePgSQLTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,12 @@ protected boolean isIndexOnlyScan(Statement stmt, String query, String index)
return doesQueryPlanContainsSubstring(stmt, query, "Index Only Scan using " + index);
}

/** Whether or not this select query uses Seq Scan. */
protected boolean isSeqScan(Statement stmt, String query)
throws SQLException {
return doesQueryPlanContainsSubstring(stmt, query, "Seq Scan on");
}

/**
* Whether or not this select query requires filtering by Postgres (i.e. not all
* conditions can be pushed down to YugaByte).
Expand Down
Loading

0 comments on commit 6c9d8e8

Please sign in to comment.