diff options
author | Konstantin Osipov <kostja@sun.com> | 2010-07-27 18:32:42 +0400 |
---|---|---|
committer | Konstantin Osipov <kostja@sun.com> | 2010-07-27 18:32:42 +0400 |
commit | c4c678f653077f6ca93bd8b50906410e29d4b127 (patch) | |
tree | f5b4dd56c20ccff8f87fcf2ff244d4be368ac972 /sql | |
parent | 740c0d3a87c07dd5f482db5705449143993e7385 (diff) | |
parent | 8ee568cde7bef3893f5500d07ef45cb58107cff3 (diff) | |
download | mariadb-git-c4c678f653077f6ca93bd8b50906410e29d4b127.tar.gz |
Merge trunk-bugfixing -> trunk-runtime.
Diffstat (limited to 'sql')
49 files changed, 246 insertions, 1181 deletions
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 7107a68ee84..e8a594c4d8b 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -43,7 +43,7 @@ SET (SQL_SOURCE discover.cc ../libmysql/errmsg.c field.cc field_conv.cc filesort.cc gstream.cc sha2.cc ha_partition.cc - handler.cc hash_filo.cc hash_filo.h sql_plugin_services.h + handler.cc hash_filo.h sql_plugin_services.h hostname.cc init.cc item.cc item_buff.cc item_cmpfunc.cc item_create.cc item_func.cc item_geofunc.cc item_row.cc item_strfunc.cc item_subselect.cc item_sum.cc item_timefunc.cc @@ -60,7 +60,7 @@ SET (SQL_SOURCE sql_cache.cc sql_class.cc sql_client.cc sql_crypt.cc sql_crypt.h sql_cursor.cc sql_db.cc sql_delete.cc sql_derived.cc sql_do.cc sql_error.cc sql_handler.cc sql_help.cc sql_insert.cc sql_lex.cc - sql_list.cc sql_load.cc sql_manager.cc sql_map.cc sql_parse.cc + sql_list.cc sql_load.cc sql_manager.cc sql_parse.cc sql_partition.cc sql_plugin.cc sql_prepare.cc sql_rename.cc debug_sync.cc debug_sync.h sql_repl.cc sql_select.cc sql_show.cc sql_state.c sql_string.cc @@ -185,22 +185,15 @@ RUN_BISON( # Gen_lex_hash ADD_EXECUTABLE(gen_lex_hash gen_lex_hash.cc) -TARGET_LINK_LIBRARIES(gen_lex_hash mysys) ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h - COMMAND gen_lex_hash ARGS > lex_hash.h.tmp && - ${CMAKE_COMMAND} -E copy_if_different lex_hash.h.tmp lex_hash.h - COMMAND ${CMAKE_COMMAND} -E remove -f lex_hash.h.tmp - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gen_lex_hash.cc) + COMMAND gen_lex_hash > lex_hash.h +) MYSQL_ADD_EXECUTABLE(mysql_tzinfo_to_sql tztime.cc) SET_TARGET_PROPERTIES(mysql_tzinfo_to_sql PROPERTIES COMPILE_FLAGS "-DTZINFO2SQL") -TARGET_LINK_LIBRARIES(mysql_tzinfo_to_sql ${MYSQLD_STATIC_PLUGIN_LIBS} - mysys dbug strings vio regex - ${LIBWRAP} ${LIBCRYPT} ${LIBDL} - ${SSL_LIBRARIES}) +TARGET_LINK_LIBRARIES(mysql_tzinfo_to_sql mysys) ADD_CUSTOM_TARGET( GenServerSource diff --git a/sql/Makefile.am b/sql/Makefile.am index 4b1ecbbc8da..7fed55f3cd6 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -90,7 +90,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \ item_create.h item_subselect.h item_row.h \ sql_priv.h item_geofunc.h sql_bitmap.h \ procedure.h sql_class.h sql_lex.h sql_list.h \ - sql_map.h sql_string.h unireg.h \ + sql_string.h unireg.h \ sql_error.h field.h handler.h mysqld_suffix.h \ sql_profile.h mysqld.h sql_help.h frm_crypt.h \ ha_ndbcluster.h ha_ndbcluster_cond.h \ @@ -135,7 +135,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc sql_partition.cc \ item_row.cc item_geofunc.cc item_xmlfunc.cc \ field.cc strfunc.cc key.cc sql_class.cc sql_list.cc \ net_serv.cc protocol.cc sql_state.c \ - lock.cc sql_string.cc sql_manager.cc sql_map.cc \ + lock.cc sql_string.cc sql_manager.cc \ main.cc mysqld.cc password.c hash_filo.cc hostname.cc \ sql_connect.cc scheduler.cc sql_parse.cc \ keycaches.cc set_var.cc sql_yacc.yy sys_vars.cc \ @@ -160,8 +160,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc sql_partition.cc \ rpl_reporting.cc \ sql_union.cc sql_derived.cc \ sql_client.cc \ - repl_failsafe.h repl_failsafe.cc \ - sql_olap.cc sql_view.cc \ + repl_failsafe.h repl_failsafe.cc sql_view.cc \ gstream.cc spatial.cc sql_help.cc sql_cursor.cc \ tztime.cc my_decimal.cc\ sp_head.cc sp_pcontext.cc sp_rcontext.cc sp.cc \ diff --git a/sql/field.cc b/sql/field.cc index 56d60ff5b28..75576c59876 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1277,61 +1277,6 @@ int Field::warn_if_overflow(int op_result) } -#ifdef NOT_USED -static bool test_if_real(const char *str,int length, CHARSET_INFO *cs) -{ - cs= system_charset_info; // QQ move test_if_real into CHARSET_INFO struct - - while (length && my_isspace(cs,*str)) - { // Allow start space - length--; str++; - } - if (!length) - return 0; - if (*str == '+' || *str == '-') - { - length--; str++; - if (!length || !(my_isdigit(cs,*str) || *str == '.')) - return 0; - } - while (length && my_isdigit(cs,*str)) - { - length--; str++; - } - if (!length) - return 1; - if (*str == '.') - { - length--; str++; - while (length && my_isdigit(cs,*str)) - { - length--; str++; - } - } - if (!length) - return 1; - if (*str == 'E' || *str == 'e') - { - if (length < 3 || (str[1] != '+' && str[1] != '-') || - !my_isdigit(cs,str[2])) - return 0; - length-=3; - str+=3; - while (length && my_isdigit(cs,*str)) - { - length--; str++; - } - } - for (; length ; length--, str++) - { // Allow end space - if (!my_isspace(cs,*str)) - return 0; - } - return 1; -} -#endif - - /** Interpret field value as an integer but return the result as a string. @@ -4198,7 +4143,7 @@ int Field_float::store(double nr) } else #endif - memcpy_fixed(ptr,(uchar*) &j,sizeof(j)); + memcpy(ptr, &j, sizeof(j)); return error; } @@ -4221,7 +4166,7 @@ double Field_float::val_real(void) } else #endif - memcpy_fixed((uchar*) &j,ptr,sizeof(j)); + memcpy(&j, ptr, sizeof(j)); return ((double) j); } @@ -4235,7 +4180,7 @@ longlong Field_float::val_int(void) } else #endif - memcpy_fixed((uchar*) &j,ptr,sizeof(j)); + memcpy(&j, ptr, sizeof(j)); return (longlong) rint(j); } @@ -4252,7 +4197,7 @@ String *Field_float::val_str(String *val_buffer, } else #endif - memcpy_fixed((uchar*) &nr,ptr,sizeof(nr)); + memcpy(&nr, ptr, sizeof(nr)); uint to_length=max(field_length,70); val_buffer->alloc(to_length); @@ -4290,8 +4235,8 @@ int Field_float::cmp(const uchar *a_ptr, const uchar *b_ptr) else #endif { - memcpy_fixed(&a,a_ptr,sizeof(float)); - memcpy_fixed(&b,b_ptr,sizeof(float)); + memcpy(&a, a_ptr, sizeof(float)); + memcpy(&b, b_ptr, sizeof(float)); } return (a < b) ? -1 : (a > b) ? 1 : 0; } @@ -4308,7 +4253,7 @@ void Field_float::sort_string(uchar *to,uint length __attribute__((unused))) } else #endif - memcpy_fixed(&nr,ptr,sizeof(float)); + memcpy(&nr, ptr, sizeof(float)); uchar *tmp= to; if (nr == (float) 0.0) @@ -4319,7 +4264,7 @@ void Field_float::sort_string(uchar *to,uint length __attribute__((unused))) else { #ifdef WORDS_BIGENDIAN - memcpy_fixed(tmp,&nr,sizeof(nr)); + memcpy(tmp, &nr, sizeof(nr)); #else tmp[0]= ptr[3]; tmp[1]=ptr[2]; tmp[2]= ptr[1]; tmp[3]=ptr[0]; #endif @@ -7497,7 +7442,7 @@ double Field_blob::val_real(void) uint32 length; CHARSET_INFO *cs; - memcpy_fixed(&blob,ptr+packlength,sizeof(char*)); + memcpy(&blob, ptr+packlength, sizeof(char*)); if (!blob) return 0.0; length= get_length(ptr); @@ -7511,7 +7456,7 @@ longlong Field_blob::val_int(void) ASSERT_COLUMN_MARKED_FOR_READ; int not_used; char *blob; - memcpy_fixed(&blob,ptr+packlength,sizeof(char*)); + memcpy(&blob, ptr+packlength, sizeof(char*)); if (!blob) return 0; uint32 length=get_length(ptr); @@ -7523,7 +7468,7 @@ String *Field_blob::val_str(String *val_buffer __attribute__((unused)), { ASSERT_COLUMN_MARKED_FOR_READ; char *blob; - memcpy_fixed(&blob,ptr+packlength,sizeof(char*)); + memcpy(&blob, ptr+packlength, sizeof(char*)); if (!blob) val_ptr->set("",0,charset()); // A bit safer than ->length(0) else @@ -7537,7 +7482,7 @@ my_decimal *Field_blob::val_decimal(my_decimal *decimal_value) ASSERT_COLUMN_MARKED_FOR_READ; const char *blob; size_t length; - memcpy_fixed(&blob, ptr+packlength, sizeof(const uchar*)); + memcpy(&blob, ptr+packlength, sizeof(const uchar*)); if (!blob) { blob= ""; @@ -7565,8 +7510,8 @@ int Field_blob::cmp_max(const uchar *a_ptr, const uchar *b_ptr, uint max_length) { uchar *blob1,*blob2; - memcpy_fixed(&blob1,a_ptr+packlength,sizeof(char*)); - memcpy_fixed(&blob2,b_ptr+packlength,sizeof(char*)); + memcpy(&blob1, a_ptr+packlength, sizeof(char*)); + memcpy(&blob2, b_ptr+packlength, sizeof(char*)); uint a_len= get_length(a_ptr), b_len= get_length(b_ptr); set_if_smaller(a_len, max_length); set_if_smaller(b_len, max_length); @@ -7580,8 +7525,8 @@ int Field_blob::cmp_binary(const uchar *a_ptr, const uchar *b_ptr, char *a,*b; uint diff; uint32 a_length,b_length; - memcpy_fixed(&a,a_ptr+packlength,sizeof(char*)); - memcpy_fixed(&b,b_ptr+packlength,sizeof(char*)); + memcpy(&a, a_ptr+packlength, sizeof(char*)); + memcpy(&b, b_ptr+packlength, sizeof(char*)); a_length=get_length(a_ptr); if (a_length > max_length) a_length=max_length; @@ -7662,7 +7607,7 @@ int Field_blob::key_cmp(const uchar *key_ptr, uint max_key_length) { uchar *blob1; uint blob_length=get_length(ptr); - memcpy_fixed(&blob1,ptr+packlength,sizeof(char*)); + memcpy(&blob1, ptr+packlength, sizeof(char*)); CHARSET_INFO *cs= charset(); uint local_char_length= max_key_length / cs->mbmaxlen; local_char_length= my_charpos(cs, blob1, blob1+blob_length, @@ -7740,7 +7685,7 @@ void Field_blob::sort_string(uchar *to,uint length) break; } } - memcpy_fixed(&blob,ptr+packlength,sizeof(char*)); + memcpy(&blob, ptr+packlength, sizeof(char*)); blob_length=my_strnxfrm(field_charset, to, length, blob, blob_length); @@ -8709,7 +8654,7 @@ String *Field_bit::val_str(String *val_buffer, mi_int8store(buff,bits); val_buffer->alloc(length); - memcpy_fixed((char*) val_buffer->ptr(), buff+8-length, length); + memcpy((char *) val_buffer->ptr(), buff+8-length, length); val_buffer->length(length); val_buffer->set_charset(&my_charset_bin); return val_buffer; diff --git a/sql/field.h b/sql/field.h index 46d8a2aa6d9..7b250c34fe4 100644 --- a/sql/field.h +++ b/sql/field.h @@ -32,7 +32,6 @@ #include "sql_error.h" /* MYSQL_ERROR */ #define DATETIME_DEC 6 -const uint32 max_field_size= (uint32) 4294967295U; class Send_field; class Protocol; @@ -1763,22 +1762,22 @@ public: void put_length(uchar *pos, uint32 length); inline void get_ptr(uchar **str) { - memcpy_fixed((uchar*) str,ptr+packlength,sizeof(uchar*)); + memcpy(str, ptr+packlength, sizeof(uchar*)); } inline void get_ptr(uchar **str, uint row_offset) { - memcpy_fixed((uchar*) str,ptr+packlength+row_offset,sizeof(char*)); + memcpy(str, ptr+packlength+row_offset, sizeof(char*)); } inline void set_ptr(uchar *length, uchar *data) { memcpy(ptr,length,packlength); - memcpy_fixed(ptr+packlength,&data,sizeof(char*)); + memcpy(ptr+packlength, &data,sizeof(char*)); } void set_ptr_offset(my_ptrdiff_t ptr_diff, uint32 length, uchar *data) { uchar *ptr_ofs= ADD_TO_PTR(ptr,ptr_diff,uchar*); store_length(ptr_ofs, packlength, length); - memcpy_fixed(ptr_ofs+packlength,&data,sizeof(char*)); + memcpy(ptr_ofs+packlength, &data, sizeof(char*)); } inline void set_ptr(uint32 length, uchar *data) { @@ -1797,7 +1796,7 @@ public: return 1; } tmp=(uchar*) value.ptr(); - memcpy_fixed(ptr+packlength,&tmp,sizeof(char*)); + memcpy(ptr+packlength, &tmp, sizeof(char*)); return 0; } virtual uchar *pack(uchar *to, const uchar *from, diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 299865e6114..ea6ff82e0aa 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -286,7 +286,7 @@ static void do_copy_blob(Copy_field *copy) { ulong length=((Field_blob*) copy->from_field)->get_length(); ((Field_blob*) copy->to_field)->store_length(length); - memcpy_fixed(copy->to_ptr,copy->from_ptr,sizeof(char*)); + memcpy(copy->to_ptr, copy->from_ptr, sizeof(char*)); } static void do_conv_blob(Copy_field *copy) diff --git a/sql/filesort.cc b/sql/filesort.cc index 2398785a038..419f18263cc 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -511,6 +511,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, volatile THD::killed_state *killed= &thd->killed; handler *file; MY_BITMAP *save_read_set, *save_write_set; + bool skip_record; DBUG_ENTER("find_all_keys"); DBUG_PRINT("info",("using: %s", (select ? select->quick ? "ranges" : "where": @@ -603,7 +604,8 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, } if (error == 0) param->examined_rows++; - if (error == 0 && (!select || select->skip_record() == 0)) + if (!error && (!select || + (!select->skip_record(thd, &skip_record) && !skip_record))) { if (idx == param->keys) { @@ -1663,7 +1665,7 @@ void change_double_for_sort(double nr,uchar *to) else { #ifdef WORDS_BIGENDIAN - memcpy_fixed(tmp,&nr,sizeof(nr)); + memcpy(tmp, &nr, sizeof(nr)); #else { uchar *ptr= (uchar*) &nr; diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 5a0904f87b9..a9c03f7e2a7 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -77,33 +77,12 @@ So, we can read full search-structure as 32-bit word */ #define NO_YACC_SYMBOLS -#include "my_global.h" -#include "my_sys.h" -#include "m_string.h" -#ifndef __GNU_LIBRARY__ -#define __GNU_LIBRARY__ // Skip warnings in getopt.h -#endif -#include <my_getopt.h> +#include <my_global.h> #include "mysql_version.h" #include "lex.h" - -const char *default_dbug_option="d:t:o,/tmp/gen_lex_hash.trace"; - -struct my_option my_long_options[] = -{ -#ifdef DBUG_OFF - {"debug", '#', "This is a non-debug version. Catch this and exit", - 0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, -#else - {"debug", '#', "Output debug log", (uchar**) &default_dbug_option, - (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, -#endif - {"help", '?', "Display help and exit", - 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"version", 'V', "Output version information and exit", - 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} -}; +#include <stdlib.h> +#include <stdio.h> +#include <string.h> struct hash_lex_struct { @@ -340,57 +319,6 @@ void print_find_structs() } -static void usage(int version) -{ - printf("%s Ver 3.6 Distrib %s, for %s (%s)\n", - my_progname, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE); - if (version) - return; - puts("Copyright (C) 2001 MySQL AB, by VVA and Monty"); - puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\ -and you are welcome to modify and redistribute it under the GPL license\n"); - puts("This program generates a perfect hashing function for the sql_lex.cc"); - printf("Usage: %s [OPTIONS]\n\n", my_progname); - my_print_help(my_long_options); -} - - -extern "C" my_bool -get_one_option(int optid, const struct my_option *opt __attribute__((unused)), - char *argument __attribute__((unused))) -{ - switch(optid) { - case 'V': - usage(1); - exit(0); - case 'I': - case '?': - usage(0); - exit(0); - case '#': - DBUG_PUSH(argument ? argument : default_dbug_option); - break; - } - return 0; -} - - -static int get_options(int argc, char **argv) -{ - int ho_error; - - if ((ho_error= handle_options(&argc, &argv, my_long_options, get_one_option))) - exit(ho_error); - - if (argc >= 1) - { - usage(0); - exit(1); - } - return(0); -} - - int check_dup_symbols(SYMBOL *s1, SYMBOL *s2) { if (s1->length!=s2->length || strncmp(s1->name,s2->name,s1->length)) @@ -441,11 +369,7 @@ int check_duplicates() int main(int argc,char **argv) { - MY_INIT(argv[0]); - DBUG_PROCESS(argv[0]); - if (get_options(argc,(char **) argv)) - exit(1); /* Broken up to indicate that it's not advice to you, gentle reader. */ printf("/*\n\n Do " "not " "edit " "this " "file " "directly!\n\n*/\n"); @@ -562,7 +486,6 @@ static SYMBOL *get_hash_symbol(const char *s,\n\ }\n\ }\n" ); - my_end(0); exit(0); } diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index bd3cd780bc5..7891f658f45 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -64,10 +64,6 @@ #include "debug_sync.h" static const char *ha_par_ext= ".par"; -#ifdef NOT_USED -static int free_share(PARTITION_SHARE * share); -static PARTITION_SHARE *get_share(const char *table_name, TABLE * table); -#endif /**************************************************************************** MODULE create/delete handler object @@ -1129,13 +1125,6 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt, part= i * num_subparts + j; DBUG_PRINT("info", ("Optimize subpartition %u (%s)", part, sub_elem->partition_name)); -#ifdef NOT_USED - if (print_admin_msg(thd, "note", table_share->db.str, table->alias, - opt_op_name[flag], - "Start to operate on subpartition %s", - sub_elem->partition_name)) - DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR); -#endif if ((error= handle_opt_part(thd, check_opt, m_file[part], flag))) { /* print a line which partition the error belongs to */ @@ -1162,13 +1151,6 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt, { DBUG_PRINT("info", ("Optimize partition %u (%s)", i, part_elem->partition_name)); -#ifdef NOT_USED - if (print_admin_msg(thd, "note", table_share->db.str, table->alias, - opt_op_name[flag], - "Start to operate on partition %s", - part_elem->partition_name)) - DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR); -#endif if ((error= handle_opt_part(thd, check_opt, m_file[i], flag))) { /* print a line which partition the error belongs to */ diff --git a/sql/ha_partition.h b/sql/ha_partition.h index cdbfb2163c7..cfab2dde394 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -143,9 +143,6 @@ private: Variables for lock structures. */ THR_LOCK_DATA lock; /* MySQL lock */ -#ifdef NOT_USED - PARTITION_SHARE *share; /* Shared lock info */ -#endif /* TRUE <=> this object was created with ha_partition::clone and doesn't diff --git a/sql/handler.cc b/sql/handler.cc index e67f5d6862c..9893b3cac16 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -190,15 +190,6 @@ plugin_ref ha_lock_engine(THD *thd, const handlerton *hton) } -#ifdef NOT_USED -static handler *create_default(TABLE_SHARE *table, MEM_ROOT *mem_root) -{ - handlerton *hton= ha_default_handlerton(current_thd); - return (hton && hton->create) ? hton->create(hton, table, mem_root) : NULL; -} -#endif - - handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type) { plugin_ref plugin; @@ -239,10 +230,6 @@ handlerton *ha_checktype(THD *thd, enum legacy_db_type database_type, RUN_HOOK(transaction, after_rollback, (thd, FALSE)); switch (database_type) { -#ifndef NO_HASH - case DB_TYPE_HASH: - return ha_resolve_by_legacy_type(thd, DB_TYPE_HASH); -#endif case DB_TYPE_MRG_ISAM: return ha_resolve_by_legacy_type(thd, DB_TYPE_MRG_MYISAM); default: diff --git a/sql/handler.h b/sql/handler.h index 9f262542a4f..cad97c1f751 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -33,10 +33,6 @@ #include <ft_global.h> #include <keycache.h> -#ifndef NO_HASH -#define NO_HASH /* Not yet implemented */ -#endif - // the following is for checking tables #define HA_ADMIN_ALREADY_DONE 1 diff --git a/sql/hostname.cc b/sql/hostname.cc index d309efc4196..5311d9ada73 100644 --- a/sql/hostname.cc +++ b/sql/hostname.cc @@ -126,7 +126,7 @@ static void prepare_hostname_cache_key(const char *ip_string, DBUG_ASSERT(ip_string_length < HOST_ENTRY_KEY_SIZE); memset(ip_key, 0, HOST_ENTRY_KEY_SIZE); - memcpy_fixed(ip_key, ip_string, ip_string_length); + memcpy(ip_key, ip_string, ip_string_length); } static inline Host_entry *hostname_cache_search(const char *ip_key) @@ -148,7 +148,7 @@ static bool add_hostname_impl(const char *ip_key, const char *hostname) char *hostname_copy; - memcpy_fixed(&entry->ip_key, ip_key, HOST_ENTRY_KEY_SIZE); + memcpy(&entry->ip_key, ip_key, HOST_ENTRY_KEY_SIZE); if (hostname_size) { diff --git a/sql/item.cc b/sql/item.cc index 13b4aa96c76..92cf2df8a4c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4914,11 +4914,8 @@ Item *Item_field::equal_fields_propagator(uchar *arg) e.g. <bin_col> = <int_col> AND <bin_col> = <hex_string>) since Items don't know the context they are in and there are functions like IF (<hex_string>, 'yes', 'no'). - The same problem occurs when comparing a DATE/TIME field with a - DATE/TIME represented as an int and as a string. */ - if (!item || - (cmp_context != (Item_result)-1 && item->cmp_context != cmp_context)) + if (!item || !has_compatible_context(item)) item= this; else if (field && (field->flags & ZEROFILL_FLAG) && IS_NUM(field->type())) { @@ -4982,8 +4979,7 @@ Item *Item_field::replace_equal_field(uchar *arg) Item *const_item= item_equal->get_const(); if (const_item) { - if (cmp_context != (Item_result)-1 && - const_item->cmp_context != cmp_context) + if (!has_compatible_context(const_item)) return this; return const_item; } @@ -5053,21 +5049,6 @@ enum_field_types Item::field_type() const } -bool Item::is_datetime() -{ - switch (field_type()) - { - case MYSQL_TYPE_DATE: - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_TIMESTAMP: - return TRUE; - default: - break; - } - return FALSE; -} - - String *Item::check_well_formed_result(String *str, bool send_error) { /* Check whether we got a well-formed string */ @@ -7468,6 +7449,8 @@ bool Item_cache_datetime::cache_value_int() return FALSE; value_cached= TRUE; + // Mark cached string value obsolete + str_value_cached= FALSE; /* Assume here that the underlying item will do correct conversion.*/ int_value= example->val_int_result(); null_value= example->null_value; @@ -7480,7 +7463,13 @@ bool Item_cache_datetime::cache_value() { if (!example) return FALSE; + + if (cmp_context == INT_RESULT) + return cache_value_int(); + str_value_cached= TRUE; + // Mark cached int value obsolete + value_cached= FALSE; /* Assume here that the underlying item will do correct conversion.*/ String *res= example->str_result(&str_value); if (res && res != &str_value) @@ -7504,8 +7493,47 @@ void Item_cache_datetime::store(Item *item, longlong val_arg) String *Item_cache_datetime::val_str(String *str) { DBUG_ASSERT(fixed == 1); - if (!str_value_cached && !cache_value()) - return NULL; + if (!str_value_cached) + { + /* + When it's possible the Item_cache_datetime uses INT datetime + representation due to speed reasons. But still, it always has the STRING + result type and thus it can be asked to return a string value. + It is possible that at this time cached item doesn't contain correct + string value, thus we have to convert cached int value to string and + return it. + */ + if (value_cached) + { + MYSQL_TIME ltime; + if (str_value.alloc(MAX_DATE_STRING_REP_LENGTH)) + return NULL; + if (cached_field_type == MYSQL_TYPE_TIME) + { + ulonglong time= int_value; + DBUG_ASSERT(time < TIME_MAX_VALUE); + set_zero_time(<ime, MYSQL_TIMESTAMP_TIME); + ltime.second= time % 100; + time/= 100; + ltime.minute= time % 100; + time/= 100; + ltime.hour= time % 100; + } + else + { + int was_cut; + longlong res; + res= number_to_datetime(val_int(), <ime, TIME_FUZZY_DATE, &was_cut); + if (res == -1) + return NULL; + } + str_value.length(my_TIME_to_str(<ime, + const_cast<char*>(str_value.ptr()))); + str_value_cached= TRUE; + } + else if (!cache_value()) + return NULL; + } return &str_value; } diff --git a/sql/item.h b/sql/item.h index 35a0e8373f2..c7a97ca716a 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1171,7 +1171,40 @@ public: representation is more precise than the string one). */ virtual bool result_as_longlong() { return FALSE; } - bool is_datetime(); + inline bool is_datetime() const + { + switch (field_type()) + { + case MYSQL_TYPE_DATE: + case MYSQL_TYPE_DATETIME: + case MYSQL_TYPE_TIMESTAMP: + return TRUE; + default: + break; + } + return FALSE; + } + /** + Check whether this and the given item has compatible comparison context. + Used by the equality propagation. See Item_field::equal_fields_propagator. + + @return + TRUE if the context is the same or if fields could be + compared as DATETIME values by the Arg_comparator. + FALSE otherwise. + */ + inline bool has_compatible_context(Item *item) const + { + /* Same context. */ + if (cmp_context == (Item_result)-1 || item->cmp_context == cmp_context) + return TRUE; + /* DATETIME comparison context. */ + if (is_datetime()) + return item->is_datetime() || item->cmp_context == STRING_RESULT; + if (item->is_datetime()) + return is_datetime() || cmp_context == STRING_RESULT; + return FALSE; + } virtual Field::geometry_type get_geometry_type() const { return Field::GEOM_GEOMETRY; }; String *check_well_formed_result(String *str, bool send_error= 0); @@ -3232,6 +3265,7 @@ public: virtual bool cache_value()= 0; bool basic_const_item() const { return test(example && example->basic_const_item());} + virtual void clear() { null_value= TRUE; value_cached= FALSE; } }; @@ -3412,6 +3446,7 @@ public: */ bool cache_value_int(); bool cache_value(); + void clear() { Item_cache::clear(); str_value_cached= FALSE; } }; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index d31799d7e60..85565b735d4 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -876,8 +876,10 @@ get_time_value(THD *thd, Item ***item_arg, Item **cache_arg, Do not cache GET_USER_VAR() function as its const_item() may return TRUE for the current thread but it still may change during the execution. */ - if (item->const_item() && cache_arg && (item->type() != Item::FUNC_ITEM || - ((Item_func*)item)->functype() != Item_func::GUSERVAR_FUNC)) + if (item->const_item() && cache_arg && + item->type() != Item::CACHE_ITEM && + (item->type() != Item::FUNC_ITEM || + ((Item_func*)item)->functype() != Item_func::GUSERVAR_FUNC)) { Item_cache_int *cache= new Item_cache_int(); /* Mark the cache as non-const to prevent re-caching. */ @@ -937,6 +939,7 @@ int Arg_comparator::set_cmp_func(Item_result_field *owner_arg, get_value_a_func= &get_datetime_value; get_value_b_func= &get_datetime_value; cmp_collation.set(&my_charset_numeric); + set_cmp_context_for_datetime(); return 0; } else if (type == STRING_RESULT && (*a)->field_type() == MYSQL_TYPE_TIME && @@ -949,6 +952,7 @@ int Arg_comparator::set_cmp_func(Item_result_field *owner_arg, func= &Arg_comparator::compare_datetime; get_value_a_func= &get_time_value; get_value_b_func= &get_time_value; + set_cmp_context_for_datetime(); return 0; } else if (type == STRING_RESULT && @@ -1005,6 +1009,7 @@ bool Arg_comparator::try_year_cmp_func(Item_result type) is_nulls_eq= is_owner_equal_func(); func= &Arg_comparator::compare_datetime; + set_cmp_context_for_datetime(); return TRUE; } @@ -1058,6 +1063,7 @@ void Arg_comparator::set_datetime_cmp_func(Item_result_field *owner_arg, func= &Arg_comparator::compare_datetime; get_value_a_func= &get_datetime_value; get_value_b_func= &get_datetime_value; + set_cmp_context_for_datetime(); } @@ -1144,8 +1150,10 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg, Do not cache GET_USER_VAR() function as its const_item() may return TRUE for the current thread but it still may change during the execution. */ - if (item->const_item() && cache_arg && (item->type() != Item::FUNC_ITEM || - ((Item_func*)item)->functype() != Item_func::GUSERVAR_FUNC)) + if (item->const_item() && cache_arg && + item->type() != Item::CACHE_ITEM && + (item->type() != Item::FUNC_ITEM || + ((Item_func*)item)->functype() != Item_func::GUSERVAR_FUNC)) { Item_cache_int *cache= new Item_cache_int(MYSQL_TYPE_DATETIME); /* Mark the cache as non-const to prevent re-caching. */ @@ -4712,8 +4720,6 @@ void Item_func_like::cleanup() Item_bool_func2::cleanup(); } -#ifdef USE_REGEX - /** @brief Compile regular expression. @@ -4865,9 +4871,6 @@ void Item_func_regex::cleanup() } -#endif /* USE_REGEX */ - - #ifdef LIKE_CMP_TOUPPER #define likeconv(cs,A) (uchar) (cs)->toupper(A) #else diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 8813324262c..f9851011563 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -25,6 +25,7 @@ #include "thr_malloc.h" /* sql_calloc */ #include "item_func.h" /* Item_int_func, Item_bool_func */ +#include "my_regex.h" extern Item_result item_cmp_type(Item_result a,Item_result b); class Item_bool_func2; @@ -123,7 +124,17 @@ public: delete [] comparators; comparators= 0; } - + /* + Set correct cmp_context if items would be compared as INTs. + */ + inline void set_cmp_context_for_datetime() + { + DBUG_ASSERT(func == &Arg_comparator::compare_datetime); + if ((*a)->result_as_longlong()) + (*a)->cmp_context= INT_RESULT; + if ((*b)->result_as_longlong()) + (*b)->cmp_context= INT_RESULT; + } friend class Item_func; }; @@ -258,7 +269,7 @@ protected: my_bool result_for_null_param; public: Item_in_optimizer(Item *a, Item_in_subselect *b): - Item_bool_func(a, my_reinterpret_cast(Item *)(b)), cache(0), + Item_bool_func(a, reinterpret_cast<Item *>(b)), cache(0), save_cache(0), result_for_null_param(UNKNOWN) {} bool fix_fields(THD *, Item **); @@ -1424,9 +1435,6 @@ public: void cleanup(); }; -#ifdef USE_REGEX - -#include "my_regex.h" class Item_func_regex :public Item_bool_func { @@ -1455,23 +1463,6 @@ public: CHARSET_INFO *compare_collation() { return cmp_collation.collation; } }; -#else - -class Item_func_regex :public Item_bool_func -{ -public: - Item_func_regex(Item *a,Item *b) :Item_bool_func(a,b) {} - longlong val_int() { return 0;} - const char *func_name() const { return "regex"; } - - virtual inline void print(String *str, enum_query_type query_type) - { - print_op(str, query_type); - } -}; - -#endif /* USE_REGEX */ - typedef class Item COND; diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index e046087b16a..d734b55a970 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -49,7 +49,7 @@ void Item_geometry_func::fix_length_and_dec() { collation.set(&my_charset_bin); decimals=0; - max_length= max_field_size; + max_length= (uint32) 4294967295U; maybe_null= 1; } diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 34b09ca6fdc..d8d18fd8ef6 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -184,7 +184,7 @@ public: void fix_length_and_dec(); uint cols(); - Item* element_index(uint i) { return my_reinterpret_cast(Item*)(row[i]); } + Item* element_index(uint i) { return reinterpret_cast<Item*>(row[i]); } Item** addr(uint i) { return (Item**)row + i; } bool check_cols(uint c); bool null_inside(); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 77c45ea85f7..b05d845dead 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1214,8 +1214,7 @@ void Item_sum_hybrid::setup_hybrid(Item *item, Item *value_arg) { value= Item_cache::get_cache(item); value->setup(item); - if (value_arg) - value->store(value_arg); + value->store(value_arg); cmp= new Arg_comparator(); cmp->set_cmp_func(this, args, (Item**)&value, FALSE); collation.set(item->collation); @@ -1903,7 +1902,7 @@ void Item_sum_variance::update_field() void Item_sum_hybrid::clear() { - value->null_value= 1; + value->clear(); null_value= 1; } diff --git a/sql/item_sum.h b/sql/item_sum.h index b4539995632..2a722b93165 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -1010,6 +1010,11 @@ protected: void no_rows_in_result(); Field *create_tmp_field(bool group, TABLE *table, uint convert_blob_length); + /* + MIN/MAX uses Item_cache_datetime for storing DATETIME values, thus + in this case a correct INT value can be provided. + */ + bool result_as_longlong() { return args[0]->result_as_longlong(); } }; diff --git a/sql/log.h b/sql/log.h index 4a58c3081d8..6e87b6cbade 100644 --- a/sql/log.h +++ b/sql/log.h @@ -637,7 +637,6 @@ enum enum_binlog_format { BINLOG_FORMAT_ROW= 2, ///< row-based BINLOG_FORMAT_UNSPEC=3 ///< thd_binlog_format() returns it when binlog is closed }; -extern TYPELIB binlog_format_typelib; int query_error_code(THD *thd, bool not_killed); uint purge_log_get_error_code(int res); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 375c96bdec4..26026ba8ae0 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -294,12 +294,6 @@ arg_cmp_func Arg_comparator::comparator_matrix[5][2] = {&Arg_comparator::compare_row, &Arg_comparator::compare_e_row}, {&Arg_comparator::compare_decimal, &Arg_comparator::compare_e_decimal}}; -const char *log_output_names[] = { "NONE", "FILE", "TABLE", NullS}; -static const unsigned int log_output_names_len[]= { 4, 4, 5, 0 }; -TYPELIB log_output_typelib= {array_elements(log_output_names)-1,"", - log_output_names, - (unsigned int *) log_output_names_len}; - /* static variables */ #ifdef HAVE_PSI_INTERFACE @@ -395,8 +389,8 @@ my_bool opt_skip_slave_start = 0; ///< If set, slave is not autostarted my_bool opt_reckless_slave = 0; my_bool opt_enable_named_pipe= 0; my_bool opt_local_infile, opt_slave_compressed_protocol; -my_bool opt_safe_user_create = 0, opt_no_mix_types = 0; -my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0; +my_bool opt_safe_user_create = 0; +my_bool opt_show_slave_auth_info; my_bool opt_log_slave_updates= 0; char *opt_slave_skip_errors; @@ -440,9 +434,6 @@ my_bool sp_automatic_privileges= 1; ulong opt_binlog_rows_event_max_size; const char *binlog_format_names[]= {"MIXED", "STATEMENT", "ROW", NullS}; -TYPELIB binlog_format_typelib= - { array_elements(binlog_format_names) - 1, "", - binlog_format_names, NULL }; #ifdef HAVE_INITGROUPS static bool calling_initgroups= FALSE; /**< Used in SIGSEGV handler. */ #endif @@ -458,7 +449,7 @@ ulong thread_created; ulong back_log, connect_timeout, concurrency, server_id; ulong table_cache_size, table_def_size; ulong what_to_log; -ulong query_buff_size, slow_launch_time, slave_open_temp_tables; +ulong slow_launch_time, slave_open_temp_tables; ulong open_files_limit, max_binlog_size, max_relay_log_size; ulong slave_trans_retries; uint slave_net_timeout; @@ -547,7 +538,6 @@ char mysql_real_data_home[FN_REFLEN], mysql_charsets_dir[FN_REFLEN], *opt_init_file, *opt_tc_log_file; char *lc_messages_dir_ptr, *log_error_file_ptr; -char err_shared_dir[FN_REFLEN]; char mysql_unpacked_real_data_home[FN_REFLEN]; int mysql_unpacked_real_data_home_len; uint mysql_real_data_home_len, mysql_data_home_len= 1; @@ -581,7 +571,6 @@ Le_creator le_creator; MYSQL_FILE *bootstrap_file; int bootstrap_error; -FILE *stderror_file=0; I_List<THD> threads; Rpl_filter* rpl_filter; @@ -613,7 +602,7 @@ pthread_key(MEM_ROOT**,THR_MALLOC); pthread_key(THD*, THR_THD); mysql_mutex_t LOCK_thread_count; mysql_mutex_t LOCK_open, - LOCK_mapped_file, LOCK_status, LOCK_global_read_lock, + LOCK_status, LOCK_global_read_lock, LOCK_error_log, LOCK_uuid_generator, LOCK_delayed_insert, LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, @@ -1476,9 +1465,7 @@ void clean_up(bool print_message) delete rpl_filter; end_ssl(); vio_end(); -#ifdef USE_REGEX my_regex_end(); -#endif #if defined(ENABLED_DEBUG_SYNC) /* End the debug sync facility. See debug_sync.cc. */ debug_sync_end(); @@ -1541,7 +1528,6 @@ static void clean_up_mutexes() mysql_rwlock_destroy(&LOCK_grant); mysql_mutex_destroy(&LOCK_open); mysql_mutex_destroy(&LOCK_thread_count); - mysql_mutex_destroy(&LOCK_mapped_file); mysql_mutex_destroy(&LOCK_status); mysql_mutex_destroy(&LOCK_delayed_insert); mysql_mutex_destroy(&LOCK_delayed_status); @@ -1942,7 +1928,7 @@ static void network_init(void) (void) setsockopt(unix_sock,SOL_SOCKET,SO_REUSEADDR,(char*)&arg, sizeof(arg)); umask(0); - if (bind(unix_sock, my_reinterpret_cast(struct sockaddr *) (&UNIXaddr), + if (bind(unix_sock, reinterpret_cast<struct sockaddr *>(&UNIXaddr), sizeof(UNIXaddr)) < 0) { sql_perror("Can't start server : Bind on unix socket"); /* purecov: tested */ @@ -3353,9 +3339,7 @@ static int init_common_variables() if (item_create_init()) return 1; item_init(); -#ifdef USE_REGEX my_regex_init(&my_charset_latin1); -#endif /* Process a comma-separated character set list and choose the first available character set. This is mostly for @@ -3518,7 +3502,6 @@ static int init_thread_environment() { mysql_mutex_init(key_LOCK_open, &LOCK_open, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_thread_count, &LOCK_thread_count, MY_MUTEX_INIT_FAST); - mysql_mutex_init(key_LOCK_mapped_file, &LOCK_mapped_file, MY_MUTEX_INIT_SLOW); mysql_mutex_init(key_LOCK_status, &LOCK_status, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_delayed_insert, &LOCK_delayed_insert, MY_MUTEX_INIT_FAST); @@ -7697,7 +7680,7 @@ PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids, key_LOCK_connection_count, key_LOCK_crypt, key_LOCK_delayed_create, key_LOCK_delayed_insert, key_LOCK_delayed_status, key_LOCK_error_log, key_LOCK_gdl, key_LOCK_global_read_lock, key_LOCK_global_system_variables, - key_LOCK_manager, key_LOCK_mapped_file, + key_LOCK_manager, key_LOCK_open, key_LOCK_prepared_stmt_count, key_LOCK_rpl_status, key_LOCK_server_started, key_LOCK_status, key_LOCK_system_variables_hash, key_LOCK_table_share, key_LOCK_thd_data, @@ -7737,7 +7720,6 @@ static PSI_mutex_info all_server_mutexes[]= { &key_LOCK_global_read_lock, "LOCK_global_read_lock", PSI_FLAG_GLOBAL}, { &key_LOCK_global_system_variables, "LOCK_global_system_variables", PSI_FLAG_GLOBAL}, { &key_LOCK_manager, "LOCK_manager", PSI_FLAG_GLOBAL}, - { &key_LOCK_mapped_file, "LOCK_mapped_file", PSI_FLAG_GLOBAL}, { &key_LOCK_open, "LOCK_open", PSI_FLAG_GLOBAL}, { &key_LOCK_prepared_stmt_count, "LOCK_prepared_stmt_count", PSI_FLAG_GLOBAL}, { &key_LOCK_rpl_status, "LOCK_rpl_status", PSI_FLAG_GLOBAL}, diff --git a/sql/mysqld.h b/sql/mysqld.h index b07d148f507..22e757e6e8a 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -78,9 +78,6 @@ extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *files_charset_info ; extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *national_charset_info; extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *table_alias_charset; -extern TYPELIB log_output_typelib; -extern const char *log_output_names[]; - /** Character set of the buildin error messages loaded from errmsg.sys. */ @@ -105,7 +102,7 @@ extern bool volatile abort_loop; extern bool in_bootstrap; extern uint volatile thread_count, global_read_lock; extern uint connection_count; -extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types; +extern my_bool opt_safe_user_create; extern my_bool opt_safe_show_db, opt_local_infile, opt_myisam_use_mmap; extern my_bool opt_slave_compressed_protocol, use_temp_pool; extern uint slave_exec_mode_options; @@ -173,7 +170,6 @@ extern ulong slave_trans_retries; extern uint slave_net_timeout; extern uint max_user_connections; extern ulong what_to_log,flush_time; -extern ulong query_buff_size; extern ulong max_prepared_stmt_count, prepared_stmt_count; extern ulong binlog_cache_size, open_files_limit; extern ulonglong max_binlog_cache_size; @@ -210,9 +206,7 @@ extern MYSQL_FILE *bootstrap_file; extern my_bool old_mode; extern LEX_STRING opt_init_connect, opt_init_slave; extern int bootstrap_error; -extern FILE *stderror_file; extern I_List<THD> threads; -extern char err_shared_dir[]; extern scheduler_functions thread_scheduler; extern TYPELIB thread_handling_typelib; extern my_decimal decimal_zero; @@ -234,7 +228,7 @@ extern PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids, key_LOCK_connection_count, key_LOCK_crypt, key_LOCK_delayed_create, key_LOCK_delayed_insert, key_LOCK_delayed_status, key_LOCK_error_log, key_LOCK_gdl, key_LOCK_global_read_lock, key_LOCK_global_system_variables, - key_LOCK_logger, key_LOCK_manager, key_LOCK_mapped_file, + key_LOCK_logger, key_LOCK_manager, key_LOCK_open, key_LOCK_prepared_stmt_count, key_LOCK_rpl_status, key_LOCK_server_started, key_LOCK_status, key_LOCK_table_share, key_LOCK_thd_data, @@ -313,7 +307,6 @@ extern MYSQL_PLUGIN_IMPORT char mysql_real_data_home[]; extern char mysql_unpacked_real_data_home[]; extern MYSQL_PLUGIN_IMPORT struct system_variables global_system_variables; extern char default_logfile_name[FN_REFLEN]; -extern char err_shared_dir[]; #define mysql_tmpdir (my_tmpdir(&mysql_tmpdir_list)) @@ -324,7 +317,7 @@ extern MYSQL_PLUGIN_IMPORT key_map key_map_full; /* Should be threaded Server mutex locks and condition variables. */ extern mysql_mutex_t LOCK_open, - LOCK_mapped_file, LOCK_user_locks, LOCK_status, + LOCK_user_locks, LOCK_status, LOCK_error_log, LOCK_delayed_insert, LOCK_uuid_generator, LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone, LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_read_lock, diff --git a/sql/nt_servc.cc b/sql/nt_servc.cc index 76dc2846ed0..1f1b7f0c20f 100644 --- a/sql/nt_servc.cc +++ b/sql/nt_servc.cc @@ -375,29 +375,6 @@ void NTService::ServiceCtrlHandler(DWORD ctrlCode) dwState=pService->dwState; // get current state switch(ctrlCode) { - -#ifdef NOT_USED /* do we need this ? */ - case SERVICE_CONTROL_PAUSE: - if (pService->bRunning && ! pService->bPause) - { - dwState = SERVICE_PAUSED; - pService->SetStatus(SERVICE_PAUSE_PENDING,NO_ERROR, 0, 1, - pService->nPauseTimeOut); - pService->PauseService(); - } - break; - - case SERVICE_CONTROL_CONTINUE: - if (pService->bRunning && pService->bPause) - { - dwState = SERVICE_RUNNING; - pService->SetStatus(SERVICE_CONTINUE_PENDING,NO_ERROR, 0, 1, - pService->nResumeTimeOut); - pService->ResumeService(); - } - break; -#endif - case SERVICE_CONTROL_SHUTDOWN: case SERVICE_CONTROL_STOP: dwState = SERVICE_STOP_PENDING; diff --git a/sql/opt_range.h b/sql/opt_range.h index 0d4000002b0..33b3d561ad8 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -825,7 +825,11 @@ class SQL_SELECT :public Sql_alloc { tmp.set_all(); return test_quick_select(thd, tmp, 0, limit, force_quick_range) < 0; } - inline bool skip_record() { return cond ? cond->val_int() == 0 : 0; } + inline bool skip_record(THD *thd, bool *skip_record) + { + *skip_record= cond ? cond->val_int() == FALSE : FALSE; + return thd->is_error(); + } int test_quick_select(THD *thd, key_map keys, table_map prev_tables, ha_rows limit, bool force_quick_range); }; diff --git a/sql/protocol.cc b/sql/protocol.cc index 3f957dcc2de..87a54eaf10d 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -790,31 +790,14 @@ bool Protocol::send_result_set_metadata(List<Item> *list, uint flags) local_packet->realloc(local_packet->length()+10)) goto err; pos= (char*) local_packet->ptr()+local_packet->length(); - -#ifdef TO_BE_DELETED_IN_6 - if (!(thd->client_capabilities & CLIENT_LONG_FLAG)) - { - pos[0]=3; - int3store(pos+1,field.length); - pos[4]=1; - pos[5]=field.type; - pos[6]=2; - pos[7]= (char) field.flags; - pos[8]= (char) field.decimals; - pos+= 9; - } - else -#endif - { - pos[0]=3; - int3store(pos+1,field.length); - pos[4]=1; - pos[5]=field.type; - pos[6]=3; - int2store(pos+7,field.flags); - pos[9]= (char) field.decimals; - pos+= 10; - } + pos[0]=3; + int3store(pos+1,field.length); + pos[4]=1; + pos[5]=field.type; + pos[6]=3; + int2store(pos+7,field.flags); + pos[9]= (char) field.decimals; + pos+= 10; } local_packet->length((uint) (pos - local_packet->ptr())); if (flags & SEND_DEFAULTS) diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 9a1f7fb826b..47eb2f7031d 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -55,9 +55,6 @@ const char* rpl_status_type[]= "AUTH_MASTER","IDLE_SLAVE","ACTIVE_SLAVE","LOST_SOLDIER","TROOP_SOLDIER", "RECOVERY_CAPTAIN","NULL",NullS }; -TYPELIB rpl_status_typelib= {array_elements(rpl_status_type)-1,"", - rpl_status_type, NULL}; - static Slave_log_event* find_slave_event(IO_CACHE* log, const char* log_file_name, @@ -71,42 +68,6 @@ static Slave_log_event* find_slave_event(IO_CACHE* log, functions like register_slave()) are working. */ -#if NOT_USED -static int init_failsafe_rpl_thread(THD* thd) -{ - DBUG_ENTER("init_failsafe_rpl_thread"); - thd->system_thread = SYSTEM_THREAD_DELAYED_INSERT; - /* - thd->bootstrap is to report errors barely to stderr; if this code is - enable again one day, one should check if bootstrap is still needed (maybe - this thread has no other error reporting method). - */ - thd->bootstrap = 1; - thd->security_ctx->skip_grants(); - my_net_init(&thd->net, 0); - thd->net.read_timeout = slave_net_timeout; - thd->max_client_packet_length=thd->net.max_packet; - mysql_mutex_lock(&LOCK_thread_count); - thd->thread_id= thd->variables.pseudo_thread_id= thread_id++; - mysql_mutex_unlock(&LOCK_thread_count); - - if (init_thr_lock() || thd->store_globals()) - { - /* purecov: begin inspected */ - close_connection(thd, ER_OUT_OF_RESOURCES, 1); // is this needed? - statistic_increment(aborted_connects,&LOCK_status); - one_thread_per_connection_end(thd,0); - DBUG_RETURN(-1); - /* purecov: end */ - } - - thd->mem_root->free= thd->mem_root->used= 0; - thd_proc_info(thd, "Thread initialized"); - thd->set_time(); - DBUG_RETURN(0); -} -#endif - void change_rpl_status(RPL_STATUS from_status, RPL_STATUS to_status) { mysql_mutex_lock(&LOCK_rpl_status); @@ -623,66 +584,6 @@ err: } -#if NOT_USED -int find_recovery_captain(THD* thd, MYSQL* mysql) -{ - return 0; -} -#endif - -#if NOT_USED -pthread_handler_t handle_failsafe_rpl(void *arg) -{ - DBUG_ENTER("handle_failsafe_rpl"); - THD *thd = new THD; - thd->thread_stack = (char*)&thd; - MYSQL* recovery_captain = 0; - const char* msg; - - pthread_detach_this_thread(); - if (init_failsafe_rpl_thread(thd) || !(recovery_captain=mysql_init(0))) - { - sql_print_error("Could not initialize failsafe replication thread"); - goto err; - } - mysql_mutex_lock(&LOCK_rpl_status); - msg= thd->enter_cond(&COND_rpl_status, - &LOCK_rpl_status, "Waiting for request"); - while (!thd->killed && !abort_loop) - { - bool break_req_chain = 0; - mysql_cond_wait(&COND_rpl_status, &LOCK_rpl_status); - thd_proc_info(thd, "Processing request"); - while (!break_req_chain) - { - switch (rpl_status) { - case RPL_LOST_SOLDIER: - if (find_recovery_captain(thd, recovery_captain)) - rpl_status=RPL_TROOP_SOLDIER; - else - rpl_status=RPL_RECOVERY_CAPTAIN; - break_req_chain=1; /* for now until other states are implemented */ - break; - default: - break_req_chain=1; - break; - } - } - } - thd->exit_cond(msg); -err: - if (recovery_captain) - mysql_close(recovery_captain); - delete thd; - - DBUG_LEAVE; // Must match DBUG_ENTER() - my_thread_end(); - pthread_exit(0); - return 0; // Avoid compiler warnings -} -#endif - - /** Execute a SHOW SLAVE HOSTS statement. diff --git a/sql/repl_failsafe.h b/sql/repl_failsafe.h index 94b151aaee7..c6d00de47cb 100644 --- a/sql/repl_failsafe.h +++ b/sql/repl_failsafe.h @@ -30,7 +30,7 @@ extern RPL_STATUS rpl_status; extern mysql_mutex_t LOCK_rpl_status; extern mysql_cond_t COND_rpl_status; -extern TYPELIB rpl_role_typelib, rpl_status_typelib; +extern TYPELIB rpl_role_typelib; extern const char* rpl_role_type[], *rpl_status_type[]; pthread_handler_t handle_failsafe_rpl(void *arg); diff --git a/sql/rpl_record.cc b/sql/rpl_record.cc index ced5c0943dd..8219f70727e 100644 --- a/sql/rpl_record.cc +++ b/sql/rpl_record.cc @@ -238,7 +238,8 @@ unpack_row(Relay_log_info const *rli, conv_field ? conv_field : *field_ptr; DBUG_PRINT("debug", ("Conversion %srequired for field '%s' (#%ld)", conv_field ? "" : "not ", - (*field_ptr)->field_name, field_ptr - begin_ptr)); + (*field_ptr)->field_name, + (long) (field_ptr - begin_ptr))); DBUG_ASSERT(f != NULL); /* diff --git a/sql/set_var.h b/sql/set_var.h index 1b415567659..5f1f889c4ce 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -169,7 +169,6 @@ protected: { return ((uchar*)&global_system_variables) + offset; } }; -#include "log.h" /* binlog_format_typelib */ #include "sql_plugin.h" /* SHOW_HA_ROWS, SHOW_MY_BOOL */ /**************************************************************************** diff --git a/sql/slave.cc b/sql/slave.cc index a6199854e48..7cf5ea9ab9f 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -83,7 +83,6 @@ ulonglong relay_log_space_limit = 0; */ int disconnect_slave_event_count = 0, abort_slave_event_count = 0; -int events_till_abort = -1; static pthread_key(Master_info*, RPL_MASTER_INFO); @@ -798,17 +797,6 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start, } -#ifdef NOT_USED_YET -static int end_slave_on_walk(Master_info* mi, uchar* /*unused*/) -{ - DBUG_ENTER("end_slave_on_walk"); - - end_master_info(mi); - DBUG_RETURN(0); -} -#endif - - /* Release slave threads at time of executing shutdown. diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 9d48c1282d5..1ff2ba59093 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -4159,71 +4159,6 @@ THD::binlog_prepare_pending_rows_event(TABLE*, uint32, MY_BITMAP const*, Update_rows_log_event *); #endif -#ifdef NOT_USED -static char const* -field_type_name(enum_field_types type) -{ - switch (type) { - case MYSQL_TYPE_DECIMAL: - return "MYSQL_TYPE_DECIMAL"; - case MYSQL_TYPE_TINY: - return "MYSQL_TYPE_TINY"; - case MYSQL_TYPE_SHORT: - return "MYSQL_TYPE_SHORT"; - case MYSQL_TYPE_LONG: - return "MYSQL_TYPE_LONG"; - case MYSQL_TYPE_FLOAT: - return "MYSQL_TYPE_FLOAT"; - case MYSQL_TYPE_DOUBLE: - return "MYSQL_TYPE_DOUBLE"; - case MYSQL_TYPE_NULL: - return "MYSQL_TYPE_NULL"; - case MYSQL_TYPE_TIMESTAMP: - return "MYSQL_TYPE_TIMESTAMP"; - case MYSQL_TYPE_LONGLONG: - return "MYSQL_TYPE_LONGLONG"; - case MYSQL_TYPE_INT24: - return "MYSQL_TYPE_INT24"; - case MYSQL_TYPE_DATE: - return "MYSQL_TYPE_DATE"; - case MYSQL_TYPE_TIME: - return "MYSQL_TYPE_TIME"; - case MYSQL_TYPE_DATETIME: - return "MYSQL_TYPE_DATETIME"; - case MYSQL_TYPE_YEAR: - return "MYSQL_TYPE_YEAR"; - case MYSQL_TYPE_NEWDATE: - return "MYSQL_TYPE_NEWDATE"; - case MYSQL_TYPE_VARCHAR: - return "MYSQL_TYPE_VARCHAR"; - case MYSQL_TYPE_BIT: - return "MYSQL_TYPE_BIT"; - case MYSQL_TYPE_NEWDECIMAL: - return "MYSQL_TYPE_NEWDECIMAL"; - case MYSQL_TYPE_ENUM: - return "MYSQL_TYPE_ENUM"; - case MYSQL_TYPE_SET: - return "MYSQL_TYPE_SET"; - case MYSQL_TYPE_TINY_BLOB: - return "MYSQL_TYPE_TINY_BLOB"; - case MYSQL_TYPE_MEDIUM_BLOB: - return "MYSQL_TYPE_MEDIUM_BLOB"; - case MYSQL_TYPE_LONG_BLOB: - return "MYSQL_TYPE_LONG_BLOB"; - case MYSQL_TYPE_BLOB: - return "MYSQL_TYPE_BLOB"; - case MYSQL_TYPE_VAR_STRING: - return "MYSQL_TYPE_VAR_STRING"; - case MYSQL_TYPE_STRING: - return "MYSQL_TYPE_STRING"; - case MYSQL_TYPE_GEOMETRY: - return "MYSQL_TYPE_GEOMETRY"; - } - return "Unknown"; -} -#endif - - /* Declare in unnamed namespace. */ CPP_UNNAMED_NS_START diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index c94ea1302c8..00666bc85b4 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -59,6 +59,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, bool const_cond_result; ha_rows deleted= 0; bool reverse= FALSE; + bool skip_record; ORDER *order= (ORDER *) ((order_list && order_list->elements) ? order_list->first : NULL); uint usable_index= MAX_KEY; @@ -298,7 +299,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, { thd->examined_row_count++; // thd->is_error() is tested to disallow delete row on error - if (!(select && select->skip_record())&& ! thd->is_error() ) + if (!select || (!select->skip_record(thd, &skip_record) && !skip_record)) { if (table->triggers && diff --git a/sql/sql_error.cc b/sql/sql_error.cc index cc6529f7b10..e5d0f79b2d7 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -588,16 +588,11 @@ void push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, DBUG_PRINT("enter", ("code: %d, msg: %s", code, msg)); /* - Calling push_warning/push_warning_printf with a - level of WARN_LEVEL_ERROR *is* a bug. - Either use my_error(), or WARN_LEVEL_WARN. - Please fix the calling code, and do *NOT* - add more work around code in the assert below. + Calling push_warning/push_warning_printf with a level of + WARN_LEVEL_ERROR *is* a bug. Either use my_printf_error(), + my_error(), or WARN_LEVEL_WARN. */ - DBUG_ASSERT( (level != MYSQL_ERROR::WARN_LEVEL_ERROR) - || (code == ER_CANT_CREATE_TABLE) /* See Bug#47233 */ - || (code == ER_ILLEGAL_HA_CREATE_OPTION) /* See Bug#47233 */ - ); + DBUG_ASSERT(level != MYSQL_ERROR::WARN_LEVEL_ERROR); if (level == MYSQL_ERROR::WARN_LEVEL_ERROR) level= MYSQL_ERROR::WARN_LEVEL_WARN; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index eef139d5698..4ddc108770b 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -41,7 +41,6 @@ sys_var *trg_new_row_fake_var= (sys_var*) 0x01; LEX_STRING constant for null-string to be used in parser and other places. */ const LEX_STRING null_lex_str= {NULL, 0}; -const LEX_STRING empty_lex_str= { (char*) "", 0 }; /** @note The order of the elements of this array must correspond to the order of elements in enum_binlog_stmt_unsafe. diff --git a/sql/sql_lex.h b/sql/sql_lex.h index b8bf3b220c9..784a69cf9c1 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -589,11 +589,11 @@ public: st_select_lex* outer_select(); st_select_lex* first_select() { - return my_reinterpret_cast(st_select_lex*)(slave); + return reinterpret_cast<st_select_lex*>(slave); } st_select_lex_unit* next_unit() { - return my_reinterpret_cast(st_select_lex_unit*)(next); + return reinterpret_cast<st_select_lex_unit*>(next); } st_select_lex* return_after_parsing() { return return_to; } void exclude_level(); @@ -995,8 +995,6 @@ enum xa_option_words {XA_NONE, XA_JOIN, XA_RESUME, XA_ONE_PHASE, XA_SUSPEND, XA_FOR_MIGRATE}; extern const LEX_STRING null_lex_str; -extern const LEX_STRING empty_lex_str; - class Sroutine_hash_entry; diff --git a/sql/sql_map.cc b/sql/sql_map.cc deleted file mode 100644 index ca8a88bcbf8..00000000000 --- a/sql/sql_map.cc +++ /dev/null @@ -1,144 +0,0 @@ -/* Copyright (C) 2000-2001, 2004-2005 MySQL AB, 2008-2009 Sun Microsystems, Inc - - 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 Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - 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 */ - - -#ifdef USE_PRAGMA_IMPLEMENTATION -#pragma implementation // gcc: Class implementation -#endif - -#include "sql_priv.h" -#include "unireg.h" // REQUIRED: for other includes -#include "sql_map.h" // mapped_files -#include "sql_class.h" // THD - -#include <sys/stat.h> -#ifdef HAVE_SYS_MMAN_H -#include <sys/mman.h> -#endif - -mapped_files::mapped_files(const char * filename,uchar *magic,uint magic_length) -{ -#ifdef HAVE_MMAP - name=my_strdup(filename,MYF(0)); - use_count=1; - error=0; - map=0; - size=0; - if ((file= mysql_file_open(key_file_map, name, O_RDONLY, MYF(MY_WME))) >= 0) - { - struct stat stat_buf; - if (!fstat(file, &stat_buf)) - { - if (!(map=(uchar*) my_mmap(0,(size_t)(size= stat_buf.st_size),PROT_READ, - MAP_SHARED | MAP_NORESERVE,file, - 0L))) - { - error=errno; - my_error(ER_NO_FILE_MAPPING, MYF(0), (char *) name, error); - } - } - if (map && memcmp(map,magic,magic_length)) - { - my_error(ER_WRONG_MAGIC, MYF(0), name); - (void) my_munmap((char*) map,(size_t)size); - map=0; - } - if (!map) - { - (void) mysql_file_close(file, MYF(0)); - file= -1; - } - } -#endif -} - - -mapped_files::~mapped_files() -{ -#ifdef HAVE_MMAP - if (file >= 0) - { - (void) my_munmap((char*) map,(size_t)size); - (void) mysql_file_close(file, MYF(0)); - file= -1; map=0; - } - my_free(name); -#endif -} - - -static I_List<mapped_files> maps_in_use; - -/* -** Check if a file is mapped. If it is, then return pointer to old map, -** else alloc new object -*/ - -mapped_files *map_file(const char * name,uchar *magic,uint magic_length) -{ -#ifdef HAVE_MMAP - mysql_mutex_lock(&LOCK_mapped_file); - I_List_iterator<mapped_files> list(maps_in_use); - mapped_files *map; - char path[FN_REFLEN]; - sprintf(path,"%s/%s/%s.uniq",mysql_data_home,current_thd->db,name); - (void) unpack_filename(path,path); - - while ((map=list++)) - { - if (!strcmp(path,map->name)) - break; - } - if (!map) - { - map=new mapped_files(path,magic,magic_length); - maps_in_use.append(map); - } - else - { - map->use_count++; - if (!map->map) - my_error(ER_NO_FILE_MAPPING, MYF(0), path, map->error); - } - mysql_mutex_unlock(&LOCK_mapped_file); - return map; -#else - return NULL; -#endif -} - -/* -** free the map if there are no more users for it -*/ - -void unmap_file(mapped_files *map) -{ -#ifdef HAVE_MMAP - mysql_mutex_lock(&LOCK_mapped_file); - if (!map->use_count--) - delete map; - mysql_mutex_unlock(&LOCK_mapped_file); -#endif -} - -/***************************************************************************** -** Instansiate templates -*****************************************************************************/ - -#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION -/* Used templates */ -template class I_List<mapped_files>; -template class I_List_iterator<mapped_files>; -#endif diff --git a/sql/sql_map.h b/sql/sql_map.h deleted file mode 100644 index be1c145df3f..00000000000 --- a/sql/sql_map.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef SQL_MAP_INCLUDED -#define SQL_MAP_INCLUDED - -/* Copyright (C) 2000-2001, 2005 MySQL AB - - 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 Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - 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 */ - - -/* interface for memory mapped files */ - -#ifdef USE_PRAGMA_INTERFACE -#pragma interface /* gcc class implementation */ -#endif - -#include "my_base.h" /* ha_rows */ -#include "sql_list.h" /* ilink */ - -class mapped_files; -mapped_files *map_file(const char * name,uchar *magic,uint magic_length); -void unmap_file(mapped_files *map); - -class mapped_files :public ilink { - uchar *map; - ha_rows size; - char *name; // name of mapped file - File file; // >= 0 if open - int error; // If not mapped - uint use_count; - -public: - mapped_files(const char * name,uchar *magic,uint magic_length); - ~mapped_files(); - - friend class mapped_file; - friend mapped_files *map_file(const char * name,uchar *magic, - uint magic_length); - friend void unmap_file(mapped_files *map); -}; - - -class mapped_file -{ - mapped_files *file; -public: - mapped_file(const char * name,uchar *magic,uint magic_length) - { - file=map_file(name,magic,magic_length); /* old or new map */ - } - ~mapped_file() - { - unmap_file(file); /* free map */ - } - uchar *map() - { - return file->map; - } -}; - -#endif /* SQL_MAP_INCLUDED */ diff --git a/sql/sql_olap.cc b/sql/sql_olap.cc deleted file mode 100644 index b957d1e9be4..00000000000 --- a/sql/sql_olap.cc +++ /dev/null @@ -1,188 +0,0 @@ -/* Copyright (C) 2000-2006 MySQL AB - - 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 Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - 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 */ - - -/* - OLAP implementation by Sinisa Milivojevic <sinisa@mysql.com> - Inspired by code submitted by Srilakshmi <lakshmi@gdit.iiit.net> - - The ROLLUP code in this file has to be complitely rewritten as it's - not good enough to satisfy the goals of MySQL. - - In 4.1 we will replace this with a working, superior implementation - of ROLLUP. -*/ - -#ifdef DISABLED_UNTIL_REWRITTEN_IN_4_1 - -#ifdef USE_PRAGMA_IMPLEMENTATION -#pragma implementation // gcc: Class implementation -#endif - -#include "sql_priv.h" -#include "unireg.h" -#include "sql_select.h" - - -/**************************************************************************** - Functions that recursively actually creates new SELECT's - Returns 0 if OK, 1 if error, -1 if error already printed to client -****************************************************************************/ - - -static int make_new_olap_select(LEX *lex, SELECT_LEX *select_lex, List<Item> new_fields) -{ - THD *thd=current_thd; - Item *item, *new_item; - Item_null *constant= new Item_null("ALL"); - - SELECT_LEX *new_select = (SELECT_LEX *) thd->memdup((char*) select_lex, sizeof(*select_lex)); - if (!new_select) - return 1; - lex->last_selects->next=new_select; - new_select->linkage=OLAP_TYPE; - new_select->olap=NON_EXISTING_ONE; - new_select->group_list.elements=0; - new_select->group_list.first=(uchar *)0; - new_select->group_list.next=(uchar **)&new_select->group_list.first; - List<Item> privlist; - - List_iterator<Item> list_it(select_lex->item_list); - List_iterator<Item> new_it(new_fields); - - while ((item=list_it++)) - { - bool not_found= TRUE; - if (item->type()==Item::FIELD_ITEM) - { - Item_field *iif = (Item_field *)item; - new_it.rewind(); - while ((new_item=new_it++)) - { - if (new_item->type()==Item::FIELD_ITEM && - !strcmp(((Item_field*)new_item)->table_name,iif->table_name) && - !strcmp(((Item_field*)new_item)->field_name,iif->field_name)) - { - not_found= 0; - ((Item_field*)new_item)->db_name=iif->db_name; - Item_field *new_one=new Item_field(&select_lex->context, - iif->db_name, iif->table_name, iif->field_name); - privlist.push_back(new_one); - if (add_to_list(new_select->group_list,new_one,1)) - return 1; - break; - } - } - } - if (not_found) - { - if (item->type() == Item::FIELD_ITEM) - privlist.push_back(constant); - else - privlist.push_back((Item*)thd->memdup((char *)item,item->size_of())); - } - } - new_select->item_list=privlist; - - lex->last_selects = new_select; - return 0; -} - -/**************************************************************************** - Functions that recursively creates combinations of queries for OLAP - Returns 0 if OK, 1 if error, -1 if error already printed to client -****************************************************************************/ - -static int olap_combos(List<Item> old_fields, List<Item> new_fields, Item *item, LEX *lex, - SELECT_LEX *select_lex, int position, int selection, int num_fields, - int num_new_fields) -{ - int sl_return = 0; - if (position == num_new_fields) - { - if (item) - new_fields.push_front(item); - sl_return = make_new_olap_select(lex, select_lex, new_fields); - } - else - { - if (item) - new_fields.push_front(item); - while ((num_fields - num_new_fields >= selection - position) && !sl_return) - { - item = old_fields.pop(); - sl_return = olap_combos(old_fields, new_fields, item, lex, select_lex, position+1, ++selection, num_fields, num_new_fields); - } - } - return sl_return; -} - - -/**************************************************************************** - Top level function for converting OLAP clauses to multiple selects - This is also a place where clauses treatment depends on OLAP type - Returns 0 if OK, 1 if error, -1 if error already printed to client -****************************************************************************/ - -int handle_olaps(LEX *lex, SELECT_LEX *select_lex) -{ - List<Item> item_list_copy, new_item_list; - item_list_copy.empty(); - new_item_list.empty(); - int count=select_lex->group_list.elements; - int sl_return=0; - - - lex->last_selects=select_lex; - - for (ORDER *order= select_lex->group_list.first ; order ; order=order->next) - item_list_copy.push_back(*(order->item)); - - List<Item> all_fields(select_lex->item_list); - - - if (setup_tables(lex->thd, &select_lex->context, &select_lex->top_join_list, - select_lex->table_list.first - &select_lex->leaf_tables, FALSE) || - setup_fields(lex->thd, 0, select_lex->item_list, MARK_COLUMNS_READ, - &all_fields,1) || - setup_fields(lex->thd, 0, item_list_copy, MARK_COLUMNS_READ, - &all_fields, 1)) - return -1; - - if (select_lex->olap == CUBE_TYPE) - { - for ( int i=count-1; i>=0 && !sl_return; i--) - sl_return=olap_combos(item_list_copy, new_item_list, (Item *)0, lex, select_lex, 0, 0, count, i); - } - else if (select_lex->olap == ROLLUP_TYPE) - { - for ( int i=count-1; i>=0 && !sl_return; i--) - { - Item *item; - item_list_copy.pop(); - List_iterator<Item> it(item_list_copy); - new_item_list.empty(); - while ((item = it++)) - new_item_list.push_front(item); - sl_return=make_new_olap_select(lex, select_lex, new_item_list); - } - } - else - sl_return=1; // impossible - return sl_return; -} - -#endif /* DISABLED_UNTIL_REWRITTEN_IN_4_1 */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 53c2ca6fa39..4a4b0bdd66b 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -6061,7 +6061,7 @@ bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum_field_types type, void store_position_for_column(const char *name) { - current_thd->lex->last_field->after=my_const_cast(char*) (name); + current_thd->lex->last_field->after=(char*) (name); } bool @@ -7537,28 +7537,6 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables, if (select_lex->item_list.elements) { /* Check permissions for used tables in CREATE TABLE ... SELECT */ - -#ifdef NOT_NECESSARY_TO_CHECK_CREATE_TABLE_EXIST_WHEN_PREPARING_STATEMENT - /* This code throws an ill error for CREATE TABLE t1 SELECT * FROM t1 */ - /* - Only do the check for PS, because we on execute we have to check that - against the opened tables to ensure we don't use a table that is part - of the view (which can only be done after the table has been opened). - */ - if (thd->stmt_arena->is_stmt_prepare_or_first_sp_execute()) - { - /* - For temporary tables we don't have to check if the created table exists - */ - if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) && - find_table_in_global_list(tables, create_table->db, - create_table->table_name)) - { - error= FALSE; - goto err; - } - } -#endif if (tables && check_table_access(thd, SELECT_ACL, tables, FALSE, UINT_MAX, FALSE)) goto err; diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 27cd03d8edd..7e8c1fed999 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -901,19 +901,6 @@ static void plugin_del(struct st_plugin_int *plugin) DBUG_VOID_RETURN; } -#ifdef NOT_USED - -static void plugin_del(const LEX_STRING *name) -{ - struct st_plugin_int *plugin; - DBUG_ENTER("plugin_del(name)"); - if ((plugin= plugin_find_internal(name, MYSQL_ANY_PLUGIN))) - plugin_del(plugin); - DBUG_VOID_RETURN; -} - -#endif - static void reap_plugins(void) { uint count, idx; @@ -1394,51 +1381,6 @@ static bool register_builtin(struct st_mysql_plugin *plugin, DBUG_RETURN(0); } -#ifdef NOT_USED_YET -/* - Register a plugin at run time. (note, this doesn't initialize a plugin) - Will be useful for embedded applications. - - SYNOPSIS - plugin_register_builtin() - thd current thread (used to store scratch data in mem_root) - plugin static plugin to install - - RETURN - false - plugin registered successfully -*/ -bool plugin_register_builtin(THD *thd, struct st_mysql_plugin *plugin) -{ - struct st_plugin_int tmp, *ptr; - bool result= true; - int dummy_argc= 0; - DBUG_ENTER("plugin_register_builtin"); - - bzero(&tmp, sizeof(tmp)); - tmp.plugin= plugin; - tmp.name.str= (char *)plugin->name; - tmp.name.length= strlen(plugin->name); - - mysql_mutex_lock(&LOCK_plugin); - mysql_rwlock_wrlock(&LOCK_system_variables_hash); - - if (test_plugin_options(thd->mem_root, &tmp, &dummy_argc, NULL)) - goto end; - tmp.state= PLUGIN_IS_UNINITIALIZED; - if ((result= register_builtin(plugin, &tmp, &ptr))) - { - mysql_del_sys_var_chain(tmp.system_vars); - restore_pluginvar_names(tmp.system_vars); - } - -end: - mysql_rwlock_unlock(&LOCK_system_variables_hash); - mysql_mutex_unlock(&LOCK_plugin); - - DBUG_RETURN(result);; -} -#endif /* NOT_USED_YET */ - /* called only by plugin_init() diff --git a/sql/sql_priv.h b/sql/sql_priv.h index 708608fc2f1..f0f6a1969f5 100644 --- a/sql/sql_priv.h +++ b/sql/sql_priv.h @@ -59,8 +59,6 @@ (Old), (New)); \ } while(0) -extern char err_shared_dir[]; - /*************************************************************************/ #endif diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 1d61c37ba13..60354d15091 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -11894,38 +11894,30 @@ flush_cached_records(JOIN *join,JOIN_TAB *join_tab,bool skip_last) SQL_SELECT *select=join_tab->select; if (rc == NESTED_LOOP_OK) { - bool consider_record= !join_tab->cache.select || - !join_tab->cache.select->skip_record(); - - /* - Check for error: skip_record() can execute code by calling - Item_subselect::val_*. We need to check for errors (if any) - after such call. - */ - if (join->thd->is_error()) + bool skip_record= FALSE; + if (join_tab->cache.select && + join_tab->cache.select->skip_record(join->thd, &skip_record)) { reset_cache_write(&join_tab->cache); return NESTED_LOOP_ERROR; } - if (consider_record) + if (!skip_record) { uint i; reset_cache_read(&join_tab->cache); for (i=(join_tab->cache.records- (skip_last ? 1 : 0)) ; i-- > 0 ;) { read_cached_record(join_tab); - if (!select || !select->skip_record()) + skip_record= FALSE; + if (select && select->skip_record(join->thd, &skip_record)) { - /* - Check for error: skip_record() can execute code by calling - Item_subselect::val_*. We need to check for errors (if any) - after such call. - */ - if (join->thd->is_error()) - rc= NESTED_LOOP_ERROR; - else - rc= (join_tab->next_select)(join,join_tab+1,0); + reset_cache_write(&join_tab->cache); + return NESTED_LOOP_ERROR; + } + if (!skip_record) + { + rc= (join_tab->next_select)(join,join_tab+1,0); if (rc != NESTED_LOOP_OK && rc != NESTED_LOOP_NO_MORE_ROWS) { reset_cache_write(&join_tab->cache); @@ -12441,11 +12433,6 @@ join_ft_read_first(JOIN_TAB *tab) if (!table->file->inited) table->file->ha_index_init(tab->ref.key, 1); -#if NOT_USED_YET - /* as ft-key doesn't use store_key's, see also FT_SELECT::init() */ - if (cp_buffer_from_ref(tab->join->thd, table, &tab->ref)) - return -1; -#endif table->file->ft_init(); if ((error= table->file->ft_read(table->record[0]))) @@ -12735,22 +12722,6 @@ end_write(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), { copy_fields(&join->tmp_table_param); copy_funcs(join->tmp_table_param.items_to_copy); -#ifdef TO_BE_DELETED - if (!table->uniques) // If not unique handling - { - /* Copy null values from group to row */ - ORDER *group; - for (group=table->group ; group ; group=group->next) - { - Item *item= *group->item; - if (item->maybe_null) - { - Field *field=item->get_tmp_table_field(); - field->ptr[-1]= (uchar) (field->is_null() ? 1 : 0); - } - } - } -#endif if (!join->having || join->having->val_int()) { int error; @@ -13958,44 +13929,6 @@ err: DBUG_RETURN(-1); } -#ifdef NOT_YET -/** - Add the HAVING criteria to table->select. -*/ - -static bool fix_having(JOIN *join, Item **having) -{ - (*having)->update_used_tables(); // Some tables may have been const - JOIN_TAB *table=&join->join_tab[join->const_tables]; - table_map used_tables= join->const_table_map | table->table->map; - - DBUG_EXECUTE("where",print_where(*having,"having", QT_ORDINARY);); - Item* sort_table_cond=make_cond_for_table(*having,used_tables,used_tables); - if (sort_table_cond) - { - if (!table->select) - if (!(table->select=new SQL_SELECT)) - return 1; - if (!table->select->cond) - table->select->cond=sort_table_cond; - else // This should never happen - if (!(table->select->cond= new Item_cond_and(table->select->cond, - sort_table_cond)) || - table->select->cond->fix_fields(join->thd, &table->select->cond)) - return 1; - table->select_cond=table->select->cond; - table->select_cond->top_level_item(); - DBUG_EXECUTE("where",print_where(table->select_cond, - "select and having", - QT_ORDINARY);); - *having=make_cond_for_table(*having,~ (table_map) 0,~used_tables); - DBUG_EXECUTE("where", - print_where(*having,"having after make_cond", QT_ORDINARY);); - } - return 0; -} -#endif - /***************************************************************************** Remove duplicates from tmp table diff --git a/sql/sql_show.cc b/sql/sql_show.cc index dc3784eb538..b1f6104b73c 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -5714,52 +5714,6 @@ static int get_schema_partitions_record(THD *thd, TABLE_LIST *tables, } -#ifdef NOT_USED -static interval_type get_real_interval_type(interval_type i_type) -{ - switch (i_type) { - case INTERVAL_YEAR: - return INTERVAL_YEAR; - - case INTERVAL_QUARTER: - case INTERVAL_YEAR_MONTH: - case INTERVAL_MONTH: - return INTERVAL_MONTH; - - case INTERVAL_WEEK: - case INTERVAL_DAY: - return INTERVAL_DAY; - - case INTERVAL_DAY_HOUR: - case INTERVAL_HOUR: - return INTERVAL_HOUR; - - case INTERVAL_DAY_MINUTE: - case INTERVAL_HOUR_MINUTE: - case INTERVAL_MINUTE: - return INTERVAL_MINUTE; - - case INTERVAL_DAY_SECOND: - case INTERVAL_HOUR_SECOND: - case INTERVAL_MINUTE_SECOND: - case INTERVAL_SECOND: - return INTERVAL_SECOND; - - case INTERVAL_DAY_MICROSECOND: - case INTERVAL_HOUR_MICROSECOND: - case INTERVAL_MINUTE_MICROSECOND: - case INTERVAL_SECOND_MICROSECOND: - case INTERVAL_MICROSECOND: - return INTERVAL_MICROSECOND; - case INTERVAL_LAST: - DBUG_ASSERT(0); - } - DBUG_ASSERT(0); - return INTERVAL_SECOND; -} - -#endif - #ifdef HAVE_EVENT_SCHEDULER /* Loads an event from mysql.event and copies it's data to a row of diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 42b3dfaad83..c4b4a37b35a 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -7312,12 +7312,22 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, if (table->s->tmp_table != NO_TMP_TABLE) { /* Close lock if this is a transactional table */ - if (thd->lock && - ! (thd->locked_tables_mode == LTM_LOCK_TABLES || - thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES)) + if (thd->lock) { - mysql_unlock_tables(thd, thd->lock); - thd->lock=0; + if (thd->locked_tables_mode != LTM_LOCK_TABLES && + thd->locked_tables_mode != LTM_PRELOCKED_UNDER_LOCK_TABLES) + { + mysql_unlock_tables(thd, thd->lock); + thd->lock=0; + } + else + { + /* + If LOCK TABLES list is not empty and contains this table, + unlock the table and remove the table from this list. + */ + mysql_lock_remove(thd, thd->lock, table); + } } /* Remove link to old table and rename the new one */ close_temporary_table(thd, table, 1, 1); diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 25c1fd6fa1e..c52467531a9 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -477,7 +477,14 @@ int mysql_update(THD *thd, while (!(error=info.read_record(&info)) && !thd->killed) { thd->examined_row_count++; - if (!(select && select->skip_record())) + bool skip_record= FALSE; + if (select && select->skip_record(thd, &skip_record)) + { + error= 1; + table->file->unlock_row(); + break; + } + if (!skip_record) { if (table->file->was_semi_consistent_read()) continue; /* repeat the read of the same row if it still exists */ @@ -584,7 +591,8 @@ int mysql_update(THD *thd, while (!(error=info.read_record(&info)) && !thd->killed) { thd->examined_row_count++; - if (!(select && select->skip_record())) + bool skip_record; + if (!select || (!select->skip_record(thd, &skip_record) && !skip_record)) { if (table->file->was_semi_consistent_read()) continue; /* repeat the read of the same row if it still exists */ diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 9e212fb95e9..320e6d9253e 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -796,7 +796,11 @@ static Sys_var_lexstring Sys_init_connect( static Sys_var_charptr Sys_init_file( "init_file", "Read SQL commands from this file at startup", READ_ONLY GLOBAL_VAR(opt_init_file), - IF_DISABLE_GRANT_OPTIONS(NO_CMD_LINE, CMD_LINE(REQUIRED_ARG)), +#ifdef DISABLE_GRANT_OPTIONS + NO_CMD_LINE, +#else + CMD_LINE(REQUIRED_ARG), +#endif IN_FS_CHARSET, DEFAULT(0)); static PolyLock_rwlock PLock_sys_init_slave(&LOCK_sys_init_slave); @@ -2873,6 +2877,8 @@ static bool fix_log_output(sys_var *self, THD *thd, enum_var_type type) return false; } +static const char *log_output_names[] = { "NONE", "FILE", "TABLE", NULL}; + static Sys_var_set Sys_log_output( "log_output", "Syntax: log-output=value[,value...], " "where \"value\" could be TABLE, FILE or NONE", diff --git a/sql/table.cc b/sql/table.cc index a58623f0036..c89ce90e719 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -797,7 +797,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, goto err; /* purecov: inspected */ bzero((char*) keyinfo,n_length); share->key_info= keyinfo; - key_part= my_reinterpret_cast(KEY_PART_INFO*) (keyinfo+keys); + key_part= reinterpret_cast<KEY_PART_INFO*>(keyinfo+keys); strpos=disk_buff+6; if (!(rec_per_key= (ulong*) alloc_root(&share->mem_root, @@ -1822,8 +1822,8 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, if (!(key_info= (KEY*) alloc_root(&outparam->mem_root, n_length))) goto err; outparam->key_info= key_info; - key_part= (my_reinterpret_cast(KEY_PART_INFO*) (key_info+share->keys)); - + key_part= (reinterpret_cast<KEY_PART_INFO*>(key_info+share->keys)); + memcpy(key_info, share->key_info, sizeof(*key_info)*share->keys); memcpy(key_part, share->key_info[0].key_part, (sizeof(*key_part) * share->key_parts)); diff --git a/sql/udf_example.c b/sql/udf_example.c index 284689d329f..5f8e71d25fa 100644 --- a/sql/udf_example.c +++ b/sql/udf_example.c @@ -133,7 +133,6 @@ typedef long long longlong; #include <string.h> #define strmov(a,b) stpcpy(a,b) #define bzero(a,b) memset(a,0,b) -#define memcpy_fixed(a,b,c) memcpy(a,b,c) #endif #endif #include <mysql.h> @@ -778,7 +777,7 @@ char *lookup(UDF_INIT *initid __attribute__((unused)), UDF_ARGS *args, } pthread_mutex_unlock(&LOCK_hostname); #endif - memcpy_fixed((char*) &in,(char*) *hostent->h_addr_list, sizeof(in.s_addr)); + memcpy(&in, *hostent->h_addr_list, sizeof(in.s_addr)); *res_length= (ulong) (strmov(result, inet_ntoa(in)) - result); return result; } |