-
Notifications
You must be signed in to change notification settings - Fork 92
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
Reset cross-db flag for each statement #3237
Changes from 2 commits
4e00c8c
168aeb0
b20fa79
7a6c570
8ca2971
c72b9ca
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 |
---|---|---|
|
@@ -793,6 +793,372 @@ int | |
~~END~~ | ||
|
||
|
||
-- tsql | ||
-- Cross-db testcases for statements in batch/block | ||
USE master; | ||
GO | ||
|
||
-- Batches having system objects | ||
BEGIN; SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.sysdatabases; BEGIN; SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; END; END; | ||
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.
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. Also let's include below cases:
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.
Done.
Regarding, 2nd point - not adding anything for default db setting since it doesn't affect anything while query execution. It is only utilised while setting up a new db session. 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. regarding default_schema, It is being tracked by BABEL-5050, needs separate fix. |
||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
BEGIN; SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; BEGIN SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.sysdatabases; END; END; | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
BEGIN; SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.sysdatabases; END; BEGIN; SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; END; | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
BEGIN; SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; END; BEGIN SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.sysdatabases; END; | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; | ||
SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.sysdatabases; | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.sysdatabases; | ||
SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; | ||
SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.sysdatabases; | ||
SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.sysdatabases; | ||
SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; | ||
SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.sysdatabases; | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
-- Batches having user created objects | ||
BEGIN; SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.babel_cross_db_vu_prepare_db1_t1; BEGIN; SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; END; END; | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
BEGIN; SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; BEGIN SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.babel_cross_db_vu_prepare_db1_t1; END; END; | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
BEGIN; SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.babel_cross_db_vu_prepare_db1_t1; END; BEGIN; SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; END; | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
BEGIN; SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; END; BEGIN SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.babel_cross_db_vu_prepare_db1_t1; END; | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; | ||
SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.babel_cross_db_vu_prepare_db1_t1; | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.babel_cross_db_vu_prepare_db1_t1; | ||
SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; | ||
SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.babel_cross_db_vu_prepare_db1_t1; | ||
SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.babel_cross_db_vu_prepare_db1_t1; | ||
SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; | ||
SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.babel_cross_db_vu_prepare_db1_t1; | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
-- Batches having different types of DMLs | ||
BEGIN; INSERT INTO my_babel_cross_db_vu_prepare_db1.dbo.babel_cross_db_vu_prepare_db1_t1 VALUES (1); BEGIN; SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; END; END; | ||
GO | ||
~~ROW COUNT: 1~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
BEGIN; SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; BEGIN; INSERT INTO my_babel_cross_db_vu_prepare_db1.dbo.babel_cross_db_vu_prepare_db1_t1 VALUES (1); END; END; | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~ROW COUNT: 1~~ | ||
|
||
|
||
BEGIN; UPDATE my_babel_cross_db_vu_prepare_db1.dbo.babel_cross_db_vu_prepare_db1_t1 SET a = 2; BEGIN; SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; END; END; | ||
GO | ||
~~ROW COUNT: 10~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
BEGIN; SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; BEGIN; UPDATE my_babel_cross_db_vu_prepare_db1.dbo.babel_cross_db_vu_prepare_db1_t1 SET a = 2; END; END; | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~ROW COUNT: 10~~ | ||
|
||
|
||
BEGIN; DELETE FROM my_babel_cross_db_vu_prepare_db1.dbo.babel_cross_db_vu_prepare_db1_t1 WHERE a = 2; BEGIN; SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; END; END; | ||
GO | ||
~~ROW COUNT: 10~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
BEGIN; SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; BEGIN; DELETE FROM my_babel_cross_db_vu_prepare_db1.dbo.babel_cross_db_vu_prepare_db1_t1 WHERE a = 2; END; END; | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
-- Batches with subqueries | ||
SELECT DISTINCT (SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.babel_cross_db_vu_prepare_db1_t1 t2 WHERE t2.a = t1.a) FROM babel_cross_db_vu_prepare_master_t1 t1; | ||
SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; | ||
GO | ||
~~START~~ | ||
int | ||
<NULL> | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
SELECT DISTINCT 1 FROM babel_cross_db_vu_prepare_master_t1; | ||
SELECT DISTINCT (SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.babel_cross_db_vu_prepare_db1_t1 t2 WHERE t2.a = t1.a) FROM babel_cross_db_vu_prepare_master_t1 t1; | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
<NULL> | ||
~~END~~ | ||
|
||
|
||
-- Batches with DDL and DML combination | ||
BEGIN; SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.sysdatabases; BEGIN CREATE TABLE babel_cross_db_vu_verify_tempt(a int); SELECT DISTINCT 1 FROM babel_cross_db_vu_verify_tempt; END; END; | ||
GO | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
~~END~~ | ||
|
||
|
||
DROP TABLE babel_cross_db_vu_verify_tempt; | ||
GO | ||
|
||
BEGIN; CREATE TABLE babel_cross_db_vu_verify_tempt(a int); SELECT DISTINCT 1 FROM babel_cross_db_vu_verify_tempt; BEGIN; SELECT DISTINCT 1 FROM my_babel_cross_db_vu_prepare_db1.dbo.sysdatabases; END; END; | ||
GO | ||
~~START~~ | ||
int | ||
~~END~~ | ||
|
||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
|
||
DROP TABLE babel_cross_db_vu_verify_tempt; | ||
GO | ||
|
||
-- tsql | ||
USE master | ||
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.
We are also setting this flag to true in
makeExecuteProcedure
but not resetting it back. What would happen if we exec a batch likeThere 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 reset is_cross_db in enterDMLStatement ?
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.
Also seems like we can just remove use of this flag from
makeExecuteProcedure
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.
Yes, I noticed it too. On top of that we can cleanup some logic from pl_exec as well. We should track it separately because I assume there we will need more test coverage, can't just rely on existing tests to conclude that given logic is redundant.
Done.