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] Truncate doesn't seem to delete index tables #1175

Closed
ramkumarvs opened this issue Apr 8, 2019 · 1 comment
Closed

[YSQL] Truncate doesn't seem to delete index tables #1175

ramkumarvs opened this issue Apr 8, 2019 · 1 comment
Assignees
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug
Projects

Comments

@ramkumarvs
Copy link
Contributor

# create table test(id int primary key, value int);
CREATE TABLE
# create unique index uq_test_value on test(value);
CREATE INDEX
# insert into test values(1, 2);
INSERT 0 1
# select * from test;
 id | value
----+-------
  1 |     2
(1 row)

# truncate test;
TRUNCATE TABLE
# select * from test;
 id | value
----+-------
(0 rows)

# insert into test values(1, 2);
ERROR:  Query error: Duplicate key found in primary key or unique index
@ramkumarvs ramkumarvs added kind/bug This issue is a bug area/ysql Yugabyte SQL (YSQL) labels Apr 8, 2019
@rkarthik007 rkarthik007 added this to To do in YSQL via automation Apr 9, 2019
@rkarthik007 rkarthik007 modified the milestone: v1.0 Apr 9, 2019
@robertpang robertpang moved this from To do to In progress in YSQL May 2, 2019
yugabyte-ci pushed a commit that referenced this issue May 2, 2019
Summary:
This revision fixes an issue with the TRUNCATE statement where indexes on a table are not truncated when the table is truncated. For example,

```
# create table test (id int primary key, value int);
CREATE TABLE
# create unique index unique_idx on test (value);
CREATE INDEX
# insert into test values (1, 2);
INSERT 0 1
# truncate test;
TRUNCATE TABLE
# select * from test;
 id | value
----+-------
(0 rows)
# insert into test values(1, 2);
ERROR:  duplicate key value violates unique constraint "unique_idx"
```

The associated indexes are now truncated along with the base table in this revision.

A few miscellaneous code cleanups are also included in this diff.

Test Plan: yb_create_index

Reviewers: neha, mihnea

Reviewed By: mihnea

Subscribers: yql

Differential Revision: https://phabricator.dev.yugabyte.com/D6552
@robertpang
Copy link
Contributor

The issue is fixed in commit b7fa3d9.

YSQL automation moved this from In progress to Done May 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug
Projects
YSQL
  
Done
Development

No branches or pull requests

3 participants