summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUILD/FINISH.sh6
-rw-r--r--client/mysql.cc1
-rw-r--r--cmake/configure.pl7
-rw-r--r--include/CMakeLists.txt1
-rw-r--r--include/handler_state.h21
-rw-r--r--include/lf.h2
-rw-r--r--include/my_sys.h1
-rw-r--r--mysql-test/extra/binlog_tests/binlog.test47
-rw-r--r--mysql-test/extra/binlog_tests/binlog_insert_delayed.test1
-rw-r--r--mysql-test/extra/rpl_tests/rpl_auto_increment.test5
-rw-r--r--mysql-test/extra/rpl_tests/rpl_insert_delayed.test2
-rw-r--r--mysql-test/include/index_merge2.inc1
-rw-r--r--mysql-test/include/strict_autoinc.inc3
-rw-r--r--mysql-test/r/adddate_454.result10
-rw-r--r--mysql-test/r/auto_increment.result7
-rw-r--r--mysql-test/r/auto_increment_ranges_innodb.result266
-rw-r--r--mysql-test/r/auto_increment_ranges_myisam.result272
-rw-r--r--mysql-test/r/commit_1innodb.result2
-rw-r--r--mysql-test/r/create.result2
-rw-r--r--mysql-test/r/datetime_456.result8
-rw-r--r--mysql-test/r/derived_view.result6
-rw-r--r--mysql-test/r/errors.result8
-rw-r--r--mysql-test/r/features.result140
-rw-r--r--mysql-test/r/func_time.result2
-rw-r--r--mysql-test/r/gis.result23
-rw-r--r--mysql-test/r/index_merge_innodb.result2
-rw-r--r--mysql-test/r/index_merge_myisam.result2
-rw-r--r--mysql-test/r/insert.result12
-rw-r--r--mysql-test/r/insert_select.result4
-rw-r--r--mysql-test/r/insert_update.result4
-rw-r--r--mysql-test/r/last_value.result73
-rw-r--r--mysql-test/r/mix2_myisam.result2
-rw-r--r--mysql-test/r/myisam_mrr.result2
-rw-r--r--mysql-test/r/mysqld--help.result1
-rw-r--r--mysql-test/r/null_key.result2
-rw-r--r--mysql-test/r/partition_pruning.result6
-rw-r--r--mysql-test/r/replace.result4
-rw-r--r--mysql-test/r/strict_autoinc_1myisam.result4
-rw-r--r--mysql-test/r/strict_autoinc_2innodb.result4
-rw-r--r--mysql-test/r/strict_autoinc_3heap.result4
-rw-r--r--mysql-test/r/subselect4.result159
-rw-r--r--mysql-test/r/trigger.result2
-rw-r--r--mysql-test/r/type_date.result12
-rw-r--r--mysql-test/r/view.result43
-rw-r--r--mysql-test/r/xtradb_mrr.result2
-rw-r--r--mysql-test/suite/binlog/r/binlog_innodb_row.result2
-rw-r--r--mysql-test/suite/binlog/r/binlog_row_binlog.result79
-rw-r--r--mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result4
-rw-r--r--mysql-test/suite/binlog/r/binlog_stm_binlog.result88
-rw-r--r--mysql-test/suite/binlog/r/binlog_unsafe.result1
-rw-r--r--mysql-test/suite/heap/heap_hash.result19
-rw-r--r--mysql-test/suite/heap/heap_hash.test13
-rw-r--r--mysql-test/suite/innodb/r/auto_increment_dup.result33
-rw-r--r--mysql-test/suite/innodb/r/innodb-autoinc.result24
-rw-r--r--mysql-test/suite/innodb/r/innodb-lock.result4
-rw-r--r--mysql-test/suite/innodb/r/innodb.result2
-rw-r--r--mysql-test/suite/innodb/r/innodb_bug56947.result2
-rw-r--r--mysql-test/suite/innodb/r/innodb_mysql.result5
-rw-r--r--mysql-test/suite/innodb/t/auto_increment_dup.test51
-rw-r--r--mysql-test/suite/innodb/t/innodb-autoinc.test24
-rw-r--r--mysql-test/suite/maria/maria3.result2
-rw-r--r--mysql-test/suite/maria/mrr.result2
-rw-r--r--mysql-test/suite/optimizer_unfixed_bugs/r/bug43617.result4
-rw-r--r--mysql-test/suite/plugins/t/feedback_plugin_send.test3
-rw-r--r--mysql-test/suite/rpl/r/rpl_auto_increment.result19
-rw-r--r--mysql-test/suite/rpl/r/rpl_insert_delayed,stmt.rdiff4
-rw-r--r--mysql-test/suite/rpl/r/rpl_loaddatalocal.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_mdev382.result84
-rw-r--r--mysql-test/suite/rpl/t/rpl_mdev382.test34
-rw-r--r--mysql-test/suite/rpl/t/rpl_start_stop_slave.test10
-rw-r--r--mysql-test/suite/sys_vars/r/all_vars.result1
-rw-r--r--mysql-test/suite/sys_vars/r/expensive_subquery_limit_basic.result52
-rw-r--r--mysql-test/suite/sys_vars/r/innodb_merge_sort_block_size_basic.result24
-rw-r--r--mysql-test/suite/sys_vars/t/expensive_subquery_limit_basic.test38
-rw-r--r--mysql-test/suite/sys_vars/t/innodb_merge_sort_block_size_basic.test19
-rw-r--r--mysql-test/t/adddate_454.test9
-rw-r--r--mysql-test/t/auto_increment.test5
-rw-r--r--mysql-test/t/auto_increment_ranges.inc240
-rw-r--r--mysql-test/t/auto_increment_ranges_innodb.test7
-rw-r--r--mysql-test/t/auto_increment_ranges_myisam.test7
-rw-r--r--mysql-test/t/datetime_456.test8
-rw-r--r--mysql-test/t/errors.test9
-rw-r--r--mysql-test/t/features.test111
-rw-r--r--mysql-test/t/func_time.test2
-rw-r--r--mysql-test/t/gis.test16
-rw-r--r--mysql-test/t/last_value.test46
-rw-r--r--mysql-test/t/mdev375.test2
-rw-r--r--mysql-test/t/replace.test4
-rw-r--r--mysql-test/t/subselect4.test69
-rw-r--r--mysql-test/t/view.test35
-rw-r--r--mysys/lf_alloc-pin.c2
-rw-r--r--mysys/lf_hash.c4
-rw-r--r--mysys/mf_iocache2.c2
-rw-r--r--mysys/my_getopt.c10
-rw-r--r--mysys/my_sync.c18
-rwxr-xr-xscripts/mytop.sh147
-rw-r--r--sql/derror.cc4
-rw-r--r--sql/event_scheduler.cc5
-rw-r--r--sql/field.cc5
-rw-r--r--sql/handler.cc52
-rw-r--r--sql/handler.h5
-rw-r--r--sql/item.cc12
-rw-r--r--sql/item.h106
-rw-r--r--sql/item_func.cc61
-rw-r--r--sql/item_func.h21
-rw-r--r--sql/item_geofunc.cc3
-rw-r--r--sql/item_strfunc.cc1
-rw-r--r--sql/item_subselect.cc307
-rw-r--r--sql/item_subselect.h5
-rw-r--r--sql/item_timefunc.cc37
-rw-r--r--sql/item_xmlfunc.cc2
-rw-r--r--sql/lex.h1
-rw-r--r--sql/log.cc10
-rw-r--r--sql/log_event.cc36
-rw-r--r--sql/mysqld.cc49
-rw-r--r--sql/mysqld.h1
-rw-r--r--sql/opt_sum.cc2
-rw-r--r--sql/sql_base.cc39
-rw-r--r--sql/sql_class.h30
-rw-r--r--sql/sql_insert.cc58
-rw-r--r--sql/sql_join_cache.cc7
-rw-r--r--sql/sql_parse.cc50
-rw-r--r--sql/sql_select.cc33
-rw-r--r--sql/sql_select.h2
-rw-r--r--sql/sql_state.c2
-rw-r--r--sql/sql_table.cc4
-rw-r--r--sql/sql_time.cc69
-rw-r--r--sql/sql_time.h2
-rw-r--r--sql/sql_trigger.cc3
-rw-r--r--sql/sql_update.cc2
-rw-r--r--sql/sql_yacc.yy16
-rw-r--r--sql/sys_vars.cc15
-rw-r--r--sql/table.cc22
-rw-r--r--sql/table.h12
-rw-r--r--sql/tztime.cc4
-rw-r--r--storage/heap/hp_hash.c9
-rw-r--r--storage/innobase/handler/ha_innodb.cc29
-rw-r--r--storage/xtradb/btr/btr0btr.c4
-rw-r--r--storage/xtradb/buf/buf0buf.c11
-rw-r--r--storage/xtradb/buf/buf0lru.c51
-rw-r--r--storage/xtradb/buf/buf0rea.c47
-rw-r--r--storage/xtradb/dict/dict0dict.c42
-rw-r--r--storage/xtradb/dict/dict0mem.c4
-rw-r--r--storage/xtradb/fil/fil0fil.c2
-rw-r--r--storage/xtradb/ha/ha0ha.c16
-rw-r--r--storage/xtradb/handler/ha_innodb.cc80
-rw-r--r--storage/xtradb/handler/handler0alter.cc18
-rw-r--r--storage/xtradb/handler/i_s.cc290
-rw-r--r--storage/xtradb/handler/i_s.h2
-rw-r--r--storage/xtradb/include/btr0btr.h3
-rw-r--r--storage/xtradb/include/btr0types.h4
-rw-r--r--storage/xtradb/include/buf0buf.h21
-rw-r--r--storage/xtradb/include/buf0buf.ic2
-rw-r--r--storage/xtradb/include/dict0dict.h5
-rw-r--r--storage/xtradb/include/dict0dict.ic2
-rw-r--r--storage/xtradb/include/ha_prototypes.h11
-rw-r--r--storage/xtradb/include/log0log.h2
-rw-r--r--storage/xtradb/include/os0file.h2
-rw-r--r--storage/xtradb/include/srv0srv.h2
-rw-r--r--storage/xtradb/include/trx0sys.h4
-rw-r--r--storage/xtradb/include/univ.i2
-rw-r--r--storage/xtradb/mem/mem0dbg.c4
-rw-r--r--storage/xtradb/os/os0file.c2
-rw-r--r--storage/xtradb/page/page0zip.c2
-rw-r--r--storage/xtradb/row/row0ins.c6
-rw-r--r--storage/xtradb/row/row0merge.c188
-rw-r--r--storage/xtradb/row/row0vers.c11
-rw-r--r--storage/xtradb/trx/trx0sys.c2
-rw-r--r--storage/xtradb/ut/ut0dbg.c6
-rw-r--r--storage/xtradb/ut/ut0ut.c8
170 files changed, 3667 insertions, 912 deletions
diff --git a/BUILD/FINISH.sh b/BUILD/FINISH.sh
index 37dcd1fe836..b7ff195ccf6 100644
--- a/BUILD/FINISH.sh
+++ b/BUILD/FINISH.sh
@@ -21,6 +21,12 @@ extra_configs="$extra_configs $local_infile_configs $EXTRA_CONFIGS"
configure="./configure $base_configs $extra_configs"
+if test "$just_print" = "1" -a "$just_configure" = "1"
+then
+ just_print=""
+ configure="$configure --print"
+fi
+
commands="\
/bin/rm -rf configure;
/bin/rm -rf CMakeCache.txt CMakeFiles/
diff --git a/client/mysql.cc b/client/mysql.cc
index d39e765a99a..5aab3e1098f 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -897,6 +897,7 @@ static COMMANDS commands[] = {
{ "LAST_INSERT_ID", 0, 0, 0, ""},
{ "ISSIMPLE", 0, 0, 0, ""},
{ "LAST_DAY", 0, 0, 0, ""},
+ { "LAST_VALUE", 0, 0, 0, ""},
{ "LCASE", 0, 0, 0, ""},
{ "LEAST", 0, 0, 0, ""},
{ "LENGTH", 0, 0, 0, ""},
diff --git a/cmake/configure.pl b/cmake/configure.pl
index 69f973c41fb..3a7d187c0be 100644
--- a/cmake/configure.pl
+++ b/cmake/configure.pl
@@ -25,6 +25,7 @@ my $cmakeargs = "";
# Assume this script is in <srcroot>/cmake
my $srcdir = dirname(dirname(abs_path($0)));
my $cmake_install_prefix="";
+my $just_print= 0;
# Sets installation directory, bindir, libdir, libexecdir etc
# the equivalent CMake variables are given without prefix
@@ -113,6 +114,11 @@ foreach my $option (@ARGV)
system("cmake ${srcdir} -LH");
exit(0);
}
+ if ($option =~ /print/)
+ {
+ $just_print=1;
+ next;
+ }
if($option =~ /with-plugins=/)
{
my @plugins= split(/,/, substr($option,13));
@@ -223,6 +229,7 @@ foreach my $option (@ARGV)
}
print("configure.pl : calling cmake $srcdir $cmakeargs\n");
+exit(0) if ($just_print);
unlink("CMakeCache.txt");
my $rc = system("cmake $srcdir $cmakeargs");
exit($rc);
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index a90238dbd42..95850da382b 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -51,6 +51,7 @@ SET(HEADERS
m_ctype.h
my_attribute.h
my_compiler.h
+ handler_state.h
)
INSTALL(FILES ${HEADERS} DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development)
diff --git a/include/handler_state.h b/include/handler_state.h
new file mode 100644
index 00000000000..65604a672fb
--- /dev/null
+++ b/include/handler_state.h
@@ -0,0 +1,21 @@
+/*
+ Map handler error message to sql states. Note that this list MUST be in
+ increasing order!
+ See sql_state.c for usage
+*/
+
+{ HA_ERR_KEY_NOT_FOUND, "02000", "" },
+{ HA_ERR_FOUND_DUPP_KEY, "23000", "" },
+{ HA_ERR_WRONG_COMMAND, "0A000", "" },
+{ HA_ERR_UNSUPPORTED, "0A000", "" },
+{ HA_WRONG_CREATE_OPTION, "0A000", "" },
+{ HA_ERR_FOUND_DUPP_UNIQUE, "23000", "" },
+{ HA_ERR_UNKNOWN_CHARSET, "0A000", "" },
+{ HA_ERR_READ_ONLY_TRANSACTION, "25000", "" },
+{ HA_ERR_LOCK_DEADLOCK, "40001", "" },
+{ HA_ERR_NO_REFERENCED_ROW, "23000", "" },
+{ HA_ERR_ROW_IS_REFERENCED, "23000", "" },
+{ HA_ERR_TABLE_EXIST, "42S01", "" },
+{ HA_ERR_FOREIGN_DUPLICATE_KEY, "23000", "" },
+{ HA_ERR_TABLE_READONLY, "25000", "" },
+{ HA_ERR_AUTOINC_ERANGE, "22003", "" },
diff --git a/include/lf.h b/include/lf.h
index cdd24c07502..07769d10943 100644
--- a/include/lf.h
+++ b/include/lf.h
@@ -95,7 +95,7 @@ nolock_wrap(lf_dynarray_iterate, int,
*/
#define LF_PINBOX_PINS 4
-#define LF_PURGATORY_SIZE 10
+#define LF_PURGATORY_SIZE 100
typedef void lf_pinbox_free_func(void *, void *, void*);
diff --git a/include/my_sys.h b/include/my_sys.h
index 4e993f92d1b..1d666cb4a60 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -85,6 +85,7 @@ typedef struct my_aio_result {
#define MY_THREADSAFE 2048 /* my_seek(): lock fd mutex */
#define MY_SYNC 4096 /* my_copy(): sync dst file */
#define MY_SYNC_DIR 32768 /* my_create/delete/rename: sync directory */
+#define MY_SYNC_FILESIZE 65536 /* my_sync(): safe sync when file is extended */
#define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */
#define MY_GIVE_INFO 2 /* Give time info about process*/
diff --git a/mysql-test/extra/binlog_tests/binlog.test b/mysql-test/extra/binlog_tests/binlog.test
index 3bbc693ceda..5b57eab1005 100644
--- a/mysql-test/extra/binlog_tests/binlog.test
+++ b/mysql-test/extra/binlog_tests/binlog.test
@@ -205,16 +205,55 @@ DROP PROCEDURE p4;
--echo End of 5.0 tests
-# Test of a too big SET INSERT_ID: see if the truncated value goes
-# into binlog (right), or the too big value (wrong); we look at the
-# binlog further down with SHOW BINLOG EVENTS.
+# Test of a too big SET INSERT_ID.
+# This should generate an error and should not be put in binlog
+# We look at the binlog further down with SHOW BINLOG EVENTS.
+
reset master;
create table t1 (id tinyint auto_increment primary key);
+insert into t1 values(5);
+set insert_id=128;
+--error 167
+insert into t1 values(null) /* Not binlogged */;
+
+# The followin insert ignore will be put in binlog
set insert_id=128;
-insert into t1 values(null);
+insert ignore into t1 values(null) /* Insert 128 */;
+
+# Insert with duplicate key error should not go into binglo
+set insert_id=5;
+--error ER_DUP_ENTRY
+insert into t1 values(null) /* Not binlogged */;
+
+# Insert with autogenerated key + duplicate key error should go into binlog
+set insert_id=5;
+insert ignore into t1 values(null) /* Insert 5 */;
select * from t1;
drop table t1;
+# Same tests but with 2 rows inserted at a time
+
+create table t1 (id tinyint auto_increment primary key) engine=myisam;
+set insert_id=128;
+--error 167
+insert into t1 values(5),(null) /* Insert_id 128 */;
+
+# The followin insert ignore will be put in binlog
+set insert_id=128;
+insert ignore into t1 values (4),(null) /* Insert_id 128 */;
+
+# Insert with duplicate key error should not go into binglo
+set insert_id=5;
+--error ER_DUP_ENTRY
+insert into t1 values(3),(null) /* Insert_id 5 */;
+
+# Insert with autogenerated key + duplicate key error should go into binlog
+set insert_id=5;
+insert ignore into t1 values(2),(null) /* Insert_id 5 */;
+select * from t1 order by id;
+drop table t1;
+
+
# bug#22027
create table t1 (a int);
create table if not exists t2 select * from t1;
diff --git a/mysql-test/extra/binlog_tests/binlog_insert_delayed.test b/mysql-test/extra/binlog_tests/binlog_insert_delayed.test
index 7b31a3ebf17..8f669fc1152 100644
--- a/mysql-test/extra/binlog_tests/binlog_insert_delayed.test
+++ b/mysql-test/extra/binlog_tests/binlog_insert_delayed.test
@@ -28,6 +28,7 @@
# BUG#20627: INSERT DELAYED does not honour auto_increment_* variables
# Bug in this test: BUG#38068: binlog_stm_binlog fails sporadically in pushbuild
+reset master;
create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
diff --git a/mysql-test/extra/rpl_tests/rpl_auto_increment.test b/mysql-test/extra/rpl_tests/rpl_auto_increment.test
index bd5943d46ea..8cd86de8040 100644
--- a/mysql-test/extra/rpl_tests/rpl_auto_increment.test
+++ b/mysql-test/extra/rpl_tests/rpl_auto_increment.test
@@ -111,7 +111,7 @@ set auto_increment_increment=11;
set auto_increment_offset=4;
insert into t1 values(null);
insert into t1 values(null);
---error ER_DUP_ENTRY
+--error 167
insert into t1 values(null);
select a, mod(a-@@auto_increment_offset,@@auto_increment_increment) from t1 order by a;
@@ -120,6 +120,8 @@ create table t2 (a tinyint unsigned not null auto_increment primary key) engine=
set auto_increment_increment=10;
set auto_increment_offset=1;
set insert_id=1000;
+insert into t2 values(10);
+--error 167
insert into t2 values(null);
select a, mod(a-@@auto_increment_offset,@@auto_increment_increment) from t2 order by a;
@@ -127,6 +129,7 @@ select a, mod(a-@@auto_increment_offset,@@auto_increment_increment) from t2 orde
create table t3 like t1;
set auto_increment_increment=1000;
set auto_increment_offset=700;
+--error 167
insert into t3 values(null);
select * from t3 order by a;
sync_slave_with_master;
diff --git a/mysql-test/extra/rpl_tests/rpl_insert_delayed.test b/mysql-test/extra/rpl_tests/rpl_insert_delayed.test
index df08622b0bd..62e90b629ba 100644
--- a/mysql-test/extra/rpl_tests/rpl_insert_delayed.test
+++ b/mysql-test/extra/rpl_tests/rpl_insert_delayed.test
@@ -102,7 +102,9 @@ CREATE TABLE t1(a int, UNIQUE(a));
--let $_start= query_get_value(SHOW MASTER STATUS, Position, 1)
INSERT DELAYED IGNORE INTO t1 VALUES(1);
+--disable_warnings
INSERT DELAYED IGNORE INTO t1 VALUES(1);
+--enable_warnings
flush table t1; # to wait for INSERT DELAYED to be done
if (`SELECT @@global.binlog_format = 'STATEMENT'`)
{
diff --git a/mysql-test/include/index_merge2.inc b/mysql-test/include/index_merge2.inc
index 1d6b82e1787..c50a45a9923 100644
--- a/mysql-test/include/index_merge2.inc
+++ b/mysql-test/include/index_merge2.inc
@@ -343,6 +343,7 @@ alter table t1 add index i3(key3);
update t1 set key2=key1,key3=key1;
# to test the bug, the following must use "sort_union":
+--replace_column 9 REF
explain select * from t1 where (key3 > 30 and key3<35) or (key2 >32 and key2 < 40);
select * from t1 where (key3 > 30 and key3<35) or (key2 >32 and key2 < 40);
drop table t1;
diff --git a/mysql-test/include/strict_autoinc.inc b/mysql-test/include/strict_autoinc.inc
index 823efcc2040..3298008b66f 100644
--- a/mysql-test/include/strict_autoinc.inc
+++ b/mysql-test/include/strict_autoinc.inc
@@ -19,11 +19,12 @@ select count(*) from t1;
set auto_increment_increment=1000;
set auto_increment_offset=700;
---error ER_WARN_DATA_OUT_OF_RANGE
+--error 167
insert into t1 values(null);
select count(*) from t1;
set @@sql_mode=@org_mode;
+--error 167
insert into t1 values(null);
select * from t1;
diff --git a/mysql-test/r/adddate_454.result b/mysql-test/r/adddate_454.result
new file mode 100644
index 00000000000..0993cdce32c
--- /dev/null
+++ b/mysql-test/r/adddate_454.result
@@ -0,0 +1,10 @@
+create table t1 (d date);
+insert into t1 values ('2012-00-00');
+select * from t1;
+d
+2012-00-00
+update t1 set d = adddate(d, interval 1 day);
+select * from t1;
+d
+NULL
+drop table t1;
diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result
index 30b4ff11227..12cbf294b69 100644
--- a/mysql-test/r/auto_increment.result
+++ b/mysql-test/r/auto_increment.result
@@ -150,7 +150,7 @@ select last_insert_id();
last_insert_id()
255
insert into t1 set i = null;
-ERROR 23000: Duplicate entry '255' for key 'PRIMARY'
+ERROR 22003: Out of range value for column 'i' at row 1
select last_insert_id();
last_insert_id()
255
@@ -162,8 +162,7 @@ select last_insert_id();
last_insert_id()
255
insert into t1 set i = null;
-Warnings:
-Warning 1264 Out of range value for column 'i' at row 1
+ERROR 22003: Out of range value for column 'i' at row 1
select last_insert_id();
last_insert_id()
255
@@ -487,7 +486,7 @@ SELECT @@SESSION.AUTO_INCREMENT_OFFSET;
@@SESSION.AUTO_INCREMENT_OFFSET
1
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
-ERROR 22003: Out of range value for column 't1' at row 167
+ERROR 22003: Out of range value for column 'c1' at row 2
SELECT * FROM t1;
c1
1
diff --git a/mysql-test/r/auto_increment_ranges_innodb.result b/mysql-test/r/auto_increment_ranges_innodb.result
new file mode 100644
index 00000000000..fb936ddfd2b
--- /dev/null
+++ b/mysql-test/r/auto_increment_ranges_innodb.result
@@ -0,0 +1,266 @@
+set default_storage_engine=innodb;
+drop table if exists t1;
+#
+# Testing ranges with smallint
+#
+create table t1 (a smallint primary key auto_increment);
+insert into t1 values(32767);
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+truncate table t1;
+insert into t1 values(32767-1);
+insert into t1 values(NULL);
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+select * from t1;
+a
+32766
+32767
+truncate table t1;
+insert into t1 values(32767),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 2
+select * from t1;
+a
+truncate table t1;
+insert into t1 values(32767-1),(NULL),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 3
+truncate table t1;
+insert into t1 values(32767+1);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+select * from t1;
+a
+32767
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+drop table t1;
+#
+# Testing ranges with unsigned smallint
+#
+create table t1 (a smallint unsigned primary key auto_increment);
+insert into t1 values(65535);
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+truncate table t1;
+insert into t1 values(65535-1);
+insert into t1 values(NULL);
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+select * from t1;
+a
+65534
+65535
+truncate table t1;
+insert into t1 values(65535),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 2
+select * from t1;
+a
+truncate table t1;
+insert into t1 values(65535-1),(NULL),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 3
+truncate table t1;
+insert into t1 values(65535+1);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+select * from t1;
+a
+65535
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+drop table t1;
+#
+# Testing ranges with integer
+#
+create table t1 (a int primary key auto_increment);
+insert into t1 values(2147483647);
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+truncate table t1;
+insert into t1 values(2147483647-1);
+insert into t1 values(NULL);
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+select * from t1;
+a
+2147483646
+2147483647
+truncate table t1;
+insert into t1 values(2147483647),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 2
+select * from t1;
+a
+truncate table t1;
+insert into t1 values(2147483647-1),(NULL),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 3
+truncate table t1;
+insert into t1 values(2147483647+1);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+select * from t1;
+a
+2147483647
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+drop table t1;
+#
+# Testing ranges with unsigned integer
+#
+create table t1 (a int unsigned primary key auto_increment);
+insert into t1 values(4294967295);
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+truncate table t1;
+insert into t1 values(4294967295-1);
+insert into t1 values(NULL);
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+select * from t1;
+a
+4294967294
+4294967295
+truncate table t1;
+insert into t1 values(4294967295),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 2
+select * from t1;
+a
+truncate table t1;
+insert into t1 values(4294967295-1),(NULL),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 3
+truncate table t1;
+insert into t1 values(4294967295+1);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+select * from t1;
+a
+4294967295
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+drop table t1;
+#
+# Testing ranges with bigint
+#
+create table t1 (a bigint primary key auto_increment);
+insert into t1 values(cast(9223372036854775807 as unsigned));
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+truncate table t1;
+insert into t1 values(cast(9223372036854775807 as unsigned)-1);
+insert into t1 values(NULL);
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+select * from t1;
+a
+9223372036854775806
+9223372036854775807
+truncate table t1;
+insert into t1 values(cast(9223372036854775807 as unsigned)),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 2
+select * from t1;
+a
+truncate table t1;
+insert into t1 values(cast(9223372036854775807 as unsigned)-1),(NULL),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 3
+truncate table t1;
+insert into t1 values(cast(9223372036854775807 as unsigned)+1);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+select * from t1;
+a
+9223372036854775807
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+drop table t1;
+#
+# Testing ranges with unsigned bigint
+#
+create table t1 (a bigint unsigned primary key auto_increment);
+insert into t1 values(18446744073709551615-1);
+insert into t1 values(NULL);
+ERROR HY000: Failed to read auto-increment value from storage engine
+insert into t1 values(NULL);
+ERROR HY000: Failed to read auto-increment value from storage engine
+truncate table t1;
+insert into t1 values(18446744073709551615-1);
+insert into t1 values(NULL);
+ERROR HY000: Failed to read auto-increment value from storage engine
+insert into t1 values(NULL);
+ERROR HY000: Failed to read auto-increment value from storage engine
+select * from t1;
+a
+18446744073709551614
+truncate table t1;
+insert into t1 values(18446744073709551615),(NULL);
+ERROR HY000: Failed to read auto-increment value from storage engine
+select * from t1;
+a
+truncate table t1;
+insert into t1 values(18446744073709551615-1),(NULL),(NULL);
+ERROR HY000: Failed to read auto-increment value from storage engine
+drop table t1;
+#
+# Test IGNORE and strict mode
+#
+create table t1 (a smallint primary key auto_increment);
+insert ignore into t1 values(32766),(NULL),(NULL),(1);
+Warnings:
+Warning 167 Out of range value for column 'a' at row 3
+select * from t1;
+a
+1
+32766
+32767
+truncate table t1;
+set @org_mode=@@sql_mode;
+set @@sql_mode='ansi,traditional';
+insert ignore into t1 values(32766),(NULL),(NULL);
+Warnings:
+Warning 167 Out of range value for column 'a' at row 3
+truncate table t1;
+insert into t1 values(32766),(NULL),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 3
+set @@sql_mode=@org_mode;
+drop table t1;
+#
+# Test auto increment with negative numbers
+#
+CREATE TABLE t1 (a INTEGER AUTO_INCREMENT, PRIMARY KEY (a));
+INSERT INTO t1 VALUES (NULL), (2), (-5), (NULL);
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1;
+a
+-5
+1
+2
+3
+5
+TRUNCATE TABLE t1;
+INSERT INTO t1 VALUES (-5), (NULL);
+SELECT * FROM t1;
+a
+-5
+1
+DROP TABLE t1;
+#
+# Test inserting a value out-of-range into an auto increment column
+#
+CREATE TABLE t1 (a smallint AUTO_INCREMENT, PRIMARY KEY (a));
+INSERT INTO t1 VALUES (2);
+INSERT INTO t1 VALUES (32768);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+INSERT INTO t1 VALUES (NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+SELECT * FROM t1;
+a
+2
+32767
+DROP TABLE t1;
+#
+# Test old behaviour
+#
+create table t1 (a smallint primary key auto_increment);
+insert into t1 values(32766),(NULL);
+delete from t1 where a=32767;
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+drop table t1;
diff --git a/mysql-test/r/auto_increment_ranges_myisam.result b/mysql-test/r/auto_increment_ranges_myisam.result
new file mode 100644
index 00000000000..5101321c864
--- /dev/null
+++ b/mysql-test/r/auto_increment_ranges_myisam.result
@@ -0,0 +1,272 @@
+set default_storage_engine=MYISAM;
+drop table if exists t1;
+#
+# Testing ranges with smallint
+#
+create table t1 (a smallint primary key auto_increment);
+insert into t1 values(32767);
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+truncate table t1;
+insert into t1 values(32767-1);
+insert into t1 values(NULL);
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+select * from t1;
+a
+32766
+32767
+truncate table t1;
+insert into t1 values(32767),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 2
+select * from t1;
+a
+32767
+truncate table t1;
+insert into t1 values(32767-1),(NULL),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 3
+truncate table t1;
+insert into t1 values(32767+1);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+select * from t1;
+a
+32767
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+drop table t1;
+#
+# Testing ranges with unsigned smallint
+#
+create table t1 (a smallint unsigned primary key auto_increment);
+insert into t1 values(65535);
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+truncate table t1;
+insert into t1 values(65535-1);
+insert into t1 values(NULL);
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+select * from t1;
+a
+65534
+65535
+truncate table t1;
+insert into t1 values(65535),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 2
+select * from t1;
+a
+65535
+truncate table t1;
+insert into t1 values(65535-1),(NULL),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 3
+truncate table t1;
+insert into t1 values(65535+1);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+select * from t1;
+a
+65535
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+drop table t1;
+#
+# Testing ranges with integer
+#
+create table t1 (a int primary key auto_increment);
+insert into t1 values(2147483647);
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+truncate table t1;
+insert into t1 values(2147483647-1);
+insert into t1 values(NULL);
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+select * from t1;
+a
+2147483646
+2147483647
+truncate table t1;
+insert into t1 values(2147483647),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 2
+select * from t1;
+a
+2147483647
+truncate table t1;
+insert into t1 values(2147483647-1),(NULL),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 3
+truncate table t1;
+insert into t1 values(2147483647+1);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+select * from t1;
+a
+2147483647
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+drop table t1;
+#
+# Testing ranges with unsigned integer
+#
+create table t1 (a int unsigned primary key auto_increment);
+insert into t1 values(4294967295);
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+truncate table t1;
+insert into t1 values(4294967295-1);
+insert into t1 values(NULL);
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+select * from t1;
+a
+4294967294
+4294967295
+truncate table t1;
+insert into t1 values(4294967295),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 2
+select * from t1;
+a
+4294967295
+truncate table t1;
+insert into t1 values(4294967295-1),(NULL),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 3
+truncate table t1;
+insert into t1 values(4294967295+1);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+select * from t1;
+a
+4294967295
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+drop table t1;
+#
+# Testing ranges with bigint
+#
+create table t1 (a bigint primary key auto_increment);
+insert into t1 values(cast(9223372036854775807 as unsigned));
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+truncate table t1;
+insert into t1 values(cast(9223372036854775807 as unsigned)-1);
+insert into t1 values(NULL);
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+select * from t1;
+a
+9223372036854775806
+9223372036854775807
+truncate table t1;
+insert into t1 values(cast(9223372036854775807 as unsigned)),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 2
+select * from t1;
+a
+9223372036854775807
+truncate table t1;
+insert into t1 values(cast(9223372036854775807 as unsigned)-1),(NULL),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 3
+truncate table t1;
+insert into t1 values(cast(9223372036854775807 as unsigned)+1);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+select * from t1;
+a
+9223372036854775807
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+drop table t1;
+#
+# Testing ranges with unsigned bigint
+#
+create table t1 (a bigint unsigned primary key auto_increment);
+insert into t1 values(18446744073709551615-1);
+insert into t1 values(NULL);
+ERROR HY000: Failed to read auto-increment value from storage engine
+insert into t1 values(NULL);
+ERROR HY000: Failed to read auto-increment value from storage engine
+truncate table t1;
+insert into t1 values(18446744073709551615-1);
+insert into t1 values(NULL);
+ERROR HY000: Failed to read auto-increment value from storage engine
+insert into t1 values(NULL);
+ERROR HY000: Failed to read auto-increment value from storage engine
+select * from t1;
+a
+18446744073709551614
+truncate table t1;
+insert into t1 values(18446744073709551615),(NULL);
+ERROR HY000: Failed to read auto-increment value from storage engine
+select * from t1;
+a
+18446744073709551615
+truncate table t1;
+insert into t1 values(18446744073709551615-1),(NULL),(NULL);
+ERROR HY000: Failed to read auto-increment value from storage engine
+drop table t1;
+#
+# Test IGNORE and strict mode
+#
+create table t1 (a smallint primary key auto_increment);
+insert ignore into t1 values(32766),(NULL),(NULL),(1);
+Warnings:
+Warning 167 Out of range value for column 'a' at row 3
+select * from t1;
+a
+1
+32766
+32767
+truncate table t1;
+set @org_mode=@@sql_mode;
+set @@sql_mode='ansi,traditional';
+insert ignore into t1 values(32766),(NULL),(NULL);
+Warnings:
+Warning 167 Out of range value for column 'a' at row 3
+truncate table t1;
+insert into t1 values(32766),(NULL),(NULL);
+ERROR 22003: Out of range value for column 'a' at row 3
+set @@sql_mode=@org_mode;
+drop table t1;
+#
+# Test auto increment with negative numbers
+#
+CREATE TABLE t1 (a INTEGER AUTO_INCREMENT, PRIMARY KEY (a));
+INSERT INTO t1 VALUES (NULL), (2), (-5), (NULL);
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1;
+a
+-5
+1
+2
+3
+4
+TRUNCATE TABLE t1;
+INSERT INTO t1 VALUES (-5), (NULL);
+SELECT * FROM t1;
+a
+-5
+1
+DROP TABLE t1;
+#
+# Test inserting a value out-of-range into an auto increment column
+#
+CREATE TABLE t1 (a smallint AUTO_INCREMENT, PRIMARY KEY (a));
+INSERT INTO t1 VALUES (2);
+INSERT INTO t1 VALUES (32768);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+INSERT INTO t1 VALUES (NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+SELECT * FROM t1;
+a
+2
+32767
+DROP TABLE t1;
+#
+# Test old behaviour
+#
+create table t1 (a smallint primary key auto_increment);
+insert into t1 values(32766),(NULL);
+delete from t1 where a=32767;
+insert into t1 values(NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+drop table t1;
diff --git a/mysql-test/r/commit_1innodb.result b/mysql-test/r/commit_1innodb.result
index 3e3d75f66e4..af198edc4ca 100644
--- a/mysql-test/r/commit_1innodb.result
+++ b/mysql-test/r/commit_1innodb.result
@@ -529,6 +529,8 @@ SUCCESS
# 13. Read-write statement: INSERT IGNORE, change 0 rows.
#
insert ignore t1 set a=2;
+Warnings:
+Warning 1062 Duplicate entry '2' for key 'a'
call p_verify_status_increment(2, 2, 1, 0);
SUCCESS
diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result
index 0a6dff6d9a3..ba52959be84 100644
--- a/mysql-test/r/create.result
+++ b/mysql-test/r/create.result
@@ -2396,6 +2396,8 @@ a b
drop table t1;
create table if not exists t1 (a int unique, b int)
ignore select 1 as a, 1 as b union select 1 as a, 2 as b;
+Warnings:
+Warning 1062 Duplicate entry '1' for key 'a'
select * from t1;
a b
1 1
diff --git a/mysql-test/r/datetime_456.result b/mysql-test/r/datetime_456.result
new file mode 100644
index 00000000000..ba020a250b7
--- /dev/null
+++ b/mysql-test/r/datetime_456.result
@@ -0,0 +1,8 @@
+create table t1 (d datetime);
+insert t1 values (addtime('9999-12-31 23:59:59', '00:00:01')),
+(from_days(3652499));
+select * from t1;
+d
+NULL
+NULL
+drop table t1;
diff --git a/mysql-test/r/derived_view.result b/mysql-test/r/derived_view.result
index ba01db4a66f..5446406924f 100644
--- a/mysql-test/r/derived_view.result
+++ b/mysql-test/r/derived_view.result
@@ -1687,7 +1687,6 @@ SELECT t.b, t.c, t1.a
FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t
WHERE t.b AND t.c = t1.a;
b c a
-8 c c
EXPLAIN EXTENDED
SELECT t.b, t.c, t1.a
FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t
@@ -1702,7 +1701,6 @@ SELECT t.b, t.c, t1.a
FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t
WHERE t.b <> 0 AND t.c = t1.a;
b c a
-8 c c
INSERT INTO t3 VALUES (100), (200);
EXPLAIN EXTENDED
SELECT t.b, t.c, t1.a
@@ -1718,7 +1716,7 @@ SELECT t.b, t.c, t1.a
FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t
WHERE t.b AND t.c = t1.a;
b c a
-8 c c
+NULL NULL c
EXPLAIN EXTENDED
SELECT t.b, t.c, t1.a
FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t
@@ -1733,7 +1731,7 @@ SELECT t.b, t.c, t1.a
FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t
WHERE t.b <> 0 AND t.c = t1.a;
b c a
-8 c c
+NULL NULL c
SET optimizer_switch=@save_optimizer_switch;
DROP TABLE t1,t2,t3;
#
diff --git a/mysql-test/r/errors.result b/mysql-test/r/errors.result
index 8560e6176c4..23c77d3978c 100644
--- a/mysql-test/r/errors.result
+++ b/mysql-test/r/errors.result
@@ -160,3 +160,11 @@ ERROR 42S22: Unknown column '' in 'VALUES() function'
INSERT INTO t2(a,b) VALUES (1,0) ON DUPLICATE KEY UPDATE
b=(SELECT VALUES(a)+2 FROM t1);
DROP TABLE t1, t2;
+#
+# MDEV-492: incorrect error check before sending OK in mysql_update
+#
+CREATE TABLE t1 (a CHAR(3), b BLOB);
+UPDATE t1 SET a = 'new'
+WHERE COLUMN_CREATE( 1, 'v', 1, 'w' ) IS NULL;
+ERROR 22007: Illegal value used as argument of dynamic column function
+drop table t1;
diff --git a/mysql-test/r/features.result b/mysql-test/r/features.result
new file mode 100644
index 00000000000..7b6a352ab0c
--- /dev/null
+++ b/mysql-test/r/features.result
@@ -0,0 +1,140 @@
+drop table if exists t1;
+show status like "feature%";
+Variable_name Value
+Feature_dynamic_columns 0
+Feature_fulltext 0
+Feature_gis 0
+Feature_locale 0
+Feature_subquery 0
+Feature_timezone 0
+Feature_trigger 0
+Feature_xml 0
+#
+# Feature GIS
+#
+CREATE TABLE t1 (g POINT);
+SHOW FIELDS FROM t1;
+Field Type Null Key Default Extra
+g point YES NULL
+INSERT INTO t1 VALUES
+(PointFromText('POINT(10 10)')),
+(PointFromText('POINT(20 10)')),
+(PointFromText('POINT(20 20)')),
+(PointFromWKB(AsWKB(PointFromText('POINT(10 20)'))));
+drop table t1;
+show status like "feature_gis";
+Variable_name Value
+Feature_gis 3
+#
+# Feature dynamic columns
+#
+set @a= COLUMN_CREATE(1, 1212 AS int);
+set @b= column_add(@a, 2, 1212 as integer);
+select column_get(@b, 2 as integer);
+column_get(@b, 2 as integer)
+1212
+show status like "feature_dynamic_columns";
+Variable_name Value
+Feature_dynamic_columns 2
+#
+# Feature fulltext
+#
+CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b)) engine=myisam;
+INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
+('Full-text indexes', 'are called collections'),
+('Only MyISAM tables','support collections'),
+('Function MATCH ... AGAINST()','is used to do a search'),
+('Full-text search in MySQL', 'implements vector space model');
+select * from t1 where MATCH(a,b) AGAINST ("collections");
+a b
+Only MyISAM tables support collections
+Full-text indexes are called collections
+select * from t1 where MATCH(a,b) AGAINST ("indexes");
+a b
+Full-text indexes are called collections
+drop table t1;
+show status like "feature_fulltext";
+Variable_name Value
+Feature_fulltext 2
+#
+# Feature locale
+#
+SET lc_messages=sr_RS;
+SET lc_messages=en_US;
+show status like "feature_locale";
+Variable_name Value
+Feature_locale 2
+#
+# Feature subquery
+#
+select (select 2);
+(select 2)
+2
+SELECT (SELECT 1) UNION SELECT (SELECT 2);
+(SELECT 1)
+1
+2
+create table t1 (a int);
+insert into t1 values (2);
+select (select a from t1 where t1.a=t2.a), a from t1 as t2;
+(select a from t1 where t1.a=t2.a) a
+2 2
+drop table t1;
+show status like "feature_subquery";
+Variable_name Value
+Feature_subquery 4
+#
+# Feature timezone
+#
+SELECT FROM_UNIXTIME(unix_timestamp()) > "1970-01-01";
+FROM_UNIXTIME(unix_timestamp()) > "1970-01-01"
+1
+set time_zone="+03:00";
+SELECT FROM_UNIXTIME(unix_timestamp()) > "1970-01-01";
+FROM_UNIXTIME(unix_timestamp()) > "1970-01-01"
+1
+set time_zone= @@global.time_zone;
+show status like "feature_timezone";
+Variable_name Value
+Feature_timezone 1
+#
+# Feature triggers
+#
+create table t1 (i int);
+# let us test some very simple trigger
+create trigger trg before insert on t1 for each row set @a:=1;
+set @a:=0;
+select @a;
+@a
+0
+insert into t1 values (1),(2);
+select @a;
+@a
+1
+SHOW TRIGGERS IN test like 't1';
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg INSERT t1 set @a:=1 BEFORE NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
+drop trigger trg;
+drop table t1;
+show status like "%trigger%";
+Variable_name Value
+Com_create_trigger 1
+Com_drop_trigger 1
+Com_show_create_trigger 0
+Com_show_triggers 1
+Executed_triggers 2
+Feature_trigger 2
+#
+# Feature xml
+#
+SET @xml='<a aa1="aa1" aa2="aa2">a1<b ba1="ba1">b1<c>c1</c>b2</b>a2</a>';
+SELECT extractValue(@xml,'/a');
+extractValue(@xml,'/a')
+a1 a2
+select updatexml('<div><div><span>1</span><span>2</span></div></div>',
+'/','<tr><td>1</td><td>2</td></tr>') as upd1;
+upd1
+<tr><td>1</td><td>2</td></tr>
+show status like "feature_xml";
+Variable_name Value
+Feature_xml 2
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index bfc6b72caa1..15120af869c 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -1922,3 +1922,5 @@ cast(greatest(cast("0-0-0" as date), cast("10:20:05" as time)) as datetime(6))
select microsecond('12:00:00.123456'), microsecond('2009-12-31 23:59:59.000010');
microsecond('12:00:00.123456') microsecond('2009-12-31 23:59:59.000010')
123456 10
+select now(258);
+ERROR 42000: Too big precision 258 specified for 'now'. Maximum is 6.
diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result
index ca48177b1b5..30385323502 100644
--- a/mysql-test/r/gis.result
+++ b/mysql-test/r/gis.result
@@ -1428,6 +1428,29 @@ WHERE ST_Contains(ST_Buffer(bridges.position, 15.0), buildings.footprint) = 1;
count(*)
1
DROP DATABASE gis_ogs;
+#
+# BUG #1043845 st_distance() results are incorrect depending on variable order
+#
+select st_distance(geomfromtext('LINESTRING(-95.9673005697771 36.13509598461,
+ -95.9673057475387 36.1344478941074,
+ -95.9673063519371 36.134484524621,
+ -95.9673049102515 36.1343976584193)'),
+geomfromtext('point(-95.96269500000000000000 36.14181833333330000000)')) ;
+st_distance(geomfromtext('LINESTRING(-95.9673005697771 36.13509598461,
+ -95.9673057475387 36.1344478941074,
+ -95.9673063519371 36.134484524621,
+
+0.008148695928146028
+select st_distance(geomfromtext('point(-95.96269500000000000000 36.14181833333330000000)'),
+geomfromtext('LINESTRING(-95.9673005697771 36.13509598461,
+ -95.9673057475387 36.1344478941074,
+ -95.9673063519371 36.134484524621,
+ -95.9673049102515 36.1343976584193) ')) ;
+st_distance(geomfromtext('point(-95.96269500000000000000 36.14181833333330000000)'),
+geomfromtext('LINESTRING(-95.9673005697771 36.13509598461,
+ -95.9673057475387 36.1344478941074,
+ -95.9673063519371 36.
+0.008148695928146028
USE test;
#
# BUG#12414917 - ISCLOSED() CRASHES ON 64-BIT BUILDS
diff --git a/mysql-test/r/index_merge_innodb.result b/mysql-test/r/index_merge_innodb.result
index 92bcb2e88f0..b93d15f7bef 100644
--- a/mysql-test/r/index_merge_innodb.result
+++ b/mysql-test/r/index_merge_innodb.result
@@ -313,7 +313,7 @@ alter table t1 add index i3(key3);
update t1 set key2=key1,key3=key1;
explain select * from t1 where (key3 > 30 and key3<35) or (key2 >32 and key2 < 40);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index_merge i2,i3 i3,i2 4,4 NULL 9 Using sort_union(i3,i2); Using where
+1 SIMPLE t1 index_merge i2,i3 i3,i2 4,4 NULL REF Using sort_union(i3,i2); Using where
select * from t1 where (key3 > 30 and key3<35) or (key2 >32 and key2 < 40);
key1 key2 key3
31 31 31
diff --git a/mysql-test/r/index_merge_myisam.result b/mysql-test/r/index_merge_myisam.result
index bf151a872cf..0b6959d15a9 100644
--- a/mysql-test/r/index_merge_myisam.result
+++ b/mysql-test/r/index_merge_myisam.result
@@ -1146,7 +1146,7 @@ alter table t1 add index i3(key3);
update t1 set key2=key1,key3=key1;
explain select * from t1 where (key3 > 30 and key3<35) or (key2 >32 and key2 < 40);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index_merge i2,i3 i3,i2 4,4 NULL 11 Using sort_union(i3,i2); Using where
+1 SIMPLE t1 index_merge i2,i3 i3,i2 4,4 NULL REF Using sort_union(i3,i2); Using where
select * from t1 where (key3 > 30 and key3<35) or (key2 >32 and key2 < 40);
key1 key2 key3
31 31 31
diff --git a/mysql-test/r/insert.result b/mysql-test/r/insert.result
index 655303be7f4..7110f541fb7 100644
--- a/mysql-test/r/insert.result
+++ b/mysql-test/r/insert.result
@@ -327,9 +327,11 @@ select row_count();
row_count()
3
insert ignore into t1 values (1, 1);
+Warnings:
+Warning 1062 Duplicate entry '1' for key 'PRIMARY'
select row_count();
row_count()
-0
+-1
replace into t1 values (1, 11);
select row_count();
row_count()
@@ -371,7 +373,15 @@ drop table t1,t2;
create table t1 (id int primary key auto_increment, data int, unique(data));
insert ignore into t1 values(NULL,100),(NULL,110),(NULL,120);
insert ignore into t1 values(NULL,10),(NULL,20),(NULL,110),(NULL,120),(NULL,100),(NULL,90);
+Warnings:
+Warning 1062 Duplicate entry '110' for key 'data'
+Warning 1062 Duplicate entry '120' for key 'data'
+Warning 1062 Duplicate entry '100' for key 'data'
insert ignore into t1 values(NULL,130),(NULL,140),(500,110),(550,120),(450,100),(NULL,150);
+Warnings:
+Warning 1062 Duplicate entry '110' for key 'data'
+Warning 1062 Duplicate entry '120' for key 'data'
+Warning 1062 Duplicate entry '100' for key 'data'
select * from t1 order by id;
id data
1 100
diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result
index c952b914167..8bfc4e9215e 100644
--- a/mysql-test/r/insert_select.result
+++ b/mysql-test/r/insert_select.result
@@ -6,6 +6,10 @@ insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1;
insert into t2 (payoutID) SELECT payoutID+10 FROM t1;
ERROR 23000: Duplicate entry '16' for key 'PRIMARY'
insert ignore into t2 (payoutID) SELECT payoutID+10 FROM t1;
+Warnings:
+Warning 1062 Duplicate entry '16' for key 'PRIMARY'
+Warning 1062 Duplicate entry '16' for key 'PRIMARY'
+Warning 1062 Duplicate entry '22' for key 'PRIMARY'
select * from t2;
payoutID
1
diff --git a/mysql-test/r/insert_update.result b/mysql-test/r/insert_update.result
index c3acea5d11f..1987c5c0559 100644
--- a/mysql-test/r/insert_update.result
+++ b/mysql-test/r/insert_update.result
@@ -172,11 +172,15 @@ DROP TABLE t2;
create table t1 (a int not null unique) engine=myisam;
insert into t1 values (1),(2);
insert ignore into t1 select 1 on duplicate key update a=2;
+Warnings:
+Warning 1062 Duplicate entry '2' for key 'a'
select * from t1;
a
1
2
insert ignore into t1 select a from t1 as t2 on duplicate key update a=t1.a+1 ;
+Warnings:
+Warning 1062 Duplicate entry '2' for key 'a'
select * from t1;
a
1
diff --git a/mysql-test/r/last_value.result b/mysql-test/r/last_value.result
new file mode 100644
index 00000000000..6222eacd4f0
--- /dev/null
+++ b/mysql-test/r/last_value.result
@@ -0,0 +1,73 @@
+drop table if exists t1;
+drop database if exists mysqltest;
+CREATE TABLE t1 (a INT, b INT, c INT, d INT);
+INSERT INTO t1 VALUES (1,3,0,NULL),(2,2,0,NULL),(3,4,0,NULL),(4,2,0,NULL);
+SELECT * FROM t1;
+a b c d
+1 3 0 NULL
+2 2 0 NULL
+3 4 0 NULL
+4 2 0 NULL
+UPDATE t1 SET c=LAST_VALUE(@last_a:=a,@last_b:=b,@last_c:=c,1), d=4211 WHERE c=0 ORDER BY b DESC LIMIT 1;
+SELECT @last_a, @last_b, @last_c;
+@last_a @last_b @last_c
+3 4 0
+SELECT * FROM t1;
+a b c d
+1 3 0 NULL
+2 2 0 NULL
+3 4 1 4211
+4 2 0 NULL
+DROP TABLE t1;
+SELECT LAST_VALUE(@last_a:=1,@last_b:=1);
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def LAST_VALUE(@last_a:=1,@last_b:=1) 8 1 1 N 32897 0 63
+LAST_VALUE(@last_a:=1,@last_b:=1)
+1
+select @last_b;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def @last_b 8 20 1 Y 32896 0 63
+@last_b
+1
+SELECT LAST_VALUE(@last_a:=1,@last_b:=1.0);
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def LAST_VALUE(@last_a:=1,@last_b:=1.0) 246 4 3 N 32897 1 63
+LAST_VALUE(@last_a:=1,@last_b:=1.0)
+1.0
+select @last_b;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def @last_b 246 83 3 Y 32896 30 63
+@last_b
+1.0
+SELECT LAST_VALUE(@last_a:=1,@last_b:="hello");
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def LAST_VALUE(@last_a:=1,@last_b:="hello") 253 5 5 N 1 31 8
+LAST_VALUE(@last_a:=1,@last_b:="hello")
+hello
+select @last_b;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def @last_b 250 16777215 5 Y 0 31 8
+@last_b
+hello
+SELECT date(LAST_VALUE(@last_a:=1,@last_b:="2001-02-03"));
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def date(LAST_VALUE(@last_a:=1,@last_b:="2001-02-03")) 10 10 10 Y 128 0 63
+date(LAST_VALUE(@last_a:=1,@last_b:="2001-02-03"))
+2001-02-03
+select @last_b;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def @last_b 250 16777215 10 Y 0 31 8
+@last_b
+2001-02-03
+SELECT LAST_VALUE(@last_a:=1,@last_b:="2001-02-03",NULL);
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def LAST_VALUE(@last_a:=1,@last_b:="2001-02-03",NULL) 6 0 0 Y 32896 0 63
+LAST_VALUE(@last_a:=1,@last_b:="2001-02-03",NULL)
+NULL
+select @last_b;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def @last_b 250 16777215 10 Y 0 31 8
+@last_b
+2001-02-03
+SELECT LAST_VALUE();
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1
diff --git a/mysql-test/r/mix2_myisam.result b/mysql-test/r/mix2_myisam.result
index e5f5857d2c9..6f90555325b 100644
--- a/mysql-test/r/mix2_myisam.result
+++ b/mysql-test/r/mix2_myisam.result
@@ -702,6 +702,8 @@ id
2
99
insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');
+Warnings:
+Warning 1062 Duplicate entry '1-1' for key 'PRIMARY'
commit;
select id,id3 from t1;
id id3
diff --git a/mysql-test/r/myisam_mrr.result b/mysql-test/r/myisam_mrr.result
index 03d212dbc04..bd50df7c40e 100644
--- a/mysql-test/r/myisam_mrr.result
+++ b/mysql-test/r/myisam_mrr.result
@@ -278,6 +278,8 @@ bb-1 NULL cc-2 NULL-1
drop table t1, t2, t3, t4;
create table t1 (a int, b int not null,unique key (a,b),index(b));
insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6);
+Warnings:
+Warning 1062 Duplicate entry '6-6' for key 'a'
create table t2 like t1;
insert into t2 select * from t1;
alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10));
diff --git a/mysql-test/r/mysqld--help.result b/mysql-test/r/mysqld--help.result
index 63df79160cc..718909d1b27 100644
--- a/mysql-test/r/mysqld--help.result
+++ b/mysql-test/r/mysqld--help.result
@@ -923,7 +923,6 @@ key-cache-age-threshold 300
key-cache-block-size 1024
key-cache-division-limit 100
key-cache-segments 0
-language MYSQL_SHAREDIR/
large-pages FALSE
lc-messages en_US
lc-messages-dir MYSQL_SHAREDIR/
diff --git a/mysql-test/r/null_key.result b/mysql-test/r/null_key.result
index 35c6ebe1442..ba79011f53e 100644
--- a/mysql-test/r/null_key.result
+++ b/mysql-test/r/null_key.result
@@ -1,6 +1,8 @@
drop table if exists t1,t2;
create table t1 (a int, b int not null,unique key (a,b),index(b)) engine=myisam;
insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6);
+Warnings:
+Warning 1062 Duplicate entry '6-6' for key 'a'
explain select * from t1 where a is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a a 5 const 3 Using where; Using index
diff --git a/mysql-test/r/partition_pruning.result b/mysql-test/r/partition_pruning.result
index 4d48b70d26a..ec7fd798d4c 100644
--- a/mysql-test/r/partition_pruning.result
+++ b/mysql-test/r/partition_pruning.result
@@ -787,7 +787,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pNULL,p2001-01-01 index a a 4 NULL 4 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 pNULL ref a a 4 const 1 Using where; Using index
+1 SIMPLE t1 pNULL ref a a 4 const 1 Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1002-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 range a a 4 NULL 4 Using where; Using index
@@ -1116,7 +1116,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 4 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 pNULL ref a a 4 const 1 Using where; Using index
+1 SIMPLE t1 pNULL ref a a 4 const 1 Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1002-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 4 Using where; Using index
@@ -1445,7 +1445,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 4 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 pNULL ref a a 4 const 1 Using where; Using index
+1 SIMPLE t1 pNULL ref a a 4 const 1 Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1002-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 4 Using where; Using index
diff --git a/mysql-test/r/replace.result b/mysql-test/r/replace.result
index 842302c89ac..59b8565f671 100644
--- a/mysql-test/r/replace.result
+++ b/mysql-test/r/replace.result
@@ -13,9 +13,9 @@ drop table t1;
create table t1 (a tinyint not null auto_increment primary key, b char(20) default "default_value");
insert into t1 values (126,"first"),(63, "middle"),(0,"last");
insert into t1 values (0,"error");
-ERROR 23000: Duplicate entry '127' for key 'PRIMARY'
+ERROR 22003: Out of range value for column 'a' at row 1
replace into t1 values (0,"error");
-ERROR 23000: Duplicate entry '127' for key 'PRIMARY'
+ERROR 22003: Out of range value for column 'a' at row 1
replace into t1 values (126,"first updated");
replace into t1 values (63,default);
select * from t1;
diff --git a/mysql-test/r/strict_autoinc_1myisam.result b/mysql-test/r/strict_autoinc_1myisam.result
index afcccb1c40f..b22540f295b 100644
--- a/mysql-test/r/strict_autoinc_1myisam.result
+++ b/mysql-test/r/strict_autoinc_1myisam.result
@@ -20,9 +20,7 @@ count(*)
0
set @@sql_mode=@org_mode;
insert into t1 values(null);
-Warnings:
-Warning 1264 Out of range value for column 'a' at row 1
+ERROR 22003: Out of range value for column 'a' at row 1
select * from t1;
a
-127
drop table t1;
diff --git a/mysql-test/r/strict_autoinc_2innodb.result b/mysql-test/r/strict_autoinc_2innodb.result
index e534286e2a2..1cf720da12a 100644
--- a/mysql-test/r/strict_autoinc_2innodb.result
+++ b/mysql-test/r/strict_autoinc_2innodb.result
@@ -20,9 +20,7 @@ count(*)
0
set @@sql_mode=@org_mode;
insert into t1 values(null);
-Warnings:
-Warning 1264 Out of range value for column 'a' at row 1
+ERROR 22003: Out of range value for column 'a' at row 1
select * from t1;
a
-127
drop table t1;
diff --git a/mysql-test/r/strict_autoinc_3heap.result b/mysql-test/r/strict_autoinc_3heap.result
index 0a31da04460..21eea537af5 100644
--- a/mysql-test/r/strict_autoinc_3heap.result
+++ b/mysql-test/r/strict_autoinc_3heap.result
@@ -20,9 +20,7 @@ count(*)
0
set @@sql_mode=@org_mode;
insert into t1 values(null);
-Warnings:
-Warning 1264 Out of range value for column 'a' at row 1
+ERROR 22003: Out of range value for column 'a' at row 1
select * from t1;
a
-127
drop table t1;
diff --git a/mysql-test/r/subselect4.result b/mysql-test/r/subselect4.result
index 28441e4019e..7f290fb5b03 100644
--- a/mysql-test/r/subselect4.result
+++ b/mysql-test/r/subselect4.result
@@ -206,6 +206,165 @@ default(a)
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
DROP TABLE t;
#
+# LP BUG#1009187, MDEV-373, MYSQL bug#58628
+# Wrong result for a query with [NOT] IN subquery predicate if
+# the left part of the predicate is explicit NULL
+#
+CREATE TABLE t1 (pk INT NOT NULL, i INT NOT NULL);
+INSERT INTO t1 VALUES (0,10), (1,20), (2,30), (3,40);
+CREATE TABLE t2a (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i,pk));
+INSERT INTO t2a VALUES (0,0), (1,1), (2,2), (3,3);
+CREATE TABLE t2b (pk INT, i INT);
+INSERT INTO t2b VALUES (0,0), (1,1), (2,2), (3,3);
+CREATE TABLE t2c (pk INT NOT NULL, i INT NOT NULL);
+INSERT INTO t2c VALUES (0,0), (1,1), (2,2), (3,3);
+create index it2c on t2c (i,pk);
+CREATE TABLE t2d (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i));
+INSERT INTO t2d VALUES (0,0), (1,1), (2,2), (3,3);
+EXPLAIN
+SELECT * FROM t1 WHERE NULL NOT IN (SELECT t2a.i FROM t2a WHERE t2a.pk = t1.pk);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
+2 DEPENDENT SUBQUERY t2a unique_subquery PRIMARY PRIMARY 8 const,test.t1.pk 1 Using index; Using where; Full scan on NULL key
+SELECT * FROM t1 WHERE NULL NOT IN (SELECT t2a.i FROM t2a WHERE t2a.pk = t1.pk);
+pk i
+SELECT * FROM t1 WHERE 1+NULL NOT IN (SELECT t2a.i FROM t2a WHERE t2a.pk = t1.pk);
+pk i
+SELECT * FROM t1 WHERE NULL IN (SELECT t2a.i FROM t2a WHERE t2a.pk = t1.pk) IS UNKNOWN;
+pk i
+0 10
+1 20
+2 30
+3 40
+SELECT t1.pk, NULL NOT IN (SELECT t2a.i FROM t2a WHERE t2a.pk = t1.pk) FROM t1;
+pk NULL NOT IN (SELECT t2a.i FROM t2a WHERE t2a.pk = t1.pk)
+0 NULL
+1 NULL
+2 NULL
+3 NULL
+EXPLAIN
+SELECT * FROM t1 WHERE NULL NOT IN (SELECT t2b.i FROM t2b WHERE t2b.pk = t1.pk);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
+2 DEPENDENT SUBQUERY t2b ALL NULL NULL NULL NULL 4 Using where
+SELECT * FROM t1 WHERE NULL NOT IN (SELECT t2b.i FROM t2b WHERE t2b.pk = t1.pk);
+pk i
+SELECT * FROM t1 WHERE NULL IN (SELECT t2b.i FROM t2b WHERE t2b.pk = t1.pk) IS UNKNOWN;
+pk i
+0 10
+1 20
+2 30
+3 40
+SELECT t1.pk, NULL NOT IN (SELECT t2b.i FROM t2b WHERE t2b.pk = t1.pk) FROM t1;
+pk NULL NOT IN (SELECT t2b.i FROM t2b WHERE t2b.pk = t1.pk)
+0 NULL
+1 NULL
+2 NULL
+3 NULL
+EXPLAIN
+SELECT * FROM t1 WHERE NULL NOT IN (SELECT t2c.i FROM t2c WHERE t2c.pk = t1.pk);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
+2 DEPENDENT SUBQUERY t2c index_subquery it2c it2c 8 const,test.t1.pk 2 Using index; Using where; Full scan on NULL key
+SELECT * FROM t1 WHERE NULL NOT IN (SELECT t2c.i FROM t2c WHERE t2c.pk = t1.pk);
+pk i
+SELECT * FROM t1 WHERE NULL IN (SELECT t2c.i FROM t2c WHERE t2c.pk = t1.pk) IS UNKNOWN;
+pk i
+0 10
+1 20
+2 30
+3 40
+SELECT t1.pk, NULL NOT IN (SELECT t2c.i FROM t2c WHERE t2c.pk = t1.pk) FROM t1;
+pk NULL NOT IN (SELECT t2c.i FROM t2c WHERE t2c.pk = t1.pk)
+0 NULL
+1 NULL
+2 NULL
+3 NULL
+EXPLAIN
+SELECT * FROM t1 WHERE NULL NOT IN (SELECT t2d.i FROM t2d WHERE t2d.pk = t1.pk);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
+2 DEPENDENT SUBQUERY t2d const PRIMARY PRIMARY 4 const 1 Using where; Full scan on NULL key
+SELECT * FROM t1 WHERE NULL NOT IN (SELECT t2d.i FROM t2d WHERE t2d.pk = t1.pk);
+pk i
+SELECT * FROM t1 WHERE NULL IN (SELECT t2d.i FROM t2d WHERE t2d.pk = t1.pk) IS UNKNOWN;
+pk i
+0 10
+1 20
+2 30
+3 40
+SELECT t1.pk, NULL NOT IN (SELECT t2d.i FROM t2d WHERE t2d.pk = t1.pk) FROM t1;
+pk NULL NOT IN (SELECT t2d.i FROM t2d WHERE t2d.pk = t1.pk)
+0 NULL
+1 NULL
+2 NULL
+3 NULL
+EXPLAIN
+SELECT * FROM t1 WHERE (NULL, 1) NOT IN (SELECT t2a.i, t2a.pk FROM t2a WHERE t2a.pk = t1.pk);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
+2 DEPENDENT SUBQUERY t2a eq_ref PRIMARY PRIMARY 8 const,test.t1.pk 1 Using where; Using index; Full scan on NULL key
+SELECT * FROM t1 WHERE (NULL, 1) NOT IN (SELECT t2a.i, t2a.pk FROM t2a WHERE t2a.pk = t1.pk);
+pk i
+0 10
+2 30
+3 40
+SELECT (NULL, 1) NOT IN (SELECT t2a.i, t2a.pk FROM t2a WHERE t2a.pk = t1.pk) from t1;
+(NULL, 1) NOT IN (SELECT t2a.i, t2a.pk FROM t2a WHERE t2a.pk = t1.pk)
+1
+NULL
+1
+1
+EXPLAIN
+SELECT * FROM t1 WHERE (NULL, 1) NOT IN (SELECT t2b.i, t2b.pk FROM t2b WHERE t2b.pk = t1.pk);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
+2 DEPENDENT SUBQUERY t2b ALL NULL NULL NULL NULL 4 Using where
+SELECT * FROM t1 WHERE (NULL, 1) NOT IN (SELECT t2b.i, t2b.pk FROM t2b WHERE t2b.pk = t1.pk);
+pk i
+0 10
+2 30
+3 40
+SELECT (NULL, 1) NOT IN (SELECT t2b.i, t2b.pk FROM t2b WHERE t2b.pk = t1.pk) from t1;
+(NULL, 1) NOT IN (SELECT t2b.i, t2b.pk FROM t2b WHERE t2b.pk = t1.pk)
+1
+NULL
+1
+1
+EXPLAIN
+SELECT * FROM t1 WHERE (NULL, 1) NOT IN (SELECT t2c.i, t2c.pk FROM t2c WHERE t2c.pk = t1.pk);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
+2 DEPENDENT SUBQUERY t2c ref it2c it2c 8 const,test.t1.pk 2 Using where; Using index; Full scan on NULL key
+SELECT * FROM t1 WHERE (NULL, 1) NOT IN (SELECT t2c.i, t2c.pk FROM t2c WHERE t2c.pk = t1.pk);
+pk i
+0 10
+2 30
+3 40
+SELECT (NULL, 1) NOT IN (SELECT t2c.i, t2c.pk FROM t2c WHERE t2c.pk = t1.pk) from t1;
+(NULL, 1) NOT IN (SELECT t2c.i, t2c.pk FROM t2c WHERE t2c.pk = t1.pk)
+1
+NULL
+1
+1
+EXPLAIN
+SELECT * FROM t1 WHERE (NULL, 1) NOT IN (SELECT t2d.i, t2d.pk FROM t2d WHERE t2d.pk = t1.pk);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
+2 DEPENDENT SUBQUERY t2d const PRIMARY PRIMARY 4 const 1 Using where; Full scan on NULL key
+SELECT * FROM t1 WHERE (NULL, 1) NOT IN (SELECT t2d.i, t2d.pk FROM t2d WHERE t2d.pk = t1.pk);
+pk i
+0 10
+2 30
+3 40
+SELECT (NULL, 1) NOT IN (SELECT t2d.i, t2d.pk FROM t2d WHERE t2d.pk = t1.pk) from t1;
+(NULL, 1) NOT IN (SELECT t2d.i, t2d.pk FROM t2d WHERE t2d.pk = t1.pk)
+1
+NULL
+1
+1
+drop table t1, t2a, t2b, t2c, t2d;
+#
# End of 5.1 tests.
#
#
diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result
index 63193bdedbc..3310209df58 100644
--- a/mysql-test/r/trigger.result
+++ b/mysql-test/r/trigger.result
@@ -165,6 +165,8 @@ select @log;
(BEFORE_INSERT: new=(id=1, data=1))(AFTER_INSERT: new=(id=1, data=1))
set @log:= "";
insert ignore t1 values (1, 2);
+Warnings:
+Warning 1062 Duplicate entry '1' for key 'PRIMARY'
select @log;
@log
(BEFORE_INSERT: new=(id=1, data=2))
diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result
index 41f590400ea..8a85cd53b2a 100644
--- a/mysql-test/r/type_date.result
+++ b/mysql-test/r/type_date.result
@@ -209,15 +209,11 @@ a
SET SQL_MODE=TRADITIONAL;
EXPLAIN SELECT * FROM t1 WHERE a = '0000-00-00';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ref i i 4 const 1 Using where; Using index
-Warnings:
-Warning 1264 Out of range value for column 'a' at row 1
+1 SIMPLE t1 ref i i 4 const 1 Using index
SELECT * FROM t1 WHERE a = '0000-00-00';
a
0000-00-00
0000-00-00
-Warnings:
-Warning 1264 Out of range value for column 'a' at row 1
SELECT * FROM t2 WHERE a = '0000-00-00';
a
0000-00-00
@@ -242,15 +238,11 @@ a
SET SQL_MODE=TRADITIONAL;
EXPLAIN SELECT * FROM t1 WHERE a = '1000-00-00';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ref i i 4 const 1 Using where; Using index
-Warnings:
-Warning 1265 Data truncated for column 'a' at row 1
+1 SIMPLE t1 ref i i 4 const 1 Using index
SELECT * FROM t1 WHERE a = '1000-00-00';
a
1000-00-00
1000-00-00
-Warnings:
-Warning 1265 Data truncated for column 'a' at row 1
SELECT * FROM t2 WHERE a = '1000-00-00';
a
1000-00-00
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index b50f6b81206..5af20fd0c3c 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -4678,6 +4678,7 @@ DROP TABLE t1,t2,t3;
# LP bug#1007622 Server crashes in handler::increment_statistics on
# inserting into a view over a view
#
+flush status;
CREATE TABLE t1 (a INT);
CREATE ALGORITHM=MERGE VIEW v1 AS SELECT a1.* FROM t1 AS a1, t1 AS a2;
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM v1;
@@ -4687,6 +4688,48 @@ a
1
drop view v2,v1;
drop table t1;
+show status like '%view%';
+Variable_name Value
+Com_create_view 2
+Com_drop_view 1
+Opened_views 3
+show status like 'Opened_table%';
+Variable_name Value
+Opened_table_definitions 2
+Opened_tables 3
+#
+# MDEV-486 LP BUG#1010116 Incorrect query results in
+# view and derived tables
+#
+SELECT
+`Derived1`.`id`,
+`Derived2`.`Val1`
+FROM (select 30631 as `id`) AS `Derived1` LEFT OUTER JOIN (SELECT
+2 as `id`,
+1 AS `Val1`
+FROM (select 30631 as `id`) AS `Derived3`) AS `Derived2` ON `Derived1`.`id` = `Derived2`.`id`;
+id Val1
+30631 NULL
+create table t1 ( id int );
+insert into t1 values (30631);
+create table t2 ( id int );
+insert into t2 values (30631);
+create algorithm=MERGE view v2 as select 2 as id, 1 as val1 from t2;
+select t1.*, v2.* from t1 left join v2 on t1.id = v2.id;
+id id val1
+30631 NULL NULL
+drop view v2;
+drop table t1,t2;
+create table t1 ( id int );
+insert into t1 values (30631);
+create table t2 ( id int );
+insert into t2 values (30631);
+create algorithm=MERGE view v2 as select 2 as id, id is null as bbb, id as iddqd, 1 as val1 from t2;
+select t1.*, v2.* from t1 left join v2 on t1.id = v2.id;
+id id bbb iddqd val1
+30631 NULL NULL NULL NULL
+drop view v2;
+drop table t1,t2;
# -----------------------------------------------------------------
# -- End of 5.3 tests.
# -----------------------------------------------------------------
diff --git a/mysql-test/r/xtradb_mrr.result b/mysql-test/r/xtradb_mrr.result
index 069d3c25826..15b750d2fd3 100644
--- a/mysql-test/r/xtradb_mrr.result
+++ b/mysql-test/r/xtradb_mrr.result
@@ -276,6 +276,8 @@ bb-1 NULL cc-2 NULL-1
drop table t1, t2, t3, t4;
create table t1 (a int, b int not null,unique key (a,b),index(b));
insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6);
+Warnings:
+Warning 1062 Duplicate entry '6-6' for key 'a'
create table t2 like t1;
insert into t2 select * from t1;
alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10));
diff --git a/mysql-test/suite/binlog/r/binlog_innodb_row.result b/mysql-test/suite/binlog/r/binlog_innodb_row.result
index 61f961f16da..043f363c9c7 100644
--- a/mysql-test/suite/binlog/r/binlog_innodb_row.result
+++ b/mysql-test/suite/binlog/r/binlog_innodb_row.result
@@ -69,6 +69,8 @@ INSERT INTO t1 VALUES (1);
START TRANSACTION;
INSERT INTO t2 VALUES (1);
INSERT IGNORE INTO t1 VALUES (1);
+Warnings:
+Warning 1062 Duplicate entry '1' for key 'PRIMARY'
COMMIT;
INSERT INTO t1 VALUES (2);
START TRANSACTION;
diff --git a/mysql-test/suite/binlog/r/binlog_row_binlog.result b/mysql-test/suite/binlog/r/binlog_row_binlog.result
index 95477d13b50..a3ee21b9957 100644
--- a/mysql-test/suite/binlog/r/binlog_row_binlog.result
+++ b/mysql-test/suite/binlog/r/binlog_row_binlog.result
@@ -578,13 +578,46 @@ DROP PROCEDURE p4;
End of 5.0 tests
reset master;
create table t1 (id tinyint auto_increment primary key);
+insert into t1 values(5);
set insert_id=128;
-insert into t1 values(null);
+insert into t1 values(null) /* Not binlogged */;
+ERROR 22003: Out of range value for column 'id' at row 1
+set insert_id=128;
+insert ignore into t1 values(null) /* Insert 128 */;
+Warnings:
+Warning 167 Out of range value for column 'id' at row 1
+set insert_id=5;
+insert into t1 values(null) /* Not binlogged */;
+ERROR 23000: Duplicate entry '5' for key 'PRIMARY'
+set insert_id=5;
+insert ignore into t1 values(null) /* Insert 5 */;
Warnings:
-Warning 1264 Out of range value for column 'id' at row 1
+Warning 1062 Duplicate entry '5' for key 'PRIMARY'
select * from t1;
id
-127
+5
+drop table t1;
+create table t1 (id tinyint auto_increment primary key) engine=myisam;
+set insert_id=128;
+insert into t1 values(5),(null) /* Insert_id 128 */;
+ERROR 22003: Out of range value for column 'id' at row 2
+set insert_id=128;
+insert ignore into t1 values (4),(null) /* Insert_id 128 */;
+Warnings:
+Warning 167 Out of range value for column 'id' at row 2
+set insert_id=5;
+insert into t1 values(3),(null) /* Insert_id 5 */;
+ERROR 23000: Duplicate entry '5' for key 'PRIMARY'
+set insert_id=5;
+insert ignore into t1 values(2),(null) /* Insert_id 5 */;
+Warnings:
+Warning 1062 Duplicate entry '5' for key 'PRIMARY'
+select * from t1 order by id;
+id
+2
+3
+4
+5
drop table t1;
create table t1 (a int);
create table if not exists t2 select * from t1;
@@ -603,36 +636,19 @@ master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */
-master-bin.000001 # Query # # use `test`; create table t1 (a int)
+master-bin.000001 # Query # # use `test`; create table t1 (id tinyint auto_increment primary key) engine=myisam
master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Query # # use `test`; CREATE TABLE IF NOT EXISTS `t2` (
- `a` int(11) DEFAULT NULL
-)
-master-bin.000001 # Query # # COMMIT
-master-bin.000001 # Query # # use `test`; CREATE TABLE IF NOT EXISTS `t3` (
- `a` int(11) DEFAULT NULL
-)
-master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Table_map # # table_id: # (mysql.user)
+master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Table_map # # table_id: # (mysql.user)
-master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Table_map # # table_id: # (test.t1)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Table_map # # table_id: # (mysql.user)
-master-bin.000001 # Delete_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Table_map # # table_id: # (test.t1)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # COMMIT
-drop table t1,t2,t3,tt1;
-create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
-insert /* before delayed */ delayed /* after delayed */ into t1 values (207);
-insert /*! delayed */ into t1 values (null);
-insert delayed into t1 values (300);
-FLUSH TABLES;
-show binlog events from <binlog_start>;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # use `test`; create table t1 (id tinyint auto_increment primary key)
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
@@ -659,8 +675,15 @@ master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (mysql.user)
master-bin.000001 # Delete_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # COMMIT
-master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE IF EXISTS `tt1` /* generated by server */
-master-bin.000001 # Query # # use `test`; DROP TABLE `t1`,`t2`,`t3` /* generated by server */
+drop table t1,t2,t3,tt1;
+reset master;
+create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
+insert /* before delayed */ delayed /* after delayed */ into t1 values (207);
+insert /*! delayed */ into t1 values (null);
+insert delayed into t1 values (300);
+FLUSH TABLES;
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t1)
diff --git a/mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result b/mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result
index cdcc96b94b0..15610296d5c 100644
--- a/mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result
+++ b/mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result
@@ -1,3 +1,4 @@
+reset master;
create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
insert /* before delayed */ delayed /* after delayed */ into t1 values (207);
insert /*! delayed */ into t1 values (null);
@@ -5,9 +6,6 @@ insert delayed into t1 values (300);
FLUSH TABLES;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Query # # use `mtr`; INSERT INTO test_suppressions (pattern) VALUES ( NAME_CONST('pattern',_latin1'Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT' COLLATE 'latin1_swedish_ci'))
-master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; insert /* before delayed */ /* after delayed */ into t1 values (207)
diff --git a/mysql-test/suite/binlog/r/binlog_stm_binlog.result b/mysql-test/suite/binlog/r/binlog_stm_binlog.result
index 062f4f4e906..68e76921ff3 100644
--- a/mysql-test/suite/binlog/r/binlog_stm_binlog.result
+++ b/mysql-test/suite/binlog/r/binlog_stm_binlog.result
@@ -387,13 +387,46 @@ DROP PROCEDURE p4;
End of 5.0 tests
reset master;
create table t1 (id tinyint auto_increment primary key);
+insert into t1 values(5);
set insert_id=128;
-insert into t1 values(null);
+insert into t1 values(null) /* Not binlogged */;
+ERROR 22003: Out of range value for column 'id' at row 1
+set insert_id=128;
+insert ignore into t1 values(null) /* Insert 128 */;
+Warnings:
+Warning 167 Out of range value for column 'id' at row 1
+set insert_id=5;
+insert into t1 values(null) /* Not binlogged */;
+ERROR 23000: Duplicate entry '5' for key 'PRIMARY'
+set insert_id=5;
+insert ignore into t1 values(null) /* Insert 5 */;
Warnings:
-Warning 1264 Out of range value for column 'id' at row 1
+Warning 1062 Duplicate entry '5' for key 'PRIMARY'
select * from t1;
id
-127
+5
+drop table t1;
+create table t1 (id tinyint auto_increment primary key) engine=myisam;
+set insert_id=128;
+insert into t1 values(5),(null) /* Insert_id 128 */;
+ERROR 22003: Out of range value for column 'id' at row 2
+set insert_id=128;
+insert ignore into t1 values (4),(null) /* Insert_id 128 */;
+Warnings:
+Warning 167 Out of range value for column 'id' at row 2
+set insert_id=5;
+insert into t1 values(3),(null) /* Insert_id 5 */;
+ERROR 23000: Duplicate entry '5' for key 'PRIMARY'
+set insert_id=5;
+insert ignore into t1 values(2),(null) /* Insert_id 5 */;
+Warnings:
+Warning 1062 Duplicate entry '5' for key 'PRIMARY'
+select * from t1 order by id;
+id
+2
+3
+4
+5
drop table t1;
create table t1 (a int);
create table if not exists t2 select * from t1;
@@ -408,35 +441,33 @@ show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; create table t1 (id tinyint auto_increment primary key)
master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Intvar # # INSERT_ID=127
-master-bin.000001 # Query # # use `test`; insert into t1 values(null)
+master-bin.000001 # Query # # use `test`; insert into t1 values(5)
+master-bin.000001 # Query # # COMMIT
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Intvar # # INSERT_ID=128
+master-bin.000001 # Query # # use `test`; insert ignore into t1 values(null) /* Insert 128 */
+master-bin.000001 # Query # # COMMIT
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Intvar # # INSERT_ID=5
+master-bin.000001 # Query # # use `test`; insert ignore into t1 values(null) /* Insert 5 */
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */
-master-bin.000001 # Query # # use `test`; create table t1 (a int)
-master-bin.000001 # Query # # use `test`; create table if not exists t2 select * from t1
-master-bin.000001 # Query # # use `test`; create temporary table tt1 (a int)
-master-bin.000001 # Query # # use `test`; create table if not exists t3 like tt1
+master-bin.000001 # Query # # use `test`; create table t1 (id tinyint auto_increment primary key) engine=myisam
master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Query # # use `mysql`; INSERT INTO user SET host='localhost', user='@#@', password=password('Just a test')
+master-bin.000001 # Intvar # # INSERT_ID=128
+master-bin.000001 # Query # # use `test`; insert into t1 values(5),(null) /* Insert_id 128 */
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Query # # use `mysql`; UPDATE user SET password=password('Another password') WHERE host='localhost' AND user='@#@'
+master-bin.000001 # Intvar # # INSERT_ID=128
+master-bin.000001 # Query # # use `test`; insert ignore into t1 values (4),(null) /* Insert_id 128 */
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Query # # use `mysql`; DELETE FROM user WHERE host='localhost' AND user='@#@'
+master-bin.000001 # Intvar # # INSERT_ID=5
+master-bin.000001 # Query # # use `test`; insert into t1 values(3),(null) /* Insert_id 5 */
master-bin.000001 # Query # # COMMIT
-drop table t1,t2,t3,tt1;
-create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
-insert /* before delayed */ delayed /* after delayed */ into t1 values (207);
-insert /*! delayed */ into t1 values (null);
-insert delayed into t1 values (300);
-FLUSH TABLES;
-show binlog events from <binlog_start>;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # use `test`; create table t1 (id tinyint auto_increment primary key)
master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Intvar # # INSERT_ID=127
-master-bin.000001 # Query # # use `test`; insert into t1 values(null)
+master-bin.000001 # Intvar # # INSERT_ID=5
+master-bin.000001 # Query # # use `test`; insert ignore into t1 values(2),(null) /* Insert_id 5 */
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */
master-bin.000001 # Query # # use `test`; create table t1 (a int)
@@ -452,8 +483,15 @@ master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `mysql`; DELETE FROM user WHERE host='localhost' AND user='@#@'
master-bin.000001 # Query # # COMMIT
-master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE `tt1` /* generated by server */
-master-bin.000001 # Query # # use `test`; DROP TABLE `t1`,`t2`,`t3` /* generated by server */
+drop table t1,t2,t3,tt1;
+reset master;
+create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
+insert /* before delayed */ delayed /* after delayed */ into t1 values (207);
+insert /*! delayed */ into t1 values (null);
+insert delayed into t1 values (300);
+FLUSH TABLES;
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t1)
diff --git a/mysql-test/suite/binlog/r/binlog_unsafe.result b/mysql-test/suite/binlog/r/binlog_unsafe.result
index 2cc1ebdd2d7..043b3d1e7a6 100644
--- a/mysql-test/suite/binlog/r/binlog_unsafe.result
+++ b/mysql-test/suite/binlog/r/binlog_unsafe.result
@@ -2682,6 +2682,7 @@ CREATE TABLE insert_2_keys (a INT UNIQUE KEY, b INT UNIQUE KEY);
INSERT INTO insert_2_keys values (1, 1);
INSERT IGNORE INTO insert_table SELECT * FROM filler_table;
Warnings:
+Warning 1062 Duplicate entry '1' for key 'PRIMARY'
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT IGNORE... SELECT is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are ignored. This order cannot be predicted and may differ on master and the slave.
TRUNCATE TABLE insert_table;
INSERT INTO insert_table SELECT * FROM filler_table ON DUPLICATE KEY UPDATE a = 1;
diff --git a/mysql-test/suite/heap/heap_hash.result b/mysql-test/suite/heap/heap_hash.result
index 453bfc0c165..ac62427c81c 100644
--- a/mysql-test/suite/heap/heap_hash.result
+++ b/mysql-test/suite/heap/heap_hash.result
@@ -427,4 +427,23 @@ INDEX(col_int_key) USING HASH) ENGINE = HEAP;
INSERT INTO t1 (col_int_nokey, col_int_key) VALUES (3, 0), (4, 0), (3, 1);
DELETE FROM t1 WHERE col_int_nokey = 5 ORDER BY col_int_key LIMIT 2;
DROP TABLE t1;
+#
+# Bug #1002564: Wrong result for a lookup query from a heap table
+#
+CREATE TABLE t1 (c1 VARCHAR(10) NOT NULL, KEY i1 (c1(3))) ENGINE=MEMORY DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES ('foo1'), ('bar2'), ('baz3');
+explain SELECT * FROM t1 WHERE c1='bar2';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref i1 i1 5 const 2 Using where
+SELECT * FROM t1 WHERE c1='bar2';
+c1
+bar2
+ALTER TABLE t1 DROP KEY i1, ADD KEY il (c1(3)) using btree;
+explain SELECT * FROM t1 WHERE c1='bar2';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref il il 5 const 1 Using where
+SELECT * FROM t1 WHERE c1='bar2';
+c1
+bar2
+DROP TABLE t1;
End of 5.5 tests
diff --git a/mysql-test/suite/heap/heap_hash.test b/mysql-test/suite/heap/heap_hash.test
index 80ae01e9547..80d6ef9c8f2 100644
--- a/mysql-test/suite/heap/heap_hash.test
+++ b/mysql-test/suite/heap/heap_hash.test
@@ -316,4 +316,17 @@ DELETE FROM t1 WHERE col_int_nokey = 5 ORDER BY col_int_key LIMIT 2;
DROP TABLE t1;
+--echo #
+--echo # Bug #1002564: Wrong result for a lookup query from a heap table
+--echo #
+
+CREATE TABLE t1 (c1 VARCHAR(10) NOT NULL, KEY i1 (c1(3))) ENGINE=MEMORY DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES ('foo1'), ('bar2'), ('baz3');
+explain SELECT * FROM t1 WHERE c1='bar2';
+SELECT * FROM t1 WHERE c1='bar2';
+ALTER TABLE t1 DROP KEY i1, ADD KEY il (c1(3)) using btree;
+explain SELECT * FROM t1 WHERE c1='bar2';
+SELECT * FROM t1 WHERE c1='bar2';
+DROP TABLE t1;
+
--echo End of 5.5 tests
diff --git a/mysql-test/suite/innodb/r/auto_increment_dup.result b/mysql-test/suite/innodb/r/auto_increment_dup.result
new file mode 100644
index 00000000000..5bf901cb212
--- /dev/null
+++ b/mysql-test/suite/innodb/r/auto_increment_dup.result
@@ -0,0 +1,33 @@
+drop table if exists t1;
+CREATE TABLE t1(
+id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+k INT,
+c CHAR(1),
+UNIQUE KEY(k)) ENGINE=InnoDB;
+#
+# Connection 1
+#
+SET DEBUG_SYNC='ha_write_row_end SIGNAL continue2 WAIT_FOR continue1';
+affected rows: 0
+INSERT INTO t1(k) VALUES (1), (2), (3) ON DUPLICATE KEY UPDATE c='1';
+#
+# Connection 2
+#
+SET DEBUG_SYNC='start_ha_write_row WAIT_FOR continue2';
+affected rows: 0
+SET DEBUG_SYNC='after_mysql_insert SIGNAL continue1';
+affected rows: 0
+INSERT INTO t1(k) VALUES (2), (4), (5) ON DUPLICATE KEY UPDATE c='2';
+affected rows: 3
+info: Records: 3 Duplicates: 0 Warnings: 0
+affected rows: 4
+info: Records: 3 Duplicates: 1 Warnings: 0
+SET DEBUG_SYNC='RESET';
+SELECT * FROM t1 ORDER BY k;
+id k c
+1 1 NULL
+4 2 1
+2 3 NULL
+5 4 NULL
+6 5 NULL
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/r/innodb-autoinc.result b/mysql-test/suite/innodb/r/innodb-autoinc.result
index 9eb89bead74..8c4c1c20590 100644
--- a/mysql-test/suite/innodb/r/innodb-autoinc.result
+++ b/mysql-test/suite/innodb/r/innodb-autoinc.result
@@ -2,7 +2,7 @@ drop table if exists t1;
CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (9223372036854775807, null);
INSERT INTO t1 (c2) VALUES ('innodb');
-Got one of the listed errors
+ERROR 22003: Out of range value for column 'c1' at row 1
SELECT * FROM t1;
c1 c2
9223372036854775807 NULL
@@ -10,7 +10,7 @@ DROP TABLE t1;
CREATE TABLE t1 (c1 TINYINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (127, null);
INSERT INTO t1 (c2) VALUES ('innodb');
-Got one of the listed errors
+ERROR 22003: Out of range value for column 'c1' at row 1
SELECT * FROM t1;
c1 c2
127 NULL
@@ -18,7 +18,7 @@ DROP TABLE t1;
CREATE TABLE t1 (c1 TINYINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (255, null);
INSERT INTO t1 (c2) VALUES ('innodb');
-Got one of the listed errors
+ERROR 22003: Out of range value for column 'c1' at row 1
SELECT * FROM t1;
c1 c2
255 NULL
@@ -26,7 +26,7 @@ DROP TABLE t1;
CREATE TABLE t1 (c1 SMALLINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (32767, null);
INSERT INTO t1 (c2) VALUES ('innodb');
-Got one of the listed errors
+ERROR 22003: Out of range value for column 'c1' at row 1
SELECT * FROM t1;
c1 c2
32767 NULL
@@ -34,7 +34,7 @@ DROP TABLE t1;
CREATE TABLE t1 (c1 SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (65535, null);
INSERT INTO t1 (c2) VALUES ('innodb');
-Got one of the listed errors
+ERROR 22003: Out of range value for column 'c1' at row 1
SELECT * FROM t1;
c1 c2
65535 NULL
@@ -42,7 +42,7 @@ DROP TABLE t1;
CREATE TABLE t1 (c1 MEDIUMINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (8388607, null);
INSERT INTO t1 (c2) VALUES ('innodb');
-Got one of the listed errors
+ERROR 22003: Out of range value for column 'c1' at row 1
SELECT * FROM t1;
c1 c2
8388607 NULL
@@ -50,7 +50,7 @@ DROP TABLE t1;
CREATE TABLE t1 (c1 MEDIUMINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (16777215, null);
INSERT INTO t1 (c2) VALUES ('innodb');
-Got one of the listed errors
+ERROR 22003: Out of range value for column 'c1' at row 1
SELECT * FROM t1;
c1 c2
16777215 NULL
@@ -58,7 +58,7 @@ DROP TABLE t1;
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (2147483647, null);
INSERT INTO t1 (c2) VALUES ('innodb');
-Got one of the listed errors
+ERROR 22003: Out of range value for column 'c1' at row 1
SELECT * FROM t1;
c1 c2
2147483647 NULL
@@ -66,7 +66,7 @@ DROP TABLE t1;
CREATE TABLE t1 (c1 INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (4294967295, null);
INSERT INTO t1 (c2) VALUES ('innodb');
-Got one of the listed errors
+ERROR 22003: Out of range value for column 'c1' at row 1
SELECT * FROM t1;
c1 c2
4294967295 NULL
@@ -74,7 +74,7 @@ DROP TABLE t1;
CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (9223372036854775807, null);
INSERT INTO t1 (c2) VALUES ('innodb');
-Got one of the listed errors
+ERROR 22003: Out of range value for column 'c1' at row 1
SELECT * FROM t1;
c1 c2
9223372036854775807 NULL
@@ -567,7 +567,7 @@ Variable_name Value
auto_increment_increment 65535
auto_increment_offset 65535
INSERT INTO t1 VALUES (NULL),(NULL);
-ERROR 22003: Out of range value for column 't1' at row 167
+ERROR 22003: Out of range value for column 'c1' at row 1
SELECT * FROM t1;
c1
1
@@ -858,7 +858,7 @@ PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t2 SELECT c1 FROM t1;
Got one of the listed errors
INSERT INTO t2 SELECT NULL FROM t1;
-Got one of the listed errors
+ERROR 22003: Out of range value for column 'c1' at row 1
DROP TABLE t1;
DROP TABLE t2;
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
diff --git a/mysql-test/suite/innodb/r/innodb-lock.result b/mysql-test/suite/innodb/r/innodb-lock.result
index 439a8d6513c..7191bcd238a 100644
--- a/mysql-test/suite/innodb/r/innodb-lock.result
+++ b/mysql-test/suite/innodb/r/innodb-lock.result
@@ -98,8 +98,12 @@ CREATE TABLE t1 (a INT PRIMARY KEY, b INT NOT NULL) ENGINE=InnoDB;
INSERT INTO t1 VALUES(3,1);
BEGIN;
INSERT IGNORE INTO t1 VALUES(3,14);
+Warnings:
+Warning 1062 Duplicate entry '3' for key 'PRIMARY'
BEGIN;
INSERT IGNORE INTO t1 VALUES(3,23);
+Warnings:
+Warning 1062 Duplicate entry '3' for key 'PRIMARY'
SELECT * FROM t1 FOR UPDATE;
COMMIT;
a b
diff --git a/mysql-test/suite/innodb/r/innodb.result b/mysql-test/suite/innodb/r/innodb.result
index 17fe766616a..2af2a7b80bf 100644
--- a/mysql-test/suite/innodb/r/innodb.result
+++ b/mysql-test/suite/innodb/r/innodb.result
@@ -816,6 +816,8 @@ id
1
2
insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');
+Warnings:
+Warning 1062 Duplicate entry '1-1' for key 'PRIMARY'
commit;
select id,id3 from t1;
id id3
diff --git a/mysql-test/suite/innodb/r/innodb_bug56947.result b/mysql-test/suite/innodb/r/innodb_bug56947.result
index b279069d834..8b864b62e81 100644
--- a/mysql-test/suite/innodb/r/innodb_bug56947.result
+++ b/mysql-test/suite/innodb/r/innodb_bug56947.result
@@ -3,6 +3,6 @@ SET GLOBAL innodb_file_per_table=0;
create table bug56947(a int not null) engine = innodb;
CREATE TABLE `bug56947#1`(a int) ENGINE=InnoDB;
alter table bug56947 add unique index (a);
-ERROR HY000: Table 'test.bug56947#1' already exists
+ERROR 42S01: Table 'test.bug56947#1' already exists
drop table `bug56947#1`;
drop table bug56947;
diff --git a/mysql-test/suite/innodb/r/innodb_mysql.result b/mysql-test/suite/innodb/r/innodb_mysql.result
index 2b3d24551c7..be2b4b28f6a 100644
--- a/mysql-test/suite/innodb/r/innodb_mysql.result
+++ b/mysql-test/suite/innodb/r/innodb_mysql.result
@@ -1480,10 +1480,15 @@ k a c
1 6 2
2 7 NULL
insert ignore into t2 values (null,6,1),(10,8,1);
+Warnings:
+Warning 1062 Duplicate entry '6' for key 'idx_1'
select last_insert_id();
last_insert_id()
0
insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1);
+Warnings:
+Warning 1062 Duplicate entry '6' for key 'idx_1'
+Warning 1062 Duplicate entry '8' for key 'idx_1'
select last_insert_id();
last_insert_id()
11
diff --git a/mysql-test/suite/innodb/t/auto_increment_dup.test b/mysql-test/suite/innodb/t/auto_increment_dup.test
new file mode 100644
index 00000000000..ad439024f65
--- /dev/null
+++ b/mysql-test/suite/innodb/t/auto_increment_dup.test
@@ -0,0 +1,51 @@
+##########################################################################
+# LP bug #1035225 / MySQL bug #66301: INSERT ... ON DUPLICATE KEY UPDATE +
+# innodb_autoinc_lock_mode=1 is broken
+##########################################################################
+
+--source include/have_innodb.inc
+--source include/have_debug_sync.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+CREATE TABLE t1(
+ id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ k INT,
+ c CHAR(1),
+ UNIQUE KEY(k)) ENGINE=InnoDB;
+
+--enable_info
+
+--connect(con1, localhost, root)
+--connect(con2, localhost, root)
+
+--connection con1
+
+--echo #
+--echo # Connection 1
+--echo #
+SET DEBUG_SYNC='ha_write_row_end SIGNAL continue2 WAIT_FOR continue1';
+--send INSERT INTO t1(k) VALUES (1), (2), (3) ON DUPLICATE KEY UPDATE c='1'
+
+--connection con2
+--echo #
+--echo # Connection 2
+--echo #
+SET DEBUG_SYNC='start_ha_write_row WAIT_FOR continue2';
+SET DEBUG_SYNC='after_mysql_insert SIGNAL continue1';
+INSERT INTO t1(k) VALUES (2), (4), (5) ON DUPLICATE KEY UPDATE c='2';
+
+--connection con1
+--reap
+--disable_info
+SET DEBUG_SYNC='RESET';
+SELECT * FROM t1 ORDER BY k;
+
+--disconnect con1
+--disconnect con2
+
+--connection default
+
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/t/innodb-autoinc.test b/mysql-test/suite/innodb/t/innodb-autoinc.test
index 4f54a8ff957..888c73bacdf 100644
--- a/mysql-test/suite/innodb/t/innodb-autoinc.test
+++ b/mysql-test/suite/innodb/t/innodb-autoinc.test
@@ -11,7 +11,7 @@ drop table if exists t1;
#
CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (9223372036854775807, null);
--- error ER_DUP_ENTRY,1062
+-- error 167
INSERT INTO t1 (c2) VALUES ('innodb');
SELECT * FROM t1;
DROP TABLE t1;
@@ -22,14 +22,14 @@ DROP TABLE t1;
# TINYINT
CREATE TABLE t1 (c1 TINYINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (127, null);
--- error ER_DUP_ENTRY,1062
+-- error 167
INSERT INTO t1 (c2) VALUES ('innodb');
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 TINYINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (255, null);
--- error ER_DUP_ENTRY,1062
+-- error 167
INSERT INTO t1 (c2) VALUES ('innodb');
SELECT * FROM t1;
DROP TABLE t1;
@@ -38,14 +38,14 @@ DROP TABLE t1;
#
CREATE TABLE t1 (c1 SMALLINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (32767, null);
--- error ER_DUP_ENTRY,1062
+-- error 167
INSERT INTO t1 (c2) VALUES ('innodb');
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (65535, null);
--- error ER_DUP_ENTRY,1062
+-- error 167
INSERT INTO t1 (c2) VALUES ('innodb');
SELECT * FROM t1;
DROP TABLE t1;
@@ -54,14 +54,14 @@ DROP TABLE t1;
#
CREATE TABLE t1 (c1 MEDIUMINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (8388607, null);
--- error ER_DUP_ENTRY,1062
+-- error 167
INSERT INTO t1 (c2) VALUES ('innodb');
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 MEDIUMINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (16777215, null);
--- error ER_DUP_ENTRY,1062
+-- error 167
INSERT INTO t1 (c2) VALUES ('innodb');
SELECT * FROM t1;
DROP TABLE t1;
@@ -70,14 +70,14 @@ DROP TABLE t1;
#
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (2147483647, null);
--- error ER_DUP_ENTRY,1062
+-- error 167
INSERT INTO t1 (c2) VALUES ('innodb');
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (4294967295, null);
--- error ER_DUP_ENTRY,1062
+-- error 167
INSERT INTO t1 (c2) VALUES ('innodb');
SELECT * FROM t1;
DROP TABLE t1;
@@ -86,7 +86,7 @@ DROP TABLE t1;
#
CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (9223372036854775807, null);
--- error ER_DUP_ENTRY,1062
+-- error 167
INSERT INTO t1 (c2) VALUES ('innodb');
SELECT * FROM t1;
DROP TABLE t1;
@@ -349,7 +349,7 @@ INSERT INTO t1 VALUES (18446744073709551610); #-- 2^64 - 2
SELECT * FROM t1;
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1152921504606846976, @@SESSION.AUTO_INCREMENT_OFFSET=1152921504606846976;
SHOW VARIABLES LIKE "%auto_inc%";
---error ER_WARN_DATA_OUT_OF_RANGE
+--error 167
INSERT INTO t1 VALUES (NULL),(NULL);
SELECT * FROM t1;
DROP TABLE t1;
@@ -437,7 +437,7 @@ CREATE TABLE t2(
PRIMARY KEY) ENGINE=InnoDB;
-- error ER_DUP_ENTRY,1062
INSERT INTO t2 SELECT c1 FROM t1;
--- error ER_DUP_ENTRY,1467
+-- error 167
INSERT INTO t2 SELECT NULL FROM t1;
DROP TABLE t1;
DROP TABLE t2;
diff --git a/mysql-test/suite/maria/maria3.result b/mysql-test/suite/maria/maria3.result
index 37613875f38..27d72b75930 100644
--- a/mysql-test/suite/maria/maria3.result
+++ b/mysql-test/suite/maria/maria3.result
@@ -452,6 +452,8 @@ SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO';
CREATE TABLE t1 (id int(11) PRIMARY KEY auto_increment,f1 varchar(10) NOT NULL UNIQUE);
INSERT IGNORE INTO t1 (f1) VALUES ("test1");
INSERT IGNORE INTO t1 (f1) VALUES ("test1");
+Warnings:
+Warning 1062 Duplicate entry 'test1' for key 'f1'
INSERT IGNORE INTO t1 (f1) VALUES ("test2");
SELECT * FROM t1;
id f1
diff --git a/mysql-test/suite/maria/mrr.result b/mysql-test/suite/maria/mrr.result
index af7789eebff..06be64566e5 100644
--- a/mysql-test/suite/maria/mrr.result
+++ b/mysql-test/suite/maria/mrr.result
@@ -277,6 +277,8 @@ bb-1 NULL cc-2 NULL-1
drop table t1, t2, t3, t4;
create table t1 (a int, b int not null,unique key (a,b),index(b));
insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6);
+Warnings:
+Warning 1062 Duplicate entry '6-6' for key 'a'
create table t2 like t1;
insert into t2 select * from t1;
alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10));
diff --git a/mysql-test/suite/optimizer_unfixed_bugs/r/bug43617.result b/mysql-test/suite/optimizer_unfixed_bugs/r/bug43617.result
index 3c19a37c95d..505dd587d0b 100644
--- a/mysql-test/suite/optimizer_unfixed_bugs/r/bug43617.result
+++ b/mysql-test/suite/optimizer_unfixed_bugs/r/bug43617.result
@@ -38,7 +38,11 @@ c1 c2 c3 c4
2008-01-01 00:00:00 NULL 2008-01-02 2008-01-03 00:00:00
2009-01-29 11:11:27 2009-01-29 00:00:00 2009-01-29 2009-01-29 00:00:00
INSERT IGNORE INTO t1(c1,c2) VALUES('20070525','20070527') /* doesnt throw error */;
+Warnings:
+Warning 1062 Duplicate entry '2007-05-25 00:00:00' for key 'PRIMARY'
INSERT IGNORE INTO t1(c1,c2) VALUES(19840905,830907) /* doesnt throw error */;
+Warnings:
+Warning 1062 Duplicate entry '1983-09-07 00:00:00' for key 'c2'
SELECT * FROM t1 WHERE c1='20070527' /* Returns no rows */;
c1 c2 c3 c4
INSERT INTO t1(c1) VALUES('20070525') ON DUPLICATE KEY UPDATE c1='20070527';
diff --git a/mysql-test/suite/plugins/t/feedback_plugin_send.test b/mysql-test/suite/plugins/t/feedback_plugin_send.test
index 3324ef469fe..45b507f8e78 100644
--- a/mysql-test/suite/plugins/t/feedback_plugin_send.test
+++ b/mysql-test/suite/plugins/t/feedback_plugin_send.test
@@ -1,3 +1,6 @@
+# Restart of server does not work for embedded.
+--source include/not_embedded.inc
+
source feedback_plugin_load.test;
if (!$MTR_FEEDBACK_PLUGIN) {
diff --git a/mysql-test/suite/rpl/r/rpl_auto_increment.result b/mysql-test/suite/rpl/r/rpl_auto_increment.result
index 8b41a01cb6e..41bacd78f52 100644
--- a/mysql-test/suite/rpl/r/rpl_auto_increment.result
+++ b/mysql-test/suite/rpl/r/rpl_auto_increment.result
@@ -125,6 +125,10 @@ insert into t1 values(600),(NULL),(NULL);
ERROR 23000: Duplicate entry '600' for key 'PRIMARY'
set @@insert_id=600;
insert ignore into t1 values(600),(NULL),(NULL),(610),(NULL);
+Warnings:
+Warning 1062 Duplicate entry '600' for key 'PRIMARY'
+Warning 1062 Duplicate entry '600' for key 'PRIMARY'
+Warning 1062 Duplicate entry '600' for key 'PRIMARY'
select * from t1;
a
1
@@ -186,7 +190,7 @@ set auto_increment_offset=4;
insert into t1 values(null);
insert into t1 values(null);
insert into t1 values(null);
-ERROR 23000: Duplicate entry '125' for key 'PRIMARY'
+ERROR 22003: Out of range value for column 'a' at row 1
select a, mod(a-@@auto_increment_offset,@@auto_increment_increment) from t1 order by a;
a mod(a-@@auto_increment_offset,@@auto_increment_increment)
103 0
@@ -196,21 +200,19 @@ create table t2 (a tinyint unsigned not null auto_increment primary key) engine=
set auto_increment_increment=10;
set auto_increment_offset=1;
set insert_id=1000;
+insert into t2 values(10);
insert into t2 values(null);
-Warnings:
-Warning 1264 Out of range value for column 'a' at row 1
+ERROR 22003: Out of range value for column 'a' at row 1
select a, mod(a-@@auto_increment_offset,@@auto_increment_increment) from t2 order by a;
a mod(a-@@auto_increment_offset,@@auto_increment_increment)
-251 0
+10 9
create table t3 like t1;
set auto_increment_increment=1000;
set auto_increment_offset=700;
insert into t3 values(null);
-Warnings:
-Warning 1264 Out of range value for column 'a' at row 1
+ERROR 22003: Out of range value for column 'a' at row 1
select * from t3 order by a;
a
-127
select * from t1 order by a;
a
103
@@ -218,10 +220,9 @@ a
125
select * from t2 order by a;
a
-251
+10
select * from t3 order by a;
a
-127
drop table t1,t2,t3;
set auto_increment_increment=1;
set auto_increment_offset=1;
diff --git a/mysql-test/suite/rpl/r/rpl_insert_delayed,stmt.rdiff b/mysql-test/suite/rpl/r/rpl_insert_delayed,stmt.rdiff
index 5e0e7db5b63..ddb10d604c6 100644
--- a/mysql-test/suite/rpl/r/rpl_insert_delayed,stmt.rdiff
+++ b/mysql-test/suite/rpl/r/rpl_insert_delayed,stmt.rdiff
@@ -1,5 +1,5 @@
---- suite/rpl/r/rpl_insert_delayed.result 2012-02-06 21:37:21.000000000 +0100
-+++ suite/rpl/r/rpl_insert_delayed,stmt.reject 2012-02-06 23:12:55.000000000 +0100
+--- suite/rpl/r/rpl_insert_delayed.result 2012-09-18 01:37:45.317521958 +0300
++++ suite/rpl/r/rpl_insert_delayed,stmt.reject 2012-09-18 01:36:16.637514667 +0300
@@ -15,17 +15,17 @@
insert delayed into t1 values(10, "my name");
flush table t1;
diff --git a/mysql-test/suite/rpl/r/rpl_loaddatalocal.result b/mysql-test/suite/rpl/r/rpl_loaddatalocal.result
index 257d5f580e8..16fd3f19c4a 100644
--- a/mysql-test/suite/rpl/r/rpl_loaddatalocal.result
+++ b/mysql-test/suite/rpl/r/rpl_loaddatalocal.result
@@ -14,6 +14,8 @@ select * into outfile 'MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' from t1;
drop table t1;
create table t1(a int primary key);
load data local infile 'MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' into table t1;
+Warnings:
+Warning 1062 Duplicate entry '2' for key 'PRIMARY'
SELECT * FROM t1 ORDER BY a;
a
1
diff --git a/mysql-test/suite/rpl/r/rpl_mdev382.result b/mysql-test/suite/rpl/r/rpl_mdev382.result
index 50da7e67bba..bbc57006d0d 100644
--- a/mysql-test/suite/rpl/r/rpl_mdev382.result
+++ b/mysql-test/suite/rpl/r/rpl_mdev382.result
@@ -77,8 +77,8 @@ master-bin.000001 # Query # # use `test`; insert into t1 values(18)
master-bin.000001 # Xid # # COMMIT /* XID */
*** Test correct USE statement in SHOW BINLOG EVENTS ***
set sql_mode = 'ANSI_QUOTES';
-CREATE DATABASE "db1`; SELECT 'oops!'";
-use "db1`; SELECT 'oops!'";
+CREATE DATABASE "db1`; select 'oops!'";
+use "db1`; select 'oops!'";
CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM;
INSERT INTO t1 VALUES (1);
set sql_mode = '';
@@ -86,41 +86,41 @@ INSERT INTO t1 VALUES (2);
set sql_mode = 'ANSI_QUOTES';
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # CREATE DATABASE "db1`; SELECT 'oops!'"
-master-bin.000001 # Query # # use "db1`; SELECT 'oops!'"; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
+master-bin.000001 # Query # # CREATE DATABASE "db1`; select 'oops!'"
+master-bin.000001 # Query # # use "db1`; select 'oops!'"; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Query # # use "db1`; SELECT 'oops!'"; INSERT INTO t1 VALUES (1)
+master-bin.000001 # Query # # use "db1`; select 'oops!'"; INSERT INTO t1 VALUES (1)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Query # # use "db1`; SELECT 'oops!'"; INSERT INTO t1 VALUES (2)
+master-bin.000001 # Query # # use "db1`; select 'oops!'"; INSERT INTO t1 VALUES (2)
master-bin.000001 # Query # # COMMIT
set sql_mode = '';
set sql_quote_show_create = 0;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # CREATE DATABASE "db1`; SELECT 'oops!'"
-master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
+master-bin.000001 # Query # # CREATE DATABASE "db1`; select 'oops!'"
+master-bin.000001 # Query # # use `db1``; select 'oops!'`; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (1)
+master-bin.000001 # Query # # use `db1``; select 'oops!'`; INSERT INTO t1 VALUES (1)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (2)
+master-bin.000001 # Query # # use `db1``; select 'oops!'`; INSERT INTO t1 VALUES (2)
master-bin.000001 # Query # # COMMIT
set sql_quote_show_create = 1;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # CREATE DATABASE "db1`; SELECT 'oops!'"
-master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
+master-bin.000001 # Query # # CREATE DATABASE "db1`; select 'oops!'"
+master-bin.000001 # Query # # use `db1``; select 'oops!'`; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (1)
+master-bin.000001 # Query # # use `db1``; select 'oops!'`; INSERT INTO t1 VALUES (1)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (2)
+master-bin.000001 # Query # # use `db1``; select 'oops!'`; INSERT INTO t1 VALUES (2)
master-bin.000001 # Query # # COMMIT
DROP TABLE t1;
use test;
***Test LOAD DATA INFILE with various identifiers that need correct quoting ***
-use `db1``; SELECT 'oops!'`;
+use `db1``; select 'oops!'`;
set timestamp=1000000000;
CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
`c``3` VARCHAR(7));
@@ -134,31 +134,31 @@ fo\o bar |b"a'z!
truncate `t``1`;
use test;
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f''le.txt'
- INTO TABLE `db1``; SELECT 'oops!'`.`t``1`
+ INTO TABLE `db1``; select 'oops!'`.`t``1`
FIELDS TERMINATED BY ',' ESCAPED BY '\\' ENCLOSED BY ''''
LINES TERMINATED BY '\n'
(`a``1`, `b``2`) SET `c``3` = concat('|', "b""a'z", "!");
-SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
+SELECT * FROM `db1``; select 'oops!'`.`t``1`;
a`1 b`2 c`3
fo\o bar |b"a'z!
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
+master-bin.000001 # Query # # use `db1``; select 'oops!'`; CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
`c``3` VARCHAR(7))
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
-master-bin.000001 # Execute_load_query # # use `db1``; SELECT 'oops!'`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f\'le.txt' INTO TABLE `t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, @`b```) SET `b``2`= @`b```, `c``3`= concat('|', "b""a'z", "!") ;file_id=#
+master-bin.000001 # Execute_load_query # # use `db1``; select 'oops!'`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f\'le.txt' INTO TABLE `t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, @`b```) SET `b``2`= @`b```, `c``3`= concat('|', "b""a'z", "!") ;file_id=#
master-bin.000001 # Query # # COMMIT
-master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; truncate `t``1`
+master-bin.000001 # Query # # use `db1``; select 'oops!'`; truncate `t``1`
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
-master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f\'le.txt' INTO TABLE `db1``; SELECT 'oops!'`.`t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, `b``2`) SET `c``3`= concat('|', "b""a'z", "!") ;file_id=#
+master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f\'le.txt' INTO TABLE `db1``; select 'oops!'`.`t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, `b``2`) SET `c``3`= concat('|', "b""a'z", "!") ;file_id=#
master-bin.000001 # Query # # COMMIT
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
-use `db1``; SELECT 'oops!'`/*!*/;
+use `db1``; select 'oops!'`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@@ -188,7 +188,7 @@ BEGIN
/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
-LOAD DATA LOCAL INFILE '<name>' INTO TABLE `db1``; SELECT 'oops!'`.`t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, `b``2`) SET `c``3`= concat('|', "b""a'z", "!")
+LOAD DATA LOCAL INFILE '<name>' INTO TABLE `db1``; select 'oops!'`.`t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, `b``2`) SET `c``3`= concat('|', "b""a'z", "!")
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
COMMIT
@@ -197,10 +197,10 @@ DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
-SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
+SELECT * FROM `db1``; select 'oops!'`.`t``1`;
a`1 b`2 c`3
fo\o bar |b"a'z!
-DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
+DROP TABLE `db1``; select 'oops!'`.`t``1`;
drop table t1,t2;
*** Test truncation of long SET expression in LOAD DATA ***
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(1000));
@@ -223,7 +223,7 @@ a b
2 A| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|A
DROP TABLE t1;
*** Test user variables whose names require correct quoting ***
-use `db1``; SELECT 'oops!'`;
+use `db1``; select 'oops!'`;
CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100));
INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100));
SELECT @`a``1`:=a1, @`a``2`:=a2, @`a``3`:=a3, @`a``4`:=a4, @`b```:=b, @```c`:=c, @```d```:=d FROM t1;
@@ -232,9 +232,9 @@ SELECT @`a``1`:=a1, @`a``2`:=a2, @`a``3`:=a3, @`a``4`:=a4, @`b```:=b, @```c`:=c,
INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98));
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100))
+master-bin.000001 # Query # # use `db1``; select 'oops!'`; CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100))
master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100))
+master-bin.000001 # Query # # use `db1``; select 'oops!'`; INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100))
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # User var # # @`a``1`=-9223372036854775808
@@ -244,13 +244,13 @@ master-bin.000001 # User var # # @`a``4`=18446744073709551615
master-bin.000001 # User var # # @`b```=-1.234560123456789e125
master-bin.000001 # User var # # @```c`=-1234501234567890123456789012345678901234567890123456789.0123456789
master-bin.000001 # User var # # @```d```=_latin1 0x78787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878 COLLATE latin1_swedish_ci
-master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98))
+master-bin.000001 # Query # # use `db1``; select 'oops!'`; INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98))
master-bin.000001 # Query # # COMMIT
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
-use `db1``; SELECT 'oops!'`/*!*/;
+use `db1``; select 'oops!'`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@@ -291,46 +291,44 @@ DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
-SELECT * FROM `db1``; SELECT 'oops!'`.t1 ORDER BY a1;
+SELECT * FROM `db1``; select 'oops!'`.t1 ORDER BY a1;
a1 a2 a3 a4 b c d
-9223372036854775808 42 9223372036854775807 18446744073709551615 -1.234560123456789e125 -1234501234567890123456789012345678901234567890123456789.0123456789 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-9223372036854775807 4200 9223372036854775806 18446744073709551614 -6.172800617283945e124 -1234501234567890123456789012345678901234567890123456789.0123456789 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DROP TABLE t1;
*** Test correct quoting in foreign key error message ***
-use `db1``; SELECT 'oops!'`;
+use `db1``; select 'oops!'`;
CREATE TABLE `t``1` ( `a``` INT PRIMARY KEY) ENGINE=innodb;
CREATE TABLE `t``2` ( `b``` INT PRIMARY KEY, `c``` INT NOT NULL,
FOREIGN KEY fk (`c```) REFERENCES `t``1`(`a```)) ENGINE=innodb;
TRUNCATE `t``1`;
-ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`db1``; SELECT 'oops!'`.`t``2`, CONSTRAINT `INNODB_FOREIGN_KEY_NAME` FOREIGN KEY (`c```) REFERENCES `db1``; SELECT 'oops!'`.`t``1` (`a```))
+ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`db1``; select 'oops!'`.`t``2`, CONSTRAINT `INNODB_FOREIGN_KEY_NAME` FOREIGN KEY (`c```) REFERENCES `db1``; select 'oops!'`.`t``1` (`a```))
DROP TABLE `t``2`;
DROP TABLE `t``1`;
*** Test correct quoting of DELETE FROM statement binlogged for HEAP table that is emptied due to server restart
include/stop_slave.inc
-CREATE TABLE `db1``; SELECT 'oops!'`.`t``1` (`a``` INT PRIMARY KEY) ENGINE=heap;
-INSERT INTO `db1``; SELECT 'oops!'`.`t``1` VALUES (1), (2), (5);
-SELECT * FROM `db1``; SELECT 'oops!'`.`t``1` ORDER BY 1;
+CREATE TABLE `db1``; select 'oops!'`.`t``1` (`a``` INT PRIMARY KEY) ENGINE=heap;
+INSERT INTO `db1``; select 'oops!'`.`t``1` VALUES (1), (2), (5);
+SELECT * FROM `db1``; select 'oops!'`.`t``1` ORDER BY 1;
a`
1
2
5
set timestamp=1000000000;
# The table should be empty on the master.
-SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
+SELECT * FROM `db1``; select 'oops!'`.`t``1`;
a`
# The DELETE statement should be correctly quoted
show binlog events in 'master-bin.000002' from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000002 # Query # # BEGIN
-master-bin.000002 # Query # # use `test`; DELETE FROM `db1``; SELECT 'oops!'`.`t``1`
-master-bin.000002 # Query # # COMMIT
+master-bin.000002 # Query # # DELETE FROM `db1``; select 'oops!'`.`t``1`
include/start_slave.inc
# The table should be empty on the slave also.
-SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
+SELECT * FROM `db1``; select 'oops!'`.`t``1`;
a`
-DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
+DROP TABLE `db1``; select 'oops!'`.`t``1`;
use test;
-DROP DATABASE `db1``; SELECT 'oops!'`;
+DROP DATABASE `db1``; select 'oops!'`;
*** Test correct quoting of mysqlbinlog --rewrite-db option ***
CREATE TABLE t1 (a INT PRIMARY KEY);
INSERT INTO t1 VALUES(1);
diff --git a/mysql-test/suite/rpl/t/rpl_mdev382.test b/mysql-test/suite/rpl/t/rpl_mdev382.test
index e84a29137bc..d88eeaa463e 100644
--- a/mysql-test/suite/rpl/t/rpl_mdev382.test
+++ b/mysql-test/suite/rpl/t/rpl_mdev382.test
@@ -64,8 +64,8 @@ set sql_quote_show_create = 1;
connection master;
let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
set sql_mode = 'ANSI_QUOTES';
-CREATE DATABASE "db1`; SELECT 'oops!'";
-use "db1`; SELECT 'oops!'";
+CREATE DATABASE "db1`; select 'oops!'";
+use "db1`; select 'oops!'";
CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM;
INSERT INTO t1 VALUES (1);
set sql_mode = '';
@@ -88,7 +88,7 @@ use test;
'fo\\o','bar'
EOF
-use `db1``; SELECT 'oops!'`;
+use `db1``; select 'oops!'`;
let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
set timestamp=1000000000;
CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
@@ -105,11 +105,11 @@ truncate `t``1`;
use test;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/f''le.txt'
- INTO TABLE `db1``; SELECT 'oops!'`.`t``1`
+ INTO TABLE `db1``; select 'oops!'`.`t``1`
FIELDS TERMINATED BY ',' ESCAPED BY '\\\\' ENCLOSED BY ''''
LINES TERMINATED BY '\\n'
(`a``1`, `b``2`) SET `c``3` = concat('|', "b""a'z", "!");
-SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
+SELECT * FROM `db1``; select 'oops!'`.`t``1`;
let $pos2= query_get_value(SHOW MASTER STATUS, Position, 1);
--source include/show_binlog_events.inc
@@ -119,10 +119,10 @@ let $MYSQLD_DATADIR= `select @@datadir`;
sync_slave_with_master;
connection slave;
-SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
+SELECT * FROM `db1``; select 'oops!'`.`t``1`;
connection master;
-DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
+DROP TABLE `db1``; select 'oops!'`.`t``1`;
--remove_file $load_file
connection master;
@@ -158,7 +158,7 @@ DROP TABLE t1;
--echo *** Test user variables whose names require correct quoting ***
-use `db1``; SELECT 'oops!'`;
+use `db1``; select 'oops!'`;
let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100));
INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100));
@@ -172,13 +172,13 @@ let $pos2= query_get_value(SHOW MASTER STATUS, Position, 1);
sync_slave_with_master;
connection slave;
-SELECT * FROM `db1``; SELECT 'oops!'`.t1 ORDER BY a1;
+SELECT * FROM `db1``; select 'oops!'`.t1 ORDER BY a1;
connection master;
DROP TABLE t1;
--echo *** Test correct quoting in foreign key error message ***
-use `db1``; SELECT 'oops!'`;
+use `db1``; select 'oops!'`;
CREATE TABLE `t``1` ( `a``` INT PRIMARY KEY) ENGINE=innodb;
CREATE TABLE `t``2` ( `b``` INT PRIMARY KEY, `c``` INT NOT NULL,
FOREIGN KEY fk (`c```) REFERENCES `t``1`(`a```)) ENGINE=innodb;
@@ -197,9 +197,9 @@ connection slave;
--source include/stop_slave.inc
connection master;
-CREATE TABLE `db1``; SELECT 'oops!'`.`t``1` (`a``` INT PRIMARY KEY) ENGINE=heap;
-INSERT INTO `db1``; SELECT 'oops!'`.`t``1` VALUES (1), (2), (5);
-SELECT * FROM `db1``; SELECT 'oops!'`.`t``1` ORDER BY 1;
+CREATE TABLE `db1``; select 'oops!'`.`t``1` (`a``` INT PRIMARY KEY) ENGINE=heap;
+INSERT INTO `db1``; select 'oops!'`.`t``1` VALUES (1), (2), (5);
+SELECT * FROM `db1``; select 'oops!'`.`t``1` ORDER BY 1;
# Restart the master mysqld.
# This will cause an implicit truncation of the memory-based table, which will
@@ -230,7 +230,7 @@ set timestamp=1000000000;
--echo # The table should be empty on the master.
let $binlog_file= master-bin.000002;
let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
+SELECT * FROM `db1``; select 'oops!'`.`t``1`;
--echo # The DELETE statement should be correctly quoted
--source include/show_binlog_events.inc
@@ -242,16 +242,16 @@ connection master;
sync_slave_with_master;
connection slave;
--echo # The table should be empty on the slave also.
-SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
+SELECT * FROM `db1``; select 'oops!'`.`t``1`;
connection master;
-DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
+DROP TABLE `db1``; select 'oops!'`.`t``1`;
sync_slave_with_master;
connection master;
use test;
-DROP DATABASE `db1``; SELECT 'oops!'`;
+DROP DATABASE `db1``; select 'oops!'`;
--echo *** Test correct quoting of mysqlbinlog --rewrite-db option ***
CREATE TABLE t1 (a INT PRIMARY KEY);
diff --git a/mysql-test/suite/rpl/t/rpl_start_stop_slave.test b/mysql-test/suite/rpl/t/rpl_start_stop_slave.test
index c9c8f043668..ab388f3eebc 100644
--- a/mysql-test/suite/rpl/t/rpl_start_stop_slave.test
+++ b/mysql-test/suite/rpl/t/rpl_start_stop_slave.test
@@ -21,6 +21,16 @@
connection slave;
--let $connection_id=`SELECT id FROM information_schema.processlist where state LIKE 'Waiting for master to send event'`
+if(!$connection_id)
+{
+ # Something went wrong (timing)
+ # Show process list so that we can debug. In this case we will abort with
+ # wrong result
+ -- echo "Could not find connect id. Dumping process list for debugging"
+ SELECT * FROM information_schema.processlist;
+ exit;
+}
+
set @time_before_kill := (select CURRENT_TIMESTAMP);
--echo [Time before the query]
diff --git a/mysql-test/suite/sys_vars/r/all_vars.result b/mysql-test/suite/sys_vars/r/all_vars.result
index 692545ae0fb..1bd4e394f6a 100644
--- a/mysql-test/suite/sys_vars/r/all_vars.result
+++ b/mysql-test/suite/sys_vars/r/all_vars.result
@@ -10,6 +10,5 @@ there should be *no* long test name listed below:
select distinct variable_name as `there should be *no* variables listed below:` from t2
left join t1 on variable_name=test_name where test_name is null;
there should be *no* variables listed below:
-expensive_subquery_limit
drop table t1;
drop table t2;
diff --git a/mysql-test/suite/sys_vars/r/expensive_subquery_limit_basic.result b/mysql-test/suite/sys_vars/r/expensive_subquery_limit_basic.result
new file mode 100644
index 00000000000..1617de21001
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/expensive_subquery_limit_basic.result
@@ -0,0 +1,52 @@
+SET @start_global_value = @@global.expensive_subquery_limit;
+SELECT @start_global_value;
+@start_global_value
+100
+select @@global.expensive_subquery_limit;
+@@global.expensive_subquery_limit
+100
+select @@session.expensive_subquery_limit;
+@@session.expensive_subquery_limit
+100
+show global variables like 'expensive_subquery_limit';
+Variable_name Value
+expensive_subquery_limit 100
+show session variables like 'expensive_subquery_limit';
+Variable_name Value
+expensive_subquery_limit 100
+select * from information_schema.global_variables where variable_name='expensive_subquery_limit';
+VARIABLE_NAME VARIABLE_VALUE
+EXPENSIVE_SUBQUERY_LIMIT 100
+select * from information_schema.session_variables where variable_name='expensive_subquery_limit';
+VARIABLE_NAME VARIABLE_VALUE
+EXPENSIVE_SUBQUERY_LIMIT 100
+set global expensive_subquery_limit=10;
+set session expensive_subquery_limit=20;
+select @@global.expensive_subquery_limit;
+@@global.expensive_subquery_limit
+10
+select @@session.expensive_subquery_limit;
+@@session.expensive_subquery_limit
+20
+show global variables like 'expensive_subquery_limit';
+Variable_name Value
+expensive_subquery_limit 10
+show session variables like 'expensive_subquery_limit';
+Variable_name Value
+expensive_subquery_limit 20
+select * from information_schema.global_variables where variable_name='expensive_subquery_limit';
+VARIABLE_NAME VARIABLE_VALUE
+EXPENSIVE_SUBQUERY_LIMIT 10
+select * from information_schema.session_variables where variable_name='expensive_subquery_limit';
+VARIABLE_NAME VARIABLE_VALUE
+EXPENSIVE_SUBQUERY_LIMIT 20
+set global expensive_subquery_limit=1.1;
+ERROR 42000: Incorrect argument type to variable 'expensive_subquery_limit'
+set global expensive_subquery_limit=1e1;
+ERROR 42000: Incorrect argument type to variable 'expensive_subquery_limit'
+set global expensive_subquery_limit="foo";
+ERROR 42000: Incorrect argument type to variable 'expensive_subquery_limit'
+SET @@global.expensive_subquery_limit = @start_global_value;
+SELECT @@global.expensive_subquery_limit;
+@@global.expensive_subquery_limit
+100
diff --git a/mysql-test/suite/sys_vars/r/innodb_merge_sort_block_size_basic.result b/mysql-test/suite/sys_vars/r/innodb_merge_sort_block_size_basic.result
new file mode 100644
index 00000000000..90c2954e43d
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/innodb_merge_sort_block_size_basic.result
@@ -0,0 +1,24 @@
+SELECT @@global.innodb_merge_sort_block_size;
+@@global.innodb_merge_sort_block_size
+1048576
+SELECT @@session.innodb_merge_sort_block_size;
+@@session.innodb_merge_sort_block_size
+1048576
+SET @old_global=@@global.innodb_merge_sort_block_size;
+SET @old_session=@@session.innodb_merge_sort_block_size;
+SET @@global.innodb_merge_sort_block_size = 2*1024*1024;
+SET @@session.innodb_merge_sort_block_size = 4*1024*1024;
+SELECT @@global.innodb_merge_sort_block_size;
+@@global.innodb_merge_sort_block_size
+2097152
+SELECT @@session.innodb_merge_sort_block_size;
+@@session.innodb_merge_sort_block_size
+4194304
+SET @@global.innodb_merge_sort_block_size = 1024*1024*1024+1;
+Warnings:
+Warning 1292 Truncated incorrect innodb_merge_sort_block_size value: '1073741825'
+SELECT @@global.innodb_merge_sort_block_size;
+@@global.innodb_merge_sort_block_size
+1073741824
+SET @@global.innodb_merge_sort_block_size=@old_global;
+SET @@session.innodb_merge_sort_block_size=@old_session;
diff --git a/mysql-test/suite/sys_vars/t/expensive_subquery_limit_basic.test b/mysql-test/suite/sys_vars/t/expensive_subquery_limit_basic.test
new file mode 100644
index 00000000000..c86433e94f5
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/expensive_subquery_limit_basic.test
@@ -0,0 +1,38 @@
+SET @start_global_value = @@global.expensive_subquery_limit;
+SELECT @start_global_value;
+
+#
+# exists as global and session
+#
+select @@global.expensive_subquery_limit;
+select @@session.expensive_subquery_limit;
+show global variables like 'expensive_subquery_limit';
+show session variables like 'expensive_subquery_limit';
+select * from information_schema.global_variables where variable_name='expensive_subquery_limit';
+select * from information_schema.session_variables where variable_name='expensive_subquery_limit';
+
+#
+# show that it's writable
+#
+set global expensive_subquery_limit=10;
+set session expensive_subquery_limit=20;
+select @@global.expensive_subquery_limit;
+select @@session.expensive_subquery_limit;
+show global variables like 'expensive_subquery_limit';
+show session variables like 'expensive_subquery_limit';
+select * from information_schema.global_variables where variable_name='expensive_subquery_limit';
+select * from information_schema.session_variables where variable_name='expensive_subquery_limit';
+
+#
+# incorrect types
+#
+--error ER_WRONG_TYPE_FOR_VAR
+set global expensive_subquery_limit=1.1;
+--error ER_WRONG_TYPE_FOR_VAR
+set global expensive_subquery_limit=1e1;
+--error ER_WRONG_TYPE_FOR_VAR
+set global expensive_subquery_limit="foo";
+
+SET @@global.expensive_subquery_limit = @start_global_value;
+SELECT @@global.expensive_subquery_limit;
+
diff --git a/mysql-test/suite/sys_vars/t/innodb_merge_sort_block_size_basic.test b/mysql-test/suite/sys_vars/t/innodb_merge_sort_block_size_basic.test
new file mode 100644
index 00000000000..2ec4870f345
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/innodb_merge_sort_block_size_basic.test
@@ -0,0 +1,19 @@
+--source include/have_xtradb.inc
+
+SELECT @@global.innodb_merge_sort_block_size;
+SELECT @@session.innodb_merge_sort_block_size;
+
+SET @old_global=@@global.innodb_merge_sort_block_size;
+SET @old_session=@@session.innodb_merge_sort_block_size;
+
+SET @@global.innodb_merge_sort_block_size = 2*1024*1024;
+SET @@session.innodb_merge_sort_block_size = 4*1024*1024;
+
+SELECT @@global.innodb_merge_sort_block_size;
+SELECT @@session.innodb_merge_sort_block_size;
+
+SET @@global.innodb_merge_sort_block_size = 1024*1024*1024+1;
+SELECT @@global.innodb_merge_sort_block_size;
+
+SET @@global.innodb_merge_sort_block_size=@old_global;
+SET @@session.innodb_merge_sort_block_size=@old_session;
diff --git a/mysql-test/t/adddate_454.test b/mysql-test/t/adddate_454.test
new file mode 100644
index 00000000000..1d69cdc9558
--- /dev/null
+++ b/mysql-test/t/adddate_454.test
@@ -0,0 +1,9 @@
+#
+# MDEV-454 Addition of a time interval reduces the resulting value
+#
+create table t1 (d date);
+insert into t1 values ('2012-00-00');
+select * from t1;
+update t1 set d = adddate(d, interval 1 day);
+select * from t1;
+drop table t1;
diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test
index 884e0fabb5e..15156b89d8e 100644
--- a/mysql-test/t/auto_increment.test
+++ b/mysql-test/t/auto_increment.test
@@ -104,7 +104,7 @@ explain extended select last_insert_id();
--error ER_DUP_ENTRY
insert into t1 set i = 254;
select last_insert_id();
---error ER_DUP_ENTRY
+--error 167
insert into t1 set i = null;
select last_insert_id();
drop table t1;
@@ -113,6 +113,7 @@ create table t1 (i tinyint unsigned not null auto_increment, key (i));
insert into t1 set i = 254;
insert into t1 set i = null;
select last_insert_id();
+--error 167
insert into t1 set i = null;
select last_insert_id();
drop table t1;
@@ -353,7 +354,7 @@ INSERT INTO t1 VALUES (18446744073709551601);
SET @@SESSION.AUTO_INCREMENT_INCREMENT=10;
SELECT @@SESSION.AUTO_INCREMENT_OFFSET;
---error ER_WARN_DATA_OUT_OF_RANGE
+--error 167
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
SELECT * FROM t1;
diff --git a/mysql-test/t/auto_increment_ranges.inc b/mysql-test/t/auto_increment_ranges.inc
new file mode 100644
index 00000000000..a94aa46d38e
--- /dev/null
+++ b/mysql-test/t/auto_increment_ranges.inc
@@ -0,0 +1,240 @@
+#
+# Test of auto_increment at end of range
+#
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+--echo #
+--echo # Testing ranges with smallint
+--echo #
+let $type=smallint;
+let $range_max=32767;
+
+eval create table t1 (a $type primary key auto_increment);
+eval insert into t1 values($range_max);
+--error 167
+insert into t1 values(NULL);
+truncate table t1;
+eval insert into t1 values($range_max-1);
+insert into t1 values(NULL);
+--error 167
+insert into t1 values(NULL);
+select * from t1;
+truncate table t1;
+--error 167
+eval insert into t1 values($range_max),(NULL);
+select * from t1;
+truncate table t1;
+--error 167
+eval insert into t1 values($range_max-1),(NULL),(NULL);
+truncate table t1;
+eval insert into t1 values($range_max+1);
+select * from t1;
+--error 167
+eval insert into t1 values(NULL);
+drop table t1;
+
+--echo #
+--echo # Testing ranges with unsigned smallint
+--echo #
+
+let $type=smallint unsigned;
+let $range_max=65535;
+
+eval create table t1 (a $type primary key auto_increment);
+eval insert into t1 values($range_max);
+--error 167
+insert into t1 values(NULL);
+truncate table t1;
+eval insert into t1 values($range_max-1);
+insert into t1 values(NULL);
+--error 167
+insert into t1 values(NULL);
+select * from t1;
+truncate table t1;
+--error 167
+eval insert into t1 values($range_max),(NULL);
+select * from t1;
+truncate table t1;
+--error 167
+eval insert into t1 values($range_max-1),(NULL),(NULL);
+truncate table t1;
+eval insert into t1 values($range_max+1);
+select * from t1;
+--error 167
+eval insert into t1 values(NULL);
+drop table t1;
+
+--echo #
+--echo # Testing ranges with integer
+--echo #
+
+let $type=int;
+let $range_max=2147483647;
+
+eval create table t1 (a $type primary key auto_increment);
+eval insert into t1 values($range_max);
+--error 167
+insert into t1 values(NULL);
+truncate table t1;
+eval insert into t1 values($range_max-1);
+insert into t1 values(NULL);
+--error 167
+insert into t1 values(NULL);
+select * from t1;
+truncate table t1;
+--error 167
+eval insert into t1 values($range_max),(NULL);
+select * from t1;
+truncate table t1;
+--error 167
+eval insert into t1 values($range_max-1),(NULL),(NULL);
+truncate table t1;
+eval insert into t1 values($range_max+1);
+select * from t1;
+--error 167
+eval insert into t1 values(NULL);
+drop table t1;
+
+--echo #
+--echo # Testing ranges with unsigned integer
+--echo #
+
+let $type=int unsigned;
+let $range_max=4294967295;
+
+eval create table t1 (a $type primary key auto_increment);
+eval insert into t1 values($range_max);
+--error 167
+insert into t1 values(NULL);
+truncate table t1;
+eval insert into t1 values($range_max-1);
+insert into t1 values(NULL);
+--error 167
+insert into t1 values(NULL);
+select * from t1;
+truncate table t1;
+--error 167
+eval insert into t1 values($range_max),(NULL);
+select * from t1;
+truncate table t1;
+--error 167
+eval insert into t1 values($range_max-1),(NULL),(NULL);
+truncate table t1;
+eval insert into t1 values($range_max+1);
+select * from t1;
+--error 167
+eval insert into t1 values(NULL);
+drop table t1;
+
+--echo #
+--echo # Testing ranges with bigint
+--echo #
+
+let $type=bigint;
+let $range_max=cast(9223372036854775807 as unsigned);
+
+eval create table t1 (a $type primary key auto_increment);
+eval insert into t1 values($range_max);
+--error 167
+insert into t1 values(NULL);
+truncate table t1;
+eval insert into t1 values($range_max-1);
+insert into t1 values(NULL);
+--error 167
+insert into t1 values(NULL);
+select * from t1;
+truncate table t1;
+--error 167
+eval insert into t1 values($range_max),(NULL);
+select * from t1;
+truncate table t1;
+--error 167
+eval insert into t1 values($range_max-1),(NULL),(NULL);
+truncate table t1;
+eval insert into t1 values($range_max+1);
+select * from t1;
+--error 167
+eval insert into t1 values(NULL);
+drop table t1;
+
+--echo #
+--echo # Testing ranges with unsigned bigint
+--echo #
+
+let $type=bigint unsigned;
+let $range_max=18446744073709551615;
+
+eval create table t1 (a $type primary key auto_increment);
+eval insert into t1 values($range_max-1);
+--error ER_AUTOINC_READ_FAILED
+insert into t1 values(NULL);
+--error ER_AUTOINC_READ_FAILED
+insert into t1 values(NULL);
+truncate table t1;
+eval insert into t1 values($range_max-1);
+--error ER_AUTOINC_READ_FAILED
+insert into t1 values(NULL);
+--error ER_AUTOINC_READ_FAILED
+insert into t1 values(NULL);
+select * from t1;
+truncate table t1;
+--error ER_AUTOINC_READ_FAILED
+eval insert into t1 values($range_max),(NULL);
+select * from t1;
+truncate table t1;
+--error ER_AUTOINC_READ_FAILED
+eval insert into t1 values($range_max-1),(NULL),(NULL);
+drop table t1;
+
+--echo #
+--echo # Test IGNORE and strict mode
+--echo #
+create table t1 (a smallint primary key auto_increment);
+insert ignore into t1 values(32766),(NULL),(NULL),(1);
+select * from t1;
+truncate table t1;
+
+set @org_mode=@@sql_mode;
+set @@sql_mode='ansi,traditional';
+insert ignore into t1 values(32766),(NULL),(NULL);
+truncate table t1;
+--error 167
+insert into t1 values(32766),(NULL),(NULL);
+set @@sql_mode=@org_mode;
+drop table t1;
+
+--echo #
+--echo # Test auto increment with negative numbers
+--echo #
+CREATE TABLE t1 (a INTEGER AUTO_INCREMENT, PRIMARY KEY (a));
+INSERT INTO t1 VALUES (NULL), (2), (-5), (NULL);
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1;
+TRUNCATE TABLE t1;
+INSERT INTO t1 VALUES (-5), (NULL);
+SELECT * FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # Test inserting a value out-of-range into an auto increment column
+--echo #
+CREATE TABLE t1 (a smallint AUTO_INCREMENT, PRIMARY KEY (a));
+INSERT INTO t1 VALUES (2);
+INSERT INTO t1 VALUES (32768);
+--error 167
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Test old behaviour
+--echo #
+create table t1 (a smallint primary key auto_increment);
+insert into t1 values(32766),(NULL);
+delete from t1 where a=32767;
+--error 167
+insert into t1 values(NULL);
+drop table t1;
diff --git a/mysql-test/t/auto_increment_ranges_innodb.test b/mysql-test/t/auto_increment_ranges_innodb.test
new file mode 100644
index 00000000000..c2afee7ac66
--- /dev/null
+++ b/mysql-test/t/auto_increment_ranges_innodb.test
@@ -0,0 +1,7 @@
+#
+# Test of auto_increment at end of range
+#
+
+--source include/have_innodb.inc
+set default_storage_engine=innodb;
+--source auto_increment_ranges.inc
diff --git a/mysql-test/t/auto_increment_ranges_myisam.test b/mysql-test/t/auto_increment_ranges_myisam.test
new file mode 100644
index 00000000000..90e84377540
--- /dev/null
+++ b/mysql-test/t/auto_increment_ranges_myisam.test
@@ -0,0 +1,7 @@
+#
+# Test of auto_increment at end of range
+#
+
+set default_storage_engine=MYISAM;
+--source auto_increment_ranges.inc
+
diff --git a/mysql-test/t/datetime_456.test b/mysql-test/t/datetime_456.test
new file mode 100644
index 00000000000..0c187959d52
--- /dev/null
+++ b/mysql-test/t/datetime_456.test
@@ -0,0 +1,8 @@
+#
+# MDEV-456 An out-of-range datetime value (with a 5-digit year) can be created and cause troubles
+#
+create table t1 (d datetime);
+insert t1 values (addtime('9999-12-31 23:59:59', '00:00:01')),
+ (from_days(3652499));
+select * from t1;
+drop table t1;
diff --git a/mysql-test/t/errors.test b/mysql-test/t/errors.test
index 82204e1bfac..6ce6e439919 100644
--- a/mysql-test/t/errors.test
+++ b/mysql-test/t/errors.test
@@ -189,3 +189,12 @@ INSERT INTO t2 VALUES (1,0) ON DUPLICATE KEY UPDATE
INSERT INTO t2(a,b) VALUES (1,0) ON DUPLICATE KEY UPDATE
b=(SELECT VALUES(a)+2 FROM t1);
DROP TABLE t1, t2;
+
+--echo #
+--echo # MDEV-492: incorrect error check before sending OK in mysql_update
+--echo #
+CREATE TABLE t1 (a CHAR(3), b BLOB);
+--error ER_DYN_COL_DATA
+UPDATE t1 SET a = 'new'
+WHERE COLUMN_CREATE( 1, 'v', 1, 'w' ) IS NULL;
+drop table t1;
diff --git a/mysql-test/t/features.test b/mysql-test/t/features.test
new file mode 100644
index 00000000000..cdfc9413da5
--- /dev/null
+++ b/mysql-test/t/features.test
@@ -0,0 +1,111 @@
+# Testing of feature statistics
+
+-- source include/have_geometry.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+show status like "feature%";
+
+--echo #
+--echo # Feature GIS
+--echo #
+
+CREATE TABLE t1 (g POINT);
+SHOW FIELDS FROM t1;
+INSERT INTO t1 VALUES
+ (PointFromText('POINT(10 10)')),
+ (PointFromText('POINT(20 10)')),
+ (PointFromText('POINT(20 20)')),
+ (PointFromWKB(AsWKB(PointFromText('POINT(10 20)'))));
+drop table t1;
+
+show status like "feature_gis";
+
+--echo #
+--echo # Feature dynamic columns
+--echo #
+set @a= COLUMN_CREATE(1, 1212 AS int);
+set @b= column_add(@a, 2, 1212 as integer);
+select column_get(@b, 2 as integer);
+
+show status like "feature_dynamic_columns";
+
+--echo #
+--echo # Feature fulltext
+--echo #
+
+CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b)) engine=myisam;
+INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
+ ('Full-text indexes', 'are called collections'),
+ ('Only MyISAM tables','support collections'),
+ ('Function MATCH ... AGAINST()','is used to do a search'),
+ ('Full-text search in MySQL', 'implements vector space model');
+select * from t1 where MATCH(a,b) AGAINST ("collections");
+select * from t1 where MATCH(a,b) AGAINST ("indexes");
+drop table t1;
+
+# We need the following when running with --ps-protocol
+--replace_result 4 2
+show status like "feature_fulltext";
+
+
+--echo #
+--echo # Feature locale
+--echo #
+
+SET lc_messages=sr_RS;
+SET lc_messages=en_US;
+show status like "feature_locale";
+
+--echo #
+--echo # Feature subquery
+--echo #
+
+select (select 2);
+SELECT (SELECT 1) UNION SELECT (SELECT 2);
+
+create table t1 (a int);
+insert into t1 values (2);
+select (select a from t1 where t1.a=t2.a), a from t1 as t2;
+drop table t1;
+--replace_result 8 4
+show status like "feature_subquery";
+
+--echo #
+--echo # Feature timezone
+--echo #
+
+SELECT FROM_UNIXTIME(unix_timestamp()) > "1970-01-01";
+set time_zone="+03:00";
+SELECT FROM_UNIXTIME(unix_timestamp()) > "1970-01-01";
+set time_zone= @@global.time_zone;
+show status like "feature_timezone";
+
+--echo #
+--echo # Feature triggers
+--echo #
+
+create table t1 (i int);
+--echo # let us test some very simple trigger
+create trigger trg before insert on t1 for each row set @a:=1;
+set @a:=0;
+select @a;
+insert into t1 values (1),(2);
+select @a;
+SHOW TRIGGERS IN test like 't1';
+drop trigger trg;
+drop table t1;
+
+show status like "%trigger%";
+
+--echo #
+--echo # Feature xml
+--echo #
+SET @xml='<a aa1="aa1" aa2="aa2">a1<b ba1="ba1">b1<c>c1</c>b2</b>a2</a>';
+SELECT extractValue(@xml,'/a');
+select updatexml('<div><div><span>1</span><span>2</span></div></div>',
+ '/','<tr><td>1</td><td>2</td></tr>') as upd1;
+--replace_result 4 2
+show status like "feature_xml";
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index 42705975b88..f60f5e5ced7 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -1172,3 +1172,5 @@ select cast(greatest(cast("0-0-0" as date), cast("10:20:05" as time)) as datetim
select microsecond('12:00:00.123456'), microsecond('2009-12-31 23:59:59.000010');
+--error ER_TOO_BIG_PRECISION
+select now(258);
diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test
index f4c9de4e7da..b0ad8329cfb 100644
--- a/mysql-test/t/gis.test
+++ b/mysql-test/t/gis.test
@@ -1293,6 +1293,21 @@ WHERE ST_Contains(ST_Buffer(bridges.position, 15.0), buildings.footprint) = 1;
#WHERE lakes.name = 'Blue Lake';
DROP DATABASE gis_ogs;
+
+--echo #
+--echo # BUG #1043845 st_distance() results are incorrect depending on variable order
+--echo #
+
+select st_distance(geomfromtext('LINESTRING(-95.9673005697771 36.13509598461,
+ -95.9673057475387 36.1344478941074,
+ -95.9673063519371 36.134484524621,
+ -95.9673049102515 36.1343976584193)'),
+ geomfromtext('point(-95.96269500000000000000 36.14181833333330000000)')) ;
+select st_distance(geomfromtext('point(-95.96269500000000000000 36.14181833333330000000)'),
+ geomfromtext('LINESTRING(-95.9673005697771 36.13509598461,
+ -95.9673057475387 36.1344478941074,
+ -95.9673063519371 36.134484524621,
+ -95.9673049102515 36.1343976584193) ')) ;
USE test;
@@ -1344,4 +1359,3 @@ SELECT 1 FROM g1 WHERE a >= ANY
DROP TABLE g1;
--echo End of 5.5 tests
-
diff --git a/mysql-test/t/last_value.test b/mysql-test/t/last_value.test
new file mode 100644
index 00000000000..41cfdb5482d
--- /dev/null
+++ b/mysql-test/t/last_value.test
@@ -0,0 +1,46 @@
+#
+# Tests for the LAST_VALUE function
+#
+
+--disable_warnings
+drop table if exists t1;
+drop database if exists mysqltest;
+--enable_warnings
+
+# CREATE TABLE `queue` (
+# `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+# `priority` int(11) DEFAULT NULL,
+# `state` int(11) DEFAULT NULL,
+# `pid` int(10) unsigned DEFAULT NULL,
+# `dat` varbinary(200) DEFAULT NULL,
+# PRIMARY KEY (`id`)
+# )
+
+CREATE TABLE t1 (a INT, b INT, c INT, d INT);
+INSERT INTO t1 VALUES (1,3,0,NULL),(2,2,0,NULL),(3,4,0,NULL),(4,2,0,NULL);
+SELECT * FROM t1;
+UPDATE t1 SET c=LAST_VALUE(@last_a:=a,@last_b:=b,@last_c:=c,1), d=4211 WHERE c=0 ORDER BY b DESC LIMIT 1;
+SELECT @last_a, @last_b, @last_c;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+#
+# Test with different types
+#
+# PS protocol gives slightly different metadata for the length
+--enable_metadata
+--disable_ps_protocol
+SELECT LAST_VALUE(@last_a:=1,@last_b:=1);
+select @last_b;
+--enable_ps_protocol
+SELECT LAST_VALUE(@last_a:=1,@last_b:=1.0);
+select @last_b;
+SELECT LAST_VALUE(@last_a:=1,@last_b:="hello");
+select @last_b;
+SELECT date(LAST_VALUE(@last_a:=1,@last_b:="2001-02-03"));
+select @last_b;
+SELECT LAST_VALUE(@last_a:=1,@last_b:="2001-02-03",NULL);
+select @last_b;
+--disable_metadata
+--error ER_PARSE_ERROR
+SELECT LAST_VALUE();
diff --git a/mysql-test/t/mdev375.test b/mysql-test/t/mdev375.test
index 547d57aa587..fe259b37808 100644
--- a/mysql-test/t/mdev375.test
+++ b/mysql-test/t/mdev375.test
@@ -1,6 +1,8 @@
#
# MDEV-375 Server crashes in THD::print_aborted_warning with log_warnings > 3
#
+--source include/not_embedded.inc
+
SET GLOBAL log_warnings=4;
SET GLOBAL max_connections=2;
diff --git a/mysql-test/t/replace.test b/mysql-test/t/replace.test
index ff910bdf5cf..3d32a8c0da6 100644
--- a/mysql-test/t/replace.test
+++ b/mysql-test/t/replace.test
@@ -25,9 +25,9 @@ drop table t1;
create table t1 (a tinyint not null auto_increment primary key, b char(20) default "default_value");
insert into t1 values (126,"first"),(63, "middle"),(0,"last");
---error ER_DUP_ENTRY
+--error 167
insert into t1 values (0,"error");
---error ER_DUP_ENTRY
+--error 167
replace into t1 values (0,"error");
replace into t1 values (126,"first updated");
replace into t1 values (63,default);
diff --git a/mysql-test/t/subselect4.test b/mysql-test/t/subselect4.test
index b53967e35e5..50b34eece89 100644
--- a/mysql-test/t/subselect4.test
+++ b/mysql-test/t/subselect4.test
@@ -185,6 +185,75 @@ SELECT * FROM (SELECT default(a) FROM t GROUP BY a) d;
DROP TABLE t;
--echo #
+--echo # LP BUG#1009187, MDEV-373, MYSQL bug#58628
+--echo # Wrong result for a query with [NOT] IN subquery predicate if
+--echo # the left part of the predicate is explicit NULL
+--echo #
+
+CREATE TABLE t1 (pk INT NOT NULL, i INT NOT NULL);
+INSERT INTO t1 VALUES (0,10), (1,20), (2,30), (3,40);
+
+CREATE TABLE t2a (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i,pk));
+INSERT INTO t2a VALUES (0,0), (1,1), (2,2), (3,3);
+
+CREATE TABLE t2b (pk INT, i INT);
+INSERT INTO t2b VALUES (0,0), (1,1), (2,2), (3,3);
+
+CREATE TABLE t2c (pk INT NOT NULL, i INT NOT NULL);
+INSERT INTO t2c VALUES (0,0), (1,1), (2,2), (3,3);
+create index it2c on t2c (i,pk);
+
+CREATE TABLE t2d (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i));
+INSERT INTO t2d VALUES (0,0), (1,1), (2,2), (3,3);
+
+EXPLAIN
+SELECT * FROM t1 WHERE NULL NOT IN (SELECT t2a.i FROM t2a WHERE t2a.pk = t1.pk);
+SELECT * FROM t1 WHERE NULL NOT IN (SELECT t2a.i FROM t2a WHERE t2a.pk = t1.pk);
+SELECT * FROM t1 WHERE 1+NULL NOT IN (SELECT t2a.i FROM t2a WHERE t2a.pk = t1.pk);
+SELECT * FROM t1 WHERE NULL IN (SELECT t2a.i FROM t2a WHERE t2a.pk = t1.pk) IS UNKNOWN;
+SELECT t1.pk, NULL NOT IN (SELECT t2a.i FROM t2a WHERE t2a.pk = t1.pk) FROM t1;
+
+EXPLAIN
+SELECT * FROM t1 WHERE NULL NOT IN (SELECT t2b.i FROM t2b WHERE t2b.pk = t1.pk);
+SELECT * FROM t1 WHERE NULL NOT IN (SELECT t2b.i FROM t2b WHERE t2b.pk = t1.pk);
+SELECT * FROM t1 WHERE NULL IN (SELECT t2b.i FROM t2b WHERE t2b.pk = t1.pk) IS UNKNOWN;
+SELECT t1.pk, NULL NOT IN (SELECT t2b.i FROM t2b WHERE t2b.pk = t1.pk) FROM t1;
+
+EXPLAIN
+SELECT * FROM t1 WHERE NULL NOT IN (SELECT t2c.i FROM t2c WHERE t2c.pk = t1.pk);
+SELECT * FROM t1 WHERE NULL NOT IN (SELECT t2c.i FROM t2c WHERE t2c.pk = t1.pk);
+SELECT * FROM t1 WHERE NULL IN (SELECT t2c.i FROM t2c WHERE t2c.pk = t1.pk) IS UNKNOWN;
+SELECT t1.pk, NULL NOT IN (SELECT t2c.i FROM t2c WHERE t2c.pk = t1.pk) FROM t1;
+
+EXPLAIN
+SELECT * FROM t1 WHERE NULL NOT IN (SELECT t2d.i FROM t2d WHERE t2d.pk = t1.pk);
+SELECT * FROM t1 WHERE NULL NOT IN (SELECT t2d.i FROM t2d WHERE t2d.pk = t1.pk);
+SELECT * FROM t1 WHERE NULL IN (SELECT t2d.i FROM t2d WHERE t2d.pk = t1.pk) IS UNKNOWN;
+SELECT t1.pk, NULL NOT IN (SELECT t2d.i FROM t2d WHERE t2d.pk = t1.pk) FROM t1;
+
+EXPLAIN
+SELECT * FROM t1 WHERE (NULL, 1) NOT IN (SELECT t2a.i, t2a.pk FROM t2a WHERE t2a.pk = t1.pk);
+SELECT * FROM t1 WHERE (NULL, 1) NOT IN (SELECT t2a.i, t2a.pk FROM t2a WHERE t2a.pk = t1.pk);
+SELECT (NULL, 1) NOT IN (SELECT t2a.i, t2a.pk FROM t2a WHERE t2a.pk = t1.pk) from t1;
+
+EXPLAIN
+SELECT * FROM t1 WHERE (NULL, 1) NOT IN (SELECT t2b.i, t2b.pk FROM t2b WHERE t2b.pk = t1.pk);
+SELECT * FROM t1 WHERE (NULL, 1) NOT IN (SELECT t2b.i, t2b.pk FROM t2b WHERE t2b.pk = t1.pk);
+SELECT (NULL, 1) NOT IN (SELECT t2b.i, t2b.pk FROM t2b WHERE t2b.pk = t1.pk) from t1;
+
+EXPLAIN
+SELECT * FROM t1 WHERE (NULL, 1) NOT IN (SELECT t2c.i, t2c.pk FROM t2c WHERE t2c.pk = t1.pk);
+SELECT * FROM t1 WHERE (NULL, 1) NOT IN (SELECT t2c.i, t2c.pk FROM t2c WHERE t2c.pk = t1.pk);
+SELECT (NULL, 1) NOT IN (SELECT t2c.i, t2c.pk FROM t2c WHERE t2c.pk = t1.pk) from t1;
+
+EXPLAIN
+SELECT * FROM t1 WHERE (NULL, 1) NOT IN (SELECT t2d.i, t2d.pk FROM t2d WHERE t2d.pk = t1.pk);
+SELECT * FROM t1 WHERE (NULL, 1) NOT IN (SELECT t2d.i, t2d.pk FROM t2d WHERE t2d.pk = t1.pk);
+SELECT (NULL, 1) NOT IN (SELECT t2d.i, t2d.pk FROM t2d WHERE t2d.pk = t1.pk) from t1;
+
+drop table t1, t2a, t2b, t2c, t2d;
+
+--echo #
--echo # End of 5.1 tests.
--echo #
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 17026e45724..c4881f7df3f 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -4618,6 +4618,8 @@ DROP TABLE t1,t2,t3;
--echo # inserting into a view over a view
--echo #
+flush status;
+--disable_ps_protocol
CREATE TABLE t1 (a INT);
CREATE ALGORITHM=MERGE VIEW v1 AS SELECT a1.* FROM t1 AS a1, t1 AS a2;
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM v1;
@@ -4625,7 +4627,40 @@ INSERT INTO v2 (a) VALUES (1) ;
select * from t1;
drop view v2,v1;
drop table t1;
+show status like '%view%';
+show status like 'Opened_table%';
+--enable_ps_protocol
+--echo #
+--echo # MDEV-486 LP BUG#1010116 Incorrect query results in
+--echo # view and derived tables
+--echo #
+
+SELECT
+`Derived1`.`id`,
+`Derived2`.`Val1`
+FROM (select 30631 as `id`) AS `Derived1` LEFT OUTER JOIN (SELECT
+2 as `id`,
+1 AS `Val1`
+FROM (select 30631 as `id`) AS `Derived3`) AS `Derived2` ON `Derived1`.`id` = `Derived2`.`id`;
+
+create table t1 ( id int );
+insert into t1 values (30631);
+create table t2 ( id int );
+insert into t2 values (30631);
+create algorithm=MERGE view v2 as select 2 as id, 1 as val1 from t2;
+select t1.*, v2.* from t1 left join v2 on t1.id = v2.id;
+drop view v2;
+drop table t1,t2;
+
+create table t1 ( id int );
+insert into t1 values (30631);
+create table t2 ( id int );
+insert into t2 values (30631);
+create algorithm=MERGE view v2 as select 2 as id, id is null as bbb, id as iddqd, 1 as val1 from t2;
+select t1.*, v2.* from t1 left join v2 on t1.id = v2.id;
+drop view v2;
+drop table t1,t2;
--echo # -----------------------------------------------------------------
--echo # -- End of 5.3 tests.
--echo # -----------------------------------------------------------------
diff --git a/mysys/lf_alloc-pin.c b/mysys/lf_alloc-pin.c
index d23ef129aa2..6ab6ba3aae0 100644
--- a/mysys/lf_alloc-pin.c
+++ b/mysys/lf_alloc-pin.c
@@ -271,7 +271,7 @@ static int ptr_cmp(void **a, void **b)
void _lf_pinbox_free(LF_PINS *pins, void *addr)
{
add_to_purgatory(pins, addr);
- if (pins->purgatory_count % LF_PURGATORY_SIZE)
+ if (pins->purgatory_count % LF_PURGATORY_SIZE == 0)
_lf_pinbox_real_free(pins);
}
diff --git a/mysys/lf_hash.c b/mysys/lf_hash.c
index 83cfe1a1639..38b212c65f0 100644
--- a/mysys/lf_hash.c
+++ b/mysys/lf_hash.c
@@ -268,8 +268,10 @@ static LF_SLIST *lsearch(LF_SLIST * volatile *head, CHARSET_INFO *cs,
int res= lfind(head, cs, hashnr, key, keylen, &cursor, pins);
if (res)
_lf_pin(pins, 2, cursor.curr);
- _lf_unpin(pins, 0);
+ else
+ _lf_unpin(pins, 2);
_lf_unpin(pins, 1);
+ _lf_unpin(pins, 0);
return res ? cursor.curr : 0;
}
diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c
index 72372ae6bc0..ff05b7fa485 100644
--- a/mysys/mf_iocache2.c
+++ b/mysys/mf_iocache2.c
@@ -440,7 +440,7 @@ process_flags:
/* TODO: implement precision */
if (backtick_quoting)
{
- size_t total= my_b_write_backtick_quote(info, (uchar *) par, length2);
+ size_t total= my_b_write_backtick_quote(info, par, length2);
if (total == (size_t)-1)
goto err;
out_length+= total;
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index facc1569943..c1b0a129a30 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -691,15 +691,13 @@ static int setval(const struct my_option *opts, void *value, char *argument,
*((double*) value)= getopt_double(argument, opts, &err);
break;
case GET_STR:
- if (argument == enabled_my_option)
- break; /* string options don't use this default of "1" */
- *((char**) value)= argument;
+ /* If no argument or --enable-string-option, set string to "" */
+ *((char**) value)= argument == enabled_my_option ? (char*) "" : argument;
break;
case GET_STR_ALLOC:
- if (argument == enabled_my_option)
- break; /* string options don't use this default of "1" */
my_free(*((char**) value));
- if (!(*((char**) value)= my_strdup(argument, MYF(MY_WME))))
+ if (!(*((char**) value)= my_strdup(argument == enabled_my_option ? "" :
+ argument, MYF(MY_WME))))
{
res= EXIT_OUT_OF_MEMORY;
goto ret;
diff --git a/mysys/my_sync.c b/mysys/my_sync.c
index 3853d30632e..88bcb685271 100644
--- a/mysys/my_sync.c
+++ b/mysys/my_sync.c
@@ -49,6 +49,13 @@ void thr_set_sync_wait_callback(void (*before_wait)(void),
(which is correct behaviour, if we know that the other thread synced the
file before closing)
+ MY_SYNC_FILESIZE is useful when syncing a file after it has been extended.
+ On Linux, fdatasync() on ext3/ext4 file systems does not properly flush
+ to disk the inode data required to preserve the added data across a crash
+ (this looks to be a bug). But when a file is extended, inode data will most
+ likely need flushing in any case, so passing MY_SYNC_FILESIZE as flags
+ is not likely to be any slower, and will be crash safe on Linux ext3/ext4.
+
RETURN
0 ok
-1 error
@@ -84,8 +91,12 @@ int my_sync(File fd, myf my_flags)
DBUG_PRINT("info",("fcntl(F_FULLFSYNC) failed, falling back"));
#endif
#if defined(HAVE_FDATASYNC) && HAVE_DECL_FDATASYNC
- res= fdatasync(fd);
-#elif defined(HAVE_FSYNC)
+ if (!(my_flags & MY_SYNC_FILESIZE))
+ res= fdatasync(fd);
+ else
+ {
+#endif
+#if defined(HAVE_FSYNC)
res= fsync(fd);
if (res == -1 && errno == ENOLCK)
res= 0; /* Result Bug in Old FreeBSD */
@@ -95,6 +106,9 @@ int my_sync(File fd, myf my_flags)
#error Cannot find a way to sync a file, durability in danger
res= 0; /* No sync (strange OS) */
#endif
+#if defined(HAVE_FDATASYNC) && HAVE_DECL_FDATASYNC
+ }
+#endif
} while (res == -1 && errno == EINTR);
if (res)
diff --git a/scripts/mytop.sh b/scripts/mytop.sh
index a36fddf7368..f0456498da7 100755
--- a/scripts/mytop.sh
+++ b/scripts/mytop.sh
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
#
-# $Id: mytop,v 1.90 2010/05/23 10:51:21 mark Exp $
+# $Id: mytop,v 1.91 2012/01/18 16:49:12 mgrennan Exp $
=pod
@@ -15,12 +15,13 @@ mytop - display MySQL server performance info like `top'
use 5.005;
use strict;
use DBI;
+use DBD::mysql;
use Getopt::Long;
use Socket;
use List::Util qw(min max);
use File::Basename;
-$main::VERSION = "1.9a";
+$main::VERSION = "1.91a";
my $path_for_script= dirname($0);
$|=1;
@@ -96,7 +97,7 @@ my %config = (
resolve => 0,
slow => 10, # slow query time
socket => '',
- sort => 0, # default or reverse sort ("s")
+ sort => 1, # default or reverse sort ("s")
user => 'root',
fullqueries => 0
);
@@ -378,12 +379,11 @@ while (1)
## keystroke command processing (if we get this far)
##
- # ! - Force past a replication error
-
- if ($key eq 'r')
+ if ($key eq '!')
{
- Execute("STOP SLAVE; SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; START SLAVE;");
- next;
+ Execute("stop slave");
+ Execute("set global sql_slave_skip_counter=1");
+ Execute("start slave");
}
# t - top
@@ -415,7 +415,7 @@ while (1)
next;
}
- ## m - mode swtich to qps
+ ## m - mode switch to qps
if ($key eq 'm')
{
@@ -425,17 +425,7 @@ while (1)
next;
}
- ## M - mode swtich to qps
-
- if ($key eq 'M')
- {
- $config{mode} = 'status';
- Clear() unless $config{batchmode};
- print "Queries Per Second [hit q to exit this mode]\n";
- next;
- }
-
- ## c - mode swtich to command summary
+ ## c - mode switch to command summary
if ($key eq 'c')
{
@@ -467,8 +457,6 @@ while (1)
next;
}
- # Change the SLOW query value
-
if ($key eq 'S')
{
cmd_S();
@@ -755,7 +743,9 @@ while (1)
ReadKey(0);
}
- if ($key eq 'S')
+ # Switch to show status mode
+
+ if ($key eq 'M')
{
$config{mode} = 'status';
}
@@ -931,6 +921,11 @@ sub GetData()
}
}
+ open L, "</proc/loadavg";
+ my $l = <L>;
+ close L;
+ chomp $l;
+
$last_time = $now_time;
## Server Uptime in meaningful terms...
@@ -962,6 +957,7 @@ sub GetData()
printf "%-.${host_width}s %${up_width}s\n",
"$server on $config{host} ($db_version)",
"up $uptime $current_time";
+# "load $l up $uptime $current_time";
$lines_left--;
@@ -1055,19 +1051,29 @@ sub GetData()
if ($t_delta)
{
+ my $rows_read;
+ if (defined($STATUS{Rows_read}))
+ {
+ $rows_read= $STATUS{Rows_read} - $OLD_STATUS{Rows_read};
+ }
+ else
+ {
+ $rows_read=
+ ($STATUS{Handler_read_first}+$STATUS{Handler_read_key}+
+ $STATUS{Handler_read_next}+$STATUS{Handler_read_prev}+
+ $STATUS{Handler_read_rnd}+$STATUS{Handler_read_rnd_next} -
+ $OLD_STATUS{Handler_read_first}-$OLD_STATUS{Handler_read_key}-
+ $OLD_STATUS{Handler_read_next}-$OLD_STATUS{Handler_read_prev}-
+ $OLD_STATUS{Handler_read_rnd}-
+ $OLD_STATUS{Handler_read_rnd_next});
+ }
printf(" Handler: (R/W/U/D) %5d/%5d/%5d/%5d Tmp: R/W/U: %5d/%5d/%5d\n",
- ($STATUS{Handler_read_first}+$STATUS{Handler_read_key}+
- $STATUS{Handler_read_next}+$STATUS{Handler_read_prev}+
- $STATUS{Handler_read_rnd}+$STATUS{Handler_read_rnd_next} -
- $OLD_STATUS{Handler_read_first}-$OLD_STATUS{Handler_read_key}-
- $OLD_STATUS{Handler_read_next}-$OLD_STATUS{Handler_read_prev}-
- $OLD_STATUS{Handler_read_rnd}-
- $OLD_STATUS{Handler_read_rnd_next})/$t_delta,
+ $rows_read/$t_delta,
($STATUS{Handler_write} - $OLD_STATUS{Handler_write}) /
$t_delta,
($STATUS{Handler_update} - $OLD_STATUS{Handler_update}) /
$t_delta,
- ($STATUS{Handler_delete} - $OLD_STATUS{Handler_delete}) /
+ ($STATUS{Handler_delete} - $OLD_STATUS{Handler_delete}) /
$t_delta,
($STATUS{Rows_tmp_read} - $OLD_STATUS{Rows_tmp_read}) /
$t_delta,
@@ -1083,7 +1089,7 @@ sub GetData()
$lines_left--;
- printf(" MyISAM Key Efficiency: %2.1f%% Bps in/out: %5s/%5s ",
+ printf(" ISAM Key Efficiency: %2.1f%% Bps in/out: %5s/%5s ",
$cache_hits_percent,
make_short($STATUS{Bytes_received} / $STATUS{Uptime} ),
make_short($STATUS{Bytes_sent} / $STATUS{Uptime}));
@@ -1095,35 +1101,40 @@ sub GetData()
$lines_left--;
- my($data) = Hashes('SHOW SLAVE STATUS');
- if (defined($data->{Master_Host}))
+ my($data) = Hashes('show global variables like "read_only"');
+ if ($data->{Value} ne "OFF")
{
- print " Replication ";
- if ($HAS_COLOR) {
- print GREEN();
- print RED() if ($data->{Slave_IO_Running} ne "Yes") ;
- }
- print "IO:$data->{Slave_IO_Running} ";
+ print RED() if ($HAS_COLOR) ;
+ print " ReadOnly";
RESET() if ($HAS_COLOR);
+ }
- if ($HAS_COLOR) {
- print GREEN();
- print RED() if ($data->{Slave_SQL_Running} ne "Yes") ;
+ ($data) = Hashes('SHOW SLAVE STATUS');
+ if (defined($data->{Master_Host}))
+ {
+ if (defined($data->{Seconds_Behind_Master}))
+ {
+ if ($HAS_COLOR) {
+ print GREEN();
+ print YELLOW() if ($data->{Seconds_Behind_Master} > 60);
+ print MAGENTA() if ($data->{Seconds_Behind_Master} > 360);
+ }
}
+ print " Replication ";
+ print "IO:$data->{Slave_IO_Running} ";
print "SQL:$data->{Slave_SQL_Running} ";
print RESET() if ($HAS_COLOR);
- my $SlaveDelay = $data->{Seconds_Behind_Master};
- if ($SlaveDelay)
+ if (defined($data->{Seconds_Behind_Master}))
{
if ($HAS_COLOR) {
print GREEN();
- print YELLOW() if ($SlaveDelay > 10);
- print MAGENTA() if ($SlaveDelay > 120);
+ print YELLOW() if ($data->{Seconds_Behind_Master} > 60);
+ print MAGENTA() if ($data->{Seconds_Behind_Master} > 360);
}
- print "Delay: $SlaveDelay sec.";
+ print "Delay: $data->{Seconds_Behind_Master} sec.";
} else {
- my $free = $width - 35;
+ my $free = $width - 45;
my $Err = substr $data->{Last_Error},0 ,$free;
printf(" ERR: %-${free}s", $Err) if ( $Err ne "" );
}
@@ -1198,6 +1209,7 @@ sub GetData()
if ($is_ip and $config{resolve})
{
$thread->{Host} =~ s/:\d+$//;
+# my $host = $thread->{Host};
my $host = gethostbyaddr(inet_aton($thread->{Host}), AF_INET);
# $host =~ s/^([^.]+).*/$1/;
$thread->{Host} = $host;
@@ -1483,7 +1495,7 @@ sub GetShowStatus()
Clear() unless $config{batchmode};
my @rows = Hashes("SHOW STATUS");
- printf "%32s %10s %10s\n", 'Counter', 'Total', 'Change';
+ printf "%32s %10s %10s Toggle idle with 'i'\n", 'Counter', 'Total', 'Change';
printf "%32s %10s %10s\n", '-------', '-----', '------';
for my $row (@rows)
@@ -1519,9 +1531,7 @@ sub GetShowStatus()
}
}
- if ($delta != 0) {
- printf "%32s: %10s %10s\n", $name, $value, $delta;
- }
+ printf "%32s: %10s %10s\n", $name, $value, $delta;
print RESET() if $HAS_COLOR;
$statcache{$name} = $value;
@@ -1703,12 +1713,11 @@ sub trim($)
sub PrintHelp()
{
my $help = qq[
-Help for mytop version $main::VERSION by Mark Grennan <${YELLOW}Mark\@Grennan.com${RESET}>
-Origional work by Jeremy D. Zawodny <${YELLOW}Jeremy\@Zawodny.com${RESET}>
+Help for mytop version $main::VERSION by Jeremy D. Zawodny <${YELLOW}Jeremy\@Zawodny.com${RESET}>
+ with updates by Mark Grennan <${YELLOW}mark\@grennan.com${RESET}>
? - display this screen
# - toggle short/long numbers (not yet implemented)
- ! - force past replication error
c - command summary view (based on Com_* counters)
C - turn color on and off
d - show only a specific database
@@ -1733,8 +1742,9 @@ Origional work by Jeremy D. Zawodny <${YELLOW}Jeremy\@Zawodny.com${RESET}>
S - change slow quiery hightlighting
t - switch to thread view (default)
u - show only a specific user
- V - show variablesi
+ V - show variables
: - enter a command (not yet implemented)
+ ! - Skip an error that has stopped replications (at your own risk)
L - show full queries (do not strip to terminal width)
Base version from ${GREEN}http://www.mysqlfanboy.com/mytop${RESET}
@@ -2317,11 +2327,8 @@ having the User column appear, for example.
mytop was developed and is maintained by Jeremy D. Zawodny
(Jeremy@Zawodny.com).
-(Mark Grennan) After weeks and months of trying to get Jeremy's
-attention I desided to release my own update to mytop. I use it
-every day as a part of my job. Thanks Jeremy for creating mytop.
-I hope you find my updates as helpful as I have. I can be
-reached at (Mark@Grennan.com).
+If you wish to e-mail me regarding this software, B<PLEASE> subscribe
+to the B<mytop> mailing list. See the B<mytop> homepage for details.
=head1 DISCLAIMER
@@ -2330,12 +2337,6 @@ for it. Yahoo! does not necessarily support this software in any
way. It is merely a personal idea which happened to be very useful in
my job.
-=head1 RECRUITING
-
-If you hack Perl and grok MySQL, come work at Yahoo! Contact me for
-details. Or just send me your resume. Er, unless we just had layoffs,
-in which case we're not hiring. :-(
-
=head1 SEE ALSO
Please check the MySQL manual if you're not sure where some of the
@@ -2344,7 +2345,6 @@ output of B<mytop> is coming from.
=head1 COPYRIGHT
Copyright (C) 2000-2010, Jeremy D. Zawodny.
-Copyright (C) 2010, Mark T. Grennan.
=head1 CREDITS
@@ -2358,6 +2358,15 @@ Many thanks go to these fine folks:
Added --fullqueries and reading of .my.cnf
+=item Mark Grennan (mark@grennan.com) www.linuxfangoy.com
+
+Added updates for MySQL 5.x. Added 'S' (slow) highlighting.
+Added 'C' to turn on and off Color. Added 'l' command to change
+color for long running queries. Fixed a few documentation issues.
+Monitors Slave status. Added color to Queue hit ratio.
+Added number of rows sorted per second.
+Created release 1.7.
+
=item Sami Ahlroos (sami@avis-net.de)
Suggested the idle/noidle stuff.
diff --git a/sql/derror.cc b/sql/derror.cc
index baf7163790d..33835992258 100644
--- a/sql/derror.cc
+++ b/sql/derror.cc
@@ -177,8 +177,8 @@ bool read_texts(const char *file_name, const char *language,
O_RDONLY | O_SHARE | O_BINARY,
MYF(0))) < 0)
goto err;
- sql_print_error("An old style --language value with language specific part detected: %s", lc_messages_dir);
- sql_print_error("Use --lc-messages-dir without language specific part instead.");
+ sql_print_warning("An old style --language or -lc-message-dir value with language specific part detected: %s", lc_messages_dir);
+ sql_print_warning("Use --lc-messages-dir without language specific part instead.");
}
funktpos=1;
diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc
index 55a3f6b36c4..b41c9e2cda0 100644
--- a/sql/event_scheduler.cc
+++ b/sql/event_scheduler.cc
@@ -42,7 +42,7 @@
cond_wait(mythd, abstime, msg, SCHED_FUNC, __LINE__)
extern pthread_attr_t connection_attrib;
-
+extern ulong event_executed;
Event_db_repository *Event_worker_thread::db_repository;
@@ -557,7 +557,8 @@ Event_scheduler::execute_top(Event_queue_element_for_exec *event_name)
event_name)))
goto error;
- ++started_events;
+ started_events++;
+ executed_events++; // For SHOW STATUS
DBUG_PRINT("info", ("Event is in THD: 0x%lx", (long) new_thd));
DBUG_RETURN(FALSE);
diff --git a/sql/field.cc b/sql/field.cc
index f20d9ba87fc..a3d3d951887 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -5677,7 +5677,7 @@ bool Field_newdate::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate)
if (!tmp)
return fuzzydate & TIME_NO_ZERO_DATE;
if (!ltime->month || !ltime->day)
- return !(fuzzydate & TIME_FUZZY_DATE);
+ return fuzzydate & TIME_NO_ZERO_IN_DATE;
return 0;
}
@@ -9395,9 +9395,12 @@ Field *make_field(TABLE_SHARE *share, uchar *ptr, uint32 field_length,
#ifdef HAVE_SPATIAL
if (f_is_geom(pack_flag))
+ {
+ status_var_increment(current_thd->status_var.feature_gis);
return new Field_geom(ptr,null_pos,null_bit,
unireg_check, field_name, share,
pack_length, geom_type);
+ }
#endif
if (f_is_blob(pack_flag))
return new Field_blob(ptr,null_pos,null_bit,
diff --git a/sql/handler.cc b/sql/handler.cc
index 58d37532796..b06aa4255fd 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -2502,6 +2502,8 @@ int handler::update_auto_increment()
bool append= FALSE;
THD *thd= table->in_use;
struct system_variables *variables= &thd->variables;
+ int result=0, tmp;
+ enum enum_check_fields save_count_cuted_fields;
DBUG_ENTER("handler::update_auto_increment");
/*
@@ -2519,8 +2521,10 @@ int handler::update_auto_increment()
statement (case of INSERT VALUES(null),(3763),(null):
the last NULL needs to insert 3764, not the value of the first NULL plus
1).
+ Ignore negative values.
*/
- adjust_next_insert_id_after_explicit_value(nr);
+ if ((longlong) nr > 0 || (table->next_number_field->flags & UNSIGNED_FLAG))
+ adjust_next_insert_id_after_explicit_value(nr);
insert_id_for_cur_row= 0; // didn't generate anything
DBUG_RETURN(0);
}
@@ -2579,7 +2583,6 @@ int handler::update_auto_increment()
else
nb_desired_values= AUTO_INC_DEFAULT_NB_MAX;
}
- /* This call ignores all its parameters but nr, currently */
get_auto_increment(variables->auto_increment_offset,
variables->auto_increment_increment,
nb_desired_values, &nr,
@@ -2616,29 +2619,23 @@ int handler::update_auto_increment()
}
if (unlikely(nr == ULONGLONG_MAX))
- DBUG_RETURN(HA_ERR_AUTOINC_ERANGE);
+ DBUG_RETURN(HA_ERR_AUTOINC_ERANGE);
DBUG_PRINT("info",("auto_increment: %lu", (ulong) nr));
- if (unlikely(table->next_number_field->store((longlong) nr, TRUE)))
- {
- /*
- first test if the query was aborted due to strict mode constraints
- */
- if (killed_mask_hard(thd->killed) == KILL_BAD_DATA)
- DBUG_RETURN(HA_ERR_AUTOINC_ERANGE);
+ /* Store field without warning (Warning will be printed by insert) */
+ save_count_cuted_fields= thd->count_cuted_fields;
+ thd->count_cuted_fields= CHECK_FIELD_IGNORE;
+ tmp= table->next_number_field->store((longlong) nr, TRUE);
+ thd->count_cuted_fields= save_count_cuted_fields;
+ if (unlikely(tmp)) // Out of range value in store
+ {
/*
- field refused this value (overflow) and truncated it, use the result of
- the truncation (which is going to be inserted); however we try to
- decrease it to honour auto_increment_* variables.
- That will shift the left bound of the reserved interval, we don't
- bother shifting the right bound (anyway any other value from this
- interval will cause a duplicate key).
+ It's better to return an error here than getting a confusing
+ 'duplicate key error' later.
*/
- nr= prev_insert_id(table->next_number_field->val_int(), variables);
- if (unlikely(table->next_number_field->store((longlong) nr, TRUE)))
- nr= table->next_number_field->val_int();
+ result= HA_ERR_AUTOINC_ERANGE;
}
if (append)
{
@@ -2660,6 +2657,10 @@ int handler::update_auto_increment()
already set.
*/
insert_id_for_cur_row= nr;
+
+ if (result) // overflow
+ DBUG_RETURN(result);
+
/*
Set next insert id to point to next auto-increment value to be able to
handle multi-row statements.
@@ -2783,7 +2784,7 @@ void handler::ha_release_auto_increment()
}
-void handler::print_keydup_error(uint key_nr, const char *msg)
+void handler::print_keydup_error(uint key_nr, const char *msg, myf errflag)
{
/* Write the duplicated key in the error message */
char key[MAX_KEY_LENGTH];
@@ -2793,7 +2794,7 @@ void handler::print_keydup_error(uint key_nr, const char *msg)
{
/* Key is unknown */
str.copy("", 0, system_charset_info);
- my_printf_error(ER_DUP_ENTRY, msg, MYF(0), str.c_ptr(), "*UNKNOWN*");
+ my_printf_error(ER_DUP_ENTRY, msg, errflag, str.c_ptr(), "*UNKNOWN*");
}
else
{
@@ -2806,7 +2807,7 @@ void handler::print_keydup_error(uint key_nr, const char *msg)
str.append(STRING_WITH_LEN("..."));
}
my_printf_error(ER_DUP_ENTRY, msg,
- MYF(0), str.c_ptr_safe(), table->key_info[key_nr].name);
+ errflag, str.c_ptr_safe(), table->key_info[key_nr].name);
}
}
@@ -2874,7 +2875,7 @@ void handler::print_error(int error, myf errflag)
uint key_nr=get_dup_key(error);
if ((int) key_nr >= 0)
{
- print_keydup_error(key_nr, ER(ER_DUP_ENTRY_WITH_KEY_NAME));
+ print_keydup_error(key_nr, ER(ER_DUP_ENTRY_WITH_KEY_NAME), errflag);
DBUG_VOID_RETURN;
}
}
@@ -3037,7 +3038,10 @@ void handler::print_error(int error, myf errflag)
textno= ER_AUTOINC_READ_FAILED;
break;
case HA_ERR_AUTOINC_ERANGE:
- textno= ER_WARN_DATA_OUT_OF_RANGE;
+ textno= error;
+ my_error(textno, errflag, table->next_number_field->field_name,
+ table->in_use->warning_info->current_row_for_warning());
+ DBUG_VOID_RETURN;
break;
case HA_ERR_TOO_MANY_CONCURRENT_TRXS:
textno= ER_TOO_MANY_CONCURRENT_TRXS;
diff --git a/sql/handler.h b/sql/handler.h
index 9c0850e157a..4a6fc2f1bd5 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -1957,7 +1957,7 @@ public:
void adjust_next_insert_id_after_explicit_value(ulonglong nr);
int update_auto_increment();
- void print_keydup_error(uint key_nr, const char *msg);
+ void print_keydup_error(uint key_nr, const char *msg, myf errflag);
virtual void print_error(int error, myf errflag);
virtual bool get_error_message(int error, String *buf);
uint get_dup_key(int error);
@@ -2006,7 +2006,8 @@ public:
if (!error ||
((flags & HA_CHECK_DUP_KEY) &&
(error == HA_ERR_FOUND_DUPP_KEY ||
- error == HA_ERR_FOUND_DUPP_UNIQUE)))
+ error == HA_ERR_FOUND_DUPP_UNIQUE)) ||
+ error == HA_ERR_AUTOINC_ERANGE)
return FALSE;
return TRUE;
}
diff --git a/sql/item.cc b/sql/item.cc
index ac54e1925b7..4d80a153785 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -503,8 +503,8 @@ Item::Item(THD *thd, Item *item):
orig_name(item->orig_name),
max_length(item->max_length),
name_length(item->name_length),
- marker(item->marker),
decimals(item->decimals),
+ marker(item->marker),
maybe_null(item->maybe_null),
in_rollup(item->in_rollup),
null_value(item->null_value),
@@ -7759,6 +7759,13 @@ Item* Item_cache_wrapper::get_tmp_table_item(THD *thd_arg)
}
+bool Item_direct_view_ref::send(Protocol *protocol, String *buffer)
+{
+ if (check_null_ref())
+ return protocol->store_null();
+ return Item_direct_ref::send(protocol, buffer);
+}
+
/**
Prepare referenced field then call usual Item_direct_ref::fix_fields .
@@ -7773,6 +7780,7 @@ Item* Item_cache_wrapper::get_tmp_table_item(THD *thd_arg)
bool Item_direct_view_ref::fix_fields(THD *thd, Item **reference)
{
+ DBUG_ASSERT(1);
/* view fild reference must be defined */
DBUG_ASSERT(*ref);
/* (*ref)->check_cols() will be made in Item_direct_ref::fix_fields */
@@ -9285,7 +9293,7 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
item->max_length, item->decimals));
fld_type= Field::field_type_merge(fld_type, get_real_type(item));
{
- int item_decimals= item->decimals;
+ uint item_decimals= item->decimals;
/* fix variable decimals which always is NOT_FIXED_DEC */
if (Field::result_merge_type(fld_type) == INT_RESULT)
item_decimals= 0;
diff --git a/sql/item.h b/sql/item.h
index 8855996b76c..3136bb00394 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -618,8 +618,8 @@ public:
calls.
*/
uint name_length; /* Length of name */
+ uint decimals;
int8 marker;
- uint8 decimals;
bool maybe_null; /* If item may be null */
bool in_rollup; /* If used in GROUP BY list
of a query with ROLLUP */
@@ -3161,20 +3161,29 @@ class Item_direct_view_ref :public Item_direct_ref
{
Item_equal *item_equal;
TABLE_LIST *view;
+ TABLE *null_ref_table;
+
+ bool check_null_ref()
+ {
+ if (null_ref_table == NULL)
+ {
+ null_ref_table= view->get_real_join_table();
+ }
+ if (null_ref_table->null_row)
+ {
+ null_value= 1;
+ return TRUE;
+ }
+ return FALSE;
+ }
public:
Item_direct_view_ref(Name_resolution_context *context_arg, Item **item,
const char *table_name_arg,
const char *field_name_arg,
TABLE_LIST *view_arg)
:Item_direct_ref(context_arg, item, table_name_arg, field_name_arg),
- item_equal(0), view(view_arg) {}
- /* Constructor need to process subselect with temporary tables (see Item) */
- Item_direct_view_ref(THD *thd, Item_direct_ref *item)
- :Item_direct_ref(thd, item), item_equal(0) {}
- Item_direct_view_ref(TABLE_LIST *view_arg, Item **item,
- const char *field_name_arg)
- :Item_direct_ref(view_arg, item, field_name_arg), item_equal(0)
- {}
+ item_equal(0), view(view_arg),
+ null_ref_table(NULL) {}
bool fix_fields(THD *, Item **);
bool eq(const Item *item, bool binary_cmp) const;
@@ -3205,6 +3214,85 @@ public:
view_arg->view_used_tables|= (*ref)->used_tables();
return 0;
}
+ void save_val(Field *to)
+ {
+ if (check_null_ref())
+ to->set_null();
+ else
+ Item_direct_ref::save_val(to);
+ }
+ double val_real()
+ {
+ if (check_null_ref())
+ return 0;
+ else
+ return Item_direct_ref::val_real();
+ }
+ longlong val_int()
+ {
+ if (check_null_ref())
+ return 0;
+ else
+ return Item_direct_ref::val_int();
+ }
+ String *val_str(String* tmp)
+ {
+ if (check_null_ref())
+ return NULL;
+ else
+ return Item_direct_ref::val_str(tmp);
+ }
+ my_decimal *val_decimal(my_decimal *tmp)
+ {
+ if (check_null_ref())
+ return NULL;
+ else
+ return Item_direct_ref::val_decimal(tmp);
+ }
+ bool val_bool()
+ {
+ if (check_null_ref())
+ return 0;
+ else
+ return Item_direct_ref::val_bool();
+ }
+ bool is_null()
+ {
+ if (check_null_ref())
+ return 1;
+ else
+ return Item_direct_ref::is_null();
+ }
+ bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate)
+ {
+ if (check_null_ref())
+ {
+ bzero((char*) ltime,sizeof(*ltime));
+ return 1;
+ }
+ return Item_direct_ref::get_date(ltime, fuzzydate);
+ }
+ bool send(Protocol *protocol, String *buffer);
+ void save_org_in_field(Field *field)
+ {
+ if (check_null_ref())
+ field->set_null();
+ else
+ Item_direct_ref::save_val(field);
+ }
+ void save_in_result_field(bool no_conversions)
+ {
+ if (check_null_ref())
+ result_field->set_null();
+ else
+ Item_direct_ref::save_in_result_field(no_conversions);
+ }
+
+ void cleanup()
+ {
+ null_ref_table= NULL;
+ Item_direct_ref::cleanup();
+ }
};
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 7a7cdd4ba02..441eb37d701 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -6046,6 +6046,8 @@ bool Item_func_match::fix_fields(THD *thd, Item **ref)
DBUG_ASSERT(fixed == 0);
Item *UNINIT_VAR(item); // Safe as arg_count is > 1
+ status_var_increment(thd->status_var.feature_fulltext);
+
maybe_null=1;
join_key=0;
@@ -6816,3 +6818,62 @@ longlong Item_func_uuid_short::val_int()
mysql_mutex_unlock(&LOCK_short_uuid_generator);
return (longlong) val;
}
+
+
+/**
+ Last_value - return last argument.
+*/
+
+void Item_func_last_value::evaluate_sideeffects()
+{
+ DBUG_ASSERT(fixed == 1 && arg_count > 0);
+ for (uint i= 0; i < arg_count-1 ; i++)
+ args[i]->val_int();
+}
+
+String *Item_func_last_value::val_str(String *str)
+{
+ String *tmp;
+ evaluate_sideeffects();
+ tmp= last_value->val_str(str);
+ null_value= last_value->null_value;
+ return tmp;
+}
+
+longlong Item_func_last_value::val_int()
+{
+ longlong tmp;
+ evaluate_sideeffects();
+ tmp= last_value->val_int();
+ null_value= last_value->null_value;
+ return tmp;
+}
+
+double Item_func_last_value::val_real()
+{
+ double tmp;
+ evaluate_sideeffects();
+ tmp= last_value->val_real();
+ null_value= last_value->null_value;
+ return tmp;
+}
+
+my_decimal *Item_func_last_value::val_decimal(my_decimal *decimal_value)
+{
+ my_decimal *tmp;
+ evaluate_sideeffects();
+ tmp= last_value->val_decimal(decimal_value);
+ null_value= last_value->null_value;
+ return tmp;
+}
+
+
+void Item_func_last_value::fix_length_and_dec()
+{
+ last_value= args[arg_count -1];
+ decimals= last_value->decimals;
+ max_length= last_value->max_length;
+ collation.set(last_value->collation.collation);
+ maybe_null= last_value->maybe_null;
+ unsigned_flag= last_value->unsigned_flag;
+}
diff --git a/sql/item_func.h b/sql/item_func.h
index 111479c8e52..586444e0e4e 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -2003,6 +2003,27 @@ public:
}
};
+
+class Item_func_last_value :public Item_func
+{
+protected:
+ Item *last_value;
+public:
+ Item_func_last_value(List<Item> &list) :Item_func(list) {}
+ double val_real();
+ longlong val_int();
+ String *val_str(String *);
+ my_decimal *val_decimal(my_decimal *);
+ void fix_length_and_dec();
+ enum Item_result result_type () const { return last_value->result_type(); }
+ const char *func_name() const { return "last_value"; }
+ table_map not_null_tables() const { return 0; }
+ enum_field_types field_type() const { return last_value->field_type(); }
+ bool const_item() const { return 0; }
+ void evaluate_sideeffects();
+};
+
+
Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name,
LEX_STRING component);
extern bool check_reserved_words(LEX_STRING *name);
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index 3648b10af3f..bc89a6c14b3 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -1695,7 +1695,8 @@ count_distance:
for (dist_point= collector.get_first(); dist_point; dist_point= dist_point->get_next())
{
/* We only check vertices of object 2 */
- if (dist_point->shape < obj2_si)
+ if (dist_point->type != Gcalc_heap::nt_shape_node ||
+ dist_point->shape < obj2_si)
continue;
/* if we have an edge to check */
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index c5d1edbe475..ebfca684ccb 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -3774,6 +3774,7 @@ bool Item_func_dyncol_create::fix_fields(THD *thd, Item **ref)
(arg_count / 2));
nums= (uint *) alloc_root(thd->mem_root,
sizeof(uint) * (arg_count / 2));
+ status_var_increment(thd->status_var.feature_dynamic_columns);
return res || vals == 0 || nums == 0;
}
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index c10b75c154b..efc058763c0 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -220,6 +220,8 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref)
uint8 uncacheable;
bool res;
+ status_var_increment(thd->status_var.feature_subquery);
+
DBUG_ASSERT(fixed == 0);
engine->set_thd((thd= thd_param));
if (!done_first_fix_fields)
@@ -733,6 +735,19 @@ bool Item_subselect::expr_cache_is_needed(THD *thd)
/**
+ Check if the left IN argument contains NULL values.
+
+ @retval TRUE there are NULLs
+ @retval FALSE otherwise
+*/
+
+inline bool Item_in_subselect::left_expr_has_null()
+{
+ return (*(optimizer->get_cache()))->null_value;
+}
+
+
+/**
Check if an expression cache is needed for this subquery
@param thd Thread handle
@@ -3283,161 +3298,51 @@ int subselect_uniquesubquery_engine::scan_table()
}
-/*
- Copy ref key and check for null parts in it
-
- SYNOPSIS
- subselect_uniquesubquery_engine::copy_ref_key()
-
- DESCRIPTION
- Copy ref key and check for null parts in it.
- Depending on the nullability and conversion problems this function
- recognizes and processes the following states :
- 1. Partial match on top level. This means IN has a value of FALSE
- regardless of the data in the subquery table.
- Detected by finding a NULL in the left IN operand of a top level
- expression.
- We may actually skip reading the subquery, so return TRUE to skip
- the table scan in subselect_uniquesubquery_engine::exec and make
- the value of the IN predicate a NULL (that is equal to FALSE on
- top level).
- 2. No exact match when IN is nested inside another predicate.
- Detected by finding a NULL in the left IN operand when IN is not
- a top level predicate.
- We cannot have an exact match. But we must proceed further with a
- table scan to find out if it's a partial match (and IN has a value
- of NULL) or no match (and IN has a value of FALSE).
- So we return FALSE to continue with the scan and see if there are
- any record that would constitute a partial match (as we cannot
- determine that from the index).
- 3. Error converting the left IN operand to the column type of the
- right IN operand. This counts as no match (and IN has the value of
- FALSE). We mark the subquery table cursor as having no more rows
- (to ensure that the processing that follows will not find a match)
- and return FALSE, so IN is not treated as returning NULL.
+/**
+ Copy ref key for index access into the only subquery table.
+ @details
+ Copy ref key and check for conversion problems.
+ If there is an error converting the left IN operand to the column type of
+ the right IN operand count it as no match. In this case IN has the value of
+ FALSE. We mark the subquery table cursor as having no more rows (to ensure
+ that the processing that follows will not find a match) and return FALSE,
+ so IN is not treated as returning NULL.
- RETURN
- FALSE - The value of the IN predicate is not known. Proceed to find the
- value of the IN predicate using the determined values of
- null_keypart and table->status.
- TRUE - IN predicate has a value of NULL. Stop the processing right there
- and return NULL to the outer predicates.
+ @returns
+ @retval FALSE The outer ref was copied into an index lookup key.
+ @retval TRUE The outer ref cannot possibly match any row, IN is FALSE.
*/
-bool subselect_uniquesubquery_engine::copy_ref_key()
+bool subselect_uniquesubquery_engine::copy_ref_key(bool skip_constants)
{
DBUG_ENTER("subselect_uniquesubquery_engine::copy_ref_key");
for (store_key **copy= tab->ref.key_copy ; *copy ; copy++)
{
- if ((*copy)->store_key_is_const())
- continue;
- tab->ref.key_err= (*copy)->copy();
-
- /*
- When there is a NULL part in the key we don't need to make index
- lookup for such key thus we don't need to copy whole key.
- If we later should do a sequential scan return OK. Fail otherwise.
-
- See also the comment for the subselect_uniquesubquery_engine::exec()
- function.
- */
- null_keypart= (*copy)->null_key;
- if (null_keypart)
- {
- bool top_level= ((Item_in_subselect *) item)->is_top_level_item();
- if (top_level)
- {
- /* Partial match on top level */
- DBUG_RETURN(1);
- }
- else
- {
- /* No exact match when IN is nested inside another predicate */
- break;
- }
- }
-
- /*
- Check if the error is equal to STORE_KEY_FATAL. This is not expressed
- using the store_key::store_key_result enum because ref.key_err is a
- boolean and we want to detect both TRUE and STORE_KEY_FATAL from the
- space of the union of the values of [TRUE, FALSE] and
- store_key::store_key_result.
- TODO: fix the variable an return types.
- */
- if (tab->ref.key_err & 1)
- {
- /*
- Error converting the left IN operand to the column type of the right
- IN operand.
- */
- tab->table->status= STATUS_NOT_FOUND;
- break;
- }
- }
- DBUG_RETURN(0);
-}
-
-
-/*
- @retval 1 A NULL was found in the outer reference, index lookup is
- not applicable, the outer ref is unsusable as a lookup key,
- use some other method to find a match.
- @retval 0 The outer ref was copied into an index lookup key.
- @retval -1 The outer ref cannot possibly match any row, IN is FALSE.
-*/
-/* TIMOUR: this method is a variant of copy_ref_key(), needs refactoring. */
-
-int subselect_uniquesubquery_engine::copy_ref_key_simple()
-{
- for (store_key **copy= tab->ref.key_copy ; *copy ; copy++)
- {
enum store_key::store_key_result store_res;
+ if (skip_constants && (*copy)->store_key_is_const())
+ continue;
store_res= (*copy)->copy();
tab->ref.key_err= store_res;
- /*
- When there is a NULL part in the key we don't need to make index
- lookup for such key thus we don't need to copy whole key.
- If we later should do a sequential scan return OK. Fail otherwise.
-
- See also the comment for the subselect_uniquesubquery_engine::exec()
- function.
- */
- null_keypart= (*copy)->null_key;
- if (null_keypart)
- return 1;
-
- /*
- Check if the error is equal to STORE_KEY_FATAL. This is not expressed
- using the store_key::store_key_result enum because ref.key_err is a
- boolean and we want to detect both TRUE and STORE_KEY_FATAL from the
- space of the union of the values of [TRUE, FALSE] and
- store_key::store_key_result.
- TODO: fix the variable an return types.
- */
if (store_res == store_key::STORE_KEY_FATAL)
{
/*
Error converting the left IN operand to the column type of the right
IN operand.
*/
- return -1;
+ DBUG_RETURN(true);
}
}
- return 0;
+ DBUG_RETURN(false);
}
-/*
- Execute subselect
-
- SYNOPSIS
- subselect_uniquesubquery_engine::exec()
+/**
+ Execute subselect via unique index lookup
- DESCRIPTION
+ @details
Find rows corresponding to the ref key using index access.
If some part of the lookup key is NULL, then we're evaluating
NULL IN (SELECT ... )
@@ -3454,11 +3359,11 @@ int subselect_uniquesubquery_engine::copy_ref_key_simple()
The result of this function (info about whether a row was found) is
stored in this->empty_result_set.
- NOTE
- RETURN
- FALSE - ok
- TRUE - an error occured while scanning
+ @returns
+ @retval 0 OK
+ @retval 1 notify caller to call Item_subselect::reset(),
+ in most cases reset() sets the result to NULL
*/
int subselect_uniquesubquery_engine::exec()
@@ -3468,32 +3373,30 @@ int subselect_uniquesubquery_engine::exec()
TABLE *table= tab->table;
empty_result_set= TRUE;
table->status= 0;
+ Item_in_subselect *in_subs= (Item_in_subselect *) item;
+
+ if (!tab->preread_init_done && tab->preread_init())
+ DBUG_RETURN(1);
- /* TODO: change to use of 'full_scan' here? */
- if (copy_ref_key())
+ if (in_subs->left_expr_has_null())
{
/*
- TIMOUR: copy_ref_key() == 1 means NULL result, not error, why return 1?
- Check who reiles on this result.
+ The case when all values in left_expr are NULL is handled by
+ Item_in_optimizer::val_int().
*/
- DBUG_RETURN(1);
+ if (in_subs->is_top_level_item())
+ DBUG_RETURN(1); /* notify caller to call reset() and set NULL value. */
+ else
+ DBUG_RETURN(scan_table());
}
- if (table->status)
+
+ if (copy_ref_key(true))
{
- /*
- We know that there will be no rows even if we scan.
- Can be set in copy_ref_key.
- */
- ((Item_in_subselect *) item)->value= 0;
+ /* We know that there will be no rows even if we scan. */
+ in_subs->value= 0;
DBUG_RETURN(0);
}
- if (!tab->preread_init_done && tab->preread_init())
- DBUG_RETURN(1);
-
- if (null_keypart)
- DBUG_RETURN(scan_table());
-
if (!table->file->inited)
table->file->ha_index_init(tab->ref.key, 0);
error= table->file->ha_index_read_map(table->record[0],
@@ -3569,14 +3472,10 @@ subselect_uniquesubquery_engine::~subselect_uniquesubquery_engine()
}
-/*
- Index-lookup subselect 'engine' - run the subquery
-
- SYNOPSIS
- subselect_indexsubquery_engine:exec()
- full_scan
+/**
+ Execute subselect via unique index lookup
- DESCRIPTION
+ @details
The engine is used to resolve subqueries in form
oe IN (SELECT key FROM tbl WHERE subq_where)
@@ -3591,7 +3490,7 @@ subselect_uniquesubquery_engine::~subselect_uniquesubquery_engine()
row that satisfies subq_where. If found, return NULL, otherwise
return FALSE.
- TODO
+ @todo
The step #1 can be optimized further when the index has several key
parts. Consider a subquery:
@@ -3616,9 +3515,10 @@ subselect_uniquesubquery_engine::~subselect_uniquesubquery_engine()
cheaper. We can use index statistics to quickly check whether "ref" scan
will be cheaper than full table scan.
- RETURN
- 0
- 1
+ @returns
+ @retval 0 OK
+ @retval 1 notify caller to call Item_subselect::reset(),
+ in most cases reset() sets the result to NULL
*/
int subselect_indexsubquery_engine::exec()
@@ -3627,10 +3527,10 @@ int subselect_indexsubquery_engine::exec()
int error;
bool null_finding= 0;
TABLE *table= tab->table;
+ Item_in_subselect *in_subs= (Item_in_subselect *) item;
((Item_in_subselect *) item)->value= 0;
empty_result_set= TRUE;
- null_keypart= 0;
table->status= 0;
if (check_null)
@@ -3640,25 +3540,27 @@ int subselect_indexsubquery_engine::exec()
((Item_in_subselect *) item)->was_null= 0;
}
- /* Copy the ref key and check for nulls... */
- if (copy_ref_key())
+ if (!tab->preread_init_done && tab->preread_init())
DBUG_RETURN(1);
- if (table->status)
+ if (in_subs->left_expr_has_null())
{
- /*
- We know that there will be no rows even if we scan.
- Can be set in copy_ref_key.
+ /*
+ The case when all values in left_expr are NULL is handled by
+ Item_in_optimizer::val_int().
*/
- ((Item_in_subselect *) item)->value= 0;
- DBUG_RETURN(0);
+ if (in_subs->is_top_level_item())
+ DBUG_RETURN(1); /* notify caller to call reset() and set NULL value. */
+ else
+ DBUG_RETURN(scan_table());
}
- if (!tab->preread_init_done && tab->preread_init())
- DBUG_RETURN(1);
-
- if (null_keypart)
- DBUG_RETURN(scan_table());
+ if (copy_ref_key(true))
+ {
+ /* We know that there will be no rows even if we scan. */
+ in_subs->value= 0;
+ DBUG_RETURN(0);
+ }
if (!table->file->inited)
table->file->ha_index_init(tab->ref.key, 1);
@@ -5429,37 +5331,42 @@ subselect_partial_match_engine::subselect_partial_match_engine(
int subselect_partial_match_engine::exec()
{
Item_in_subselect *item_in= (Item_in_subselect *) item;
- int copy_res, lookup_res;
+ int lookup_res;
- /* Try to find a matching row by index lookup. */
- copy_res= lookup_engine->copy_ref_key_simple();
- if (copy_res == -1)
- {
- /* The result is FALSE based on the outer reference. */
- item_in->value= 0;
- item_in->null_value= 0;
- return 0;
- }
- else if (copy_res == 0)
+ DBUG_ASSERT(!(item_in->left_expr_has_null() &&
+ item_in->is_top_level_item()));
+
+ if (!item_in->left_expr_has_null())
{
- /* Search for a complete match. */
- if ((lookup_res= lookup_engine->index_lookup()))
+ /* Try to find a matching row by index lookup. */
+ if (lookup_engine->copy_ref_key(false))
{
- /* An error occured during lookup(). */
+ /* The result is FALSE based on the outer reference. */
item_in->value= 0;
item_in->null_value= 0;
- return lookup_res;
+ return 0;
}
- else if (item_in->value || !count_columns_with_nulls)
+ else
{
- /*
- A complete match was found, the result of IN is TRUE.
- If no match was found, and there are no NULLs in the materialized
- subquery, then the result is guaranteed to be false because this
- branch is executed when the outer reference has no NULLs as well.
- Notice: (this->item == lookup_engine->item)
- */
- return 0;
+ /* Search for a complete match. */
+ if ((lookup_res= lookup_engine->index_lookup()))
+ {
+ /* An error occured during lookup(). */
+ item_in->value= 0;
+ item_in->null_value= 0;
+ return lookup_res;
+ }
+ else if (item_in->value || !count_columns_with_nulls)
+ {
+ /*
+ A complete match was found, the result of IN is TRUE.
+ If no match was found, and there are no NULLs in the materialized
+ subquery, then the result is guaranteed to be false because this
+ branch is executed when the outer reference has no NULLs as well.
+ Notice: (this->item == lookup_engine->item)
+ */
+ return 0;
+ }
}
}
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index 05c4528490f..2a64c63a1be 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -591,6 +591,7 @@ public:
/* Inform 'this' that it was computed, and contains a valid result. */
void set_first_execution() { if (first_execution) first_execution= FALSE; }
bool expr_cache_is_needed(THD *thd);
+ inline bool left_expr_has_null();
int optimize(double *out_rows, double *cost);
/*
@@ -869,7 +870,6 @@ protected:
expression is NULL.
*/
bool empty_result_set;
- bool null_keypart; /* TRUE <=> constructed search tuple has a NULL */
public:
// constructor can assign THD because it will be called after JOIN::prepare
@@ -893,8 +893,7 @@ public:
bool no_tables();
int index_lookup(); /* TIMOUR: this method needs refactoring. */
int scan_table();
- bool copy_ref_key();
- int copy_ref_key_simple(); /* TIMOUR: this method needs refactoring. */
+ bool copy_ref_key(bool skip_constants);
bool no_rows() { return empty_result_set; }
virtual enum_engine_type engine_type() { return UNIQUESUBQUERY_ENGINE; }
};
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 857d9bc2080..117276e488b 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -361,9 +361,8 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
{
uint days;
days= calc_daynr(l_time->year,1,1) + yearday - 1;
- if (days <= 0 || days > MAX_DAY_NUMBER)
+ if (get_date_from_daynr(days,&l_time->year,&l_time->month,&l_time->day))
goto err;
- get_date_from_daynr(days,&l_time->year,&l_time->month,&l_time->day);
}
if (week_number >= 0 && weekday)
@@ -408,9 +407,8 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
(weekday - 1);
}
- if (days <= 0 || days > MAX_DAY_NUMBER)
+ if (get_date_from_daynr(days,&l_time->year,&l_time->month,&l_time->day))
goto err;
- get_date_from_daynr(days,&l_time->year,&l_time->month,&l_time->day);
}
if (l_time->month > 12 || l_time->day > 31 || l_time->hour > 23 ||
@@ -768,7 +766,7 @@ longlong Item_func_to_days::val_int()
{
DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime;
- if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE))
+ if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE))
return 0;
return (longlong) calc_daynr(ltime.year,ltime.month,ltime.day);
}
@@ -808,7 +806,7 @@ longlong Item_func_to_seconds::val_int()
MYSQL_TIME ltime;
longlong seconds;
longlong days;
- if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE))
+ if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE))
return 0;
seconds= ltime.hour * 3600L + ltime.minute * 60 + ltime.second;
seconds=ltime.neg ? -seconds : seconds;
@@ -1501,10 +1499,11 @@ bool Item_func_from_days::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
if ((fuzzy_date & TIME_NO_ZERO_DATE) && value == 0)
return (null_value= 1);
bzero(ltime, sizeof(MYSQL_TIME));
- get_date_from_daynr((long) value, &ltime->year, &ltime->month, &ltime->day);
+ if (get_date_from_daynr((long) value, &ltime->year, &ltime->month,
+ &ltime->day))
+ return (null_value= 1);
- if ((fuzzy_date & TIME_NO_ZERO_DATE) &&
- (ltime->year == 0 || ltime->month == 0 || ltime->day == 0))
+ if ((fuzzy_date & TIME_NO_ZERO_DATE) && ltime->year == 0)
return (null_value= 1);
ltime->time_type= MYSQL_TIMESTAMP_DATE;
@@ -2043,7 +2042,7 @@ bool Item_date_add_interval::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
{
INTERVAL interval;
- if (args[0]->get_date(ltime, TIME_NO_ZERO_DATE | TIME_FUZZY_DATE) ||
+ if (args[0]->get_date(ltime, TIME_NO_ZERO_DATE | TIME_FUZZY_DATE | TIME_NO_ZERO_IN_DATE) ||
get_interval_value(args[1], int_type, &interval))
return (null_value=1);
@@ -2514,14 +2513,12 @@ bool Item_func_makedate::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
year= year_2000_handling(year);
days= calc_daynr(year,1,1) + daynr - 1;
- /* Day number from year 0 to 9999-12-31 */
- if (days >= 0 && days <= MAX_DAY_NUMBER)
- {
- bzero(ltime, sizeof(*ltime));
- ltime->time_type= MYSQL_TIMESTAMP_DATE;
- get_date_from_daynr(days, &ltime->year, &ltime->month, &ltime->day);
- return (null_value= 0);
- }
+ if (get_date_from_daynr(days, &ltime->year, &ltime->month, &ltime->day))
+ goto err;
+ ltime->time_type= MYSQL_TIMESTAMP_DATE;
+ ltime->neg= 0;
+ ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0;
+ return (null_value= 0);
err:
return (null_value= 1);
@@ -2615,8 +2612,8 @@ bool Item_func_add_time::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
if (!is_time)
{
- get_date_from_daynr(days,&ltime->year,&ltime->month,&ltime->day);
- if (!ltime->day)
+ if (get_date_from_daynr(days,&ltime->year,&ltime->month,&ltime->day) ||
+ !ltime->day)
return (null_value= 1);
return (null_value= 0);
}
diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc
index 0fa2d39aea9..ae0a74c5ba6 100644
--- a/sql/item_xmlfunc.cc
+++ b/sql/item_xmlfunc.cc
@@ -2601,6 +2601,8 @@ void Item_xml_str_func::fix_length_and_dec()
MY_XPATH xpath;
int rc;
+ status_var_increment(current_thd->status_var.feature_xml);
+
nodeset_func= 0;
if (agg_arg_charsets_for_comparison(collation, args, arg_count))
diff --git a/sql/lex.h b/sql/lex.h
index 9f4369630a0..9bf4c439cb6 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -302,6 +302,7 @@ static SYMBOL symbols[] = {
{ "KILL", SYM(KILL_SYM)},
{ "LANGUAGE", SYM(LANGUAGE_SYM)},
{ "LAST", SYM(LAST_SYM)},
+ { "LAST_VALUE", SYM(LAST_VALUE)},
{ "LEADING", SYM(LEADING)},
{ "LEAVE", SYM(LEAVE_SYM)},
{ "LEAVES", SYM(LEAVES)},
diff --git a/sql/log.cc b/sql/log.cc
index 56c07f81c9e..bcca0012a56 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -3182,7 +3182,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name,
bytes_written+= description_event_for_queue->data_written;
}
if (flush_io_cache(&log_file) ||
- mysql_file_sync(log_file.file, MYF(MY_WME)))
+ mysql_file_sync(log_file.file, MYF(MY_WME|MY_SYNC_FILESIZE)))
goto err;
mysql_mutex_lock(&LOCK_commit_ordered);
strmake(last_commit_pos_file, log_file_name,
@@ -3212,7 +3212,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name,
strlen(log_file_name)) ||
my_b_write(&index_file, (uchar*) "\n", 1) ||
flush_io_cache(&index_file) ||
- mysql_file_sync(index_file.file, MYF(MY_WME)))
+ mysql_file_sync(index_file.file, MYF(MY_WME|MY_SYNC_FILESIZE)))
goto err;
#ifdef HAVE_REPLICATION
@@ -3302,7 +3302,7 @@ static bool copy_up_file_and_fill(IO_CACHE *index_file, my_off_t offset)
}
/* The following will either truncate the file or fill the end with \n' */
if (mysql_file_chsize(file, offset - init_offset, '\n', MYF(MY_WME)) ||
- mysql_file_sync(file, MYF(MY_WME)))
+ mysql_file_sync(file, MYF(MY_WME|MY_SYNC_FILESIZE)))
goto err;
/* Reset data in old index cache */
@@ -3939,7 +3939,7 @@ int MYSQL_BIN_LOG::sync_purge_index_file()
DBUG_ENTER("MYSQL_BIN_LOG::sync_purge_index_file");
if ((error= flush_io_cache(&purge_index_file)) ||
- (error= my_sync(purge_index_file.file, MYF(MY_WME))))
+ (error= my_sync(purge_index_file.file, MYF(MY_WME|MY_SYNC_FILESIZE))))
DBUG_RETURN(error);
DBUG_RETURN(error);
@@ -4556,7 +4556,7 @@ bool MYSQL_BIN_LOG::flush_and_sync(bool *synced)
if (sync_period && ++sync_counter >= sync_period)
{
sync_counter= 0;
- err= mysql_file_sync(fd, MYF(MY_WME));
+ err= mysql_file_sync(fd, MYF(MY_WME|MY_SYNC_FILESIZE));
if (synced)
*synced= 1;
#ifndef DBUG_OFF
diff --git a/sql/log_event.cc b/sql/log_event.cc
index dca9091e03d..6fc116d2b92 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -1086,6 +1086,9 @@ bool Log_event::write_header(IO_CACHE* file, ulong event_data_length)
ulong now;
bool ret;
DBUG_ENTER("Log_event::write_header");
+ DBUG_PRINT("enter", ("filepos: %lld length: %lu type: %d",
+ (longlong) my_b_tell(file), event_data_length,
+ (int) get_type_code()));
/* Store number of bytes that will be written by this event */
data_written= event_data_length + sizeof(header);
@@ -3512,6 +3515,34 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli)
return do_apply_event(rli, query, q_len);
}
+/**
+ Compare if two errors should be regarded as equal.
+ This is to handle the case when you can get slightly different errors
+ on master and slave for the same thing.
+ @param
+ expected_error Error we got on master
+ actual_error Error we got on slave
+
+ @return
+ 1 Errors are equal
+ 0 Errors are different
+*/
+
+bool test_if_equal_repl_errors(int expected_error, int actual_error)
+{
+ if (expected_error == actual_error)
+ return 1;
+ switch (expected_error) {
+ case ER_DUP_ENTRY:
+ case ER_AUTOINC_READ_FAILED:
+ return (actual_error == ER_AUTOINC_READ_FAILED ||
+ actual_error == HA_ERR_AUTOINC_ERANGE);
+ default:
+ break;
+ }
+ return 0;
+}
+
/**
@todo
@@ -3824,7 +3855,8 @@ compare_errors:
DBUG_PRINT("info",("expected_error: %d sql_errno: %d",
expected_error, actual_error));
- if ((expected_error && expected_error != actual_error &&
+ if ((expected_error &&
+ !test_if_equal_repl_errors(expected_error, actual_error) &&
!concurrency_error_code(expected_error)) &&
!ignored_error_code(actual_error) &&
!ignored_error_code(expected_error))
@@ -3846,7 +3878,7 @@ Default database: '%s'. Query: '%s'",
If we get the same error code as expected and it is not a concurrency
issue, or should be ignored.
*/
- else if ((expected_error == actual_error &&
+ else if ((test_if_equal_repl_errors(expected_error, actual_error) &&
!concurrency_error_code(expected_error)) ||
ignored_error_code(actual_error))
{
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 91bc2bfe226..885756b1a10 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -360,7 +360,7 @@ static DYNAMIC_ARRAY all_options;
/* Global variables */
-bool opt_bin_log, opt_ignore_builtin_innodb= 0;
+bool opt_bin_log, opt_bin_log_used=0, opt_ignore_builtin_innodb= 0;
my_bool opt_log, opt_slow_log, debug_assert_if_crashed_table= 0, opt_help= 0, opt_abort;
ulonglong log_output_options;
my_bool opt_userstat_running;
@@ -482,6 +482,7 @@ ulonglong binlog_stmt_cache_size=0;
ulonglong max_binlog_stmt_cache_size=0;
ulonglong query_cache_size=0;
ulong refresh_version; /* Increments on each reload */
+ulong executed_events=0;
query_id_t global_query_id;
my_atomic_rwlock_t global_query_id_lock;
my_atomic_rwlock_t thread_running_lock;
@@ -579,7 +580,7 @@ char mysql_real_data_home[FN_REFLEN],
lc_messages_dir[FN_REFLEN], reg_ext[FN_EXTLEN],
mysql_charsets_dir[FN_REFLEN],
*opt_init_file, *opt_tc_log_file;
-char *lc_messages_dir_ptr, *log_error_file_ptr;
+char *lc_messages_dir_ptr= lc_messages_dir, *log_error_file_ptr;
char mysql_unpacked_real_data_home[FN_REFLEN];
int mysql_unpacked_real_data_home_len;
uint mysql_real_data_home_len, mysql_data_home_len= 1;
@@ -2026,13 +2027,19 @@ static struct passwd *check_user(const char *user)
if (!(tmp_user_info= getpwuid(atoi(user))))
goto err;
}
+
return tmp_user_info;
/* purecov: end */
err:
sql_print_error("Fatal error: Can't change to run as user '%s' ; Please check that the user exists!\n",user);
unireg_abort(1);
+#endif
+ return NULL;
+}
+static inline void allow_coredumps()
+{
#ifdef PR_SET_DUMPABLE
if (test_flags & TEST_CORE_ON_SIGNAL)
{
@@ -2040,11 +2047,9 @@ err:
(void) prctl(PR_SET_DUMPABLE, 1);
}
#endif
-
-#endif
- return NULL;
}
+
static void set_user(const char *user, struct passwd *user_info_arg)
{
/* purecov: begin tested */
@@ -2071,6 +2076,7 @@ static void set_user(const char *user, struct passwd *user_info_arg)
sql_perror("setuid");
unireg_abort(1);
}
+ allow_coredumps();
#endif
/* purecov: end */
}
@@ -2090,6 +2096,7 @@ static void set_effective_user(struct passwd *user_info_arg)
sql_perror("setreuid");
unireg_abort(1);
}
+ allow_coredumps();
#endif
}
@@ -4166,14 +4173,15 @@ static int init_server_components()
unireg_abort(1);
/* need to configure logging before initializing storage engines */
- if (opt_log_slave_updates && !opt_bin_log)
+ if (!opt_bin_log_used)
{
- sql_print_warning("You need to use --log-bin to make "
- "--log-slave-updates work.");
+ if (opt_log_slave_updates)
+ sql_print_warning("You need to use --log-bin to make "
+ "--log-slave-updates work.");
+ if (binlog_format_used)
+ sql_print_warning("You need to use --log-bin to make "
+ "--binlog-format work.");
}
- if (!opt_bin_log && binlog_format_used)
- sql_print_warning("You need to use --log-bin to make "
- "--binlog-format work.");
/* Check that we have not let the format to unspecified at this point */
DBUG_ASSERT((uint)global_system_variables.binlog_format <=
@@ -6220,7 +6228,7 @@ struct my_option my_long_options[]=
{"language", 'L',
"Client error messages in given language. May be given as a full path. "
"Deprecated. Use --lc-messages-dir instead.",
- &lc_messages_dir_ptr, &lc_messages_dir_ptr, 0,
+ 0, 0, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"lc-messages", 0,
"Set the language used for the error messages.",
@@ -6941,6 +6949,16 @@ SHOW_VAR status_vars[]= {
{"Delayed_insert_threads", (char*) &delayed_insert_threads, SHOW_LONG_NOFLUSH},
{"Delayed_writes", (char*) &delayed_insert_writes, SHOW_LONG},
{"Empty_queries", (char*) offsetof(STATUS_VAR, empty_queries), SHOW_LONG_STATUS},
+ {"Executed_events", (char*) &executed_events, SHOW_LONG_NOFLUSH },
+ {"Executed_triggers", (char*) offsetof(STATUS_VAR, executed_triggers), SHOW_LONG_STATUS},
+ {"Feature_dynamic_columns", (char*) offsetof(STATUS_VAR, feature_dynamic_columns), SHOW_LONG_STATUS},
+ {"Feature_fulltext", (char*) offsetof(STATUS_VAR, feature_fulltext), SHOW_LONG_STATUS},
+ {"Feature_gis", (char*) offsetof(STATUS_VAR, feature_gis), SHOW_LONG_STATUS},
+ {"Feature_locale", (char*) offsetof(STATUS_VAR, feature_locale), SHOW_LONG_STATUS},
+ {"Feature_subquery", (char*) offsetof(STATUS_VAR, feature_subquery), SHOW_LONG_STATUS},
+ {"Feature_timezone", (char*) offsetof(STATUS_VAR, feature_timezone), SHOW_LONG_STATUS},
+ {"Feature_trigger", (char*) offsetof(STATUS_VAR, feature_trigger), SHOW_LONG_STATUS},
+ {"Feature_xml", (char*) offsetof(STATUS_VAR, feature_xml), SHOW_LONG_STATUS},
{"Flush_commands", (char*) &refresh_version, SHOW_LONG_NOFLUSH},
{"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS},
{"Handler_delete", (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS},
@@ -6980,6 +6998,7 @@ SHOW_VAR status_vars[]= {
{"Opened_files", (char*) &my_file_total_opened, SHOW_LONG_NOFLUSH},
{"Opened_tables", (char*) offsetof(STATUS_VAR, opened_tables), SHOW_LONG_STATUS},
{"Opened_table_definitions", (char*) offsetof(STATUS_VAR, opened_shares), SHOW_LONG_STATUS},
+ {"Opened_views", (char*) offsetof(STATUS_VAR, opened_views), SHOW_LONG_STATUS},
{"Prepared_stmt_count", (char*) &show_prepared_stmt_count, SHOW_FUNC},
{"Rows_sent", (char*) offsetof(STATUS_VAR, rows_sent), SHOW_LONGLONG_STATUS},
{"Rows_read", (char*) offsetof(STATUS_VAR, rows_read), SHOW_LONGLONG_STATUS},
@@ -7212,7 +7231,7 @@ static int mysql_init_variables(void)
myisam_test_invalid_symlink= test_if_data_home_dir;
#endif
opt_log= opt_slow_log= 0;
- opt_bin_log= 0;
+ opt_bin_log= opt_bin_log_used= 0;
opt_disable_networking= opt_skip_show_db=0;
opt_skip_name_resolve= 0;
opt_ignore_builtin_innodb= 0;
@@ -7264,10 +7283,10 @@ static int mysql_init_variables(void)
mysql_home_ptr= mysql_home;
pidfile_name_ptr= pidfile_name;
log_error_file_ptr= log_error_file;
- lc_messages_dir_ptr= lc_messages_dir;
protocol_version= PROTOCOL_VERSION;
what_to_log= ~ (1L << (uint) COM_TIME);
refresh_version= 1L; /* Increments on each reload */
+ executed_events= 0;
global_query_id= thread_id= 1L;
my_atomic_rwlock_init(&global_query_id_lock);
my_atomic_rwlock_init(&thread_running_lock);
@@ -7453,7 +7472,6 @@ mysqld_get_one_option(int optid,
break;
case 'L':
strmake(lc_messages_dir, argument, sizeof(lc_messages_dir)-1);
- lc_messages_dir_ptr= lc_messages_dir;
break;
case OPT_BINLOG_FORMAT:
binlog_format_used= true;
@@ -7482,6 +7500,7 @@ mysqld_get_one_option(int optid,
break;
case (int) OPT_BIN_LOG:
opt_bin_log= test(argument != disabled_my_option);
+ opt_bin_log_used= 1;
break;
case (int) OPT_LOG_BASENAME:
{
diff --git a/sql/mysqld.h b/sql/mysqld.h
index 56419acdcd4..619f30ce683 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -175,6 +175,7 @@ extern ulong opt_binlog_rows_event_max_size;
extern ulong rpl_recovery_rank, thread_cache_size;
extern ulong stored_program_cache_size;
extern ulong back_log;
+extern ulong executed_events;
extern char language[FN_REFLEN];
extern "C" MYSQL_PLUGIN_IMPORT ulong server_id;
extern ulong concurrency;
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index cbec039b3e4..fa3a07b72c5 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -791,7 +791,7 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo,
{
/* Update endpoints for MAX/MIN, see function comment. */
Item *value= args[between && max_fl ? 2 : 1];
- store_val_in_field(part->field, value, CHECK_FIELD_IGNORE);
+ value->save_in_field_no_warnings(part->field, 1);
if (part->null_bit)
*key_ptr++= (uchar) test(part->field->is_null());
part->field->get_key_image(key_ptr, part->length, Field::itRAW);
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 52569f193aa..85e9227c154 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -3893,34 +3893,22 @@ static bool open_table_entry_fini(THD *thd, TABLE_SHARE *share, TABLE *entry)
{
char query_buf[2*FN_REFLEN + 21];
String query(query_buf, sizeof(query_buf), system_charset_info);
+
query.length(0);
- if (query.ptr())
- {
- /* this DELETE FROM is needed even with row-based binlogging */
- query.append("DELETE FROM ");
- append_identifier(thd, &query, share->db.str, share->db.length);
- query.append(".");
- append_identifier(thd, &query, share->table_name.str,
+ query.append("DELETE FROM ");
+ append_identifier(thd, &query, share->db.str, share->db.length);
+ query.append(".");
+ append_identifier(thd, &query, share->table_name.str,
share->table_name.length);
- int errcode= query_error_code(thd, TRUE);
- if (thd->binlog_query(THD::STMT_QUERY_TYPE,
- query.ptr(), query.length(),
- FALSE, FALSE, FALSE, errcode))
- return TRUE;
- }
- else
- {
- /*
- As replication is maybe going to be corrupted, we need to warn the
- DBA on top of warning the client (which will automatically be done
- because of MYF(MY_WME) in my_malloc() above).
- */
- sql_print_error("When opening HEAP table, could not allocate memory "
- "to write 'DELETE FROM %`s.%`s' to the binary log",
- share->db.str, share->table_name.str);
- delete entry->triggers;
+
+ /*
+ we bypass thd->binlog_query() here,
+ as it does a lot of extra work, that is simply wrong in this case
+ */
+ Query_log_event qinfo(thd, query.ptr(), query.length(),
+ FALSE, TRUE, TRUE, 0);
+ if (mysql_bin_log.write(&qinfo))
return TRUE;
- }
}
}
return FALSE;
@@ -9433,6 +9421,7 @@ open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias,
if (mysql_make_view(thd, parser, table_desc,
(prgflag & OPEN_VIEW_NO_PARSE)))
goto err;
+ status_var_increment(thd->status_var.opened_views);
}
else
{
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 054f267ed01..7f7d9b46542 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -620,25 +620,17 @@ typedef struct system_status_var
ulong ha_savepoint_count;
ulong ha_savepoint_rollback_count;
-#if 0
- /* KEY_CACHE parts. These are copies of the original */
- ulong key_blocks_changed;
- ulong key_blocks_used;
- ulong key_cache_r_requests;
- ulong key_cache_read;
- ulong key_cache_w_requests;
- ulong key_cache_write;
- /* END OF KEY_CACHE parts */
-#endif
-
ulong net_big_packet_count;
ulong opened_tables;
ulong opened_shares;
+ ulong opened_views; /* +1 opening a view */
+
ulong select_full_join_count;
ulong select_full_range_join_count;
ulong select_range_count;
ulong select_range_check_count;
ulong select_scan_count;
+ ulong executed_triggers;
ulong long_query_count;
ulong filesort_merge_passes;
ulong filesort_range_count;
@@ -653,6 +645,16 @@ typedef struct system_status_var
ulong com_stmt_reset;
ulong com_stmt_close;
+ /* Features used */
+ ulong feature_dynamic_columns; /* +1 when creating a dynamic column */
+ ulong feature_fulltext; /* +1 when MATCH is used */
+ ulong feature_gis; /* +1 opening a table with GIS features */
+ ulong feature_locale; /* +1 when LOCALE is set */
+ ulong feature_subquery; /* +1 when subqueries are used */
+ ulong feature_timezone; /* +1 when XPATH is used */
+ ulong feature_trigger; /* +1 opening a table with triggers */
+ ulong feature_xml; /* +1 when XPATH is used */
+
ulong empty_queries;
ulong access_denied_errors;
ulong lost_connections;
@@ -1683,7 +1685,7 @@ public:
my_hrtime_t user_time;
// track down slow pthread_create
ulonglong prior_thr_create_utime, thr_create_utime;
- ulonglong start_utime, utime_after_lock;
+ ulonglong start_utime, utime_after_lock, utime_after_query;
// Process indicator
struct {
@@ -2486,8 +2488,8 @@ public:
*/
void update_server_status()
{
- ulonglong end_utime_of_query= current_utime();
- if (end_utime_of_query > utime_after_lock + variables.long_query_time)
+ utime_after_query= current_utime();
+ if (utime_after_query > utime_after_lock + variables.long_query_time)
server_status|= SERVER_QUERY_WAS_SLOW;
}
inline ulonglong found_rows(void)
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index e0d0d4c4223..3c3b9f85727 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -329,7 +329,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
/*
- Check update fields for the timestamp field.
+ Check update fields for the timestamp and auto_increment fields.
SYNOPSIS
check_update_fields()
@@ -342,6 +342,9 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
If the update fields include the timestamp field,
remove TIMESTAMP_AUTO_SET_ON_UPDATE from table->timestamp_field_type.
+ If the update fields include an autoinc field, set the
+ table->next_number_field_updated flag.
+
RETURN
0 OK
-1 Error
@@ -353,7 +356,9 @@ static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list,
{
TABLE *table= insert_table_list->table;
my_bool timestamp_mark;
+ my_bool autoinc_mark;
LINT_INIT(timestamp_mark);
+ LINT_INIT(autoinc_mark);
if (table->timestamp_field)
{
@@ -365,6 +370,19 @@ static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list,
table->timestamp_field->field_index);
}
+ table->next_number_field_updated= FALSE;
+
+ if (table->found_next_number_field)
+ {
+ /*
+ Unmark the auto_increment field so that we can check if this is modified
+ by update_fields
+ */
+ autoinc_mark= bitmap_test_and_clear(table->write_set,
+ table->found_next_number_field->
+ field_index);
+ }
+
/* Check the fields we are going to modify */
if (setup_fields(thd, 0, update_fields, MARK_COLUMNS_WRITE, 0, 0))
return -1;
@@ -386,6 +404,18 @@ static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list,
bitmap_set_bit(table->write_set,
table->timestamp_field->field_index);
}
+
+ if (table->found_next_number_field)
+ {
+ if (bitmap_is_set(table->write_set,
+ table->found_next_number_field->field_index))
+ table->next_number_field_updated= TRUE;
+
+ if (autoinc_mark)
+ bitmap_set_bit(table->write_set,
+ table->found_next_number_field->field_index);
+ }
+
return 0;
}
@@ -1563,6 +1593,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
MY_BITMAP *save_read_set, *save_write_set;
ulonglong prev_insert_id= table->file->next_insert_id;
ulonglong insert_id_for_cur_row= 0;
+ ulonglong prev_insert_id_for_cur_row= 0;
DBUG_ENTER("write_record");
info->records++;
@@ -1598,7 +1629,10 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
report error as usual. We will not do any duplicate key processing.
*/
if (info->ignore)
+ {
+ table->file->print_error(error, MYF(ME_JUST_WARNING));
goto ok_or_after_trg_err; /* Ignoring a not fatal error, return 0 */
+ }
goto err;
}
if ((int) (key_nr = table->file->get_dup_key(error)) < 0)
@@ -1688,6 +1722,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
if (info->ignore &&
!table->file->is_fatal_error(error, HA_CHECK_DUP_KEY))
{
+ table->file->print_error(error, MYF(ME_JUST_WARNING));
goto ok_or_after_trg_err;
}
goto err;
@@ -1705,6 +1740,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
INSERT query, which is handled separately by
THD::arg_of_last_insert_id_function.
*/
+ prev_insert_id_for_cur_row= table->file->insert_id_for_cur_row;
insert_id_for_cur_row= table->file->insert_id_for_cur_row= 0;
trg_error= (table->triggers &&
table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
@@ -1712,9 +1748,22 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
info->copied++;
}
- if (table->next_number_field)
- table->file->adjust_next_insert_id_after_explicit_value(
- table->next_number_field->val_int());
+ /*
+ Only update next_insert_id if the AUTO_INCREMENT value was explicitly
+ updated, so we don't update next_insert_id with the value from the
+ row being updated. Otherwise reset next_insert_id to what it was
+ before the duplicate key error, since that value is unused.
+ */
+ if (table->next_number_field_updated)
+ {
+ DBUG_ASSERT(table->next_number_field != NULL);
+
+ table->file->adjust_next_insert_id_after_explicit_value(table->next_number_field->val_int());
+ }
+ else
+ {
+ table->file->restore_auto_increment(prev_insert_id_for_cur_row);
+ }
goto ok_or_after_trg_err;
}
else /* DUP_REPLACE */
@@ -1803,6 +1852,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
if (!info->ignore ||
table->file->is_fatal_error(error, HA_CHECK_DUP))
goto err;
+ table->file->print_error(error, MYF(ME_JUST_WARNING));
table->file->restore_auto_increment(prev_insert_id);
goto ok_or_after_trg_err;
}
diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc
index f953cf4df57..91a98d8c6f1 100644
--- a/sql/sql_join_cache.cc
+++ b/sql/sql_join_cache.cc
@@ -3876,8 +3876,9 @@ int JOIN_TAB_SCAN_MRR::next()
If a record in in an incremental cache contains no fields then the
association for the last record in cache will be equal to cache->end_pos
*/
- DBUG_ASSERT(cache->buff <= (uchar *) (*ptr) &&
- (uchar *) (*ptr) <= cache->end_pos);
+ DBUG_ASSERT((!(mrr_mode & HA_MRR_NO_ASSOCIATION))?
+ (cache->buff <= (uchar *) (*ptr) &&
+ (uchar *) (*ptr) <= cache->end_pos): TRUE);
if (join_tab->table->vfield)
update_virtual_fields(join->thd, join_tab->table);
}
@@ -4543,7 +4544,7 @@ bool JOIN_CACHE_BKAH::prepare_look_for_matches(bool skip_last)
{
last_matching_rec_ref_ptr= next_matching_rec_ref_ptr= 0;
if (no_association &&
- (curr_matching_chain= get_matching_chain_by_join_key()))
+ !(curr_matching_chain= get_matching_chain_by_join_key()))
return 1;
last_matching_rec_ref_ptr= get_next_rec_ref(curr_matching_chain);
return 0;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 91bdad3da62..175c2c1d672 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1438,6 +1438,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
(thd->open_tables == NULL ||
(thd->locked_tables_mode == LTM_LOCK_TABLES)));
+ thd_proc_info(thd, "updating status");
/* Finalize server status flags after executing a command. */
thd->update_server_status();
thd->protocol->end_statement();
@@ -1495,38 +1496,30 @@ void log_slow_statement(THD *thd)
DBUG_VOID_RETURN; // Don't set time for sub stmt
/* Follow the slow log filter configuration. */
- if (!(thd->variables.log_slow_filter & thd->query_plan_flags))
+ if (!thd->enable_slow_log ||
+ !(thd->variables.log_slow_filter & thd->query_plan_flags))
DBUG_VOID_RETURN;
- /*
- If rate limiting of slow log writes is enabled, decide whether to log
- this query to the log or not.
- */
- if (thd->variables.log_slow_rate_limit > 1 &&
- (global_query_id % thd->variables.log_slow_rate_limit) != 0)
- DBUG_VOID_RETURN;
+ if (((thd->server_status & SERVER_QUERY_WAS_SLOW) ||
+ ((thd->server_status &
+ (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
+ opt_log_queries_not_using_indexes &&
+ !(sql_command_flags[thd->lex->sql_command] & CF_STATUS_COMMAND))) &&
+ thd->examined_row_count >= thd->variables.min_examined_row_limit)
+ {
+ thd->status_var.long_query_count++;
+ /*
+ If rate limiting of slow log writes is enabled, decide whether to log
+ this query to the log or not.
+ */
+ if (thd->variables.log_slow_rate_limit > 1 &&
+ (global_query_id % thd->variables.log_slow_rate_limit) != 0)
+ DBUG_VOID_RETURN;
- /*
- Do not log administrative statements unless the appropriate option is
- set.
- */
- if (thd->enable_slow_log)
- {
- ulonglong end_utime_of_query= thd->current_utime();
thd_proc_info(thd, "logging slow query");
-
- if (((thd->server_status & SERVER_QUERY_WAS_SLOW) ||
- ((thd->server_status &
- (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
- opt_log_queries_not_using_indexes &&
- !(sql_command_flags[thd->lex->sql_command] & CF_STATUS_COMMAND))) &&
- thd->examined_row_count >= thd->variables.min_examined_row_limit)
- {
- thd_proc_info(thd, "logging slow query");
- thd->status_var.long_query_count++;
- slow_log_print(thd, thd->query(), thd->query_length(),
- end_utime_of_query);
- }
+ slow_log_print(thd, thd->query(), thd->query_length(),
+ thd->utime_after_query);
+ thd_proc_info(thd, 0);
}
DBUG_VOID_RETURN;
}
@@ -2974,6 +2967,7 @@ end_with_restore_list:
DBUG_ASSERT(!debug_sync_set_action(thd,
STRING_WITH_LEN(act2)));
};);
+ DEBUG_SYNC(thd, "after_mysql_insert");
break;
}
case SQLCOM_REPLACE_SELECT:
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 264ff6552db..f0c786dea86 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -8072,37 +8072,6 @@ get_store_key(THD *thd, KEYUSE *keyuse, table_map used_tables,
}
/**
- This function is only called for const items on fields which are keys.
-
- @return
- returns 1 if there was some conversion made when the field was stored.
-*/
-
-bool
-store_val_in_field(Field *field, Item *item, enum_check_fields check_flag)
-{
- bool error;
- TABLE *table= field->table;
- THD *thd= table->in_use;
- ha_rows cuted_fields=thd->cuted_fields;
- my_bitmap_map *old_map= dbug_tmp_use_all_columns(table,
- table->write_set);
-
- /*
- we should restore old value of count_cuted_fields because
- store_val_in_field can be called from mysql_insert
- with select_insert, which make count_cuted_fields= 1
- */
- enum_check_fields old_count_cuted_fields= thd->count_cuted_fields;
- thd->count_cuted_fields= check_flag;
- error= item->save_in_field(field, 1);
- thd->count_cuted_fields= old_count_cuted_fields;
- dbug_tmp_restore_column_map(table->write_set, old_map);
- return error || cuted_fields != thd->cuted_fields;
-}
-
-
-/**
@details Initialize a JOIN as a query execution plan
that accesses a single table via a table scan.
@@ -17760,7 +17729,7 @@ bool test_if_ref(Item *root_cond, Item_field *left_item,Item *right_item)
field->real_type() != MYSQL_TYPE_VARCHAR &&
(field->type() != MYSQL_TYPE_FLOAT || field->decimals() == 0))
{
- return !store_val_in_field(field, right_item, CHECK_FIELD_WARN);
+ return !right_item->save_in_field_no_warnings(field, 1);
}
}
}
diff --git a/sql/sql_select.h b/sql/sql_select.h
index be5f523a7e2..118a684ab62 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -1430,7 +1430,6 @@ typedef struct st_select_check {
extern const char *join_type_str[];
/* Extern functions in sql_select.cc */
-bool store_val_in_field(Field *field, Item *val, enum_check_fields check_flag);
void count_field_types(SELECT_LEX *select_lex, TMP_TABLE_PARAM *param,
List<Item> &fields, bool reset_with_sum_func);
bool setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
@@ -1504,6 +1503,7 @@ public:
enum_check_fields saved_count_cuted_fields= thd->count_cuted_fields;
ulonglong sql_mode= thd->variables.sql_mode;
thd->variables.sql_mode&= ~(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE);
+ thd->variables.sql_mode|= MODE_INVALID_DATES;
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
diff --git a/sql/sql_state.c b/sql/sql_state.c
index 511dc65917b..5acf97f16cc 100644
--- a/sql/sql_state.c
+++ b/sql/sql_state.c
@@ -17,6 +17,7 @@
#include <my_global.h>
#include <mysqld_error.h>
+#include <my_base.h>
struct st_map_errno_to_sqlstate
{
@@ -27,6 +28,7 @@ struct st_map_errno_to_sqlstate
struct st_map_errno_to_sqlstate sqlstate_map[]=
{
+#include <handler_state.h>
#include <sql_state.h>
};
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 06ec9a733c6..5a6090e5d9a 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1828,6 +1828,7 @@ int write_bin_log(THD *thd, bool clear_error,
if (mysql_bin_log.is_open())
{
int errcode= 0;
+ thd_proc_info(thd, "Writing to binlog");
if (clear_error)
thd->clear_error();
else
@@ -1835,6 +1836,7 @@ int write_bin_log(THD *thd, bool clear_error,
error= thd->binlog_query(THD::STMT_QUERY_TYPE,
query, query_length, is_trans, FALSE, FALSE,
errcode);
+ thd_proc_info(thd, 0);
}
return error;
}
@@ -7476,7 +7478,7 @@ copy_data_between_tables(THD *thd, TABLE *from,TABLE *to,
(to->key_info[0].key_part[0].field->flags &
AUTO_INCREMENT_FLAG))
err_msg= ER(ER_DUP_ENTRY_AUTOINCREMENT_CASE);
- to->file->print_keydup_error(key_nr, err_msg);
+ to->file->print_keydup_error(key_nr, err_msg, MYF(0));
break;
}
}
diff --git a/sql/sql_time.cc b/sql/sql_time.cc
index 5972c8918ba..5c0471fdfaa 100644
--- a/sql/sql_time.cc
+++ b/sql/sql_time.cc
@@ -25,9 +25,9 @@
#include <m_ctype.h>
- /* Some functions to calculate dates */
+#define MAX_DAY_NUMBER 3652424L
-#ifndef TESTTIME
+ /* Some functions to calculate dates */
/*
Name description of interval names used in statements.
@@ -147,46 +147,42 @@ uint calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year)
/* Change a daynr to year, month and day */
/* Daynr 0 is returned as date 00.00.00 */
-void get_date_from_daynr(long daynr,uint *ret_year,uint *ret_month,
+bool get_date_from_daynr(long daynr,uint *ret_year,uint *ret_month,
uint *ret_day)
{
uint year,temp,leap_day,day_of_year,days_in_year;
uchar *month_pos;
DBUG_ENTER("get_date_from_daynr");
- if (daynr <= 365L || daynr >= 3652500)
- { /* Fix if wrong daynr */
- *ret_year= *ret_month = *ret_day =0;
+ if (daynr < 365 || daynr > MAX_DAY_NUMBER)
+ DBUG_RETURN(1);
+
+ year= (uint) (daynr*100 / 36525L);
+ temp=(((year-1)/100+1)*3)/4;
+ day_of_year=(uint) (daynr - (long) year * 365L) - (year-1)/4 +temp;
+ while (day_of_year > (days_in_year= calc_days_in_year(year)))
+ {
+ day_of_year-=days_in_year;
+ (year)++;
}
- else
+ leap_day=0;
+ if (days_in_year == 366)
{
- year= (uint) (daynr*100 / 36525L);
- temp=(((year-1)/100+1)*3)/4;
- day_of_year=(uint) (daynr - (long) year * 365L) - (year-1)/4 +temp;
- while (day_of_year > (days_in_year= calc_days_in_year(year)))
+ if (day_of_year > 31+28)
{
- day_of_year-=days_in_year;
- (year)++;
+ day_of_year--;
+ if (day_of_year == 31+28)
+ leap_day=1; /* Handle leapyears leapday */
}
- leap_day=0;
- if (days_in_year == 366)
- {
- if (day_of_year > 31+28)
- {
- day_of_year--;
- if (day_of_year == 31+28)
- leap_day=1; /* Handle leapyears leapday */
- }
- }
- *ret_month=1;
- for (month_pos= days_in_month ;
- day_of_year > (uint) *month_pos ;
- day_of_year-= *(month_pos++), (*ret_month)++)
- ;
- *ret_year=year;
- *ret_day=day_of_year+leap_day;
}
- DBUG_VOID_RETURN;
+ *ret_month=1;
+ for (month_pos= days_in_month ;
+ day_of_year > (uint) *month_pos ;
+ day_of_year-= *(month_pos++), (*ret_month)++)
+ ;
+ *ret_year=year;
+ *ret_day=day_of_year+leap_day;
+ DBUG_RETURN(0);
}
/* Functions to handle periods */
@@ -842,7 +838,6 @@ void make_truncated_value_warning(THD *thd,
/* Daynumber from year 0 to 9999-12-31 */
-#define MAX_DAY_NUMBER 3652424L
#define COMBINE(X) \
(((((X)->day * 24LL + (X)->hour) * 60LL + \
(X)->minute) * 60LL + (X)->second)*1000000LL + \
@@ -909,19 +904,18 @@ bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type,
daynr= usec;
/* Day number from year 0 to 9999-12-31 */
- if ((ulonglong) daynr > MAX_DAY_NUMBER)
+ if (get_date_from_daynr((long) daynr, &ltime->year, &ltime->month,
+ &ltime->day))
goto invalid_date;
- get_date_from_daynr((long) daynr, &ltime->year, &ltime->month,
- &ltime->day);
break;
}
case INTERVAL_WEEK:
period= (calc_daynr(ltime->year,ltime->month,ltime->day) +
sign * (long) interval.day);
/* Daynumber from year 0 to 9999-12-31 */
- if ((ulong) period > MAX_DAY_NUMBER)
+ if (get_date_from_daynr((long) period,&ltime->year,&ltime->month,
+ &ltime->day))
goto invalid_date;
- get_date_from_daynr((long) period,&ltime->year,&ltime->month,&ltime->day);
break;
case INTERVAL_YEAR:
ltime->year+= sign * (long) interval.year;
@@ -1071,4 +1065,3 @@ int my_time_compare(MYSQL_TIME *a, MYSQL_TIME *b)
return 0;
}
-#endif
diff --git a/sql/sql_time.h b/sql/sql_time.h
index 026a15cb796..c1a75bb2ad3 100644
--- a/sql/sql_time.h
+++ b/sql/sql_time.h
@@ -33,7 +33,7 @@ typedef struct st_known_date_time_format KNOWN_DATE_TIME_FORMAT;
ulong convert_period_to_month(ulong period);
ulong convert_month_to_period(ulong month);
-void get_date_from_daynr(long daynr,uint *year, uint *month, uint *day);
+bool get_date_from_daynr(long daynr,uint *year, uint *month, uint *day);
my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, uint *error_code);
bool str_to_time_with_warn(CHARSET_INFO *cs, const char *str, uint length,
MYSQL_TIME *l_time, ulonglong fuzzydate);
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index 1b942ecc93b..aff00f9fcf4 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -1334,6 +1334,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
triggers->definitions_list.elements);
table->triggers= triggers;
+ status_var_increment(thd->status_var.feature_trigger);
/*
TODO: This could be avoided if there is no triggers
@@ -2116,6 +2117,8 @@ bool Table_triggers_list::process_triggers(THD *thd,
if (sp_trigger == NULL)
return FALSE;
+ status_var_increment(thd->status_var.executed_triggers);
+
if (old_row_is_record1)
{
old_field= record1_field;
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index bf261bffec3..fb0951410a4 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -406,7 +406,7 @@ int mysql_update(THD *thd,
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
select= make_select(table, 0, 0, conds, 0, &error);
- if (error || !limit ||
+ if (error || !limit || thd->is_error() ||
(select && select->check_quick(thd, safe_update, limit)))
{
delete select;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 8ef59fafb98..555efaf366d 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1064,6 +1064,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token KILL_SYM
%token LANGUAGE_SYM /* SQL-2003-R */
%token LAST_SYM /* SQL-2003-N */
+%token LAST_VALUE
%token LE /* OPERATOR */
%token LEADING /* SQL-2003-R */
%token LEAVES
@@ -5872,9 +5873,9 @@ attribute:
NULL_SYM { Lex->type&= ~ NOT_NULL_FLAG; }
| not NULL_SYM { Lex->type|= NOT_NULL_FLAG; }
| DEFAULT now_or_signed_literal { Lex->default_value=$2; }
- | ON UPDATE_SYM NOW_SYM opt_time_precision
+ | ON UPDATE_SYM NOW_SYM optional_braces
{
- Item *item= new (YYTHD->mem_root) Item_func_now_local($4);
+ Item *item= new (YYTHD->mem_root) Item_func_now_local(6);
if (item == NULL)
MYSQL_YYABORT;
Lex->on_update_value= item;
@@ -5966,9 +5967,9 @@ type_with_opt_collate:
now_or_signed_literal:
- NOW_SYM opt_time_precision
+ NOW_SYM optional_braces
{
- $$= new (YYTHD->mem_root) Item_func_now_local($2);
+ $$= new (YYTHD->mem_root) Item_func_now_local(6);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -8890,6 +8891,12 @@ function_call_conflict:
if ($$ == NULL)
MYSQL_YYABORT;
}
+ | LAST_VALUE '(' expr_list ')'
+ {
+ $$= new (YYTHD->mem_root) Item_func_last_value(* $3);
+ if ($$ == NULL)
+ MYSQL_YYABORT;
+ }
| MICROSECOND_SYM '(' expr ')'
{
$$= new (YYTHD->mem_root) Item_func_microsecond($3);
@@ -13088,6 +13095,7 @@ keyword_sp:
| ISSUER_SYM {}
| INSERT_METHOD {}
| KEY_BLOCK_SIZE {}
+ | LAST_VALUE {}
| LAST_SYM {}
| LEAVES {}
| LESS_SYM {}
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index fe48f953c28..4a003a89a7e 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -3578,22 +3578,25 @@ static bool check_locale(sys_var *self, THD *thd, set_var *var)
if (!locale->errmsgs->errmsgs)
{
+ bool res;
mysql_mutex_lock(&LOCK_error_messages);
- if (!locale->errmsgs->errmsgs &&
- read_texts(ERRMSG_FILE, locale->errmsgs->language,
- &locale->errmsgs->errmsgs,
- ER_ERROR_LAST - ER_ERROR_FIRST + 1))
+ res= (!locale->errmsgs->errmsgs &&
+ read_texts(ERRMSG_FILE, locale->errmsgs->language,
+ &locale->errmsgs->errmsgs,
+ ER_ERROR_LAST - ER_ERROR_FIRST + 1));
+ mysql_mutex_unlock(&LOCK_error_messages);
+ if (res)
{
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
"Can't process error message file for locale '%s'",
locale->name);
- mysql_mutex_unlock(&LOCK_error_messages);
return true;
}
- mysql_mutex_unlock(&LOCK_error_messages);
}
+ status_var_increment(thd->status_var.feature_locale);
return false;
}
+
static Sys_var_struct Sys_lc_messages(
"lc_messages", "Set the language used for the error messages",
SESSION_VAR(lc_messages), NO_CMD_LINE,
diff --git a/sql/table.cc b/sql/table.cc
index d733c5ada62..47b2cae1a04 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -4949,6 +4949,28 @@ void TABLE_LIST::set_check_materialized()
}
}
+TABLE *TABLE_LIST::get_real_join_table()
+{
+ TABLE_LIST *tbl= this;
+ while (tbl->table == NULL || tbl->table->reginfo.join_tab == NULL)
+ {
+ if (tbl->view == NULL && tbl->derived == NULL)
+ break;
+ /* we do not support merging of union yet */
+ DBUG_ASSERT(tbl->view == NULL ||
+ tbl->view->select_lex.next_select() == NULL);
+ DBUG_ASSERT(tbl->derived == NULL ||
+ tbl->derived->first_select()->next_select() == NULL);
+
+ if (tbl->table)
+ table= tbl->table;
+ tbl= (tbl->view != NULL ?
+ tbl->view->select_lex.get_table_list() :
+ tbl->derived->first_select()->get_table_list());
+ }
+ return tbl->table;
+}
+
Natural_join_column::Natural_join_column(Field_translator *field_param,
TABLE_LIST *tab)
diff --git a/sql/table.h b/sql/table.h
index fc451ff5050..9e26f907920 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -1088,15 +1088,20 @@ public:
uint db_stat; /* mode of file as in handler.h */
/* number of select if it is derived table */
uint derived_select_number;
- int current_lock; /* Type of lock on table */
- bool copy_blobs; /* copy_blobs when storing */
-
/*
0 or JOIN_TYPE_{LEFT|RIGHT}. Currently this is only compared to 0.
If maybe_null !=0, this table is inner w.r.t. some outer join operation,
and null_row may be true.
*/
uint maybe_null;
+ int current_lock; /* Type of lock on table */
+ bool copy_blobs; /* copy_blobs when storing */
+ /*
+ Set if next_number_field is in the UPDATE fields of INSERT ... ON DUPLICATE
+ KEY UPDATE.
+ */
+ bool next_number_field_updated;
+
/*
If true, the current table row is considered to have all columns set to
NULL, including columns declared as "not null" (see maybe_null).
@@ -1964,6 +1969,7 @@ struct TABLE_LIST
TABLE_LIST *find_underlying_table(TABLE *table);
TABLE_LIST *first_leaf_for_name_resolution();
TABLE_LIST *last_leaf_for_name_resolution();
+ TABLE *get_real_join_table();
bool is_leaf_for_name_resolution();
inline TABLE_LIST *top_table()
{ return belong_to_view ? belong_to_view : this; }
diff --git a/sql/tztime.cc b/sql/tztime.cc
index 9fae9f3fedd..ba24cab9ca7 100644
--- a/sql/tztime.cc
+++ b/sql/tztime.cc
@@ -2329,7 +2329,6 @@ my_tz_find(THD *thd, const String *name)
if (!str_to_offset(name->ptr(), name->length(), &offset))
{
-
if (!(result_tz= (Time_zone_offset *)my_hash_search(&offset_tzs,
(const uchar *)&offset,
sizeof(long))))
@@ -2371,6 +2370,9 @@ my_tz_find(THD *thd, const String *name)
mysql_mutex_unlock(&tz_LOCK);
+ if (result_tz && result_tz != my_tz_SYSTEM && result_tz != my_tz_UTC)
+ status_var_increment(thd->status_var.feature_timezone);
+
DBUG_RETURN(result_tz);
}
diff --git a/storage/heap/hp_hash.c b/storage/heap/hp_hash.c
index d44726ba762..2abed55459c 100644
--- a/storage/heap/hp_hash.c
+++ b/storage/heap/hp_hash.c
@@ -348,6 +348,8 @@ ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const uchar *rec)
seg->length/cs->mbmaxlen);
set_if_smaller(length, char_length);
}
+ else
+ set_if_smaller(length, seg->length);
cs->coll->hash_sort(cs, pos+pack_length, length, &nr, &nr2);
}
else
@@ -593,6 +595,11 @@ int hp_rec_key_cmp(HP_KEYDEF *keydef, const uchar *rec1, const uchar *rec2,
char_length2= my_charpos(cs, pos2, pos2 + char_length2, char_length);
set_if_smaller(char_length2, safe_length2);
}
+ else
+ {
+ set_if_smaller(char_length1, seg->length);
+ set_if_smaller(char_length2, seg->length);
+ }
if (cs->coll->strnncollsp(seg->charset,
pos1, char_length1,
@@ -689,6 +696,8 @@ int hp_key_cmp(HP_KEYDEF *keydef, const uchar *rec, const uchar *key)
char_length2= my_charpos(cs, pos, pos + char_length_rec, char_length2);
set_if_smaller(char_length_rec, char_length2);
}
+ else
+ set_if_smaller(char_length_rec, seg->length);
if (cs->coll->strnncollsp(seg->charset,
(uchar*) pos, char_length_rec,
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 81bb4a1c3eb..11893626e4e 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -1474,6 +1474,15 @@ innobase_next_autoinc(
ut_a(block > 0);
ut_a(max_value > 0);
+ /*
+ Allow auto_increment to go over max_value up to max ulonglong.
+ This allows us to detect that all values are exhausted.
+ If we don't do this, we will return max_value several times
+ and get duplicate key errors instead of auto increment value
+ out of range.
+ */
+ max_value= (~(ulonglong) 0);
+
/* Current value should never be greater than the maximum. */
ut_a(current <= max_value);
@@ -5236,7 +5245,10 @@ no_commit:
goto report_error;
}
- /* MySQL errors are passed straight back. */
+ /* MySQL errors are passed straight back. except for
+ HA_ERR_AUTO_INC_READ_FAILED. This can only happen
+ for values out of range.
+ */
error_result = (int) error;
goto func_exit;
}
@@ -10264,13 +10276,16 @@ ha_innobase::get_auto_increment(
/* Not in the middle of a mult-row INSERT. */
} else if (prebuilt->autoinc_last_value == 0) {
set_if_bigger(*first_value, autoinc);
- /* Check for -ve values. */
- } else if (*first_value > col_max_value && trx->n_autoinc_rows > 0) {
- /* Set to next logical value. */
- ut_a(autoinc > trx->n_autoinc_rows);
- *first_value = (autoinc - trx->n_autoinc_rows) - 1;
}
+ if (*first_value > col_max_value)
+ {
+ /* Out of range number. Let handler::update_auto_increment()
+ take care of this */
+ prebuilt->autoinc_last_value = 0;
+ dict_table_autoinc_unlock(prebuilt->table);
+ return;
+ }
*nb_reserved_values = trx->n_autoinc_rows;
/* With old style AUTOINC locking we only update the table's
@@ -10279,7 +10294,7 @@ ha_innobase::get_auto_increment(
ulonglong current;
ulonglong next_value;
- current = *first_value > col_max_value ? autoinc : *first_value;
+ current = *first_value;
/* Compute the last value in the interval */
next_value = innobase_next_autoinc(
diff --git a/storage/xtradb/btr/btr0btr.c b/storage/xtradb/btr/btr0btr.c
index d4a0ef5ec60..3f11684cb34 100644
--- a/storage/xtradb/btr/btr0btr.c
+++ b/storage/xtradb/btr/btr0btr.c
@@ -42,6 +42,7 @@ Created 6/2/1994 Heikki Tuuri
#include "ibuf0ibuf.h"
#include "trx0trx.h"
+#endif /* UNIV_HOTBACKUP */
/**************************************************************//**
Report that an index page is corrupted. */
UNIV_INTERN
@@ -64,6 +65,7 @@ btr_corruption_report(
buf_page_print(buf_block_get_frame_fast(block), 0, 0);
}
+#ifndef UNIV_HOTBACKUP
#ifdef UNIV_BLOB_DEBUG
# include "srv0srv.h"
# include "ut0rbt.h"
@@ -1622,7 +1624,9 @@ btr_page_reorganize_low(
dict_index_t* index, /*!< in: record descriptor */
mtr_t* mtr) /*!< in: mtr */
{
+#ifndef UNIV_HOTBACKUP
buf_pool_t* buf_pool = buf_pool_from_bpage(&block->page);
+#endif /* !UNIV_HOTBACKUP */
page_t* page = buf_block_get_frame(block);
page_zip_des_t* page_zip = buf_block_get_page_zip(block);
buf_block_t* temp_block;
diff --git a/storage/xtradb/buf/buf0buf.c b/storage/xtradb/buf/buf0buf.c
index fd7b8959473..a2ff171e0c5 100644
--- a/storage/xtradb/buf/buf0buf.c
+++ b/storage/xtradb/buf/buf0buf.c
@@ -344,7 +344,6 @@ be effective only if PFS_GROUP_BUFFER_SYNC is defined. */
// was allocated for the frames */
// buf_block_t* blocks; /*!< array of buffer control blocks */
//};
-#endif /* !UNIV_HOTBACKUP */
/********************************************************************//**
Gets the smallest oldest_modification lsn for any page in the pool. Returns
@@ -482,6 +481,7 @@ buf_block_alloc(
return(block);
}
+#endif /* !UNIV_HOTBACKUP */
/********************************************************************//**
Calculates a page checksum which is stored to the page when it is written
@@ -3907,9 +3907,10 @@ buf_mark_space_corrupt(
/********************************************************************//**
Completes an asynchronous read or write request of a file page to or from
-the buffer pool. */
+the buffer pool.
+@return TRUE if successful */
UNIV_INTERN
-void
+ibool
buf_page_io_complete(
/*=================*/
buf_page_t* bpage) /*!< in: pointer to the block in question */
@@ -4057,7 +4058,7 @@ corrupt:
table as corrupted instead of crashing server */
if (bpage->space > TRX_SYS_SPACE
&& buf_mark_space_corrupt(bpage)) {
- return;
+ return(FALSE);
} else {
fputs("InnoDB: Ending processing"
" because of"
@@ -4176,6 +4177,8 @@ retry_mutex:
buf_pool_mutex_exit(buf_pool);
mutex_exit(block_mutex);
+
+ return(TRUE);
}
/********************************************************************//**
diff --git a/storage/xtradb/buf/buf0lru.c b/storage/xtradb/buf/buf0lru.c
index f7b5db2d0cc..16a91358080 100644
--- a/storage/xtradb/buf/buf0lru.c
+++ b/storage/xtradb/buf/buf0lru.c
@@ -374,7 +374,7 @@ next_page:
/******************************************************************//**
While flushing (or removing dirty) pages from a tablespace we don't
-want to hog the CPU and resources. Release the buffer pool and block
+want to hog the CPU and resources. Release the LRU list and block
mutex and try to force a context switch. Then reacquire the same mutexes.
The current page is "fixed" before the release of the mutexes and then
"unfixed" again once we have reacquired the mutexes. */
@@ -387,7 +387,7 @@ buf_flush_yield(
{
mutex_t* block_mutex;
- ut_ad(buf_pool_mutex_own(buf_pool));
+ ut_ad(mutex_own(&buf_pool->LRU_list_mutex));
ut_ad(buf_page_in_file(bpage));
block_mutex = buf_page_get_mutex(bpage);
@@ -399,13 +399,13 @@ buf_flush_yield(
buf_page_set_sticky(bpage);
/* Now it is safe to release the buf_pool->mutex. */
- buf_pool_mutex_exit(buf_pool);
+ mutex_exit(&buf_pool->LRU_list_mutex);
mutex_exit(block_mutex);
/* Try and force a context switch. */
os_thread_yield();
- buf_pool_mutex_enter(buf_pool);
+ mutex_enter(&buf_pool->LRU_list_mutex);
mutex_enter(block_mutex);
/* "Unfix" the block now that we have both the
@@ -415,9 +415,9 @@ buf_flush_yield(
}
/******************************************************************//**
-If we have hogged the resources for too long then release the buffer
-pool and flush list mutex and do a thread yield. Set the current page
-to "sticky" so that it is not relocated during the yield.
+If we have hogged the resources for too long then release the LRU list
+and flush list mutex and do a thread yield. Set the current page to
+"sticky" so that it is not relocated during the yield.
@return TRUE if yielded */
static
ibool
@@ -439,7 +439,7 @@ buf_flush_try_yield(
buf_flush_list_mutex_exit(buf_pool);
- /* Release the buffer pool and block mutex
+ /* Release the LRU list and block mutex
to give the other threads a go. */
buf_flush_yield(buf_pool, bpage);
@@ -472,7 +472,7 @@ buf_flush_or_remove_page(
mutex_t* block_mutex;
ibool processed = FALSE;
- ut_ad(buf_pool_mutex_own(buf_pool));
+ ut_ad(mutex_own(&buf_pool->LRU_list_mutex));
ut_ad(buf_flush_list_mutex_own(buf_pool));
block_mutex = buf_page_get_mutex(bpage);
@@ -595,11 +595,11 @@ buf_flush_dirty_pages(
ibool all_freed;
do {
- buf_pool_mutex_enter(buf_pool);
+ mutex_enter(&buf_pool->LRU_list_mutex);
all_freed = buf_flush_or_remove_pages(buf_pool, id);
- buf_pool_mutex_exit(buf_pool);
+ mutex_exit(&buf_pool->LRU_list_mutex);
ut_ad(buf_flush_validate(buf_pool));
@@ -659,8 +659,16 @@ scan_again:
goto next_page;
} else {
- block_mutex = buf_page_get_mutex(bpage);
- mutex_enter(block_mutex);
+ block_mutex = buf_page_get_mutex_enter(bpage);
+
+ if (!block_mutex) {
+ /* It may be impossible case...
+ Something wrong, so will be scan_again */
+
+ all_freed = FALSE;
+ goto next_page;
+ }
+
if (bpage->buf_fix_count > 0) {
@@ -694,7 +702,8 @@ scan_again:
ulint page_no;
ulint zip_size;
- buf_pool_mutex_exit(buf_pool);
+ mutex_exit(&buf_pool->LRU_list_mutex);
+ rw_lock_x_unlock(&buf_pool->page_hash_latch);
zip_size = buf_page_get_zip_size(bpage);
page_no = buf_page_get_page_no(bpage);
@@ -2370,9 +2379,23 @@ buf_LRU_free_one_page(
be in a state where it can be freed; there
may or may not be a hash index to the page */
{
+#ifdef UNIV_DEBUG
+ buf_pool_t* buf_pool = buf_pool_from_bpage(bpage);
+#endif
+ mutex_t* block_mutex = buf_page_get_mutex(bpage);
+
+ ut_ad(buf_pool_mutex_own(buf_pool));
+ ut_ad(mutex_own(block_mutex));
+
if (buf_LRU_block_remove_hashed_page(bpage, TRUE)
!= BUF_BLOCK_ZIP_FREE) {
buf_LRU_block_free_hashed_page((buf_block_t*) bpage, TRUE);
+ } else {
+ /* The block_mutex should have been released by
+ buf_LRU_block_remove_hashed_page() when it returns
+ BUF_BLOCK_ZIP_FREE. */
+ ut_ad(block_mutex == &buf_pool->zip_mutex);
+ mutex_enter(block_mutex);
}
}
diff --git a/storage/xtradb/buf/buf0rea.c b/storage/xtradb/buf/buf0rea.c
index 4ba0d2cf577..c29dcbf0444 100644
--- a/storage/xtradb/buf/buf0rea.c
+++ b/storage/xtradb/buf/buf0rea.c
@@ -51,6 +51,44 @@ i/o-fixed buffer blocks */
#define BUF_READ_AHEAD_PEND_LIMIT 2
/********************************************************************//**
+Unfixes the pages, unlatches the page,
+removes it from page_hash and removes it from LRU. */
+static
+void
+buf_read_page_handle_error(
+/*=======================*/
+ buf_page_t* bpage) /*!< in: pointer to the block */
+{
+ buf_pool_t* buf_pool = buf_pool_from_bpage(bpage);
+ const ibool uncompressed = (buf_page_get_state(bpage)
+ == BUF_BLOCK_FILE_PAGE);
+
+ /* First unfix and release lock on the bpage */
+ buf_pool_mutex_enter(buf_pool);
+ mutex_enter(buf_page_get_mutex(bpage));
+ ut_ad(buf_page_get_io_fix(bpage) == BUF_IO_READ);
+ ut_ad(bpage->buf_fix_count == 0);
+
+ /* Set BUF_IO_NONE before we remove the block from LRU list */
+ buf_page_set_io_fix(bpage, BUF_IO_NONE);
+
+ if (uncompressed) {
+ rw_lock_x_unlock_gen(
+ &((buf_block_t*) bpage)->lock,
+ BUF_IO_READ);
+ }
+
+ /* remove the block from LRU list */
+ buf_LRU_free_one_page(bpage);
+
+ ut_ad(buf_pool->n_pend_reads > 0);
+ buf_pool->n_pend_reads--;
+
+ mutex_exit(buf_page_get_mutex(bpage));
+ buf_pool_mutex_exit(buf_pool);
+}
+
+/********************************************************************//**
Low-level function which reads a page asynchronously from a file to the
buffer buf_pool if it is not already there, in which case does nothing.
Sets the io_fix flag and sets an exclusive lock on the buffer frame. The
@@ -198,6 +236,11 @@ not_to_recover:
((buf_block_t*) bpage)->frame, bpage, trx);
}
+ if (*err == DB_TABLESPACE_DELETED) {
+ buf_read_page_handle_error(bpage);
+ return(0);
+ }
+
if (srv_pass_corrupt_table) {
if (*err != DB_SUCCESS) {
bpage->is_corrupt = TRUE;
@@ -210,7 +253,9 @@ not_to_recover:
thd_wait_end(NULL);
/* The i/o is already completed when we arrive from
fil_read */
- buf_page_io_complete(bpage);
+ if (!buf_page_io_complete(bpage)) {
+ return(0);
+ }
}
return(1);
diff --git a/storage/xtradb/dict/dict0dict.c b/storage/xtradb/dict/dict0dict.c
index 3ee045807ed..516b6e927e0 100644
--- a/storage/xtradb/dict/dict0dict.c
+++ b/storage/xtradb/dict/dict0dict.c
@@ -170,6 +170,7 @@ void
dict_field_print_low(
/*=================*/
const dict_field_t* field); /*!< in: field */
+#ifndef UNIV_HOTBACKUP
/*********************************************************************//**
Frees a foreign key struct. */
static
@@ -183,7 +184,7 @@ and unique key errors */
UNIV_INTERN FILE* dict_foreign_err_file = NULL;
/* mutex protecting the foreign and unique error buffers */
UNIV_INTERN mutex_t dict_foreign_err_mutex;
-
+#endif /* !UNIV_HOTBACKUP */
/******************************************************************//**
Makes all characters in a NUL-terminated UTF-8 string lower case. */
UNIV_INTERN
@@ -2318,6 +2319,7 @@ dict_index_build_internal_non_clust(
return(new_index);
}
+#ifndef UNIV_HOTBACKUP
/*====================== FOREIGN KEY PROCESSING ========================*/
/*********************************************************************//**
@@ -2582,6 +2584,7 @@ dict_foreign_find_equiv_index(
FALSE/* allow columns to be NULL */));
}
+#endif /* !UNIV_HOTBACKUP */
/**********************************************************************//**
Returns an index object by matching on the name and column names and
if more than one index matches return the index with the max id
@@ -2641,6 +2644,7 @@ dict_table_get_index_by_max_id(
return(found);
}
+#ifndef UNIV_HOTBACKUP
/**********************************************************************//**
Report an error in a foreign key definition. */
static
@@ -2806,6 +2810,7 @@ dict_foreign_add_to_cache(
return(DB_SUCCESS);
}
+#endif /* !UNIV_HOTBACKUP */
/*********************************************************************//**
Scans from pointer onwards. Stops if is at the start of a copy of
'string' where characters are compared without case sensitivity, and
@@ -3285,6 +3290,7 @@ end_of_string:
}
}
+#ifndef UNIV_HOTBACKUP
/*********************************************************************//**
Finds the highest [number] for foreign key constraints of the table. Looks
only at the >= 4.0.18-format id's, which are of the form
@@ -4121,7 +4127,7 @@ syntax_error:
}
/*==================== END OF FOREIGN KEY PROCESSING ====================*/
-
+#endif /* !UNIV_HOTBACKUP */
/**********************************************************************//**
Returns an index object if it is found in the dictionary cache.
Assumes that dict_sys->mutex is already being held.
@@ -4654,12 +4660,6 @@ next_rec:
}
btr_pcur_close(&pcur);
mtr_commit(&mtr);
-
- if (rests) {
- fprintf(stderr, "InnoDB: Warning: failed to store %lu stats entries"
- " of %s/%s to SYS_STATS system table.\n",
- rests, index->table_name, index->name);
- }
}
/*===========================================*/
@@ -4895,6 +4895,7 @@ next_rec:
}
}
+#ifndef UNIV_HOTBACKUP
/**********************************************************************//**
Prints info of a foreign key constraint. */
static
@@ -4925,6 +4926,7 @@ dict_foreign_print_low(
fputs(" )\n", stderr);
}
+#endif /* !UNIV_HOTBACKUP */
/**********************************************************************//**
Prints a table data. */
UNIV_INTERN
@@ -5107,6 +5109,7 @@ dict_field_print_low(
}
}
+#ifndef UNIV_HOTBACKUP
/**********************************************************************//**
Outputs info on a foreign key of a table in a format suitable for
CREATE TABLE. */
@@ -5295,6 +5298,7 @@ dict_print_info_on_foreign_keys(
mutex_exit(&(dict_sys->mutex));
}
+#endif /* !UNIV_HOTBACKUP */
/********************************************************************//**
Displays the names of the index and the table. */
UNIV_INTERN
@@ -5425,6 +5429,28 @@ dict_table_replace_index_in_foreign_list(
foreign->foreign_index = new_index;
}
}
+
+
+ for (foreign = UT_LIST_GET_FIRST(table->referenced_list);
+ foreign;
+ foreign = UT_LIST_GET_NEXT(referenced_list, foreign)) {
+
+ dict_index_t* new_index;
+
+ if (foreign->referenced_index == index) {
+ ut_ad(foreign->referenced_table == index->table);
+
+ new_index = dict_foreign_find_index(
+ foreign->referenced_table,
+ foreign->referenced_col_names,
+ foreign->n_fields, index,
+ /*check_charsets=*/TRUE, /*check_null=*/FALSE);
+ ut_ad(new_index || !trx->check_foreigns);
+ ut_ad(!new_index || new_index->table == index->table);
+
+ foreign->referenced_index = new_index;
+ }
+ }
}
/**********************************************************************//**
diff --git a/storage/xtradb/dict/dict0mem.c b/storage/xtradb/dict/dict0mem.c
index 617c68925cb..6b8c11dfa7a 100644
--- a/storage/xtradb/dict/dict0mem.c
+++ b/storage/xtradb/dict/dict0mem.c
@@ -33,8 +33,8 @@ Created 1/8/1996 Heikki Tuuri
#include "data0type.h"
#include "mach0data.h"
#include "dict0dict.h"
-#include "ha_prototypes.h" /* innobase_casedn_str()*/
#ifndef UNIV_HOTBACKUP
+# include "ha_prototypes.h" /* innobase_casedn_str()*/
# include "lock0lock.h"
#endif /* !UNIV_HOTBACKUP */
#ifdef UNIV_BLOB_DEBUG
@@ -274,6 +274,7 @@ dict_mem_index_create(
return(index);
}
+#ifndef UNIV_HOTBACKUP
/**********************************************************************//**
Creates and initializes a foreign constraint memory object.
@return own: foreign constraint struct */
@@ -348,6 +349,7 @@ dict_mem_referenced_table_name_lookup_set(
}
}
+#endif /* !UNIV_HOTBACKUP */
/**********************************************************************//**
Adds a field definition to an index. NOTE: does not take a copy
of the column name if the field is a column. The memory occupied
diff --git a/storage/xtradb/fil/fil0fil.c b/storage/xtradb/fil/fil0fil.c
index 3dd00594ee5..4ab2c16d41f 100644
--- a/storage/xtradb/fil/fil0fil.c
+++ b/storage/xtradb/fil/fil0fil.c
@@ -867,8 +867,10 @@ fil_node_close_file(
ut_a(node->open);
ut_a(node->n_pending == 0 || node->space->is_being_deleted);
ut_a(node->n_pending_flushes == 0);
+#ifndef UNIV_HOTBACKUP
ut_a(node->modification_counter == node->flush_counter
|| srv_fast_shutdown == 2);
+#endif /* !UNIV_HOTBACKUP */
ret = os_file_close(node->handle);
ut_a(ret);
diff --git a/storage/xtradb/ha/ha0ha.c b/storage/xtradb/ha/ha0ha.c
index 2f5051e541f..b9499607bce 100644
--- a/storage/xtradb/ha/ha0ha.c
+++ b/storage/xtradb/ha/ha0ha.c
@@ -28,6 +28,7 @@ Created 8/22/1994 Heikki Tuuri
#include "ha0ha.ic"
#endif
+#ifndef UNIV_HOTBACKUP
#ifdef UNIV_DEBUG
# include "buf0buf.h"
#endif /* UNIV_DEBUG */
@@ -51,17 +52,13 @@ ha_create_func(
hash table: must be a power of 2, or 0 */
{
hash_table_t* table;
-#ifndef UNIV_HOTBACKUP
ulint i;
-#endif /* !UNIV_HOTBACKUP */
ut_ad(ut_is_2pow(n_mutexes));
table = hash_create(n);
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
-# ifndef UNIV_HOTBACKUP
table->adaptive = TRUE;
-# endif /* !UNIV_HOTBACKUP */
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
/* Creating MEM_HEAP_BTR_SEARCH type heaps can potentially fail,
but in practise it never should in this case, hence the asserts. */
@@ -74,7 +71,6 @@ ha_create_func(
return(table);
}
-#ifndef UNIV_HOTBACKUP
hash_create_mutexes(table, n_mutexes, mutex_level);
table->heaps = mem_alloc(n_mutexes * sizeof(void*));
@@ -83,7 +79,6 @@ ha_create_func(
table->heaps[i] = mem_heap_create_in_btr_search(4096);
ut_a(table->heaps[i]);
}
-#endif /* !UNIV_HOTBACKUP */
return(table);
}
@@ -134,7 +129,6 @@ ha_insert_for_fold_func(
while (prev_node != NULL) {
if (prev_node->fold == fold) {
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
-# ifndef UNIV_HOTBACKUP
if (table->adaptive) {
buf_block_t* prev_block = prev_node->block;
ut_a(prev_block->frame
@@ -143,7 +137,6 @@ ha_insert_for_fold_func(
prev_block->n_pointers--;
block->n_pointers++;
}
-# endif /* !UNIV_HOTBACKUP */
prev_node->block = block;
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
@@ -171,11 +164,9 @@ ha_insert_for_fold_func(
ha_node_set_data(node, block, data);
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
-# ifndef UNIV_HOTBACKUP
if (table->adaptive) {
block->n_pointers++;
}
-# endif /* !UNIV_HOTBACKUP */
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
node->fold = fold;
@@ -217,13 +208,11 @@ ha_delete_hash_node(
#endif /* UNIV_SYNC_DEBUG */
ut_ad(btr_search_enabled);
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
-# ifndef UNIV_HOTBACKUP
if (table->adaptive) {
ut_a(del_node->block->frame = page_align(del_node->data));
ut_a(del_node->block->n_pointers > 0);
del_node->block->n_pointers--;
}
-# endif /* !UNIV_HOTBACKUP */
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
HASH_DELETE_AND_COMPACT(ha_node_t, next, table, del_node);
@@ -264,13 +253,11 @@ ha_search_and_update_if_found_func(
if (node) {
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
-# ifndef UNIV_HOTBACKUP
if (table->adaptive) {
ut_a(node->block->n_pointers > 0);
node->block->n_pointers--;
new_block->n_pointers++;
}
-# endif /* !UNIV_HOTBACKUP */
node->block = new_block;
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
@@ -278,7 +265,6 @@ ha_search_and_update_if_found_func(
}
}
-#ifndef UNIV_HOTBACKUP
/*****************************************************************//**
Removes from the chain determined by fold all nodes whose data pointer
points to the page given. */
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index db0bd40c9b6..329501a2ac6 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -49,6 +49,7 @@ this program; if not, write to the Free Software Foundation, Inc.,
#include <sql_acl.h> // PROCESS_ACL
#include <m_ctype.h>
+#include <debug_sync.h> // DEBUG_SYNC
#include <mysys_err.h>
#include <mysql/plugin.h>
#include <innodb_priv.h>
@@ -494,6 +495,9 @@ static MYSQL_THDVAR_BOOL(fake_changes, PLUGIN_VAR_OPCMDARG,
"This is to cause replication prefetch IO. ATTENTION: the transaction started after enabled is affected.",
NULL, NULL, FALSE);
+static MYSQL_THDVAR_ULONG(merge_sort_block_size, PLUGIN_VAR_RQCMDARG,
+ "The block size used doing external merge-sort for secondary index creation.",
+ NULL, NULL, 1UL << 20, 1UL << 20, 1UL << 30, 0);
static handler *innobase_create_handler(handlerton *hton,
TABLE_SHARE *table,
@@ -1010,6 +1014,20 @@ thd_flush_log_at_trx_commit(
return(THDVAR((THD*) thd, flush_log_at_trx_commit));
}
+/******************************************************************//**
+Returns the merge-sort block size used for the secondary index creation
+for the current connection.
+@return the merge-sort block size, in bytes */
+extern "C" UNIV_INTERN
+ulong
+thd_merge_sort_block_size(
+/*================================*/
+ void* thd) /*!< in: thread handle (THD*), or NULL to query
++ the global merge_sort_block_size */
+{
+ return(THDVAR((THD*) thd, merge_sort_block_size));
+}
+
/********************************************************************//**
Obtain the InnoDB transaction of a MySQL thread.
@return reference to transaction pointer */
@@ -1646,6 +1664,15 @@ innobase_next_autoinc(
ut_a(block > 0);
ut_a(max_value > 0);
+ /*
+ Allow auto_increment to go over max_value up to max ulonglong.
+ This allows us to detect that all values are exhausted.
+ If we don't do this, we will return max_value several times
+ and get duplicate key errors instead of auto increment value
+ out of range.
+ */
+ max_value= (~(ulonglong) 0);
+
/* Current value should never be greater than the maximum. */
ut_a(current <= max_value);
@@ -2870,6 +2897,7 @@ innobase_change_buffering_inited_ok:
srv_read_ahead &= 3;
srv_adaptive_flushing_method %= 3;
+ srv_flush_neighbor_pages %= 3;
srv_force_recovery = (ulint) innobase_force_recovery;
@@ -5980,7 +6008,10 @@ no_commit:
goto report_error;
}
- /* MySQL errors are passed straight back. */
+ /* MySQL errors are passed straight back. except for
+ HA_ERR_AUTO_INC_READ_FAILED. This can only happen
+ for values out of range.
+ */
error_result = (int) error;
goto func_exit;
}
@@ -6688,6 +6719,7 @@ ha_innobase::index_read(
ulint ret;
DBUG_ENTER("index_read");
+ DEBUG_SYNC_C("ha_innobase_index_read_begin");
ut_a(prebuilt->trx == thd_to_trx(user_thd));
ut_ad(key_len != 0 || find_flag != HA_READ_KEY_EXACT);
@@ -8578,6 +8610,8 @@ ha_innobase::rename_table(
error = innobase_rename_table(trx, from, to, TRUE);
+ DEBUG_SYNC(thd, "after_innobase_rename_table");
+
/* Tell the InnoDB server that there might be work for
utility threads: */
@@ -8905,10 +8939,15 @@ innobase_get_mysql_key_number_for_index(
}
}
- /* Print an error message if we cannot find the index
- ** in the "index translation table". */
- sql_print_error("Cannot find index %s in InnoDB index "
- "translation table.", index->name);
+ /* If index_count in translation table is set to 0, it
+ is possible we are in the process of rebuilding table,
+ do not spit error in this case */
+ if (share->idx_trans_tbl.index_count) {
+ /* Print an error message if we cannot find the index
+ ** in the "index translation table". */
+ sql_print_error("Cannot find index %s in InnoDB index "
+ "translation table.", index->name);
+ }
}
/* If we do not have an "index translation table", or not able
@@ -11178,13 +11217,16 @@ ha_innobase::get_auto_increment(
/* Not in the middle of a mult-row INSERT. */
} else if (prebuilt->autoinc_last_value == 0) {
set_if_bigger(*first_value, autoinc);
- /* Check for -ve values. */
- } else if (*first_value > col_max_value && trx->n_autoinc_rows > 0) {
- /* Set to next logical value. */
- ut_a(autoinc > trx->n_autoinc_rows);
- *first_value = (autoinc - trx->n_autoinc_rows) - 1;
}
+ if (*first_value > col_max_value)
+ {
+ /* Out of range number. Let handler::update_auto_increment()
+ take care of this */
+ prebuilt->autoinc_last_value = 0;
+ dict_table_autoinc_unlock(prebuilt->table);
+ return;
+ }
*nb_reserved_values = trx->n_autoinc_rows;
/* With old style AUTOINC locking we only update the table's
@@ -11193,7 +11235,7 @@ ha_innobase::get_auto_increment(
ulonglong current;
ulonglong next_value;
- current = *first_value > col_max_value ? autoinc : *first_value;
+ current = *first_value;
/* Compute the last value in the interval */
next_value = innobase_next_autoinc(
@@ -12411,7 +12453,7 @@ static MYSQL_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
static MYSQL_SYSVAR_ULONG(io_capacity, srv_io_capacity,
PLUGIN_VAR_RQCMDARG,
"Number of IOPs the server can do. Tunes the background IO rate",
- NULL, NULL, 200, 100, ~ (ulong) 0L, 0);
+ NULL, NULL, 200, 100, ~0UL, 0);
static MYSQL_SYSVAR_ULONG(purge_batch_size, srv_purge_batch_size,
PLUGIN_VAR_OPCMDARG,
@@ -12544,7 +12586,7 @@ static MYSQL_SYSVAR_BOOL(adaptive_flushing, srv_adaptive_flushing,
static MYSQL_SYSVAR_ULONG(max_purge_lag, srv_max_purge_lag,
PLUGIN_VAR_RQCMDARG,
"Desired maximum length of the purge queue (0 = no limit)",
- NULL, NULL, 0, 0, ~(ulong) 0L, 0);
+ NULL, NULL, 0, 0, ~0UL, 0);
static MYSQL_SYSVAR_BOOL(rollback_on_timeout, innobase_rollback_on_timeout,
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
@@ -12648,7 +12690,7 @@ static MYSQL_SYSVAR_ULONG(commit_concurrency, innobase_commit_concurrency,
static MYSQL_SYSVAR_ULONG(concurrency_tickets, srv_n_free_tickets_to_enter,
PLUGIN_VAR_RQCMDARG,
"Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket",
- NULL, NULL, 500L, 1L, ~(ulong) 0L, 0);
+ NULL, NULL, 500L, 1L, ~0UL, 0);
#ifdef EXTENDED_FOR_KILLIDLE
#define kill_idle_help_text "If non-zero value, the idle session with transaction which is idle over the value in seconds is killed by InnoDB."
@@ -12718,12 +12760,12 @@ static MYSQL_SYSVAR_LONG(open_files, innobase_open_files,
static MYSQL_SYSVAR_ULONG(sync_spin_loops, srv_n_spin_wait_rounds,
PLUGIN_VAR_RQCMDARG,
"Count of spin-loop rounds in InnoDB mutexes (30 by default)",
- NULL, NULL, 30L, 0L, ~ (ulong) 0L, 0);
+ NULL, NULL, 30L, 0L, ~0UL, 0);
static MYSQL_SYSVAR_ULONG(spin_wait_delay, srv_spin_wait_delay,
PLUGIN_VAR_OPCMDARG,
"Maximum delay between polling for a spin lock (6 by default)",
- NULL, NULL, 6L, 0L, ~ (ulong) 0L, 0);
+ NULL, NULL, 6L, 0L, ~0UL, 0);
static MYSQL_SYSVAR_BOOL(thread_concurrency_timer_based,
innobase_thread_concurrency_timer_based,
@@ -12739,7 +12781,7 @@ static MYSQL_SYSVAR_ULONG(thread_concurrency, srv_thread_concurrency,
static MYSQL_SYSVAR_ULONG(thread_sleep_delay, srv_thread_sleep_delay,
PLUGIN_VAR_RQCMDARG,
"Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep",
- NULL, NULL, 10000L, 0L, ~ (ulong) 0L, 0);
+ NULL, NULL, 10000L, 0L, ~0UL, 0);
static MYSQL_SYSVAR_STR(data_file_path, innobase_data_file_path,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
@@ -12914,7 +12956,7 @@ innodb_adaptive_flushing_method_update(
void* var_ptr,
const void* save)
{
- *(long *)var_ptr= (*(long *)save) % 4;
+ *(long *)var_ptr= (*(long *)save) % 3;
}
const char *adaptive_flushing_method_names[]=
{
@@ -13092,6 +13134,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(corrupt_table_action),
MYSQL_SYSVAR(lazy_drop_table),
MYSQL_SYSVAR(fake_changes),
+ MYSQL_SYSVAR(merge_sort_block_size),
NULL
};
@@ -13112,6 +13155,7 @@ maria_declare_plugin(xtradb)
MariaDB_PLUGIN_MATURITY_STABLE /* maturity */
},
i_s_innodb_rseg_maria,
+i_s_innodb_undo_logs_maria,
i_s_innodb_trx_maria,
i_s_innodb_locks_maria,
i_s_innodb_lock_waits_maria,
diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc
index 92e51d37d7d..0496cb98080 100644
--- a/storage/xtradb/handler/handler0alter.cc
+++ b/storage/xtradb/handler/handler0alter.cc
@@ -713,6 +713,10 @@ ha_innobase::add_index(
ut_a(indexed_table == prebuilt->table);
+ if (indexed_table->tablespace_discarded) {
+ DBUG_RETURN(-1);
+ }
+
/* Check that index keys are sensible */
error = innobase_check_index_keys(key_info, num_of_keys, prebuilt->table);
@@ -781,7 +785,7 @@ ha_innobase::add_index(
row_mysql_lock_data_dictionary(trx);
dict_locked = TRUE;
- ut_d(dict_table_check_for_dup_indexes(prebuilt->table, FALSE));
+ ut_d(dict_table_check_for_dup_indexes(prebuilt->table, TRUE));
/* If a new primary key is defined for the table we need
to drop the original table and rebuild all indexes. */
@@ -817,7 +821,7 @@ ha_innobase::add_index(
}
ut_d(dict_table_check_for_dup_indexes(prebuilt->table,
- FALSE));
+ TRUE));
mem_heap_free(heap);
trx_general_rollback_for_mysql(trx, NULL);
row_mysql_unlock_data_dictionary(trx);
@@ -1071,7 +1075,7 @@ ha_innobase::final_add_index(
trx_commit_for_mysql(prebuilt->trx);
}
- ut_d(dict_table_check_for_dup_indexes(prebuilt->table, FALSE));
+ ut_d(dict_table_check_for_dup_indexes(prebuilt->table, TRUE));
row_mysql_unlock_data_dictionary(trx);
trx_free_for_mysql(trx);
@@ -1118,7 +1122,7 @@ ha_innobase::prepare_drop_index(
/* Test and mark all the indexes to be dropped */
row_mysql_lock_data_dictionary(trx);
- ut_d(dict_table_check_for_dup_indexes(prebuilt->table, FALSE));
+ ut_d(dict_table_check_for_dup_indexes(prebuilt->table, TRUE));
/* Check that none of the indexes have previously been flagged
for deletion. */
@@ -1289,7 +1293,7 @@ func_exit:
} while (index);
}
- ut_d(dict_table_check_for_dup_indexes(prebuilt->table, FALSE));
+ ut_d(dict_table_check_for_dup_indexes(prebuilt->table, TRUE));
row_mysql_unlock_data_dictionary(trx);
DBUG_RETURN(err);
@@ -1342,7 +1346,7 @@ ha_innobase::final_drop_index(
prebuilt->table->flags, user_thd);
row_mysql_lock_data_dictionary(trx);
- ut_d(dict_table_check_for_dup_indexes(prebuilt->table, FALSE));
+ ut_d(dict_table_check_for_dup_indexes(prebuilt->table, TRUE));
if (UNIV_UNLIKELY(err)) {
@@ -1386,7 +1390,7 @@ ha_innobase::final_drop_index(
share->idx_trans_tbl.index_count = 0;
func_exit:
- ut_d(dict_table_check_for_dup_indexes(prebuilt->table, FALSE));
+ ut_d(dict_table_check_for_dup_indexes(prebuilt->table, TRUE));
trx_commit_for_mysql(trx);
trx_commit_for_mysql(prebuilt->trx);
row_mysql_unlock_data_dictionary(trx);
diff --git a/storage/xtradb/handler/i_s.cc b/storage/xtradb/handler/i_s.cc
index 7c60b0f7775..5d86ea98d27 100644
--- a/storage/xtradb/handler/i_s.cc
+++ b/storage/xtradb/handler/i_s.cc
@@ -49,6 +49,7 @@ extern "C" {
#include "trx0i_s.h"
#include "trx0trx.h" /* for TRX_QUE_STATE_STR_MAX_LEN */
#include "trx0rseg.h" /* for trx_rseg_struct */
+#include "trx0undo.h" /* for trx_undo_struct */
#include "trx0sys.h" /* for trx_sys */
#include "dict0dict.h" /* for dict_sys */
#include "buf0lru.h" /* for XTRA_LRU_[DUMP/RESTORE] */
@@ -4437,3 +4438,292 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_buffer_pool_pages_blob_maria =
NULL,
INNODB_VERSION_STR, MariaDB_PLUGIN_MATURITY_STABLE
};
+
+
+static ST_FIELD_INFO i_s_innodb_undo_logs_fields_info[] =
+{
+#define IDX_USEG_TRX_ID 0
+ {STRUCT_FLD(field_name, "trx_id"),
+ STRUCT_FLD(field_length, TRX_ID_MAX_LEN + 1),
+ STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, 0),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_USEG_RSEG_ID 1
+ {STRUCT_FLD(field_name, "rseg_id"),
+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_USEG_USEG_ID 2
+ {STRUCT_FLD(field_name, "useg_id"),
+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_USEG_TYPE 3
+#define USEG_TYPE_MAX_LEN 256
+ {STRUCT_FLD(field_name, "type"),
+ STRUCT_FLD(field_length, USEG_TYPE_MAX_LEN),
+ STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, 0),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+ #define IDX_USEG_STATE 4
+ #define USEG_STATE_MAX_LEN 256
+ {STRUCT_FLD(field_name, "state"),
+ STRUCT_FLD(field_length, USEG_STATE_MAX_LEN),
+ STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, 0),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_USEG_SIZE 5
+ {STRUCT_FLD(field_name, "size"),
+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+ END_OF_ST_FIELD_INFO
+};
+static
+int
+i_s_innodb_undo_logs_fill_store(
+/*=================*/
+ THD* thd, /* in: thread */
+ TABLE* table, /* in/out: table to fill */
+ trx_undo_t* useg) /* in: useg to fill from */
+{
+ char trx_id[TRX_ID_MAX_LEN + 1];
+
+ DBUG_ENTER("i_s_innodb_undo_logs_fill_store");
+
+ switch (useg->type) {
+ case TRX_UNDO_INSERT:
+ OK(field_store_string(table->field[IDX_USEG_TYPE], "INSERT"));
+ break;
+ case TRX_UNDO_UPDATE:
+ OK(field_store_string(table->field[IDX_USEG_TYPE], "UPDATE"));
+ break;
+ default:
+ OK(field_store_string(table->field[IDX_USEG_TYPE], "UNKNOWN"));
+ break;
+ }
+
+ ut_snprintf(trx_id, sizeof(trx_id), TRX_ID_FMT, useg->trx_id);
+
+ switch (useg->state) {
+ case TRX_UNDO_ACTIVE:
+ OK(field_store_string(table->field[IDX_USEG_TRX_ID], trx_id));
+ OK(field_store_string(table->field[IDX_USEG_STATE], "ACTIVE"));
+ break;
+ case TRX_UNDO_CACHED:
+ OK(field_store_string(table->field[IDX_USEG_TRX_ID], NULL));
+ OK(field_store_string(table->field[IDX_USEG_STATE], "CACHED"));
+ break;
+ case TRX_UNDO_TO_FREE:
+ OK(field_store_string(table->field[IDX_USEG_TRX_ID], NULL));
+ OK(field_store_string(table->field[IDX_USEG_STATE], "TO_FREE"));
+ break;
+ case TRX_UNDO_TO_PURGE:
+ OK(field_store_string(table->field[IDX_USEG_TRX_ID], NULL));
+ OK(field_store_string(table->field[IDX_USEG_STATE], "TO_PURGE"));
+ break;
+ case TRX_UNDO_PREPARED:
+ OK(field_store_string(table->field[IDX_USEG_TRX_ID], trx_id));
+ OK(field_store_string(table->field[IDX_USEG_STATE], "PREPARED"));
+ break;
+ default:
+ OK(field_store_string(table->field[IDX_USEG_TRX_ID], trx_id));
+ OK(field_store_string(table->field[IDX_USEG_STATE], "UNKNOWN"));
+ break;
+ }
+
+ table->field[IDX_USEG_RSEG_ID]->store(useg->rseg->id);
+ table->field[IDX_USEG_USEG_ID]->store(useg->id);
+ table->field[IDX_USEG_SIZE]->store(useg->size);
+ if (schema_table_store_record(thd, table)) {
+ DBUG_RETURN(1);
+ }
+ DBUG_RETURN(0);
+}
+static
+int
+i_s_innodb_undo_logs_fill(
+/*=================*/
+ THD* thd, /* in: thread */
+ TABLE_LIST* tables, /* in/out: tables to fill */
+ COND* cond) /* in: condition (ignored) */
+{
+ TABLE* table = (TABLE *) tables->table;
+ int status = 0;
+ trx_rseg_t* rseg;
+ trx_undo_t* useg;
+
+ DBUG_ENTER("i_s_innodb_undo_logs_fill");
+
+ /* deny access to non-superusers */
+ if (check_global_access(thd, PROCESS_ACL)) {
+ DBUG_RETURN(0);
+ }
+
+ RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name);
+
+ rseg = UT_LIST_GET_FIRST(trx_sys->rseg_list);
+ while (rseg && status == 0) {
+ mutex_enter(&(rseg->mutex));
+ useg = UT_LIST_GET_FIRST(rseg->update_undo_list);
+ while (useg && status == 0) {
+ status = i_s_innodb_undo_logs_fill_store(thd, table, useg);
+ useg = UT_LIST_GET_NEXT(undo_list, useg);
+ }
+
+ useg = UT_LIST_GET_FIRST(rseg->update_undo_cached);
+ while (useg && status == 0) {
+ status = i_s_innodb_undo_logs_fill_store(thd, table, useg);
+ useg = UT_LIST_GET_NEXT(undo_list, useg);
+ }
+
+ useg = UT_LIST_GET_FIRST(rseg->insert_undo_list);
+ while (useg && status == 0) {
+ status = i_s_innodb_undo_logs_fill_store(thd, table, useg);
+ useg = UT_LIST_GET_NEXT(undo_list, useg);
+ }
+
+ useg = UT_LIST_GET_FIRST(rseg->insert_undo_cached);
+ while (useg && status == 0) {
+ status = i_s_innodb_undo_logs_fill_store(thd, table, useg);
+ useg = UT_LIST_GET_NEXT(undo_list, useg);
+ }
+ mutex_exit(&(rseg->mutex));
+ rseg = UT_LIST_GET_NEXT(rseg_list, rseg);
+ }
+
+ DBUG_RETURN(status);
+}
+
+static
+int
+i_s_innodb_undo_logs_init(
+/*=================*/
+ /* out: 0 on success */
+ void* p) /* in/out: table schema object */
+{
+ DBUG_ENTER("i_s_innodb_undo_logs_init");
+ ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p;
+
+ schema->fields_info = i_s_innodb_undo_logs_fields_info;
+ schema->fill_table = i_s_innodb_undo_logs_fill;
+
+ DBUG_RETURN(0);
+}
+
+UNIV_INTERN struct st_mysql_plugin i_s_innodb_undo_logs =
+{
+ /* the plugin type (a MYSQL_XXX_PLUGIN value) */
+ /* int */
+ STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN),
+
+ /* pointer to type-specific plugin descriptor */
+ /* void* */
+ STRUCT_FLD(info, &i_s_info),
+
+ /* plugin name */
+ /* const char* */
+ STRUCT_FLD(name, "INNODB_UNDO_LOGS"),
+
+ /* plugin author (for SHOW PLUGINS) */
+ /* const char* */
+ STRUCT_FLD(author, "Percona"),
+
+ /* general descriptive text (for SHOW PLUGINS) */
+ /* const char* */
+ STRUCT_FLD(descr, "InnoDB rollback undo segment information"),
+
+ /* the plugin license (PLUGIN_LICENSE_XXX) */
+ /* int */
+ STRUCT_FLD(license, PLUGIN_LICENSE_GPL),
+
+ /* the function to invoke when plugin is loaded */
+ /* int (*)(void*); */
+ STRUCT_FLD(init, i_s_innodb_undo_logs_init),
+
+ /* the function to invoke when plugin is unloaded */
+ /* int (*)(void*); */ STRUCT_FLD(deinit, i_s_common_deinit),
+
+ /* plugin version (for SHOW PLUGINS) */
+ STRUCT_FLD(version, 0x0100 /* 1.0 */),
+
+ /* struct st_mysql_show_var* */
+ STRUCT_FLD(status_vars, NULL),
+
+ /* struct st_mysql_sys_var** */
+ STRUCT_FLD(system_vars, NULL),
+
+ /* reserved for dependency checking */
+ /* void* */
+ STRUCT_FLD(__reserved1, NULL),
+
+ /* Plugin flags */
+ /* unsigned long */
+ STRUCT_FLD(flags, 0UL),
+};
+
+UNIV_INTERN struct st_maria_plugin i_s_innodb_undo_logs_maria =
+{
+ /* the plugin type (a MYSQL_XXX_PLUGIN value) */
+ /* int */
+ STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN),
+
+ /* pointer to type-specific plugin descriptor */
+ /* void* */
+ STRUCT_FLD(info, &i_s_info),
+
+ /* plugin name */
+ /* const char* */
+ STRUCT_FLD(name, "INNODB_UNDO_LOGS"),
+
+ /* plugin author (for SHOW PLUGINS) */
+ /* const char* */
+ STRUCT_FLD(author, "Percona"),
+
+ /* general descriptive text (for SHOW PLUGINS) */
+ /* const char* */
+ STRUCT_FLD(descr, "InnoDB rollback undo segment information"),
+
+ /* the plugin license (PLUGIN_LICENSE_XXX) */
+ /* int */
+ STRUCT_FLD(license, PLUGIN_LICENSE_GPL),
+
+ /* the function to invoke when plugin is loaded */
+ /* int (*)(void*); */
+ STRUCT_FLD(init, i_s_innodb_undo_logs_init),
+
+ /* the function to invoke when plugin is unloaded */
+ /* int (*)(void*); */ STRUCT_FLD(deinit, i_s_common_deinit),
+
+ /* plugin version (for SHOW PLUGINS) */
+ STRUCT_FLD(version, 0x0100 /* 1.0 */),
+
+ /* struct st_mysql_show_var* */
+ STRUCT_FLD(status_vars, NULL),
+
+ /* struct st_mysql_sys_var** */
+ STRUCT_FLD(system_vars, NULL),
+
+ INNODB_VERSION_STR, MariaDB_PLUGIN_MATURITY_STABLE
+};
diff --git a/storage/xtradb/handler/i_s.h b/storage/xtradb/handler/i_s.h
index f39172ea0a9..329cc2f5f91 100644
--- a/storage/xtradb/handler/i_s.h
+++ b/storage/xtradb/handler/i_s.h
@@ -43,6 +43,7 @@ extern struct st_mysql_plugin i_s_innodb_sys_fields;
extern struct st_mysql_plugin i_s_innodb_sys_foreign;
extern struct st_mysql_plugin i_s_innodb_sys_foreign_cols;
extern struct st_mysql_plugin i_s_innodb_rseg;
+extern struct st_mysql_plugin i_s_innodb_undo_logs;
extern struct st_mysql_plugin i_s_innodb_sys_stats;
extern struct st_mysql_plugin i_s_innodb_table_stats;
extern struct st_mysql_plugin i_s_innodb_index_stats;
@@ -67,6 +68,7 @@ extern struct st_maria_plugin i_s_innodb_sys_foreign_maria;
extern struct st_maria_plugin i_s_innodb_sys_foreign_cols_maria;
extern struct st_maria_plugin i_s_innodb_sys_stats_maria;
extern struct st_maria_plugin i_s_innodb_rseg_maria;
+extern struct st_maria_plugin i_s_innodb_undo_logs_maria;
extern struct st_maria_plugin i_s_innodb_table_stats_maria;
extern struct st_maria_plugin i_s_innodb_index_stats_maria;
extern struct st_maria_plugin i_s_innodb_admin_command_maria;
diff --git a/storage/xtradb/include/btr0btr.h b/storage/xtradb/include/btr0btr.h
index 520527d0375..03e89ae3f7d 100644
--- a/storage/xtradb/include/btr0btr.h
+++ b/storage/xtradb/include/btr0btr.h
@@ -92,6 +92,8 @@ insert/delete buffer when the record is not in the buffer pool. */
buffer when the record is not in the buffer pool. */
#define BTR_DELETE 8192
+#endif /* UNIV_HOTBACKUP */
+
/**************************************************************//**
Report that an index page is corrupted. */
UNIV_INTERN
@@ -112,6 +114,7 @@ btr_corruption_report(
ut_error; \
}
+#ifndef UNIV_HOTBACKUP
#ifdef UNIV_BLOB_DEBUG
# include "ut0rbt.h"
/** An index->blobs entry for keeping track of off-page column references */
diff --git a/storage/xtradb/include/btr0types.h b/storage/xtradb/include/btr0types.h
index 6f515c3f58c..43c6b425688 100644
--- a/storage/xtradb/include/btr0types.h
+++ b/storage/xtradb/include/btr0types.h
@@ -39,6 +39,8 @@ typedef struct btr_cur_struct btr_cur_t;
/** B-tree search information for the adaptive hash index */
typedef struct btr_search_struct btr_search_t;
+#ifndef UNIV_HOTBACKUP
+
/** @brief The latch protecting the adaptive search system
This latch protects the
@@ -56,6 +58,8 @@ Bear in mind (3) and (4) when using the hash index.
extern rw_lock_t** btr_search_latch_part;
+#endif /* UNIV_HOTBACKUP */
+
/** The latch protecting the adaptive search system */
//#define btr_search_latch (*btr_search_latch_temp)
diff --git a/storage/xtradb/include/buf0buf.h b/storage/xtradb/include/buf0buf.h
index 5f8220de18d..1a4990be69f 100644
--- a/storage/xtradb/include/buf0buf.h
+++ b/storage/xtradb/include/buf0buf.h
@@ -608,34 +608,34 @@ ib_uint64_t
buf_block_get_modify_clock(
/*=======================*/
buf_block_t* block); /*!< in: block */
-#else /* !UNIV_HOTBACKUP */
-# define buf_block_modify_clock_inc(block) ((void) 0)
-#endif /* !UNIV_HOTBACKUP */
/*******************************************************************//**
Increments the bufferfix count. */
UNIV_INLINE
void
buf_block_buf_fix_inc_func(
/*=======================*/
-#ifdef UNIV_SYNC_DEBUG
+# ifdef UNIV_SYNC_DEBUG
const char* file, /*!< in: file name */
ulint line, /*!< in: line */
-#endif /* UNIV_SYNC_DEBUG */
+# endif /* UNIV_SYNC_DEBUG */
buf_block_t* block) /*!< in/out: block to bufferfix */
__attribute__((nonnull));
-#ifdef UNIV_SYNC_DEBUG
+# ifdef UNIV_SYNC_DEBUG
/** Increments the bufferfix count.
@param b in/out: block to bufferfix
@param f in: file name where requested
@param l in: line number where requested */
# define buf_block_buf_fix_inc(b,f,l) buf_block_buf_fix_inc_func(f,l,b)
-#else /* UNIV_SYNC_DEBUG */
+# else /* UNIV_SYNC_DEBUG */
/** Increments the bufferfix count.
@param b in/out: block to bufferfix
@param f in: file name where requested
@param l in: line number where requested */
# define buf_block_buf_fix_inc(b,f,l) buf_block_buf_fix_inc_func(b)
-#endif /* UNIV_SYNC_DEBUG */
+# endif /* UNIV_SYNC_DEBUG */
+#else /* !UNIV_HOTBACKUP */
+# define buf_block_modify_clock_inc(block) ((void) 0)
+#endif /* !UNIV_HOTBACKUP */
/********************************************************************//**
Calculates a page checksum which is stored to the page when it is written
to a file. Note that we must be careful to calculate the same value
@@ -1193,9 +1193,10 @@ buf_page_init_for_read(
ulint offset);/*!< in: page number */
/********************************************************************//**
Completes an asynchronous read or write request of a file page to or from
-the buffer pool. */
+the buffer pool.
+@return TRUE if successful */
UNIV_INTERN
-void
+ibool
buf_page_io_complete(
/*=================*/
buf_page_t* bpage); /*!< in: pointer to the block in question */
diff --git a/storage/xtradb/include/buf0buf.ic b/storage/xtradb/include/buf0buf.ic
index 66006d366c6..6595e86a8fe 100644
--- a/storage/xtradb/include/buf0buf.ic
+++ b/storage/xtradb/include/buf0buf.ic
@@ -31,6 +31,7 @@ Created 11/5/1995 Heikki Tuuri
*******************************************************/
#include "mtr0mtr.h"
+#ifndef UNIV_HOTBACKUP
#include "buf0flu.h"
#include "buf0lru.h"
#include "buf0rea.h"
@@ -180,6 +181,7 @@ buf_page_peek_if_too_old(
return(!buf_page_peek_if_young(bpage));
}
}
+#endif /* !UNIV_HOTBACKUP */
/*********************************************************************//**
Gets the state of a block.
diff --git a/storage/xtradb/include/dict0dict.h b/storage/xtradb/include/dict0dict.h
index 6974e480144..de3605b1dfb 100644
--- a/storage/xtradb/include/dict0dict.h
+++ b/storage/xtradb/include/dict0dict.h
@@ -750,6 +750,7 @@ ulint
dict_table_zip_size(
/*================*/
const dict_table_t* table); /*!< in: table */
+#ifndef UNIV_HOTBACKUP
/*********************************************************************//**
Obtain exclusive locks on all index trees of the table. This is to prevent
accessing index trees while InnoDB is updating internal metadata for
@@ -766,6 +767,7 @@ void
dict_table_x_unlock_indexes(
/*========================*/
dict_table_t* table); /*!< in: table */
+#endif /* !UNIV_HOTBACKUP */
/********************************************************************//**
Checks if a column is in the ordering columns of the clustered index of a
table. Column prefixes are treated like whole columns.
@@ -1278,7 +1280,7 @@ UNIV_INTERN
void
dict_close(void);
/*============*/
-
+#ifndef UNIV_HOTBACKUP
/**********************************************************************//**
Check whether the table is corrupted.
@return nonzero for corrupted table, zero for valid tables */
@@ -1299,6 +1301,7 @@ dict_index_is_corrupted(
const dict_index_t* index) /*!< in: index */
__attribute__((nonnull, pure, warn_unused_result));
+#endif /* !UNIV_HOTBACKUP */
/**********************************************************************//**
Flags an index and table corrupted both in the data dictionary cache
and in the system table SYS_INDEXES. */
diff --git a/storage/xtradb/include/dict0dict.ic b/storage/xtradb/include/dict0dict.ic
index 5ed9b182d6c..02eafcc5d9c 100644
--- a/storage/xtradb/include/dict0dict.ic
+++ b/storage/xtradb/include/dict0dict.ic
@@ -491,6 +491,7 @@ dict_table_zip_size(
return(dict_table_flags_to_zip_size(table->flags));
}
+#ifndef UNIV_HOTBACKUP
/*********************************************************************//**
Obtain exclusive locks on all index trees of the table. This is to prevent
accessing index trees while InnoDB is updating internal metadata for
@@ -533,6 +534,7 @@ dict_table_x_unlock_indexes(
rw_lock_x_unlock(dict_index_get_lock(index));
}
}
+#endif /* !UNIV_HOTBACKUP */
/********************************************************************//**
Gets the number of fields in the internal representation of an index,
including fields added by the dictionary system.
diff --git a/storage/xtradb/include/ha_prototypes.h b/storage/xtradb/include/ha_prototypes.h
index 2e200ba7f43..2907365a32a 100644
--- a/storage/xtradb/include/ha_prototypes.h
+++ b/storage/xtradb/include/ha_prototypes.h
@@ -312,4 +312,15 @@ innobase_get_lower_case_table_names(void);
/*=====================================*/
+/********************************************************************//**
+Returns the merge-sort block size used for the secondary index creation
+for the current connection.
+@return the merge-sort block size, in bytes */
+
+ulong
+thd_merge_sort_block_size(
+/*======================*/
+ void* thd); /*!< in: thread handle (THD*), or NULL to query
+ the global merge_sort_block_size */
+
#endif
diff --git a/storage/xtradb/include/log0log.h b/storage/xtradb/include/log0log.h
index 6b1c2859cf7..857ec0946c2 100644
--- a/storage/xtradb/include/log0log.h
+++ b/storage/xtradb/include/log0log.h
@@ -780,7 +780,6 @@ struct log_struct{
buffer */
#ifndef UNIV_HOTBACKUP
mutex_t mutex; /*!< mutex protecting the log */
-#endif /* !UNIV_HOTBACKUP */
mutex_t log_flush_order_mutex;/*!< mutex to serialize access to
the flush list when we are putting
@@ -790,6 +789,7 @@ struct log_struct{
mtr_commit and still ensure that
insertions in the flush_list happen
in the LSN order. */
+#endif /* !UNIV_HOTBACKUP */
byte* buf_ptr; /* unaligned log buffer */
byte* buf; /*!< log buffer */
ulint buf_size; /*!< log buffer size in bytes */
diff --git a/storage/xtradb/include/os0file.h b/storage/xtradb/include/os0file.h
index b153b0dba7f..5b1f9339845 100644
--- a/storage/xtradb/include/os0file.h
+++ b/storage/xtradb/include/os0file.h
@@ -316,7 +316,7 @@ to original un-instrumented file I/O APIs */
os_file_create_func(name, create, purpose, type, success)
# define os_file_create_simple(key, name, create, access, success) \
- os_file_create_simple_func(name, create_mode, access, success)
+ os_file_create_simple_func(name, create, access, success)
# define os_file_create_simple_no_error_handling( \
key, name, create_mode, access, success) \
diff --git a/storage/xtradb/include/srv0srv.h b/storage/xtradb/include/srv0srv.h
index d99fbfb9463..a40683e00f1 100644
--- a/storage/xtradb/include/srv0srv.h
+++ b/storage/xtradb/include/srv0srv.h
@@ -117,13 +117,13 @@ extern ulint srv_max_file_format_at_startup;
/** Place locks to records only i.e. do not use next-key locking except
on duplicate key checking and foreign key checking */
extern ibool srv_locks_unsafe_for_binlog;
-#endif /* !UNIV_HOTBACKUP */
/* If this flag is TRUE, then we will use the native aio of the
OS (provided we compiled Innobase with it in), otherwise we will
use simulated aio we build below with threads.
Currently we support native aio on windows and linux */
extern my_bool srv_use_native_aio;
+#endif /* !UNIV_HOTBACKUP */
#ifdef __WIN__
extern ibool srv_use_native_conditions;
#endif
diff --git a/storage/xtradb/include/trx0sys.h b/storage/xtradb/include/trx0sys.h
index 976cb31563f..c933fb405e1 100644
--- a/storage/xtradb/include/trx0sys.h
+++ b/storage/xtradb/include/trx0sys.h
@@ -248,7 +248,6 @@ UNIV_INLINE
trx_id_t
trx_sys_get_new_trx_id(void);
/*========================*/
-#endif /* !UNIV_HOTBACKUP */
#ifdef UNIV_DEBUG
/* Flag to control TRX_RSEG_N_SLOTS behavior debugging. */
@@ -265,7 +264,6 @@ trx_write_trx_id(
/*=============*/
byte* ptr, /*!< in: pointer to memory where written */
trx_id_t id); /*!< in: id */
-#ifndef UNIV_HOTBACKUP
/*****************************************************************//**
Reads a trx id from an index page. In case that the id size changes in
some future version, this function should be used instead of
@@ -603,7 +601,6 @@ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_NO. */
#define TRX_SYS_DOUBLEWRITE_BLOCK_SIZE FSP_EXTENT_SIZE
/* @} */
-#ifndef UNIV_HOTBACKUP
/** File format tag */
/* @{ */
/** The offset of the file format tag on the trx system header page
@@ -622,6 +619,7 @@ identifier is added to this 64-bit constant. */
| TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW)
/* @} */
+#ifndef UNIV_HOTBACKUP
/** Doublewrite control struct */
struct trx_doublewrite_struct{
mutex_t mutex; /*!< mutex protecting the first_free field and
diff --git a/storage/xtradb/include/univ.i b/storage/xtradb/include/univ.i
index d54b467d2c1..ce59a3f2741 100644
--- a/storage/xtradb/include/univ.i
+++ b/storage/xtradb/include/univ.i
@@ -54,7 +54,7 @@ Created 1/20/1994 Heikki Tuuri
#define INNODB_VERSION_BUGFIX 8
#ifndef PERCONA_INNODB_VERSION
-#define PERCONA_INNODB_VERSION 27.0
+#define PERCONA_INNODB_VERSION 28.1
#endif
/* The following is the InnoDB version as shown in
diff --git a/storage/xtradb/mem/mem0dbg.c b/storage/xtradb/mem/mem0dbg.c
index ae43d6097a6..0909b7c9a64 100644
--- a/storage/xtradb/mem/mem0dbg.c
+++ b/storage/xtradb/mem/mem0dbg.c
@@ -24,7 +24,9 @@ but is included in mem0mem.* !
Created 6/9/1994 Heikki Tuuri
*************************************************************************/
-#include "ha_prototypes.h"
+#ifndef UNIV_HOTBACKUP
+# include "ha_prototypes.h"
+#endif /* !UNIV_HOTBACKUP */
#ifdef UNIV_MEM_DEBUG
# ifndef UNIV_HOTBACKUP
diff --git a/storage/xtradb/os/os0file.c b/storage/xtradb/os/os0file.c
index 5d249d52ce9..061d556c6e7 100644
--- a/storage/xtradb/os/os0file.c
+++ b/storage/xtradb/os/os0file.c
@@ -303,6 +303,7 @@ UNIV_INTERN ulint os_n_pending_writes = 0;
UNIV_INTERN ulint os_n_pending_reads = 0;
#ifdef UNIV_DEBUG
+# ifndef UNIV_HOTBACKUP
/**********************************************************************//**
Validates the consistency the aio system some of the time.
@return TRUE if ok or the check was skipped */
@@ -329,6 +330,7 @@ os_aio_validate_skip(void)
os_aio_validate_count = OS_AIO_VALIDATE_SKIP;
return(os_aio_validate());
}
+# endif /* !UNIV_HOTBACKUP */
#endif /* UNIV_DEBUG */
#ifdef _WIN32
diff --git a/storage/xtradb/page/page0zip.c b/storage/xtradb/page/page0zip.c
index d4b0dd8339d..4751f4816a9 100644
--- a/storage/xtradb/page/page0zip.c
+++ b/storage/xtradb/page/page0zip.c
@@ -4437,7 +4437,9 @@ page_zip_reorganize(
dict_index_t* index, /*!< in: index of the B-tree node */
mtr_t* mtr) /*!< in: mini-transaction */
{
+#ifndef UNIV_HOTBACKUP
buf_pool_t* buf_pool = buf_pool_from_block(block);
+#endif /* !UNIV_HOTBACKUP */
page_zip_des_t* page_zip = buf_block_get_page_zip(block);
page_t* page = buf_block_get_frame(block);
buf_block_t* temp_block;
diff --git a/storage/xtradb/row/row0ins.c b/storage/xtradb/row/row0ins.c
index a629a4fb195..b21d48c7552 100644
--- a/storage/xtradb/row/row0ins.c
+++ b/storage/xtradb/row/row0ins.c
@@ -1281,7 +1281,8 @@ run_again:
check_index = foreign->foreign_index;
}
- if (check_table == NULL || check_table->ibd_file_missing) {
+ if (check_table == NULL || check_table->ibd_file_missing
+ || check_index == NULL) {
if (check_ref) {
FILE* ef = dict_foreign_err_file;
@@ -1316,9 +1317,6 @@ run_again:
goto exit_func;
}
- ut_a(check_table);
- ut_a(check_index);
-
if (check_table != table) {
/* We already have a LOCK_IX on table, but not necessarily
on check_table */
diff --git a/storage/xtradb/row/row0merge.c b/storage/xtradb/row/row0merge.c
index f00706da0d3..c7d6304d6a7 100644
--- a/storage/xtradb/row/row0merge.c
+++ b/storage/xtradb/row/row0merge.c
@@ -89,8 +89,9 @@ rounded to a power of 2.
When not creating a PRIMARY KEY that contains column prefixes, this
can be set as small as UNIV_PAGE_SIZE / 2. See the comment above
-ut_ad(data_size < sizeof(row_merge_block_t)). */
-typedef byte row_merge_block_t[1048576];
+ut_ad(data_size < sizeof(row_merge_block_t)).
+1MB is the default merge-sort block size for innodb */
+typedef byte* row_merge_block_t;
/** @brief Secondary buffer for I/O operations of merge records.
@@ -184,7 +185,6 @@ row_merge_buf_create_low(
row_merge_buf_t* buf;
ut_ad(max_tuples > 0);
- ut_ad(max_tuples <= sizeof(row_merge_block_t));
ut_ad(max_tuples < buf_size);
buf = mem_heap_zalloc(heap, buf_size);
@@ -205,19 +205,19 @@ static
row_merge_buf_t*
row_merge_buf_create(
/*=================*/
- dict_index_t* index) /*!< in: secondary index */
+ dict_index_t* index, /*!< in: secondary index */
+ ulint block_size) /*!< in: merge block buffer size */
{
row_merge_buf_t* buf;
ulint max_tuples;
ulint buf_size;
mem_heap_t* heap;
- max_tuples = sizeof(row_merge_block_t)
- / ut_max(1, dict_index_get_min_size(index));
+ max_tuples = block_size / ut_max(1, dict_index_get_min_size(index));
buf_size = (sizeof *buf) + (max_tuples - 1) * sizeof *buf->tuples;
- heap = mem_heap_create(buf_size + sizeof(row_merge_block_t));
+ heap = mem_heap_create(buf_size + block_size);
buf = row_merge_buf_create_low(heap, index, max_tuples, buf_size);
@@ -265,8 +265,10 @@ row_merge_buf_add(
/*==============*/
row_merge_buf_t* buf, /*!< in/out: sort buffer */
const dtuple_t* row, /*!< in: row in clustered index */
- const row_ext_t* ext) /*!< in: cache of externally stored
+ const row_ext_t* ext, /*!< in: cache of externally stored
column prefixes, or NULL */
+ ulint block_size)
+ /*!< in: merge block buffer size */
{
ulint i;
ulint n_fields;
@@ -391,10 +393,10 @@ row_merge_buf_add(
page_zip_rec_needs_ext() limit. However, no further columns
will be moved to external storage until the record is inserted
to the clustered index B-tree. */
- ut_ad(data_size < sizeof(row_merge_block_t));
+ ut_ad(data_size < block_size);
/* Reserve one byte for the end marker of row_merge_block_t. */
- if (buf->total_size + data_size >= sizeof(row_merge_block_t) - 1) {
+ if (buf->total_size + data_size >= block_size - 1) {
return(FALSE);
}
@@ -700,9 +702,11 @@ row_merge_read(
ulint offset, /*!< in: offset where to read
in number of row_merge_block_t
elements */
- row_merge_block_t* buf) /*!< out: data */
+ row_merge_block_t buf, /*!< out: data */
+ ulint block_size)
+ /*!< in: merge block buffer size */
{
- ib_uint64_t ofs = ((ib_uint64_t) offset) * sizeof *buf;
+ ib_uint64_t ofs = ((ib_uint64_t) offset) * block_size;
ibool success;
#ifdef UNIV_DEBUG
@@ -715,7 +719,7 @@ row_merge_read(
success = os_file_read_no_error_handling(OS_FILE_FROM_FD(fd), buf,
(ulint) (ofs & 0xFFFFFFFF),
(ulint) (ofs >> 32),
- sizeof *buf);
+ block_size);
#ifdef POSIX_FADV_DONTNEED
/* Each block is read exactly once. Free up the file cache. */
posix_fadvise(fd, ofs, sizeof *buf, POSIX_FADV_DONTNEED);
@@ -740,16 +744,17 @@ row_merge_write(
int fd, /*!< in: file descriptor */
ulint offset, /*!< in: offset where to write,
in number of row_merge_block_t elements */
- const void* buf) /*!< in: data */
+ const void* buf, /*!< in: data */
+ ulint block_size)
+ /*!< in: merge block buffer size */
{
- size_t buf_len = sizeof(row_merge_block_t);
- ib_uint64_t ofs = buf_len * (ib_uint64_t) offset;
+ ib_uint64_t ofs = block_size * (ib_uint64_t) offset;
ibool ret;
ret = os_file_write("(merge)", OS_FILE_FROM_FD(fd), buf,
(ulint) (ofs & 0xFFFFFFFF),
(ulint) (ofs >> 32),
- buf_len);
+ block_size);
#ifdef UNIV_DEBUG
if (row_merge_print_block_write) {
@@ -761,7 +766,7 @@ row_merge_write(
#ifdef POSIX_FADV_DONTNEED
/* The block will be needed on the next merge pass,
but it can be evicted from the file cache meanwhile. */
- posix_fadvise(fd, ofs, buf_len, POSIX_FADV_DONTNEED);
+ posix_fadvise(fd, ofs, block_size, POSIX_FADV_DONTNEED);
#endif /* POSIX_FADV_DONTNEED */
return(UNIV_LIKELY(ret));
@@ -783,7 +788,9 @@ row_merge_read_rec(
const mrec_t** mrec, /*!< out: pointer to merge record,
or NULL on end of list
(non-NULL on I/O error) */
- ulint* offsets)/*!< out: offsets of mrec */
+ ulint* offsets,/*!< out: offsets of mrec */
+ ulint block_size)
+ /*!< in: merge block buffer size */
{
ulint extra_size;
ulint data_size;
@@ -820,7 +827,8 @@ row_merge_read_rec(
/* Read another byte of extra_size. */
if (UNIV_UNLIKELY(b >= block[1])) {
- if (!row_merge_read(fd, ++(*foffs), block)) {
+ if (!row_merge_read(fd, ++(*foffs), block[0],
+ block_size)) {
err_exit:
/* Signal I/O error. */
*mrec = b;
@@ -849,7 +857,8 @@ err_exit:
memcpy(*buf, b, avail_size);
- if (!row_merge_read(fd, ++(*foffs), block)) {
+ if (!row_merge_read(fd, ++(*foffs), block[0],
+ block_size)) {
goto err_exit;
}
@@ -870,7 +879,7 @@ err_exit:
/* These overflows should be impossible given that
records are much smaller than either buffer, and
the record starts near the beginning of each buffer. */
- ut_a(extra_size + data_size < sizeof *buf);
+ ut_a(extra_size + data_size < block_size);
ut_a(b + data_size < block[1]);
/* Copy the data bytes. */
@@ -885,7 +894,7 @@ err_exit:
rec_init_offsets_comp_ordinary(*mrec, 0, index, offsets);
data_size = rec_offs_data_size(offsets);
- ut_ad(extra_size + data_size < sizeof *buf);
+ ut_ad(extra_size + data_size < block_size);
b += extra_size + data_size;
@@ -910,7 +919,8 @@ err_exit:
offsets[3] = (ulint) index;
#endif /* UNIV_DEBUG */
- if (!row_merge_read(fd, ++(*foffs), block)) {
+ if (!row_merge_read(fd, ++(*foffs), block[0],
+ block_size)) {
goto err_exit;
}
@@ -992,7 +1002,9 @@ row_merge_write_rec(
int fd, /*!< in: file descriptor */
ulint* foffs, /*!< in/out: file offset */
const mrec_t* mrec, /*!< in: record to write */
- const ulint* offsets)/*!< in: offsets of mrec */
+ const ulint* offsets,/*!< in: offsets of mrec */
+ ulint block_size)
+ /*!< in: merge block buffer size */
{
ulint extra_size;
ulint size;
@@ -1027,11 +1039,12 @@ row_merge_write_rec(
record to the head of the new block. */
memcpy(b, buf[0], avail_size);
- if (!row_merge_write(fd, (*foffs)++, block)) {
+ if (!row_merge_write(fd, (*foffs)++, block[0],
+ block_size)) {
return(NULL);
}
- UNIV_MEM_INVALID(block[0], sizeof block[0]);
+ UNIV_MEM_INVALID(block[0], block_size);
/* Copy the rest. */
b = block[0];
@@ -1056,7 +1069,9 @@ row_merge_write_eof(
row_merge_block_t* block, /*!< in/out: file buffer */
byte* b, /*!< in: pointer to end of block */
int fd, /*!< in: file descriptor */
- ulint* foffs) /*!< in/out: file offset */
+ ulint* foffs, /*!< in/out: file offset */
+ ulint block_size)
+ /*!< in: merge block buffer size */
{
ut_ad(block);
ut_ad(b >= block[0]);
@@ -1071,18 +1086,19 @@ row_merge_write_eof(
*b++ = 0;
UNIV_MEM_ASSERT_RW(block[0], b - block[0]);
- UNIV_MEM_ASSERT_W(block[0], sizeof block[0]);
+ UNIV_MEM_ASSERT_W(block[0], block_size);
#ifdef UNIV_DEBUG_VALGRIND
/* The rest of the block is uninitialized. Initialize it
to avoid bogus warnings. */
memset(b, 0xff, block[1] - b);
#endif /* UNIV_DEBUG_VALGRIND */
- if (!row_merge_write(fd, (*foffs)++, block)) {
+ if (!row_merge_write(fd, (*foffs)++, block[0],
+ block_size)) {
return(NULL);
}
- UNIV_MEM_INVALID(block[0], sizeof block[0]);
+ UNIV_MEM_INVALID(block[0], block_size);
return(block[0]);
}
@@ -1140,7 +1156,9 @@ row_merge_read_clustered_index(
dict_index_t** index, /*!< in: indexes to be created */
merge_file_t* files, /*!< in: temporary files */
ulint n_index,/*!< in: number of indexes to create */
- row_merge_block_t* block) /*!< in/out: file buffer */
+ row_merge_block_t* block, /*!< in/out: file buffer */
+ ulint block_size)
+ /*!< in: merge block buffer size */
{
dict_index_t* clust_index; /* Clustered index */
mem_heap_t* row_heap; /* Heap memory to create
@@ -1168,7 +1186,7 @@ row_merge_read_clustered_index(
merge_buf = mem_alloc(n_index * sizeof *merge_buf);
for (i = 0; i < n_index; i++) {
- merge_buf[i] = row_merge_buf_create(index[i]);
+ merge_buf[i] = row_merge_buf_create(index[i], block_size);
}
mtr_start(&mtr);
@@ -1300,7 +1318,8 @@ row_merge_read_clustered_index(
const dict_index_t* index = buf->index;
if (UNIV_LIKELY
- (row && row_merge_buf_add(buf, row, ext))) {
+ (row && row_merge_buf_add(buf, row, ext,
+ block_size))) {
file->n_rec++;
continue;
}
@@ -1335,12 +1354,12 @@ err_exit:
row_merge_buf_write(buf, file, block);
if (!row_merge_write(file->fd, file->offset++,
- block)) {
+ block[0], block_size)) {
err = DB_OUT_OF_FILE_SPACE;
goto err_exit;
}
- UNIV_MEM_INVALID(block[0], sizeof block[0]);
+ UNIV_MEM_INVALID(block[0], block_size);
merge_buf[i] = row_merge_buf_empty(buf);
if (UNIV_LIKELY(row != NULL)) {
@@ -1349,7 +1368,8 @@ err_exit:
and emptied. */
if (UNIV_UNLIKELY
- (!row_merge_buf_add(buf, row, ext))) {
+ (!row_merge_buf_add(buf, row, ext,
+ block_size))) {
/* An empty buffer should have enough
room for at least one record. */
ut_error;
@@ -1393,14 +1413,16 @@ func_exit:
do { \
b2 = row_merge_write_rec(&block[2], &buf[2], b2, \
of->fd, &of->offset, \
- mrec##N, offsets##N); \
+ mrec##N, offsets##N, \
+ block_size); \
if (UNIV_UNLIKELY(!b2 || ++of->n_rec > file->n_rec)) { \
goto corrupt; \
} \
b##N = row_merge_read_rec(&block[N], &buf[N], \
b##N, index, \
file->fd, foffs##N, \
- &mrec##N, offsets##N); \
+ &mrec##N, offsets##N, \
+ block_size); \
if (UNIV_UNLIKELY(!b##N)) { \
if (mrec##N) { \
goto corrupt; \
@@ -1425,9 +1447,11 @@ row_merge_blocks(
ulint* foffs1, /*!< in/out: offset of second
source list in the file */
merge_file_t* of, /*!< in/out: output file */
- struct TABLE* table) /*!< in/out: MySQL table, for
+ struct TABLE* table, /*!< in/out: MySQL table, for
reporting erroneous key value
if applicable */
+ ulint block_size)
+ /*!< in: merge block buffer size */
{
mem_heap_t* heap; /*!< memory heap for offsets0, offsets1 */
@@ -1457,8 +1481,10 @@ row_merge_blocks(
/* Write a record and read the next record. Split the output
file in two halves, which can be merged on the following pass. */
- if (!row_merge_read(file->fd, *foffs0, &block[0])
- || !row_merge_read(file->fd, *foffs1, &block[1])) {
+ if (!row_merge_read(file->fd, *foffs0, block[0],
+ block_size)
+ || !row_merge_read(file->fd, *foffs1, block[1],
+ block_size)) {
corrupt:
mem_heap_free(heap);
return(DB_CORRUPTION);
@@ -1469,9 +1495,9 @@ corrupt:
b2 = block[2];
b0 = row_merge_read_rec(&block[0], &buf[0], b0, index, file->fd,
- foffs0, &mrec0, offsets0);
+ foffs0, &mrec0, offsets0, block_size);
b1 = row_merge_read_rec(&block[1], &buf[1], b1, index, file->fd,
- foffs1, &mrec1, offsets1);
+ foffs1, &mrec1, offsets1, block_size);
if (UNIV_UNLIKELY(!b0 && mrec0)
|| UNIV_UNLIKELY(!b1 && mrec1)) {
@@ -1521,7 +1547,8 @@ done0:
done1:
mem_heap_free(heap);
- b2 = row_merge_write_eof(&block[2], b2, of->fd, &of->offset);
+ b2 = row_merge_write_eof(&block[2], b2, of->fd, &of->offset,
+ block_size);
return(b2 ? DB_SUCCESS : DB_CORRUPTION);
}
@@ -1536,7 +1563,9 @@ row_merge_blocks_copy(
const merge_file_t* file, /*!< in: input file */
row_merge_block_t* block, /*!< in/out: 3 buffers */
ulint* foffs0, /*!< in/out: input file offset */
- merge_file_t* of) /*!< in/out: output file */
+ merge_file_t* of, /*!< in/out: output file */
+ ulint block_size)
+ /*!< in: merge block buffer size */
{
mem_heap_t* heap; /*!< memory heap for offsets0, offsets1 */
@@ -1563,7 +1592,7 @@ row_merge_blocks_copy(
/* Write a record and read the next record. Split the output
file in two halves, which can be merged on the following pass. */
- if (!row_merge_read(file->fd, *foffs0, &block[0])) {
+ if (!row_merge_read(file->fd, *foffs0, block[0], block_size)) {
corrupt:
mem_heap_free(heap);
return(FALSE);
@@ -1573,7 +1602,7 @@ corrupt:
b2 = block[2];
b0 = row_merge_read_rec(&block[0], &buf[0], b0, index, file->fd,
- foffs0, &mrec0, offsets0);
+ foffs0, &mrec0, offsets0, block_size);
if (UNIV_UNLIKELY(!b0 && mrec0)) {
goto corrupt;
@@ -1592,8 +1621,8 @@ done0:
(*foffs0)++;
mem_heap_free(heap);
- return(row_merge_write_eof(&block[2], b2, of->fd, &of->offset)
- != NULL);
+ return(row_merge_write_eof(&block[2], b2, of->fd, &of->offset,
+ block_size) != NULL);
}
/*************************************************************//**
@@ -1614,9 +1643,10 @@ row_merge(
if applicable */
ulint* num_run,/*!< in/out: Number of runs remain
to be merged */
- ulint* run_offset) /*!< in/out: Array contains the
+ ulint* run_offset, /*!< in/out: Array contains the
first offset number for each merge
run */
+ ulint block_size) /*!< in: merge block buffer size */
{
ulint foffs0; /*!< first input offset */
ulint foffs1; /*!< second input offset */
@@ -1627,7 +1657,7 @@ row_merge(
ulint n_run = 0;
/*!< num of runs generated from this merge */
- UNIV_MEM_ASSERT_W(block[0], 3 * sizeof block[0]);
+ UNIV_MEM_ASSERT_W(block[0], 3 * block_size);
ut_ad(ihalf < file->offset);
@@ -1659,7 +1689,8 @@ row_merge(
run_offset[n_run++] = of.offset;
error = row_merge_blocks(index, file, block,
- &foffs0, &foffs1, &of, table);
+ &foffs0, &foffs1, &of, table,
+ block_size);
if (error != DB_SUCCESS) {
return(error);
@@ -1677,7 +1708,8 @@ row_merge(
/* Remember the offset number for this run */
run_offset[n_run++] = of.offset;
- if (!row_merge_blocks_copy(index, file, block, &foffs0, &of)) {
+ if (!row_merge_blocks_copy(index, file, block, &foffs0, &of,
+ block_size)) {
return(DB_CORRUPTION);
}
}
@@ -1692,7 +1724,8 @@ row_merge(
/* Remember the offset number for this run */
run_offset[n_run++] = of.offset;
- if (!row_merge_blocks_copy(index, file, block, &foffs1, &of)) {
+ if (!row_merge_blocks_copy(index, file, block, &foffs1, &of,
+ block_size)) {
return(DB_CORRUPTION);
}
}
@@ -1721,7 +1754,7 @@ row_merge(
*tmpfd = file->fd;
*file = of;
- UNIV_MEM_INVALID(block[0], 3 * sizeof block[0]);
+ UNIV_MEM_INVALID(block[0], 3 * block_size);
return(DB_SUCCESS);
}
@@ -1739,9 +1772,11 @@ row_merge_sort(
index entries */
row_merge_block_t* block, /*!< in/out: 3 buffers */
int* tmpfd, /*!< in/out: temporary file handle */
- struct TABLE* table) /*!< in/out: MySQL table, for
+ struct TABLE* table, /*!< in/out: MySQL table, for
reporting erroneous key value
if applicable */
+ ulint block_size)
+ /*!< in: merge block buffer size */
{
ulint half = file->offset / 2;
ulint num_runs;
@@ -1770,7 +1805,7 @@ row_merge_sort(
/* Merge the runs until we have one big run */
do {
error = row_merge(trx, index, file, block, tmpfd,
- table, &num_runs, run_offset);
+ table, &num_runs, run_offset, block_size);
UNIV_MEM_ASSERT_RW(run_offset, num_runs * sizeof *run_offset);
@@ -1841,7 +1876,9 @@ row_merge_insert_index_tuples(
ulint zip_size,/*!< in: compressed page size of
the old table, or 0 if uncompressed */
int fd, /*!< in: file descriptor */
- row_merge_block_t* block) /*!< in/out: file buffer */
+ row_merge_block_t* block, /*!< in/out: file buffer */
+ ulint block_size)
+ /*! in: merge block buffer size */
{
const byte* b;
que_thr_t* thr;
@@ -1880,7 +1917,7 @@ row_merge_insert_index_tuples(
b = *block;
- if (!row_merge_read(fd, foffs, block)) {
+ if (!row_merge_read(fd, foffs, block[0], block_size)) {
error = DB_CORRUPTION;
} else {
mrec_buf_t* buf = mem_heap_alloc(graph_heap, sizeof *buf);
@@ -1891,7 +1928,8 @@ row_merge_insert_index_tuples(
ulint n_ext;
b = row_merge_read_rec(block, buf, b, index,
- fd, &foffs, &mrec, offsets);
+ fd, &foffs, &mrec, offsets,
+ block_size);
if (UNIV_UNLIKELY(!b)) {
/* End of list, or I/O error */
if (mrec) {
@@ -2656,11 +2694,16 @@ row_merge_build_indexes(
if applicable */
{
merge_file_t* merge_files;
- row_merge_block_t* block;
+ /* Some code uses block[1] as the synonym for block + block_size. So
+ we initialize block[3] to the address boundary of block[2], even
+ though space for 3 only buffers is allocated. */
+ row_merge_block_t block[4];
ulint block_size;
ulint i;
ulint error;
int tmpfd;
+ ulint merge_sort_block_size;
+ void* block_mem;
ut_ad(trx);
ut_ad(old_table);
@@ -2668,14 +2711,21 @@ row_merge_build_indexes(
ut_ad(indexes);
ut_ad(n_indexes);
+ merge_sort_block_size = thd_merge_sort_block_size(trx->mysql_thd);
+
trx_start_if_not_started(trx);
/* Allocate memory for merge file data structure and initialize
fields */
merge_files = mem_alloc(n_indexes * sizeof *merge_files);
- block_size = 3 * sizeof *block;
- block = os_mem_alloc_large(&block_size);
+ block_size = 3 * merge_sort_block_size;
+ block_mem = os_mem_alloc_large(&block_size);
+
+ for (i = 0; i < UT_ARR_SIZE(block); i++) {
+ block[i] = (row_merge_block_t ) ((byte *) block_mem +
+ i * merge_sort_block_size);
+ }
for (i = 0; i < n_indexes; i++) {
@@ -2693,7 +2743,7 @@ row_merge_build_indexes(
error = row_merge_read_clustered_index(
trx, table, old_table, new_table, indexes,
- merge_files, n_indexes, block);
+ merge_files, n_indexes, block, merge_sort_block_size);
if (error != DB_SUCCESS) {
@@ -2705,13 +2755,15 @@ row_merge_build_indexes(
for (i = 0; i < n_indexes; i++) {
error = row_merge_sort(trx, indexes[i], &merge_files[i],
- block, &tmpfd, table);
+ block, &tmpfd, table,
+ merge_sort_block_size);
if (error == DB_SUCCESS) {
error = row_merge_insert_index_tuples(
trx, indexes[i], new_table,
dict_table_zip_size(old_table),
- merge_files[i].fd, block);
+ merge_files[i].fd, block,
+ merge_sort_block_size);
}
/* Close the temporary file to free up space. */
@@ -2731,7 +2783,7 @@ func_exit:
}
mem_free(merge_files);
- os_mem_free_large(block, block_size);
+ os_mem_free_large(block_mem, block_size);
return(error);
}
diff --git a/storage/xtradb/row/row0vers.c b/storage/xtradb/row/row0vers.c
index 5fd7d082194..6d83dbaf8ee 100644
--- a/storage/xtradb/row/row0vers.c
+++ b/storage/xtradb/row/row0vers.c
@@ -209,17 +209,6 @@ row_vers_impl_x_locked_off_kernel(
prev_trx_id = row_get_rec_trx_id(prev_version, clust_index,
clust_offsets);
- /* If the trx_id and prev_trx_id are different and if
- the prev_version is marked deleted then the
- prev_trx_id must have already committed for the trx_id
- to be able to modify the row. Therefore, prev_trx_id
- cannot hold any implicit lock. */
- if (vers_del && trx_id != prev_trx_id) {
-
- mutex_enter(&kernel_mutex);
- break;
- }
-
/* The stack of versions is locked by mtr. Thus, it
is safe to fetch the prefixes for externally stored
columns. */
diff --git a/storage/xtradb/trx/trx0sys.c b/storage/xtradb/trx/trx0sys.c
index dd869a787bd..7d303c2563c 100644
--- a/storage/xtradb/trx/trx0sys.c
+++ b/storage/xtradb/trx/trx0sys.c
@@ -137,12 +137,12 @@ UNIV_INTERN mysql_pfs_key_t trx_doublewrite_mutex_key;
UNIV_INTERN mysql_pfs_key_t file_format_max_mutex_key;
#endif /* UNIV_PFS_MUTEX */
+#ifndef UNIV_HOTBACKUP
#ifdef UNIV_DEBUG
/* Flag to control TRX_RSEG_N_SLOTS behavior debugging. */
uint trx_rseg_n_slots_debug = 0;
#endif
-#ifndef UNIV_HOTBACKUP
/** This is used to track the maximum file format id known to InnoDB. It's
updated via SET GLOBAL innodb_file_format_max = 'x' or when we open
or create a table. */
diff --git a/storage/xtradb/ut/ut0dbg.c b/storage/xtradb/ut/ut0dbg.c
index 64fadd76d1c..53ed4a53044 100644
--- a/storage/xtradb/ut/ut0dbg.c
+++ b/storage/xtradb/ut/ut0dbg.c
@@ -25,7 +25,9 @@ Created 1/30/1994 Heikki Tuuri
#include "univ.i"
#include "ut0dbg.h"
-#include "ha_prototypes.h"
+#ifndef UNIV_HOTBACKUP
+# include "ha_prototypes.h"
+#endif /* !UNIV_HOTBACKUP */
#if defined(__GNUC__) && (__GNUC__ > 2)
#else
@@ -56,7 +58,7 @@ ut_dbg_assertion_failed(
ut_print_timestamp(stderr);
#ifdef UNIV_HOTBACKUP
fprintf(stderr, " InnoDB: Assertion failure in file %s line %lu\n",
- innobase_basename(file), line);
+ file, line);
#else /* UNIV_HOTBACKUP */
fprintf(stderr,
" InnoDB: Assertion failure in thread %lu"
diff --git a/storage/xtradb/ut/ut0ut.c b/storage/xtradb/ut/ut0ut.c
index 60def59193a..31c8351a518 100644
--- a/storage/xtradb/ut/ut0ut.c
+++ b/storage/xtradb/ut/ut0ut.c
@@ -245,7 +245,9 @@ ut_print_timestamp(
(int)cal_tm.wMinute,
(int)cal_tm.wSecond);
#else
+#ifdef HAVE_LOCALTIME_R
struct tm cal_tm;
+#endif
struct tm* cal_tm_ptr;
time_t tm;
@@ -288,7 +290,9 @@ ut_sprintf_timestamp(
(int)cal_tm.wMinute,
(int)cal_tm.wSecond);
#else
+#ifdef HAVE_LOCALTIME_R
struct tm cal_tm;
+#endif
struct tm* cal_tm_ptr;
time_t tm;
@@ -333,7 +337,9 @@ ut_sprintf_timestamp_without_extra_chars(
(int)cal_tm.wMinute,
(int)cal_tm.wSecond);
#else
+#ifdef HAVE_LOCALTIME_R
struct tm cal_tm;
+#endif
struct tm* cal_tm_ptr;
time_t tm;
@@ -374,7 +380,9 @@ ut_get_year_month_day(
*month = (ulint)cal_tm.wMonth;
*day = (ulint)cal_tm.wDay;
#else
+#ifdef HAVE_LOCALTIME_R
struct tm cal_tm;
+#endif
struct tm* cal_tm_ptr;
time_t tm;