Skip to content

Commit

Permalink
0001940: On MySQL sym_transaction_id_post_5_1_23 function should not …
Browse files Browse the repository at this point in the history
…be checking the autocommit session variable
  • Loading branch information
chenson42 committed Aug 27, 2014
1 parent 9de185f commit d6afb33
Showing 1 changed file with 25 additions and 29 deletions.
Expand Up @@ -78,41 +78,37 @@ public void createRequiredDatabaseObjects() {
if (this.functionTemplateKeySuffix.equals(PRE_5_1_23)) {
String function = this.parameterService.getTablePrefix() + "_" + TRANSACTION_ID + this.functionTemplateKeySuffix;
if (!installed(SQL_FUNCTION_INSTALLED, function)) {
String sql = "create function $(functionName)() " +
" returns varchar(50) NOT DETERMINISTIC READS SQL DATA " +
" begin " +
" declare comm_name varchar(50); " +
" declare comm_value varchar(50); " +
" declare comm_cur cursor for show status like 'Com_commit'; " +
" if @@autocommit = 0 then " +
" open comm_cur; " +
" fetch comm_cur into comm_name, comm_value; " +
" close comm_cur; " +
" return concat(concat(connection_id(), '.'), comm_value); " +
" else " +
" return null; " +
" end if; " +
" end ";
String sql = "create function $(functionName)() " +
" returns varchar(50) NOT DETERMINISTIC READS SQL DATA " +
" begin " +
" declare comm_name varchar(50); " +
" declare comm_value varchar(50); " +
" declare comm_cur cursor for show status like 'Com_commit'; " +
" if @@autocommit = 0 then " +
" open comm_cur; " +
" fetch comm_cur into comm_name, comm_value; " +
" close comm_cur; " +
" return concat(concat(connection_id(), '.'), comm_value); " +
" else " +
" return null; " +
" end if; " +
" end ";
install(sql, function);
}

} else {
String function = this.parameterService.getTablePrefix() + "_" + TRANSACTION_ID + this.functionTemplateKeySuffix;
if (!installed(SQL_FUNCTION_INSTALLED, function)) {
String sql = "create function $(functionName)() " +
" returns varchar(50) NOT DETERMINISTIC READS SQL DATA " +
" begin " +
" declare comm_value varchar(50); " +
" declare comm_cur cursor for select VARIABLE_VALUE from INFORMATION_SCHEMA.SESSION_STATUS where VARIABLE_NAME='COM_COMMIT'; " +
" if @@autocommit = 0 then " +
" open comm_cur; " +
" fetch comm_cur into comm_value; " +
" close comm_cur; " +
" return concat(concat(connection_id(), '.'), comm_value); " +
" else " +
" return null; " +
" end if; " +
" end ";
String sql = "create function $(functionName)() " +
" returns varchar(50) NOT DETERMINISTIC READS SQL DATA \n" +
" begin \n" +
" declare comm_value varchar(50); \n" +
" declare comm_cur cursor for select VARIABLE_VALUE from INFORMATION_SCHEMA.SESSION_STATUS where VARIABLE_NAME='COM_COMMIT'; \n" +
" open comm_cur; \n" +
" fetch comm_cur into comm_value; \n" +
" close comm_cur; \n" +
" return concat(concat(connection_id(), '.'), comm_value); \n" +
" end \n";
install(sql, function);
}
}
Expand Down

0 comments on commit d6afb33

Please sign in to comment.