diff options
author | Jon Olav Hauglid <jon.hauglid@oracle.com> | 2010-09-24 08:46:43 +0200 |
---|---|---|
committer | Jon Olav Hauglid <jon.hauglid@oracle.com> | 2010-09-24 08:46:43 +0200 |
commit | bf1d4487fb5cce46ce3ceeb3d3fab005bba4036f (patch) | |
tree | 4bcb5f0af19f57b815b5e6fae8942c6093aa81b9 | |
parent | 6b8032ed4f8dc03c22f4fd0f168a6eed26d68846 (diff) | |
parent | 04b3b7c1a6cb88b8f4bf97f5647d195b70602d1a (diff) | |
download | mariadb-git-bf1d4487fb5cce46ce3ceeb3d3fab005bba4036f.tar.gz |
Merge from mysql-5.5-bugfixing to mysql-5.5-runtime.
-rw-r--r-- | mysql-test/r/type_newdecimal.result | 12 | ||||
-rw-r--r-- | mysql-test/suite/perfschema/r/server_init.result | 18 | ||||
-rw-r--r-- | mysql-test/suite/perfschema/t/server_init.test | 76 | ||||
-rw-r--r-- | mysql-test/t/type_newdecimal.test | 9 | ||||
-rw-r--r-- | sql/field.cc | 5 | ||||
-rw-r--r-- | sql/log.cc | 5 | ||||
-rw-r--r-- | sql/log.h | 1 | ||||
-rw-r--r-- | sql/sql_plugin.cc | 2 | ||||
-rw-r--r-- | sql/sql_repl.cc | 16 | ||||
-rw-r--r-- | storage/perfschema/pfs_engine_table.cc | 12 |
10 files changed, 72 insertions, 84 deletions
diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result index e5fbf158a8b..819e41f41c5 100644 --- a/mysql-test/r/type_newdecimal.result +++ b/mysql-test/r/type_newdecimal.result @@ -1908,4 +1908,16 @@ group by PAY.id + 1; mult v_net_with_discount v_total 1.0000 27.18 27.180000 DROP TABLE currencies, payments, sub_tasks; +# +# BUG#52171: distinct aggregates on unsigned decimal fields trigger assertions +# +CREATE TABLE t1 (a DECIMAL(4,4) UNSIGNED); +INSERT INTO t1 VALUES (0); +SELECT AVG(DISTINCT a) FROM t1; +AVG(DISTINCT a) +0.00000000 +SELECT SUM(DISTINCT a) FROM t1; +SUM(DISTINCT a) +0.0000 +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/suite/perfschema/r/server_init.result b/mysql-test/suite/perfschema/r/server_init.result index 5f3b071484d..0c1e06d157c 100644 --- a/mysql-test/suite/perfschema/r/server_init.result +++ b/mysql-test/suite/perfschema/r/server_init.result @@ -116,18 +116,10 @@ where name like "wait/synch/mutex/sql/LOCK_rpl_status"; count(name) 1 select count(name) from MUTEX_INSTANCES -where name like "wait/synch/mutex/sql/LOG_INFO::lock"; -count(name) -1 -select count(name) from MUTEX_INSTANCES where name like "wait/synch/mutex/sql/Query_cache::structure_guard_mutex"; count(name) 1 select count(name) from MUTEX_INSTANCES -where name like "wait/synch/mutex/sql/Event_scheduler::LOCK_scheduler_state"; -count(name) -1 -select count(name) from MUTEX_INSTANCES where name like "wait/synch/mutex/sql/LOCK_event_metadata"; count(name) 1 @@ -144,15 +136,15 @@ where name like "wait/synch/mutex/sql/Cversion_lock"; count(name) 1 select count(name) from MUTEX_INSTANCES -where name like "wait/synch/mutex/sql/LOCK_xid_cache"; +where name like "wait/synch/mutex/sql/LOCK_audit_mask"; count(name) 1 select count(name) from MUTEX_INSTANCES -where name like "wait/synch/mutex/sql/LOCK_plugin"; +where name like "wait/synch/mutex/sql/LOCK_xid_cache"; count(name) 1 select count(name) from MUTEX_INSTANCES -where name like "wait/synch/mutex/sql/LOCK_gdl"; +where name like "wait/synch/mutex/sql/LOCK_plugin"; count(name) 1 select count(name) from MUTEX_INSTANCES @@ -212,10 +204,6 @@ where name like "wait/synch/cond/sql/Query_cache::COND_cache_status_changed"; count(name) 1 select count(name) from COND_INSTANCES -where name like "wait/synch/cond/sql/Event_scheduler::COND_state"; -count(name) -1 -select count(name) from COND_INSTANCES where name like "wait/synch/cond/sql/COND_queue_state"; count(name) 1 diff --git a/mysql-test/suite/perfschema/t/server_init.test b/mysql-test/suite/perfschema/t/server_init.test index 2e19d2c843a..cc461374a79 100644 --- a/mysql-test/suite/perfschema/t/server_init.test +++ b/mysql-test/suite/perfschema/t/server_init.test @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009, 2010, 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 @@ -10,8 +10,8 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# along with this program; if not, write to the Free Software Foundation, +# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA # Tests for PERFORMANCE_SCHEMA @@ -43,10 +43,6 @@ select count(name) from MUTEX_INSTANCES select count(name) from MUTEX_INSTANCES where name like "wait/synch/mutex/mysys/THR_LOCK_myisam"; -# Does not exist in mysql 5.5, 6.0 only -# select count(name) from MUTEX_INSTANCES -# where name like "wait/synch/mutex/mysys/THR_LOCK_myisam_log"; - select count(name) from MUTEX_INSTANCES where name like "wait/synch/mutex/mysys/THR_LOCK_heap"; @@ -83,11 +79,6 @@ select count(name) from MUTEX_INSTANCES select count(name) from MUTEX_INSTANCES where name like "wait/synch/mutex/sql/LOCK_delayed_insert"; -# Named LOCK_uuid_short in 6.0 only -# select count(name) from MUTEX_INSTANCES -# where name like "wait/synch/mutex/sql/LOCK_uuid_short"; - -# Named LOCK_uuid_generator in 5.5, LOCK_uuid_short in 6.0 select count(name) from MUTEX_INSTANCES where name like "wait/synch/mutex/sql/LOCK_uuid_generator"; @@ -130,14 +121,16 @@ select count(name) from MUTEX_INSTANCES select count(name) from MUTEX_INSTANCES where name like "wait/synch/mutex/sql/LOCK_rpl_status"; -select count(name) from MUTEX_INSTANCES - where name like "wait/synch/mutex/sql/LOG_INFO::lock"; +# LOG_INFO object are created on demand, and are not global. +# select count(name) from MUTEX_INSTANCES +# where name like "wait/synch/mutex/sql/LOG_INFO::lock"; select count(name) from MUTEX_INSTANCES where name like "wait/synch/mutex/sql/Query_cache::structure_guard_mutex"; -select count(name) from MUTEX_INSTANCES - where name like "wait/synch/mutex/sql/Event_scheduler::LOCK_scheduler_state"; +# The event scheduler may be disabled +# select count(name) from MUTEX_INSTANCES +# where name like "wait/synch/mutex/sql/Event_scheduler::LOCK_scheduler_state"; select count(name) from MUTEX_INSTANCES where name like "wait/synch/mutex/sql/LOCK_event_metadata"; @@ -148,16 +141,11 @@ select count(name) from MUTEX_INSTANCES select count(name) from MUTEX_INSTANCES where name like "wait/synch/mutex/sql/LOCK_user_locks"; -# Does not exist in mysql 5.5, 6.0 only -# select count(name) from MUTEX_INSTANCES -# where name like "wait/synch/mutex/sql/LOCK_mdl"; - select count(name) from MUTEX_INSTANCES where name like "wait/synch/mutex/sql/Cversion_lock"; -# Does not exist in mysql 5.5, 6.0 only -# select count(name) from MUTEX_INSTANCES -# where name like "wait/synch/mutex/sql/LOCK_audit_mask"; +select count(name) from MUTEX_INSTANCES + where name like "wait/synch/mutex/sql/LOCK_audit_mask"; select count(name) from MUTEX_INSTANCES where name like "wait/synch/mutex/sql/LOCK_xid_cache"; @@ -165,28 +153,13 @@ select count(name) from MUTEX_INSTANCES select count(name) from MUTEX_INSTANCES where name like "wait/synch/mutex/sql/LOCK_plugin"; -select count(name) from MUTEX_INSTANCES - where name like "wait/synch/mutex/sql/LOCK_gdl"; +# Not a global variable, may be destroyed already. +# select count(name) from MUTEX_INSTANCES +# where name like "wait/synch/mutex/sql/LOCK_gdl"; select count(name) from MUTEX_INSTANCES where name like "wait/synch/mutex/sql/tz_LOCK"; -# Does not exist in mysql 5.5, 6.0 only -# select count(name) from MUTEX_INSTANCES -# where name like "wait/synch/mutex/sql/slave_start"; - -# Does not exist in mysql 5.5, 6.0 only -# select count(name) from MUTEX_INSTANCES -# where name like "wait/synch/mutex/sql/BML_class::THR_LOCK_BML"; - -# Does not exist in mysql 5.5, 6.0 only -# select count(name) from MUTEX_INSTANCES -# where name like "wait/synch/mutex/sql/BML_class::THR_LOCK_BML_active"; - -# Does not exist in mysql 5.5, 6.0 only -# select count(name) from MUTEX_INSTANCES -# where name like "wait/synch/mutex/sql/BML_class::THR_LOCK_BML_get"; - # Verify that these global rwlocks have been properly initilized in sql select count(name) from RWLOCK_INSTANCES @@ -230,25 +203,10 @@ select count(name) from COND_INSTANCES select count(name) from COND_INSTANCES where name like "wait/synch/cond/sql/Query_cache::COND_cache_status_changed"; -select count(name) from COND_INSTANCES - where name like "wait/synch/cond/sql/Event_scheduler::COND_state"; +# The event scheduler may be disabled +# select count(name) from COND_INSTANCES +# where name like "wait/synch/cond/sql/Event_scheduler::COND_state"; select count(name) from COND_INSTANCES where name like "wait/synch/cond/sql/COND_queue_state"; -# Does not exist in mysql 5.5, 6.0 only -# select count(name) from COND_INSTANCES -# where name like "wait/synch/cond/sql/COND_mdl"; - -# Does not exist in mysql 5.5, 6.0 only -# select count(name) from COND_INSTANCES -# where name like "wait/synch/cond/sql/BML_class::COND_BML"; - -# Does not exist in mysql 5.5, 6.0 only -# select count(name) from COND_INSTANCES -# where name like "wait/synch/cond/sql/BML_class::COND_BML_registered"; - -# Does not exist in mysql 5.5, 6.0 only -# select count(name) from COND_INSTANCES -# where name like "wait/synch/cond/sql/BML_class::COND_BML_release"; - diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test index 3f418a339cc..bd70e64b1ad 100644 --- a/mysql-test/t/type_newdecimal.test +++ b/mysql-test/t/type_newdecimal.test @@ -1509,5 +1509,14 @@ group by PAY.id + 1; DROP TABLE currencies, payments, sub_tasks; +--echo # +--echo # BUG#52171: distinct aggregates on unsigned decimal fields trigger assertions +--echo # + +CREATE TABLE t1 (a DECIMAL(4,4) UNSIGNED); +INSERT INTO t1 VALUES (0); +SELECT AVG(DISTINCT a) FROM t1; +SELECT SUM(DISTINCT a) FROM t1; +DROP TABLE t1; --echo End of 5.1 tests diff --git a/sql/field.cc b/sql/field.cc index fc55426b177..113b4752648 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -9104,7 +9104,7 @@ void Create_field::init_for_tmp_table(enum_field_types sql_type_arg, case MYSQL_TYPE_NEWDECIMAL: case MYSQL_TYPE_FLOAT: case MYSQL_TYPE_DOUBLE: - pack_flag= FIELDFLAG_DECIMAL | FIELDFLAG_NUMBER | + pack_flag= FIELDFLAG_NUMBER | (decimals_arg & FIELDFLAG_MAX_DEC) << FIELDFLAG_DEC_SHIFT; break; @@ -9153,12 +9153,13 @@ void Create_field::init_for_tmp_table(enum_field_types sql_type_arg, (maybe_null ? FIELDFLAG_MAYBE_NULL : 0) | (is_unsigned ? 0 : FIELDFLAG_DECIMAL); - DBUG_PRINT("debug", ("pack_flag: %s%s%s%s%s, pack_type: %d", + DBUG_PRINT("debug", ("pack_flag: %s%s%s%s%s%s, pack_type: %d", FLAGSTR(pack_flag, FIELDFLAG_BINARY), FLAGSTR(pack_flag, FIELDFLAG_NUMBER), FLAGSTR(pack_flag, FIELDFLAG_INTERVAL), FLAGSTR(pack_flag, FIELDFLAG_GEOM), FLAGSTR(pack_flag, FIELDFLAG_BLOB), + FLAGSTR(pack_flag, FIELDFLAG_DECIMAL), f_packtype(pack_flag))); DBUG_VOID_RETURN; } diff --git a/sql/log.cc b/sql/log.cc index 88352706318..8cf5dd9ae65 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -5284,11 +5284,8 @@ int MYSQL_BIN_LOG::wait_for_update_bin_log(THD* thd, const struct timespec *timeout) { int ret= 0; - const char* old_msg = thd->proc_info; DBUG_ENTER("wait_for_update_bin_log"); - old_msg= thd->enter_cond(&update_cond, &LOCK_log, - "Master has sent all binlog to slave; " - "waiting for binlog to be updated"); + if (!timeout) mysql_cond_wait(&update_cond, &LOCK_log); else diff --git a/sql/log.h b/sql/log.h index ebb23deda81..5df05e7ff90 100644 --- a/sql/log.h +++ b/sql/log.h @@ -460,6 +460,7 @@ public: inline char* get_log_fname() { return log_file_name; } inline char* get_name() { return name; } inline mysql_mutex_t* get_log_lock() { return &LOCK_log; } + inline mysql_cond_t* get_log_cond() { return &update_cond; } inline IO_CACHE* get_log_file() { return &log_file; } inline void lock_index() { mysql_mutex_lock(&LOCK_index);} diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 956be657af2..f48a3183289 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -519,7 +519,7 @@ static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report) /* no op */; cur= (struct st_mysql_plugin*) - my_malloc(i*sizeof(struct st_mysql_plugin), MYF(MY_ZEROFILL|MY_WME)); + my_malloc((i+1)*sizeof(struct st_mysql_plugin), MYF(MY_ZEROFILL|MY_WME)); if (!cur) { free_plugin_mem(&plugin_dl); diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index ab6c6e738b2..7bca41f1265 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -448,6 +448,8 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, const char *errmsg = "Unknown error"; NET* net = &thd->net; mysql_mutex_t *log_lock; + mysql_cond_t *log_cond; + bool binlog_can_be_corrupted= FALSE; #ifndef DBUG_OFF int left_events = max_binlog_dump_events; @@ -591,7 +593,8 @@ impossible position"; mysql_bin_log, and it's already inited, and it will be destroyed only at shutdown). */ - log_lock = mysql_bin_log.get_log_lock(); + log_lock= mysql_bin_log.get_log_lock(); + log_cond= mysql_bin_log.get_log_cond(); if (pos > BIN_LOG_HEADER_SIZE) { /* reset transmit packet for the event read from binary log @@ -826,6 +829,7 @@ impossible position"; #ifndef DBUG_OFF ulong hb_info_counter= 0; #endif + const char* old_msg= thd->proc_info; signal_cnt= mysql_bin_log.signal_cnt; do { @@ -834,6 +838,9 @@ impossible position"; DBUG_ASSERT(heartbeat_ts && heartbeat_period != 0); set_timespec_nsec(*heartbeat_ts, heartbeat_period); } + thd->enter_cond(log_cond, log_lock, + "Master has sent all binlog to slave; " + "waiting for binlog to be updated"); ret= mysql_bin_log.wait_for_update_bin_log(thd, heartbeat_ts); DBUG_ASSERT(ret == 0 || (heartbeat_period != 0 && coord != NULL)); if (ret == ETIMEDOUT || ret == ETIME) @@ -849,12 +856,15 @@ impossible position"; #endif /* reset transmit packet for the heartbeat event */ if (reset_transmit_packet(thd, flags, &ev_offset, &errmsg)) + { + thd->exit_cond(old_msg); goto err; + } if (send_heartbeat_event(net, packet, coord)) { errmsg = "Failed on my_net_write()"; my_errno= ER_UNKNOWN_ERROR; - mysql_mutex_unlock(log_lock); + thd->exit_cond(old_msg); goto err; } } @@ -863,7 +873,7 @@ impossible position"; DBUG_PRINT("wait",("binary log received update or a broadcast signal caught")); } } while (signal_cnt == mysql_bin_log.signal_cnt && !thd->killed); - mysql_mutex_unlock(log_lock); + thd->exit_cond(old_msg); } break; diff --git a/storage/perfschema/pfs_engine_table.cc b/storage/perfschema/pfs_engine_table.cc index df00811959c..3b1959c98d2 100644 --- a/storage/perfschema/pfs_engine_table.cc +++ b/storage/perfschema/pfs_engine_table.cc @@ -223,6 +223,8 @@ int PFS_engine_table::read_row(TABLE *table, Field **fields) { my_bitmap_map *org_bitmap; + Field *f; + Field **fields_reset; /* Make sure the table structure is as expected before mapping @@ -240,6 +242,16 @@ int PFS_engine_table::read_row(TABLE *table, /* We internally write to Fields to support the read interface */ org_bitmap= dbug_tmp_use_all_columns(table, table->write_set); + + /* + Some callers of the storage engine interface do not honor the + f->is_null() flag, and will attempt to read the data itself. + A known offender is mysql_checksum_table(). + For robustness, reset every field. + */ + for (fields_reset= fields; (f= *fields_reset) ; fields_reset++) + f->reset(); + int result= read_row_values(table, buf, fields, read_all); dbug_tmp_restore_column_map(table->write_set, org_bitmap); |