Skip to content

Commit

Permalink
Reset cross-db flag for each statement (#3237) (#3305)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
HarshLunagariya authored Dec 24, 2024
1 parent 92e34b5 commit f8a5d62
Show file tree
Hide file tree
Showing 3 changed files with 1,621 additions and 0 deletions.
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;
}
// record that the stmt is dml
stmt->is_dml = true;
// record if a function call
Expand Down
Loading

0 comments on commit f8a5d62

Please sign in to comment.