Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YSQL] Dropping table doesn't drop table index #852

Closed
frozenspider opened this issue Feb 8, 2019 · 1 comment
Closed

[YSQL] Dropping table doesn't drop table index #852

frozenspider opened this issue Feb 8, 2019 · 1 comment
Assignees
Labels
kind/enhancement This is an enhancement of an existing feature

Comments

@frozenspider
Copy link
Contributor

postgres=# create table test(a int);
CREATE TABLE
postgres=# create unique index test_a on test(a);
CREATE INDEX
postgres=# drop table test;
DROP TABLE
postgres=# create table test(a int);
CREATE TABLE
postgres=# create unique index test_a on test(a);
ERROR:  relation "test_a" already exists

Moreover, we aren’t supporting DROP INDEX statement - we can't get rid of leftover indices:

postgres=# drop index test_a;
ERROR:  DROP INDEX not supported yet
LINE 1: drop index test_a;
             ^
@frozenspider frozenspider added the kind/bug This issue is a bug label Feb 8, 2019
@nocaway nocaway added kind/enhancement This is an enhancement of an existing feature and removed kind/bug This issue is a bug labels Feb 8, 2019
@nocaway
Copy link
Contributor

nocaway commented Feb 8, 2019

Need to add support for DROP INDEX.
According to Postgres's specification on drop table, indexes on table must ALWAYS be dropped.

DROP TABLE always removes any indexes, rules, triggers, and constraints that exist for the target table. However, to drop a table that is referenced by a view or a foreign-key constraint of another table, CASCADE must be specified. (CASCADE will remove a dependent view entirely, but in the foreign-key case it will only remove the foreign-key constraint, not the other table entirely.)

@ravimurthy ravimurthy assigned fizaaluthra and unassigned robertpang Feb 20, 2019
yugabyte-ci pushed a commit that referenced this issue Feb 28, 2019
Summary:
- Enabled pg_depend
- Fixed DROP VIEW (it was previously throwing an error)
- Correctly throw an error when we try to DROP a table that another object depends on (like a VIEW).
- Fixes DROP TABLE statement with multiple tables (ENG 4708 - #880)
- Drop the indexes of a table when we drop the table.

Test Plan: Run PgRegress tests

Reviewers: robert, mihnea

Reviewed By: mihnea

Subscribers: kannan, yql

Differential Revision: https://phabricator.dev.yugabyte.com/D6212
nspiegelberg added a commit that referenced this issue Aug 9, 2019
Summary:
#852 added support for pg_depend, which allows us to handle dependencies between multiple
commands.  This means we can now enable DROP TABLE for multiple entries.  This is needed to support
pgbench.

Test Plan:
./yb_build.sh --java-test org.yb.pgsql.TestPgRegressTable
./yb_build.sh --java-test org.yb.pgsql.TestPgRegressTypesString

Reviewers: bogdan, neil

Reviewed By: neil

Subscribers: jason, mikhail, neha, yql

Differential Revision: https://phabricator.dev.yugabyte.com/D7025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement This is an enhancement of an existing feature
Projects
None yet
Development

No branches or pull requests

4 participants