-
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
Fix transaction leak when DMLs contains a non pltsql language function which calls another non tsql function inside try catch #3217
Fix transaction leak when DMLs contains a non pltsql language function which calls another non tsql function inside try catch #3217
Conversation
Pull Request Test Coverage Report for Build 12281033050Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
9b5ecd8
to
c9323eb
Compare
c9323eb
to
93cbed0
Compare
Signed-off-by: Tanzeel Khan <[email protected]>
93cbed0
to
3848657
Compare
@@ -4622,6 +4622,7 @@ exec_stmt_execsql(PLtsql_execstate *estate, | |||
bool fmtonly_enabled = true; | |||
CmdType cmd = CMD_UNKNOWN; | |||
bool enable_txn_in_triggers = !pltsql_disable_txn_in_triggers; | |||
bool support_tsql_trans = pltsql_support_tsql_transactions(); |
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.
Please see if this fix is needed for other callers of pltsql_support_tsql_transactions
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 made this change in pltsql_exec_trigger
. Change was not needed there, but did it anyway for consistency in code.
Signed-off-by: Tanzeel Khan <[email protected]>
8d92966
into
babelfish-for-postgresql:BABEL_5_X_DEV
…n which calls another non tsql function inside try catch (babelfish-for-postgresql#3217) When DMLs are executed outside a user transaction block, babelfish starts an implicit transaction to handle errors inside triggers. This is done irrespective of whether the statement actually fires a trigger. Now if the DML calls a non pltsql function which in calls another non tsql func or procedure inside a try catch, we do not properly decrement the pltsql_sys_func_entry_count variable properly. So the return value of pltsql_support_tsql_transactions() is different at beginning of the DML compared to after the end of the statement. This difference leads to babelfish not commit the implict transaction block. As a fix, store the value of pltsql_support_tsql_transactions() at start of execution of DML and just reuse it for after execution. Issues Resolved: [BABEL-5446] Signed-off-by: Tanzeel Khan [email protected]
…n which calls another non tsql function inside try catch (babelfish-for-postgresql#3217) When DMLs are executed outside a user transaction block, babelfish starts an implicit transaction to handle errors inside triggers. This is done irrespective of whether the statement actually fires a trigger. Now if the DML calls a non pltsql function which in calls another non tsql func or procedure inside a try catch, we do not properly decrement the pltsql_sys_func_entry_count variable properly. So the return value of pltsql_support_tsql_transactions() is different at beginning of the DML compared to after the end of the statement. This difference leads to babelfish not commit the implict transaction block. As a fix, store the value of pltsql_support_tsql_transactions() at start of execution of DML and just reuse it for after execution. Issues Resolved: [BABEL-5446] Signed-off-by: Tanzeel Khan [email protected]
…n which calls another non tsql function inside try catch (#3217) (#3272) When DMLs are executed outside a user transaction block, babelfish starts an implicit transaction to handle errors inside triggers. This is done irrespective of whether the statement actually fires a trigger. Now if the DML calls a non pltsql function which in calls another non tsql func or procedure inside a try catch, we do not properly decrement the pltsql_sys_func_entry_count variable properly. So the return value of pltsql_support_tsql_transactions() is different at beginning of the DML compared to after the end of the statement. This difference leads to babelfish not commit the implict transaction block. As a fix, store the value of pltsql_support_tsql_transactions() at start of execution of DML and just reuse it for after execution. Issues Resolved: [BABEL-5446] Signed-off-by: Tanzeel Khan [email protected]
…n which calls another non tsql function inside try catch (#3217) (#3273) When DMLs are executed outside a user transaction block, babelfish starts an implicit transaction to handle errors inside triggers. This is done irrespective of whether the statement actually fires a trigger. Now if the DML calls a non pltsql function which in calls another non tsql func or procedure inside a try catch, we do not properly decrement the pltsql_sys_func_entry_count variable properly. So the return value of pltsql_support_tsql_transactions() is different at beginning of the DML compared to after the end of the statement. This difference leads to babelfish not commit the implict transaction block. As a fix, store the value of pltsql_support_tsql_transactions() at start of execution of DML and just reuse it for after execution. Issues Resolved: [BABEL-5446] Signed-off-by: Tanzeel Khan [email protected]
Description
When DMLs are executed outside a user transaction block, babelfish starts an implicit transaction to handle errors inside triggers. This is done irrespective of whether the statement actually fires a trigger.
Now if the DML calls a non pltsql function which in calls another non tsql func or procedure inside a try catch, we do not properly decrement the
pltsql_sys_func_entry_count
variable properly. So the return value ofpltsql_support_tsql_transactions()
is different at beginning of the DML compared to after the end of the statement. This difference leads to babelfish not commit the implict transaction block.As a fix, store the value of pltsql_support_tsql_transactions() at start of execution of DML and just reuse it for after execution.
Issues Resolved
[BABEL-5446]
Sign Off
Signed-off-by: Tanzeel Khan [email protected]
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.