From 07099b70210210c16b362eede7fa82940662e87f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 18 Jul 2013 11:16:18 +0300 Subject: [PATCH 01/15] Fix of using uninitialized variadle. --- sql/sql_select.cc | 2 ++ sql/sql_union.cc | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 03d83cebeac..f90874ff62c 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -15674,6 +15674,8 @@ create_internal_tmp_table_from_heap2(THD *thd, TABLE *table, const char *save_proc_info; int write_err= 0; DBUG_ENTER("create_internal_tmp_table_from_heap2"); + if (is_duplicate) + *is_duplicate= FALSE; if (table->s->db_type() != heap_hton || error != HA_ERR_RECORD_FILE_FULL) diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 248296b2bf4..1551a8ff6d6 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -83,7 +83,7 @@ int select_union::send_data(List &values) */ return -1; } - bool is_duplicate; + bool is_duplicate= FALSE; /* create_internal_tmp_table_from_heap will generate error if needed */ if (table->file->is_fatal_error(write_err, HA_CHECK_DUP) && create_internal_tmp_table_from_heap(thd, table, From 9e13011efb137728e14a89d936616a14ebee8f59 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 19 Jul 2013 13:21:23 +0300 Subject: [PATCH 02/15] Revert reverted patch (as workaround) to have no problem with ongoing fix. --- storage/xtradb/buf/buf0buf.c | 6 +- storage/xtradb/fil/fil0fil.c | 103 ++++++++++++++++++++++++++++--- storage/xtradb/include/buf0buf.h | 7 ++- storage/xtradb/include/fil0fil.h | 13 ++-- storage/xtradb/srv/srv0start.c | 23 ++++++- storage/xtradb/trx/trx0sys.c | 8 ++- 6 files changed, 136 insertions(+), 24 deletions(-) diff --git a/storage/xtradb/buf/buf0buf.c b/storage/xtradb/buf/buf0buf.c index b294c88497e..1084dcdf344 100644 --- a/storage/xtradb/buf/buf0buf.c +++ b/storage/xtradb/buf/buf0buf.c @@ -581,6 +581,8 @@ UNIV_INTERN ibool buf_page_is_corrupted( /*==================*/ + ibool check_lsn, /*!< in: TRUE if we need to check + and complain about the LSN */ const byte* read_buf, /*!< in: a database page */ ulint zip_size) /*!< in: size of compressed page; 0 for uncompressed pages */ @@ -600,7 +602,7 @@ buf_page_is_corrupted( } #ifndef UNIV_HOTBACKUP - if (recv_lsn_checks_on) { + if (check_lsn && recv_lsn_checks_on) { ib_uint64_t current_lsn; if (log_peek_lsn(¤t_lsn) @@ -3945,7 +3947,7 @@ buf_page_io_complete( /* From version 3.23.38 up we store the page checksum to the 4 first bytes of the page end lsn field */ - if (buf_page_is_corrupted(frame, + if (buf_page_is_corrupted(TRUE, frame, buf_page_get_zip_size(bpage))) { corrupt: fprintf(stderr, diff --git a/storage/xtradb/fil/fil0fil.c b/storage/xtradb/fil/fil0fil.c index 48f3c43cdc0..929e24d20ce 100644 --- a/storage/xtradb/fil/fil0fil.c +++ b/storage/xtradb/fil/fil0fil.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1883,11 +1883,63 @@ fil_write_flushed_lsn_to_data_files( return(DB_SUCCESS); } +/*******************************************************************//** +Checks the consistency of the first data page of a data file +at database startup. +@retval NULL on success, or if innodb_force_recovery is set +@return pointer to an error message string */ +static __attribute__((warn_unused_result)) +const char* +fil_check_first_page( +/*=================*/ + const page_t* page, /*!< in: data page */ + ibool first_page) /*!< in: TRUE if this is the + first page of the tablespace */ +{ + ulint space_id; + ulint flags; + + if (srv_force_recovery >= SRV_FORCE_IGNORE_CORRUPT) { + return(NULL); + } + + space_id = mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_ID + page); + flags = mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page); + + if (first_page && !space_id && !flags) { + ulint nonzero_bytes = UNIV_PAGE_SIZE; + const byte* b = page; + + while (!*b && --nonzero_bytes) { + b++; + } + + if (!nonzero_bytes) { + return("space header page consists of zero bytes"); + } + } + + if (buf_page_is_corrupted( + FALSE, page, dict_table_flags_to_zip_size(flags))) { + return("checksum mismatch"); + } + + if (!first_page + || (page_get_space_id(page) == space_id + && page_get_page_no(page) == 0)) { + return(NULL); + } + + return("inconsistent data in space header"); +} + /*******************************************************************//** Reads the flushed lsn, arch no, and tablespace flag fields from a data -file at database startup. */ +file at database startup. +@retval NULL on success, or if innodb_force_recovery is set +@return pointer to an error message string */ UNIV_INTERN -void +const char* fil_read_first_page( /*================*/ os_file_t data_file, /*!< in: open data file */ @@ -1909,6 +1961,7 @@ fil_read_first_page( byte* buf; page_t* page; ib_uint64_t flushed_lsn; + const char* check_msg; buf = ut_malloc(2 * UNIV_PAGE_SIZE); /* Align the memory for a possible read from a raw device */ @@ -1916,13 +1969,18 @@ fil_read_first_page( os_file_read(data_file, page, 0, 0, UNIV_PAGE_SIZE); - *flags = mach_read_from_4(page + - FSP_HEADER_OFFSET + FSP_SPACE_FLAGS); + *flags = mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page); flushed_lsn = mach_read_from_8(page + FIL_PAGE_FILE_FLUSH_LSN); + check_msg = fil_check_first_page(page, !one_read_already); + ut_free(buf); + if (check_msg) { + return(check_msg); + } + if (!one_read_already) { *min_flushed_lsn = flushed_lsn; *max_flushed_lsn = flushed_lsn; @@ -1930,7 +1988,7 @@ fil_read_first_page( *min_arch_log_no = arch_log_no; *max_arch_log_no = arch_log_no; #endif /* UNIV_LOG_ARCHIVE */ - return; + return(NULL); } if (*min_flushed_lsn > flushed_lsn) { @@ -1947,6 +2005,8 @@ fil_read_first_page( *max_arch_log_no = arch_log_no; } #endif /* UNIV_LOG_ARCHIVE */ + + return(NULL); } /*================ SINGLE-TABLE TABLESPACES ==========================*/ @@ -3271,6 +3331,7 @@ fil_open_single_table_tablespace( os_file_t file; char* filepath; ibool success; + const char* check_msg; byte* buf2; byte* page; ulint space_id; @@ -3331,6 +3392,8 @@ fil_open_single_table_tablespace( success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE); + check_msg = fil_check_first_page(page, TRUE); + /* We have to read the tablespace id and flags from the file. */ space_id = fsp_header_get_space_id(page); @@ -3366,7 +3429,7 @@ fil_open_single_table_tablespace( current_lsn = log_get_lsn(); /* check the header page's consistency */ - if (buf_page_is_corrupted(page, + if (buf_page_is_corrupted(TRUE, page, dict_table_flags_to_zip_size(space_flags))) { fprintf(stderr, "InnoDB: page 0 of %s seems corrupt.\n", filepath); file_is_corrupt = TRUE; @@ -3788,8 +3851,20 @@ skip_write: ut_free(buf2); - if (UNIV_UNLIKELY(space_id != id - || space_flags != (flags & ~(~0 << DICT_TF_BITS)))) { + if (check_msg) { + ut_print_timestamp(stderr); + fprintf(stderr, " InnoDB: Error: %s in file ", check_msg); + ut_print_filename(stderr, filepath); + fprintf(stderr, " (tablespace id=%lu, flags=%lu)\n" + "InnoDB: Please refer to " REFMAN + "innodb-troubleshooting-datadict.html\n", + (ulong) id, (ulong) flags); + success = FALSE; + goto func_exit; + } + + if (space_id != id + || space_flags != (flags & ~(~0 << DICT_TF_BITS))) { ut_print_timestamp(stderr); fputs(" InnoDB: Error: tablespace id and flags in file ", @@ -4280,11 +4355,21 @@ fil_load_single_table_tablespace( page = ut_align(buf2, UNIV_PAGE_SIZE); if (size >= FIL_IBD_FILE_INITIAL_SIZE * (lint)UNIV_PAGE_SIZE) { + const char* check_msg; success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE); /* We have to read the tablespace id from the file */ + check_msg = fil_check_first_page(page, TRUE); + + if (check_msg) { + fprintf(stderr, + "InnoDB: Error: %s in file %s", + check_msg, filepath); + goto func_exit; + } + space_id = fsp_header_get_space_id(page); flags = fsp_header_get_flags(page); } else { diff --git a/storage/xtradb/include/buf0buf.h b/storage/xtradb/include/buf0buf.h index f00a06c8805..233231e4cab 100644 --- a/storage/xtradb/include/buf0buf.h +++ b/storage/xtradb/include/buf0buf.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -684,9 +684,12 @@ UNIV_INTERN ibool buf_page_is_corrupted( /*==================*/ + ibool check_lsn, /*!< in: TRUE if we need to check + and complain about the LSN */ const byte* read_buf, /*!< in: a database page */ - ulint zip_size); /*!< in: size of compressed page; + ulint zip_size) /*!< in: size of compressed page; 0 for uncompressed pages */ + __attribute__((warn_unused_result)); #ifndef UNIV_HOTBACKUP /**********************************************************************//** Gets the space id, page offset, and byte offset within page of a diff --git a/storage/xtradb/include/fil0fil.h b/storage/xtradb/include/fil0fil.h index 2149d0aadca..881623b30cf 100644 --- a/storage/xtradb/include/fil0fil.h +++ b/storage/xtradb/include/fil0fil.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -328,10 +328,12 @@ fil_write_flushed_lsn_to_data_files( ulint arch_log_no); /*!< in: latest archived log file number */ /*******************************************************************//** -Reads the flushed lsn and arch no fields from a data file at database -startup. */ +Reads the flushed lsn, arch no, and tablespace flag fields from a data +file at database startup. +@retval NULL on success, or if innodb_force_recovery is set +@return pointer to an error message string */ UNIV_INTERN -void +const char* fil_read_first_page( /*================*/ os_file_t data_file, /*!< in: open data file */ @@ -347,8 +349,9 @@ fil_read_first_page( #endif /* UNIV_LOG_ARCHIVE */ ib_uint64_t* min_flushed_lsn, /*!< out: min of flushed lsn values in data files */ - ib_uint64_t* max_flushed_lsn); /*!< out: max of flushed + ib_uint64_t* max_flushed_lsn) /*!< out: max of flushed lsn values in data files */ + __attribute__((warn_unused_result)); /*******************************************************************//** Increments the count of pending operation, if space is not being deleted. @return TRUE if being deleted, and operation should be skipped */ diff --git a/storage/xtradb/srv/srv0start.c b/storage/xtradb/srv/srv0start.c index 6e6c5ff4e41..93416088f17 100644 --- a/storage/xtradb/srv/srv0start.c +++ b/storage/xtradb/srv/srv0start.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2009, Percona Inc. @@ -817,6 +817,7 @@ open_or_create_data_files( } if (ret == FALSE) { + const char* check_msg; /* We open the data file */ if (one_created) { @@ -914,13 +915,20 @@ open_or_create_data_files( return(DB_ERROR); } skip_size_check: - fil_read_first_page( + check_msg = fil_read_first_page( files[i], one_opened, &flags, #ifdef UNIV_LOG_ARCHIVE min_arch_log_no, max_arch_log_no, #endif /* UNIV_LOG_ARCHIVE */ min_flushed_lsn, max_flushed_lsn); + if (check_msg) { + fprintf(stderr, + "InnoDB: Error: %s in data file %s\n", + check_msg, name); + return(DB_ERROR); + } + if (!one_opened && UNIV_PAGE_SIZE != fsp_flags_get_page_size(flags)) { @@ -1042,6 +1050,8 @@ skip_size_check: if (ret == FALSE) { + const char* check_msg; + /* We open the data file */ files[i] = os_file_create(innodb_file_data_key, @@ -1078,13 +1088,20 @@ skip_size_check: (ulong) TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9); } - fil_read_first_page( + check_msg = fil_read_first_page( files[i], one_opened, &flags, #ifdef UNIV_LOG_ARCHIVE min_arch_log_no, max_arch_log_no, #endif /* UNIV_LOG_ARCHIVE */ min_flushed_lsn, max_flushed_lsn); + if (check_msg) { + fprintf(stderr, + "InnoDB: Error: %s in doublewrite " + "buffer file %s\n", check_msg, name); + return(DB_ERROR); + } + one_opened = TRUE; } else { /* We created the data file and now write it full of diff --git a/storage/xtradb/trx/trx0sys.c b/storage/xtradb/trx/trx0sys.c index ef00bc0a1f0..a56e55c0e19 100644 --- a/storage/xtradb/trx/trx0sys.c +++ b/storage/xtradb/trx/trx0sys.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -726,7 +726,8 @@ trx_sys_doublewrite_init_or_restore_pages( /* Check if the page is corrupt */ if (UNIV_UNLIKELY - (buf_page_is_corrupted(read_buf, zip_size))) { + (buf_page_is_corrupted( + TRUE, read_buf, zip_size))) { fprintf(stderr, "InnoDB: Warning: database page" @@ -737,7 +738,8 @@ trx_sys_doublewrite_init_or_restore_pages( " the doublewrite buffer.\n", (ulong) space_id, (ulong) page_no); - if (buf_page_is_corrupted(page, zip_size)) { + if (buf_page_is_corrupted( + TRUE, page, zip_size)) { fprintf(stderr, "InnoDB: Dump of the page:\n"); buf_page_print( From 9a780a59d53a905d8acf67e51cba5f1492e706b6 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Thu, 25 Jul 2013 22:42:26 +0400 Subject: [PATCH 03/15] MDEV-4687: impossible where with < operation, but =-5 return one row - Let _ma_record_pos() set SEARCH_PART_KEY when doing a search on a prefix of a [unique] key. Otherwise, _ma_search_pos() would find the first key equal to search key, and assume it is also the last one, which will make a wrong estimate of key's position. A wrong key position may cause min_pos > max_pos and records_in_range() will return 0, which will make the optimizer think it's an impossible range while in fact it is not. --- storage/maria/ma_range.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/storage/maria/ma_range.c b/storage/maria/ma_range.c index bb72c10bba7..2a01359f1a1 100644 --- a/storage/maria/ma_range.c +++ b/storage/maria/ma_range.c @@ -144,6 +144,10 @@ static ha_rows _ma_record_pos(MARIA_HA *info, const uchar *key_data, (HA_KEYSEG**) 0); DBUG_EXECUTE("key", _ma_print_key(DBUG_FILE, &key);); nextflag=maria_read_vec[search_flag]; + + /* Indicate if we're doing a search on a key prefix */ + if (((((key_part_map)1) << key.keyinfo->keysegs) - 1) != keypart_map) + nextflag |= SEARCH_PART_KEY; /* my_handler.c:ha_compare_text() has a flag 'skip_end_space'. From 3ef0157daa3593d2003e14fac3a7a8a249e9c048 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Mon, 29 Jul 2013 16:03:41 +0200 Subject: [PATCH 04/15] MDEV-4815 - allow multiple mysql_server_init() / mysql_server_end() in the same process, for embedded library. - Reset static variables that are used to signal "init done" for DBUG, in dbug_end() - Set string server variables to NULL after memory for the value is freed - avoids double free() - fix DBUG_ASSERTs that happened during reinitialization. --- dbug/dbug.c | 1 + mysys/waiting_threads.c | 1 + sql/sys_vars.h | 3 +++ storage/xtradb/os/os0file.c | 4 ++++ 4 files changed, 9 insertions(+) diff --git a/dbug/dbug.c b/dbug/dbug.c index b285b32fa17..db5ecb7b95e 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -1642,6 +1642,7 @@ void _db_end_() cs->stack= &init_settings; FreeState(cs, 0); + init_done= 0; } diff --git a/mysys/waiting_threads.c b/mysys/waiting_threads.c index 0a9474e68b4..c861dcc738c 100644 --- a/mysys/waiting_threads.c +++ b/mysys/waiting_threads.c @@ -475,6 +475,7 @@ void wt_end() my_atomic_rwlock_destroy(&cycle_stats_lock); my_atomic_rwlock_destroy(&success_stats_lock); my_atomic_rwlock_destroy(&wait_stats_lock); + reshash.alloc.constructor= NULL; wt_init_done= 0; DBUG_VOID_RETURN; } diff --git a/sql/sys_vars.h b/sql/sys_vars.h index 8345a2836dd..b7be81afd73 100644 --- a/sql/sys_vars.h +++ b/sql/sys_vars.h @@ -427,7 +427,10 @@ public: void cleanup() { if (flags & ALLOCATED) + { my_free(global_var(char*)); + global_var(char *)= NULL; + } flags&= ~ALLOCATED; } static bool do_string_check(THD *thd, set_var *var, CHARSET_INFO *charset) diff --git a/storage/xtradb/os/os0file.c b/storage/xtradb/os/os0file.c index ae6ba05c9f6..5beed447c91 100644 --- a/storage/xtradb/os/os0file.c +++ b/storage/xtradb/os/os0file.c @@ -3773,6 +3773,10 @@ os_aio_free(void) ut_free(os_aio_segment_wait_events); os_aio_segment_wait_events = 0; os_aio_n_segments = 0; +#ifdef _WIN32 + completion_port = 0; + read_completion_port = 0; +#endif } #ifdef WIN_ASYNC_IO From 04684b7709f55a5a9de9226e834bcfbed05ee5c0 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Wed, 31 Jul 2013 17:24:52 +0400 Subject: [PATCH 05/15] MDEV-4817: Optimizer fails to optimize expression of the form 'FOO' IS NULL - Modify the way Item_cond::fix_fields() and Item_cond::eval_not_null_tables() calculate bitmap for Item_cond_or::not_null_tables(): if they see a "... OR inexpensive_const_false_item OR ..." then the item can be ignored. - Updated test results. There can be more warnings produced since parts of WHERE are evaluated more times. --- mysql-test/r/func_group.result | 2 + mysql-test/r/insert.result | 3 +- mysql-test/r/join_outer.result | 21 ++++++++++ mysql-test/r/join_outer_innodb.result | 4 +- mysql-test/r/join_outer_jcl6.result | 21 ++++++++++ mysql-test/r/range.result | 2 + mysql-test/r/range_mrr_icp.result | 2 + mysql-test/r/subselect_cache.result | 2 + mysql-test/t/join_outer.test | 17 ++++++++ sql/item_cmpfunc.cc | 56 ++++++++++++++++++++++++--- 10 files changed, 122 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 38aa3f49c4d..ba90707ca40 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -1971,6 +1971,7 @@ MIN(t2.pk) NULL Warnings: Warning 1292 Truncated incorrect INTEGER value: 'j' +Warning 1292 Truncated incorrect INTEGER value: 'j' EXPLAIN SELECT MIN(t2.pk) @@ -1984,6 +1985,7 @@ id select_type table type possible_keys key key_len ref rows Extra 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Warnings: Warning 1292 Truncated incorrect INTEGER value: 'j' +Warning 1292 Truncated incorrect INTEGER value: 'j' # # 2) Test that subquery materialization is setup for query with diff --git a/mysql-test/r/insert.result b/mysql-test/r/insert.result index 7110f541fb7..a722ab8d97f 100644 --- a/mysql-test/r/insert.result +++ b/mysql-test/r/insert.result @@ -663,9 +663,10 @@ Warning 1365 Division by 0 Warning 1048 Column 'data' cannot be null update t1 set data='envelope' where 1/0 or 1; affected rows: 2 -info: Rows matched: 2 Changed: 2 Warnings: 3 +info: Rows matched: 2 Changed: 2 Warnings: 4 Warnings: Warning 1365 Division by 0 +Warning 1365 Division by 0 Warning 1265 Data truncated for column 'data' at row 1 Warning 1265 Data truncated for column 'data' at row 2 insert t1 (data) values (default), (1/0), ('dead beef'); diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 8920539ef2e..fb4cc58d607 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -2117,4 +2117,25 @@ SELECT a.* FROM t1 a LEFT JOIN t1 b ON a.id = b.id WHERE a.modified > b.modified or b.modified IS NULL; id modified DROP TABLE t1; +# +# MDEV-4817: Optimizer fails to optimize expression of the form 'FOO' IS NULL +# +create table t0 (a int not null); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +alter table t0 add person_id varchar(255) not null; +create table t1 (pk int not null primary key); +insert into t1 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo' or 'xyz' IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 Using index +explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 Using index +explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo' or t0.person_id='bar'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 Using index +drop table t0, t1; SET optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/r/join_outer_innodb.result b/mysql-test/r/join_outer_innodb.result index 1081fc0eed3..336fb5ee6b6 100644 --- a/mysql-test/r/join_outer_innodb.result +++ b/mysql-test/r/join_outer_innodb.result @@ -14,8 +14,8 @@ EXPLAIN SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id WHERE t1.name LIKE 'A%' OR FALSE; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index NULL fkey 5 NULL 5 Using index -1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.fkey 1 Using where +1 SIMPLE t1 index PRIMARY,name name 23 NULL 3 Using where; Using index +1 SIMPLE t2 ref fkey fkey 5 test.t1.id 1 Using index DROP TABLE t1,t2; # # BUG#58456: Assertion 0 in QUICK_INDEX_MERGE_SELECT::need_sorted_output diff --git a/mysql-test/r/join_outer_jcl6.result b/mysql-test/r/join_outer_jcl6.result index 43443aa2fef..b5460d43e2b 100644 --- a/mysql-test/r/join_outer_jcl6.result +++ b/mysql-test/r/join_outer_jcl6.result @@ -2128,6 +2128,27 @@ SELECT a.* FROM t1 a LEFT JOIN t1 b ON a.id = b.id WHERE a.modified > b.modified or b.modified IS NULL; id modified DROP TABLE t1; +# +# MDEV-4817: Optimizer fails to optimize expression of the form 'FOO' IS NULL +# +create table t0 (a int not null); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +alter table t0 add person_id varchar(255) not null; +create table t1 (pk int not null primary key); +insert into t1 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo' or 'xyz' IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 Using index +explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 Using index +explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo' or t0.person_id='bar'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 Using index +drop table t0, t1; SET optimizer_switch=@save_optimizer_switch; set join_cache_level=default; show variables like 'join_cache_level'; diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 146d250d687..86d98fdcc54 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -1590,6 +1590,8 @@ NULL Warnings: Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date +Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date +Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date SELECT str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20'; str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20' 1 diff --git a/mysql-test/r/range_mrr_icp.result b/mysql-test/r/range_mrr_icp.result index 3769ceb9145..0527449fa9b 100644 --- a/mysql-test/r/range_mrr_icp.result +++ b/mysql-test/r/range_mrr_icp.result @@ -1592,6 +1592,8 @@ NULL Warnings: Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date +Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date +Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date SELECT str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20'; str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20' 1 diff --git a/mysql-test/r/subselect_cache.result b/mysql-test/r/subselect_cache.result index 7bd10dc11a6..95f935981c2 100644 --- a/mysql-test/r/subselect_cache.result +++ b/mysql-test/r/subselect_cache.result @@ -3129,6 +3129,7 @@ WHERE table1 .`col_varchar_key` ) field10 1 NULL f Warnings: Warning 1292 Truncated incorrect DOUBLE value: 'f' +Warning 1292 Truncated incorrect DOUBLE value: 'f' SET @@optimizer_switch = 'subquery_cache=on'; /* cache is on */ SELECT COUNT( DISTINCT table2 .`col_int_key` ) , ( SELECT SUBQUERY2_t1 .`col_int_key` @@ -3144,6 +3145,7 @@ WHERE table1 .`col_varchar_key` ) field10 1 NULL f Warnings: Warning 1292 Truncated incorrect DOUBLE value: 'f' +Warning 1292 Truncated incorrect DOUBLE value: 'f' drop table t1,t2,t3,t4; set @@optimizer_switch= default; #launchpad BUG#611625 diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index 24885c056b8..b0000b2b943 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -1670,4 +1670,21 @@ SELECT a.* FROM t1 a LEFT JOIN t1 b ON a.id = b.id DROP TABLE t1; +--echo # +--echo # MDEV-4817: Optimizer fails to optimize expression of the form 'FOO' IS NULL +--echo # +create table t0 (a int not null); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +alter table t0 add person_id varchar(255) not null; +create table t1 (pk int not null primary key); +insert into t1 select A.a + 10*B.a from t0 A, t0 B; + +explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo' or 'xyz' IS NULL; +explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo'; +explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo' or t0.person_id='bar'; + +drop table t0, t1; + + SET optimizer_switch=@save_optimizer_switch; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 51b31d8e17f..ebd03743f48 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -4301,12 +4301,40 @@ Item_cond::fix_fields(THD *thd, Item **ref) return TRUE; /* purecov: inspected */ used_tables_cache|= item->used_tables(); if (item->const_item()) - and_tables_cache= (table_map) 0; + { + if (!item->is_expensive() && item->val_int() == 0) + { + /* + This is "... OR false_cond OR ..." + In this case, false_cond has no effect on cond_or->not_null_tables() + */ + } + else + { + /* + This is "... OR const_cond OR ..." + In this case, cond_or->not_null_tables()=0, because the condition + some_cond_or might be true regardless of what tables are + NULL-complemented. + */ + and_tables_cache= (table_map) 0; + } + } else { - table_map tmp_table_map= item->not_null_tables(); - not_null_tables_cache|= tmp_table_map; - and_tables_cache&= tmp_table_map; + /* + If an item is a + - constant + - inexpensive + - its value is 0 + then we don't need to account it in not_null_tables_cache + */ + //if (!(item->const_item() && !item->is_expensive() )) + { + table_map tmp_table_map= item->not_null_tables(); + not_null_tables_cache|= tmp_table_map; + and_tables_cache&= tmp_table_map; + } const_item_cache= FALSE; } @@ -4334,7 +4362,25 @@ Item_cond::eval_not_null_tables(uchar *opt_arg) { table_map tmp_table_map; if (item->const_item()) - and_tables_cache= (table_map) 0; + { + if (!item->is_expensive() && item->val_int() == 0) + { + /* + This is "... OR false_cond OR ..." + In this case, false_cond has no effect on cond_or->not_null_tables() + */ + } + else + { + /* + This is "... OR const_cond OR ..." + In this case, cond_or->not_null_tables()=0, because the condition + some_cond_or might be true regardless of what tables are + NULL-complemented. + */ + and_tables_cache= (table_map) 0; + } + } else { tmp_table_map= item->not_null_tables(); From 04fd2f18cb9de58d62ec6c860f586b9f81a95300 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Aug 2013 11:46:11 +0300 Subject: [PATCH 06/15] MDEV-4811 Assertion `offset < 0x1f' fails in type_and_offset_store on COLUMN_ADD MDEV-4812 Valgrind warnings (Invalid write) in dynamic_column_update_many on COLUMN_ADD Fixed problem of working on wrong data (do not allow offset to out of string length). --- mysql-test/r/dyncol.result | 21 +++++++++++++++++++++ mysql-test/t/dyncol.test | 23 +++++++++++++++++++++++ mysys/ma_dyncol.c | 27 ++++++++++++++++++--------- 3 files changed, 62 insertions(+), 9 deletions(-) diff --git a/mysql-test/r/dyncol.result b/mysql-test/r/dyncol.result index 6b1dd4d96ec..1b06bd06162 100644 --- a/mysql-test/r/dyncol.result +++ b/mysql-test/r/dyncol.result @@ -1404,5 +1404,26 @@ v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VI drop view v1; drop table t1; # +# MDEV-4811: Assertion `offset < 0x1f' fails in type_and_offset_store +# on COLUMN_ADD +# +CREATE TABLE t1 (dyn TINYBLOB) ENGINE=MyISAM; +INSERT INTO t1 SET dyn = COLUMN_CREATE( 40, REPEAT('a', 233), 4, REPEAT('b', 322) ); +Warnings: +Warning 1265 Data truncated for column 'dyn' at row 1 +SELECT COLUMN_ADD( dyn, 6, REPEAT('x',80), 4, REPEAT('y',215) AS INTEGER ) FROM t1; +ERROR HY000: Encountered illegal format of dynamic column string +DROP table t1; +# +# MDEV-4812: Valgrind warnings (Invalid write) in +# dynamic_column_update_many on COLUMN_ADD +# +CREATE TABLE t1 (dyncol TINYBLOB) ENGINE=MyISAM; +INSERT INTO t1 SET dyncol = COLUMN_CREATE( 7, REPEAT('k',487), 209, REPEAT('x',464) ); +Warnings: +Warning 1265 Data truncated for column 'dyncol' at row 1 +SELECT COLUMN_ADD( dyncol, 7, '22:22:22', 8, REPEAT('x',270) AS CHAR ) FROM t1; +DROP table t1; +# # end of 5.3 tests # diff --git a/mysql-test/t/dyncol.test b/mysql-test/t/dyncol.test index ca3ff600509..914bf9151b3 100644 --- a/mysql-test/t/dyncol.test +++ b/mysql-test/t/dyncol.test @@ -599,6 +599,29 @@ drop view v1; drop table t1; +--echo # +--echo # MDEV-4811: Assertion `offset < 0x1f' fails in type_and_offset_store +--echo # on COLUMN_ADD +--echo # + +CREATE TABLE t1 (dyn TINYBLOB) ENGINE=MyISAM; +INSERT INTO t1 SET dyn = COLUMN_CREATE( 40, REPEAT('a', 233), 4, REPEAT('b', 322) ); +--error ER_DYN_COL_WRONG_FORMAT +SELECT COLUMN_ADD( dyn, 6, REPEAT('x',80), 4, REPEAT('y',215) AS INTEGER ) FROM t1; + +DROP table t1; + +--echo # +--echo # MDEV-4812: Valgrind warnings (Invalid write) in +--echo # dynamic_column_update_many on COLUMN_ADD +--echo # +CREATE TABLE t1 (dyncol TINYBLOB) ENGINE=MyISAM; + +INSERT INTO t1 SET dyncol = COLUMN_CREATE( 7, REPEAT('k',487), 209, REPEAT('x',464) ); +--error 0,ER_DYN_COL_WRONG_FORMAT +SELECT COLUMN_ADD( dyncol, 7, '22:22:22', 8, REPEAT('x',270) AS CHAR ) FROM t1; +DROP table t1; + --echo # --echo # end of 5.3 tests --echo # diff --git a/mysys/ma_dyncol.c b/mysys/ma_dyncol.c index 03d9007c7cb..f01d69f0b25 100644 --- a/mysys/ma_dyncol.c +++ b/mysys/ma_dyncol.c @@ -1228,13 +1228,14 @@ dynamic_column_create(DYNAMIC_COLUMN *str, uint column_nr, @param header_end Pointer to the header end @param offset_size Size of offset field in bytes @param last_offset Size of the data segment + @param error Set in case of error @return number of bytes */ static size_t get_length_interval(uchar *entry, uchar *entry_next, uchar *header_end, size_t offset_size, - size_t last_offset) + size_t last_offset, my_bool *error) { size_t offset, offset_next; DYNAMIC_COLUMN_TYPE type, type_next; @@ -1242,8 +1243,12 @@ static size_t get_length_interval(uchar *entry, uchar *entry_next, type_and_offset_read(&type, &offset, entry, offset_size); if (entry_next >= header_end) + { + *error= 0; return (last_offset - offset); + } type_and_offset_read(&type_next, &offset_next, entry_next, offset_size); + *error= (offset_next > last_offset); return (offset_next - offset); } @@ -1255,17 +1260,18 @@ static size_t get_length_interval(uchar *entry, uchar *entry_next, @param header_end Pointer to the header end @param offset_size Size of offset field in bytes @param last_offset Size of the data segment + @param error Set in case of error @return number of bytes */ static size_t get_length(uchar *entry, uchar *header_end, size_t offset_size, - size_t last_offset) + size_t last_offset, my_bool *error) { return get_length_interval(entry, entry + offset_size + COLUMN_NUMBER_SIZE, - header_end, offset_size, last_offset); + header_end, offset_size, last_offset, error); } @@ -1304,6 +1310,7 @@ find_column(DYNAMIC_COLUMN_TYPE *type, uchar **data, size_t *length, uchar *entry; size_t offset, total_data, header_size, entry_size; uchar key[2+4]; + my_bool error; if (!entry_pos) entry_pos= &entry; @@ -1329,12 +1336,12 @@ find_column(DYNAMIC_COLUMN_TYPE *type, uchar **data, size_t *length, return 1; *data= header + header_size + offset; *length= get_length(entry, header + header_size, offset_size, - total_data); + total_data, &error); /* Check that the found data is withing the ranges. This can happen if we get data with wrong offsets. */ - if ((long) *length < 0 || offset + *length > total_data) + if (error || (long) *length < 0 || offset + *length > total_data) return 1; *entry_pos= entry; @@ -1837,12 +1844,13 @@ dynamic_column_update_many(DYNAMIC_COLUMN *str, entry_size, column_count, &entry)) { size_t entry_data_size; + my_bool error; /* Data existed; We have to replace or delete it */ entry_data_size= get_length(entry, header_end, - offset_size, max_offset); - if ((long) entry_data_size < 0) + offset_size, max_offset, &error); + if (error || (long) entry_data_size < 0) { rc= ER_DYNCOL_FORMAT; goto end; @@ -2038,12 +2046,13 @@ dynamic_column_update_many(DYNAMIC_COLUMN *str, /* copy first the data that was not replaced in original packed data */ if (start < end) { + my_bool error; /* Add old data last in 'tmp' */ size_t data_size= get_length_interval(header_base + start * entry_size, header_base + end * entry_size, - header_end, offset_size, max_offset); - if ((long) data_size < 0 || + header_end, offset_size, max_offset, &error); + if (error || (long) data_size < 0 || data_size > max_offset - first_offset) { dynamic_column_column_free(&tmp); From f596d28df6331003d115e61abd3699d1dd4d950e Mon Sep 17 00:00:00 2001 From: Elena Stepanova Date: Mon, 5 Aug 2013 18:30:12 +0400 Subject: [PATCH 07/15] Deliberate change in behavior introduced along with the fix for MDEV-4310 --- .../suite/storage_engine/type_spatial.result | 24 ++++----- .../type_spatial_indexes.result | 48 ++++++++--------- .../storage_engine/type_spatial_indexes.rdiff | 28 +++++----- .../storage_engine/type_spatial.rdiff | 28 +++++----- .../storage_engine/type_spatial_indexes.rdiff | 52 +++++++++---------- 5 files changed, 90 insertions(+), 90 deletions(-) diff --git a/mysql-test/suite/storage_engine/type_spatial.result b/mysql-test/suite/storage_engine/type_spatial.result index 94e3b22fd3c..6c2f5a4d50f 100644 --- a/mysql-test/suite/storage_engine/type_spatial.result +++ b/mysql-test/suite/storage_engine/type_spatial.result @@ -414,20 +414,20 @@ FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second first second w c o e d t i r 120 120 1 1 0 1 0 1 1 0 120 121 0 0 1 0 0 0 1 0 -120 122 0 1 NULL 0 NULL 0 NULL 0 -120 123 0 1 NULL 0 NULL 0 NULL 0 +120 122 NULL NULL NULL NULL NULL NULL NULL NULL +120 123 NULL NULL NULL NULL NULL NULL NULL NULL 121 120 0 0 1 0 0 0 1 0 121 121 1 1 0 1 0 1 1 0 -121 122 0 1 NULL 0 NULL 0 NULL 0 -121 123 0 1 NULL 0 NULL 0 NULL 0 -122 120 1 0 NULL 0 NULL 0 NULL 0 -122 121 1 0 NULL 0 NULL 0 NULL 0 -122 122 1 1 NULL 1 NULL 0 NULL 0 -122 123 1 1 NULL 1 NULL 0 NULL 0 -123 120 1 0 NULL 0 NULL 0 NULL 0 -123 121 1 0 NULL 0 NULL 0 NULL 0 -123 122 1 1 NULL 1 NULL 0 NULL 0 -123 123 1 1 NULL 1 NULL 0 NULL 0 +121 122 NULL NULL NULL NULL NULL NULL NULL NULL +121 123 NULL NULL NULL NULL NULL NULL NULL NULL +122 120 NULL NULL NULL NULL NULL NULL NULL NULL +122 121 NULL NULL NULL NULL NULL NULL NULL NULL +122 122 NULL NULL NULL NULL NULL NULL NULL NULL +122 123 NULL NULL NULL NULL NULL NULL NULL NULL +123 120 NULL NULL NULL NULL NULL NULL NULL NULL +123 121 NULL NULL NULL NULL NULL NULL NULL NULL +123 122 NULL NULL NULL NULL NULL NULL NULL NULL +123 123 NULL NULL NULL NULL NULL NULL NULL NULL DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; USE gis_ogs; # Lakes diff --git a/mysql-test/suite/storage_engine/type_spatial_indexes.result b/mysql-test/suite/storage_engine/type_spatial_indexes.result index cebcb80d14f..93bb4c617e5 100644 --- a/mysql-test/suite/storage_engine/type_spatial_indexes.result +++ b/mysql-test/suite/storage_engine/type_spatial_indexes.result @@ -414,20 +414,20 @@ FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second first second w c o e d t i r 120 120 1 1 0 1 0 1 1 0 120 121 0 0 1 0 0 0 1 0 -120 122 0 1 NULL 0 NULL 0 NULL 0 -120 123 0 1 NULL 0 NULL 0 NULL 0 +120 122 NULL NULL NULL NULL NULL NULL NULL NULL +120 123 NULL NULL NULL NULL NULL NULL NULL NULL 121 120 0 0 1 0 0 0 1 0 121 121 1 1 0 1 0 1 1 0 -121 122 0 1 NULL 0 NULL 0 NULL 0 -121 123 0 1 NULL 0 NULL 0 NULL 0 -122 120 1 0 NULL 0 NULL 0 NULL 0 -122 121 1 0 NULL 0 NULL 0 NULL 0 -122 122 1 1 NULL 1 NULL 0 NULL 0 -122 123 1 1 NULL 1 NULL 0 NULL 0 -123 120 1 0 NULL 0 NULL 0 NULL 0 -123 121 1 0 NULL 0 NULL 0 NULL 0 -123 122 1 1 NULL 1 NULL 0 NULL 0 -123 123 1 1 NULL 1 NULL 0 NULL 0 +121 122 NULL NULL NULL NULL NULL NULL NULL NULL +121 123 NULL NULL NULL NULL NULL NULL NULL NULL +122 120 NULL NULL NULL NULL NULL NULL NULL NULL +122 121 NULL NULL NULL NULL NULL NULL NULL NULL +122 122 NULL NULL NULL NULL NULL NULL NULL NULL +122 123 NULL NULL NULL NULL NULL NULL NULL NULL +123 120 NULL NULL NULL NULL NULL NULL NULL NULL +123 121 NULL NULL NULL NULL NULL NULL NULL NULL +123 122 NULL NULL NULL NULL NULL NULL NULL NULL +123 123 NULL NULL NULL NULL NULL NULL NULL NULL DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; USE gis_ogs; # Lakes @@ -1114,20 +1114,20 @@ FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second first second w c o e d t i r 120 120 1 1 0 1 0 1 1 0 120 121 0 0 1 0 0 0 1 0 -120 122 0 1 NULL 0 NULL 0 NULL 0 -120 123 0 1 NULL 0 NULL 0 NULL 0 +120 122 NULL NULL NULL NULL NULL NULL NULL NULL +120 123 NULL NULL NULL NULL NULL NULL NULL NULL 121 120 0 0 1 0 0 0 1 0 121 121 1 1 0 1 0 1 1 0 -121 122 0 1 NULL 0 NULL 0 NULL 0 -121 123 0 1 NULL 0 NULL 0 NULL 0 -122 120 1 0 NULL 0 NULL 0 NULL 0 -122 121 1 0 NULL 0 NULL 0 NULL 0 -122 122 1 1 NULL 1 NULL 0 NULL 0 -122 123 1 1 NULL 1 NULL 0 NULL 0 -123 120 1 0 NULL 0 NULL 0 NULL 0 -123 121 1 0 NULL 0 NULL 0 NULL 0 -123 122 1 1 NULL 1 NULL 0 NULL 0 -123 123 1 1 NULL 1 NULL 0 NULL 0 +121 122 NULL NULL NULL NULL NULL NULL NULL NULL +121 123 NULL NULL NULL NULL NULL NULL NULL NULL +122 120 NULL NULL NULL NULL NULL NULL NULL NULL +122 121 NULL NULL NULL NULL NULL NULL NULL NULL +122 122 NULL NULL NULL NULL NULL NULL NULL NULL +122 123 NULL NULL NULL NULL NULL NULL NULL NULL +123 120 NULL NULL NULL NULL NULL NULL NULL NULL +123 121 NULL NULL NULL NULL NULL NULL NULL NULL +123 122 NULL NULL NULL NULL NULL NULL NULL NULL +123 123 NULL NULL NULL NULL NULL NULL NULL NULL DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; USE gis_ogs; # Lakes diff --git a/storage/innobase/mysql-test/storage_engine/type_spatial_indexes.rdiff b/storage/innobase/mysql-test/storage_engine/type_spatial_indexes.rdiff index 9061900182e..04572ee03be 100644 --- a/storage/innobase/mysql-test/storage_engine/type_spatial_indexes.rdiff +++ b/storage/innobase/mysql-test/storage_engine/type_spatial_indexes.rdiff @@ -1,5 +1,5 @@ ---- suite/storage_engine/type_spatial_indexes.result 2013-01-23 01:25:45.367797786 +0400 -+++ suite/storage_engine/type_spatial_indexes.reject 2013-01-23 01:46:17.560307029 +0400 +--- suite/storage_engine/type_spatial_indexes.result 2013-08-05 18:08:49.000000000 +0400 ++++ suite/storage_engine/type_spatial_indexes.reject 2013-08-05 18:25:24.000000000 +0400 @@ -702,699 +702,15 @@ DROP DATABASE IF EXISTS gis_ogs; CREATE DATABASE gis_ogs; @@ -416,20 +416,20 @@ -first second w c o e d t i r -120 120 1 1 0 1 0 1 1 0 -120 121 0 0 1 0 0 0 1 0 --120 122 0 1 NULL 0 NULL 0 NULL 0 --120 123 0 1 NULL 0 NULL 0 NULL 0 +-120 122 NULL NULL NULL NULL NULL NULL NULL NULL +-120 123 NULL NULL NULL NULL NULL NULL NULL NULL -121 120 0 0 1 0 0 0 1 0 -121 121 1 1 0 1 0 1 1 0 --121 122 0 1 NULL 0 NULL 0 NULL 0 --121 123 0 1 NULL 0 NULL 0 NULL 0 --122 120 1 0 NULL 0 NULL 0 NULL 0 --122 121 1 0 NULL 0 NULL 0 NULL 0 --122 122 1 1 NULL 1 NULL 0 NULL 0 --122 123 1 1 NULL 1 NULL 0 NULL 0 --123 120 1 0 NULL 0 NULL 0 NULL 0 --123 121 1 0 NULL 0 NULL 0 NULL 0 --123 122 1 1 NULL 1 NULL 0 NULL 0 --123 123 1 1 NULL 1 NULL 0 NULL 0 +-121 122 NULL NULL NULL NULL NULL NULL NULL NULL +-121 123 NULL NULL NULL NULL NULL NULL NULL NULL +-122 120 NULL NULL NULL NULL NULL NULL NULL NULL +-122 121 NULL NULL NULL NULL NULL NULL NULL NULL +-122 122 NULL NULL NULL NULL NULL NULL NULL NULL +-122 123 NULL NULL NULL NULL NULL NULL NULL NULL +-123 120 NULL NULL NULL NULL NULL NULL NULL NULL +-123 121 NULL NULL NULL NULL NULL NULL NULL NULL +-123 122 NULL NULL NULL NULL NULL NULL NULL NULL +-123 123 NULL NULL NULL NULL NULL NULL NULL NULL -DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; -USE gis_ogs; -# Lakes diff --git a/storage/myisammrg/mysql-test/storage_engine/type_spatial.rdiff b/storage/myisammrg/mysql-test/storage_engine/type_spatial.rdiff index dbf29fb8d00..52e9d9fdbe4 100644 --- a/storage/myisammrg/mysql-test/storage_engine/type_spatial.rdiff +++ b/storage/myisammrg/mysql-test/storage_engine/type_spatial.rdiff @@ -1,5 +1,5 @@ ---- type_spatial.result 2013-01-23 01:25:39.143876032 +0400 -+++ type_spatial.reject 2013-01-23 02:51:14.535315418 +0400 +--- suite/storage_engine/type_spatial.result 2013-08-05 17:52:53.000000000 +0400 ++++ suite/storage_engine/type_spatial.reject 2013-08-05 17:56:37.000000000 +0400 @@ -2,699 +2,15 @@ DROP DATABASE IF EXISTS gis_ogs; CREATE DATABASE gis_ogs; @@ -416,20 +416,20 @@ -first second w c o e d t i r -120 120 1 1 0 1 0 1 1 0 -120 121 0 0 1 0 0 0 1 0 --120 122 0 1 NULL 0 NULL 0 NULL 0 --120 123 0 1 NULL 0 NULL 0 NULL 0 +-120 122 NULL NULL NULL NULL NULL NULL NULL NULL +-120 123 NULL NULL NULL NULL NULL NULL NULL NULL -121 120 0 0 1 0 0 0 1 0 -121 121 1 1 0 1 0 1 1 0 --121 122 0 1 NULL 0 NULL 0 NULL 0 --121 123 0 1 NULL 0 NULL 0 NULL 0 --122 120 1 0 NULL 0 NULL 0 NULL 0 --122 121 1 0 NULL 0 NULL 0 NULL 0 --122 122 1 1 NULL 1 NULL 0 NULL 0 --122 123 1 1 NULL 1 NULL 0 NULL 0 --123 120 1 0 NULL 0 NULL 0 NULL 0 --123 121 1 0 NULL 0 NULL 0 NULL 0 --123 122 1 1 NULL 1 NULL 0 NULL 0 --123 123 1 1 NULL 1 NULL 0 NULL 0 +-121 122 NULL NULL NULL NULL NULL NULL NULL NULL +-121 123 NULL NULL NULL NULL NULL NULL NULL NULL +-122 120 NULL NULL NULL NULL NULL NULL NULL NULL +-122 121 NULL NULL NULL NULL NULL NULL NULL NULL +-122 122 NULL NULL NULL NULL NULL NULL NULL NULL +-122 123 NULL NULL NULL NULL NULL NULL NULL NULL +-123 120 NULL NULL NULL NULL NULL NULL NULL NULL +-123 121 NULL NULL NULL NULL NULL NULL NULL NULL +-123 122 NULL NULL NULL NULL NULL NULL NULL NULL +-123 123 NULL NULL NULL NULL NULL NULL NULL NULL -DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; -USE gis_ogs; -# Lakes diff --git a/storage/myisammrg/mysql-test/storage_engine/type_spatial_indexes.rdiff b/storage/myisammrg/mysql-test/storage_engine/type_spatial_indexes.rdiff index 20d98db1ff2..ecd0025c9d9 100644 --- a/storage/myisammrg/mysql-test/storage_engine/type_spatial_indexes.rdiff +++ b/storage/myisammrg/mysql-test/storage_engine/type_spatial_indexes.rdiff @@ -1,5 +1,5 @@ ---- type_spatial_indexes.result 2013-01-23 01:25:45.367797786 +0400 -+++ type_spatial_indexes.reject 2013-01-23 02:51:15.247306467 +0400 +--- suite/storage_engine/type_spatial_indexes.result 2013-08-05 18:08:49.000000000 +0400 ++++ suite/storage_engine/type_spatial_indexes.reject 2013-08-05 18:27:47.000000000 +0400 @@ -2,1399 +2,31 @@ DROP DATABASE IF EXISTS gis_ogs; CREATE DATABASE gis_ogs; @@ -416,20 +416,20 @@ -first second w c o e d t i r -120 120 1 1 0 1 0 1 1 0 -120 121 0 0 1 0 0 0 1 0 --120 122 0 1 NULL 0 NULL 0 NULL 0 --120 123 0 1 NULL 0 NULL 0 NULL 0 +-120 122 NULL NULL NULL NULL NULL NULL NULL NULL +-120 123 NULL NULL NULL NULL NULL NULL NULL NULL -121 120 0 0 1 0 0 0 1 0 -121 121 1 1 0 1 0 1 1 0 --121 122 0 1 NULL 0 NULL 0 NULL 0 --121 123 0 1 NULL 0 NULL 0 NULL 0 --122 120 1 0 NULL 0 NULL 0 NULL 0 --122 121 1 0 NULL 0 NULL 0 NULL 0 --122 122 1 1 NULL 1 NULL 0 NULL 0 --122 123 1 1 NULL 1 NULL 0 NULL 0 --123 120 1 0 NULL 0 NULL 0 NULL 0 --123 121 1 0 NULL 0 NULL 0 NULL 0 --123 122 1 1 NULL 1 NULL 0 NULL 0 --123 123 1 1 NULL 1 NULL 0 NULL 0 +-121 122 NULL NULL NULL NULL NULL NULL NULL NULL +-121 123 NULL NULL NULL NULL NULL NULL NULL NULL +-122 120 NULL NULL NULL NULL NULL NULL NULL NULL +-122 121 NULL NULL NULL NULL NULL NULL NULL NULL +-122 122 NULL NULL NULL NULL NULL NULL NULL NULL +-122 123 NULL NULL NULL NULL NULL NULL NULL NULL +-123 120 NULL NULL NULL NULL NULL NULL NULL NULL +-123 121 NULL NULL NULL NULL NULL NULL NULL NULL +-123 122 NULL NULL NULL NULL NULL NULL NULL NULL +-123 123 NULL NULL NULL NULL NULL NULL NULL NULL -DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; -USE gis_ogs; -# Lakes @@ -1126,20 +1126,20 @@ -first second w c o e d t i r -120 120 1 1 0 1 0 1 1 0 -120 121 0 0 1 0 0 0 1 0 --120 122 0 1 NULL 0 NULL 0 NULL 0 --120 123 0 1 NULL 0 NULL 0 NULL 0 +-120 122 NULL NULL NULL NULL NULL NULL NULL NULL +-120 123 NULL NULL NULL NULL NULL NULL NULL NULL -121 120 0 0 1 0 0 0 1 0 -121 121 1 1 0 1 0 1 1 0 --121 122 0 1 NULL 0 NULL 0 NULL 0 --121 123 0 1 NULL 0 NULL 0 NULL 0 --122 120 1 0 NULL 0 NULL 0 NULL 0 --122 121 1 0 NULL 0 NULL 0 NULL 0 --122 122 1 1 NULL 1 NULL 0 NULL 0 --122 123 1 1 NULL 1 NULL 0 NULL 0 --123 120 1 0 NULL 0 NULL 0 NULL 0 --123 121 1 0 NULL 0 NULL 0 NULL 0 --123 122 1 1 NULL 1 NULL 0 NULL 0 --123 123 1 1 NULL 1 NULL 0 NULL 0 +-121 122 NULL NULL NULL NULL NULL NULL NULL NULL +-121 123 NULL NULL NULL NULL NULL NULL NULL NULL +-122 120 NULL NULL NULL NULL NULL NULL NULL NULL +-122 121 NULL NULL NULL NULL NULL NULL NULL NULL +-122 122 NULL NULL NULL NULL NULL NULL NULL NULL +-122 123 NULL NULL NULL NULL NULL NULL NULL NULL +-123 120 NULL NULL NULL NULL NULL NULL NULL NULL +-123 121 NULL NULL NULL NULL NULL NULL NULL NULL +-123 122 NULL NULL NULL NULL NULL NULL NULL NULL +-123 123 NULL NULL NULL NULL NULL NULL NULL NULL -DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; -USE gis_ogs; -# Lakes From 32e56e7e1452cc9dd1ffc9b82071596bc0e56304 Mon Sep 17 00:00:00 2001 From: Elena Stepanova Date: Mon, 5 Aug 2013 18:42:22 +0400 Subject: [PATCH 08/15] The test was non-deterministic while choosing an alternative storage engine --- mysql-test/suite/storage_engine/alter_table_online.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/storage_engine/alter_table_online.test b/mysql-test/suite/storage_engine/alter_table_online.test index 94dec2a72bb..c19ec0199eb 100644 --- a/mysql-test/suite/storage_engine/alter_table_online.test +++ b/mysql-test/suite/storage_engine/alter_table_online.test @@ -112,7 +112,7 @@ if ($mysql_errname!=ER_CANT_DO_ONLINE) --let $alter_definition = MODIFY b BIGINT $default_col_opts --source alter_table.inc ---let $alternative_engine = `SELECT engine FROM information_schema.engines WHERE engine != '$storage_engine' AND support IN ('YES','DEFAULT')` +--let $alternative_engine = `SELECT engine FROM information_schema.engines WHERE engine IN ('MEMORY','MyISAM') AND engine != '$storage_engine' ORDER BY engine LIMIT 1` --let $error_codes = ER_CANT_DO_ONLINE --let $online = 1 From b9f61c14b7b5c3bc99131c7cfcf8b4d3c1313901 Mon Sep 17 00:00:00 2001 From: Elena Stepanova Date: Mon, 5 Aug 2013 20:31:29 +0400 Subject: [PATCH 09/15] Deliberate change in behavior introduced in MySQL 5.5.31 along with the partitioning enhancement for Bug#14521864 --- .../storage_engine/parts/optimize_table.rdiff | 12 +-- .../storage_engine/parts/repair_table.rdiff | 80 ++----------------- 2 files changed, 11 insertions(+), 81 deletions(-) diff --git a/storage/innobase/mysql-test/storage_engine/parts/optimize_table.rdiff b/storage/innobase/mysql-test/storage_engine/parts/optimize_table.rdiff index 77ee7e2eb31..a35ba5167d9 100644 --- a/storage/innobase/mysql-test/storage_engine/parts/optimize_table.rdiff +++ b/storage/innobase/mysql-test/storage_engine/parts/optimize_table.rdiff @@ -1,25 +1,25 @@ ---- suite/storage_engine/parts/optimize_table.result 2012-07-12 22:16:39.343572304 +0400 -+++ suite/storage_engine/parts/optimize_table.reject 2012-07-15 20:07:01.632130348 +0400 +--- suite/storage_engine/parts/optimize_table.result 2013-07-18 22:55:38.000000000 +0400 ++++ suite/storage_engine/parts/optimize_table.reject 2013-08-05 19:45:19.000000000 +0400 @@ -9,18 +9,22 @@ INSERT INTO t1 (a,b) VALUES (3,'c'),(4,'d'); ALTER TABLE t1 OPTIMIZE PARTITION p1; Table Op Msg_type Msg_text -+test.t1 optimize note Table does not support optimize, doing recreate + analyze instead ++test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t2 (a,b) VALUES (4,'d'); ALTER TABLE t2 OPTIMIZE PARTITION p0 NO_WRITE_TO_BINLOG; Table Op Msg_type Msg_text -+test.t2 optimize note Table does not support optimize, doing recreate + analyze instead ++test.t2 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t2 optimize status OK INSERT INTO t1 (a,b) VALUES (6,'f'); ALTER TABLE t1 OPTIMIZE PARTITION ALL LOCAL; Table Op Msg_type Msg_text -+test.t1 optimize note Table does not support optimize, doing recreate + analyze instead ++test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t2 (a,b) VALUES (5,'e'); ALTER TABLE t2 OPTIMIZE PARTITION p1,p0; Table Op Msg_type Msg_text -+test.t2 optimize note Table does not support optimize, doing recreate + analyze instead ++test.t2 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t2 optimize status OK DROP TABLE t1, t2; DROP TABLE IF EXISTS t1,t2; diff --git a/storage/innobase/mysql-test/storage_engine/parts/repair_table.rdiff b/storage/innobase/mysql-test/storage_engine/parts/repair_table.rdiff index 7ddc57e0ead..35b150e82d1 100644 --- a/storage/innobase/mysql-test/storage_engine/parts/repair_table.rdiff +++ b/storage/innobase/mysql-test/storage_engine/parts/repair_table.rdiff @@ -1,26 +1,6 @@ ---- suite/storage_engine/parts/repair_table.result 2013-01-23 01:35:44.388267080 +0400 -+++ suite/storage_engine/parts/repair_table.reject 2013-01-23 01:44:40.337529283 +0400 -@@ -9,27 +9,27 @@ - INSERT INTO t2 (a,b) SELECT a, b FROM t1; - ALTER TABLE t1 REPAIR PARTITION p0; - Table Op Msg_type Msg_text --test.t1 repair status OK -+test.t1 repair note The storage engine for the table doesn't support repair - INSERT INTO t1 (a,b) VALUES (3,'c'); - ALTER TABLE t1 REPAIR PARTITION NO_WRITE_TO_BINLOG p0, p1; - Table Op Msg_type Msg_text --test.t1 repair status OK -+test.t1 repair note The storage engine for the table doesn't support repair - INSERT INTO t2 (a,b) VALUES (5,'e'),(6,'f'); - ALTER TABLE t2 REPAIR PARTITION LOCAL p1; - Table Op Msg_type Msg_text --test.t2 repair status OK -+test.t2 repair note The storage engine for the table doesn't support repair - INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h'); - ALTER TABLE t1 REPAIR PARTITION LOCAL ALL EXTENDED; - Table Op Msg_type Msg_text --test.t1 repair status OK -+test.t1 repair note The storage engine for the table doesn't support repair +--- suite/storage_engine/parts/repair_table.result 2013-07-18 22:55:38.000000000 +0400 ++++ suite/storage_engine/parts/repair_table.reject 2013-08-05 19:54:09.000000000 +0400 +@@ -25,7 +25,7 @@ INSERT INTO t1 (a,b) VALUES (10,'j'); ALTER TABLE t1 REPAIR PARTITION p1 QUICK USE_FRM; Table Op Msg_type Msg_text @@ -29,39 +9,7 @@ INSERT INTO t2 (a,b) VALUES (12,'l'); ALTER TABLE t2 REPAIR PARTITION NO_WRITE_TO_BINLOG ALL QUICK EXTENDED USE_FRM; Table Op Msg_type Msg_text --test.t2 repair status OK -+test.t2 repair note The storage engine for the table doesn't support repair - DROP TABLE t1, t2; - DROP TABLE IF EXISTS t1,t2; - CREATE TABLE t1 (a , b ) ENGINE= PARTITION BY HASH(a) PARTITIONS 2; -@@ -37,35 +37,35 @@ - CREATE TABLE t2 (a , b ) ENGINE= PARTITION BY HASH(a) PARTITIONS 2; - REPAIR TABLE t1; - Table Op Msg_type Msg_text --test.t1 repair status OK -+test.t1 repair note The storage engine for the table doesn't support repair - INSERT INTO t1 (a,b) VALUES (3,'c'); - INSERT INTO t2 (a,b) VALUES (4,'d'); - REPAIR NO_WRITE_TO_BINLOG TABLE t1, t2; - Table Op Msg_type Msg_text --test.t1 repair status OK --test.t2 repair status OK -+test.t1 repair note The storage engine for the table doesn't support repair -+test.t2 repair note The storage engine for the table doesn't support repair - INSERT INTO t2 (a,b) VALUES (5,'e'),(6,'f'); - REPAIR LOCAL TABLE t2; - Table Op Msg_type Msg_text --test.t2 repair status OK -+test.t2 repair note The storage engine for the table doesn't support repair - INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h'); - INSERT INTO t2 (a,b) VALUES (9,'i'); - REPAIR LOCAL TABLE t2, t1 EXTENDED; - Table Op Msg_type Msg_text --test.t2 repair status OK --test.t1 repair status OK -+test.t2 repair note The storage engine for the table doesn't support repair -+test.t1 repair note The storage engine for the table doesn't support repair - INSERT INTO t1 (a,b) VALUES (10,'j'); +@@ -58,8 +58,8 @@ INSERT INTO t2 (a,b) VALUES (11,'k'); REPAIR TABLE t1, t2 QUICK USE_FRM; Table Op Msg_type Msg_text @@ -72,25 +20,7 @@ INSERT INTO t1 (a,b) VALUES (12,'l'); INSERT INTO t2 (a,b) VALUES (13,'m'); REPAIR NO_WRITE_TO_BINLOG TABLE t1, t2 QUICK EXTENDED USE_FRM; - Table Op Msg_type Msg_text --test.t1 repair status OK --test.t2 repair status OK -+test.t1 repair note The storage engine for the table doesn't support repair -+test.t2 repair note The storage engine for the table doesn't support repair - FLUSH TABLE t1; - INSERT INTO t1 (a,b) VALUES (14,'n'); - ERROR HY000: Failed to read from the .par file -@@ -93,127 +93,21 @@ - CREATE TABLE t1 (a , b , (a)) ENGINE= PARTITION BY HASH(a) PARTITIONS 2; - REPAIR TABLE t1; - Table Op Msg_type Msg_text --test.t1 repair status OK -+test.t1 repair note The storage engine for the table doesn't support repair - INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h'); - REPAIR TABLE t1 EXTENDED; - Table Op Msg_type Msg_text --test.t1 repair status OK -+test.t1 repair note The storage engine for the table doesn't support repair +@@ -101,119 +101,13 @@ INSERT INTO t1 (a,b) VALUES (10,'j'); REPAIR TABLE t1 USE_FRM; Table Op Msg_type Msg_text From c98cd2c8161af772087376247e42a1ab89802097 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Mon, 5 Aug 2013 20:57:48 +0400 Subject: [PATCH 10/15] Update test results after fix for MDEV-4687 --- mysql-test/suite/innodb/r/innodb_mysql.result | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb_mysql.result b/mysql-test/suite/innodb/r/innodb_mysql.result index b2df98bbfa6..56bc86968b3 100644 --- a/mysql-test/suite/innodb/r/innodb_mysql.result +++ b/mysql-test/suite/innodb/r/innodb_mysql.result @@ -361,8 +361,8 @@ EXPLAIN SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id WHERE t1.name LIKE 'A%' OR FALSE; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index NULL fkey 5 NULL 5 Using index -1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.fkey 1 Using where +1 SIMPLE t1 index PRIMARY,name name 23 NULL 3 Using where; Using index +1 SIMPLE t2 ref fkey fkey 5 test.t1.id 1 Using index DROP TABLE t1,t2; CREATE TABLE t1 ( id int NOT NULL, From 220623572ddd463efb64f38284cce03545f52262 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 5 Aug 2013 17:34:38 +0300 Subject: [PATCH 11/15] Fix possible race condition in Query cache. --- sql/sql_cache.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 086a6f2ff5b..99baa70070e 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1312,17 +1312,17 @@ ulong Query_cache::resize(ulong query_cache_size_arg) { BLOCK_LOCK_WR(block); Query_cache_query *query= block->query(); - if (query && query->writer()) + if (query->writer()) { /* - Drop the writer; this will cancel any attempts to store + Drop the writer; this will cancel any attempts to store the processed statement associated with this writer. */ query->writer()->first_query_block= NULL; query->writer(0); refused++; } - BLOCK_UNLOCK_WR(block); + query->unlock_n_destroy(); block= block->next; } while (block != queries_blocks); } @@ -4247,11 +4247,11 @@ my_bool Query_cache::move_by_type(uchar **border, size_t key_length; key=query_cache_query_get_key((uchar*) block, &key_length, 0); my_hash_first(&queries, (uchar*) key, key_length, &record_idx); - // Move table of used tables - memmove((char*) new_block->table(0), (char*) block->table(0), - ALIGN_SIZE(n_tables*sizeof(Query_cache_block_table))); block->query()->unlock_n_destroy(); block->destroy(); + // Move table of used tables + memmove((char*) new_block->table(0), (char*) block->table(0), + ALIGN_SIZE(n_tables*sizeof(Query_cache_block_table))); new_block->init(len); new_block->type=Query_cache_block::QUERY; new_block->used=used; From e6a6f653a9c67741f67df9448b3182066939283c Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 8 Aug 2013 11:36:03 +0400 Subject: [PATCH 12/15] MDEV-4512 Valgrind warnings in my_long10_to_str_8bit on INTERVAL and DATE_ADD with incorrect types Fixing a typo: bit AND (&) was erroneously used instead of logical AND (&&) --- mysql-test/r/func_set.result | 19 +++++++++++++++++++ mysql-test/t/func_set.test | 18 ++++++++++++++++++ sql/item_cmpfunc.cc | 2 +- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_set.result b/mysql-test/r/func_set.result index 14ebc8203ec..4c7ec14490f 100644 --- a/mysql-test/r/func_set.result +++ b/mysql-test/r/func_set.result @@ -159,3 +159,22 @@ SELECT CONVERT( a USING latin1 ) FROM t2; CONVERT( a USING latin1 ) DROP TABLE t1, t2; +# +# Start of 5.3 tests +# +# +# MDEV-4512 Valgrind warnings in my_long10_to_str_8bit on INTERVAL and DATE_ADD with incorrect types +# +CREATE TABLE t1 (pk INT PRIMARY KEY); +INSERT INTO t1 VALUES (10),(11); +SELECT INTERVAL( 9, 1, DATE_ADD( pk, INTERVAL pk MINUTE_SECOND ), 9, 8, 3, 5, 2, 1 ) FROM t1; +INTERVAL( 9, 1, DATE_ADD( pk, INTERVAL pk MINUTE_SECOND ), 9, 8, 3, 5, 2, 1 ) +8 +8 +Warnings: +Warning 1292 Incorrect datetime value: '10' +Warning 1292 Incorrect datetime value: '11' +DROP TABLE t1; +# +# End of 5.3 tests +# diff --git a/mysql-test/t/func_set.test b/mysql-test/t/func_set.test index 294efa8caf1..1dab3aae852 100644 --- a/mysql-test/t/func_set.test +++ b/mysql-test/t/func_set.test @@ -97,3 +97,21 @@ SELECT CONVERT( a USING latin1 ) FROM t1; SELECT CONVERT( a USING latin1 ) FROM t2; DROP TABLE t1, t2; + + +--echo # +--echo # Start of 5.3 tests +--echo # + +--echo # +--echo # MDEV-4512 Valgrind warnings in my_long10_to_str_8bit on INTERVAL and DATE_ADD with incorrect types +--echo # +CREATE TABLE t1 (pk INT PRIMARY KEY); +INSERT INTO t1 VALUES (10),(11); +SELECT INTERVAL( 9, 1, DATE_ADD( pk, INTERVAL pk MINUTE_SECOND ), 9, 8, 3, 5, 2, 1 ) FROM t1; +DROP TABLE t1; + +--echo # +--echo # End of 5.3 tests +--echo # + diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index b2a91c8ec1e..2ebeb821321 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1960,7 +1960,7 @@ void Item_func_interval::fix_length_and_dec() for (uint i= 1; not_null_consts && i < rows; i++) { Item *el= row->element_index(i); - not_null_consts&= el->const_item() & !el->is_null(); + not_null_consts&= el->const_item() && !el->is_null(); } if (not_null_consts && From e9db0da787996c1244f579bbc313c82ecde95d2f Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 8 Aug 2013 12:58:28 +0400 Subject: [PATCH 13/15] MDEV-4653 Wrong result for CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5') --- mysql-test/r/timezone2.result | 19 +++++++++++++++++++ mysql-test/t/timezone2.test | 16 ++++++++++++++++ sql/item_timefunc.cc | 8 ++++++-- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/timezone2.result b/mysql-test/r/timezone2.result index e2e337628ce..70f5ef9edc1 100644 --- a/mysql-test/r/timezone2.result +++ b/mysql-test/r/timezone2.result @@ -309,3 +309,22 @@ CONVERT_TZ(1, 1, a) NULL DROP TABLE t1; End of 5.1 tests +# +# Start of 5.3 tests +# +# +# MDEV-4653 Wrong result for CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5') +# +SELECT CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5'); +CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '00:00:00' +SELECT CONVERT_TZ(TIME('2010-01-01 00:00:00'),'+00:00','+7:5'); +CONVERT_TZ(TIME('2010-01-01 00:00:00'),'+00:00','+7:5') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '00:00:00' +# +# End of 5.3 tests +# diff --git a/mysql-test/t/timezone2.test b/mysql-test/t/timezone2.test index c4445da107c..7764b39bf33 100644 --- a/mysql-test/t/timezone2.test +++ b/mysql-test/t/timezone2.test @@ -284,3 +284,19 @@ SELECT CONVERT_TZ(1, 1, a) FROM t1; DROP TABLE t1; --echo End of 5.1 tests + + +--echo # +--echo # Start of 5.3 tests +--echo # + +--echo # +--echo # MDEV-4653 Wrong result for CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5') +--echo # + +SELECT CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5'); +SELECT CONVERT_TZ(TIME('2010-01-01 00:00:00'),'+00:00','+7:5'); + +--echo # +--echo # End of 5.3 tests +--echo # diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 3322863a76d..d89cd01d26a 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1923,7 +1923,9 @@ bool Item_date_add_interval::get_date(MYSQL_TIME *ltime, uint fuzzy_date) { INTERVAL interval; - if (args[0]->get_date(ltime, 0) || + if (args[0]->get_date(ltime, + cached_field_type == MYSQL_TYPE_TIME ? + TIME_TIME_ONLY : 0) || get_interval_value(args[1], int_type, &value, &interval)) return (null_value=1); @@ -2301,7 +2303,9 @@ bool Item_time_typecast::get_date(MYSQL_TIME *ltime, uint fuzzy_date) if (ltime->time_type != MYSQL_TIMESTAMP_TIME) ltime->year= ltime->month= ltime->day= 0; ltime->time_type= MYSQL_TIMESTAMP_TIME; - return 0; + return (fuzzy_date & TIME_TIME_ONLY) ? 0 : + (null_value= check_date_with_warn(ltime, fuzzy_date, + MYSQL_TIMESTAMP_ERROR)); } From b718dc449bfc6aa5756a316d4db8853918765619 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 8 Aug 2013 13:33:15 +0200 Subject: [PATCH 14/15] mysql --skip-column-names flag should not affect alignment of field values, set num_flag[] unconditionally, not under "if (column_names)" http://ronaldbradford.com/blog/unexplained-trivial-mysql-behavior-2013-08-02/ --- client/mysql.cc | 2 +- mysql-test/r/mysql.result | 4 ++++ mysql-test/t/mysql.test | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/client/mysql.cc b/client/mysql.cc index e9e21c0289d..e3885422563 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -3510,6 +3510,7 @@ print_table_data(MYSQL_RES *result) if (length < 4 && !IS_NOT_NULL(field->flags)) length=4; // Room for "NULL" field->max_length=length; + num_flag[mysql_field_tell(result) - 1]= IS_NUM(field->type); separator.fill(separator.length()+length+2,'-'); separator.append('+'); } @@ -3529,7 +3530,6 @@ print_table_data(MYSQL_RES *result) tee_fprintf(PAGER, " %-*s |",(int) min(display_length, MAX_COLUMN_LENGTH), field->name); - num_flag[off]= IS_NUM(field->type); } (void) tee_fputs("\n", PAGER); tee_puts((char*) separator.ptr(), PAGER); diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index 4d2ac25a0eb..cb705d285fe 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -515,5 +515,9 @@ aa`bb``cc drop database `aa``bb````cc`; a >>\ndelimiter\n<< ++-------------------+ +| a | +| aaaaaaaaaaaaaaaaa | ++-------------------+ End of tests diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index 9187cf82513..6281bb5f4c1 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -603,5 +603,10 @@ delimiter EOF --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/13639125.sql +# +# --skip-column-names and alignment +# +--exec $MYSQL -t -N -e "SELECT 'a' union select 'aaaaaaaaaaaaaaaaa'" + --echo --echo End of tests From f1b4718ec894664df221704bb70fed80bdc14070 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 12 Aug 2013 16:47:59 +0400 Subject: [PATCH 15/15] MDEV-4652 Wrong result for CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00')) --- mysql-test/r/type_time.result | 9 +++++++++ mysql-test/t/type_time.test | 6 ++++++ sql/item.cc | 3 ++- sql/item_func.cc | 7 +++++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/type_time.result b/mysql-test/r/type_time.result index 5a047f32062..23943c3c848 100644 --- a/mysql-test/r/type_time.result +++ b/mysql-test/r/type_time.result @@ -182,5 +182,14 @@ NULL Warnings: Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' # +# MDEV-4652 Wrong result for CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00'))) +# +SELECT CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00'))); +CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00'))) +00:00:01.000000 +SELECT CONCAT(GREATEST(TIME('32 00:00:01'),TIME('00:00:00'))); +CONCAT(GREATEST(TIME('32 00:00:01'),TIME('00:00:00'))) +768:00:01.000000 +# # End of 5.3 tests # diff --git a/mysql-test/t/type_time.test b/mysql-test/t/type_time.test index 26d77ad378e..1c0ba75e274 100644 --- a/mysql-test/t/type_time.test +++ b/mysql-test/t/type_time.test @@ -128,6 +128,12 @@ drop table t1; --echo # SELECT CONVERT_TZ(GREATEST(TIME('00:00:00'),TIME('00:00:00')),'+00:00','+7:5'); +--echo # +--echo # MDEV-4652 Wrong result for CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00'))) +--echo # +SELECT CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00'))); +SELECT CONCAT(GREATEST(TIME('32 00:00:01'),TIME('00:00:00'))); + --echo # --echo # End of 5.3 tests --echo # diff --git a/sql/item.cc b/sql/item.cc index f5687f18cb3..1383500b007 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -252,7 +252,8 @@ String *Item::val_string_from_decimal(String *str) String *Item::val_string_from_date(String *str) { MYSQL_TIME ltime; - if (get_date(<ime, 0) || + if (get_date(<ime, + field_type() == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0) || str->alloc(MAX_DATE_STRING_REP_LENGTH)) { null_value= 1; diff --git a/sql/item_func.cc b/sql/item_func.cc index e1a2bd44c34..9079de6f06e 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2480,6 +2480,13 @@ bool Item_func_min_max::get_date(MYSQL_TIME *ltime, uint fuzzy_date) ltime->time_type= MYSQL_TIMESTAMP_DATE; ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0; } + else if (compare_as_dates->field_type() == MYSQL_TYPE_TIME) + { + ltime->time_type= MYSQL_TIMESTAMP_TIME; + ltime->hour+= (ltime->month * 32 + ltime->day) * 24; + ltime->month= ltime->day= 0; + } + return 0; }