-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix alter table drop constraint not able to drop some constraints (#2602
) Babelfish was hashing the constraint name for named table constraints. But no hashing was done for unnamed table constraints, unnamed column constraints or named column constraints. On the other hand the constraint name in DROP CONSTRAINT was always hashed without exception. This means we were failing DROP for all constraints which were not hashed during creation. As a fix, we have removed the hashing step from named table constraints creation, making creation of constraints consistent for Babelfish. This also allows us to remove hashing from DROP CONSTRAINT command. Not hashing constraint name has one repercussion, Users can now create a PRIMARY KEY/UNIQUE constraint with same name as an existing Index on the same table. This was previously blocked for named table constraints but not for other types of constraints. We could block this in the future in a more complete way. Issues Resolved: BABEL-2047 Signed-off-by: Tanzeel Khan [email protected]
- Loading branch information
1 parent
c3340fd
commit d89aba9
Showing
47 changed files
with
1,752 additions
and
152 deletions.
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
41 changes: 41 additions & 0 deletions
41
test/JDBC/expected/BABEL-621-after-14_12-before-15-vu-cleanup.out
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
DROP INDEX idx on babel_621_vu_prepare_table_1; | ||
DROP INDEX idx on babel_621_vu_prepare_table_2; | ||
GO | ||
|
||
DROP INDEX uniq on babel_621_vu_prepare_table_3; | ||
GO | ||
|
||
DROP INDEX very_long_index_name_on_a_table_1234567890_1234567890_1234567890_1234567890_1234567890 on babel_621_vu_prepare_table_with_long_index_name; | ||
GO | ||
|
||
DROP INDEX very_long_index_name_on_a_table_1234567890_1234567890_1234567890_1234567890_1234567890 on babel_621_table_with_long_name_1234567890_1234567890_1234567890_1234567890_1234567890; | ||
GO | ||
|
||
DROP TABLE babel_621_vu_prepare_table_1; | ||
GO | ||
DROP TABLE babel_621_vu_prepare_table_2; | ||
GO | ||
DROP TABLE babel_621_vu_prepare_table_3; | ||
GO | ||
DROP TABLE babel_621_vu_prepare_table_4; | ||
GO | ||
DROP TABLE babel_621_vu_prepare_table_with_long_index_name; | ||
GO | ||
DROP TABLE babel_621_vu_prepare_second_table_with_long_index_name; | ||
GO | ||
DROP TABLE babel_621_table_with_long_name_1234567890_1234567890_1234567890_1234567890_1234567890; | ||
GO | ||
DROP TABLE babel_621_second_table_with_long_name_1234567890_1234567890_1234567890_1234567890_1234567890; | ||
GO | ||
DROP TABLE babel_621_vu_prepare_table_6; | ||
GO | ||
DROP TABLE table_6; | ||
GO | ||
DROP TABLE table_7; | ||
GO | ||
DROP TABLE babel_621_vu_prepare_table_7; | ||
GO | ||
DROP TABLE babel_621_vu_prepare_table_8; | ||
GO | ||
DROP TABLE babel_621_vu_prepare_table_10; | ||
GO |
114 changes: 114 additions & 0 deletions
114
test/JDBC/expected/BABEL-621-after-14_12-before-15-vu-prepare.out
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
EXECUTE sp_babelfish_configure 'escape_hatch_unique_constraint', 'ignore' | ||
go | ||
|
||
create table babel_621_vu_prepare_table_1 (a int); | ||
go | ||
create table babel_621_vu_prepare_table_2 (a int); | ||
go | ||
create index idx on babel_621_vu_prepare_table_1(a); | ||
go | ||
create index idx on babel_621_vu_prepare_table_2(a); | ||
go | ||
|
||
create table babel_621_vu_prepare_table_3 (a int); | ||
go | ||
alter table babel_621_vu_prepare_table_3 add constraint uniq unique (a); | ||
go | ||
create index uniq on babel_621_vu_prepare_table_3(a); | ||
go | ||
|
||
create table babel_621_vu_prepare_table_4 (a int); | ||
go | ||
create index uniq_table_4 on babel_621_vu_prepare_table_4(a); | ||
go | ||
alter table babel_621_vu_prepare_table_4 add constraint uniq_table_4 unique (a); | ||
go | ||
alter table babel_621_vu_prepare_table_4 drop constraint uniq_table_4; | ||
go | ||
|
||
-- Very long index name | ||
create table babel_621_vu_prepare_table_with_long_index_name (a int); | ||
go | ||
create index very_long_index_name_on_a_table_1234567890_1234567890_1234567890_1234567890_1234567890 on babel_621_vu_prepare_table_with_long_index_name(a); | ||
go | ||
|
||
create table babel_621_vu_prepare_second_table_with_long_index_name (a int); | ||
go | ||
create index very_long_index_name_on_a_table_1234567890_1234567890_1234567890_1234567890_1234567890 on babel_621_vu_prepare_second_table_with_long_index_name(a); | ||
go | ||
|
||
-- Very long table name and very long index name | ||
create table babel_621_table_with_long_name_1234567890_1234567890_1234567890_1234567890_1234567890 (a int); | ||
go | ||
create index very_long_index_name_on_a_table_1234567890_1234567890_1234567890_1234567890_1234567890 on babel_621_table_with_long_name_1234567890_1234567890_1234567890_1234567890_1234567890(a); | ||
go | ||
|
||
create table babel_621_second_table_with_long_name_1234567890_1234567890_1234567890_1234567890_1234567890 (a int); | ||
go | ||
create index very_long_index_name_on_a_table_1234567890_1234567890_1234567890_1234567890_1234567890 on babel_621_second_table_with_long_name_1234567890_1234567890_1234567890_1234567890_1234567890(a); | ||
go | ||
|
||
-- Situation where simple concatenation of table and index name does not work | ||
-- E.g. table_a + index_a == table_b + index_b | ||
create table babel_621_vu_prepare_table_6 (a int); | ||
go | ||
create index idx_ on babel_621_vu_prepare_table_6(a); | ||
go | ||
|
||
create table table_6 (a int); | ||
go | ||
create index idx_babel_621_vu_prepare_ on table_6(a); | ||
go | ||
-- Situation where simple concatenation of index and table name does not work (reverse of previous) | ||
-- E.g. index_a + table_a == index_b + table_b | ||
create table table_7 (a int); | ||
go | ||
create index idx_babel_621_vu_prepare_ on table_7(a); | ||
go | ||
|
||
create table babel_621_vu_prepare_table_7 (a int); | ||
go | ||
create index idx_ on babel_621_vu_prepare_table_7(a); | ||
go | ||
|
||
-- | ||
create table babel_621_vu_prepare_table_8 ( | ||
a int, | ||
value int, | ||
constraint constraint_8 unique nonclustered | ||
( | ||
value asc | ||
) | ||
) | ||
go | ||
alter table babel_621_vu_prepare_table_8 drop constraint constraint_8; | ||
go | ||
insert into babel_621_vu_prepare_table_8 values(1, 1); | ||
insert into babel_621_vu_prepare_table_8 values(2, 1); | ||
go | ||
~~ROW COUNT: 1~~ | ||
|
||
~~ROW COUNT: 1~~ | ||
|
||
|
||
create table babel_621_vu_prepare_table_10 | ||
( | ||
a int, | ||
b int, | ||
c int | ||
) | ||
go | ||
create unique index idx on babel_621_vu_prepare_table_10 (a, b); | ||
go | ||
insert into babel_621_vu_prepare_table_10 values(1, 1, 1); | ||
insert into babel_621_vu_prepare_table_10 values(1, 2, 1); | ||
insert into babel_621_vu_prepare_table_10 values(1, 2, 2); | ||
go | ||
~~ROW COUNT: 1~~ | ||
|
||
~~ROW COUNT: 1~~ | ||
|
||
~~ERROR (Code: 2627)~~ | ||
|
||
~~ERROR (Message: duplicate key value violates unique constraint "idxbabel_621_vu_prepare_table_147dc0d6e295169e8ba6e11ebeb1c6472")~~ | ||
|
15 changes: 15 additions & 0 deletions
15
test/JDBC/expected/BABEL-621-after-14_12-before-15-vu-verify.out
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
select a, value from babel_621_vu_prepare_table_8 order by a; | ||
go | ||
~~START~~ | ||
int#!#int | ||
1#!#1 | ||
2#!#1 | ||
~~END~~ | ||
|
||
|
||
drop index idx on babel_621_vu_prepare_table_10; | ||
go | ||
insert into babel_621_vu_prepare_table_10 values(1, 2, 2); | ||
go | ||
~~ROW COUNT: 1~~ | ||
|
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
Oops, something went wrong.