-
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.
Signed-off-by: Chenxiao Wang <[email protected]>
- Loading branch information
Chenxiao Wang
committed
Dec 20, 2024
1 parent
12af309
commit ea4e954
Showing
6 changed files
with
326 additions
and
0 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
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 |
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,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 |
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,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 | ||
|
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,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 |
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,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 |
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,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 | ||
|