Skip to content

Commit

Permalink
Seperate testing files
Browse files Browse the repository at this point in the history
Signed-off-by: Chenxiao Wang <[email protected]>
  • Loading branch information
Chenxiao Wang committed Dec 20, 2024
1 parent 12af309 commit ea4e954
Show file tree
Hide file tree
Showing 6 changed files with 326 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/JDBC/expected/BABEL-2961-vu-cleanup.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
IF OBJECT_ID('dbo.SomeNonExistentTable', 'U') IS NOT NULL
DROP TABLE dbo.SomeNonExistentTable
GO


IF OBJECT_ID('dbo.NonExistentTableView', 'V') IS NOT NULL
DROP VIEW dbo.NonExistentTableView
GO

IF OBJECT_ID('dbo.NonExistentTableFunc', 'IF') IS NOT NULL
DROP FUNCTION dbo.NonExistentTableFunc
GO

IF OBJECT_ID('dbo.CallNonExistentProc', 'P') IS NOT NULL
DROP PROCEDURE dbo.CallNonExistentProc
GO

IF OBJECT_ID('dbo.TestTable', 'U') IS NOT NULL
DROP TABLE dbo.TestTable
GO

IF OBJECT_ID('dbo.NonExistentTable', 'U') IS NOT NULL
DROP TABLE dbo.NonExistentTable
GO

IF OBJECT_ID('dbo.DropNonExistentUser', 'P') IS NOT NULL
DROP PROCEDURE dbo.DropNonExistentUser
GO

IF OBJECT_ID('dbo.NonExistentProc', 'P') IS NOT NULL
DROP PROCEDURE dbo.NonExistentProc
GO

IF OBJECT_ID('nonexistent_schema.TestFunc', 'FN') IS NOT NULL
DROP FUNCTION nonexistent_schema.TestFunc
GO
54 changes: 54 additions & 0 deletions test/JDBC/expected/BABEL-2961-vu-prepare.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
-- Create a view that attempts to select from a non-existent table
CREATE VIEW dbo.NonExistentTableView AS
SELECT * FROM dbo.SomeNonExistentTable
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: relation "dbo.somenonexistenttable" does not exist)~~



-- Create a function that attempts to select from a non-existent table
CREATE FUNCTION dbo.NonExistentTableFunc()
RETURNS TABLE
AS
RETURN
(
SELECT * FROM dbo.SomeNonExistentTable
)
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: relation "dbo.somenonexistenttable" does not exist)~~


-- Create a procedure that attempts to execute a non-existent procedure
CREATE PROCEDURE dbo.CallNonExistentProc
AS
BEGIN
EXEC dbo.NonExistentProc
END
GO


-- Create a function that attempts to use a non-existent schema
CREATE FUNCTION nonexistent_schema.TestFunc()
RETURNS INT
AS
BEGIN
RETURN 1
END
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: schema "nonexistent_schema" does not exist)~~



-- Create a procedure that attempts to drop a non-existent user
CREATE PROCEDURE dbo.DropNonExistentUser
AS
BEGIN
DROP USER NonExistentUser
END
GO
104 changes: 104 additions & 0 deletions test/JDBC/expected/BABEL-2961-vu-verify.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
CREATE TABLE myschema.t(a int)
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: schema "myschema" does not exist)~~


EXEC dbo.myproc
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: procedure dbo.myproc() does not exist)~~


SELECT * FROM dbo.t14
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: relation "dbo.t14" does not exist)~~


DROP USER smith
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: Cannot drop the user 'smith', because it does not exist or you do not have permission.)~~


EXEC dbo.CallNonExistentProc
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: procedure dbo.nonexistentproc() does not exist)~~


EXEC dbo.DropNonExistentUser
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: Cannot drop the user 'nonexistentuser', because it does not exist or you do not have permission.)~~


-- Attempt multiple operations within a single transaction
BEGIN TRANSACTION
CREATE TABLE dbo.TestTable (ID INT)
INSERT INTO dbo.TestTable VALUES (1)
SELECT * FROM dbo.NonExistentTable
COMMIT
GO
~~ROW COUNT: 1~~

~~ERROR (Code: 33557097)~~

~~ERROR (Message: relation "dbo.nonexistenttable" does not exist)~~


-- Verify if the transaction rolled back correctly
SELECT * FROM dbo.TestTable
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: relation "dbo.testtable" does not exist)~~


CREATE DATABASE TestDB2961
GO

USE TestDB2961
GO

CREATE TABLE myschema.t(a int)
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: schema "myschema" does not exist)~~


EXEC dbo.myproc
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: procedure dbo.myproc() does not exist)~~


SELECT * FROM dbo.t14
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: relation "dbo.t14" does not exist)~~


DROP USER smith
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: Cannot drop the user 'smith', because it does not exist or you do not have permission.)~~


USE master
GO

DROP DATABASE TestDB2961
GO

36 changes: 36 additions & 0 deletions test/JDBC/input/BABEL-2961-vu-cleanup.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
IF OBJECT_ID('dbo.SomeNonExistentTable', 'U') IS NOT NULL
DROP TABLE dbo.SomeNonExistentTable
GO


IF OBJECT_ID('dbo.NonExistentTableView', 'V') IS NOT NULL
DROP VIEW dbo.NonExistentTableView
GO

IF OBJECT_ID('dbo.NonExistentTableFunc', 'IF') IS NOT NULL
DROP FUNCTION dbo.NonExistentTableFunc
GO

IF OBJECT_ID('dbo.CallNonExistentProc', 'P') IS NOT NULL
DROP PROCEDURE dbo.CallNonExistentProc
GO

IF OBJECT_ID('dbo.TestTable', 'U') IS NOT NULL
DROP TABLE dbo.TestTable
GO

IF OBJECT_ID('dbo.NonExistentTable', 'U') IS NOT NULL
DROP TABLE dbo.NonExistentTable
GO

IF OBJECT_ID('dbo.DropNonExistentUser', 'P') IS NOT NULL
DROP PROCEDURE dbo.DropNonExistentUser
GO

IF OBJECT_ID('dbo.NonExistentProc', 'P') IS NOT NULL
DROP PROCEDURE dbo.NonExistentProc
GO

IF OBJECT_ID('nonexistent_schema.TestFunc', 'FN') IS NOT NULL
DROP FUNCTION nonexistent_schema.TestFunc
GO
42 changes: 42 additions & 0 deletions test/JDBC/input/BABEL-2961-vu-prepare.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
-- Create a view that attempts to select from a non-existent table
CREATE VIEW dbo.NonExistentTableView AS
SELECT * FROM dbo.SomeNonExistentTable
GO


-- Create a function that attempts to select from a non-existent table
CREATE FUNCTION dbo.NonExistentTableFunc()
RETURNS TABLE
AS
RETURN
(
SELECT * FROM dbo.SomeNonExistentTable
)
GO

-- Create a procedure that attempts to execute a non-existent procedure
CREATE PROCEDURE dbo.CallNonExistentProc
AS
BEGIN
EXEC dbo.NonExistentProc
END
GO


-- Create a function that attempts to use a non-existent schema
CREATE FUNCTION nonexistent_schema.TestFunc()
RETURNS INT
AS
BEGIN
RETURN 1
END
GO


-- Create a procedure that attempts to drop a non-existent user
CREATE PROCEDURE dbo.DropNonExistentUser
AS
BEGIN
DROP USER NonExistentUser
END
GO
54 changes: 54 additions & 0 deletions test/JDBC/input/BABEL-2961-vu-verify.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
CREATE TABLE myschema.t(a int)
GO

EXEC dbo.myproc
GO

SELECT * FROM dbo.t14
GO

DROP USER smith
GO

EXEC dbo.CallNonExistentProc
GO

EXEC dbo.DropNonExistentUser
GO

-- Attempt multiple operations within a single transaction
BEGIN TRANSACTION
CREATE TABLE dbo.TestTable (ID INT)
INSERT INTO dbo.TestTable VALUES (1)
SELECT * FROM dbo.NonExistentTable
COMMIT
GO

-- Verify if the transaction rolled back correctly
SELECT * FROM dbo.TestTable
GO

CREATE DATABASE TestDB2961
GO

USE TestDB2961
GO

CREATE TABLE myschema.t(a int)
GO

EXEC dbo.myproc
GO

SELECT * FROM dbo.t14
GO

DROP USER smith
GO

USE master
GO

DROP DATABASE TestDB2961
GO

0 comments on commit ea4e954

Please sign in to comment.