Skip to content
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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions contrib/babelfishpg_tsql/src/tsqlIface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1857,6 +1857,7 @@ class tsqlBuilder : public tsqlCommonMutator
graft(makeSQL(ctx), peekContainer());
}

is_cross_db = false;
// prepare rewriting
clear_rewritten_query_fragment();
PLtsql_stmt_execsql *stmt = (PLtsql_stmt_execsql *) getPLtsql_fragment(ctx);
Expand Down Expand Up @@ -1917,7 +1918,10 @@ class tsqlBuilder : public tsqlCommonMutator

// record whether stmt is cross-db
if (is_cross_db)
{
stmt->is_cross_db = true;
is_cross_db = false;
Copy link
Contributor

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

Copy link
Contributor

@tanscorpio7 tanscorpio7 Dec 16, 2024

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 ?

Copy link
Contributor

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

Copy link
Contributor Author

@HarshLunagariya HarshLunagariya Dec 16, 2024

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.

}
// record that the stmt is dml
stmt->is_dml = true;
// record if a function call
Expand Down
Loading
Loading