Skip to content

Commit

Permalink
Test changes for 'Fix error when trying to drop columns from temp tab…
Browse files Browse the repository at this point in the history
…les.' (#2753) (#2779)

Tests for babelfish-for-postgresql/postgresql_modified_for_babelfish#410

Task: BABEL-4912

Signed-off-by: Jason Teng <[email protected]>
  • Loading branch information
Sairakan authored Jul 24, 2024
1 parent c49db09 commit 633c293
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 79 deletions.
89 changes: 89 additions & 0 deletions test/JDBC/expected/temp_table.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
-- 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 a
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: cannot drop a column used by a generated column)~~


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
22 changes: 3 additions & 19 deletions test/JDBC/expected/temp_table_rollback-vu-verify.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)~~


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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,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
Expand All @@ -221,37 +221,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)~~


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
Expand Down
22 changes: 3 additions & 19 deletions test/JDBC/expected/temp_table_rollback_isolation_snapshot.out
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,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
Expand All @@ -221,37 +221,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)~~


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
Expand Down
22 changes: 3 additions & 19 deletions test/JDBC/expected/temp_table_rollback_xact_abort_on.out
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,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
Expand All @@ -221,37 +221,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)~~


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
Expand Down
48 changes: 48 additions & 0 deletions test/JDBC/input/temp_tables/temp_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
-- 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 a
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
6 changes: 3 additions & 3 deletions test/JDBC/input/temp_tables/temp_table_rollback-vu-verify.sql
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,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
Expand All @@ -95,12 +95,12 @@ ROLLBACK
GO

BEGIN TRAN
ALTER TABLE #temp_table_rollback_t1 DROP COLUMN b
ALTER TABLE #temp_table_rollback_t1 ALTER COLUMN b VARCHAR
COMMIT
GO

BEGIN TRAN
ALTER TABLE #temp_table_rollback_t1 ALTER COLUMN b VARCHAR
ALTER TABLE #temp_table_rollback_t1 DROP COLUMN b
COMMIT
GO

Expand Down

0 comments on commit 633c293

Please sign in to comment.