-
Notifications
You must be signed in to change notification settings - Fork 97
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
Test changes for 'Fix error when trying to drop columns from temp tables.' #2753
Changes from 5 commits
dcb2570
c45114d
a3de207
e423172
e4a22ec
55f5489
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
-- BABEL-4912 test ALTER TABLE for temp tables | ||
CREATE TABLE #t1 (a INT IDENTITY PRIMARY KEY NOT NULL, b INT) | ||
GO | ||
|
||
INSERT INTO #t1 (b) values (1) | ||
GO | ||
~~ROW COUNT: 1~~ | ||
|
||
|
||
SELECT * FROM #t1 | ||
GO | ||
~~START~~ | ||
int#!#int | ||
1#!#1 | ||
~~END~~ | ||
|
||
|
||
ALTER TABLE #t1 DROP COLUMN b | ||
GO | ||
|
||
SELECT * FROM #t1 | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
ALTER TABLE #t1 ADD b varchar(20) | ||
GO | ||
|
||
SELECT * FROM #t1 | ||
GO | ||
~~START~~ | ||
int#!#varchar | ||
1#!#<NULL> | ||
~~END~~ | ||
|
||
|
||
ALTER TABLE #t1 ADD c AS a + 1 | ||
GO | ||
|
||
SELECT * FROM #t1 | ||
GO | ||
~~START~~ | ||
int#!#varchar#!#int | ||
1#!#<NULL>#!#2 | ||
~~END~~ | ||
|
||
|
||
ALTER TABLE #t1 DROP COLUMN b | ||
GO | ||
|
||
SELECT * FROM #t1 | ||
GO | ||
~~START~~ | ||
int#!#int | ||
1#!#2 | ||
~~END~~ | ||
|
||
|
||
ALTER TABLE #t1 DROP COLUMN c | ||
GO | ||
|
||
SELECT * FROM #t1 | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
DROP TABLE #t1 | ||
GO |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,7 +144,7 @@ COMMIT | |
GO | ||
|
||
---------------------------------------------------------- | ||
-- ALTER TABLE (should fail due to BABEL-4912) | ||
-- ALTER TABLE (BABEL-4912) | ||
---------------------------------------------------------- | ||
CREATE TABLE #temp_table_rollback_t1 (a int, b int) | ||
GO | ||
|
@@ -153,37 +153,21 @@ BEGIN TRAN | |
ALTER TABLE #temp_table_rollback_t1 DROP COLUMN b | ||
ROLLBACK | ||
GO | ||
~~ERROR (Code: 3726)~~ | ||
|
||
~~ERROR (Message: cannot drop column b of table "#temp_table_rollback_t1" because other objects depend on it)~~ | ||
|
||
Comment on lines
-156
to
-159
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for handling this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just added an extra test case, that while not reproducing this exact error, produces a similar error due to a dependency. |
||
|
||
BEGIN TRAN | ||
ALTER TABLE #temp_table_rollback_t1 ALTER COLUMN b VARCHAR | ||
ROLLBACK | ||
GO | ||
~~ERROR (Code: 33557097)~~ | ||
|
||
~~ERROR (Message: unexpected object depending on column: type "#temp_table_rollback_t1")~~ | ||
|
||
|
||
BEGIN TRAN | ||
ALTER TABLE #temp_table_rollback_t1 DROP COLUMN b | ||
ALTER TABLE #temp_table_rollback_t1 ALTER COLUMN b VARCHAR | ||
COMMIT | ||
GO | ||
~~ERROR (Code: 3726)~~ | ||
|
||
~~ERROR (Message: cannot drop column b of table "#temp_table_rollback_t1" because other objects depend on it)~~ | ||
|
||
|
||
BEGIN TRAN | ||
ALTER TABLE #temp_table_rollback_t1 ALTER COLUMN b VARCHAR | ||
ALTER TABLE #temp_table_rollback_t1 DROP COLUMN b | ||
COMMIT | ||
GO | ||
~~ERROR (Code: 33557097)~~ | ||
|
||
~~ERROR (Message: unexpected object depending on column: type "#temp_table_rollback_t1")~~ | ||
|
||
|
||
DROP TABLE #temp_table_rollback_t1 | ||
GO | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
-- BABEL-4912 test ALTER TABLE for temp tables | ||
CREATE TABLE #t1 (a INT IDENTITY PRIMARY KEY NOT NULL, b INT) | ||
GO | ||
|
||
INSERT INTO #t1 (b) values (1) | ||
GO | ||
|
||
SELECT * FROM #t1 | ||
GO | ||
|
||
ALTER TABLE #t1 DROP COLUMN b | ||
GO | ||
|
||
SELECT * FROM #t1 | ||
GO | ||
|
||
ALTER TABLE #t1 ADD b varchar(20) | ||
GO | ||
|
||
SELECT * FROM #t1 | ||
GO | ||
|
||
ALTER TABLE #t1 ADD c AS a + 1 | ||
GO | ||
|
||
SELECT * FROM #t1 | ||
GO | ||
|
||
ALTER TABLE #t1 DROP COLUMN b | ||
GO | ||
|
||
SELECT * FROM #t1 | ||
GO | ||
|
||
ALTER TABLE #t1 DROP COLUMN c | ||
GO | ||
|
||
SELECT * FROM #t1 | ||
GO | ||
|
||
DROP TABLE #t1 | ||
GO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add more tests, such as
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added more test cases. Note that foreign key constraints are not allowed for temp tables, so I can't test that.