Commit 5f95f01b authored by unknown's avatar unknown

BUG#30996: Committed too early when autocommit and lock table

Moved out a lot of code into functions from external_lock and
start_stmt
Fixed a crashing bug at memory alloc failure
Merged the stmt and all variables into one trans variable
Always register start of statement as according to the
interface of the handlers.
Also register for start of transaction when not statement commit
== not autocommit AND no begin - commit ongoing
Now that we registered in a proper manner we also needed to handle
the commit call when end of statement and transaction is ongoing
Added start_stmt_count to know when we have start of statement
for first table


mysql-test/suite/ndb/r/ndb_lock_table.result:
  Added a new test case for bug30996
mysql-test/suite/ndb/t/ndb_lock_table.test:
  Added a new test case for bug30996
sql/ha_ndbcluster.cc:
  Moved out a lot of code into functions from external_lock and
  start_stmt
  Fixed a crashing bug at memory alloc failure
  Merged the stmt and all variables into one trans variable
  Always register start of statement as according to the
  interface of the handlers.
  Also register for start of transaction when not statement commit
  == not autocommit AND no begin - commit ongoing
  Now that we registered in a proper manner we also needed to handle
  the commit call when end of statement and transaction is ongoing
  Added start_stmt_count to know when we have start of statement
  for first table
sql/ha_ndbcluster.h:
  New functions and merged variables
parent 577a1633
drop table if exists t1;
create table t1 (a int) engine ndb;
set autocommit=1;
lock table t1 write;
set autocommit=0;
insert into t1 values (0);
rollback;
select * from t1;
a
unlock tables;
drop table t1;
-- source include/have_ndb.inc
# BUG 30996
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (a int) engine ndb;
set autocommit=1;
lock table t1 write;
set autocommit=0;
insert into t1 values (0);
rollback;
select * from t1;
unlock tables;
drop table t1;
This diff is collapsed.
......@@ -204,8 +204,8 @@ class Thd_ndb
Ndb *ndb;
ulong count;
uint lock_count;
NdbTransaction *all;
NdbTransaction *stmt;
uint start_stmt_count;
NdbTransaction *trans;
bool m_error;
bool m_slow_path;
int m_error_code;
......@@ -496,6 +496,10 @@ private:
friend int execute_no_commit(ha_ndbcluster*, NdbTransaction*, bool);
friend int execute_no_commit_ie(ha_ndbcluster*, NdbTransaction*, bool);
void transaction_checks(THD *thd);
int start_statement(THD *thd, Thd_ndb *thd_ndb, Ndb* ndb);
int init_handler_for_statement(THD *thd, Thd_ndb *thd_ndb);
NdbTransaction *m_active_trans;
NdbScanOperation *m_active_cursor;
const NdbDictionary::Table *m_table;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment