diff --git a/client/client_priv.h b/client/client_priv.h index 8d25bddc286..24df2bdee7f 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -49,5 +49,5 @@ enum options_client #ifdef HAVE_NDBCLUSTER_DB OPT_NDBCLUSTER, OPT_NDB_CONNECTSTRING, #endif - OPT_IGNORE_TABLE + OPT_IGNORE_TABLE,OPT_INSERT_IGNORE }; diff --git a/client/mysqldump.c b/client/mysqldump.c index b07a36aa7ad..976a6642ea0 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -83,7 +83,7 @@ static my_bool verbose=0,tFlag=0,cFlag=0,dFlag=0,quick= 1, extended_insert= 1, opt_autocommit=0,opt_disable_keys=1,opt_xml=0, opt_delete_master_logs=0, tty_password=0, opt_single_transaction=0, opt_comments= 0, opt_compact= 0, - opt_hex_blob=0, opt_order_by_primary=0; + opt_hex_blob=0, opt_order_by_primary=0, opt_ignore=0; static ulong opt_max_allowed_packet, opt_net_buffer_length; static MYSQL mysql_connection,*sock=0; static char insert_pat[12 * 1024],*opt_password=0,*current_user=0, @@ -257,6 +257,9 @@ static struct my_option my_long_options[] = "use the directive multiple times, once for each table. Each table must " "be specified with both database and table names, e.g. --ignore-table=database.table", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"insert-ignore", OPT_INSERT_IGNORE, "Insert rows with INSERT IGNORE.", + (gptr*) &opt_ignore, (gptr*) &opt_ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + 0, 0}, {"lines-terminated-by", OPT_LTB, "Lines in the i.file are terminated by ...", (gptr*) &lines_terminated, (gptr*) &lines_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -1100,13 +1103,15 @@ static uint get_table_structure(char *table, char *db) my_bool init=0; uint numFields; char *strpos, *result_table, *opt_quoted_table; - const char *delayed; + const char *insert_option; char name_buff[NAME_LEN+3],table_buff[NAME_LEN*2+3]; char table_buff2[NAME_LEN*2+3]; FILE *sql_file = md_result_file; DBUG_ENTER("get_table_structure"); - delayed= opt_delayed ? " DELAYED " : ""; + insert_option= (opt_delayed && opt_ignore) ? " DELAYED IGNORE " : + opt_delayed ? " DELAYED " : + opt_ignore ? " IGNORE " : ""; if (verbose) fprintf(stderr, "-- Retrieving table structure for table %s...\n", table); @@ -1190,11 +1195,11 @@ static uint get_table_structure(char *table, char *db) if (cFlag) my_snprintf(insert_pat, sizeof(insert_pat), "INSERT %sINTO %s (", - delayed, opt_quoted_table); + insert_option, opt_quoted_table); else { my_snprintf(insert_pat, sizeof(insert_pat), "INSERT %sINTO %s VALUES ", - delayed, opt_quoted_table); + insert_option, opt_quoted_table); if (!extended_insert) strcat(insert_pat,"("); } @@ -1258,11 +1263,11 @@ static uint get_table_structure(char *table, char *db) } if (cFlag) my_snprintf(insert_pat, sizeof(insert_pat), "INSERT %sINTO %s (", - delayed, result_table); + insert_option, result_table); else { my_snprintf(insert_pat, sizeof(insert_pat), "INSERT %sINTO %s VALUES ", - delayed, result_table); + insert_option, result_table); if (!extended_insert) strcat(insert_pat,"("); } diff --git a/cmd-line-utils/libedit/Makefile.am b/cmd-line-utils/libedit/Makefile.am index 9ff005c7156..03f3eb65fbc 100644 --- a/cmd-line-utils/libedit/Makefile.am +++ b/cmd-line-utils/libedit/Makefile.am @@ -24,7 +24,7 @@ pkginclude_HEADERS = readline/readline.h noinst_HEADERS = chared.h el.h el_term.h histedit.h key.h parse.h refresh.h sig.h \ sys.h tokenizer.h config.h hist.h map.h prompt.h read.h \ - search.h tty.h libedit_term.h + search.h tty.h libedit_term.h vis.h EXTRA_DIST = makelist.sh np/unvis.c np/strlcpy.c np/vis.c np/vis.h np/strlcat.c np/fgetln.c diff --git a/include/my_global.h b/include/my_global.h index f051ed2918e..9f3acef0ff6 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -43,6 +43,11 @@ #define HAVE_ERRNO_AS_DEFINE #endif /* __CYGWIN__ */ +/* Determine when to use "#pragma interface" */ +#if !defined(__CYGWIN__) && !defined(__ICC) && defined(__GNUC__) && (__GNUC__ < 3) +#define USE_PRAGMA_INTERFACE +#endif + #if defined(i386) && !defined(__i386__) #define __i386__ #endif diff --git a/include/raid.h b/include/raid.h index 04c54393e54..c840afcbaab 100644 --- a/include/raid.h +++ b/include/raid.h @@ -89,7 +89,7 @@ extern "C" { #ifdef __cplusplus } -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c index 6fa41fb3fd0..70074e44c6f 100644 --- a/libmysqld/libmysqld.c +++ b/libmysqld/libmysqld.c @@ -199,6 +199,14 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, unix_socket=0; db_name = db ? my_strdup(db,MYF(MY_WME)) : NULL; + /* Send client information for access check */ + client_flag|=CLIENT_CAPABILITIES; + if (client_flag & CLIENT_MULTI_STATEMENTS) + client_flag|= CLIENT_MULTI_RESULTS; + client_flag&= ~CLIENT_COMPRESS; + if (db) + client_flag|=CLIENT_CONNECT_WITH_DB; + mysql->thd= create_embedded_thd(client_flag, db_name); init_embedded_mysql(mysql, client_flag, db_name); @@ -209,11 +217,6 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, if (mysql_init_charset(mysql)) goto error; - /* Send client information for access check */ - client_flag|=CLIENT_CAPABILITIES; - client_flag&= ~CLIENT_COMPRESS; - if (db) - client_flag|=CLIENT_CONNECT_WITH_DB; mysql->server_status= SERVER_STATUS_AUTOCOMMIT; if (mysql->options.init_commands) diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result index 766e43b2299..3037047b513 100644 --- a/mysql-test/r/group_min_max.result +++ b/mysql-test/r/group_min_max.result @@ -1961,3 +1961,10 @@ a varchar(30), b varchar(30), primary key(a), key(b) select distinct a from t1; a drop table t1; +create table t1(a int, key(a)) engine=innodb; +insert into t1 values(1); +select a, count(a) from t1 group by a with rollup; +a count(a) +1 1 +NULL 1 +drop table t1; diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 6c8e7a9cf8b..0b993d681e3 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -748,3 +748,7 @@ TABLE_CONSTRAINTS TABLE_NAME select KEY_COLUMN_USAGE TABLE_NAME select delete from mysql.user where user='mysqltest_4'; flush privileges; +SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA; +table_schema count(*) +information_schema 15 +mysql 17 diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index fdbdd26b00c..6d03e8603cb 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -631,3 +631,63 @@ UNLOCK TABLES; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; DROP TABLE t1; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t1 VALUES (4),(5),(6); + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +DROP TABLE IF EXISTS `t1`; +CREATE TABLE `t1` ( + `a` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + + +/*!40000 ALTER TABLE `t1` DISABLE KEYS */; +LOCK TABLES `t1` WRITE; +INSERT IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6); +UNLOCK TABLES; +/*!40000 ALTER TABLE `t1` ENABLE KEYS */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +DROP TABLE IF EXISTS `t1`; +CREATE TABLE `t1` ( + `a` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + + +/*!40000 ALTER TABLE `t1` DISABLE KEYS */; +INSERT DELAYED IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6); +/*!40000 ALTER TABLE `t1` ENABLE KEYS */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +DROP TABLE t1; diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test index d85b3395853..9feb4f33682 100644 --- a/mysql-test/t/group_min_max.test +++ b/mysql-test/t/group_min_max.test @@ -610,3 +610,14 @@ create table t1 ( --enable_warnings select distinct a from t1; drop table t1; + +# +# Bug #9798: group by with rollup +# + +--disable_warnings +create table t1(a int, key(a)) engine=innodb; +--enable_warnings +insert into t1 values(1); +select a, count(a) from t1 group by a with rollup; +drop table t1; diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 3e322ad2f5b..05dfeb67ccc 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1,4 +1,4 @@ -# This test uses grants, which can't get tested for embedded server +# This test uses grants, which can't get tested for embedded server -- source include/not_embedded.inc # Test for information_schema.schemata & @@ -486,3 +486,10 @@ where COLUMN_NAME='TABLE_NAME'; connection default; delete from mysql.user where user='mysqltest_4'; flush privileges; + +# +# Bug #9404 information_schema: Weird error messages +# with SELECT SUM() ... GROUP BY queries +# +SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA; + diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 949c62ef288..ceae60c4577 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -204,3 +204,14 @@ CREATE TABLE t1 (a char(10)); INSERT INTO t1 VALUES ('\''); --exec $MYSQL_DUMP --skip-comments test t1 DROP TABLE t1; + +# +# Test for --insert-ignore +# + +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t1 VALUES (4),(5),(6); +--exec $MYSQL_DUMP --skip-comments --insert-ignore test t1 +--exec $MYSQL_DUMP --skip-comments --insert-ignore --delayed-insert test t1 +DROP TABLE t1; diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index 84ae9674de9..e86688c4315 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -1,3 +1,5 @@ +-- source include/have_innodb.inc + # # Problem with range optimizer # diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index 6c0487aee40..1f28b8e4538 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -15,6 +15,7 @@ MV="mv" STRIP=1 DEBUG=0 SILENT=0 +MACHINE= TMP=/tmp SUFFIX="" NDBCLUSTER= @@ -26,6 +27,7 @@ parse_arguments() { --tmp=*) TMP=`echo "$arg" | sed -e "s;--tmp=;;"` ;; --suffix=*) SUFFIX=`echo "$arg" | sed -e "s;--suffix=;;"` ;; --no-strip) STRIP=0 ;; + --machine) MACHINE=`echo "$arg" | sed -e "s;--machine=;;"` ;; --silent) SILENT=1 ;; --with-ndbcluster) NDBCLUSTER=1 ;; *) @@ -38,6 +40,8 @@ parse_arguments() { parse_arguments "$@" + + #make # This should really be integrated with automake and not duplicate the @@ -310,8 +314,17 @@ system=`echo $system | sed -e 's/linux-gnu/linux/g'` system=`echo $system | sed -e 's/solaris2.\([0-9]*\)/solaris\1/g'` system=`echo $system | sed -e 's/sco3.2v\(.*\)/openserver\1/g'` +# Use the override --machine if present +if [ $MACHINE != "" ] ; then + machine= $MACHINE +fi + # Change the distribution to a long descriptive name NEW_NAME=mysql@MYSQL_SERVER_SUFFIX@-$version-$system-$machine$SUFFIX + +# Print the platform name for build logs +echo "PLATFORM NAME: $system-$machine" + BASE2=$TMP/$NEW_NAME rm -r -f $BASE2 mv $BASE $BASE2 diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index e1e2d4ce148..33db1eae82a 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -11,7 +11,6 @@ in_rpm=0 windows=0 defaults="" user="" -tmp_file=/tmp/mysql_install_db.$$ case "$1" in --no-defaults|--defaults-file=*|--defaults-extra-file=*) @@ -223,10 +222,8 @@ then then echo "Fill help tables" fi - echo "use mysql;" > $tmp_file - cat $tmp_file $fill_help_tables | eval "$mysqld_install_cmd_line" + (echo "use mysql;"; cat $fill_help_tables) | eval "$mysqld_install_cmd_line" res=$? - rm $tmp_file if test $res != 0 then echo "" diff --git a/sql/examples/ha_archive.h b/sql/examples/ha_archive.h index e2c40c880a4..c68462be1ab 100644 --- a/sql/examples/ha_archive.h +++ b/sql/examples/ha_archive.h @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/examples/ha_example.h b/sql/examples/ha_example.h index 3c6ce4220ee..ae72e5bb275 100644 --- a/sql/examples/ha_example.h +++ b/sql/examples/ha_example.h @@ -21,7 +21,7 @@ that you can implement. */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/field.h b/sql/field.h index 853b5dd13ff..edc3286ae8d 100644 --- a/sql/field.h +++ b/sql/field.h @@ -20,7 +20,7 @@ variables must declare the size_of() member function. */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/ha_berkeley.h b/sql/ha_berkeley.h index 1d49c3be0e9..f6376939445 100644 --- a/sql/ha_berkeley.h +++ b/sql/ha_berkeley.h @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/ha_blackhole.h b/sql/ha_blackhole.h index b6f924e94b9..84a386e17f8 100644 --- a/sql/ha_blackhole.h +++ b/sql/ha_blackhole.h @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/ha_heap.h b/sql/ha_heap.h index fb526888b01..5d50270ec5b 100644 --- a/sql/ha_heap.h +++ b/sql/ha_heap.h @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/ha_innodb.h b/sql/ha_innodb.h index 6c412a889b2..bcbc38650b3 100644 --- a/sql/ha_innodb.h +++ b/sql/ha_innodb.h @@ -21,7 +21,7 @@ Innodb */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/ha_myisam.h b/sql/ha_myisam.h index 7e14a3b7941..bbd9721f8e2 100644 --- a/sql/ha_myisam.h +++ b/sql/ha_myisam.h @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/ha_myisammrg.h b/sql/ha_myisammrg.h index 6058c32c805..3bc9c11d4be 100644 --- a/sql/ha_myisammrg.h +++ b/sql/ha_myisammrg.h @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index 81b2873d9dd..8012f16e42e 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -21,7 +21,7 @@ /* The class defining a handle to an NDB Cluster table */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/handler.h b/sql/handler.h index b5fc5503556..1b5f6e13d04 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -17,7 +17,7 @@ /* Definitions for parameters to do with handler-routines */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/item.h b/sql/item.h index 697194e2878..0e15e539067 100644 --- a/sql/item.h +++ b/sql/item.h @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 96101f7b691..a929d509723 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -17,7 +17,7 @@ /* compare and test functions */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/item_func.cc b/sql/item_func.cc index 283d7463293..3c87b6ef920 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2533,6 +2533,28 @@ longlong Item_func_bit_count::val_int() #ifdef HAVE_DLOPEN +void udf_handler::cleanup() +{ + if (!not_original) + { + if (initialized) + { + if (u_d->func_deinit != NULL) + { + void (*deinit)(UDF_INIT *) = (void (*)(UDF_INIT*)) + u_d->func_deinit; + (*deinit)(&initid); + } + free_udf(u_d); + initialized= FALSE; + } + if (buffers) // Because of bug in ecc + delete [] buffers; + buffers= 0; + } +} + + bool udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func, uint arg_count, Item **arguments) @@ -2805,6 +2827,13 @@ my_decimal *udf_handler::val_decimal(my_bool *null_value, my_decimal *dec_buf) } +void Item_udf_func::cleanup() +{ + udf.cleanup(); + Item_func::cleanup(); +} + + double Item_func_udf_float::val_real() { DBUG_ASSERT(fixed == 1); @@ -2930,21 +2959,8 @@ String *Item_func_udf_str::val_str(String *str) udf_handler::~udf_handler() { - if (!not_original) - { - if (initialized) - { - if (u_d->func_deinit != NULL) - { - void (*deinit)(UDF_INIT *) = (void (*)(UDF_INIT*)) - u_d->func_deinit; - (*deinit)(&initid); - } - free_udf(u_d); - } - if (buffers) // Because of bug in ecc - delete [] buffers; - } + /* Everything should be properly cleaned up by this moment. */ + DBUG_ASSERT(not_original || !(initialized || buffers)); } #else diff --git a/sql/item_func.h b/sql/item_func.h index 57faa05ce23..b53f2a0b9c6 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -17,7 +17,7 @@ /* Function items used by mysql */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif @@ -879,6 +879,7 @@ public: fixed= 1; return res; } + void cleanup(); Item_result result_type () const { return udf.result_type(); } table_map not_null_tables() const { return 0; } }; diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h index e19036cc982..c45fb88a48a 100644 --- a/sql/item_geofunc.h +++ b/sql/item_geofunc.h @@ -19,7 +19,7 @@ #ifdef HAVE_SPATIAL -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index eec81f953fb..d7c77829cfc 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -17,7 +17,8 @@ /* This file defines all string functions */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE +#error PRAGMA #pragma interface /* gcc class implementation */ #endif diff --git a/sql/item_subselect.h b/sql/item_subselect.h index bdea5c5efee..84935429353 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -16,7 +16,7 @@ /* subselect Item */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 76bf8189a0e..a5694189976 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -2456,6 +2456,17 @@ bool Item_udf_sum::add() DBUG_RETURN(0); } +void Item_udf_sum::cleanup() +{ + /* + udf_handler::cleanup() nicely handles case when we have not + original item but one created by copy_or_same() method. + */ + udf.cleanup(); + Item_sum::cleanup(); +} + + Item *Item_sum_udf_float::copy_or_same(THD* thd) { return new (thd->mem_root) Item_sum_udf_float(thd, this); diff --git a/sql/item_sum.h b/sql/item_sum.h index fb72fed1c5e..bb5d31b4b4f 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -17,7 +17,7 @@ /* classes for sum functions */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif @@ -667,6 +667,7 @@ public: bool add(); void reset_field() {}; void update_field() {}; + void cleanup(); }; diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index ab511ae2883..c8fb2b39836 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -17,7 +17,7 @@ /* Function items used by mysql */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 85b5e7270ec..b81a083d9b3 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -6670,6 +6670,8 @@ cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts, - NGA = QA - (GA union C) = {NG_1, ..., NG_m} - the ones not in GROUP BY and not referenced by MIN/MAX functions. with the following properties specified below. + B3. If Q has a GROUP BY WITH ROLLUP clause the access method is not + applicable. SA1. There is at most one attribute in SA referenced by any number of MIN and/or MAX functions which, which if present, is denoted as C. @@ -6754,6 +6756,8 @@ cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts, other field as in: "select min(a) from t1 group by a" ? - We assume that the general correctness of the GROUP-BY query was checked before this point. Is this correct, or do we have to check it completely? + - Lift the limitation in condition (B3), that is, make this access method + applicable to ROLLUP queries. RETURN If mem_root != NULL @@ -6793,7 +6797,8 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree) DBUG_RETURN(NULL); /* This is not a select statement. */ if ((join->tables != 1) || /* The query must reference one table. */ ((!join->group_list) && /* Neither GROUP BY nor a DISTINCT query. */ - (!join->select_distinct))) + (!join->select_distinct)) || + (thd->lex->select_lex.olap == ROLLUP_TYPE)) /* Check (B3) for ROLLUP */ DBUG_RETURN(NULL); if (table->s->keys == 0) /* There are no indexes to use. */ DBUG_RETURN(NULL); diff --git a/sql/opt_range.h b/sql/opt_range.h index 71680b5a1fc..8d365262334 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -20,7 +20,7 @@ #ifndef _opt_range_h #define _opt_range_h -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/procedure.h b/sql/procedure.h index 5d0dccbcd5e..aceadd10883 100644 --- a/sql/procedure.h +++ b/sql/procedure.h @@ -17,7 +17,7 @@ /* When using sql procedures */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/protocol.h b/sql/protocol.h index de379db541b..01331ef64ba 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/set_var.h b/sql/set_var.h index 585f6df3547..32f45187124 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -16,7 +16,7 @@ /* Classes to support the SET command */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/sql_class.h b/sql/sql_class.h index f3e7a0d34b5..51d77ee6f4f 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -17,7 +17,7 @@ /* Classes in mysql */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/sql_list.h b/sql/sql_list.h index 55d9d668bdd..ac0f7f7012a 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index bc6d7821268..81f58310775 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1437,9 +1437,6 @@ bool do_command(THD *thd) } else { - if (thd->killed == THD::KILL_QUERY || thd->killed == THD::KILL_BAD_DATA) - thd->killed= THD::NOT_KILLED; - packet=(char*) net->read_pos; command = (enum enum_server_command) (uchar) packet[0]; if (command >= COM_END) @@ -1486,6 +1483,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd, bool error= 0; DBUG_ENTER("dispatch_command"); + if (thd->killed == THD::KILL_QUERY || thd->killed == THD::KILL_BAD_DATA) + thd->killed= THD::NOT_KILLED; + thd->command=command; /* Commands which will always take a long time should be marked with diff --git a/sql/sql_select.h b/sql/sql_select.h index 82efb62f7a3..a27fbc60856 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -17,7 +17,7 @@ /* classes to use when handling where clause */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/sql_string.h b/sql/sql_string.h index 7ece9885040..c05305d9265 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -16,7 +16,7 @@ /* This file is originally from the mysql distribution. Coded by monty */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/sql_udf.h b/sql/sql_udf.h index 51ea6d4d627..4df3fe0949d 100644 --- a/sql/sql_udf.h +++ b/sql/sql_udf.h @@ -17,7 +17,7 @@ /* This file defines structures needed by udf functions */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface #endif @@ -67,6 +67,7 @@ class udf_handler :public Sql_alloc bool get_arguments(); bool fix_fields(THD *thd,struct st_table_list *tlist,Item_result_field *item, uint arg_count,Item **args); + void cleanup(); double val(my_bool *null_value) { if (get_arguments()) diff --git a/sql/tztime.h b/sql/tztime.h index 777e521d761..cbf359e8961 100644 --- a/sql/tztime.h +++ b/sql/tztime.h @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class interface */ #endif diff --git a/storage/heap/hp_hash.c b/storage/heap/hp_hash.c index 52a250bd7af..7f02eb587a8 100644 --- a/storage/heap/hp_hash.c +++ b/storage/heap/hp_hash.c @@ -635,13 +635,12 @@ int hp_key_cmp(HP_KEYDEF *keydef, const byte *rec, const byte *key) key+= 2; /* skip key pack length */ if (cs->mbmaxlen > 1) { - uint char_length= seg->length / cs->mbmaxlen; - char_length_key= my_charpos(cs, key, key + char_length_key, - char_length); - set_if_smaller(char_length_key, seg->length); - char_length_rec= my_charpos(cs, pos, pos + char_length_rec, - char_length); - set_if_smaller(char_length_rec, seg->length); + uint char_length1, char_length2; + char_length1= char_length2= seg->length / cs->mbmaxlen; + char_length1= my_charpos(cs, key, key + char_length_key, char_length1); + set_if_smaller(char_length_key, char_length1); + char_length2= my_charpos(cs, pos, pos + char_length_rec, char_length2); + set_if_smaller(char_length_rec, char_length2); } if (cs->coll->strnncollsp(seg->charset,