-
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
Reset cross-db flag for each statement #3237
Conversation
Signed-off-by: Harsh Lunagariya <[email protected]>
Pull Request Test Coverage Report for Build 12408305896Details
💛 - Coveralls |
Signed-off-by: Harsh Lunagariya <[email protected]>
84bc298
to
168aeb0
Compare
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.
LGTM!
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 comment
The reason will be displayed to describe this comment to others. Learn more.
- Let's also add test where we call
sys
objects as well like db1.sys.databases etc. - Create temp tables after executing cross-db stmt as DDL permissions work differently.
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 let's include below cases:
- tests for statements in batch inside a transaction.
- some cases where login/user has some default db and schemas with it and it's executing one cross-db query with other queries in a batch.
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.
- Let's also add test where we call
sys
objects as well like db1.sys.databases etc.- Create temp tables after executing cross-db stmt as DDL permissions work differently.
Done.
Also let's include below cases:
- tests for statements in batch inside a transaction.
- some cases where login/user has some default db and schemas with it and it's executing one cross-db query with other queries in a batch.
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 comment
The 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 | ||
|
||
-- 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Also let's include below cases:
- tests for statements in batch inside a transaction.
- some cases where login/user has some default db and schemas with it and it's executing one cross-db query with other queries in a batch.
Signed-off-by: Harsh Lunagariya <[email protected]>
stmt->is_cross_db = true; | ||
is_cross_db = false; |
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 like
EXEC db.dbo.p
SELECT * FROM t
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 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.
Also seems like we can just remove use of this flag from makeExecuteProcedure
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.
can we reset is_cross_db in enterDMLStatement ?
Done.
Signed-off-by: Harsh Lunagariya <[email protected]>
d931262
to
7a6c570
Compare
Signed-off-by: Harsh Lunagariya <[email protected]>
decfd2d
to
8ca2971
Compare
~~ROW COUNT: 4~~ | ||
|
||
|
||
SELECT * FROM my_babel_cross_db_vu_prepare_db1.dbo.babel_cross_db_vu_prepare_db1_t1; |
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.
This one needs an ORDER BY clause or else it will be flaky.
~~ROW COUNT: 1~~ | ||
|
||
|
||
SELECT * FROM my_babel_cross_db_vu_prepare_db1.dbo.babel_cross_db_vu_prepare_db1_t1; |
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.
This one also needs an ORDER BY clause.
~~ROW COUNT: 1~~ | ||
|
||
|
||
SELECT * FROM dbo.my_babel_cross_db_vu_prepare_db1_t2; |
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.
Same here, needs ORDER BY.
Signed-off-by: Harsh Lunagariya <[email protected]>
d2e7653
into
babelfish-for-postgresql:BABEL_5_X_DEV
Earlier, while parsing the batch, We were marking the all the subsequent statements of the batch as cross-database statements once we encounter any cross-database statement in batch which was incorrect. This commit fixes above behaviour by resetting 'is_cross_db' maintained at mutator level once we mark some statement as cross_db in the parse tree. Task: BABEL-5447 Signed-off-by: Harsh Lunagariya <[email protected]>
Earlier, while parsing the batch, We were marking the all the subsequent statements of the batch as cross-database statements once we encounter any cross-database statement in batch which was incorrect. This commit fixes above behaviour by resetting 'is_cross_db' maintained at mutator level once we mark some statement as cross_db in the parse tree. Task: BABEL-5447 Signed-off-by: Harsh Lunagariya <[email protected]>
Earlier, while parsing the batch, We were marking the all the subsequent statements of the batch as cross-database statements once we encounter any cross-database statement in batch which was incorrect. This commit fixes above behaviour by resetting 'is_cross_db' maintained at mutator level once we mark some statement as cross_db in the parse tree. Cherry-pick of d2e7653 Task: BABEL-5447 Signed-off-by: Harsh Lunagariya <[email protected]>
Earlier, while parsing the batch, We were marking the all the subsequent statements of the batch as cross-database statements once we encounter any cross-database statement in batch which was incorrect. This commit fixes above behaviour by resetting 'is_cross_db' maintained at mutator level once we mark some statement as cross_db in the parse tree. Cherry-pick of d2e7653 Task: BABEL-5447 Signed-off-by: Harsh Lunagariya <[email protected]>
Description
Earlier, while parsing the batch, We were marking the all the subsequent statements of the batch as cross-database statements once we encounter any cross-database statement in batch which was incorrect.
This commit fixes above behaviour by resetting 'is_cross_db' maintained at mutator level once we mark some statement as cross_db in the parse tree.
Issues Resolved
BABEL-5447
Test Scenarios Covered
Use case based -
Boundary conditions -
Arbitrary inputs -
Negative test cases -
Minor version upgrade tests -
Major version upgrade tests -
Performance tests -
Tooling impact -
Client tests -
Check List
By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.