summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRamil Kalimullin <ramil@mysql.com>2009-03-27 13:34:24 +0400
committerRamil Kalimullin <ramil@mysql.com>2009-03-27 13:34:24 +0400
commitad7e825d54d618957fe62027644c5173db67a7c8 (patch)
tree3c97f7a4db77ed478b48a99991c4b6ead65d5164
parent296390a20f25a1c7573cfa38d078f9b2be88f0fb (diff)
parentc2c47b67fd6f6130b941a0b50fa701b0bb105ba7 (diff)
downloadmariadb-git-ad7e825d54d618957fe62027644c5173db67a7c8.tar.gz
Merge
-rw-r--r--mysql-test/include/mix1.inc40
-rw-r--r--mysql-test/r/innodb_mysql.result30
-rw-r--r--sql/handler.cc16
3 files changed, 83 insertions, 3 deletions
diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc
index cc9183205be..5531f877872 100644
--- a/mysql-test/include/mix1.inc
+++ b/mysql-test/include/mix1.inc
@@ -1122,6 +1122,46 @@ SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5;
DROP TABLE t1;
+#
+# Bug#37284 Crash in Field_string::type()
+#
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+CREATE TABLE t1 (a char(50)) ENGINE=InnoDB;
+CREATE INDEX i1 on t1 (a(3));
+SELECT * FROM t1 WHERE a = 'abcde';
+DROP TABLE t1;
+
+
+--echo #
+--echo # BUG #26288: savepoint are not deleted on comit, if the transaction
+--echo # was otherwise empty
+--echo #
+BEGIN;
+SAVEPOINT s1;
+COMMIT;
+--error 1305
+RELEASE SAVEPOINT s1;
+
+BEGIN;
+SAVEPOINT s2;
+COMMIT;
+--error 1305
+ROLLBACK TO SAVEPOINT s2;
+
+BEGIN;
+SAVEPOINT s3;
+ROLLBACK;
+--error 1305
+RELEASE SAVEPOINT s3;
+
+BEGIN;
+SAVEPOINT s4;
+ROLLBACK;
+--error 1305
+ROLLBACK TO SAVEPOINT s4;
+
--echo End of 5.0 tests
# Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY
diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result
index 6fcc9415d12..57dc11c3501 100644
--- a/mysql-test/r/innodb_mysql.result
+++ b/mysql-test/r/innodb_mysql.result
@@ -1378,6 +1378,36 @@ a b c
5 1 1
4 1 1
DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a char(50)) ENGINE=InnoDB;
+CREATE INDEX i1 on t1 (a(3));
+SELECT * FROM t1 WHERE a = 'abcde';
+a
+DROP TABLE t1;
+#
+# BUG #26288: savepoint are not deleted on comit, if the transaction
+# was otherwise empty
+#
+BEGIN;
+SAVEPOINT s1;
+COMMIT;
+RELEASE SAVEPOINT s1;
+ERROR 42000: SAVEPOINT s1 does not exist
+BEGIN;
+SAVEPOINT s2;
+COMMIT;
+ROLLBACK TO SAVEPOINT s2;
+ERROR 42000: SAVEPOINT s2 does not exist
+BEGIN;
+SAVEPOINT s3;
+ROLLBACK;
+RELEASE SAVEPOINT s3;
+ERROR 42000: SAVEPOINT s3 does not exist
+BEGIN;
+SAVEPOINT s4;
+ROLLBACK;
+ROLLBACK TO SAVEPOINT s4;
+ERROR 42000: SAVEPOINT s4 does not exist
End of 5.0 tests
CREATE TABLE `t2` (
`k` int(11) NOT NULL auto_increment,
diff --git a/sql/handler.cc b/sql/handler.cc
index 18c8e6c1f5a..d22ee220dc1 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1184,6 +1184,16 @@ end:
if (rw_trans)
start_waiting_global_read_lock(thd);
}
+ else if (all)
+ {
+ /*
+ A COMMIT of an empty transaction. There may be savepoints.
+ Destroy them. If the transaction is not empty
+ savepoints are cleared in ha_commit_one_phase()
+ or ha_rollback_trans().
+ */
+ thd->transaction.cleanup();
+ }
#endif /* USING_TRANSACTIONS */
DBUG_RETURN(error);
}
@@ -1292,11 +1302,11 @@ int ha_rollback_trans(THD *thd, bool all)
thd->transaction.xid_state.xid.null();
}
if (all)
- {
thd->variables.tx_isolation=thd->session_tx_isolation;
- thd->transaction.cleanup();
- }
}
+ /* Always cleanup. Even if there nht==0. There may be savepoints. */
+ if (all)
+ thd->transaction.cleanup();
#endif /* USING_TRANSACTIONS */
if (all)
thd->transaction_rollback_request= FALSE;