You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# 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
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: