From 29e5a66b8800dfb2ff3d28e859d443c0f8c033d3 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 May 2007 19:58:06 +0300 Subject: [PATCH 01/74] Added casts to avoid compiler warnings and fixed a wrong type. mysys/array.c: Added casts to avoid compiler warnings. mysys/hash.c: Added casts to avoid compiler warnings. sql/sql_plugin.cc: Fixed wrong type. --- mysys/array.c | 18 +++++++++--------- mysys/hash.c | 8 +++++--- sql/sql_plugin.cc | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/mysys/array.c b/mysys/array.c index d9c17d817cc..8a539f18a20 100644 --- a/mysys/array.c +++ b/mysys/array.c @@ -63,7 +63,7 @@ my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size, array->size_of_element=element_size; if ((array->buffer= init_buffer)) DBUG_RETURN(FALSE); - if (!(array->buffer=(char*) my_malloc_ci(element_size*init_alloc,MYF(MY_WME)))) + if (!(array->buffer=(uchar*) my_malloc_ci(element_size*init_alloc,MYF(MY_WME)))) { array->max_element=0; DBUG_RETURN(TRUE); @@ -132,7 +132,7 @@ uchar *alloc_dynamic(DYNAMIC_ARRAY *array) if (array->elements == array->max_element) { char *new_ptr; - if (array->buffer == (char *)(array + 1)) + if (array->buffer == (uchar *)(array + 1)) { /* In this senerio, the buffer is statically preallocated, @@ -152,7 +152,7 @@ uchar *alloc_dynamic(DYNAMIC_ARRAY *array) array->size_of_element, MYF(MY_WME | MY_ALLOW_ZERO_PTR)))) return 0; - array->buffer=new_ptr; + array->buffer= (uchar*) new_ptr; array->max_element+=array->alloc_increment; } return array->buffer+(array->elements++ * array->size_of_element); @@ -206,7 +206,7 @@ my_bool set_dynamic(DYNAMIC_ARRAY *array, uchar* element, uint idx) char *new_ptr; size=(idx+array->alloc_increment)/array->alloc_increment; size*= array->alloc_increment; - if (array->buffer == (char *)(array + 1)) + if (array->buffer == (uchar *)(array + 1)) { /* In this senerio, the buffer is statically preallocated, @@ -224,7 +224,7 @@ my_bool set_dynamic(DYNAMIC_ARRAY *array, uchar* element, uint idx) array->size_of_element, MYF(MY_WME | MY_ALLOW_ZERO_PTR)))) return TRUE; - array->buffer=new_ptr; + array->buffer= (uchar*) new_ptr; array->max_element=size; } bzero((uchar*) (array->buffer+array->elements*array->size_of_element), @@ -273,7 +273,7 @@ void delete_dynamic(DYNAMIC_ARRAY *array) /* Just mark as empty if we are using a static buffer */ - if (array->buffer == (char *)(array + 1)) + if (array->buffer == (uchar *)(array + 1)) array->elements= 0; else if (array->buffer) @@ -295,7 +295,7 @@ void delete_dynamic(DYNAMIC_ARRAY *array) void delete_dynamic_element(DYNAMIC_ARRAY *array, uint idx) { - char *ptr=array->buffer+array->size_of_element*idx; + char *ptr= (char*) array->buffer+array->size_of_element*idx; array->elements--; memmove(ptr,ptr+array->size_of_element, (array->elements-idx)*array->size_of_element); @@ -318,12 +318,12 @@ void freeze_size(DYNAMIC_ARRAY *array) /* Do nothing if we are using a static buffer */ - if (array->buffer == (char *)(array + 1)) + if (array->buffer == (uchar *)(array + 1)) return; if (array->buffer && array->max_element != elements) { - array->buffer=(char*) my_realloc(array->buffer, + array->buffer=(uchar*) my_realloc(array->buffer, elements*array->size_of_element, MYF(MY_WME)); array->max_element=elements; diff --git a/mysys/hash.c b/mysys/hash.c index 698c2299f4d..d8c914d13dd 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -308,7 +308,8 @@ static int hashcmp(const HASH *hash, HASH_LINK *pos, const uchar *key, my_bool my_hash_insert(HASH *info,const uchar *record) { int flag; - uint halfbuff,hash_nr,first_index,idx; + size_t idx; + uint halfbuff,hash_nr,first_index; uchar *ptr_to_rec,*ptr_to_rec2; HASH_LINK *data,*empty,*gpos,*gpos2,*pos; @@ -535,7 +536,8 @@ exit: my_bool hash_update(HASH *hash, uchar *record, uchar *old_key, size_t old_key_length) { - uint idx,new_index,new_pos_index,blength,records,empty; + uint new_index,new_pos_index,blength,records,empty; + size_t idx; HASH_LINK org_link,*data,*previous,*pos; DBUG_ENTER("hash_update"); @@ -546,7 +548,7 @@ my_bool hash_update(HASH *hash, uchar *record, uchar *old_key, if ((found= hash_first(hash, new_key, idx, &state))) do { - if (found != record) + if (found != (char*) record) DBUG_RETURN(1); /* Duplicate entry */ } while ((found= hash_next(hash, new_key, idx, &state))); diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index f0dd586977b..fde4d9df2ec 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1056,7 +1056,7 @@ static uchar *get_hash_key(const uchar *buff, size_t *length, } -static uchar *get_bookmark_hash_key(const uchar *buff, uint *length, +static uchar *get_bookmark_hash_key(const uchar *buff, size_t *length, my_bool not_used __attribute__((unused))) { struct st_bookmark *var= (st_bookmark *)buff; From 44c169f2cdcce8be7177f963597b81e1b4e1eef1 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 May 2007 08:22:38 +0300 Subject: [PATCH 02/74] Added casts and fixed wrong type. client/mysqltest.c: Added casts to avoid compiler warnings. mysys/my_quick.c: Added cast to avoid compiler warning. sql/sql_map.cc: Added casts to avoid compiler warnings. strings/ctype-ucs2.c: Fixed wrong type. --- client/mysqltest.c | 28 ++++++++++++++++------------ mysys/my_quick.c | 2 +- sql/sql_map.cc | 4 ++-- strings/ctype-ucs2.c | 6 +++--- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 4442cd538d3..50080636054 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1222,7 +1222,8 @@ VAR* var_get(const char *var_name, const char **var_name_end, my_bool raw, if (length >= MAX_VAR_NAME_LENGTH) die("Too long variable name: %s", save_var_name); - if (!(v = (VAR*) hash_search(&var_hash, save_var_name, length))) + if (!(v = (VAR*) hash_search(&var_hash, (const uchar*) save_var_name, + length))) { char buff[MAX_VAR_NAME_LENGTH+1]; strmake(buff, save_var_name, length); @@ -1253,7 +1254,7 @@ err: VAR *var_obtain(const char *name, int len) { VAR* v; - if ((v = (VAR*)hash_search(&var_hash, name, len))) + if ((v = (VAR*)hash_search(&var_hash, (const uchar *) name, len))) return v; v = var_init(0, name, len, "", 0); my_hash_insert(&var_hash, (uchar*)v); @@ -4667,7 +4668,7 @@ void free_win_path_patterns() for (i=0 ; i < patterns.elements ; i++) { const char** pattern= dynamic_element(&patterns, i, const char**); - my_free(*pattern, MYF(0)); + my_free((char*) *pattern, MYF(0)); } delete_dynamic(&patterns); } @@ -7488,7 +7489,8 @@ REPLACE *init_replace(char * *from, char * *to,uint count, for (i=1 ; i <= found_sets ; i++) { pos=from[found_set[i-1].table_offset]; - rep_str[i].found= !bcmp(pos,"\\^",3) ? 2 : 1; + rep_str[i].found= !bcmp((const uchar*) pos, + (const uchar*) "\\^", 3) ? 2 : 1; rep_str[i].replace_string=to_array[found_set[i-1].table_offset]; rep_str[i].to_offset=found_set[i-1].found_offset-start_at_word(pos); rep_str[i].from_offset=found_set[i-1].found_offset-replace_len(pos)+ @@ -7686,15 +7688,17 @@ int find_found(FOUND_SET *found_set,uint table_offset, int found_offset) uint start_at_word(char * pos) { - return (((!bcmp(pos,"\\b",2) && pos[2]) || !bcmp(pos,"\\^",2)) ? 1 : 0); + return (((!bcmp((const uchar*) pos, (const uchar*) "\\b",2) && pos[2]) || + !bcmp((const uchar*) pos, (const uchar*) "\\^", 2)) ? 1 : 0); } uint end_of_word(char * pos) { char * end=strend(pos); - return ((end > pos+2 && !bcmp(end-2,"\\b",2)) || - (end >= pos+2 && !bcmp(end-2,"\\$",2))) ? - 1 : 0; + return ((end > pos+2 && !bcmp((const uchar*) end-2, + (const uchar*) "\\b", 2)) || + (end >= pos+2 && !bcmp((const uchar*) end-2, + (const uchar*) "\\$",2))) ? 1 : 0; } /**************************************************************************** @@ -7721,7 +7725,7 @@ int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name) if (!(pa->str= (uchar*) my_malloc((uint) (PS_MALLOC-MALLOC_OVERHEAD), MYF(MY_WME)))) { - my_free(pa->typelib.type_names,MYF(0)); + my_free((char*) pa->typelib.type_names,MYF(0)); DBUG_RETURN (-1); } pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(uchar*)+ @@ -7767,9 +7771,9 @@ int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name) old_count*sizeof(*pa->flag)); } pa->flag[pa->typelib.count]=0; /* Reset flag */ - pa->typelib.type_names[pa->typelib.count++]= pa->str+pa->length; + pa->typelib.type_names[pa->typelib.count++]= (char*) pa->str+pa->length; pa->typelib.type_names[pa->typelib.count]= NullS; /* Put end-mark */ - VOID(strmov(pa->str+pa->length,name)); + VOID(strmov((char*) pa->str+pa->length,name)); pa->length+=length; DBUG_RETURN(0); } /* insert_pointer_name */ @@ -7782,7 +7786,7 @@ void free_pointer_array(POINTER_ARRAY *pa) if (pa->typelib.count) { pa->typelib.count=0; - my_free(pa->typelib.type_names,MYF(0)); + my_free((char*) pa->typelib.type_names,MYF(0)); pa->typelib.type_names=0; my_free(pa->str,MYF(0)); } diff --git a/mysys/my_quick.c b/mysys/my_quick.c index af8ef05bd5f..c19fe08572d 100644 --- a/mysys/my_quick.c +++ b/mysys/my_quick.c @@ -50,7 +50,7 @@ size_t my_quick_write(File Filedes,const uchar *Buffer,size_t Count) #ifndef DBUG_OFF writtenbytes = #endif - write(Filedes,Buffer,Count)) != Count) + (size_t) write(Filedes,Buffer,Count)) != Count) { #ifndef DBUG_OFF if ((writtenbytes == 0 || writtenbytes == (size_t) -1) && errno == EINTR) diff --git a/sql/sql_map.cc b/sql/sql_map.cc index 0a494377fc6..7b707f813fc 100644 --- a/sql/sql_map.cc +++ b/sql/sql_map.cc @@ -48,7 +48,7 @@ mapped_files::mapped_files(const char * filename,uchar *magic,uint magic_length) if (map && memcmp(map,magic,magic_length)) { my_error(ER_WRONG_MAGIC, MYF(0), name); - VOID(my_munmap(map,size)); + VOID(my_munmap((char*) map,size)); map=0; } if (!map) @@ -66,7 +66,7 @@ mapped_files::~mapped_files() #ifdef HAVE_MMAP if (file >= 0) { - VOID(my_munmap(map,size)); + VOID(my_munmap((char*) map,size)); VOID(my_close(file,MYF(0))); file= -1; map=0; } diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 88a686ff256..38b2789c545 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1586,8 +1586,8 @@ my_bool my_like_range_ucs2(CHARSET_INFO *cs, -ulong my_scan_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *str, const char *end, int sequence_type) +size_t my_scan_ucs2(CHARSET_INFO *cs __attribute__((unused)), + const char *str, const char *end, int sequence_type) { const char *str0= str; end--; /* for easier loop condition, because of two bytes per character */ @@ -1600,7 +1600,7 @@ ulong my_scan_ucs2(CHARSET_INFO *cs __attribute__((unused)), if (str[0] != '\0' || str[1] != ' ') break; } - return (ulong) (str - str0); + return (size_t) (str - str0); default: return 0; } From 7a432ea43bedbdbcf7e2b5a4dd53b4b8eacfca68 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 May 2007 09:26:53 +0300 Subject: [PATCH 03/74] Added casts and fixed wrong type. client/mysqltest.c: Added casts to avoid compiler warnings. mysys/my_quick.c: Added cast to avoid compiler warning. sql/log.cc: Fixed compiler problem on Solaris. sql/sql_map.cc: Added casts to avoid compiler warnings. strings/ctype-ucs2.c: Fixed wrong type. --- client/mysqltest.c | 28 ++++++++++++++++------------ mysys/my_quick.c | 2 +- sql/log.cc | 2 +- sql/sql_map.cc | 4 ++-- strings/ctype-ucs2.c | 6 +++--- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 4442cd538d3..50080636054 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1222,7 +1222,8 @@ VAR* var_get(const char *var_name, const char **var_name_end, my_bool raw, if (length >= MAX_VAR_NAME_LENGTH) die("Too long variable name: %s", save_var_name); - if (!(v = (VAR*) hash_search(&var_hash, save_var_name, length))) + if (!(v = (VAR*) hash_search(&var_hash, (const uchar*) save_var_name, + length))) { char buff[MAX_VAR_NAME_LENGTH+1]; strmake(buff, save_var_name, length); @@ -1253,7 +1254,7 @@ err: VAR *var_obtain(const char *name, int len) { VAR* v; - if ((v = (VAR*)hash_search(&var_hash, name, len))) + if ((v = (VAR*)hash_search(&var_hash, (const uchar *) name, len))) return v; v = var_init(0, name, len, "", 0); my_hash_insert(&var_hash, (uchar*)v); @@ -4667,7 +4668,7 @@ void free_win_path_patterns() for (i=0 ; i < patterns.elements ; i++) { const char** pattern= dynamic_element(&patterns, i, const char**); - my_free(*pattern, MYF(0)); + my_free((char*) *pattern, MYF(0)); } delete_dynamic(&patterns); } @@ -7488,7 +7489,8 @@ REPLACE *init_replace(char * *from, char * *to,uint count, for (i=1 ; i <= found_sets ; i++) { pos=from[found_set[i-1].table_offset]; - rep_str[i].found= !bcmp(pos,"\\^",3) ? 2 : 1; + rep_str[i].found= !bcmp((const uchar*) pos, + (const uchar*) "\\^", 3) ? 2 : 1; rep_str[i].replace_string=to_array[found_set[i-1].table_offset]; rep_str[i].to_offset=found_set[i-1].found_offset-start_at_word(pos); rep_str[i].from_offset=found_set[i-1].found_offset-replace_len(pos)+ @@ -7686,15 +7688,17 @@ int find_found(FOUND_SET *found_set,uint table_offset, int found_offset) uint start_at_word(char * pos) { - return (((!bcmp(pos,"\\b",2) && pos[2]) || !bcmp(pos,"\\^",2)) ? 1 : 0); + return (((!bcmp((const uchar*) pos, (const uchar*) "\\b",2) && pos[2]) || + !bcmp((const uchar*) pos, (const uchar*) "\\^", 2)) ? 1 : 0); } uint end_of_word(char * pos) { char * end=strend(pos); - return ((end > pos+2 && !bcmp(end-2,"\\b",2)) || - (end >= pos+2 && !bcmp(end-2,"\\$",2))) ? - 1 : 0; + return ((end > pos+2 && !bcmp((const uchar*) end-2, + (const uchar*) "\\b", 2)) || + (end >= pos+2 && !bcmp((const uchar*) end-2, + (const uchar*) "\\$",2))) ? 1 : 0; } /**************************************************************************** @@ -7721,7 +7725,7 @@ int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name) if (!(pa->str= (uchar*) my_malloc((uint) (PS_MALLOC-MALLOC_OVERHEAD), MYF(MY_WME)))) { - my_free(pa->typelib.type_names,MYF(0)); + my_free((char*) pa->typelib.type_names,MYF(0)); DBUG_RETURN (-1); } pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(uchar*)+ @@ -7767,9 +7771,9 @@ int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name) old_count*sizeof(*pa->flag)); } pa->flag[pa->typelib.count]=0; /* Reset flag */ - pa->typelib.type_names[pa->typelib.count++]= pa->str+pa->length; + pa->typelib.type_names[pa->typelib.count++]= (char*) pa->str+pa->length; pa->typelib.type_names[pa->typelib.count]= NullS; /* Put end-mark */ - VOID(strmov(pa->str+pa->length,name)); + VOID(strmov((char*) pa->str+pa->length,name)); pa->length+=length; DBUG_RETURN(0); } /* insert_pointer_name */ @@ -7782,7 +7786,7 @@ void free_pointer_array(POINTER_ARRAY *pa) if (pa->typelib.count) { pa->typelib.count=0; - my_free(pa->typelib.type_names,MYF(0)); + my_free((char*) pa->typelib.type_names,MYF(0)); pa->typelib.type_names=0; my_free(pa->str,MYF(0)); } diff --git a/mysys/my_quick.c b/mysys/my_quick.c index af8ef05bd5f..c19fe08572d 100644 --- a/mysys/my_quick.c +++ b/mysys/my_quick.c @@ -50,7 +50,7 @@ size_t my_quick_write(File Filedes,const uchar *Buffer,size_t Count) #ifndef DBUG_OFF writtenbytes = #endif - write(Filedes,Buffer,Count)) != Count) + (size_t) write(Filedes,Buffer,Count)) != Count) { #ifndef DBUG_OFF if ((writtenbytes == 0 || writtenbytes == (size_t) -1) && errno == EINTR) diff --git a/sql/log.cc b/sql/log.cc index 11afdc8d20d..6ef1c1ea912 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -4855,7 +4855,7 @@ void TC_LOG_MMAP::close() case 3: my_free((uchar*)pages, MYF(0)); case 2: - my_munmap((uchar*)data, (size_t)file_length); + my_munmap((char*)data, (size_t)file_length); case 1: my_close(fd, MYF(0)); } diff --git a/sql/sql_map.cc b/sql/sql_map.cc index 0a494377fc6..7b707f813fc 100644 --- a/sql/sql_map.cc +++ b/sql/sql_map.cc @@ -48,7 +48,7 @@ mapped_files::mapped_files(const char * filename,uchar *magic,uint magic_length) if (map && memcmp(map,magic,magic_length)) { my_error(ER_WRONG_MAGIC, MYF(0), name); - VOID(my_munmap(map,size)); + VOID(my_munmap((char*) map,size)); map=0; } if (!map) @@ -66,7 +66,7 @@ mapped_files::~mapped_files() #ifdef HAVE_MMAP if (file >= 0) { - VOID(my_munmap(map,size)); + VOID(my_munmap((char*) map,size)); VOID(my_close(file,MYF(0))); file= -1; map=0; } diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 88a686ff256..38b2789c545 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1586,8 +1586,8 @@ my_bool my_like_range_ucs2(CHARSET_INFO *cs, -ulong my_scan_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *str, const char *end, int sequence_type) +size_t my_scan_ucs2(CHARSET_INFO *cs __attribute__((unused)), + const char *str, const char *end, int sequence_type) { const char *str0= str; end--; /* for easier loop condition, because of two bytes per character */ @@ -1600,7 +1600,7 @@ ulong my_scan_ucs2(CHARSET_INFO *cs __attribute__((unused)), if (str[0] != '\0' || str[1] != ' ') break; } - return (ulong) (str - str0); + return (size_t) (str - str0); default: return 0; } From 441b11374d12832cc831c1b62e352c5c1769b519 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 May 2007 16:47:11 +0300 Subject: [PATCH 04/74] Don't give warning that readonly variable is forced to be readonly mysql-test-run run now fails if we have [Warning] and [ERROR] as tags in .err file Fixed wrong reference to the mysql manual Fixed wrong prototype that caused some tests to fail on 64 bit platforms mysql-test/lib/mtr_report.pl: Test run now fails if we have [Warning] and [ERROR] as tags in .err file Added list of all common 'not fatal' errors to ignore error list mysql-test/mysql-test-run-shell.sh: Fixed some wrong startup options mysql-test/t/disabled.def: Disable instance manager tests because they generate warnings (and probably don't read the option files correctly) sql/ha_ndbcluster_binlog.cc: Ensure we log all binglog errors with the "NDB Binlog" tag sql/slave.cc: Make errors uniform sql/sql_plugin.cc: Don't give warning that readonly variable is forced to be readonly sql/stacktrace.c: Corrected manual reference storage/blackhole/ha_blackhole.cc: Fixed wrong prototype that caused test to fail on 64 bit platforms storage/example/ha_example.cc: Fixed wrong prototype that caused test to fail on 64 bit platforms --- mysql-test/lib/mtr_report.pl | 64 +++++++++++++++++++++++++++--- mysql-test/mysql-test-run-shell.sh | 9 ++++- mysql-test/t/disabled.def | 3 ++ sql/ha_ndbcluster_binlog.cc | 20 +++++----- sql/slave.cc | 4 +- sql/sql_plugin.cc | 4 +- sql/stacktrace.c | 8 ++-- storage/blackhole/ha_blackhole.cc | 4 +- storage/example/ha_example.cc | 2 +- 9 files changed, 90 insertions(+), 28 deletions(-) diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl index ce206a35727..fc1f8b59d23 100644 --- a/mysql-test/lib/mtr_report.pl +++ b/mysql-test/lib/mtr_report.pl @@ -265,8 +265,12 @@ sub mtr_report_stats ($) { else { # We report different types of problems in order - foreach my $pattern ( "^Warning:", "^Error:", "^==.* at 0x", - "InnoDB: Warning", "missing DBUG_RETURN", + foreach my $pattern ( "^Warning:", + "\\[Warning\\]", + "\\[ERROR\\]", + "^Error:", "^==.* at 0x", + "InnoDB: Warning", + "missing DBUG_RETURN", "mysqld: Warning", "allocated at line", "Attempting backtrace", "Assertion .* failed" ) @@ -281,10 +285,58 @@ sub mtr_report_stats ($) { while ( ) { # Skip some non fatal warnings from the log files - if ( /Warning:\s+Table:.* on (delete|rename)/ or - /Warning:\s+Setting lower_case_table_names=2/ or - /Warning:\s+One can only use the --user.*root/ or - /InnoDB: Warning: we did not need to do crash recovery/) + if ( + /Aborted connection/ or + /Client requested master to start replication from impossible position/ or + /Could not find first log file name in binary log/ or + /Enabling keys got errno/ or + /Error reading master configuration/ or + /Error reading packet/ or + /Event Scheduler/ or + /Failed to open the existing master info file/ or + /Failed to open log/ or + /Forcing shutdown of [0-9]* plugins/ or + /Got error [0-9]* when reading table/ or + /Incorrect definition of table/ or + /Incorrect information in file/ or + /InnoDB: Warning: we did not need to do crash recovery/ or + /Invalid \(old\?\) table or database name/ or + /Lock wait timeout exceeded/ or + /Log entry on master is longer than max_allowed_packet/ or + /NDB Binlog:/ or + /Neither --relay-log nor --relay-log-index were used/ or + /Query partially completed/ or + /Slave I.O thread aborted while waiting for relay log/ or + /Slave SQL thread is stopped because UNTIL condition/ or + /Slave \(additional info\)/ or + /Slave: According to the master's version/ or + /Slave: Error .*Deadlock found/ or + /Slave: Error .*Unknown table/ or + /Slave: Query caused different errors on master and slave/ or + /Slave: The incident LOST_EVENTS occured on the master/ or + /Slave: Unknown error.* 1105/ or + /Slave: .*master may suffer from/ or + /Slave: Error in Write_rows event: / or + /Slave: Table width mismatch/ or + /Slave: Error .* doesn't exist/ or + /Slave: Column [0-9]* type mismatch/ or + /Slave: Table .* doesn't exist/ or + /Slave: Field .* of table .* has no default value/ or + /Sort aborted/ or + /Warning:\s+One can only use the --user.*root/ or + /Warning:\s+Setting lower_case_table_names=2/ or + /Warning:\s+Table:.* on (delete|rename)/ or + /You have an error in your SQL syntax/ or + /deprecated/ or + /description of time zone/ or + /equal MySQL server ids/ or + /error .*connecting to master/ or + /error reading log entry/ or + /lower_case_table_names is set/ or + /skip-name-resolve mode/ or + /slave SQL thread aborted/ or + /Slave: .*Duplicate entry/ + ) { next; # Skip these lines } diff --git a/mysql-test/mysql-test-run-shell.sh b/mysql-test/mysql-test-run-shell.sh index 953478fa9f4..54323c878a9 100644 --- a/mysql-test/mysql-test-run-shell.sh +++ b/mysql-test/mysql-test-run-shell.sh @@ -629,6 +629,11 @@ else TEST_MODE=`echo $TEST_MODE | sed 's/^ *//'` fi +# +# Skip tests that doesn't work with shell version +# +SKIP_TEST="$SKIP_TEST bootstrap" + #++ # mysqld Environment Parameters #-- @@ -900,8 +905,8 @@ MYSQL_DUMP="$MYSQL_DUMP --no-defaults --debug-info -uroot --socket=$MASTER_MYSOC MYSQL_SLAP="$MYSQL_SLAP -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLSLAP_OPT" MYSQL_DUMP_SLAVE="$MYSQL_DUMP_DIR --no-defaults -uroot --socket=$SLAVE_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT" MYSQL_SHOW="$MYSQL_SHOW --no-defaults --debug-info -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLSHOW_OPT" -MYSQL_BINLOG="$MYSQL_BINLOG --debug-info --no-defaults --local-load=$MYSQL_TMP_DIR --character-sets-dir=$CHARSETSDIR $EXTRA_MYSQLBINLOG_OPT" -MYSQL_IMPORT="$MYSQL_IMPORT --debug-info -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT" +MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --debug-info --local-load=$MYSQL_TMP_DIR --character-sets-dir=$CHARSETSDIR $EXTRA_MYSQLBINLOG_OPT" +MYSQL_IMPORT="$MYSQL_IMPORT --no-defaults --debug-info -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT" MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose" MYSQL="$MYSQL --no-defaults --debug-info --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD" export MYSQL MYSQL_CHECK MYSQL_DUMP MYSQL_DUMP_SLAVE MYSQL_SHOW MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES MYSQL_IMPORT diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index e2a0b30c592..8f5403844d3 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -15,6 +15,9 @@ im_options : Bug#20294 2006-07-24 stewart Instance manager test im_daemon_life_cycle : Bug#20294 2007-05-14 alik Instance manager tests fail randomly im_cmd_line : Bug#20294 2007-05-14 alik Instance manager tests fail randomly im_life_cycle : BUG#27851 Instance manager dies on ASSERT in ~Thread_registry() or from not being able to close a mysqld instance. +im_instance_conf : BUG#28743 Instance manager generates warnings in test suite +im_utils : BUG#28743 Instance manager generates warnings in test suite + concurrent_innodb : BUG#21579 2006-08-11 mleich innodb_concurrent random failures with varying differences ndb_autodiscover : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog ndb_autodiscover2 : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index 8b2250a9a9b..391051d8775 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -1893,16 +1893,16 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, pthread_mutex_lock(&LOCK_open); if (ndbcluster_check_if_local_table(schema->db, schema->name)) { - DBUG_PRINT("info", ("NDB binlog: Skipping locally defined table '%s.%s'", + DBUG_PRINT("info", ("NDB Binlog: Skipping locally defined table '%s.%s'", schema->db, schema->name)); - sql_print_error("NDB binlog: Skipping locally defined table '%s.%s' from " + sql_print_error("NDB Binlog: Skipping locally defined table '%s.%s' from " "binlog schema event '%s' from node %d. ", schema->db, schema->name, schema->query, schema->node_id); } else if (ndb_create_table_from_engine(thd, schema->db, schema->name)) { - sql_print_error("NDB binlog: Could not discover table '%s.%s' from " + sql_print_error("NDB Binlog: Could not discover table '%s.%s' from " "binlog schema event '%s' from node %d. " "my_errno: %d", schema->db, schema->name, schema->query, @@ -1910,7 +1910,7 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, List_iterator_fast it(thd->warn_list); MYSQL_ERROR *err; while ((err= it++)) - sql_print_warning("NDB binlog: (%d)%s", err->code, err->msg); + sql_print_warning("NDB Binlog: (%d)%s", err->code, err->msg); } pthread_mutex_unlock(&LOCK_open); log_query= 1; @@ -1931,7 +1931,7 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, else { /* Database contained local tables, leave it */ - sql_print_error("NDB binlog: Skipping drop database '%s' since it contained local tables " + sql_print_error("NDB Binlog: Skipping drop database '%s' since it contained local tables " "binlog schema event '%s' from node %d. ", schema->db, schema->query, schema->node_id); @@ -2179,23 +2179,23 @@ ndb_binlog_thread_handle_schema_event_post_epoch(THD *thd, pthread_mutex_lock(&LOCK_open); if (ndbcluster_check_if_local_table(schema->db, schema->name)) { - DBUG_PRINT("info", ("NDB binlog: Skipping locally defined table '%s.%s'", + DBUG_PRINT("info", ("NDB Binlog: Skipping locally defined table '%s.%s'", schema->db, schema->name)); - sql_print_error("NDB binlog: Skipping locally defined table '%s.%s' from " + sql_print_error("NDB Binlog: Skipping locally defined table '%s.%s' from " "binlog schema event '%s' from node %d. ", schema->db, schema->name, schema->query, schema->node_id); } else if (ndb_create_table_from_engine(thd, schema->db, schema->name)) { - sql_print_error("NDB binlog: Could not discover table '%s.%s' from " + sql_print_error("NDB Binlog: Could not discover table '%s.%s' from " "binlog schema event '%s' from node %d. my_errno: %d", schema->db, schema->name, schema->query, schema->node_id, my_errno); List_iterator_fast it(thd->warn_list); MYSQL_ERROR *err; while ((err= it++)) - sql_print_warning("NDB binlog: (%d)%s", err->code, err->msg); + sql_print_warning("NDB Binlog: (%d)%s", err->code, err->msg); } pthread_mutex_unlock(&LOCK_open); } @@ -4113,7 +4113,7 @@ restart: injector::transaction::binlog_pos start= trans.start_pos(); if (int r= trans.commit()) { - sql_print_error("NDB binlog: " + sql_print_error("NDB Binlog: " "Error during COMMIT of GCI. Error: %d", r); /* TODO: Further handling? */ diff --git a/sql/slave.cc b/sql/slave.cc index 7504585696d..aa42bad3265 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -601,9 +601,9 @@ void slave_print_msg(enum loglevel level, RELAY_LOG_INFO const *rli, my_vsnprintf(pbuff, pbuffsize, msg, args); /* If the msg string ends with '.', do not add a ',' it would be ugly */ if (pbuff[0] && (*(strend(pbuff)-1) == '.')) - (*report_function)("Slave: %s Error_code: %d", pbuff, err_code); + (*report_function)("Slave: %s Error_code: %d", pbuff, err_code); else - (*report_function)("Slave: %s, Error_code: %d", pbuff, err_code); + (*report_function)("Slave: %s. Error_code: %d", pbuff, err_code); DBUG_VOID_RETURN; } diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index fde4d9df2ec..37301751d03 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -2879,9 +2879,9 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, if (!opt->update) { opt->update= update_func_str; - if (!(opt->flags & PLUGIN_VAR_MEMALLOC)) + if (!(opt->flags & PLUGIN_VAR_MEMALLOC | PLUGIN_VAR_READONLY)) { - opt->flags |= PLUGIN_VAR_READONLY; + opt->flags|= PLUGIN_VAR_READONLY; sql_print_warning("Server variable %s of plugin %s was forced " "to be read-only: string variable without " "update_func and PLUGIN_VAR_MEMALLOC flag", diff --git a/sql/stacktrace.c b/sql/stacktrace.c index 36e64087c5e..40507907120 100644 --- a/sql/stacktrace.c +++ b/sql/stacktrace.c @@ -206,9 +206,11 @@ terribly wrong...\n"); fprintf(stderr, "Stack trace seems successful - bottom reached\n"); end: - fprintf(stderr, "Please read http://dev.mysql.com/doc/mysql/en/using-stack-trace.html and follow instructions on how to resolve the stack trace. Resolved\n\ -stack trace is much more helpful in diagnosing the problem, so please do \n\ -resolve it\n"); + fprintf(stderr, + "Please read http://dev.mysql.com/doc/refman/5.1/en/resolve-stack-dump.html\n" + "and follow instructions on how to resolve the stack trace.\n" + "Resolved stack trace is much more helpful in diagnosing the\n" + "problem, so please do resolve it\n"); } #endif /* TARGET_OS_LINUX */ #endif /* HAVE_STACKTRACE */ diff --git a/storage/blackhole/ha_blackhole.cc b/storage/blackhole/ha_blackhole.cc index 1441b7f71fb..03da7808948 100644 --- a/storage/blackhole/ha_blackhole.cc +++ b/storage/blackhole/ha_blackhole.cc @@ -287,8 +287,8 @@ static void blackhole_free_key(st_blackhole_share *share) my_free((uchar*) share, MYF(0)); } -static uchar* blackhole_get_key(st_blackhole_share *share, uint *length, - my_bool not_used __attribute__((unused))) +static uchar* blackhole_get_key(st_blackhole_share *share, size_t *length, + my_bool not_used __attribute__((unused))) { *length= share->table_name_length; return (uchar*) share->table_name; diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc index cd43672bb88..06efc727837 100644 --- a/storage/example/ha_example.cc +++ b/storage/example/ha_example.cc @@ -114,7 +114,7 @@ pthread_mutex_t example_mutex; Function we use in the creation of our hash to get key. */ -static uchar* example_get_key(EXAMPLE_SHARE *share,uint *length, +static uchar* example_get_key(EXAMPLE_SHARE *share, size_t *length, my_bool not_used __attribute__((unused))) { *length=share->table_name_length; From 72a9b472beef06c2c45b21488184f7bad9457ef8 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 May 2007 19:46:48 +0300 Subject: [PATCH 05/74] Disabled compiler warnings mainly for Win 64. mysys/my_conio.c: To avoid a warning from compiler. sql/ha_partition.cc: result is type bool, so calculation should be forced to that also. support-files/compiler_warnings.supp: Added new disabled warnings for Win 64. --- mysys/my_conio.c | 6 ++++-- sql/ha_partition.cc | 2 +- support-files/compiler_warnings.supp | 9 ++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/mysys/my_conio.c b/mysys/my_conio.c index d03f63a11a9..1ea1f7a820a 100644 --- a/mysys/my_conio.c +++ b/mysys/my_conio.c @@ -125,6 +125,7 @@ char* my_cgets(char *buffer, size_t clen, size_t* plen) { ULONG state; char *result; + DWORD plen_res; CONSOLE_SCREEN_BUFFER_INFO csbi; pthread_auto_mutex_decl(my_conio_cs); @@ -171,7 +172,8 @@ char* my_cgets(char *buffer, size_t clen, size_t* plen) do { clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y); - if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, clen - 1, plen, NULL)) + if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, clen - 1, &plen_res, + NULL)) { result= NULL; clen>>= 1; @@ -183,7 +185,7 @@ char* my_cgets(char *buffer, size_t clen, size_t* plen) } } while (GetLastError() == ERROR_NOT_ENOUGH_MEMORY); - + *plen= plen_res; if (result != NULL) { diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 36711cc100b..e9f4bc4c745 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -1965,7 +1965,7 @@ bool ha_partition::create_handler_file(const char *name) MYF(MY_WME))) >= 0) { result= my_write(file, (uchar *) file_buffer, tot_len_byte, - MYF(MY_WME | MY_NABP)); + MYF(MY_WME | MY_NABP)) != 0; VOID(my_close(file, MYF(0))); } else diff --git a/support-files/compiler_warnings.supp b/support-files/compiler_warnings.supp index 04f5a30bafa..0a2c720b81b 100644 --- a/support-files/compiler_warnings.supp +++ b/support-files/compiler_warnings.supp @@ -51,6 +51,11 @@ db_vrfy.c : .*comparison is always false due to limited range of data type.* .* : conversion from '.*size_t' to 'uint32'.* .* : conversion from '.*size_t' to 'off_t'.* .* : conversion from '.*size_t' to 'size_s'.* +.* : conversion from '.*size_t' to 'DWORD'.* +.* : conversion from '.*size_t' to 'uLongf'.* +.* : conversion from '.*size_t' to 'UINT'.* +.* : conversion from '.*size_t' to 'uInt'.* +.* : conversion from '.*size_t' to 'uint16'.* # # The following should be fixed by the ndb team @@ -64,7 +69,9 @@ db_vrfy.c : .*comparison is always false due to limited range of data type.* # listener.cc : .*conversion from 'SOCKET' to 'int'.* net_serv.cc : .*conversion from 'SOCKET' to 'int'.* -mi_packrec.c : .*result of 32-bit shift implicitly converted to 64 bits.* : 567 + +# allow a little moving space for the warning below +mi_packrec.c : .*result of 32-bit shift implicitly converted to 64 bits.* : 560-600 # # Wrong compiler warnings From 9ac571dc0cc09143373368f75ad91a4c3d93661e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 May 2007 21:07:48 +0300 Subject: [PATCH 06/74] Added casts to remove compiler warnings on windows Give warnings also for safe_mutex errors found by test system Added some warnings from different machines in pushbuild mysql-test/lib/mtr_report.pl: Give warnings also for safe_mutex errors Added some warnings from different machines in pushbuild mysys/my_compress.c: Added casts to remove compiler warnings on windows sql/sql_class.cc: Added cast to remove compiler warnings on windows --- mysql-test/lib/mtr_report.pl | 23 +++++++++++++++-------- mysys/my_compress.c | 4 ++-- sql/sql_class.cc | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl index fc1f8b59d23..0cfe44f5e1e 100644 --- a/mysql-test/lib/mtr_report.pl +++ b/mysql-test/lib/mtr_report.pl @@ -270,6 +270,7 @@ sub mtr_report_stats ($) { "\\[ERROR\\]", "^Error:", "^==.* at 0x", "InnoDB: Warning", + "^safe_mutex:", "missing DBUG_RETURN", "mysqld: Warning", "allocated at line", @@ -286,6 +287,7 @@ sub mtr_report_stats ($) { { # Skip some non fatal warnings from the log files if ( + /"SELECT UNIX_TIMESTAMP()" failed on master/ or /Aborted connection/ or /Client requested master to start replication from impossible position/ or /Could not find first log file name in binary log/ or @@ -293,8 +295,8 @@ sub mtr_report_stats ($) { /Error reading master configuration/ or /Error reading packet/ or /Event Scheduler/ or - /Failed to open the existing master info file/ or /Failed to open log/ or + /Failed to open the existing master info file/ or /Forcing shutdown of [0-9]* plugins/ or /Got error [0-9]* when reading table/ or /Incorrect definition of table/ or @@ -304,25 +306,30 @@ sub mtr_report_stats ($) { /Lock wait timeout exceeded/ or /Log entry on master is longer than max_allowed_packet/ or /NDB Binlog:/ or + /NDB: failed to setup table/ or + /NDB: only row based binary logging/ or /Neither --relay-log nor --relay-log-index were used/ or /Query partially completed/ or /Slave I.O thread aborted while waiting for relay log/ or /Slave SQL thread is stopped because UNTIL condition/ or + /Slave SQL thread retried transaction/ or /Slave \(additional info\)/ or + /Slave: .*Duplicate column name/ or + /Slave: .*master may suffer from/ or /Slave: According to the master's version/ or + /Slave: Column [0-9]* type mismatch/ or + /Slave: Error .* doesn't exist/ or /Slave: Error .*Deadlock found/ or /Slave: Error .*Unknown table/ or + /Slave: Error in Write_rows event: / or + /Slave: Field .* of table .* has no default value/ or /Slave: Query caused different errors on master and slave/ or + /Slave: Table .* doesn't exist/ or + /Slave: Table width mismatch/ or /Slave: The incident LOST_EVENTS occured on the master/ or /Slave: Unknown error.* 1105/ or - /Slave: .*master may suffer from/ or - /Slave: Error in Write_rows event: / or - /Slave: Table width mismatch/ or - /Slave: Error .* doesn't exist/ or - /Slave: Column [0-9]* type mismatch/ or - /Slave: Table .* doesn't exist/ or - /Slave: Field .* of table .* has no default value/ or /Sort aborted/ or + /Time-out in NDB/ or /Warning:\s+One can only use the --user.*root/ or /Warning:\s+Setting lower_case_table_names=2/ or /Warning:\s+Table:.* on (delete|rename)/ or diff --git a/mysys/my_compress.c b/mysys/my_compress.c index 3966be8b6bb..d495a1c1c6d 100644 --- a/mysys/my_compress.c +++ b/mysys/my_compress.c @@ -68,7 +68,7 @@ uchar *my_compress_alloc(const uchar *packet, size_t *len, size_t *complen) return 0; /* Not enough memory */ tmp_complen= *complen; - res= compress((Bytef*) compbuf, &tmp_complen, (Bytef*) packet, *len); + res= compress((Bytef*) compbuf, &tmp_complen, (Bytef*) packet, (uLong) *len); *complen= tmp_complen; if (res != Z_OK) @@ -120,7 +120,7 @@ my_bool my_uncompress(uchar *packet, size_t len, size_t *complen) tmp_complen= *complen; error= uncompress((Bytef*) compbuf, &tmp_complen, (Bytef*) packet, - len); + (uLong) len); *complen= tmp_complen; if (error != Z_OK) { /* Probably wrong packet */ diff --git a/sql/sql_class.cc b/sql/sql_class.cc index ffa058164dd..ef1690516f0 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -927,7 +927,7 @@ void THD::add_changed_table(TABLE *table) DBUG_ASSERT((options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) && table->file->has_transactions()); add_changed_table(table->s->table_cache_key.str, - table->s->table_cache_key.length); + (long) table->s->table_cache_key.length); DBUG_VOID_RETURN; } From 08dd5dcf168bbc1e1bf6e8bab784fdde58068daa Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 25 Jul 2007 01:58:12 +0300 Subject: [PATCH 07/74] Added support for 'internal temporary tables' in HEAP tables. Now we don't take any mutexes when creating or dropping internal HEAP tables during SELECT. Change buffer sizes to size_t to make keycache 64 bit safe on platforms where sizeof(ulong) != sizeof(size_t) BitKeeper/etc/ignore: added support-files/mysqld_multi.server include/heap.h: Added 'internal_table' to HP_CREATE_INFO include/keycache.h: Change buffer sizes to size_t to make keycache 64 bit safe include/my_base.h: Added HA_OPEN_INTERNAL_TABLE to mark temporary tables that should be deleted on close mysys/mf_keycache.c: Change buffer sizes to size_t to make keycache 64 bit safe sql/sql_select.cc: Added HA_OPEN_INTERNAL_TABLE to mark temporary tables that should be deleted on close Removed not anymore needed call to delete_table() storage/heap/ha_heap.cc: Added support for internal temporary tables that should be deleted on close. Internal tables now use dedicated open and close calls to avoid taking mutexes. If heap_open() failes, now delete the newly created table. (This fixes a possible memory leak) Remove never executed info() in create() storage/heap/ha_heap.h: Added slots needed to handle internal temporary tables storage/heap/heapdef.h: Protect against C++ inclusion storage/heap/hp_close.c: Don't call list_delete() for internal temporary tables (They are not in the list) storage/heap/hp_create.c: Added HP_SHARE ** element to heap_create() to store the SHARE of the newly created table. For internal temporary tables: Don't take any mutex and don't put them into the open table list. storage/heap/hp_open.c: Split heap_open() into sub functions to be able to create internal temporary tables without putting them in the heap_share_list. Add faster open() functions for when we already know the 'share'. storage/heap/hp_test1.c: Update call to heap_create() Initialize all keyinfo members. storage/heap/hp_test2.c: Update call to heap_create() --- .bzrignore | 1 + include/heap.h | 5 ++- include/keycache.h | 6 +-- include/my_base.h | 2 + mysys/mf_keycache.c | 19 +++++----- sql/sql_select.cc | 5 +-- storage/heap/ha_heap.cc | 32 +++++++++++----- storage/heap/ha_heap.h | 2 + storage/heap/heapdef.h | 2 + storage/heap/hp_close.c | 3 +- storage/heap/hp_create.c | 53 ++++++++++++++++---------- storage/heap/hp_open.c | 81 ++++++++++++++++++++++++++++++---------- storage/heap/hp_test1.c | 4 +- storage/heap/hp_test2.c | 8 ++-- 14 files changed, 154 insertions(+), 69 deletions(-) diff --git a/.bzrignore b/.bzrignore index 329c5e227ca..fdcbc3b262b 100644 --- a/.bzrignore +++ b/.bzrignore @@ -2995,3 +2995,4 @@ win/vs71cache.txt win/vs8cache.txt zlib/*.ds? zlib/*.vcproj +support-files/mysqld_multi.server diff --git a/include/heap.h b/include/heap.h index d309fb4f162..4a1c7d419ed 100644 --- a/include/heap.h +++ b/include/heap.h @@ -189,11 +189,14 @@ typedef struct st_heap_create_info ulonglong max_table_size; ulonglong auto_increment; my_bool with_auto_increment; + my_bool internal_table; } HP_CREATE_INFO; /* Prototypes for heap-functions */ extern HP_INFO *heap_open(const char *name, int mode); +extern HP_INFO *heap_open_from_share(HP_SHARE *share, int mode); +extern HP_INFO *heap_open_from_share_and_register(HP_SHARE *share, int mode); extern int heap_close(HP_INFO *info); extern int heap_write(HP_INFO *info,const uchar *buff); extern int heap_update(HP_INFO *info,const uchar *old,const uchar *newdata); @@ -204,7 +207,7 @@ extern int heap_delete(HP_INFO *info,const uchar *buff); extern int heap_info(HP_INFO *info,HEAPINFO *x,int flag); extern int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, uint reclength, ulong max_records, ulong min_records, - HP_CREATE_INFO *create_info); + HP_CREATE_INFO *create_info, HP_SHARE **share); extern int heap_delete_table(const char *name); extern void heap_drop_table(HP_INFO *info); extern int heap_extra(HP_INFO *info,enum ha_extra_function function); diff --git a/include/keycache.h b/include/keycache.h index 7f4ce86cea0..a6005bae878 100644 --- a/include/keycache.h +++ b/include/keycache.h @@ -47,7 +47,7 @@ typedef struct st_key_cache my_bool in_resize; /* true during resize operation */ my_bool resize_in_flush; /* true during flush of resize operation */ my_bool can_be_used; /* usage of cache for read/write is allowed */ - ulong key_cache_mem_size; /* specified size of the cache memory */ + size_t key_cache_mem_size; /* specified size of the cache memory */ uint key_cache_block_size; /* size of the page buffer of a cache block */ ulong min_warm_blocks; /* min number of warm blocks; */ ulong age_threshold; /* age threshold for hot blocks */ @@ -107,10 +107,10 @@ typedef struct st_key_cache extern KEY_CACHE dflt_key_cache_var, *dflt_key_cache; extern int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, - ulong use_mem, uint division_limit, + size_t use_mem, uint division_limit, uint age_threshold); extern int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, - ulong use_mem, uint division_limit, + size_t use_mem, uint division_limit, uint age_threshold); extern void change_key_cache_param(KEY_CACHE *keycache, uint division_limit, uint age_threshold); diff --git a/include/my_base.h b/include/my_base.h index 04127b81b78..339554979a8 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -48,6 +48,8 @@ #define HA_OPEN_FOR_REPAIR 32 /* open even if crashed */ #define HA_OPEN_FROM_SQL_LAYER 64 #define HA_OPEN_MMAP 128 /* open memory mapped */ +/* Internal temp table, used for temporary results */ +#define HA_OPEN_INTERNAL_TABLE 256 /* The following is parameter to ha_rkey() how to use key */ diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 1fef8aac170..c81da9a469a 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -366,10 +366,11 @@ static inline uint next_power(uint value) */ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, - ulong use_mem, uint division_limit, + size_t use_mem, uint division_limit, uint age_threshold) { - uint blocks, hash_links, length; + ulong blocks, hash_links; + size_t length; int error; DBUG_ENTER("init_key_cache"); DBUG_ASSERT(key_cache_block_size >= 512); @@ -405,8 +406,8 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, DBUG_PRINT("info", ("key_cache_block_size: %u", key_cache_block_size)); - blocks= (uint) (use_mem / (sizeof(BLOCK_LINK) + 2 * sizeof(HASH_LINK) + - sizeof(HASH_LINK*) * 5/4 + key_cache_block_size)); + blocks= (ulong) (use_mem / (sizeof(BLOCK_LINK) + 2 * sizeof(HASH_LINK) + + sizeof(HASH_LINK*) * 5/4 + key_cache_block_size)); /* It doesn't make sense to have too few blocks (less than 8) */ if (blocks >= 8) { @@ -424,18 +425,18 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, ALIGN_SIZE(hash_links * sizeof(HASH_LINK)) + ALIGN_SIZE(sizeof(HASH_LINK*) * keycache->hash_entries))) + - ((ulong) blocks * keycache->key_cache_block_size) > use_mem) + ((size_t) blocks * keycache->key_cache_block_size) > use_mem) blocks--; /* Allocate memory for cache page buffers */ if ((keycache->block_mem= - my_large_malloc((ulong) blocks * keycache->key_cache_block_size, + my_large_malloc((size_t) blocks * keycache->key_cache_block_size, MYF(MY_WME)))) { /* Allocate memory for blocks, hash_links and hash entries; For each block 2 hash links are allocated */ - if ((keycache->block_root= (BLOCK_LINK*) my_malloc((uint) length, + if ((keycache->block_root= (BLOCK_LINK*) my_malloc(length, MYF(0)))) break; my_large_free(keycache->block_mem, MYF(0)); @@ -448,7 +449,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, } blocks= blocks / 4*3; } - keycache->blocks_unused= (ulong) blocks; + keycache->blocks_unused= blocks; keycache->disk_blocks= (int) blocks; keycache->hash_links= hash_links; keycache->hash_root= (HASH_LINK**) ((char*) keycache->block_root + @@ -556,7 +557,7 @@ err: */ int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, - ulong use_mem, uint division_limit, + size_t use_mem, uint division_limit, uint age_threshold) { int blocks; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index be6d1f74852..6c7949fc8d7 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -10198,7 +10198,7 @@ static bool open_tmp_table(TABLE *table) { int error; if ((error=table->file->ha_open(table, table->s->table_name.str,O_RDWR, - HA_OPEN_TMP_TABLE))) + HA_OPEN_TMP_TABLE | HA_OPEN_INTERNAL_TABLE))) { table->file->print_error(error,MYF(0)); /* purecov: inspected */ table->db_stat=0; @@ -10436,8 +10436,7 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param, /* remove heap table and change to use myisam table */ (void) table->file->ha_rnd_end(); - (void) table->file->close(); - (void) table->file->delete_table(table->s->table_name.str); + (void) table->file->close(); // This deletes the table ! delete table->file; table->file=0; plugin_unlock(0, table->s->db_plugin); diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc index f2b67f20c57..2e7c47e17b4 100644 --- a/storage/heap/ha_heap.cc +++ b/storage/heap/ha_heap.cc @@ -22,7 +22,7 @@ #include "mysql_priv.h" #include #include "ha_heap.h" - +#include "heapdef.h" static handler *heap_create_handler(handlerton *hton, TABLE_SHARE *table, @@ -61,8 +61,8 @@ static handler *heap_create_handler(handlerton *hton, *****************************************************************************/ ha_heap::ha_heap(handlerton *hton, TABLE_SHARE *table_arg) - :handler(hton, table_arg), file(0), records_changed(0), - key_stat_version(0) + :handler(hton, table_arg), file(0), records_changed(0), internal_table(0), + key_stat_version(0) {} @@ -90,13 +90,25 @@ const char **ha_heap::bas_ext() const int ha_heap::open(const char *name, int mode, uint test_if_locked) { - if (!(file= heap_open(name, mode)) && my_errno == ENOENT) + if ((test_if_locked & HA_OPEN_INTERNAL_TABLE) || + !(file= heap_open(name, mode)) && my_errno == ENOENT) { HA_CREATE_INFO create_info; + internal_table= test(test_if_locked & HA_OPEN_INTERNAL_TABLE); bzero(&create_info, sizeof(create_info)); + file= 0; if (!create(name, table, &create_info)) { - file= heap_open(name, mode); + file= internal_table ? + heap_open_from_share(internal_share, mode) : + heap_open_from_share_and_register(internal_share, mode); + if (!file) + { + /* Couldn't open table; Remove the newly created table */ + pthread_mutex_lock(&THR_LOCK_heap); + hp_free(internal_share); + pthread_mutex_unlock(&THR_LOCK_heap); + } implicit_emptied= 1; } } @@ -120,7 +132,7 @@ int ha_heap::open(const char *name, int mode, uint test_if_locked) int ha_heap::close(void) { - return heap_close(file); + return internal_table ? hp_close(file) : heap_close(file); } @@ -542,7 +554,7 @@ int ha_heap::delete_table(const char *name) void ha_heap::drop_table(const char *name) { - heap_drop_table(file); + file->s->delete_on_close= 1; close(); } @@ -681,16 +693,16 @@ int ha_heap::create(const char *name, TABLE *table_arg, create_info->auto_increment_value - 1 : 0); hp_create_info.max_table_size=current_thd->variables.max_heap_table_size; hp_create_info.with_auto_increment= found_real_auto_increment; + hp_create_info.internal_table= internal_table; max_rows = (ha_rows) (hp_create_info.max_table_size / mem_per_row); error= heap_create(name, keys, keydef, share->reclength, (ulong) ((share->max_rows < max_rows && share->max_rows) ? share->max_rows : max_rows), - (ulong) share->min_rows, &hp_create_info); + (ulong) share->min_rows, &hp_create_info, &internal_share); my_free((uchar*) keydef, MYF(0)); - if (file) - info(HA_STATUS_NO_LOCK | HA_STATUS_CONST | HA_STATUS_VARIABLE); + DBUG_ASSERT(file == 0); return (error); } diff --git a/storage/heap/ha_heap.h b/storage/heap/ha_heap.h index c414383a4aa..7db775ca15a 100644 --- a/storage/heap/ha_heap.h +++ b/storage/heap/ha_heap.h @@ -25,10 +25,12 @@ class ha_heap: public handler { HP_INFO *file; + HP_SHARE *internal_share; key_map btree_keys; /* number of records changed since last statistics update */ uint records_changed; uint key_stat_version; + my_bool internal_table; public: ha_heap(handlerton *hton, TABLE_SHARE *table); ~ha_heap() {} diff --git a/storage/heap/heapdef.h b/storage/heap/heapdef.h index c43d73eb96d..3fc94062303 100644 --- a/storage/heap/heapdef.h +++ b/storage/heap/heapdef.h @@ -16,6 +16,7 @@ /* This file is included in all heap-files */ #include /* This includes global */ +C_MODE_START #ifdef THREAD #include #endif @@ -107,3 +108,4 @@ extern pthread_mutex_t THR_LOCK_heap; #define pthread_mutex_lock(A) #define pthread_mutex_unlock(A) #endif +C_MODE_END diff --git a/storage/heap/hp_close.c b/storage/heap/hp_close.c index 79fed859487..d571815980c 100644 --- a/storage/heap/hp_close.c +++ b/storage/heap/hp_close.c @@ -42,7 +42,8 @@ int hp_close(register HP_INFO *info) } #endif info->s->changed=0; - heap_open_list=list_delete(heap_open_list,&info->open_list); + if (info->open_list.data) + heap_open_list=list_delete(heap_open_list,&info->open_list); if (!--info->s->open_count && info->s->delete_on_close) hp_free(info->s); /* Table was deleted */ my_free((uchar*) info,MYF(0)); diff --git a/storage/heap/hp_create.c b/storage/heap/hp_create.c index b910b89ffcd..b6814fc1614 100644 --- a/storage/heap/hp_create.c +++ b/storage/heap/hp_create.c @@ -19,23 +19,27 @@ static int keys_compare(heap_rb_param *param, uchar *key1, uchar *key2); static void init_block(HP_BLOCK *block,uint reclength,ulong min_records, ulong max_records); +/* Create a heap table */ + int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, uint reclength, ulong max_records, ulong min_records, - HP_CREATE_INFO *create_info) + HP_CREATE_INFO *create_info, HP_SHARE **res) { uint i, j, key_segs, max_length, length; - HP_SHARE *share; + HP_SHARE *share= 0; HA_KEYSEG *keyseg; - DBUG_ENTER("heap_create"); - pthread_mutex_lock(&THR_LOCK_heap); - if ((share= hp_find_named_heap(name)) && share->open_count == 0) + if (!create_info->internal_table) { - hp_free(share); - share= NULL; - } - + pthread_mutex_lock(&THR_LOCK_heap); + if ((share= hp_find_named_heap(name)) && share->open_count == 0) + { + hp_free(share); + share= 0; + } + } + if (!share) { HP_KEYDEF *keyinfo; @@ -131,10 +135,7 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, keys*sizeof(HP_KEYDEF)+ key_segs*sizeof(HA_KEYSEG), MYF(MY_ZEROFILL)))) - { - pthread_mutex_unlock(&THR_LOCK_heap); - DBUG_RETURN(1); - } + goto err; share->keydef= (HP_KEYDEF*) (share + 1); share->key_stat_version= 1; keyseg= (HA_KEYSEG*) (share->keydef + keys); @@ -189,20 +190,33 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, if (!(share->name= my_strdup(name,MYF(0)))) { my_free((uchar*) share,MYF(0)); - pthread_mutex_unlock(&THR_LOCK_heap); - DBUG_RETURN(1); + goto err; } #ifdef THREAD thr_lock_init(&share->lock); VOID(pthread_mutex_init(&share->intern_lock,MY_MUTEX_INIT_FAST)); #endif - share->open_list.data= (void*) share; - heap_share_list= list_add(heap_share_list,&share->open_list); + if (!create_info->internal_table) + { + share->open_list.data= (void*) share; + heap_share_list= list_add(heap_share_list,&share->open_list); + } + else + share->delete_on_close= 1; } - pthread_mutex_unlock(&THR_LOCK_heap); + if (!create_info->internal_table) + pthread_mutex_unlock(&THR_LOCK_heap); + + *res= share; DBUG_RETURN(0); + +err: + if (!create_info->internal_table) + pthread_mutex_unlock(&THR_LOCK_heap); + DBUG_RETURN(1); } /* heap_create */ + static int keys_compare(heap_rb_param *param, uchar *key1, uchar *key2) { uint not_used[2]; @@ -279,7 +293,8 @@ void heap_drop_table(HP_INFO *info) void hp_free(HP_SHARE *share) { - heap_share_list= list_delete(heap_share_list, &share->open_list); + if (share->open_list.data) /* If not internal table */ + heap_share_list= list_delete(heap_share_list, &share->open_list); hp_clear(share); /* Remove blocks from memory */ #ifdef THREAD thr_lock_delete(&share->lock); diff --git a/storage/heap/hp_open.c b/storage/heap/hp_open.c index d252704a11b..4d5ec6e27ac 100644 --- a/storage/heap/hp_open.c +++ b/storage/heap/hp_open.c @@ -22,43 +22,34 @@ #include "my_sys.h" -HP_INFO *heap_open(const char *name, int mode) +/* + Open heap table based on HP_SHARE structure + + NOTE + This doesn't register the table in the open table list. +*/ + +HP_INFO *heap_open_from_share(HP_SHARE *share, int mode) { HP_INFO *info; - HP_SHARE *share; + DBUG_ENTER("heap_open_from_share"); - DBUG_ENTER("heap_open"); - pthread_mutex_lock(&THR_LOCK_heap); - if (!(share= hp_find_named_heap(name))) - { - my_errno= ENOENT; - pthread_mutex_unlock(&THR_LOCK_heap); - DBUG_RETURN(0); - } if (!(info= (HP_INFO*) my_malloc((uint) sizeof(HP_INFO) + 2 * share->max_key_length, MYF(MY_ZEROFILL)))) { - pthread_mutex_unlock(&THR_LOCK_heap); DBUG_RETURN(0); } share->open_count++; #ifdef THREAD thr_lock_data_init(&share->lock,&info->lock,NULL); #endif - info->open_list.data= (void*) info; - heap_open_list= list_add(heap_open_list,&info->open_list); - pthread_mutex_unlock(&THR_LOCK_heap); - info->s= share; info->lastkey= (uchar*) (info + 1); info->recbuf= (uchar*) (info->lastkey + share->max_key_length); info->mode= mode; info->current_record= (ulong) ~0L; /* No current record */ - info->current_ptr= 0; - info->current_hash_ptr= 0; info->lastinx= info->errkey= -1; - info->update= 0; #ifndef DBUG_OFF info->opt_flag= READ_CHECK_USED; /* Check when changing */ #endif @@ -68,7 +59,59 @@ HP_INFO *heap_open(const char *name, int mode) DBUG_RETURN(info); } - /* map name to a heap-nr. If name isn't found return 0 */ + +/* + Open heap table based on HP_SHARE structure and register it +*/ + +HP_INFO *heap_open_from_share_and_register(HP_SHARE *share, int mode) +{ + HP_INFO *info; + DBUG_ENTER("heap_open_from_share_and_register"); + + pthread_mutex_lock(&THR_LOCK_heap); + if ((info= heap_open_from_share(share, mode))) + { + info->open_list.data= (void*) info; + heap_open_list= list_add(heap_open_list,&info->open_list); + } + pthread_mutex_unlock(&THR_LOCK_heap); + DBUG_RETURN(info); +} + + +/* + Open heap table based on name + + NOTE + This register the table in the open table list. so that it can be + found by future heap_open() calls. +*/ + +HP_INFO *heap_open(const char *name, int mode) +{ + HP_INFO *info; + HP_SHARE *share; + DBUG_ENTER("heap_open"); + + pthread_mutex_lock(&THR_LOCK_heap); + if (!(share= hp_find_named_heap(name))) + { + my_errno= ENOENT; + pthread_mutex_unlock(&THR_LOCK_heap); + DBUG_RETURN(0); + } + if ((info= heap_open_from_share(share, mode))) + { + info->open_list.data= (void*) info; + heap_open_list= list_add(heap_open_list,&info->open_list); + } + pthread_mutex_unlock(&THR_LOCK_heap); + DBUG_RETURN(info); +} + + +/* map name to a heap-nr. If name isn't found return 0 */ HP_SHARE *hp_find_named_heap(const char *name) { diff --git a/storage/heap/hp_test1.c b/storage/heap/hp_test1.c index aad5677db69..24eea141ad9 100644 --- a/storage/heap/hp_test1.c +++ b/storage/heap/hp_test1.c @@ -37,6 +37,7 @@ int main(int argc, char **argv) HP_KEYDEF keyinfo[10]; HA_KEYSEG keyseg[4]; HP_CREATE_INFO hp_create_info; + HP_SHARE *tmp_share; MY_INIT(argv[0]); filename= "test1"; @@ -52,6 +53,7 @@ int main(int argc, char **argv) keyinfo[0].seg[0].start=1; keyinfo[0].seg[0].length=6; keyinfo[0].seg[0].charset= &my_charset_latin1; + keyinfo[0].seg[0].null_bit= 0; keyinfo[0].flag = HA_NOSAME; deleted=0; @@ -59,7 +61,7 @@ int main(int argc, char **argv) printf("- Creating heap-file\n"); if (heap_create(filename,1,keyinfo,30,(ulong) flag*100000L,10L, - &hp_create_info) || + &hp_create_info, &tmp_share) || !(file= heap_open(filename, 2))) goto err; printf("- Writing records:s\n"); diff --git a/storage/heap/hp_test2.c b/storage/heap/hp_test2.c index 46b1fd61d46..e2a8e2f6926 100644 --- a/storage/heap/hp_test2.c +++ b/storage/heap/hp_test2.c @@ -59,6 +59,7 @@ int main(int argc, char *argv[]) char record[128],record2[128],record3[128],key[10]; const char *filename,*filename2; HP_INFO *file,*file2; + HP_SHARE *tmp_share; HP_KEYDEF keyinfo[MAX_KEYS]; HA_KEYSEG keyseg[MAX_KEYS*5]; HEAP_PTR position; @@ -126,7 +127,7 @@ int main(int argc, char *argv[]) printf("- Creating heap-file\n"); if (heap_create(filename,keys,keyinfo,reclength,(ulong) flag*100000L, - (ulong) recant/2, &hp_create_info) || + (ulong) recant/2, &hp_create_info, &tmp_share) || !(file= heap_open(filename, 2))) goto err; signal(SIGINT,endprog); @@ -562,8 +563,9 @@ int main(int argc, char *argv[]) heap_close(file2); printf("- Creating output heap-file 2\n"); - if (heap_create(filename2,1,keyinfo,reclength,0L,0L,&hp_create_info) || - !(file2= heap_open(filename2, 2))) + if (heap_create(filename2, 1, keyinfo, reclength, 0L, 0L, &hp_create_info, + &tmp_share) || + !(file2= heap_open_from_share_and_register(tmp_share, 2))) goto err; printf("- Copying and removing records\n"); From d47f320c192c72a144ca961d7ae4bb5693be0c62 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 28 Jul 2007 10:25:50 +0200 Subject: [PATCH 08/74] Backported mi_test_all.sh from 5.1. --- myisam/mi_test_all.sh | 256 +++++++++++++++++++++--------------------- 1 file changed, 128 insertions(+), 128 deletions(-) diff --git a/myisam/mi_test_all.sh b/myisam/mi_test_all.sh index c1fb12d7c3b..5989d9cfaf0 100755 --- a/myisam/mi_test_all.sh +++ b/myisam/mi_test_all.sh @@ -6,143 +6,143 @@ valgrind="valgrind --alignment=8 --leak-check=yes" silent="-s" -if test -f mi_test1$MACH ; then suffix=$MACH else suffix=""; fi -mi_test1$suffix $silent -myisamchk$suffix -se test1 -mi_test1$suffix $silent -N -S -myisamchk$suffix -se test1 -mi_test1$suffix $silent -P --checksum -myisamchk$suffix -se test1 -mi_test1$suffix $silent -P -N -S -myisamchk$suffix -se test1 -mi_test1$suffix $silent -B -N -R2 -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -k 480 --unique -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -N -S -R1 -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -p -S -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -p -S -N --unique -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -p -S -N --key_length=127 --checksum -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -p -S -N --key_length=128 -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -p -S --key_length=480 -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -B -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -B --key_length=64 --unique -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -B -k 480 --checksum -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -B -k 480 -N --unique --checksum -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -m -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -m -P --unique --checksum -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -m -P --key_length=480 --key_cache -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -m -p -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -w -S --unique -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -w --key_length=64 --checksum -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -w -N --key_length=480 -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -w -S --key_length=480 --checksum -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -b -N -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -a -b --key_length=480 -myisamchk$suffix -sm test1 -mi_test1$suffix $silent -p -B --key_length=480 -myisamchk$suffix -sm test1 +if test -f mi_test1$MACH ; then suffix=$MACH ; else suffix=""; fi +./mi_test1$suffix $silent +./myisamchk$suffix -se test1 +./mi_test1$suffix $silent -N -S +./myisamchk$suffix -se test1 +./mi_test1$suffix $silent -P --checksum +./myisamchk$suffix -se test1 +./mi_test1$suffix $silent -P -N -S +./myisamchk$suffix -se test1 +./mi_test1$suffix $silent -B -N -R2 +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -k 480 --unique +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -N -S -R1 +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -p -S +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -p -S -N --unique +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -p -S -N --key_length=127 --checksum +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -p -S -N --key_length=128 +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -p -S --key_length=480 +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -B +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -B --key_length=64 --unique +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -B -k 480 --checksum +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -B -k 480 -N --unique --checksum +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -m +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -m -P --unique --checksum +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -m -P --key_length=480 --key_cache +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -m -p +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -w -S --unique +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -w --key_length=64 --checksum +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -w -N --key_length=480 +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -w -S --key_length=480 --checksum +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -b -N +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -a -b --key_length=480 +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent -p -B --key_length=480 +./myisamchk$suffix -sm test1 -mi_test1$suffix $silent --checksum -myisamchk$suffix -se test1 -myisamchk$suffix -rs test1 -myisamchk$suffix -se test1 -myisamchk$suffix -rqs test1 -myisamchk$suffix -se test1 -myisamchk$suffix -rs --correct-checksum test1 -myisamchk$suffix -se test1 -myisamchk$suffix -rqs --correct-checksum test1 -myisamchk$suffix -se test1 -myisamchk$suffix -ros --correct-checksum test1 -myisamchk$suffix -se test1 -myisamchk$suffix -rqos --correct-checksum test1 -myisamchk$suffix -se test1 +./mi_test1$suffix $silent --checksum +./myisamchk$suffix -se test1 +./myisamchk$suffix -rs test1 +./myisamchk$suffix -se test1 +./myisamchk$suffix -rqs test1 +./myisamchk$suffix -se test1 +./myisamchk$suffix -rs --correct-checksum test1 +./myisamchk$suffix -se test1 +./myisamchk$suffix -rqs --correct-checksum test1 +./myisamchk$suffix -se test1 +./myisamchk$suffix -ros --correct-checksum test1 +./myisamchk$suffix -se test1 +./myisamchk$suffix -rqos --correct-checksum test1 +./myisamchk$suffix -se test1 # check of myisampack / myisamchk -myisampack$suffix --force -s test1 +./myisampack$suffix --force -s test1 # Ignore error for index file -myisamchk$suffix -es test1 2>&1 >& /dev/null -myisamchk$suffix -rqs test1 -myisamchk$suffix -es test1 -myisamchk$suffix -rs test1 -myisamchk$suffix -es test1 -myisamchk$suffix -rus test1 -myisamchk$suffix -es test1 +./myisamchk$suffix -es test1 2>&1 >& /dev/null +./myisamchk$suffix -rqs test1 +./myisamchk$suffix -es test1 +./myisamchk$suffix -rs test1 +./myisamchk$suffix -es test1 +./myisamchk$suffix -rus test1 +./myisamchk$suffix -es test1 -mi_test1$suffix $silent --checksum -S -myisamchk$suffix -se test1 -myisamchk$suffix -ros test1 -myisamchk$suffix -rqs test1 -myisamchk$suffix -se test1 +./mi_test1$suffix $silent --checksum -S +./myisamchk$suffix -se test1 +./myisamchk$suffix -ros test1 +./myisamchk$suffix -rqs test1 +./myisamchk$suffix -se test1 -myisampack$suffix --force -s test1 -myisamchk$suffix -rqs test1 -myisamchk$suffix -es test1 -myisamchk$suffix -rus test1 -myisamchk$suffix -es test1 +./myisampack$suffix --force -s test1 +./myisamchk$suffix -rqs test1 +./myisamchk$suffix -es test1 +./myisamchk$suffix -rus test1 +./myisamchk$suffix -es test1 -mi_test1$suffix $silent --checksum --unique -myisamchk$suffix -se test1 -mi_test1$suffix $silent --unique -S -myisamchk$suffix -se test1 +./mi_test1$suffix $silent --checksum --unique +./myisamchk$suffix -se test1 +./mi_test1$suffix $silent --unique -S +./myisamchk$suffix -se test1 -mi_test1$suffix $silent --key_multiple -N -S -myisamchk$suffix -sm test1 -mi_test1$suffix $silent --key_multiple -a -p --key_length=480 -myisamchk$suffix -sm test1 -mi_test1$suffix $silent --key_multiple -a -B --key_length=480 -myisamchk$suffix -sm test1 -mi_test1$suffix $silent --key_multiple -P -S -myisamchk$suffix -sm test1 +./mi_test1$suffix $silent --key_multiple -N -S +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent --key_multiple -a -p --key_length=480 +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent --key_multiple -a -B --key_length=480 +./myisamchk$suffix -sm test1 +./mi_test1$suffix $silent --key_multiple -P -S +./myisamchk$suffix -sm test1 -mi_test2$suffix $silent -L -K -W -P -myisamchk$suffix -sm test2 -mi_test2$suffix $silent -L -K -W -P -A -myisamchk$suffix -sm test2 -mi_test2$suffix $silent -L -K -W -P -S -R1 -m500 +./mi_test2$suffix $silent -L -K -W -P +./myisamchk$suffix -sm test2 +./mi_test2$suffix $silent -L -K -W -P -A +./myisamchk$suffix -sm test2 +./mi_test2$suffix $silent -L -K -W -P -S -R1 -m500 echo "mi_test2$suffix $silent -L -K -R1 -m2000 ; Should give error 135" -myisamchk$suffix -sm test2 -mi_test2$suffix $silent -L -K -R1 -m2000 -myisamchk$suffix -sm test2 -mi_test2$suffix $silent -L -K -P -S -R3 -m50 -b1000000 -myisamchk$suffix -sm test2 -mi_test2$suffix $silent -L -B -myisamchk$suffix -sm test2 -mi_test2$suffix $silent -D -B -c -myisamchk$suffix -sm test2 -mi_test2$suffix $silent -m10000 -e8192 -K -myisamchk$suffix -sm test2 -mi_test2$suffix $silent -m10000 -e16384 -E16384 -K -L -myisamchk$suffix -sm test2 +./myisamchk$suffix -sm test2 +./mi_test2$suffix $silent -L -K -R1 -m2000 +./myisamchk$suffix -sm test2 +./mi_test2$suffix $silent -L -K -P -S -R3 -m50 -b1000000 +./myisamchk$suffix -sm test2 +./mi_test2$suffix $silent -L -B +./myisamchk$suffix -sm test2 +./mi_test2$suffix $silent -D -B -c +./myisamchk$suffix -sm test2 +./mi_test2$suffix $silent -m10000 -e8192 -K +./myisamchk$suffix -sm test2 +./mi_test2$suffix $silent -m10000 -e16384 -E16384 -K -L +./myisamchk$suffix -sm test2 -mi_test2$suffix $silent -L -K -W -P -m50 -l -myisamlog$suffix -mi_test2$suffix $silent -L -K -W -P -m50 -l -b100 -myisamlog$suffix -time mi_test2$suffix $silent -time mi_test2$suffix $silent -K -B -time mi_test2$suffix $silent -L -B -time mi_test2$suffix $silent -L -K -B -time mi_test2$suffix $silent -L -K -W -B -time mi_test2$suffix $silent -L -K -W -S -B -time mi_test2$suffix $silent -D -K -W -S -B +./mi_test2$suffix $silent -L -K -W -P -m50 -l +./myisamlog$suffix +./mi_test2$suffix $silent -L -K -W -P -m50 -l -b100 +./myisamlog$suffix +time ./mi_test2$suffix $silent +time ./mi_test2$suffix $silent -K -B +time ./mi_test2$suffix $silent -L -B +time ./mi_test2$suffix $silent -L -K -B +time ./mi_test2$suffix $silent -L -K -W -B +time ./mi_test2$suffix $silent -L -K -W -S -B +time ./mi_test2$suffix $silent -D -K -W -S -B From ae8d075508dd1e942ee15ef4194c525f31e36098 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 30 Jul 2007 06:22:25 +0300 Subject: [PATCH 09/74] Add 'extension' field to all client library structures to make them extensible Reorder structure elements to make structures smaller and faster on 64 bit systems This is a first step in cleaning up the client include files (but should be enough to allow us to do future fixes without breaking the library) This change is part of WL#2872, Make client library extensible. configure.in: Increased shared library version of client library Detect gethrtime (for future) include/mysql.h: Add 'extension' field to all structures to make them extensible Reorder structure elements to make structures smaller and faster on 64 bit systems Removed an old define that is not needed for MySQL 5.1 include/mysql_com.h: Add 'extension' field to all structures to make them extensible Reorder structure elements to make structures smaller and faster on 64 bit systems --- configure.in | 7 ++--- include/mysql.h | 63 ++++++++++++++++++++++++++------------------- include/mysql_com.h | 27 ++++++++++--------- 3 files changed, 55 insertions(+), 42 deletions(-) diff --git a/configure.in b/configure.in index e2857cf43e3..23a926a5ce8 100644 --- a/configure.in +++ b/configure.in @@ -16,7 +16,7 @@ AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 DOT_FRM_VERSION=6 # See the libtool docs for information on how to do shared lib versions. -SHARED_LIB_MAJOR_VERSION=15 +SHARED_LIB_MAJOR_VERSION=16 SHARED_LIB_VERSION=$SHARED_LIB_MAJOR_VERSION:0:0 NDB_SHARED_LIB_MAJOR_VERSION=3 NDB_SHARED_LIB_VERSION=$NDB_SHARED_LIB_MAJOR_VERSION:0:0 @@ -1920,8 +1920,9 @@ AC_CHECK_FUNCS(alarm bcmp bfill bmove bsearch bzero \ chsize cuserid fchmod fcntl \ fconvert fdatasync finite fpresetsticky fpsetmask fsync ftruncate \ getcwd gethostbyaddr_r gethostbyname_r getpass getpassphrase getpwnam \ - getpwuid getrlimit getrusage getwd gmtime_r index initgroups isnan \ - localtime_r locking longjmp lrand48 madvise mallinfo memcpy memmove \ + getpwuid getrlimit getrusage getwd index initgroups isnan \ + localtime_r gethrtime gmtime_r \ + locking longjmp lrand48 madvise mallinfo memcpy memmove \ mkstemp mlockall perror poll pread pthread_attr_create mmap mmap64 getpagesize \ pthread_attr_getstacksize pthread_attr_setprio pthread_attr_setschedparam \ pthread_attr_setstacksize pthread_condattr_create pthread_getsequence_np \ diff --git a/include/mysql.h b/include/mysql.h index 489813bc154..009f9c40947 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -109,6 +109,7 @@ typedef struct st_mysql_field { unsigned int decimals; /* Number of decimals in field */ unsigned int charsetnr; /* Character set */ enum enum_field_types type; /* Type of field. See mysql_com.h for types */ + void *extension; } MYSQL_FIELD; typedef char **MYSQL_ROW; /* return data as array of strings */ @@ -143,12 +144,13 @@ typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */ typedef struct embedded_query_result EMBEDDED_QUERY_RESULT; typedef struct st_mysql_data { + MYSQL_ROWS *data; + struct embedded_query_result *embedded_info; + MEM_ROOT alloc; my_ulonglong rows; unsigned int fields; - MYSQL_ROWS *data; - MEM_ROOT alloc; /* extra info for embedded library */ - struct embedded_query_result *embedded_info; + void *extension; } MYSQL_DATA; enum mysql_option @@ -211,6 +213,7 @@ struct st_mysql_options { void (*local_infile_end)(void *); int (*local_infile_error)(void *, char *, unsigned int); void *local_infile_userdata; + void *extension; }; enum mysql_status @@ -300,27 +303,28 @@ typedef struct st_mysql from mysql_stmt_close if close had to cancel result set of this object. */ my_bool *unbuffered_fetch_owner; -#if defined(EMBEDDED_LIBRARY) || defined(EMBEDDED_LIBRARY_COMPATIBLE) || MYSQL_VERSION_ID >= 50100 /* needed for embedded server - no net buffer to store the 'info' */ char *info_buffer; -#endif + void *extension; } MYSQL; + typedef struct st_mysql_res { - my_ulonglong row_count; + my_ulonglong row_count; MYSQL_FIELD *fields; MYSQL_DATA *data; MYSQL_ROWS *data_cursor; unsigned long *lengths; /* column lengths of current row */ MYSQL *handle; /* for unbuffered reads */ - MEM_ROOT field_alloc; - unsigned int field_count, current_field; + const struct st_mysql_methods *methods; MYSQL_ROW row; /* If unbuffered read */ MYSQL_ROW current_row; /* buffer to current row */ + MEM_ROOT field_alloc; + unsigned int field_count, current_field; my_bool eof; /* Used by mysql_fetch_row */ /* mysql_stmt_close() had to cancel this result */ my_bool unbuffered_fetch_cancelled; - const struct st_mysql_methods *methods; + void *extension; } MYSQL_RES; #define MAX_MYSQL_MANAGER_ERR 256 @@ -340,21 +344,23 @@ typedef struct st_mysql_res { typedef struct st_mysql_manager { NET net; - char *host,*user,*passwd; + char *host, *user, *passwd; + char *net_buf, *net_buf_pos, *net_data_end; unsigned int port; - my_bool free_me; - my_bool eof; int cmd_status; int last_errno; - char* net_buf,*net_buf_pos,*net_data_end; int net_buf_size; + my_bool free_me; + my_bool eof; char last_error[MAX_MYSQL_MANAGER_ERR]; + void *extension; } MYSQL_MANAGER; typedef struct st_mysql_parameters { unsigned long *p_max_allowed_packet; unsigned long *p_net_buffer_length; + void *extension; } MYSQL_PARAMETERS; #if !defined(MYSQL_SERVER) && !defined(EMBEDDED_LIBRARY) @@ -369,6 +375,7 @@ typedef struct st_mysql_parameters */ int STDCALL mysql_server_init(int argc, char **argv, char **groups); void STDCALL mysql_server_end(void); + /* mysql_server_init/end need to be called when using libmysqld or libmysqlclient (exactly, mysql_server_init() is called by mysql_init() so @@ -657,23 +664,24 @@ typedef struct st_mysql_bind void *buffer; /* buffer to get/put data */ /* set this if you want to track data truncations happened during fetch */ my_bool *error; - enum enum_field_types buffer_type; /* buffer type */ - /* output buffer length, must be set when fetching str/binary */ - unsigned long buffer_length; unsigned char *row_ptr; /* for the current data position */ - unsigned long offset; /* offset position for char/binary fetch */ - unsigned long length_value; /* Used if length is 0 */ - unsigned int param_number; /* For null count and error messages */ - unsigned int pack_length; /* Internal length for packed data */ - my_bool error_value; /* used if error is 0 */ - my_bool is_unsigned; /* set if integer type is unsigned */ - my_bool long_data_used; /* If used with mysql_send_long_data */ - my_bool is_null_value; /* Used if is_null is 0 */ void (*store_param_func)(NET *net, struct st_mysql_bind *param); void (*fetch_result)(struct st_mysql_bind *, MYSQL_FIELD *, unsigned char **row); void (*skip_result)(struct st_mysql_bind *, MYSQL_FIELD *, unsigned char **row); + /* output buffer length, must be set when fetching str/binary */ + unsigned long buffer_length; + unsigned long offset; /* offset position for char/binary fetch */ + unsigned long length_value; /* Used if length is 0 */ + unsigned int param_number; /* For null count and error messages */ + unsigned int pack_length; /* Internal length for packed data */ + enum enum_field_types buffer_type; /* buffer type */ + my_bool error_value; /* used if error is 0 */ + my_bool is_unsigned; /* set if integer type is unsigned */ + my_bool long_data_used; /* If used with mysql_send_long_data */ + my_bool is_null_value; /* Used if is_null is 0 */ + void *extension; } MYSQL_BIND; @@ -688,15 +696,15 @@ typedef struct st_mysql_stmt MYSQL_FIELD *fields; /* result set metadata */ MYSQL_DATA result; /* cached result set */ MYSQL_ROWS *data_cursor; /* current row in cached result */ - /* copy of mysql->affected_rows after statement execution */ - my_ulonglong affected_rows; - my_ulonglong insert_id; /* copy of mysql->insert_id */ /* mysql_stmt_fetch() calls this function to fetch one row (it's different for buffered, unbuffered and cursor fetch). */ int (*read_row_func)(struct st_mysql_stmt *stmt, unsigned char **row); + /* copy of mysql->affected_rows after statement execution */ + my_ulonglong affected_rows; + my_ulonglong insert_id; /* copy of mysql->insert_id */ unsigned long stmt_id; /* Id for prepared statement */ unsigned long flags; /* i.e. type of cursor to open */ unsigned long prefetch_rows; /* number of rows per one COM_FETCH */ @@ -722,6 +730,7 @@ typedef struct st_mysql_stmt metadata fields when doing mysql_stmt_store_result. */ my_bool update_max_length; + void *extension; } MYSQL_STMT; enum enum_stmt_attr_type diff --git a/include/mysql_com.h b/include/mysql_com.h index ae57e84a696..5850d48fbf5 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -186,25 +186,25 @@ typedef struct st_vio Vio; typedef struct st_net { #if !defined(CHECK_EMBEDDED_DIFFERENCES) || !defined(EMBEDDED_LIBRARY) - Vio* vio; + Vio *vio; unsigned char *buff,*buff_end,*write_pos,*read_pos; my_socket fd; /* For Perl DBI/dbd */ - unsigned long max_packet,max_packet_size; - unsigned int pkt_nr,compress_pkt_nr; - unsigned int write_timeout, read_timeout, retry_count; - int fcntl; - my_bool compress; /* The following variable is set if we are doing several queries in one command ( as in LOAD TABLE ... FROM MASTER ), and do not want to confuse the client with OK at the wrong time */ unsigned long remain_in_buf,length, buf_length, where_b; + unsigned long max_packet,max_packet_size; + unsigned int pkt_nr,compress_pkt_nr; + unsigned int write_timeout, read_timeout, retry_count; + int fcntl; unsigned int *return_status; unsigned char reading_or_writing; char save_char; my_bool no_send_ok; /* For SPs and other things that do multiple stmts */ my_bool no_send_eof; /* For SPs' first version read-only cursors */ + my_bool compress; /* Set if OK packet is already sent, and we do not need to send error messages @@ -215,20 +215,20 @@ typedef struct st_net { queries in cache that have not stored its results yet */ #endif - char last_error[MYSQL_ERRMSG_SIZE], sqlstate[SQLSTATE_LENGTH+1]; - unsigned int last_errno; - unsigned char error; - /* 'query_cache_query' should be accessed only via query cache functions and methods to maintain proper locking. */ unsigned char *query_cache_query; - + unsigned int last_errno; + unsigned char error; my_bool report_error; /* We should report error (we have unreported error) */ my_bool return_errno; + char last_error[MYSQL_ERRMSG_SIZE], sqlstate[SQLSTATE_LENGTH+1]; + void *extension; } NET; + #define packet_error (~(unsigned long) 0) enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, @@ -389,6 +389,7 @@ typedef struct st_udf_args char *maybe_null; /* Set to 1 for all maybe_null args */ char **attributes; /* Pointer to attribute name */ unsigned long *attribute_lengths; /* Length of attribute arguments */ + void *extension; } UDF_ARGS; /* This holds information about the result */ @@ -399,7 +400,9 @@ typedef struct st_udf_init unsigned int decimals; /* for real functions */ unsigned long max_length; /* For string functions */ char *ptr; /* free pointer for function data */ - my_bool const_item; /* 0 if result is independent of arguments */ + /* 0 if result is independent of arguments */ + my_bool const_item; + void *extension; } UDF_INIT; /* Constants when using compression */ From b59217ebbbb9c2869ab914805729b3ca57c976fa Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 30 Jul 2007 11:33:50 +0300 Subject: [PATCH 10/74] Slow query log to file now displays queries with microsecond precission --long-query-time is now given in seconds with microseconds as decimals --min_examined_row_limit added for slow query log long_query_time user variable is now double with 6 decimals Added functions to get time in microseconds Added faster time() functions for system that has gethrtime() (Solaris) We now do less time() calls. Added field->in_read_set() and field->in_write_set() for easier field manipulation by handlers set_var.cc and my_getopt() can now handle DOUBLE variables. All time() calls changed to my_time() my_time() now does retry's if time() call fails. Added debug function for stopping in mysql_admin_table() when tables are locked Some trivial function and struct variable renames to avoid merge errors. Fixed compiler warnings Initialization of some time variables on windows moved to my_init() include/my_getopt.h: Added support for double arguments include/my_sys.h: Fixed wrong type to packfrm() Added new my_time functions include/mysql/plugin.h: Added support for DOUBLE libmysql/CMakeLists.txt: Added new time functions libmysql/Makefile.shared: Added new time functions mysql-test/r/variables.result: Testing of long_query_time mysql-test/t/variables.test: Testing of long_query_time mysys/charset.c: Fixed compiler warnings mysys/default_modify.c: Fixed compiler warnings mysys/hash.c: Fixed compiler warnings mysys/mf_getdate.c: Use my_time() mysys/mf_iocache2.c: Fixed compiler warnings mysys/mf_pack.c: Fixed compiler warnings mysys/mf_path.c: Fixed compiler warnings mysys/my_append.c: Fixed compiler warnings mysys/my_compress.c: Fixed compiler warnings mysys/my_copy.c: Fixed compiler warnings mysys/my_gethwaddr.c: Fixed compiler warnings mysys/my_getopt.c: Added support for double arguments mysys/my_getsystime.c: Added functions to get time in microseconds. Added faster time() functions for system that has gethrtime() (Solaris) Moved windows initialization code to my_init() mysys/my_init.c: Added initializing of variables needed for windows time functions mysys/my_static.c: Added variables needed for windows time functions mysys/my_static.h: Added variables needed for windows time functions mysys/my_thr_init.c: Added THR_LOCK_time, used for faster my_time() mysys/mysys_priv.h: Added THR_LOCK_time, used for faster my_time() mysys/thr_alarm.c: time() -> my_time() sql/event_data_objects.cc: end_time() -> set_current_time() sql/event_queue.cc: end_time() -> set_current_time() sql/event_scheduler.cc: Fixed compiler warnings sql/field.h: Added field->in_read_set() and field->in_write_set() for easier field manipulation by handlers sql/item.h: Added decimal to Item_float(double) sql/item_cmpfunc.h: Added decimal to Item_float(double) sql/item_timefunc.cc: time() -> my_time() sql/item_xmlfunc.cc: Fixed compiler warning sql/lock.cc: lock_time() -> set_time_after_lock() sql/log.cc: Timing in slow query log to file is now done in microseconds Changed some while() loops to for() loops. Fixed indentation time() -> my_time() sql/log.h: Slow query logging is now done based on microseconds sql/log_event.cc: time() -> my_time() Fixed arguments to new Item_float() sql/mysql_priv.h: Fixed compiler warnings Added opt_log_slow_slave_statements sql/mysqld.cc: Added --log_slow_slave_statements and --min_examined_row_limit --long-query-time now takes a double argument with microsecond resolution Don't write shutdown message when using --help Removed not needed \n Thread create time and connect time is now done in microseconds time() -> my_time() Avoid some time() calls sql/net_serv.cc: Fixed compiler warnings sql/parse_file.cc: time() -> my_time() sql/set_var.cc: Added support for DOUBLE variables Added support for variables that are given in seconds with microsecond resolution sql/set_var.h: Added support for variables that are given in seconds with microsecond resolution sql/slave.cc: Allow logging of slave queries to slow query log if 'opt_log_slow_slave_statements' is given time() -> my_time() sql/sql_cache.h: Fixed compiler warning() sql/sql_class.cc: Initialize new THD variables sql/sql_class.h: long_query_time is now in microseconds Added min_examined_row_limit Reordered some THD elements for higher efficency Added timers in microseconds (connect_utime, thr_create_utime, start_utime and utime_after_lock) Start of query is now recorded both in seconds and in microseconds. Following renames was made for more clarity and avoid merge problems from earlier versions: connect_time -> connect_utime thr_create_time -> thr_create_utime end_time() -> set_current_time() lock_time() -> set_time_after_lock() Added THD::start_utime, which is start of query in microseconds from some arbitary time Added function THD::current_utime() Removed safe_time() as retry's are handled in my_time() sql/sql_connect.cc: User resources are now using microsecond resolution sql/sql_insert.cc: end_time() -> set_current_time() sql-common/client.c: time() -> my_time() sql/sql_parse.cc: Testing if we should print to slow_query_log() is now done with microsecond precission. If min_examined_row_limit is given, only log queries to slow query log that has examined more rows than this. sql/sql_select.cc: Simplify code now that Item_float() takes decimals as argument sql/sql_show.cc: time() -> my_time() Added support for SYS_DOUBLE sql/sql_table.cc: Added debug function for stopping in mysql_admin_table() when tables are locked sql/structs.h: intime -> reset_utime --- include/my_getopt.h | 1 + include/my_sys.h | 6 +- include/mysql/plugin.h | 2 +- libmysql/CMakeLists.txt | 2 +- libmysql/Makefile.shared | 2 +- mysql-test/r/variables.result | 9 +- mysql-test/t/variables.test | 5 +- mysys/charset.c | 8 +- mysys/default_modify.c | 2 +- mysys/hash.c | 20 ++-- mysys/mf_getdate.c | 2 +- mysys/mf_iocache2.c | 14 +-- mysys/mf_pack.c | 4 +- mysys/mf_path.c | 2 +- mysys/my_append.c | 15 +-- mysys/my_compress.c | 13 ++- mysys/my_copy.c | 6 +- mysys/my_gethwaddr.c | 2 +- mysys/my_getopt.c | 43 +++++++- mysys/my_getsystime.c | 186 ++++++++++++++++++++++++++++++---- mysys/my_init.c | 22 ++++ mysys/my_static.c | 5 + mysys/my_static.h | 2 + mysys/my_thr_init.c | 4 +- mysys/mysys_priv.h | 2 +- mysys/thr_alarm.c | 12 +-- sql-common/client.c | 4 +- sql/event_data_objects.cc | 2 +- sql/event_queue.cc | 2 +- sql/event_scheduler.cc | 3 +- sql/field.h | 2 + sql/item.h | 7 +- sql/item_cmpfunc.h | 5 +- sql/item_timefunc.cc | 2 +- sql/item_xmlfunc.cc | 2 +- sql/lock.cc | 2 +- sql/log.cc | 99 +++++++++--------- sql/log.h | 16 +-- sql/log_event.cc | 8 +- sql/mysql_priv.h | 5 +- sql/mysqld.cc | 59 +++++++---- sql/net_serv.cc | 2 +- sql/parse_file.cc | 2 +- sql/set_var.cc | 69 ++++++++++++- sql/set_var.h | 28 ++++- sql/slave.cc | 7 +- sql/sql_cache.h | 1 + sql/sql_class.cc | 3 +- sql/sql_class.h | 65 ++++++------ sql/sql_connect.cc | 14 +-- sql/sql_insert.cc | 2 +- sql/sql_parse.cc | 20 ++-- sql/sql_select.cc | 8 +- sql/sql_show.cc | 15 ++- sql/sql_table.cc | 15 +++ sql/structs.h | 10 +- 56 files changed, 625 insertions(+), 245 deletions(-) diff --git a/include/my_getopt.h b/include/my_getopt.h index 115abf00618..c74f3ed672e 100644 --- a/include/my_getopt.h +++ b/include/my_getopt.h @@ -31,6 +31,7 @@ C_MODE_START #define GET_DISABLED 11 #define GET_ENUM 12 #define GET_SET 13 +#define GET_DOUBLE 14 #define GET_ASK_ADDR 128 #define GET_TYPE_MASK 127 diff --git a/include/my_sys.h b/include/my_sys.h index fb949842e48..c452bd21e15 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -833,7 +833,7 @@ extern my_bool my_compress(uchar *, size_t *, size_t *); extern my_bool my_uncompress(uchar *, size_t , size_t *); extern uchar *my_compress_alloc(const uchar *packet, size_t *len, size_t *complen); -extern int packfrm(const uchar *, size_t, uchar **, size_t *); +extern int packfrm(uchar *, size_t, uchar **, size_t *); extern int unpackfrm(uchar **, size_t *, const uchar *); extern ha_checksum my_checksum(ha_checksum crc, const uchar *mem, @@ -846,7 +846,11 @@ extern void my_sleep(ulong m_seconds); extern uint my_set_max_open_files(uint files); void my_free_open_file_info(void); +extern time_t my_time(myf flags); extern ulonglong my_getsystime(void); +extern ulonglong my_micro_time(); +extern ulonglong my_micro_time_and_time(time_t *time_arg); +time_t my_time_possible_from_micro(ulonglong microtime); extern my_bool my_gethwaddr(uchar *to); extern int my_getncpus(); diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index b87fcc60692..541fa7dfbe6 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -110,7 +110,7 @@ enum enum_mysql_show_type { SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG, SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR, - SHOW_ARRAY, SHOW_FUNC + SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE }; struct st_mysql_show_var { diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 7d4dcc1e919..c1585e10e25 100644 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -63,7 +63,7 @@ ADD_LIBRARY(libmysql SHARED dll.c libmysql.def ../strings/strmov.c ../strings/strnlen.c ../strings/strnmov.c ../strings/strtod.c ../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c ../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c - ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c) + ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c ../mysys/my_getsystime.c) ADD_DEPENDENCIES(libmysql dbug vio mysys strings GenError zlib yassl taocrypt) TARGET_LINK_LIBRARIES(libmysql mysys strings wsock32) diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared index c24c6ab52db..3a2559921f9 100644 --- a/libmysql/Makefile.shared +++ b/libmysql/Makefile.shared @@ -68,7 +68,7 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \ mf_iocache2.lo my_seek.lo my_sleep.lo \ my_pread.lo mf_cache.lo md5.lo sha1.lo \ my_getopt.lo my_gethostbyname.lo my_port.lo \ - my_rename.lo my_chsize.lo + my_rename.lo my_chsize.lo my_getsystime.lo sqlobjects = net.lo sql_cmn_objects = pack.lo client.lo my_time.lo diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index ff43993cfdb..e6d09306fcb 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -444,7 +444,14 @@ set interactive_timeout=100; set join_buffer_size=100; set last_insert_id=1; set global local_infile=1; -set long_query_time=100; +set long_query_time=0.000001; +select @@long_query_time; +@@long_query_time +0.000001 +set long_query_time=100.000001; +select @@long_query_time; +@@long_query_time +100.000001 set low_priority_updates=1; set max_allowed_packet=100; set global max_binlog_cache_size=100; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index efa2ce4a27c..8f55d83c3de 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -268,7 +268,10 @@ set interactive_timeout=100; set join_buffer_size=100; set last_insert_id=1; set global local_infile=1; -set long_query_time=100; +set long_query_time=0.000001; +select @@long_query_time; +set long_query_time=100.000001; +select @@long_query_time; set low_priority_updates=1; set max_allowed_packet=100; set global max_binlog_cache_size=100; diff --git a/mysys/charset.c b/mysys/charset.c index 1c81e480404..cc1a238f281 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -323,14 +323,14 @@ static int charset_initialized=0; static my_bool my_read_charset_file(const char *filename, myf myflags) { - char *buf; + uchar *buf; int fd; uint len, tmp_len; MY_STAT stat_info; if (!my_stat(filename, &stat_info, MYF(myflags)) || ((len= (uint)stat_info.st_size) > MY_MAX_ALLOWED_BUF) || - !(buf= (char *)my_malloc(len,myflags))) + !(buf= (uchar*) my_malloc(len,myflags))) return TRUE; if ((fd=my_open(filename,O_RDONLY,myflags)) < 0) @@ -340,7 +340,7 @@ static my_bool my_read_charset_file(const char *filename, myf myflags) if (tmp_len != len) goto error; - if (my_parse_charset_xml(buf,len,add_collation)) + if (my_parse_charset_xml((char*) buf,len,add_collation)) { #ifdef NOT_YET printf("ERROR at line %d pos %d '%s'\n", @@ -350,7 +350,7 @@ static my_bool my_read_charset_file(const char *filename, myf myflags) #endif } - my_free(buf, myflags); + my_free(buf, myflags); return FALSE; error: diff --git a/mysys/default_modify.c b/mysys/default_modify.c index b2a43f511b9..78f6105b071 100644 --- a/mysys/default_modify.c +++ b/mysys/default_modify.c @@ -218,7 +218,7 @@ int modify_defaults_file(const char *file_location, const char *option, if (my_chsize(fileno(cnf_file), (my_off_t) (dst_ptr - file_buffer), 0, MYF(MY_WME)) || my_fseek(cnf_file, 0, MY_SEEK_SET, MYF(0)) || - my_fwrite(cnf_file, file_buffer, (size_t) (dst_ptr - file_buffer), + my_fwrite(cnf_file, (uchar*) file_buffer, (size_t) (dst_ptr - file_buffer), MYF(MY_NABP))) goto err; } diff --git a/mysys/hash.c b/mysys/hash.c index 47ddc5aa97d..4532b06b533 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -137,7 +137,7 @@ void my_hash_reset(HASH *hash) DBUG_VOID_RETURN; } - /* some helper functions */ +/* some helper functions */ /* This function is char* instead of uchar* as HPUX11 compiler can't @@ -149,9 +149,9 @@ hash_key(const HASH *hash, const uchar *record, size_t *length, my_bool first) { if (hash->get_key) - return (*hash->get_key)(record,length,first); + return (char*) (*hash->get_key)(record,length,first); *length=hash->key_length; - return (uchar*) record+hash->key_offset; + return (char*) record+hash->key_offset; } /* Calculate pos according to keys */ @@ -313,12 +313,14 @@ my_bool my_hash_insert(HASH *info,const uchar *record) uchar *ptr_to_rec,*ptr_to_rec2; HASH_LINK *data,*empty,*gpos,*gpos2,*pos; - LINT_INIT(gpos); LINT_INIT(gpos2); - LINT_INIT(ptr_to_rec); LINT_INIT(ptr_to_rec2); + LINT_INIT(gpos); + LINT_INIT(gpos2); + LINT_INIT(ptr_to_rec); + LINT_INIT(ptr_to_rec2); if (HASH_UNIQUE & info->flags) { - char *key= (char*) hash_key(info, record, &idx, 1); + uchar *key= (uchar*) hash_key(info, record, &idx, 1); if (hash_search(info, key, idx)) return(TRUE); /* Duplicate entry */ } @@ -544,14 +546,16 @@ my_bool hash_update(HASH *hash, uchar *record, uchar *old_key, if (HASH_UNIQUE & hash->flags) { HASH_SEARCH_STATE state; - char *found, *new_key= hash_key(hash, record, &idx, 1); + uchar *found, *new_key= (uchar*) hash_key(hash, record, &idx, 1); if ((found= hash_first(hash, new_key, idx, &state))) + { do { - if (found != (char*) record) + if (found != record) DBUG_RETURN(1); /* Duplicate entry */ } while ((found= hash_next(hash, new_key, idx, &state))); + } } data=dynamic_element(&hash->array,0,HASH_LINK*); diff --git a/mysys/mf_getdate.c b/mysys/mf_getdate.c index 2f08027a477..3a8e1be6a0b 100644 --- a/mysys/mf_getdate.c +++ b/mysys/mf_getdate.c @@ -42,7 +42,7 @@ void get_date(register char * to, int flag, time_t date) struct tm tm_tmp; #endif - skr=date ? (time_t) date : time((time_t*) 0); + skr=date ? (time_t) date : my_time(0); #if defined(HAVE_LOCALTIME_R) && defined(_REENTRANT) if (flag & GETDATE_GMT) localtime_r(&skr,&tm_tmp); diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c index 8a5b91661c4..87ea995f518 100644 --- a/mysys/mf_iocache2.c +++ b/mysys/mf_iocache2.c @@ -246,7 +246,7 @@ size_t my_b_gets(IO_CACHE *info, char *to, size_t max_length) for (;;) { - char *pos,*end; + uchar *pos, *end; if (length > max_length) length=max_length; for (pos=info->read_pos,end=pos+length ; pos < end ;) @@ -323,7 +323,7 @@ size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) length= (size_t) (fmt - start); out_length+=length; - if (my_b_write(info, start, length)) + if (my_b_write(info, (const uchar*) start, length)) goto err; if (*fmt == '\0') /* End of format */ @@ -378,14 +378,14 @@ size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) size_t length2 = strlen(par); /* TODO: implement minimum width and precision */ out_length+= length2; - if (my_b_write(info, par, length2)) + if (my_b_write(info, (uchar*) par, length2)) goto err; } else if (*fmt == 'b') /* Sized buffer parameter, only precision makes sense */ { char *par = va_arg(args, char *); out_length+= precision; - if (my_b_write(info, par, precision)) + if (my_b_write(info, (uchar*) par, precision)) goto err; } else if (*fmt == 'd' || *fmt == 'u') /* Integer parameter */ @@ -400,7 +400,7 @@ size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) else length2= (size_t) (int10_to_str((long) (uint) iarg,buff,10)- buff); out_length+= length2; - if (my_b_write(info, buff, length2)) + if (my_b_write(info, (uchar*) buff, length2)) goto err; } else if ((*fmt == 'l' && fmt[1] == 'd') || fmt[1] == 'u') @@ -416,13 +416,13 @@ size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) else length2= (size_t) (int10_to_str(iarg,buff,10)- buff); out_length+= length2; - if (my_b_write(info, buff, length2)) + if (my_b_write(info, (uchar*) buff, length2)) goto err; } else { /* %% or unknown code */ - if (my_b_write(info, backtrack, fmt-backtrack)) + if (my_b_write(info, (uchar*) backtrack, (size_t) (fmt-backtrack))) goto err; out_length+= fmt-backtrack; } diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c index 99c0c959d94..a31b9595c85 100644 --- a/mysys/mf_pack.c +++ b/mysys/mf_pack.c @@ -56,7 +56,7 @@ void pack_dirname(char * to, const char *from) (buff_length == d_length && !bcmp(buff,start,d_length))) && *start != FN_LIBCHAR && *start) { /* Put current dir before */ - bchange(to,d_length,buff,buff_length,strlen(to)+1); + bchange((uchar*) to, d_length, (uchar*) buff, buff_length, strlen(to)+1); } } @@ -328,7 +328,7 @@ size_t unpack_dirname(char * to, const char *from) if (buff+h_length < suffix) bmove(buff+h_length,suffix,length); else - bmove_upp(buff+h_length+length,suffix+length,length); + bmove_upp((uchar*) buff+h_length+length, (uchar*) suffix+length, length); bmove(buff,tilde_expansion,h_length); } } diff --git a/mysys/mf_path.c b/mysys/mf_path.c index 7baded9d715..73e73cb7f76 100644 --- a/mysys/mf_path.c +++ b/mysys/mf_path.c @@ -46,7 +46,7 @@ char * my_path(char * to, const char *progname, if (!test_if_hard_path(to)) { if (!my_getwd(curr_dir,FN_REFLEN,MYF(0))) - bchange(to,0,curr_dir, (uint) strlen(curr_dir), (uint) strlen(to)+1); + bchange((uchar*) to, 0, (uchar*) curr_dir, strlen(curr_dir), strlen(to)+1); } } else diff --git a/mysys/my_append.c b/mysys/my_append.c index ddd3c91e832..35881a959d5 100644 --- a/mysys/my_append.c +++ b/mysys/my_append.c @@ -27,21 +27,22 @@ struct utimbuf { }; #endif - /* Append a file to another */ +/* + Append a file to another + + NOTES + Don't set MY_FNABP or MY_NABP bits on when calling this function +*/ int my_append(const char *from, const char *to, myf MyFlags) - - - /* Dont set MY_FNABP or MY_NABP bits on - when calling this funktion */ { uint Count; File from_file,to_file; - char buff[IO_SIZE]; + uchar buff[IO_SIZE]; DBUG_ENTER("my_append"); DBUG_PRINT("my",("from %s to %s MyFlags %d", from, to, MyFlags)); - from_file=to_file= -1; + from_file= to_file= -1; if ((from_file=my_open(from,O_RDONLY,MyFlags)) >= 0) { diff --git a/mysys/my_compress.c b/mysys/my_compress.c index d495a1c1c6d..bc9f8317487 100644 --- a/mysys/my_compress.c +++ b/mysys/my_compress.c @@ -154,17 +154,20 @@ my_bool my_uncompress(uchar *packet, size_t len, size_t *complen) SYNOPSIS packfrm() - data Data reference to frm file data + data Data reference to frm file data. len Length of frm file data out:pack_data Reference to the pointer to the packed frm data out:pack_len Length of packed frm file data + NOTES + data is replaced with compressed content + RETURN VALUES 0 Success >0 Failure */ -int packfrm(const uchar *data, size_t len, +int packfrm(uchar *data, size_t len, uchar **pack_data, size_t *pack_len) { int error; @@ -178,8 +181,8 @@ int packfrm(const uchar *data, size_t len, if (my_compress((uchar*)data, &org_len, &comp_len)) goto err; - DBUG_PRINT("info", ("org_len: %lu comp_len: %lu", org_len, comp_len)); - DBUG_DUMP("compressed", (char*)data, org_len); + DBUG_PRINT("info", ("org_len: %lu comp_len: %lu", (ulong) org_len, (ulong) comp_len)); + DBUG_DUMP("compressed", data, org_len); error= 2; blob_len= BLOB_HEADER + org_len; @@ -235,7 +238,7 @@ int unpackfrm(uchar **unpack_data, size_t *unpack_len, complen= uint4korr(pack_data+8); DBUG_PRINT("blob",("ver: %lu complen: %lu orglen: %lu", - ver, complen, orglen)); + ver, (ulong) complen, (ulong) orglen)); DBUG_DUMP("blob->data", pack_data + BLOB_HEADER, complen); if (ver != 1) diff --git a/mysys/my_copy.c b/mysys/my_copy.c index 3f8b0695a25..cd741b1eb52 100644 --- a/mysys/my_copy.c +++ b/mysys/my_copy.c @@ -54,7 +54,7 @@ int my_copy(const char *from, const char *to, myf MyFlags) my_bool new_file_stat= 0; /* 1 if we could stat "to" */ int create_flag; File from_file,to_file; - char buff[IO_SIZE]; + uchar buff[IO_SIZE]; MY_STAT stat_buff,new_stat_buff; DBUG_ENTER("my_copy"); DBUG_PRINT("my",("from %s to %s MyFlags %d", from, to, MyFlags)); @@ -80,10 +80,12 @@ int my_copy(const char *from, const char *to, myf MyFlags) MyFlags)) < 0) goto err; - while ((Count=my_read(from_file,buff,IO_SIZE,MyFlags)) != 0) + while ((Count=my_read(from_file, buff, sizeof(buff), MyFlags)) != 0) + { if (Count == (uint) -1 || my_write(to_file,buff,Count,MYF(MyFlags | MY_NABP))) goto err; + } if (my_close(from_file,MyFlags) | my_close(to_file,MyFlags)) DBUG_RETURN(-1); /* Error on close */ diff --git a/mysys/my_gethwaddr.c b/mysys/my_gethwaddr.c index 01abc02058b..845b5aa4152 100644 --- a/mysys/my_gethwaddr.c +++ b/mysys/my_gethwaddr.c @@ -19,7 +19,7 @@ #include "mysys_priv.h" #include -#ifndef MAIN +#if !defined(__FreeBSD__) || defined(__linux__) static my_bool memcpy_and_test(uchar *to, uchar *from, uint len) { uint i, res=1; diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 32a5452e451..3a5b130e067 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -32,6 +32,7 @@ my_bool getopt_compare_strings(const char *s, static longlong getopt_ll(char *arg, const struct my_option *optp, int *err); static ulonglong getopt_ull(char *arg, const struct my_option *optp, int *err); +static double getopt_double(char *arg, const struct my_option *optp, int *err); static void init_variables(const struct my_option *options); static int setval(const struct my_option *opts, uchar* *value, char *argument, my_bool set_maximum_value); @@ -611,6 +612,9 @@ static int setval(const struct my_option *opts, uchar* *value, char *argument, case GET_ULL: *((ulonglong*) result_pos)= getopt_ull(argument, opts, &err); break; + case GET_DOUBLE: + *((double*) result_pos)= getopt_double(argument, opts, &err); + break; case GET_STR: *((char**) result_pos)= argument; break; @@ -720,7 +724,7 @@ my_bool getopt_compare_strings(register const char *s, register const char *t, be k|K for kilo, m|M for mega or g|G for giga. */ -static longlong eval_num_suffix (char *argument, int *error, char *option_name) +static longlong eval_num_suffix(char *argument, int *error, char *option_name) { char *endchar; longlong num; @@ -801,6 +805,37 @@ ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp) } +/* + Get double value withing ranges + + Evaluates and returns the value that user gave as an argument to a variable. + + RETURN + decimal value of arg + + In case of an error, prints an error message and sets *err to + EXIT_ARGUMENT_INVALID. Otherwise err is not touched +*/ + +static double getopt_double(char *arg, const struct my_option *optp, int *err) +{ + double num; + int error; + char *end= arg + 1000; /* Big enough as *arg is \0 terminated */ + num= my_strtod(arg, &end, &error); + if (end[0] != 0 || error) + { + fprintf(stderr, + "%s: ERROR: Invalid decimal value for option '%s'\n", + my_progname, optp->name); + *err= EXIT_ARGUMENT_INVALID; + return 0.0; + } + if (optp->max_value && num > (double) optp->max_value) + num= (double) optp->max_value; + return max(num, (double) optp->min_value); +} + /* Init one value to it's default values @@ -838,6 +873,9 @@ static void init_one_value(const struct my_option *option, uchar* *variable, case GET_SET: *((ulonglong*) variable)= (ulonglong) value; break; + case GET_DOUBLE: + *((double*) variable)= (double) value; + break; case GET_STR: /* Do not clear variable value if it has no default value. @@ -1052,6 +1090,9 @@ void my_print_variables(const struct my_option *options) longlong2str(*((ulonglong*) value), buff, 10); printf("%s\n", buff); break; + case GET_DOUBLE: + printf("%g\n", *(double*) value); + break; default: printf("(Disabled)\n"); break; diff --git a/mysys/my_getsystime.c b/mysys/my_getsystime.c index 2fd7eed7778..17ba1232d7a 100644 --- a/mysys/my_getsystime.c +++ b/mysys/my_getsystime.c @@ -29,28 +29,17 @@ ulonglong my_getsystime() clock_gettime(CLOCK_REALTIME, &tp); return (ulonglong)tp.tv_sec*10000000+(ulonglong)tp.tv_nsec/100; #elif defined(__WIN__) -#define OFFSET_TO_EPOC ((__int64) 134774 * 24 * 60 * 60 * 1000 * 1000 * 10) - static __int64 offset=0, freq; LARGE_INTEGER t_cnt; - if (!offset) + struct timeval tv; + if (query_performance_frequency) { - /* strictly speaking there should be a mutex to protect - initialization section. But my_getsystime() is called from - UUID() code, and UUID() calls are serialized with a mutex anyway - */ - LARGE_INTEGER li; - FILETIME ft; - GetSystemTimeAsFileTime(&ft); - li.LowPart=ft.dwLowDateTime; - li.HighPart=ft.dwHighDateTime; - offset=li.QuadPart-OFFSET_TO_EPOC; - QueryPerformanceFrequency(&li); - freq=li.QuadPart; QueryPerformanceCounter(&t_cnt); - offset-=t_cnt.QuadPart/freq*10000000+t_cnt.QuadPart%freq*10000000/freq; + return (t_cnt.QuadPart / query_performance_frequency * 10000000+ + t_cnt.QuadPart % query_performance_frequency * 10000000/ + query_performance_frequency+query_performance_offset); } - QueryPerformanceCounter(&t_cnt); - return t_cnt.QuadPart/freq*10000000+t_cnt.QuadPart%freq*10000000/freq+offset; + gettimeofday(&tv,NULL); + return (ulonglong)tv.tv_sec*10000000+(ulonglong)tv.tv_usec*10; #elif defined(__NETWARE__) NXTime_t tm; NXGetTime(NX_SINCE_1970, NX_NSECONDS, &tm); @@ -62,3 +51,164 @@ ulonglong my_getsystime() return (ulonglong)tv.tv_sec*10000000+(ulonglong)tv.tv_usec*10; #endif } + + +/* + Return current time + + SYNOPSIS + my_time() + flags If MY_WME is set, write error if time call fails + +*/ + +#define DELTA_FOR_SECONDS LL(500000000) /* Half a second */ + +time_t my_time(myf flags __attribute__((unused))) +{ +#ifdef HAVE_GETHRTIME + static hrtime_t prev_gethrtime= 0; + static time_t cur_time= 0; + + hrtime_t cur_gethrtime; + pthread_mutex_lock(&THR_LOCK_time); + cur_gethrtime= gethrtime(); + if ((prev_gethrtime - cur_gethrtime) > DELTA_FOR_SECONDS) + { + cur_time= time(0); + prev_gethrtime= cur_gethrtime; + } + pthread_mutex_unlock(&THR_LOCK_time); + return cur_time; +#else + time_t t; + /* The following loop is here beacuse time() may fail on some systems */ + while ((t= time(0)) == (time_t) -1) + { + if (flags & MY_WME) + fprintf(stderr, "%s: Warning: time() call failed\n", my_progname); + } + return t; +#endif +} + + +/* + Return time in micro seconds + + SYNOPSIS + my_micro_time() + + NOTES + This function is to be used to measure performance in micro seconds. + As it's not defined whats the start time for the clock, this function + us only useful to measure time between two moments. + + For windows platforms we need the frequency value of the CUP. This is + initalized in my_init.c through QueryPerformanceFrequency(). + + If Windows platform doesn't support QueryPerformanceFrequency() we will + obtain the time via GetClockCount, which only supports milliseconds. + + RETURN + Value in microseconds from some undefined point in time +*/ + +ulonglong my_micro_time() +{ + ulonglong newtime; +#if defined(__WIN__) + if (query_performance_frequency) + { + QueryPerformanceCounter(&newtime); + newtime/= (query_performance_frequency * 1000000); + } + else + newtime= (GetTickCount() * 1000; /* GetTickCount only returns milliseconds */ +#elif defined(HAVE_GETHRTIME) + return gethrtime()/1000; +#else + struct timeval t; + /* The following loop is here because gettimeofday may fail on some systems */ + while (gettimeofday(&t, NULL) != 0) + {} + newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec; +#endif /* defined(__WIN__) */ + return newtime; +} + + +/* + Return time in seconds and timer in microseconds + + SYNOPSIS + my_micro_time_and_time() + time_arg Will be set to seconds since epoch (00:00:00 UTC, January 1, + 1970) + + NOTES + This function is to be useful when we need both the time and microtime. + For example in MySQL this is used to get the query time start of a query and + to measure the time of a query (for the slow query log) + + IMPLEMENTATION + Same as my_micro_time() + + RETURN + Value in microseconds from some undefined point in time +*/ + +ulonglong my_micro_time_and_time(time_t *time_arg) +{ + ulonglong newtime; +#if defined(__WIN__) + if (query_performance_frequency) + { + QueryPerformanceCounter((LARGE_INTEGER *) &newtime); + newtime/= (query_performance_frequency * 1000000); + } + else + newtime= (GetTickCount() * 1000; /* GetTickCount only returns milliseconds */ + (void) time(time_arg); +#else + struct timeval t; + /* The following loop is here because gettimeofday may fail on some systems */ + while (gettimeofday(&t, NULL) != 0) + {} + *time_arg= t.tv_sec; + newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec; +#endif /* defined(__WIN__) */ + return newtime; +} + + +/* + Returns current time + + SYNOPSIS + my_time_possible_from_micro() + microtime Value from very recent my_micro_time() + + NOTES + This function returns the current time. The microtime argument is only used + if my_micro_time() uses a function that can safely be converted to the current + time. + + RETURN + current time +*/ + +time_t my_time_possible_from_micro(ulonglong microtime __attribute__((unused))) +{ +#if defined(__WIN__) + time_t t; + while ((t= time(0)) == (time_t) -1) + {} + return t; +#elif defined(HAVE_GETHRTIME) + return my_time(0); /* Cached time */ +#else + return (time_t) (microtime / 1000000); +#endif /* defined(__WIN__) */ +} + diff --git a/mysys/my_init.c b/mysys/my_init.c index c1337205eb4..8281d7ced99 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -371,6 +371,28 @@ static void my_win_init(void) /* chiude la chiave */ RegCloseKey(hSoftMysql) ; + + /* The following is used by time functions */ +#define OFFSET_TO_EPOC ((__int64) 134774 * 24 * 60 * 60 * 1000 * 1000 * 10) +#define MS 10000000 + { + FILETIME ft; + LARGE_INTEGER li, t_cnt; + DBUG_ASSERT(sizeof(LARGE_INTEGER) == sizeof(query_performance_frequency)); + if (QueryPerformanceFrequency((LARGE_INTEGER *)&query_performance_frequency)) + query_performance_frequency= 0; + else + { + GetSystemTimeAsFileTime(&ft); + li.LowPart= ft.dwLowDateTime; + li.HighPart= ft.dwHighDateTime; + query_performance_offset= li.QuadPart-OFFSET_TO_EPOC; + QueryPerformanceCounter(&t_cnt); + query_performance_offset-= (t_cnt.QuadPart / query_performance_frequency * MS + + t_cnt.QuadPart % query_performance_frequency * MS / + query_performance_frequency); + } + } DBUG_VOID_RETURN ; } diff --git a/mysys/my_static.c b/mysys/my_static.c index 472cf3b5084..92c959c4c6c 100644 --- a/mysys/my_static.c +++ b/mysys/my_static.c @@ -93,6 +93,11 @@ int (*error_handler_hook)(uint error,const char *str,myf MyFlags)= int (*fatal_error_handler_hook)(uint error,const char *str,myf MyFlags)= my_message_no_curses; +#ifdef __WIN__ +/* from my_getsystime.c */ +ulonglong query_performance_frequency, query_performance_offset; +#endif + /* How to disable options */ my_bool NEAR my_disable_locking=0; my_bool NEAR my_disable_async_io=0; diff --git a/mysys/my_static.h b/mysys/my_static.h index 66e6ea1c280..0eca196c1c9 100644 --- a/mysys/my_static.h +++ b/mysys/my_static.h @@ -66,6 +66,8 @@ extern struct st_irem *sf_malloc_root; extern struct st_my_file_info my_file_info_default[MY_NFILE]; +extern ulonglong query_performance_frequency, query_performance_offset; + #if defined(THREAD) && !defined(__WIN__) extern sigset_t my_signals; /* signals blocked by mf_brkhant */ #endif diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index cc33ac3f21c..8b935c895c8 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -30,7 +30,7 @@ pthread_key(struct st_my_thread_var, THR_KEY_mysys); #endif /* USE_TLS */ pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open, THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_myisam,THR_LOCK_heap, - THR_LOCK_net, THR_LOCK_charset, THR_LOCK_threads; + THR_LOCK_net, THR_LOCK_charset, THR_LOCK_threads, THR_LOCK_time; pthread_cond_t THR_COND_threads; uint THR_thread_count= 0; uint my_thread_end_wait_time= 5; @@ -146,6 +146,7 @@ my_bool my_thread_global_init(void) pthread_mutex_init(&THR_LOCK_net,MY_MUTEX_INIT_FAST); pthread_mutex_init(&THR_LOCK_charset,MY_MUTEX_INIT_FAST); pthread_mutex_init(&THR_LOCK_threads,MY_MUTEX_INIT_FAST); + pthread_mutex_init(&THR_LOCK_time,MY_MUTEX_INIT_FAST); pthread_cond_init(&THR_COND_threads, NULL); #if defined( __WIN__) || defined(OS2) win_pthread_init(); @@ -202,6 +203,7 @@ void my_thread_global_end(void) pthread_mutex_destroy(&THR_LOCK_myisam); pthread_mutex_destroy(&THR_LOCK_heap); pthread_mutex_destroy(&THR_LOCK_net); + pthread_mutex_destroy(&THR_LOCK_time); pthread_mutex_destroy(&THR_LOCK_charset); if (all_threads_killed) { diff --git a/mysys/mysys_priv.h b/mysys/mysys_priv.h index 709cfed969a..6e0959ae08c 100644 --- a/mysys/mysys_priv.h +++ b/mysys/mysys_priv.h @@ -28,7 +28,7 @@ #include extern pthread_mutex_t THR_LOCK_malloc, THR_LOCK_open, THR_LOCK_keycache; extern pthread_mutex_t THR_LOCK_lock, THR_LOCK_isam, THR_LOCK_net; -extern pthread_mutex_t THR_LOCK_charset; +extern pthread_mutex_t THR_LOCK_charset, THR_LOCK_time; #else #include #endif diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index 81093be3678..2934e724724 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -157,7 +157,7 @@ my_bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm_data) DBUG_ENTER("thr_alarm"); DBUG_PRINT("enter",("thread: %s sec: %d",my_thread_name(),sec)); - now=(ulong) time((time_t*) 0); + now=(ulong) my_time(0); pthread_sigmask(SIG_BLOCK,&full_signal_set,&old_mask); pthread_mutex_lock(&LOCK_alarm); /* Lock from threads & alarms */ if (alarm_aborted > 0) @@ -351,7 +351,7 @@ static sig_handler process_alarm_part2(int sig __attribute__((unused))) } else { - ulong now=(ulong) time((time_t*) 0); + ulong now=(ulong) my_time(0); ulong next=now+10-(now%10); while ((alarm_data=(ALARM*) queue_top(&alarm_queue))->expire_time <= now) { @@ -480,7 +480,7 @@ void thr_alarm_info(ALARM_INFO *info) info->max_used_alarms= max_used_alarms; if ((info->active_alarms= alarm_queue.elements)) { - ulong now=(ulong) time((time_t*) 0); + ulong now=(ulong) my_time(0); long time_diff; ALARM *alarm_data= (ALARM*) queue_top(&alarm_queue); time_diff= (long) (alarm_data->expire_time - now); @@ -528,7 +528,7 @@ static void *alarm_handler(void *arg __attribute__((unused))) { if (alarm_queue.elements) { - ulong sleep_time,now=time((time_t*) 0); + ulong sleep_time,now= my_time(0); if (alarm_aborted) sleep_time=now+1; else @@ -685,7 +685,7 @@ static void *test_thread(void *arg) for (i=1 ; i <= 10 ; i++) { wait_time=param ? 11-i : i; - start_time=time((time_t*) 0); + start_time= my_time(0); if (thr_alarm(&got_alarm,wait_time,0)) { printf("Thread: %s Alarms aborted\n",my_thread_name()); @@ -747,7 +747,7 @@ static void *test_thread(void *arg) } } printf("Thread: %s Slept for %d (%d) sec\n",my_thread_name(), - (int) (time((time_t*) 0)-start_time), wait_time); fflush(stdout); + (int) (my_time(0)-start_time), wait_time); fflush(stdout); thr_end_alarm(&got_alarm); fflush(stdout); } diff --git a/sql-common/client.c b/sql-common/client.c index 6d63c457390..75b1c9747a5 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -232,7 +232,7 @@ static int wait_for_data(my_socket fd, uint timeout) implementations of select that don't adjust tv upon failure to reflect the time remaining */ - start_time = time(NULL); + start_time= my_time(0); for (;;) { tv.tv_sec = (long) timeout; @@ -246,7 +246,7 @@ static int wait_for_data(my_socket fd, uint timeout) #endif if (res == 0) /* timeout */ return -1; - now_time=time(NULL); + now_time= my_time(0); timeout-= (uint) (now_time - start_time); if (errno != EINTR || (int) timeout <= 0) return -1; diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc index 7b58c10079a..17924ee0e42 100644 --- a/sql/event_data_objects.cc +++ b/sql/event_data_objects.cc @@ -1644,7 +1644,7 @@ err: void Event_queue_element::mark_last_executed(THD *thd) { - thd->end_time(); + thd->set_current_time(); last_executed= (my_time_t) thd->query_start(); last_executed_changed= TRUE; diff --git a/sql/event_queue.cc b/sql/event_queue.cc index 634cc764d74..71dd6a0833f 100644 --- a/sql/event_queue.cc +++ b/sql/event_queue.cc @@ -550,7 +550,7 @@ Event_queue::get_top_for_execution_if_time(THD *thd, top= ((Event_queue_element*) queue_element(&queue, 0)); - thd->end_time(); /* Get current time */ + thd->set_current_time(); /* Get current time */ next_activation_at= top->execute_at; if (next_activation_at > thd->query_start()) diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc index c552b22e942..3092521fd4c 100644 --- a/sql/event_scheduler.cc +++ b/sql/event_scheduler.cc @@ -283,8 +283,7 @@ Event_worker_thread::run(THD *thd, Event_queue_element_for_exec *event) res= post_init_event_thread(thd); DBUG_ENTER("Event_worker_thread::run"); - DBUG_PRINT("info", ("Time is %ld, THD: 0x%lx", - (long) time(NULL), (long) thd)); + DBUG_PRINT("info", ("Time is %ld, THD: 0x%lx", (long) my_time(0), (long) thd)); if (res) goto end; diff --git a/sql/field.h b/sql/field.h index 8bf087c7ebd..2782042e911 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1394,6 +1394,8 @@ public: { return charset() == &my_charset_bin ? FALSE : TRUE; } uint32 max_display_length(); uint is_equal(Create_field *new_field); + inline bool in_read_set() { return bitmap_is_set(table->read_set, field_index); } + inline bool in_write_set() { return bitmap_is_set(table->write_set, field_index); } }; diff --git a/sql/item.h b/sql/item.h index 432da6c3a1c..c15b74a265d 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1712,8 +1712,11 @@ public: max_length=length; fixed= 1; } - Item_float(double value_par) :presentation(0), value(value_par) { fixed= 1; } - + Item_float(double value_par, uint decimal_par) :presentation(0), value(value_par) + { + decimals= (uint8) decimal_par; + fixed= 1; + } int save_in_field(Field *field, bool no_conversions); enum Type type() const { return REAL_ITEM; } enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; } diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index fcbacc32d88..47914c59b4c 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -853,6 +853,7 @@ public: friend int cmp_longlong(void *cmp_arg, packed_longlong *a,packed_longlong *b); }; + class in_double :public in_vector { double tmp; @@ -862,16 +863,16 @@ public: uchar *get_value(Item *item); Item *create_item() { - return new Item_float(0.0); + return new Item_float(0.0, 0); } void value_to_item(uint pos, Item *item) { ((Item_float*)item)->value= ((double*) base)[pos]; } Item_result result_type() { return REAL_RESULT; } - }; + class in_decimal :public in_vector { my_decimal val; diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index a87efa9e68c..7cee8088026 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1594,7 +1594,7 @@ int Item_func_now::save_in_field(Field *to, bool no_conversions) void Item_func_sysdate_local::store_now_in_TIME(MYSQL_TIME *now_time) { THD *thd= current_thd; - thd->variables.time_zone->gmt_sec_to_TIME(now_time, (my_time_t) time(NULL)); + thd->variables.time_zone->gmt_sec_to_TIME(now_time, (my_time_t) my_time(0)); thd->time_zone_used= 1; } diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index f8457a1ae50..6bc73f49a5a 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -2767,7 +2767,7 @@ String *Item_xml_str_func::parse_xml(String *raw_xml, String *parsed_xml_buf) if ((rc= my_xml_parse(&p, raw_xml->ptr(), raw_xml->length())) != MY_XML_OK) { char buf[128]; - my_snprintf(buf, sizeof(buf)-1, "parse error at line %d pos %lu: %s", + my_snprintf(buf, sizeof(buf)-1, "parse error at line %d pos %u: %s", my_xml_error_lineno(&p) + 1, my_xml_error_pos(&p) + 1, my_xml_error_string(&p)); diff --git a/sql/lock.cc b/sql/lock.cc index 4260a031def..e04be568a29 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -246,7 +246,7 @@ retry: } } - thd->lock_time(); + thd->set_time_after_lock(); DBUG_RETURN (sql_lock); } diff --git a/sql/log.cc b/sql/log.cc index 0bf77d68410..207c248c9e8 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -524,8 +524,8 @@ err: user_host the pointer to the string with user@host info user_host_len length of the user_host string. this is computed once and passed to all general log event handlers - query_time Amount of time the query took to execute (in seconds) - lock_time Amount of time the query was locked (in seconds) + query_time Amount of time the query took to execute (in microseconds) + lock_time Amount of time the query was locked (in microseconds) is_command The flag, which determines, whether the sql_text is a query or an administrator command (these are treated differently by the old logging routines) @@ -545,13 +545,12 @@ err: bool Log_to_csv_event_handler:: log_slow(THD *thd, time_t current_time, time_t query_start_arg, const char *user_host, uint user_host_len, - longlong query_time, longlong lock_time, bool is_command, + ulonglong query_utime, ulonglong lock_utime, bool is_command, const char *sql_text, uint sql_text_len) { /* table variables */ TABLE *table= slow_log.table; CHARSET_INFO *client_cs= thd->variables.character_set_client; - DBUG_ENTER("log_slow"); /* below should never happen */ @@ -582,6 +581,8 @@ bool Log_to_csv_event_handler:: if (query_start_arg) { + longlong query_time= (longlong) (query_utime/1000000); + longlong lock_time= (longlong) (lock_utime/1000000); /* A TIME field can not hold the full longlong range; query_time or lock_time may be truncated without warning here, if greater than @@ -694,12 +695,12 @@ void Log_to_file_event_handler::init_pthread_objects() bool Log_to_file_event_handler:: log_slow(THD *thd, time_t current_time, time_t query_start_arg, const char *user_host, uint user_host_len, - longlong query_time, longlong lock_time, bool is_command, + ulonglong query_utime, ulonglong lock_utime, bool is_command, const char *sql_text, uint sql_text_len) { return mysql_slow_log.write(thd, current_time, query_start_arg, user_host, user_host_len, - query_time, lock_time, is_command, + query_utime, lock_utime, is_command, sql_text, sql_text_len); } @@ -774,10 +775,10 @@ bool LOGGER::error_log_print(enum loglevel level, const char *format, va_list args) { bool error= FALSE; - Log_event_handler **current_handler= error_log_handler_list; + Log_event_handler **current_handler; /* currently we don't need locking here as there is no error_log table */ - while (*current_handler) + for (current_handler= error_log_handler_list ; *current_handler ;) error= (*current_handler++)->log_error(level, format, args) || error; return error; @@ -904,28 +905,27 @@ bool LOGGER::flush_logs(THD *thd) SYNOPSIS slow_log_print() - thd THD of the query being logged - query The query being logged - query_length The length of the query string - query_start_arg Query start timestamp + thd THD of the query being logged + query The query being logged + query_length The length of the query string + current_utime Current time in microseconds (from undefined start) RETURN - FALSE - OK - TRUE - error occured + FALSE OK + TRUE error occured */ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length, - time_t query_start_arg) + ulonglong current_utime) + { bool error= FALSE; - Log_event_handler **current_handler= slow_log_handler_list; + Log_event_handler **current_handler; bool is_command= FALSE; char user_host_buff[MAX_USER_HOST_SIZE]; - - time_t current_time; Security_context *sctx= thd->security_ctx; uint user_host_len= 0; - longlong query_time= 0, lock_time= 0; + ulonglong query_utime, lock_utime; /* Print the message to the buffer if we have slow log enabled @@ -933,10 +933,10 @@ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length, if (*slow_log_handler_list) { - current_time= time(NULL); + time_t current_time; /* do not log slow queries from replication threads */ - if (thd->slave_thread) + if (thd->slave_thread && !opt_log_slow_slave_statements) return 0; lock(); @@ -947,17 +947,22 @@ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length, } /* fill in user_host value: the format is "%s[%s] @ %s [%s]" */ - user_host_len= strxnmov(user_host_buff, MAX_USER_HOST_SIZE, - sctx->priv_user ? sctx->priv_user : "", "[", - sctx->user ? sctx->user : "", "] @ ", - sctx->host ? sctx->host : "", " [", - sctx->ip ? sctx->ip : "", "]", NullS) - - user_host_buff; + user_host_len= (strxnmov(user_host_buff, MAX_USER_HOST_SIZE, + sctx->priv_user ? sctx->priv_user : "", "[", + sctx->user ? sctx->user : "", "] @ ", + sctx->host ? sctx->host : "", " [", + sctx->ip ? sctx->ip : "", "]", NullS) - + user_host_buff); - if (query_start_arg) + current_time= my_time_possible_from_micro(current_utime); + if (thd->start_utime) { - query_time= (longlong) (current_time - query_start_arg); - lock_time= (longlong) (thd->time_after_lock - query_start_arg); + query_utime= (current_utime - thd->start_utime); + lock_utime= (thd->utime_after_lock - thd->start_utime); + } + else + { + query_utime= lock_utime= 0; } if (!query) @@ -967,10 +972,10 @@ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length, query_length= command_name[thd->command].length; } - while (*current_handler) - error= (*current_handler++)->log_slow(thd, current_time, query_start_arg, + for (current_handler= slow_log_handler_list; *current_handler ;) + error= (*current_handler++)->log_slow(thd, current_time, thd->start_time, user_host_buff, user_host_len, - query_time, lock_time, is_command, + query_utime, lock_utime, is_command, query, query_length) || error; unlock(); @@ -995,7 +1000,7 @@ bool LOGGER::general_log_print(THD *thd, enum enum_server_command command, Security_context *sctx= thd->security_ctx; ulong id; uint message_buff_len= 0, user_host_len= 0; - + time_t current_time; if (thd) { /* Normal thread */ if ((thd->options & OPTION_LOG_OFF) @@ -1017,8 +1022,6 @@ bool LOGGER::general_log_print(THD *thd, enum enum_server_command command, unlock(); return 0; } - time_t current_time= time(NULL); - user_host_len= strxnmov(user_host_buff, MAX_USER_HOST_SIZE, sctx->priv_user ? sctx->priv_user : "", "[", sctx->user ? sctx->user : "", "] @ ", @@ -1033,6 +1036,7 @@ bool LOGGER::general_log_print(THD *thd, enum enum_server_command command, else message_buff[0]= '\0'; + current_time= my_time(0); while (*current_handler) error+= (*current_handler++)-> log_general(current_time, user_host_buff, @@ -2165,8 +2169,8 @@ err: user_host the pointer to the string with user@host info user_host_len length of the user_host string. this is computed once and passed to all general log event handlers - query_time Amount of time the query took to execute (in seconds) - lock_time Amount of time the query was locked (in seconds) + query_utime Amount of time the query took to execute (in microseconds) + lock_utime Amount of time the query was locked (in microseconds) is_command The flag, which determines, whether the sql_text is a query or an administrator command. sql_text the very text of the query or administrator command @@ -2184,8 +2188,8 @@ err: bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time, time_t query_start_arg, const char *user_host, - uint user_host_len, longlong query_time, - longlong lock_time, bool is_command, + uint user_host_len, ulonglong query_utime, + ulonglong lock_utime, bool is_command, const char *sql_text, uint sql_text_len) { bool error= 0; @@ -2198,6 +2202,7 @@ bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time, { // Safety agains reopen int tmp_errno= 0; char buff[80], *end; + char query_time_buff[22+7], lock_time_buff[22+7]; uint buff_len; end= buff; @@ -2228,10 +2233,12 @@ bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time, tmp_errno= errno; } /* For slow query log */ + sprintf(query_time_buff, "%.6f", ulonglong2double(query_utime)/1000000.0); + sprintf(lock_time_buff, "%.6f", ulonglong2double(lock_utime)/1000000.0); if (my_b_printf(&log_file, - "# Query_time: %lu Lock_time: %lu" + "# Query_time: %s Lock_time: %s" " Rows_sent: %lu Rows_examined: %lu\n", - (ulong) query_time, (ulong) lock_time, + query_time_buff, lock_time_buff, (ulong) thd->sent_row_count, (ulong) thd->examined_row_count) == (uint) -1) tmp_errno= errno; @@ -3872,9 +3879,9 @@ int error_log_print(enum loglevel level, const char *format, bool slow_log_print(THD *thd, const char *query, uint query_length, - time_t query_start_arg) + ulonglong current_utime) { - return logger.slow_log_print(thd, query, query_length, query_start_arg); + return logger.slow_log_print(thd, query, query_length, current_utime); } @@ -3902,7 +3909,7 @@ void MYSQL_BIN_LOG::rotate_and_purge(uint flags) #ifdef HAVE_REPLICATION if (expire_logs_days) { - time_t purge_time= time(0) - expire_logs_days*24*60*60; + time_t purge_time= my_time(0) - expire_logs_days*24*60*60; if (purge_time >= 0) purge_logs_before_date(purge_time); } @@ -4499,7 +4506,7 @@ static void print_buffer_to_file(enum loglevel level, const char *buffer) VOID(pthread_mutex_lock(&LOCK_error_log)); - skr=time(NULL); + skr= my_time(0); localtime_r(&skr, &tm_tmp); start=&tm_tmp; diff --git a/sql/log.h b/sql/log.h index d92e0117bcc..2a796ef89e7 100644 --- a/sql/log.h +++ b/sql/log.h @@ -198,7 +198,7 @@ public: const char *sql_text, uint sql_text_len); bool write(THD *thd, time_t current_time, time_t query_start_arg, const char *user_host, uint user_host_len, - longlong query_time, longlong lock_time, bool is_command, + ulonglong query_utime, ulonglong lock_utime, bool is_command, const char *sql_text, uint sql_text_len); bool open_slow_log(const char *log_name) { @@ -393,8 +393,8 @@ public: virtual bool log_slow(THD *thd, time_t current_time, time_t query_start_arg, const char *user_host, - uint user_host_len, longlong query_time, - longlong lock_time, bool is_command, + uint user_host_len, ulonglong query_utime, + ulonglong lock_utime, bool is_command, const char *sql_text, uint sql_text_len)= 0; virtual bool log_error(enum loglevel level, const char *format, va_list args)= 0; @@ -442,8 +442,8 @@ public: virtual bool log_slow(THD *thd, time_t current_time, time_t query_start_arg, const char *user_host, - uint user_host_len, longlong query_time, - longlong lock_time, bool is_command, + uint user_host_len, ulonglong query_utime, + ulonglong lock_utime, bool is_command, const char *sql_text, uint sql_text_len); virtual bool log_error(enum loglevel level, const char *format, va_list args); @@ -479,8 +479,8 @@ public: virtual bool log_slow(THD *thd, time_t current_time, time_t query_start_arg, const char *user_host, - uint user_host_len, longlong query_time, - longlong lock_time, bool is_command, + uint user_host_len, ulonglong query_utime, + ulonglong lock_utime, bool is_command, const char *sql_text, uint sql_text_len); virtual bool log_error(enum loglevel level, const char *format, va_list args); @@ -564,7 +564,7 @@ public: bool error_log_print(enum loglevel level, const char *format, va_list args); bool slow_log_print(THD *thd, const char *query, uint query_length, - time_t query_start_arg); + ulonglong current_utime); bool general_log_print(THD *thd,enum enum_server_command command, const char *format, va_list args); diff --git a/sql/log_event.cc b/sql/log_event.cc index c062aa99b4e..db8729c8318 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -456,7 +456,7 @@ Log_event::Log_event() thd(0) { server_id= ::server_id; - when= time(NULL); + when= my_time(0); log_pos= 0; } #endif /* !MYSQL_CLIENT */ @@ -2073,7 +2073,7 @@ int Query_log_event::do_apply_event(RELAY_LOG_INFO const *rli, /* Execute the query (note that we bypass dispatch_command()) */ const char* found_semicolon= NULL; mysql_parse(thd, thd->query, thd->query_length, &found_semicolon); - + log_slow_statement(thd); } else { @@ -4349,7 +4349,7 @@ int User_var_log_event::do_apply_event(RELAY_LOG_INFO const *rli) switch (type) { case REAL_RESULT: float8get(real_val, val); - it= new Item_float(real_val); + it= new Item_float(real_val, 0); val= (char*) &real_val; // Pointer to value in native format val_len= 8; break; @@ -6173,7 +6173,7 @@ int Rows_log_event::do_apply_event(RELAY_LOG_INFO const *rli) problem. When WL#2975 is implemented, just remove the member st_relay_log_info::last_event_start_time and all its occurences. */ - const_cast(rli)->last_event_start_time= time(0); + const_cast(rli)->last_event_start_time= my_time(0); } DBUG_RETURN(0); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 7b7bc81957e..0678189b388 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -167,6 +167,7 @@ public: void restore_env(THD *thd, Object_creation_ctx *backup_ctx); protected: + Object_creation_ctx() {} virtual Object_creation_ctx *create_backup_ctx(THD *thd) = 0; virtual void change_env(THD *thd) const = 0; @@ -734,7 +735,7 @@ int error_log_print(enum loglevel level, const char *format, va_list args); bool slow_log_print(THD *thd, const char *query, uint query_length, - time_t query_start_arg); + ulonglong current_utime); bool general_log_print(THD *thd, enum enum_server_command command, const char *format,...); @@ -1791,7 +1792,7 @@ extern my_bool opt_readonly, lower_case_file_system; extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs; extern my_bool opt_secure_auth; extern char* opt_secure_file_priv; -extern my_bool opt_log_slow_admin_statements; +extern my_bool opt_log_slow_admin_statements, opt_log_slow_slave_statements; extern my_bool sp_automatic_privileges, opt_noacl; extern my_bool opt_old_style_user_limits, trust_function_creators; extern uint opt_crash_binlog_innodb; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 6d22047b9db..33cd55170ea 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -338,6 +338,7 @@ static char *default_collation_name; static char *default_storage_engine_str; static char compiled_default_collation_name[]= MYSQL_DEFAULT_COLLATION_NAME; static I_List thread_cache; +static double long_query_time; static pthread_cond_t COND_thread_cache, COND_flush_thread_cache; @@ -406,6 +407,7 @@ my_bool opt_sync_frm, opt_allow_suspicious_udfs; my_bool opt_secure_auth= 0; char* opt_secure_file_priv= 0; my_bool opt_log_slow_admin_statements= 0; +my_bool opt_log_slow_slave_statements= 0; my_bool lower_case_file_system= 0; my_bool opt_large_pages= 0; my_bool opt_myisam_use_mmap= 0; @@ -1143,7 +1145,7 @@ extern "C" void unireg_abort(int exit_code) sql_print_error("Aborting\n"); else if (opt_help) usage(); - clean_up(exit_code || !opt_bootstrap); /* purecov: inspected */ + clean_up(!opt_help && (exit_code || !opt_bootstrap)); /* purecov: inspected */ DBUG_PRINT("quit",("done with cleanup in unireg_abort")); wait_for_signal_thread_to_end(); clean_up_mutexes(); @@ -1240,12 +1242,12 @@ void clean_up(bool print_message) my_regex_end(); #endif - if (print_message && errmesg) - sql_print_information(ER(ER_SHUTDOWN_COMPLETE),my_progname); #if !defined(EMBEDDED_LIBRARY) if (!opt_bootstrap) (void) my_delete(pidfile_name,MYF(0)); // This may not always exist #endif + if (print_message && errmesg && server_start_time) + sql_print_information(ER(ER_SHUTDOWN_COMPLETE),my_progname); thread_scheduler.end(); finish_client_errs(); my_free((uchar*) my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST), @@ -1797,7 +1799,7 @@ static bool cache_thread() this thread for handling of new THD object/connection. */ thd->mysys_var->abort= 0; - thd->thr_create_time= time(NULL); + thd->thr_create_utime= my_micro_time(); threads.append(thd); return(1); } @@ -2174,7 +2176,7 @@ extern "C" sig_handler handle_segfault(int sig) segfaulted = 1; - curr_time= time(NULL); + curr_time= my_time(0); localtime_r(&curr_time, &tm); fprintf(stderr,"\ @@ -2717,7 +2719,7 @@ static int init_common_variables(const char *conf_file_name, int argc, tzset(); // Set tzname max_system_variables.pseudo_thread_id= (ulong)~0; - server_start_time= time((time_t*) 0); + server_start_time= my_time(0); rpl_filter= new Rpl_filter; binlog_filter= new Rpl_filter; if (!rpl_filter || !binlog_filter) @@ -2952,7 +2954,7 @@ static int init_common_variables(const char *conf_file_name, int argc, && !(log_output_options & LOG_NONE)) sql_print_warning("Although a path was specified for the " "--log-slow-queries option, log tables are used. " - "To enable logging to files use the --log-output option."); + "To enable logging to files use the --log-output=file option."); s= opt_logname ? opt_logname : make_default_log_name(buff, ".log"); sys_var_general_log_path.value= my_strdup(s, MYF(0)); @@ -3540,7 +3542,7 @@ server."); #ifdef HAVE_REPLICATION if (opt_bin_log && expire_logs_days) { - time_t purge_time= time(0) - expire_logs_days*24*60*60; + time_t purge_time= server_start_time - expire_logs_days*24*60*60; if (purge_time >= 0) mysql_bin_log.purge_logs_before_date(purge_time); } @@ -4289,7 +4291,7 @@ void create_thread_to_handle_connection(THD *thd) thread_created++; threads.append(thd); DBUG_PRINT("info",(("creating thread %lu"), thd->thread_id)); - thd->connect_time = time(NULL); + thd->connect_utime= thd->start_utime= my_micro_time(); if ((error=pthread_create(&thd->real_id,&connection_attrib, handle_one_connection, (void*) thd))) @@ -5076,6 +5078,8 @@ enum options_mysqld OPT_THREAD_HANDLING, OPT_INNODB_ROLLBACK_ON_TIMEOUT, OPT_SECURE_FILE_PRIV, + OPT_MIN_EXAMINED_ROW_LIMIT, + OPT_LOG_SLOW_SLAVE_STATEMENTS, OPT_OLD_MODE }; @@ -5377,8 +5381,13 @@ Disable with --skip-large-pages.", (uchar**) &opt_log_slow_admin_statements, (uchar**) &opt_log_slow_admin_statements, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"log-slow-slave-statements", OPT_LOG_SLOW_SLAVE_STATEMENTS, + "Log slow statements executed by slave thread to the slow log if it is open.", + (uchar**) &opt_log_slow_slave_statements, + (uchar**) &opt_log_slow_slave_statements, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"log-slow-queries", OPT_SLOW_QUERY_LOG, - "Log slow queries to this log file. Defaults logging to hostname-slow.log file. Must be enabled to activate other slow log options.", + "Log slow queries to a table or log file. Defaults logging to table mysql.slow_log or hostname-slow.log if --log-output=file is used. Must be enabled to activate other slow log options.", (uchar**) &opt_slow_logname, (uchar**) &opt_slow_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"log-tc", OPT_LOG_TC, @@ -5967,10 +5976,10 @@ log and this option does nothing anymore.", 0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100, 1, 100, 0, 1, 0}, {"long_query_time", OPT_LONG_QUERY_TIME, - "Log all queries that have taken more than long_query_time seconds to execute to file.", - (uchar**) &global_system_variables.long_query_time, - (uchar**) &max_system_variables.long_query_time, 0, GET_ULONG, - REQUIRED_ARG, 10, 1, LONG_TIMEOUT, 0, 1, 0}, + "Log all queries that have taken more than long_query_time seconds to execute to file. " + "The argument will be treated as a decimal value with microsecond precission.", + (uchar**) &long_query_time, (uchar**) &long_query_time, 0, GET_DOUBLE, + REQUIRED_ARG, 10, 0, LONG_TIMEOUT, 0, 0, 0}, {"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES, "If set to 1 table names are stored in lowercase on disk and table names will be case-insensitive. Should be set to 2 if you are using a case insensitive file system", (uchar**) &lower_case_table_names, @@ -6068,6 +6077,11 @@ The minimum value for this variable is 4096.", "After this many write locks, allow some read locks to run in between.", (uchar**) &max_write_lock_count, (uchar**) &max_write_lock_count, 0, GET_ULONG, REQUIRED_ARG, ~0L, 1, ~0L, 0, 1, 0}, + {"min_examined_row_limit", OPT_MIN_EXAMINED_ROW_LIMIT, + "Don't log queries which examine less than min_examined_row_limit rows to file.", + (uchar**) &global_system_variables.min_examined_row_limit, + (uchar**) &max_system_variables.min_examined_row_limit, 0, GET_ULONG, + REQUIRED_ARG, 0, 0, ~0L, 0, 1L, 0}, {"multi_range_count", OPT_MULTI_RANGE_COUNT, "Number of key ranges to request at once.", (uchar**) &global_system_variables.multi_range_count, @@ -6959,7 +6973,7 @@ Starts the MySQL database server\n"); printf("Usage: %s [OPTIONS]\n", my_progname); if (!opt_verbose) - puts("\nFor more help options (several pages), use mysqld --verbose --help\n"); + puts("\nFor more help options (several pages), use mysqld --verbose --help"); else { #ifdef __WIN__ @@ -6984,7 +6998,7 @@ Starts the MySQL database server\n"); puts("\n\ To see what values a running MySQL server is using, type\n\ -'mysqladmin variables' instead of 'mysqld --verbose --help'.\n"); +'mysqladmin variables' instead of 'mysqld --verbose --help'."); } } #endif /*!EMBEDDED_LIBRARY*/ @@ -7714,7 +7728,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), } return 0; } - /* Initiates DEBUG - but no debugging here ! */ + + +/* Handle arguments for multiple key caches */ static uchar* * mysql_getopt_value(const char *keyname, uint key_length, @@ -7772,9 +7788,10 @@ static void get_options(int *argc,char **argv) (*argc)++; /* add back one for the progname handle_options removes */ /* no need to do this for argv as we are discarding it. */ - if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes) && + if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes || + opt_log_slow_slave_statements) && !opt_slow_log) - sql_print_warning("options --log-slow-admin-statements and --log-queries-not-using-indexes have no effect if --log-slow-queries is not set"); + sql_print_warning("options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --log-slow-queries is not set"); #if defined(HAVE_BROKEN_REALPATH) my_use_symdir=0; @@ -7818,6 +7835,10 @@ static void get_options(int *argc,char **argv) /* Set global variables based on startup options */ myisam_block_size=(uint) 1 << my_bit_log2(opt_myisam_block_size); + /* long_query_time is in microseconds */ + global_system_variables.long_query_time= max_system_variables.long_query_time= + (longlong) (long_query_time * 1000000.0); + if (opt_short_log_format) opt_specialflag|= SPECIAL_SHORT_LOG_FORMAT; diff --git a/sql/net_serv.cc b/sql/net_serv.cc index bd273145782..1f75d7ab1d7 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -437,7 +437,7 @@ net_write_command(NET *net,uchar command, uchar buff[NET_HEADER_SIZE+1]; uint header_size=NET_HEADER_SIZE+1; DBUG_ENTER("net_write_command"); - DBUG_PRINT("enter",("length: %lu", len)); + DBUG_PRINT("enter",("length: %lu", (ulong) len)); buff[4]=command; /* For first packet */ diff --git a/sql/parse_file.cc b/sql/parse_file.cc index 5ea49396cb4..19fb11ac0cc 100644 --- a/sql/parse_file.cc +++ b/sql/parse_file.cc @@ -135,7 +135,7 @@ write_parameter(IO_CACHE *file, uchar* base, File_option *parameter, { /* string have to be allocated already */ LEX_STRING *val_s= (LEX_STRING *)(base + parameter->offset); - time_t tm= time(NULL); + time_t tm= my_time(0); get_date(val_s->str, GETDATE_DATE_TIME|GETDATE_GMT|GETDATE_FIXEDLENGTH, tm); diff --git a/sql/set_var.cc b/sql/set_var.cc index bd5234b42be..0ff561191ae 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -250,8 +250,8 @@ static sys_var_bool_ptr sys_log_queries_not_using_indexes(&vars, "log_queries_not_using_indexes", &opt_log_queries_not_using_indexes); static sys_var_thd_ulong sys_log_warnings(&vars, "log_warnings", &SV::log_warnings); -static sys_var_thd_ulong sys_long_query_time(&vars, "long_query_time", - &SV::long_query_time); +static sys_var_microseconds sys_var_long_query_time(&vars, "long_query_time", + &SV::long_query_time); static sys_var_thd_bool sys_low_priority_updates(&vars, "low_priority_updates", &SV::low_priority_updates, fix_low_priority_updates); @@ -315,6 +315,8 @@ static sys_var_thd_ulong sys_max_tmp_tables(&vars, "max_tmp_tables", &SV::max_tmp_tables); static sys_var_long_ptr sys_max_write_lock_count(&vars, "max_write_lock_count", &max_write_lock_count); +static sys_var_thd_ulong sys_min_examined_row_limit(&vars, "min_examined_row_limit", + &SV::min_examined_row_limit); static sys_var_thd_ulong sys_multi_range_count(&vars, "multi_range_count", &SV::multi_range_count); static sys_var_long_ptr sys_myisam_data_pointer_size(&vars, "myisam_data_pointer_size", @@ -1473,6 +1475,15 @@ Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base) pthread_mutex_unlock(&LOCK_global_system_variables); return new Item_int(value); } + case SHOW_DOUBLE: + { + double value; + pthread_mutex_lock(&LOCK_global_system_variables); + value= *(double*) value_ptr(thd, var_type, base); + pthread_mutex_unlock(&LOCK_global_system_variables); + /* 6, as this is for now only used with microseconds */ + return new Item_float(value, 6); + } case SHOW_HA_ROWS: { ha_rows value; @@ -2532,6 +2543,60 @@ void sys_var_thd_lc_time_names::set_default(THD *thd, enum_var_type type) thd->variables.lc_time_names= global_system_variables.lc_time_names; } +/* + Handling of microseoncds given as seconds.part_seconds + + NOTES + The argument to long query time is in seconds in decimal + which is converted to ulonglong integer holding microseconds for storage. + This is used for handling long_query_time +*/ + +bool sys_var_microseconds::update(THD *thd, set_var *var) +{ + double num= var->value->val_real(); + longlong microseconds; + if (num > (double) option_limits->max_value) + num= (double) option_limits->max_value; + if (num < (double) option_limits->min_value) + num= (double) option_limits->min_value; + microseconds= (longlong) (num * 1000000.0 + 0.5); + if (var->type == OPT_GLOBAL) + { + pthread_mutex_lock(&LOCK_global_system_variables); + (global_system_variables.*offset)= microseconds; + pthread_mutex_unlock(&LOCK_global_system_variables); + } + else + thd->variables.*offset= microseconds; + return 0; +} + + +void sys_var_microseconds::set_default(THD *thd, enum_var_type type) +{ + longlong microseconds= (longlong) (option_limits->def_value * 1000000.0); + if (type == OPT_GLOBAL) + { + pthread_mutex_lock(&LOCK_global_system_variables); + global_system_variables.*offset= microseconds; + pthread_mutex_unlock(&LOCK_global_system_variables); + } + else + thd->variables.*offset= microseconds; +} + + +uchar *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type, + LEX_STRING *base) +{ + thd->tmp_double_value= (double) ((type == OPT_GLOBAL) ? + global_system_variables.*offset : + thd->variables.*offset) / 1000000.0; + return (uchar*) &thd->tmp_double_value; +} + + /* Functions to update thd->options bits */ diff --git a/sql/set_var.h b/sql/set_var.h index a998dc93b84..67ec449a02f 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -113,9 +113,10 @@ class sys_var_long_ptr_global: public sys_var_global { public: ulong *value; - sys_var_long_ptr_global(sys_var_chain *chain, const char *name_arg, ulong *value_ptr_arg, - pthread_mutex_t *guard_arg, - sys_after_update_func after_update_arg= NULL) + sys_var_long_ptr_global(sys_var_chain *chain, const char *name_arg, + ulong *value_ptr_arg, + pthread_mutex_t *guard_arg, + sys_after_update_func after_update_arg= NULL) :sys_var_global(name_arg, after_update_arg, guard_arg), value(value_ptr_arg) { chain_sys_var(chain); } @@ -911,6 +912,27 @@ public: uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); }; + +class sys_var_microseconds :public sys_var_thd +{ + ulonglong SV::*offset; +public: + sys_var_microseconds(sys_var_chain *chain, const char *name_arg, + ulonglong SV::*offset_arg): + sys_var_thd(name_arg), offset(offset_arg) + { chain_sys_var(chain); } + bool check(THD *thd, set_var *var) {return 0;} + bool update(THD *thd, set_var *var); + void set_default(THD *thd, enum_var_type type); + SHOW_TYPE show_type() { return SHOW_DOUBLE; } + bool check_update_type(Item_result type) + { + return (type != INT_RESULT && type != REAL_RESULT && type != DECIMAL_RESULT); + } + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); +}; + + class sys_var_trust_routine_creators :public sys_var_bool_ptr { /* We need a derived class only to have a warn_deprecated() */ diff --git a/sql/slave.cc b/sql/slave.cc index 2e8e3f582de..6fb7d666703 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1460,6 +1460,7 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) thd->variables.max_allowed_packet= global_system_variables.max_allowed_packet + MAX_LOG_EVENT_HEADER; /* note, incr over the global not session var */ thd->slave_thread = 1; + thd->enable_slow_log= opt_log_slow_slave_statements; set_slave_thread_options(thd); thd->client_capabilities = CLIENT_LOCAL_FILES; pthread_mutex_lock(&LOCK_thread_count); @@ -1491,7 +1492,7 @@ static int safe_sleep(THD* thd, int sec, CHECK_KILLED_FUNC thread_killed, DBUG_ENTER("safe_sleep"); thr_alarm_init(&alarmed); - time_t start_time= time((time_t*) 0); + time_t start_time= my_time(0); time_t end_time= start_time+sec; while ((nap_time= (int) (end_time - start_time)) > 0) @@ -1508,7 +1509,7 @@ static int safe_sleep(THD* thd, int sec, CHECK_KILLED_FUNC thread_killed, if ((*thread_killed)(thd,thread_killed_arg)) DBUG_RETURN(1); - start_time=time((time_t*) 0); + start_time= my_time(0); } DBUG_RETURN(0); } @@ -1796,7 +1797,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) thd->set_time(); // time the query thd->lex->current_select= 0; if (!ev->when) - ev->when = time(NULL); + ev->when= my_time(0); ev->thd = thd; // because up to this point, ev->thd == 0 int reason= ev->shall_skip(rli); diff --git a/sql/sql_cache.h b/sql/sql_cache.h index c4c7e1dbc5e..645807eecbf 100644 --- a/sql/sql_cache.h +++ b/sql/sql_cache.h @@ -142,6 +142,7 @@ struct Query_cache_query uint8 tbls_type; unsigned int last_pkt_nr; + Query_cache_query() {} /* Remove gcc warning */ inline void init_n_lock(); void unlock_n_destroy(); inline ulonglong found_rows() { return limit_found_rows; } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index da975ee3103..4fe68721ae5 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -407,7 +407,8 @@ THD::THD() // Must be reset to handle error with THD's created for init of mysqld lex->current_select= 0; start_time=(time_t) 0; - time_after_lock=(time_t) 0; + start_utime= 0L; + utime_after_lock= 0L; current_linfo = 0; slave_thread = 0; bzero(&variables, sizeof(variables)); diff --git a/sql/sql_class.h b/sql/sql_class.h index 7fa66893f69..6c3400ef08c 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -249,18 +249,19 @@ struct system_variables ulonglong myisam_max_sort_file_size; ulonglong max_heap_table_size; ulonglong tmp_table_size; + ulonglong long_query_time; ha_rows select_limit; ha_rows max_join_size; ulong auto_increment_increment, auto_increment_offset; ulong bulk_insert_buff_size; ulong join_buff_size; - ulong long_query_time; ulong max_allowed_packet; ulong max_error_count; ulong max_length_for_sort_data; ulong max_sort_length; ulong max_tmp_tables; ulong max_insert_delayed_threads; + ulong min_examined_row_limit; ulong multi_range_count; ulong myisam_repair_threads; ulong myisam_sort_buff_size; @@ -1025,8 +1026,6 @@ public: Security_context main_security_ctx; Security_context *security_ctx; - /* remote (peer) port */ - uint16 peer_port; /* Points to info-string that we show in SHOW PROCESSLIST You are supposed to update thd->proc_info only if you have coded @@ -1034,6 +1033,14 @@ public: */ const char *proc_info; + /* + Used in error messages to tell user in what part of MySQL we found an + error. E. g. when where= "having clause", if fix_fields() fails, user + will know that the error was in having clause. + */ + const char *where; + + double tmp_double_value; /* Used in set_var.cc */ ulong client_capabilities; /* What the client supports */ ulong max_client_packet_length; @@ -1055,14 +1062,12 @@ public: enum enum_server_command command; uint32 server_id; uint32 file_id; // for LOAD DATA INFILE - /* - Used in error messages to tell user in what part of MySQL we found an - error. E. g. when where= "having clause", if fix_fields() fails, user - will know that the error was in having clause. - */ - const char *where; - time_t start_time,time_after_lock,user_time; - time_t connect_time,thr_create_time; // track down slow pthread_create + /* remote (peer) port */ + uint16 peer_port; + time_t start_time, user_time; + ulonglong connect_utime, thr_create_utime; // track down slow pthread_create + ulonglong start_utime, utime_after_lock; + thr_lock_type update_lock_default; Delayed_insert *di; @@ -1570,27 +1575,25 @@ public: proc_info = old_msg; pthread_mutex_unlock(&mysys_var->mutex); } - - static inline void safe_time(time_t *t) - { - /** - Wrapper around time() which retries on error (-1) - - @details - This is needed because, despite the documentation, time() may fail - in some circumstances. Here we retry time() until it succeeds, and - log the failure so that performance problems related to this can be - identified. - */ - while(unlikely(time(t) == ((time_t) -1))) - sql_print_information("time() failed with %d", errno); - } - inline time_t query_start() { query_start_used=1; return start_time; } - inline void set_time() { if (user_time) start_time=time_after_lock=user_time; else { safe_time(&start_time); time_after_lock= start_time; }} - inline void end_time() { safe_time(&start_time); } - inline void set_time(time_t t) { time_after_lock=start_time=user_time=t; } - inline void lock_time() { safe_time(&time_after_lock); } + inline void set_time() + { + if (user_time) + { + start_time= user_time; + start_utime= utime_after_lock= my_micro_time(); + } + else + start_utime= utime_after_lock= my_micro_time_and_time(&start_time); + } + inline void set_current_time() { start_time= my_time(MY_WME); } + inline void set_time(time_t t) + { + start_time= user_time= t; + start_utime= utime_after_lock= my_micro_time(); + } + void set_time_after_lock() { utime_after_lock= my_micro_time(); } + ulonglong current_utime() { return my_micro_time(); } inline ulonglong found_rows(void) { return limit_found_rows; diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 26b7098e27c..03b9908c1ad 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -97,7 +97,7 @@ static int get_or_create_user_conn(THD *thd, const char *user, uc->len= temp_len; uc->connections= uc->questions= uc->updates= uc->conn_per_hour= 0; uc->user_resources= *mqh; - uc->intime= thd->thr_create_time; + uc->reset_utime= thd->thr_create_utime; if (my_hash_insert(&hash_user_connections, (uchar*) uc)) { my_free((char*) uc,0); @@ -223,16 +223,16 @@ void decrease_user_connections(USER_CONN *uc) void time_out_user_resource_limits(THD *thd, USER_CONN *uc) { - time_t check_time = thd->start_time ? thd->start_time : time(NULL); + ulonglong check_time= thd->start_utime; DBUG_ENTER("time_out_user_resource_limits"); /* If more than a hour since last check, reset resource checking */ - if (check_time - uc->intime >= 3600) + if (check_time - uc->reset_utime >= LL(3600000000)) { uc->questions=1; uc->updates=0; uc->conn_per_hour=0; - uc->intime=check_time; + uc->reset_utime= check_time; } DBUG_VOID_RETURN; @@ -1053,8 +1053,8 @@ void prepare_new_connection_state(THD* thd) pthread_handler_t handle_one_connection(void *arg) { THD *thd= (THD*) arg; - uint launch_time = - (uint) ((thd->thr_create_time = time(NULL)) - thd->connect_time); + ulong launch_time= (ulong) ((thd->thr_create_utime= my_micro_time()) - + thd->connect_utime); if (thread_scheduler.init_new_connection_thread()) { @@ -1063,7 +1063,7 @@ pthread_handler_t handle_one_connection(void *arg) thread_scheduler.end_thread(thd,0); return 0; } - if (launch_time >= slow_launch_time) + if (launch_time >= slow_launch_time*1000000L) statistic_increment(slow_launch_threads,&LOCK_status); /* diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index b14241bbef3..12483044cb9 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2196,7 +2196,7 @@ pthread_handler_t handle_delayed_insert(void *arg) /* Add thread to THD list so that's it's visible in 'show processlist' */ pthread_mutex_lock(&LOCK_thread_count); thd->thread_id= thd->variables.pseudo_thread_id= thread_id++; - thd->end_time(); + thd->set_current_time(); threads.append(thd); thd->killed=abort_loop ? THD::KILL_CONNECTION : THD::NOT_KILLED; pthread_mutex_unlock(&LOCK_thread_count); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index f2a61b7f7c5..a13e3d3f624 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1297,7 +1297,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd, void log_slow_statement(THD *thd) { - time_t start_of_query; DBUG_ENTER("log_slow_statement"); /* @@ -1308,25 +1307,24 @@ void log_slow_statement(THD *thd) if (unlikely(thd->in_sub_stmt)) DBUG_VOID_RETURN; // Don't set time for sub stmt - start_of_query= thd->start_time; - thd->end_time(); // Set start time - /* Do not log administrative statements unless the appropriate option is set; do not log into slow log if reading from backup. */ if (thd->enable_slow_log && !thd->user_time) { - thd->proc_info="logging slow query"; + ulonglong end_utime_of_query= thd->current_utime(); - if ((ulong) (thd->start_time - thd->time_after_lock) > - thd->variables.long_query_time || - ((thd->server_status & - (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) && - opt_log_queries_not_using_indexes)) + thd->proc_info="logging slow query"; + if (((end_utime_of_query - thd->utime_after_lock) > + thd->variables.long_query_time || + ((thd->server_status & + (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) && + opt_log_queries_not_using_indexes)) && + thd->examined_row_count >= thd->variables.min_examined_row_limit) { thd->status_var.long_query_count++; - slow_log_print(thd, thd->query, thd->query_length, start_of_query); + slow_log_print(thd, thd->query, thd->query_length, end_utime_of_query); } } DBUG_VOID_RETURN; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 6c7949fc8d7..b3203592cbe 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -15508,15 +15508,11 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, /* Add "filtered" field to item_list. */ if (join->thd->lex->describe & DESCRIBE_EXTENDED) { - Item_float *filtered; - float f; + float f= 0.0; if (examined_rows) f= (float) (100.0 * join->best_positions[i].records_read / examined_rows); - else - f= 0.0; - item_list.push_back((filtered= new Item_float(f))); - filtered->decimals= 2; + item_list.push_back(new Item_float(f, 2)); } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 5b8cb93baab..6c5a408f2c8 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1663,11 +1663,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) if (mysys_var) pthread_mutex_unlock(&mysys_var->mutex); -#ifdef EXTRA_DEBUG - thd_info->start_time= tmp->time_after_lock; -#else thd_info->start_time= tmp->start_time; -#endif thd_info->query=0; if (tmp->query) { @@ -1686,7 +1682,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) VOID(pthread_mutex_unlock(&LOCK_thread_count)); thread_info *thd_info; - time_t now= time(0); + time_t now= my_time(0); while ((thd_info=thread_infos.get())) { protocol->prepare_for_resend(); @@ -1716,7 +1712,7 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond) TABLE *table= tables->table; CHARSET_INFO *cs= system_charset_info; char *user; - time_t now= time(0); + time_t now= my_time(0); DBUG_ENTER("fill_process_list"); user= thd->security_ctx->master_access & PROCESS_ACL ? @@ -2069,11 +2065,11 @@ static bool show_status_array(THD *thd, const char *wild, */ switch (show_type) { case SHOW_DOUBLE_STATUS: - { value= ((char *) status_var + (ulong) value); - end= buff + sprintf(buff, "%f", *(double*) value); + /* fall through */ + case SHOW_DOUBLE: + end= buff + my_sprintf(buff, (buff, "%f", *(double*) value)); break; - } case SHOW_LONG_STATUS: value= ((char *) status_var + (ulong) value); /* fall through */ @@ -2083,6 +2079,7 @@ static bool show_status_array(THD *thd, const char *wild, break; case SHOW_LONGLONG_STATUS: value= ((char *) status_var + (ulonglong) value); + /* fall through */ case SHOW_LONGLONG: end= longlong10_to_str(*(longlong*) value, buff, 10); break; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index dc3e72554fa..0ed7ebe631f 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -54,6 +54,20 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, HA_CREATE_INFO *create_info, Alter_info *alter_info); +#ifndef DBUG_OFF + +/* Wait until we get a 'mysql_kill' signal */ + +static void wait_for_kill_signal(THD *thd) +{ + while (thd->killed == 0) + sleep(1); + // Reset signal and continue as if nothing happend + thd->killed= THD::NOT_KILLED; +} +#endif + + /* Translate a file name to a table name (WL #1324). @@ -4111,6 +4125,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, RTFC_WAIT_OTHER_THREAD_FLAG | RTFC_CHECK_KILLED_FLAG); thd->exit_cond(old_message); + DBUG_EXECUTE_IF("wait_in_mysql_admin_table", wait_for_kill_signal(thd);); if (thd->killed) goto err; /* Flush entries in the query cache involving this table. */ diff --git a/sql/structs.h b/sql/structs.h index da2339d27f8..09a3c4d7285 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -209,6 +209,11 @@ typedef struct user_conn { char *user; /* Pointer to host part of the key. */ char *host; + /* + The moment of time when per hour counters were reset last time + (i.e. start of "hour" for conn_per_hour, updates, questions counters). + */ + ulonglong reset_utime; /* Total length of the key. */ uint len; /* Current amount of concurrent connections for this account. */ @@ -220,11 +225,6 @@ typedef struct user_conn { uint conn_per_hour, updates, questions; /* Maximum amount of resources which account is allowed to consume. */ USER_RESOURCES user_resources; - /* - The moment of time when per hour counters were reset last time - (i.e. start of "hour" for conn_per_hour, updates, questions counters). - */ - time_t intime; } USER_CONN; /* Bits in form->update */ From 8018d6ac94a9859358600c646ec55bc2a244c4a5 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 31 Jul 2007 19:40:36 +0500 Subject: [PATCH 11/74] BUG#29152 - INSERT DELAYED does not use concurrent_insert on slave INSERT DELAYED on a replication slave was converted to regular INSERT, whereas it should try concurrent INSERT first. With this patch we try to convert delayed insert to concurrent insert on a replication slave. If it is impossible for some reason, we fall back to regular insert. No test case for this fix. I do not see anything indicating this is regression - we behave this way since Nov 2000. sql/sql_insert.cc: If we're executing INSERT DELAYED on a replication slave, we're upgrading lock type to TL_WRITE as we need to ensure serial execution of queries on the slave. OTOH if we're executing regular INSERT on a replication slave, we're trying TL_WRITE_CONCURRENT_INSERT first, and if we may not use it, we fall back to TL_WRITE. Fixed INSERT DELAYED on a replication slave to behave the same way as regular INSERT, that is to try TL_WRITE_CONCURRENT_INSERT first. --- sql/sql_insert.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 19c9360b0ed..d2d03a1a119 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -446,7 +446,6 @@ void upgrade_lock_type(THD *thd, thr_lock_type *lock_type, client connection and the delayed thread. */ if (specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE) || - thd->slave_thread || thd->variables.max_insert_delayed_threads == 0 || thd->prelocked_mode || thd->lex->uses_stored_routines()) @@ -454,6 +453,14 @@ void upgrade_lock_type(THD *thd, thr_lock_type *lock_type, *lock_type= TL_WRITE; return; } + if (thd->slave_thread) + { + /* Try concurrent insert */ + *lock_type= (duplic == DUP_UPDATE || duplic == DUP_REPLACE) ? + TL_WRITE : TL_WRITE_CONCURRENT_INSERT; + return; + } + bool log_on= (thd->options & OPTION_BIN_LOG || ! (thd->security_ctx->master_access & SUPER_ACL)); if (log_on && mysql_bin_log.is_open() && is_multi_insert) From a250e2b453475694451b0553622a9a6ab330e1a6 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 31 Jul 2007 19:35:13 +0200 Subject: [PATCH 12/74] Fix a bad BitKeeper dependency structure for the "CMakeLists.txt" files. They had been introduced in 5.1 and were only later backported to 5.0; as a consequence, the files in the 5.1 tree do not depend on the 5.0 ones, and changes in 5.0 do not propagate into the 5.1 files. To fix this, the (previous) files in 5.1 now are deleted ("bk rm"), and the previously deleted files depending on 5.0 are now moved to the respective source directories ("bk mv"). The current 5.1 contents is restored in these files. If you need the previous history of the 5.1 files ("bk revtool"), access those in "BitKeeper/deleted". Contrary to the original plan, I did not introduce the name "CMakeLists.historic" - mostly in order not to clutter the source tree. This fixes bug#29982. BitKeeper/deleted/.del-CMakeLists.txt~2eb9019b: Delete: client/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~5b8836e4: Delete: CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~93f0d646: Delete: dbug/CMakeLists.txt dbug/CMakeLists.txt: Rename: BitKeeper/deleted/.del-CMakeLists.txt~9 -> dbug/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~57492bba: Delete: extra/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~8c35983c: Delete: extra/yassl/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~c3563d5f: Delete: extra/yassl/taocrypt/CMakeLists.txt extra/yassl/CMakeLists.txt: Rename: BitKeeper/deleted/.del-CMakeLists.txt~11 -> extra/yassl/CMakeLists.txt extra/yassl/taocrypt/CMakeLists.txt: Rename: BitKeeper/deleted/.del-CMakeLists.txt~12 -> extra/yassl/taocrypt/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~99a50df6: Delete: libmysql/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~86a68ea1: Delete: mysys/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~9e206e11: Delete: regex/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~95969b72: Delete: server-tools/instance-manager/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~fdec1f01: Delete: sql/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~1960eb07: Delete: storage/innobase/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~96726c3b: Delete: storage/myisam/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~bb293bb4: Delete: storage/heap/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~5fa65a12: Delete: strings/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~fb3a3a47: Delete: storage/myisammrg/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~fc201a06: Delete: tests/CMakeLists.txt tests/CMakeLists.txt: Rename: BitKeeper/deleted/.del-CMakeLists.txt~5 -> tests/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~2a609d33: Delete: vio/CMakeLists.txt vio/CMakeLists.txt: Rename: BitKeeper/deleted/.del-CMakeLists.txt~6 -> vio/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~ef945345: Delete: zlib/CMakeLists.txt zlib/CMakeLists.txt: Rename: BitKeeper/deleted/.del-CMakeLists.txt~8 -> zlib/CMakeLists.txt CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". client/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". extra/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". libmysql/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". mysys/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". regex/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". server-tools/instance-manager/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". sql/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". storage/heap/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". storage/innobase/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". storage/myisam/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". storage/myisammrg/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". strings/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". --- CMakeLists.txt | 0 client/CMakeLists.txt | 0 dbug/CMakeLists.txt | 0 extra/CMakeLists.txt | 0 extra/yassl/CMakeLists.txt | 0 extra/yassl/taocrypt/CMakeLists.txt | 0 libmysql/CMakeLists.txt | 0 mysys/CMakeLists.txt | 0 regex/CMakeLists.txt | 0 server-tools/instance-manager/CMakeLists.txt | 0 sql/CMakeLists.txt | 0 storage/heap/CMakeLists.txt | 0 storage/innobase/CMakeLists.txt | 0 storage/myisam/CMakeLists.txt | 0 storage/myisammrg/CMakeLists.txt | 0 strings/CMakeLists.txt | 0 tests/CMakeLists.txt | 0 vio/CMakeLists.txt | 0 zlib/CMakeLists.txt | 0 19 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 CMakeLists.txt mode change 100644 => 100755 client/CMakeLists.txt mode change 100644 => 100755 dbug/CMakeLists.txt mode change 100644 => 100755 extra/CMakeLists.txt mode change 100644 => 100755 extra/yassl/CMakeLists.txt mode change 100644 => 100755 extra/yassl/taocrypt/CMakeLists.txt mode change 100644 => 100755 libmysql/CMakeLists.txt mode change 100644 => 100755 mysys/CMakeLists.txt mode change 100644 => 100755 regex/CMakeLists.txt mode change 100644 => 100755 server-tools/instance-manager/CMakeLists.txt mode change 100644 => 100755 sql/CMakeLists.txt mode change 100644 => 100755 storage/heap/CMakeLists.txt mode change 100644 => 100755 storage/innobase/CMakeLists.txt mode change 100644 => 100755 storage/myisam/CMakeLists.txt mode change 100644 => 100755 storage/myisammrg/CMakeLists.txt mode change 100644 => 100755 strings/CMakeLists.txt mode change 100644 => 100755 tests/CMakeLists.txt mode change 100644 => 100755 vio/CMakeLists.txt mode change 100644 => 100755 zlib/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/dbug/CMakeLists.txt b/dbug/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/extra/CMakeLists.txt b/extra/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/extra/yassl/CMakeLists.txt b/extra/yassl/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/extra/yassl/taocrypt/CMakeLists.txt b/extra/yassl/taocrypt/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/regex/CMakeLists.txt b/regex/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/server-tools/instance-manager/CMakeLists.txt b/server-tools/instance-manager/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/storage/heap/CMakeLists.txt b/storage/heap/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/storage/myisam/CMakeLists.txt b/storage/myisam/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/storage/myisammrg/CMakeLists.txt b/storage/myisammrg/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/strings/CMakeLists.txt b/strings/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/vio/CMakeLists.txt b/vio/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/zlib/CMakeLists.txt b/zlib/CMakeLists.txt old mode 100644 new mode 100755 From 4158e75ded1e6ac0adcca94b83dd4db62d09f3eb Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 1 Aug 2007 11:54:24 +0200 Subject: [PATCH 13/74] Bug#29838 - myisam corruption using concurrent select ... and update When using concurrent insert with parallel index reads, it could happen that reading sessions found keys that pointed to records yet to be written to the data file. The result was a report of a corrupted table. But it was false alert. When inserting a record in a table with indexes, the keys are inserted into the indexes before the record is written to the data file. When the insert happens concurrently to selects, an index read can find a key that references the record that is not yet written to the data file. To avoid any access to such record, the select saves the current end of file position when it starts. Since concurrent inserts are always appended at end of the data file, the select can easily ignore any concurrently inserted record. The problem was that the ignore was only done for non-exact key searches (partial key or using >, >=, < or <=). The fix is to ignore concurrently inserted records also for exact key searches. No test case. Concurrent inserts cannot be tested with the test suite. Test cases are attached to the bug report. myisam/mi_rkey.c: Bug#29838 - myisam corruption using concurrent select ... and update Fixed mi_rkey() to always ignore records beyond saved eof. --- myisam/mi_rkey.c | 81 ++++++++++++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 30 deletions(-) diff --git a/myisam/mi_rkey.c b/myisam/mi_rkey.c index e34799da6ed..ea60b9a6f43 100644 --- a/myisam/mi_rkey.c +++ b/myisam/mi_rkey.c @@ -95,42 +95,63 @@ int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len, myisam_read_vec[search_flag], info->s->state.key_root[inx])) { /* - If we searching for a partial key (or using >, >=, < or <=) and - the data is outside of the data file, we need to continue searching - for the first key inside the data file + Found a key, but it might not be usable. We cannot use rows that + are inserted by other threads after we got our table lock + ("concurrent inserts"). The record may not even be present yet. + Keys are inserted into the index(es) before the record is + inserted into the data file. When we got our table lock, we + saved the current data_file_length. Concurrent inserts always go + to the end of the file. So we can test if the found key + references a new record. */ - if (info->lastpos >= info->state->data_file_length && - (search_flag != HA_READ_KEY_EXACT || - last_used_keyseg != keyinfo->seg + keyinfo->keysegs)) + if (info->lastpos >= info->state->data_file_length) { - do + /* The key references a concurrently inserted record. */ + if (search_flag == HA_READ_KEY_EXACT && + last_used_keyseg == keyinfo->seg + keyinfo->keysegs) + { + /* Simply ignore the key if it matches exactly. (Bug #29838) */ + my_errno= HA_ERR_KEY_NOT_FOUND; + info->lastpos= HA_OFFSET_ERROR; + } + else { - uint not_used[2]; /* - Skip rows that are inserted by other threads since we got a lock - Note that this can only happen if we are not searching after an - full length exact key, because the keys are sorted - according to position + If searching for a partial key (or using >, >=, < or <=) and + the data is outside of the data file, we need to continue + searching for the first key inside the data file. */ - if (_mi_search_next(info, keyinfo, info->lastkey, - info->lastkey_length, - myisam_readnext_vec[search_flag], - info->s->state.key_root[inx])) - break; - /* - Check that the found key does still match the search. - _mi_search_next() delivers the next key regardless of its - value. - */ - if (search_flag == HA_READ_KEY_EXACT && - ha_key_cmp(keyinfo->seg, key_buff, info->lastkey, use_key_length, - SEARCH_FIND, not_used)) + do { - my_errno= HA_ERR_KEY_NOT_FOUND; - info->lastpos= HA_OFFSET_ERROR; - break; - } - } while (info->lastpos >= info->state->data_file_length); + uint not_used[2]; + /* + Skip rows that are inserted by other threads since we got + a lock. Note that this can only happen if we are not + searching after a full length exact key, because the keys + are sorted according to position. + */ + if (_mi_search_next(info, keyinfo, info->lastkey, + info->lastkey_length, + myisam_readnext_vec[search_flag], + info->s->state.key_root[inx])) + break; /* purecov: inspected */ + /* + Check that the found key does still match the search. + _mi_search_next() delivers the next key regardless of its + value. + */ + if (search_flag == HA_READ_KEY_EXACT && + ha_key_cmp(keyinfo->seg, key_buff, info->lastkey, + use_key_length, SEARCH_FIND, not_used)) + { + /* purecov: begin inspected */ + my_errno= HA_ERR_KEY_NOT_FOUND; + info->lastpos= HA_OFFSET_ERROR; + break; + /* purecov: end */ + } + } while (info->lastpos >= info->state->data_file_length); + } } } } From 0c9a3e597d329c5475d4fec0a6f95ac87d65ca19 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 1 Aug 2007 22:59:05 +0300 Subject: [PATCH 14/74] Fixes Bug#30127: --debug-info no longer prints memory usage in mysql Fixed compiler warnings, errors and link errors Fixed new bug on Solaris with gethrtime() Added --debug-check option to all mysql clients to print errors and memory leaks Added --debug-info to all clients. This now works as --debug-check but also prints memory and cpu usage BUILD/compile-solaris-sparc-debug: Remove old cpu options client/client_priv.h: Added OPT_DBUG_CHECK client/mysql.cc: --debug-info now prints memory usage Added --debug-check client/mysql_upgrade.c: --debug-info now prints memory usage Added --debug-check client/mysqladmin.cc: --debug-info now prints memory usage Added --debug-check client/mysqlbinlog.cc: --debug-info now prints memory usage Added --debug-check client/mysqlcheck.c: --debug-info now prints memory usage Added --debug-check client/mysqldump.c: --debug-info now prints memory usage Added --debug-check client/mysqlimport.c: --debug-info now prints memory usage Added --debug-check client/mysqlshow.c: --debug-info now prints memory usage Added --debug-check client/mysqlslap.c: --debug-info now prints memory usage Added --debug-check client/mysqltest.c: --debug-info now prints memory usage Added --debug-check include/my_sys.h: Added extra option to TERMINATE to not print statistics libmysql/libmysql.c: Fixed compiler warning mysql-test/mysql-test-run.pl: --debug-info -> --debug-check to not print memory usage mysys/my_getsystime.c: Moved fast time calculation to my_micro_time_and_time() Fixed bug in previous push related to HAVE_GETHRTIME mysys/my_init.c: Print not freed memory in my_end() if MY_CHECK_ERROR is given mysys/my_static.c: Cleanup mysys/safemalloc.c: Added extra option to TERMINATE to not print statistics sql/item_xmlfunc.cc: Fixed compiler warning sql/sql_test.cc: Fixed TERMINATE() call unittest/mysys/base64-t.c: Fixed link error unittest/mysys/bitmap-t.c: Fixed link error unittest/mysys/my_atomic-t.c: Fixed link error --- BUILD/compile-solaris-sparc-debug | 2 +- client/client_priv.h | 4 +- client/mysql.cc | 23 ++++++---- client/mysql_upgrade.c | 33 ++++++++++----- client/mysqladmin.cc | 23 +++++++--- client/mysqlbinlog.cc | 23 ++++++---- client/mysqlcheck.c | 21 +++++++--- client/mysqldump.c | 23 ++++++---- client/mysqlimport.c | 20 ++++++--- client/mysqlshow.c | 20 ++++++--- client/mysqlslap.c | 22 ++++++---- client/mysqltest.c | 19 +++++++-- include/my_sys.h | 4 +- libmysql/libmysql.c | 2 +- mysql-test/mysql-test-run.pl | 12 +++--- mysys/my_getsystime.c | 70 ++++++++++++++++++------------- mysys/my_init.c | 11 +++-- mysys/my_static.c | 2 - mysys/safemalloc.c | 18 ++++---- sql/item_xmlfunc.cc | 4 +- sql/sql_test.cc | 2 +- unittest/mysys/base64-t.c | 2 + unittest/mysys/bitmap-t.c | 9 ++-- unittest/mysys/my_atomic-t.c | 3 +- 24 files changed, 245 insertions(+), 127 deletions(-) diff --git a/BUILD/compile-solaris-sparc-debug b/BUILD/compile-solaris-sparc-debug index 58fcecf5a71..43cabd644fa 100755 --- a/BUILD/compile-solaris-sparc-debug +++ b/BUILD/compile-solaris-sparc-debug @@ -6,6 +6,6 @@ make -k clean || true path=`dirname $0` . "$path/autorun.sh" -CFLAGS="-g -Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Wunused -O3 -fno-omit-frame-pointer -mcpu=v8 -Wa,-xarch=v8plusa" CXX=gcc CXXFLAGS="-Wimplicit -Wreturn-type -Wid-clash-51 -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti -O3 -fno-omit-frame-pointer -mcpu=v8 -Wa,-xarch=v8plusa -g" ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-debug +CFLAGS="-g -Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Wunused -O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-g -Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti -O3 -fno-omit-frame-pointer" ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-debug make -j 4 diff --git a/client/client_priv.h b/client/client_priv.h index 25241cc8c59..12264b6e98d 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -75,6 +75,6 @@ enum options_client OPT_SLAP_POST_QUERY, OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT, OPT_SERVER_ID, OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT, - OPT_DEBUG_INFO, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE, OPT_WRITE_BINLOG, - OPT_MAX_CLIENT_OPTION + OPT_DEBUG_INFO, OPT_DEBUG_CHECK, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE, + OPT_WRITE_BINLOG, OPT_MAX_CLIENT_OPTION }; diff --git a/client/mysql.cc b/client/mysql.cc index fe057c8b8a4..c0423e0c897 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -43,7 +43,7 @@ #include #endif -const char *VER= "14.13"; +const char *VER= "14.14"; /* Don't try to make a nice table if the data is too big */ #define MAX_COLUMN_LENGTH 1024 @@ -129,7 +129,7 @@ enum enum_info_type { INFO_INFO,INFO_ERROR,INFO_RESULT}; typedef enum enum_info_type INFO_TYPE; static MYSQL mysql; /* The connection */ -static my_bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0, +static my_bool ignore_errors=0,wait_flag=0,quick=0, connected=0,opt_raw_data=0,unbuffered=0,output_tables=0, opt_rehash=1,skip_updates=0,safe_updates=0,one_database=0, opt_compress=0, using_opt_local_infile=0, @@ -139,9 +139,11 @@ static my_bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0, default_charset_used= 0, opt_secure_auth= 0, default_pager_set= 0, opt_sigint_ignore= 0, show_warnings= 0, executing_query= 0, interrupted_query= 0; +static my_bool debug_info_flag, debug_check_flag; static my_bool column_types_flag; static ulong opt_max_allowed_packet, opt_net_buffer_length; static uint verbose=0,opt_silent=0,opt_mysql_port=0, opt_local_infile=0; +static uint my_end_arg; static char * opt_mysql_unix_port=0; static int connect_flag=CLIENT_INTERACTIVE; static char *current_host,*current_db,*current_user=0,*opt_password=0, @@ -541,7 +543,7 @@ sig_handler mysql_end(int sig) my_free(current_prompt,MYF(MY_ALLOW_ZERO_PTR)); mysql_server_end(); free_defaults(defaults_argv); - my_end(info_flag ? MY_CHECK_ERROR : 0); + my_end(my_end_arg); exit(status.exit_status); } @@ -611,8 +613,11 @@ static struct my_option my_long_options[] = {"debug", '#', "Output debug log", (uchar**) &default_dbug_option, (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"debug-info", 'T', "Print some debug info at exit.", (uchar**) &info_flag, - (uchar**) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .", + (uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-info", 'T', "Print some debug info at exit.", (uchar**) &debug_info_flag, + (uchar**) &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"database", 'D', "Database to use.", (uchar**) ¤t_db, (uchar**) ¤t_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, @@ -927,7 +932,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case '#': DBUG_PUSH(argument ? argument : default_dbug_option); - info_flag= 1; + debug_info_flag= 1; break; case 's': if (argument == disabled_my_option) @@ -1021,6 +1026,10 @@ static int get_options(int argc, char **argv) } if (tty_password) opt_password= get_tty_password(NullS); + if (debug_info_flag) + my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; + if (debug_check_flag) + my_end_arg= MY_CHECK_ERROR; return(0); } @@ -3288,7 +3297,7 @@ sql_real_connect(char *host,char *database,char *user,char *password, } connected=1; #ifndef EMBEDDED_LIBRARY - mysql.reconnect=info_flag ? 1 : 0; // We want to know if this happens + mysql.reconnect= debug_info_flag; // We want to know if this happens #else mysql.reconnect= 1; #endif diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 504b4c95a8b..6611a74ea7f 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -17,6 +17,8 @@ #include #include "../scripts/mysql_fix_privilege_tables_sql.c" +#define VER "1.1" + #ifdef HAVE_SYS_WAIT_H #include #endif @@ -32,7 +34,8 @@ static char mysql_path[FN_REFLEN]; static char mysqlcheck_path[FN_REFLEN]; -static my_bool opt_force, opt_verbose; +static my_bool opt_force, opt_verbose, debug_info_flag, debug_check_flag; +static uint my_end_arg= 0; static char *opt_user= (char*)"root"; static DYNAMIC_STRING ds_args; @@ -56,6 +59,11 @@ static struct my_option my_long_options[]= NO_ARG, 0, 0, 0, 0, 0, 0}, {"basedir", 'b', "Not used by mysql_upgrade. Only for backward compatibilty", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"character-sets-dir", OPT_CHARSETS_DIR, + "Directory where character sets are.", 0, + 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"compress", OPT_COMPRESS, "Use compression in server/client protocol.", + (uchar**)¬_used, (uchar**)¬_used, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"datadir", 'd', "Not used by mysql_upgrade. Only for backward compatibilty", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -66,14 +74,14 @@ static struct my_option my_long_options[]= {"debug", '#', "Output debug log", (uchar* *) & default_dbug_option, (uchar* *) & default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif + {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .", + (uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-info", 'T', "Print some debug info at exit.", (uchar**) &debug_info_flag, + (uchar**) &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, "Set the default character set.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are.", 0, - 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"compress", OPT_COMPRESS, "Use compression in server/client protocol.", - (uchar**)¬_used, (uchar**)¬_used, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', "Force execution of mysqlcheck even if mysql_upgrade " "has already been executed for the current version of MySQL.", (uchar**)&opt_force, (uchar**)&opt_force, 0, @@ -138,7 +146,7 @@ static void die(const char *fmt, ...) va_end(args); free_used_memory(); - my_end(MY_CHECK_ERROR); + my_end(my_end_arg); exit(1); } @@ -200,8 +208,9 @@ get_one_option(int optid, const struct my_option *opt, switch (optid) { case '?': - printf("MySQL utility for upgrading database to MySQL version %s\n", - MYSQL_SERVER_VERSION); + printf("%s Ver %s Distrib %s, for %s (%s)\n", + my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE); + puts("MySQL utility for upgrading databases to new MySQL versions\n"); my_print_help(my_long_options); exit(0); break; @@ -732,6 +741,10 @@ int main(int argc, char **argv) if (handle_options(&argc, &argv, my_long_options, get_one_option)) die(NULL); + if (debug_info_flag) + my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; + if (debug_check_flag) + my_end_arg= MY_CHECK_ERROR; if (tty_password) { @@ -780,7 +793,7 @@ int main(int argc, char **argv) create_mysql_upgrade_info_file(); free_used_memory(); - my_end(MY_CHECK_ERROR); + my_end(my_end_arg); exit(0); } diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index f6ff44c7d56..ce48ad03d33 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -40,9 +40,10 @@ ulonglong last_values[MAX_MYSQL_VAR]; static int interval=0; static my_bool option_force=0,interrupted=0,new_line=0, opt_compress=0, opt_relative=0, opt_verbose=0, opt_vertical=0, - tty_password= 0, info_flag= 0, opt_nobeep; -static uint tcp_port = 0, option_wait = 0, option_silent=0, nr_iterations, - opt_count_iterations= 0; + tty_password= 0, opt_nobeep; +static my_bool debug_info_flag= 0, debug_check_flag= 0; +static uint tcp_port = 0, option_wait = 0, option_silent=0, nr_iterations; +static uint opt_count_iterations= 0, my_end_arg; static ulong opt_connect_timeout, opt_shutdown_timeout; static char * unix_port=0; #ifdef LATER_HAVE_NDBCLUSTER_DB @@ -134,10 +135,16 @@ static struct my_option my_long_options[] = "Number of iterations to make. This works with -i (--sleep) only.", (uchar**) &nr_iterations, (uchar**) &nr_iterations, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, +#ifndef DBUG_OFF {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (uchar**) &info_flag, - (uchar**) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, +#endif + {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .", + (uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", + (uchar**) &debug_info_flag, (uchar**) &debug_info_flag, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', "Don't ask for confirmation on drop database; with multiple commands, continue even if an error occurs.", (uchar**) &option_force, (uchar**) &option_force, 0, GET_BOOL, NO_ARG, 0, 0, @@ -315,6 +322,10 @@ int main(int argc,char *argv[]) free_defaults(save_argv); exit(ho_error); } + if (debug_info_flag) + my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; + if (debug_check_flag) + my_end_arg= MY_CHECK_ERROR; if (argc == 0) { @@ -413,7 +424,7 @@ int main(int argc,char *argv[]) my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR)); #endif free_defaults(save_argv); - my_end(info_flag ? MY_CHECK_ERROR : 0); + my_end(my_end_arg); exit(error ? 1 : 0); return 0; } diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index edade347783..d8c4f4bbcbf 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -65,11 +65,13 @@ static bool one_database=0, to_last_remote_log= 0, disable_log_bin= 0; static bool opt_hexdump= 0; static bool opt_base64_output= 0; static const char* database= 0; -static my_bool force_opt= 0, short_form= 0, remote_opt= 0, info_flag; +static my_bool force_opt= 0, short_form= 0, remote_opt= 0; +static my_bool debug_info_flag, debug_check_flag; static my_bool force_if_open_opt= 1; static ulonglong offset = 0; static const char* host = 0; static int port= 0; +static uint my_end_arg; static const char* sock= 0; static const char* user = 0; static char* pass = 0; @@ -727,8 +729,12 @@ static struct my_option my_long_options[] = {"debug", '#', "Output debug log.", (uchar**) &default_dbug_option, (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (uchar**) &info_flag, - (uchar**) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .", + (uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", + (uchar**) &debug_info_flag, (uchar**) &debug_info_flag, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"disable-log-bin", 'D', "Disable binary log. This is useful, if you " "enabled --to-last-log and are sending the output to the same MySQL server. " "This way you could avoid an endless loop. You would also like to use it " @@ -860,7 +866,7 @@ static void die(const char* fmt, ...) va_end(args); cleanup(); /* We cannot free DBUG, it is used in global destructors after exit(). */ - my_end((info_flag ? MY_CHECK_ERROR : 0) | MY_DONT_FREE_DBUG); + my_end(my_end_arg | MY_DONT_FREE_DBUG); exit(1); } @@ -868,7 +874,7 @@ static void die(const char* fmt, ...) static void print_version() { - printf("%s Ver 3.2 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); + printf("%s Ver 3.3 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); NETWARE_SET_SCREEN_MODE(1); } @@ -984,7 +990,10 @@ static int parse_args(int *argc, char*** argv) load_defaults("my",load_default_groups,argc,argv); if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); - + if (debug_info_flag) + my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; + if (debug_check_flag) + my_end_arg= MY_CHECK_ERROR; return 0; } @@ -1597,7 +1606,7 @@ int main(int argc, char** argv) my_free_open_file_info(); load_processor.destroy(); /* We cannot free DBUG, it is used in global destructors after exit(). */ - my_end((info_flag ? MY_CHECK_ERROR : 0) | MY_DONT_FREE_DBUG); + my_end(my_end_arg | MY_DONT_FREE_DBUG); if (file_not_closed_error) { diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 372dfe860df..622975c51d5 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -15,7 +15,7 @@ /* By Jani Tolonen, 2001-04-20, MySQL Development Team */ -#define CHECK_VERSION "2.4.5" +#define CHECK_VERSION "2.5.0" #include "client_priv.h" #include @@ -33,10 +33,11 @@ static my_bool opt_alldbs = 0, opt_check_only_changed = 0, opt_extended = 0, opt_compress = 0, opt_databases = 0, opt_fast = 0, opt_medium_check = 0, opt_quick = 0, opt_all_in_1 = 0, opt_silent = 0, opt_auto_repair = 0, ignore_errors = 0, - tty_password= 0, opt_frm= 0, info_flag= 0, + tty_password= 0, opt_frm= 0, debug_info_flag= 0, debug_check_flag= 0, opt_fix_table_names= 0, opt_fix_db_names= 0, opt_upgrade= 0, opt_write_binlog= 1; static uint verbose = 0, opt_mysql_port=0; +static int my_end_arg; static char * opt_mysql_unix_port = 0; static char *opt_password = 0, *current_user = 0, *default_charset = (char *)MYSQL_DEFAULT_CHARSET_NAME, @@ -96,8 +97,12 @@ static struct my_option my_long_options[] = {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (uchar**) &info_flag, - (uchar**) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .", + (uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", + (uchar**) &debug_info_flag, (uchar**) &debug_info_flag, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, "Set the default character set.", (uchar**) &default_charset, (uchar**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -375,6 +380,10 @@ static int get_options(int *argc, char ***argv) } if (tty_password) opt_password = get_tty_password(NullS); + if (debug_info_flag) + my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; + if (debug_check_flag) + my_end_arg= MY_CHECK_ERROR; return(0); } /* get_options */ @@ -762,7 +771,7 @@ int main(int argc, char **argv) */ if (get_options(&argc, &argv)) { - my_end(info_flag ? MY_CHECK_ERROR : 0); + my_end(my_end_arg); exit(EX_USAGE); } if (dbConnect(current_host, current_user, opt_password)) @@ -804,6 +813,6 @@ int main(int argc, char **argv) #ifdef HAVE_SMEM my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR)); #endif - my_end(info_flag ? MY_CHECK_ERROR : 0); + my_end(my_end_arg); return(first_error!=0); } /* main */ diff --git a/client/mysqldump.c b/client/mysqldump.c index 0f30ebddacc..60252be0910 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -36,7 +36,7 @@ ** 10 Jun 2003: SET NAMES and --no-set-names by Alexander Barkov */ -#define DUMP_VERSION "10.12" +#define DUMP_VERSION "10.13" #include #include @@ -100,9 +100,9 @@ static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0, opt_dump_triggers= 0, opt_routines=0, opt_tz_utc=1, opt_events= 0, opt_alltspcs=0, opt_notspcs= 0; +static my_bool insert_pat_inited= 0, debug_info_flag= 0, debug_check_flag= 0; static ulong opt_max_allowed_packet, opt_net_buffer_length; static MYSQL mysql_connection,*mysql=0; -static my_bool insert_pat_inited= 0, info_flag; static DYNAMIC_STRING insert_pat; static char *opt_password=0,*current_user=0, *current_host=0,*path=0,*fields_terminated=0, @@ -116,7 +116,8 @@ static char compatible_mode_normal_str[255]; static ulong opt_compatible_mode= 0; #define MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL 1 #define MYSQL_OPT_MASTER_DATA_COMMENTED_SQL 2 -static uint opt_mysql_port= 0, opt_master_data; +static uint opt_mysql_port= 0, opt_master_data; +static uint my_end_arg; static char * opt_mysql_unix_port=0; static int first_error=0; static DYNAMIC_STRING extended_row; @@ -242,8 +243,12 @@ static struct my_option my_long_options[] = {"debug", '#', "Output debug log", (uchar**) &default_dbug_option, (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (uchar**) &info_flag, - (uchar**) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .", + (uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", + (uchar**) &debug_info_flag, (uchar**) &debug_info_flag, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, "Set the default character set.", (uchar**) &default_charset, (uchar**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -724,7 +729,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case '#': DBUG_PUSH(argument ? argument : default_dbug_option); - info_flag= 1; + debug_info_flag= 1; break; #include case 'V': print_version(); exit(0); @@ -858,6 +863,10 @@ static int get_options(int *argc, char ***argv) *mysql_params->p_max_allowed_packet= opt_max_allowed_packet; *mysql_params->p_net_buffer_length= opt_net_buffer_length; + if (debug_info_flag) + my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; + if (debug_check_flag) + my_end_arg= MY_CHECK_ERROR; if (opt_delayed) opt_lock=0; /* Can't have lock with delayed */ @@ -1262,7 +1271,7 @@ static void free_resources() dynstr_free(&insert_pat); if (defaults_argv) free_defaults(defaults_argv); - my_end(info_flag ? MY_CHECK_ERROR : 0); + my_end(my_end_arg); } diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 396063731cf..b09ae7a172a 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -24,7 +24,7 @@ ** * * ** ************************* */ -#define IMPORT_VERSION "3.6" +#define IMPORT_VERSION "3.7" #include "client_priv.h" #include "mysql_version.h" @@ -49,8 +49,8 @@ static char *add_load_option(char *ptr,const char *object, static my_bool verbose=0,lock_tables=0,ignore_errors=0,opt_delete=0, replace=0,silent=0,ignore=0,opt_compress=0, opt_low_priority= 0, tty_password= 0; -static my_bool info_flag= 0; -static uint opt_use_threads=0, opt_local_file=0; +static my_bool debug_info_flag= 0, debug_check_flag= 0; +static uint opt_use_threads=0, opt_local_file=0, my_end_arg= 0; static char *opt_password=0, *current_user=0, *current_host=0, *current_db=0, *fields_terminated=0, *lines_terminated=0, *enclosed=0, *opt_enclosed=0, @@ -87,8 +87,12 @@ static struct my_option my_long_options[] = 0, 0, 0}, {"debug",'#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (uchar**) &info_flag, - (uchar**) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .", + (uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", + (uchar**) &debug_info_flag, (uchar**) &debug_info_flag, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"delete", 'd', "First delete all rows from table.", (uchar**) &opt_delete, (uchar**) &opt_delete, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"fields-terminated-by", OPT_FTB, @@ -254,6 +258,10 @@ static int get_options(int *argc, char ***argv) if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); + if (debug_info_flag) + my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; + if (debug_check_flag) + my_end_arg= MY_CHECK_ERROR; if (enclosed && opt_enclosed) { @@ -659,6 +667,6 @@ int main(int argc, char **argv) my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR)); #endif free_defaults(argv_to_free); - my_end(info_flag ? MY_CHECK_ERROR : 0); + my_end(my_end_arg); return(exitcode); } diff --git a/client/mysqlshow.c b/client/mysqlshow.c index 649658d6223..fb89589f3e1 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -15,7 +15,7 @@ /* Show databases, tables or columns */ -#define SHOW_VERSION "9.6" +#define SHOW_VERSION "9.10" #include "client_priv.h" #include @@ -28,7 +28,9 @@ static char * host=0, *opt_password=0, *user=0; static my_bool opt_show_keys= 0, opt_compress= 0, opt_count=0, opt_status= 0; -static my_bool tty_password= 0, opt_table_type= 0, info_flag= 0; +static my_bool tty_password= 0, opt_table_type= 0; +static my_bool debug_info_flag= 0, debug_check_flag= 0; +static uint my_end_arg= 0; static uint opt_verbose=0; static char *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME; @@ -150,7 +152,7 @@ int main(int argc, char **argv) #ifdef HAVE_SMEM my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR)); #endif - my_end(info_flag ? MY_CHECK_ERROR : 0); + my_end(my_end_arg); exit(error ? 1 : 0); return 0; /* No compiler warnings */ } @@ -176,8 +178,12 @@ static struct my_option my_long_options[] = 0, 0, 0}, {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (uchar**) &info_flag, - (uchar**) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .", + (uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", + (uchar**) &debug_info_flag, (uchar**) &debug_info_flag, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"host", 'h', "Connect to host.", (uchar**) &host, (uchar**) &host, 0, GET_STR, @@ -326,6 +332,10 @@ get_options(int *argc,char ***argv) */ opt_verbose= 2; } + if (debug_info_flag) + my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; + if (debug_check_flag) + my_end_arg= MY_CHECK_ERROR; return; } diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 546b9dee3f5..33173858228 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -69,7 +69,7 @@ TODO: */ -#define SHOW_VERSION "0.9" +#define SLAP_VERSION "1.0" #define HUGE_STRING_LENGTH 8196 #define RAND_STRING_SIZE 126 @@ -128,10 +128,8 @@ const char *delimiter= "\n"; const char *create_schema_string= "mysqlslap"; -static my_bool opt_preserve; - +static my_bool opt_preserve= 0, debug_info_flag= 0, debug_check_flag= 0; static my_bool opt_only_print= FALSE; - static my_bool opt_compress= FALSE, tty_password= FALSE, opt_silent= FALSE, auto_generate_sql_autoincrement= FALSE, @@ -144,13 +142,14 @@ static unsigned long connect_flags= CLIENT_MULTI_RESULTS; static int verbose, delimiter_length; const char *num_int_cols_opt; const char *num_char_cols_opt; + /* Yes, we do set defaults here */ static unsigned int num_int_cols= 1; static unsigned int num_char_cols= 1; static unsigned int num_int_cols_index= 0; static unsigned int num_char_cols_index= 0; - static unsigned int iterations; +static uint my_end_arg= 0; static char *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME; static ulonglong actual_queries= 0; static ulonglong auto_actual_queries; @@ -403,7 +402,7 @@ int main(int argc, char **argv) my_free(shared_memory_base_name, MYF(MY_ALLOW_ZERO_PTR)); #endif free_defaults(defaults_argv); - my_end(0); + my_end(my_end_arg); return 0; } @@ -546,6 +545,11 @@ static struct my_option my_long_options[] = {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", (uchar**) &default_dbug_option, (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .", + (uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-info", 'T', "Print some debug info at exit.", (uchar**) &debug_info_flag, + (uchar**) &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"delimiter", 'F', "Delimiter to use in SQL statements supplied in file or command line.", (uchar**) &delimiter, (uchar**) &delimiter, 0, GET_STR, REQUIRED_ARG, @@ -636,7 +640,7 @@ static struct my_option my_long_options[] = static void print_version(void) { - printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname,SHOW_VERSION, + printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname, SLAP_VERSION, MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); } @@ -1090,6 +1094,10 @@ get_options(int *argc,char ***argv) DBUG_ENTER("get_options"); if ((ho_error= handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); + if (debug_info_flag) + my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; + if (debug_check_flag) + my_end_arg= MY_CHECK_ERROR; if (!user) user= (char *)"root"; diff --git a/client/mysqltest.c b/client/mysqltest.c index e5b9a2eaf12..cbe34bb6690 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -31,7 +31,7 @@ Holyfoot */ -#define MTEST_VERSION "3.2" +#define MTEST_VERSION "3.3" #include "client_priv.h" #include @@ -80,6 +80,7 @@ const char *opt_include= 0, *opt_charsets_dir; static int opt_port= 0; static int opt_max_connect_retries; static my_bool opt_compress= 0, silent= 0, verbose= 0; +static my_bool debug_info_flag= 0, debug_check_flag= 0; static my_bool tty_password= 0; static my_bool opt_mark_progress= 0; static my_bool ps_protocol= 0, ps_protocol_enabled= 0; @@ -100,6 +101,7 @@ static const char *load_default_groups[]= { "mysqltest", "client", 0 }; static char line_buffer[MAX_DELIMITER_LENGTH], *line_buffer_pos= line_buffer; static uint start_lineno= 0; /* Start line of current command */ +static uint my_end_arg= 0; static char delimiter[MAX_DELIMITER_LENGTH]= ";"; static uint delimiter_length= 1; @@ -807,12 +809,11 @@ void free_used_memory() static void cleanup_and_exit(int exit_code) { free_used_memory(); - my_end(MY_CHECK_ERROR); + my_end(my_end_arg | MY_CHECK_ERROR); if (!silent) { - switch (exit_code) - { + switch (exit_code) { case 1: printf("not ok\n"); break; @@ -4482,6 +4483,12 @@ static struct my_option my_long_options[] = {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif + {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .", + (uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", + (uchar**) &debug_info_flag, (uchar**) &debug_info_flag, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"host", 'h', "Connect to host.", (uchar**) &opt_host, (uchar**) &opt_host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"include", 'i', "Include SQL before each test case.", (uchar**) &opt_include, @@ -4724,6 +4731,10 @@ int parse_args(int argc, char **argv) opt_db= *argv; if (tty_password) opt_pass= get_tty_password(NullS); /* purify tested */ + if (debug_info_flag) + my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; + if (debug_check_flag) + my_end_arg= MY_CHECK_ERROR; return 0; } diff --git a/include/my_sys.h b/include/my_sys.h index c452bd21e15..76c9a7f02c7 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -150,7 +150,7 @@ extern ulonglong sf_malloc_mem_limit; #else #define my_checkmalloc() #undef TERMINATE -#define TERMINATE(A) {} +#define TERMINATE(A,B) {} #define QUICK_SAFEMALLOC #define NORMAL_SAFEMALLOC extern void *my_malloc(size_t Size,myf MyFlags); @@ -618,7 +618,7 @@ extern int nt_share_delete(const char *name,myf MyFlags); #endif #ifndef TERMINATE -extern void TERMINATE(FILE *file); +extern void TERMINATE(FILE *file, uint flag); #endif extern void init_glob_errs(void); extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags); diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 46d0c8f1037..b2f59ba2a5a 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -215,7 +215,7 @@ void STDCALL mysql_server_end() } static MYSQL_PARAMETERS mysql_internal_parameters= -{&max_allowed_packet, &net_buffer_length}; +{&max_allowed_packet, &net_buffer_length, 0}; MYSQL_PARAMETERS *STDCALL mysql_get_parameters(void) { diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 6ec4045bb43..c8f4bf5db1b 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1655,7 +1655,7 @@ sub generate_cmdline_mysqldump ($) { my($mysqld) = @_; return mtr_native_path($exe_mysqldump) . - " --no-defaults -uroot --debug-info " . + " --no-defaults -uroot --debug-check " . "--port=$mysqld->{'port'} " . "--socket=$mysqld->{'path_sock'} --password="; } @@ -1908,7 +1908,7 @@ sub environment_setup () { # ---------------------------------------------------- my $cmdline_mysqlcheck= mtr_native_path($exe_mysqlcheck) . - " --no-defaults --debug-info -uroot " . + " --no-defaults --debug-check -uroot " . "--port=$master->[0]->{'port'} " . "--socket=$master->[0]->{'path_sock'} --password="; @@ -1960,7 +1960,7 @@ sub environment_setup () { # ---------------------------------------------------- my $cmdline_mysqlimport= mtr_native_path($exe_mysqlimport) . - " -uroot --debug-info " . + " -uroot --debug-check " . "--port=$master->[0]->{'port'} " . "--socket=$master->[0]->{'path_sock'} --password="; @@ -1977,7 +1977,7 @@ sub environment_setup () { # ---------------------------------------------------- my $cmdline_mysqlshow= mtr_native_path($exe_mysqlshow) . - " -uroot --debug-info " . + " -uroot --debug-check " . "--port=$master->[0]->{'port'} " . "--socket=$master->[0]->{'path_sock'} --password="; @@ -1993,7 +1993,7 @@ sub environment_setup () { # ---------------------------------------------------- my $cmdline_mysqlbinlog= mtr_native_path($exe_mysqlbinlog) . - " --no-defaults --disable-force-if-open --debug-info"; + " --no-defaults --disable-force-if-open --debug-check"; if ( !$opt_extern && $mysql_version_id >= 50000 ) { $cmdline_mysqlbinlog .=" --character-sets-dir=$path_charsetsdir"; @@ -2011,7 +2011,7 @@ sub environment_setup () { # ---------------------------------------------------- my $cmdline_mysql= mtr_native_path($exe_mysql) . - " --no-defaults --debug-info --host=localhost --user=root --password= " . + " --no-defaults --debug-check --host=localhost --user=root --password= " . "--port=$master->[0]->{'port'} " . "--socket=$master->[0]->{'path_sock'} ". "--character-sets-dir=$path_charsetsdir"; diff --git a/mysys/my_getsystime.c b/mysys/my_getsystime.c index 17ba1232d7a..43bb6c08af9 100644 --- a/mysys/my_getsystime.c +++ b/mysys/my_getsystime.c @@ -17,11 +17,13 @@ /* thus to get the current time we should use the system function with the highest possible resolution */ +#include "mysys_priv.h" +#include "my_static.h" + #ifdef __NETWARE__ #include #endif -#include "mysys_priv.h" ulonglong my_getsystime() { #ifdef HAVE_CLOCK_GETTIME @@ -30,7 +32,6 @@ ulonglong my_getsystime() return (ulonglong)tp.tv_sec*10000000+(ulonglong)tp.tv_nsec/100; #elif defined(__WIN__) LARGE_INTEGER t_cnt; - struct timeval tv; if (query_performance_frequency) { QueryPerformanceCounter(&t_cnt); @@ -38,8 +39,7 @@ ulonglong my_getsystime() t_cnt.QuadPart % query_performance_frequency * 10000000/ query_performance_frequency+query_performance_offset); } - gettimeofday(&tv,NULL); - return (ulonglong)tv.tv_sec*10000000+(ulonglong)tv.tv_usec*10; + return 0; #elif defined(__NETWARE__) NXTime_t tm; NXGetTime(NX_SINCE_1970, NX_NSECONDS, &tm); @@ -62,26 +62,13 @@ ulonglong my_getsystime() */ -#define DELTA_FOR_SECONDS LL(500000000) /* Half a second */ - time_t my_time(myf flags __attribute__((unused))) { -#ifdef HAVE_GETHRTIME - static hrtime_t prev_gethrtime= 0; - static time_t cur_time= 0; - - hrtime_t cur_gethrtime; - pthread_mutex_lock(&THR_LOCK_time); - cur_gethrtime= gethrtime(); - if ((prev_gethrtime - cur_gethrtime) > DELTA_FOR_SECONDS) - { - cur_time= time(0); - prev_gethrtime= cur_gethrtime; - } - pthread_mutex_unlock(&THR_LOCK_time); - return cur_time; -#else time_t t; +#ifdef HAVE_GETHRTIME + (void) my_micro_time_and_time(&t); + return t; +#else /* The following loop is here beacuse time() may fail on some systems */ while ((t= time(0)) == (time_t) -1) { @@ -120,11 +107,12 @@ ulonglong my_micro_time() #if defined(__WIN__) if (query_performance_frequency) { - QueryPerformanceCounter(&newtime); + QueryPerformanceCounter((LARGE_INTEGER*) &newtime); newtime/= (query_performance_frequency * 1000000); } else - newtime= (GetTickCount() * 1000; /* GetTickCount only returns milliseconds */ + newtime= (GetTickCount() * 1000); /* GetTickCount only returns milliseconds */ + return newtime; #elif defined(HAVE_GETHRTIME) return gethrtime()/1000; #else @@ -133,13 +121,13 @@ ulonglong my_micro_time() while (gettimeofday(&t, NULL) != 0) {} newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec; -#endif /* defined(__WIN__) */ return newtime; +#endif /* defined(__WIN__) */ } /* - Return time in seconds and timer in microseconds + Return time in seconds and timer in microseconds (not different start!) SYNOPSIS my_micro_time_and_time() @@ -152,24 +140,48 @@ ulonglong my_micro_time() to measure the time of a query (for the slow query log) IMPLEMENTATION - Same as my_micro_time() + Value of time is as in time() call. + Value of microtime is same as my_micro_time(), which may be totally unrealated + to time() RETURN Value in microseconds from some undefined point in time */ +#define DELTA_FOR_SECONDS LL(500000000) /* Half a second */ + ulonglong my_micro_time_and_time(time_t *time_arg) { ulonglong newtime; #if defined(__WIN__) if (query_performance_frequency) { - QueryPerformanceCounter((LARGE_INTEGER *) &newtime); + QueryPerformanceCounter((LARGE_INTEGER*) &newtime); newtime/= (query_performance_frequency * 1000000); } else - newtime= (GetTickCount() * 1000; /* GetTickCount only returns milliseconds */ + newtime= (GetTickCount() * 1000); /* GetTickCount only returns milliseconds */ (void) time(time_arg); + return newtime; +#elif defined(HAVE_GETHRTIME) + /* + Solaris has a very slow time() call. We optimize this by using the very fast + gethrtime() call and only calling time() every 1/2 second + */ + static hrtime_t prev_gethrtime= 0; + static time_t cur_time= 0; + hrtime_t cur_gethrtime; + + pthread_mutex_lock(&THR_LOCK_time); + cur_gethrtime= gethrtime(); + if ((cur_gethrtime - prev_gethrtime) > DELTA_FOR_SECONDS) + { + cur_time= time(0); + prev_gethrtime= cur_gethrtime; + } + *time_arg= cur_time; + pthread_mutex_unlock(&THR_LOCK_time); + return cur_gethrtime/1000; #else struct timeval t; /* The following loop is here because gettimeofday may fail on some systems */ @@ -177,8 +189,8 @@ ulonglong my_micro_time_and_time(time_t *time_arg) {} *time_arg= t.tv_sec; newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec; -#endif /* defined(__WIN__) */ return newtime; +#endif /* defined(__WIN__) */ } diff --git a/mysys/my_init.c b/mysys/my_init.c index 8281d7ced99..127e94c958b 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -130,8 +130,9 @@ void my_end(int infoflag) */ FILE *info_file= DBUG_FILE; my_bool print_info= (info_file != stderr); - /* We do not use DBUG_ENTER here, as after cleanup DBUG is no longer - operational, so we cannot use DBUG_RETURN. + /* + We do not use DBUG_ENTER here, as after cleanup DBUG is no longer + operational, so we cannot use DBUG_RETURN. */ DBUG_PRINT("info",("Shutting down")); if (!info_file) @@ -185,7 +186,7 @@ Voluntary context switches %ld, Involuntary context switches %ld\n", fprintf(info_file,"\nRun time: %.1f\n",(double) clock()/CLOCKS_PER_SEC); #endif #if defined(SAFEMALLOC) - TERMINATE(stderr); /* Give statistic on screen */ + TERMINATE(stderr, 1); /* Give statistic on screen */ #elif defined(__WIN__) && defined(_MSC_VER) _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ); _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR ); @@ -197,6 +198,10 @@ Voluntary context switches %ld, Involuntary context switches %ld\n", _CrtDumpMemoryLeaks(); #endif } + else if (infoflag & MY_CHECK_ERROR) + { + TERMINATE(stderr, 0); /* Print memory leaks on screen */ + } if (!(infoflag & MY_DONT_FREE_DBUG)) { diff --git a/mysys/my_static.c b/mysys/my_static.c index 92c959c4c6c..b8bff0e9810 100644 --- a/mysys/my_static.c +++ b/mysys/my_static.c @@ -18,11 +18,9 @@ a shared library */ -#if !defined(stdin) #include "mysys_priv.h" #include "my_static.h" #include "my_alarm.h" -#endif my_bool timed_mutexes= 0; diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c index 30c501c54ee..7a2f448b2dc 100644 --- a/mysys/safemalloc.c +++ b/mysys/safemalloc.c @@ -51,7 +51,7 @@ (equivalent to realloc()) FREE( pPtr ) Free memory allocated by NEW (equivalent to free()) - TERMINATE(file) End system, report errors and stats on file + TERMINATE(file,flag) End system, report errors and stats on file I personally use two more functions, but have not included them here: char *STRSAVE( sPtr ) Save a copy of the string in dynamic memory char *RENEW( pPtr, uSize ) @@ -352,12 +352,15 @@ static int check_ptr(const char *where, uchar *ptr, const char *filename, /* - TERMINATE(FILE *file) - Report on all the memory pieces that have not been - free'ed as well as the statistics. + Report on all the memory pieces that have not been free'ed + + SYNOPSIS + TERMINATE() + file Write output to this file + flag If <> 0, also write statistics */ -void TERMINATE(FILE *file) +void TERMINATE(FILE *file, uint flag) { struct st_irem *irem; DBUG_ENTER("TERMINATE"); @@ -373,8 +376,7 @@ void TERMINATE(FILE *file) { if (file) { - fprintf(file, "Warning: Not freed memory segments: %u\n", - sf_malloc_count); + fprintf(file, "Warning: Not freed memory segments: %u\n", sf_malloc_count); (void) fflush(file); } DBUG_PRINT("safe",("sf_malloc_count: %u", sf_malloc_count)); @@ -414,7 +416,7 @@ void TERMINATE(FILE *file) } } /* Report the memory usage statistics */ - if (file) + if (file && flag) { fprintf(file, "Maximum memory usage: %ld bytes (%ldk)\n", sf_malloc_max_memory, (sf_malloc_max_memory + 1023L) / 1024L); diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index 6bc73f49a5a..067af930d6f 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -2767,9 +2767,9 @@ String *Item_xml_str_func::parse_xml(String *raw_xml, String *parsed_xml_buf) if ((rc= my_xml_parse(&p, raw_xml->ptr(), raw_xml->length())) != MY_XML_OK) { char buf[128]; - my_snprintf(buf, sizeof(buf)-1, "parse error at line %d pos %u: %s", + my_snprintf(buf, sizeof(buf)-1, "parse error at line %d pos %lu: %s", my_xml_error_lineno(&p) + 1, - my_xml_error_pos(&p) + 1, + (ulong) my_xml_error_pos(&p) + 1, my_xml_error_string(&p)); push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WRONG_VALUE, diff --git a/sql/sql_test.cc b/sql/sql_test.cc index 5bd01eea68c..0fe299d4505 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -509,7 +509,7 @@ Next alarm time: %lu\n", fflush(stdout); my_checkmalloc(); fprintf(stdout,"\nBegin safemalloc memory dump:\n"); // tag needed for test suite - TERMINATE(stdout); // Write malloc information + TERMINATE(stdout, 1); // Write malloc information fprintf(stdout,"\nEnd safemalloc memory dump.\n"); #ifdef HAVE_MALLINFO diff --git a/unittest/mysys/base64-t.c b/unittest/mysys/base64-t.c index 7e4afbb3128..1622fe22b4d 100644 --- a/unittest/mysys/base64-t.c +++ b/unittest/mysys/base64-t.c @@ -14,6 +14,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +#include #include #include #include @@ -26,6 +27,7 @@ main(void) { int i, cmp; size_t j, k, l, dst_len, needed_length; + MY_INIT("base64-t"); plan(BASE64_LOOP_COUNT * BASE64_ROWS); diff --git a/unittest/mysys/bitmap-t.c b/unittest/mysys/bitmap-t.c index 779508ee228..069a14ff553 100644 --- a/unittest/mysys/bitmap-t.c +++ b/unittest/mysys/bitmap-t.c @@ -18,12 +18,11 @@ library. */ -#include - #include +#include #include - -#include +#include +#include uint get_rand_bit(uint bitsize) { @@ -379,6 +378,8 @@ int main() int i; int const min_size = 1; int const max_size = 1024; + MY_INIT("bitmap-t"); + plan(max_size - min_size); for (i= min_size; i < max_size; i++) ok(do_test(i) == 0, "bitmap size %d", i); diff --git a/unittest/mysys/my_atomic-t.c b/unittest/mysys/my_atomic-t.c index 8280aff5422..a9e98a95cdb 100644 --- a/unittest/mysys/my_atomic-t.c +++ b/unittest/mysys/my_atomic-t.c @@ -14,9 +14,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include -#include #include #include +#include int32 a32,b32,c32; my_atomic_rwlock_t rwl; @@ -160,6 +160,7 @@ err: int main() { int err; + MY_INIT("my_atomic-t.c"); diag("N CPUs: %d", my_getncpus()); err= my_atomic_initialize(); From 586304c814c8993b3f24b840859db6714b08b9d3 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Aug 2007 03:32:54 +0400 Subject: [PATCH 15/74] Add a test case for Bug#18287 create federated table always times out, error 1159 ' ' (fixed by the patch for Bug 25679) mysql-test/r/federated.result: Update results (Bug#18287) mysql-test/t/federated.test: Add a test case for Bug#18287 create federated table always times out, error 1159 ' ' --- mysql-test/r/federated.result | 14 ++++++++++++++ mysql-test/t/federated.test | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/mysql-test/r/federated.result b/mysql-test/r/federated.result index f4750fed201..c6884216e56 100644 --- a/mysql-test/r/federated.result +++ b/mysql-test/r/federated.result @@ -1883,6 +1883,20 @@ a b 2 Curly drop table federated.t1; drop table federated.t1; + +Bug#18287 create federated table always times out, error 1159 ' ' + +Test that self-references work + +create table federated.t1 (a int primary key); +create table federated.t2 (a int primary key) +ENGINE=FEDERATED +connection='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1'; +insert into federated.t1 (a) values (1); +select * from federated.t2; +a +1 +drop table federated.t1, federated.t2; DROP TABLE IF EXISTS federated.t1; DROP DATABASE IF EXISTS federated; DROP TABLE IF EXISTS federated.t1; diff --git a/mysql-test/t/federated.test b/mysql-test/t/federated.test index a3750cb572d..59cd4f3e6a6 100644 --- a/mysql-test/t/federated.test +++ b/mysql-test/t/federated.test @@ -1631,5 +1631,19 @@ drop table federated.t1; connection slave; drop table federated.t1; +--echo +--echo Bug#18287 create federated table always times out, error 1159 ' ' +--echo +--echo Test that self-references work +--echo +connection slave; +create table federated.t1 (a int primary key); +--replace_result $SLAVE_MYPORT SLAVE_PORT +eval create table federated.t2 (a int primary key) + ENGINE=FEDERATED + connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; +insert into federated.t1 (a) values (1); +select * from federated.t2; +drop table federated.t1, federated.t2; source include/federated_cleanup.inc; From f9ea427508fa5451bd22c0d6366a855a4d88800d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Aug 2007 07:49:29 +0300 Subject: [PATCH 16/74] Set --debug-check if one uses DBUG_PUSH in all clients Fixed bug in query cache that made it impossible to run mysqld with --debug Fixed memory leaks in mysqldump and mysqltest Memory leaks associated with wrong usage of mysqltest is not fixed. To find these, run mysql-test-run --debug mysqltest client/mysql_upgrade.c: Set --debug-check if one uses DBUG_PUSH client/mysqlcheck.c: Set --debug-check if one uses DBUG_PUSH client/mysqldump.c: Set --debug-check if one uses DBUG_PUSH Fixed several memory leaks client/mysqlimport.c: Set --debug-check if one uses DBUG_PUSH client/mysqlshow.c: Set --debug-check if one uses DBUG_PUSH client/mysqlslap.c: Set --debug-check if one uses DBUG_PUSH client/mysqltest.c: Set --debug-check if one uses DBUG_PUSH Fixed some memory leaks Removed MY_CHECK_ERROR argument to my_end() as mysqltest.test otherwise shows MANY memory leaks dbug/dbug.c: Fixed compiler warning Force flush of out_file on end Removed some wrong dbug_flush(0) commands that could cause crashes mysys/my_init.c: Don't write memory usage if MY_GIVE_INFO is not given sql/sql_cache.cc: Fixed bug in query cache that made it impossible to run mysqld with --debug --- client/mysql_upgrade.c | 1 + client/mysqlcheck.c | 1 + client/mysqldump.c | 56 ++++++++++++++++++++++++++++++++---------- client/mysqlimport.c | 1 + client/mysqlshow.c | 1 + client/mysqlslap.c | 1 + client/mysqltest.c | 24 ++++++++++-------- dbug/dbug.c | 7 +++--- mysys/my_init.c | 6 ++--- sql/sql_cache.cc | 7 +++--- 10 files changed, 72 insertions(+), 33 deletions(-) diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 6611a74ea7f..5da0235c913 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -218,6 +218,7 @@ get_one_option(int optid, const struct my_option *opt, case '#': DBUG_PUSH(argument ? argument : default_dbug_option); add_option= FALSE; + debug_check_flag= 1; break; case 'p': diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 622975c51d5..ee8d5c0d6d3 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -310,6 +310,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case '#': DBUG_PUSH(argument ? argument : "d:t:o"); + debug_check_flag= 1; break; #include case OPT_TABLES: diff --git a/client/mysqldump.c b/client/mysqldump.c index 60252be0910..c55ca4577b9 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -729,7 +729,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case '#': DBUG_PUSH(argument ? argument : default_dbug_option); - debug_info_flag= 1; + debug_check_flag= 1; break; #include case 'V': print_version(); exit(0); @@ -2070,7 +2070,6 @@ static uint get_table_structure(char *table, char *db, char *table_type, int len; MYSQL_RES *result; MYSQL_ROW row; - DBUG_ENTER("get_table_structure"); DBUG_PRINT("enter", ("db: %s table: %s", db, table)); @@ -2472,6 +2471,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, fprintf(sql_file, " (%s)",row[7]); /* Sub key */ check_io(sql_file); } + mysql_free_result(result); if (!opt_xml) { if (keynr) @@ -2813,7 +2813,7 @@ static void dump_table(char *table, char *db) /* The "table" could be a view. If so, we don't do anything here. */ - if (strcmp (table_type, "VIEW") == 0) + if (strcmp(table_type, "VIEW") == 0) DBUG_VOID_RETURN; /* Check --no-data flag */ @@ -2903,6 +2903,7 @@ static void dump_table(char *table, char *db) if (mysql_real_query(mysql, query_string.str, query_string.length)) { DB_error(mysql, "when executing 'SELECT INTO OUTFILE'"); + dynstr_free(&query_string); DBUG_VOID_RETURN; } } @@ -3257,8 +3258,8 @@ static void dump_table(char *table, char *db) check_io(md_result_file); } mysql_free_result(res); - dynstr_free(&query_string); } + dynstr_free(&query_string); DBUG_VOID_RETURN; err: @@ -3379,6 +3380,7 @@ static int dump_tablespaces(char* ts_where) char extra_format[]= "UNDO_BUFFER_SIZE="; char *ubs; char *endsemi; + DBUG_ENTER("dump_tablespaces"); init_dynamic_string_checked(&sqlbuf, "SELECT LOGFILE_GROUP_NAME," @@ -3410,6 +3412,7 @@ static int dump_tablespaces(char* ts_where) if (mysql_query(mysql, sqlbuf.str) || !(tableres = mysql_store_result(mysql))) { + dynstr_free(&sqlbuf); if (mysql_errno(mysql) == ER_BAD_TABLE_ERROR || mysql_errno(mysql) == ER_BAD_DB_ERROR || mysql_errno(mysql) == ER_UNKNOWN_TABLE) @@ -3418,12 +3421,12 @@ static int dump_tablespaces(char* ts_where) "\n--\n-- Not dumping tablespaces as no INFORMATION_SCHEMA.FILES" " table on this server\n--\n"); check_io(md_result_file); - return 0; + DBUG_RETURN(0); } - my_printf_error(0, "Error: Couldn't dump tablespaces %s", + my_printf_error(0, "Error: '%s' when trying to dump tablespaces", MYF(0), mysql_error(mysql)); - return 1; + DBUG_RETURN(1); } buf[0]= 0; @@ -3475,6 +3478,7 @@ static int dump_tablespaces(char* ts_where) } } dynstr_free(&sqlbuf); + mysql_free_result(tableres); init_dynamic_string_checked(&sqlbuf, "SELECT DISTINCT TABLESPACE_NAME," " FILE_NAME," @@ -3492,7 +3496,10 @@ static int dump_tablespaces(char* ts_where) dynstr_append_checked(&sqlbuf, " ORDER BY TABLESPACE_NAME, LOGFILE_GROUP_NAME"); if (mysql_query_with_error_report(mysql, &tableres, sqlbuf.str)) - return 1; + { + dynstr_free(&sqlbuf); + DBUG_RETURN(1); + } buf[0]= 0; while ((row= mysql_fetch_row(tableres))) @@ -3538,8 +3545,9 @@ static int dump_tablespaces(char* ts_where) } } + mysql_free_result(tableres); dynstr_free(&sqlbuf); - return 0; + DBUG_RETURN(0); } static int dump_all_databases() @@ -3626,8 +3634,11 @@ RETURN VALUES 0 Success. 1 Failure. */ + int init_dumping_tables(char *qdatabase) { + DBUG_ENTER("init_dumping_tables"); + if (!opt_create_db) { char qbuf[256]; @@ -3660,10 +3671,10 @@ int init_dumping_tables(char *qdatabase) { fprintf(md_result_file,"\n%s;\n",row[1]); } + mysql_free_result(dbinfo); } } - - return 0; + DBUG_RETURN(0); } /* init_dumping_tables */ @@ -3931,8 +3942,13 @@ static int dump_selected_tables(char *db, char **table_names, int tables) } else { - maybe_die(EX_ILLEGAL_TABLE, "Couldn't find table: \"%s\"", *table_names); - /* We shall countinue here, if --force was given */ + if (!ignore_errors) + { + dynstr_free(&lock_tables_query); + free_root(&root, MYF(0)); + } + maybe_die(EX_ILLEGAL_TABLE, "Couldn't find table: \"%s\"", *table_names); + /* We shall countinue here, if --force was given */ } } end= pos; @@ -3941,14 +3957,25 @@ static int dump_selected_tables(char *db, char **table_names, int tables) { if (mysql_real_query(mysql, lock_tables_query.str, lock_tables_query.length-1)) + { + if (!ignore_errors) + { + dynstr_free(&lock_tables_query); + free_root(&root, MYF(0)); + } DB_error(mysql, "when doing LOCK TABLES"); /* We shall countinue here, if --force was given */ + } } dynstr_free(&lock_tables_query); if (flush_logs) { if (mysql_refresh(mysql, REFRESH_LOG)) + { + if (!ignore_errors) + free_root(&root, MYF(0)); DB_error(mysql, "when doing refresh"); + } /* We shall countinue here, if --force was given */ } if (opt_xml) @@ -4511,6 +4538,9 @@ static my_bool get_view_structure(char *table, char* db) if (!(table_res= mysql_store_result(mysql)) || !(row= mysql_fetch_row(table_res))) { + if (table_res) + mysql_free_result(table_res); + dynstr_free(&ds_view); DB_error(mysql, "when trying to save the result of SHOW CREATE TABLE in ds_view."); DBUG_RETURN(1); } diff --git a/client/mysqlimport.c b/client/mysqlimport.c index b09ae7a172a..afd9454d6be 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -240,6 +240,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case '#': DBUG_PUSH(argument ? argument : "d:t:o"); + debug_check_flag= 1; break; #include case 'V': print_version(); exit(0); diff --git a/client/mysqlshow.c b/client/mysqlshow.c index fb89589f3e1..a7f6cadf450 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -299,6 +299,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case '#': DBUG_PUSH(argument ? argument : "d:t:o"); + debug_check_flag= 1; break; #include case 'V': diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 33173858228..709b70a9952 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -699,6 +699,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case '#': DBUG_PUSH(argument ? argument : default_dbug_option); + debug_check_flag= 1; break; #include case 'V': diff --git a/client/mysqltest.c b/client/mysqltest.c index cbe34bb6690..7ba57f7515c 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -809,10 +809,9 @@ void free_used_memory() static void cleanup_and_exit(int exit_code) { free_used_memory(); - my_end(my_end_arg | MY_CHECK_ERROR); + my_end(my_end_arg); - if (!silent) - { + if (!silent) { switch (exit_code) { case 1: printf("not ok\n"); @@ -1085,8 +1084,7 @@ void check_result(DYNAMIC_STRING* ds) DBUG_ENTER("check_result"); DBUG_ASSERT(result_file_name); - switch (dyn_string_cmp(ds, result_file_name)) - { + switch (dyn_string_cmp(ds, result_file_name)) { case RESULT_OK: break; /* ok */ case RESULT_LENGTH_MISMATCH: @@ -1930,7 +1928,10 @@ void do_exec(struct st_command *command) command->first_argument, ds_cmd.str)); if (!(res_file= my_popen(&ds_cmd, "r")) && command->abort_on_error) + { + dynstr_free(&ds_cmd); die("popen(\"%s\", \"r\") failed", command->first_argument); + } while (fgets(buf, sizeof(buf), res_file)) { @@ -1954,6 +1955,7 @@ void do_exec(struct st_command *command) { log_msg("exec of '%s failed, error: %d, status: %d, errno: %d", ds_cmd.str, error, status, errno); + dynstr_free(&ds_cmd); die("command \"%s\" failed", command->first_argument); } @@ -1972,8 +1974,11 @@ void do_exec(struct st_command *command) } } if (!ok) + { + dynstr_free(&ds_cmd); die("command \"%s\" failed with wrong error: %d", command->first_argument, status); + } } else if (command->expected_errors.err[0].type == ERR_ERRNO && command->expected_errors.err[0].code.errnum != 0) @@ -1981,6 +1986,7 @@ void do_exec(struct st_command *command) /* Error code we wanted was != 0, i.e. not an expected success */ log_msg("exec of '%s failed, error: %d, errno: %d", ds_cmd.str, error, errno); + dynstr_free(&ds_cmd); die("command \"%s\" succeeded - should have failed with errno %d...", command->first_argument, command->expected_errors.err[0].code.errnum); } @@ -4632,6 +4638,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case '#': #ifndef DBUG_OFF DBUG_PUSH(argument ? argument : "d:t:S:i:O,/tmp/mysqltest.trace"); + debug_check_flag= 1; #endif break; case 'r': @@ -5388,11 +5395,8 @@ end: ds - dynamic string which is used for output buffer NOTE - If there is an unexpected error this function will abort mysqltest - immediately. - - RETURN VALUE - error - function will not return + If there is an unexpected error this function will abort mysqltest + immediately. */ void handle_error(struct st_command *command, diff --git a/dbug/dbug.c b/dbug/dbug.c index 83c9ea37de1..9d638c299d3 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -1184,7 +1184,7 @@ void _db_dump_(uint _line_, const char *keyword, fprintf(cs->stack->out_file, "%s: ", cs->func); } sprintf(dbuff,"%s: Memory: 0x%lx Bytes: (%ld)\n", - keyword,(ulong) memory, length); + keyword, (ulong) memory, (long) length); (void) fputs(dbuff,cs->stack->out_file); pos=0; @@ -1449,6 +1449,7 @@ static void FreeState(CODE_STATE *cs, struct settings *state, int free_state) FreeList(state->p_functions); if (!is_shared(state, out_file)) DBUGCloseFile(cs, state->out_file); + (void) fflush(cs->stack->out_file); if (state->prof_file) DBUGCloseFile(cs, state->prof_file); if (free_state) @@ -1882,7 +1883,6 @@ static FILE *OpenProfile(CODE_STATE *cs, const char *name) { (void) fprintf(cs->stack->out_file, ERR_OPEN, cs->process, name); perror(""); - dbug_flush(0); (void) Delay(cs->stack->delay); } else @@ -1892,7 +1892,6 @@ static FILE *OpenProfile(CODE_STATE *cs, const char *name) { (void) fprintf(cs->stack->out_file, ERR_OPEN, cs->process, name); perror(""); - dbug_flush(0); } else { @@ -1931,7 +1930,7 @@ static void DBUGCloseFile(CODE_STATE *cs, FILE *fp) pthread_mutex_lock(&THR_LOCK_dbug); (void) fprintf(cs->stack->out_file, ERR_CLOSE, cs->process); perror(""); - dbug_flush(0); + dbug_flush(cs); } } diff --git a/mysys/my_init.c b/mysys/my_init.c index 127e94c958b..257edb351b4 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -134,14 +134,14 @@ void my_end(int infoflag) We do not use DBUG_ENTER here, as after cleanup DBUG is no longer operational, so we cannot use DBUG_RETURN. */ - DBUG_PRINT("info",("Shutting down")); + DBUG_PRINT("info",("Shutting down: infoflag: %d print_info: %d", + infoflag, print_info)); if (!info_file) { info_file= stderr; print_info= 0; } - DBUG_PRINT("info",("Shutting down: print_info: %d", print_info)); if ((infoflag & MY_CHECK_ERROR) || print_info) { /* Test if some file is left open */ @@ -186,7 +186,7 @@ Voluntary context switches %ld, Involuntary context switches %ld\n", fprintf(info_file,"\nRun time: %.1f\n",(double) clock()/CLOCKS_PER_SEC); #endif #if defined(SAFEMALLOC) - TERMINATE(stderr, 1); /* Give statistic on screen */ + TERMINATE(stderr, (infoflag & MY_GIVE_INFO) != 0); #elif defined(__WIN__) && defined(_MSC_VER) _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ); _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR ); diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index cab9ef94d6d..ea73046ff17 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -862,6 +862,7 @@ Query_cache::Query_cache(ulong query_cache_limit_arg, ulong Query_cache::resize(ulong query_cache_size_arg) { + ulong new_query_cache_size; DBUG_ENTER("Query_cache::resize"); DBUG_PRINT("qcache", ("from %lu to %lu",query_cache_size, query_cache_size_arg)); @@ -876,13 +877,13 @@ ulong Query_cache::resize(ulong query_cache_size_arg) free_cache(); query_cache_size= query_cache_size_arg; - ulong new_query_cache_size= init_cache(); - - DBUG_EXECUTE("check_querycache",check_integrity(0);); + new_query_cache_size= init_cache(); STRUCT_LOCK(&structure_guard_mutex); m_cache_status= Query_cache::NO_FLUSH_IN_PROGRESS; pthread_cond_signal(&COND_cache_status_changed); + if (new_query_cache_size) + DBUG_EXECUTE("check_querycache",check_integrity(1);); STRUCT_UNLOCK(&structure_guard_mutex); DBUG_RETURN(new_query_cache_size); From dcf1fd73d9e35767ad19783a35ce92648e933f0a Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Aug 2007 10:50:00 +0300 Subject: [PATCH 17/74] Don't save & restore time fields from thd when it's not needed. Added back setting of 'some_tables_deleted' to not cause deadlocks in mysql_lock_table() BitKeeper/etc/ignore: added tests/bug25714 sql/lock.cc: Added comment sql/log.cc: Don't save & restore time fields from thd when it's not needed. Fix that we properly detect if open table failed sql/sql_base.cc: Added back setting of 'some_tables_deleted' to not cause deadlocks in mysql_lock_table() --- .bzrignore | 1 + sql/lock.cc | 4 ++++ sql/log.cc | 48 ++++++++++-------------------------------------- sql/sql_base.cc | 6 ++++++ 4 files changed, 21 insertions(+), 38 deletions(-) diff --git a/.bzrignore b/.bzrignore index fdcbc3b262b..0ffc430a578 100644 --- a/.bzrignore +++ b/.bzrignore @@ -2996,3 +2996,4 @@ win/vs8cache.txt zlib/*.ds? zlib/*.vcproj support-files/mysqld_multi.server +tests/bug25714 diff --git a/sql/lock.cc b/sql/lock.cc index 8e13c42d6d4..20fb7d73c1c 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -290,6 +290,10 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, } else if (!thd->some_tables_deleted || (flags & MYSQL_LOCK_IGNORE_FLUSH)) { + /* + Thread was killed or lock aborted. Let upper level close all + used tables and retry or give error. + */ thd->locked=0; break; } diff --git a/sql/log.cc b/sql/log.cc index c5c84cfb11f..c7e122462e6 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -323,20 +323,11 @@ bool Log_to_csv_event_handler:: Field_timestamp *field0; ulonglong save_thd_options; bool save_query_start_used; - time_t save_start_time; - time_t save_time_after_lock; - time_t save_user_time; - bool save_time_zone_used; + save_query_start_used= thd->query_start_used; // Because of field->set_time() save_thd_options= thd->options; thd->options&= ~OPTION_BIN_LOG; - save_query_start_used= thd->query_start_used; - save_start_time= thd->start_time; - save_time_after_lock= thd->time_after_lock; - save_user_time= thd->user_time; - save_time_zone_used= thd->time_zone_used; - bzero(& table_list, sizeof(TABLE_LIST)); table_list.alias= table_list.table_name= GENERAL_LOG_NAME.str; table_list.table_name_length= GENERAL_LOG_NAME.length; @@ -346,12 +337,13 @@ bool Log_to_csv_event_handler:: table_list.db= MYSQL_SCHEMA_NAME.str; table_list.db_length= MYSQL_SCHEMA_NAME.length; - table= open_performance_schema_table(thd, & table_list, - & open_tables_backup); + if (!(table= open_performance_schema_table(thd, & table_list, + & open_tables_backup))) + goto err; + need_close= TRUE; - if (!table || - table->file->extra(HA_EXTRA_MARK_AS_LOG_TABLE) || + if (table->file->extra(HA_EXTRA_MARK_AS_LOG_TABLE) || table->file->ha_rnd_init(0)) goto err; @@ -434,12 +426,7 @@ err: close_performance_schema_table(thd, & open_tables_backup); thd->options= save_thd_options; - thd->query_start_used= save_query_start_used; - thd->start_time= save_start_time; - thd->time_after_lock= save_time_after_lock; - thd->user_time= save_user_time; - thd->time_zone_used= save_time_zone_used; return result; } @@ -485,11 +472,6 @@ bool Log_to_csv_event_handler:: bool need_close= FALSE; bool need_rnd_end= FALSE; Open_tables_state open_tables_backup; - bool save_query_start_used; - time_t save_start_time; - time_t save_time_after_lock; - time_t save_user_time; - bool save_time_zone_used; CHARSET_INFO *client_cs= thd->variables.character_set_client; DBUG_ENTER("Log_to_csv_event_handler::log_slow"); @@ -502,18 +484,13 @@ bool Log_to_csv_event_handler:: table_list.db= MYSQL_SCHEMA_NAME.str; table_list.db_length= MYSQL_SCHEMA_NAME.length; - save_query_start_used= thd->query_start_used; - save_start_time= thd->start_time; - save_time_after_lock= thd->time_after_lock; - save_user_time= thd->user_time; - save_time_zone_used= thd->time_zone_used; + if (!(table= open_performance_schema_table(thd, & table_list, + & open_tables_backup))) + goto err; - table= open_performance_schema_table(thd, & table_list, - & open_tables_backup); need_close= TRUE; - if (!table || - table->file->extra(HA_EXTRA_MARK_AS_LOG_TABLE) || + if (table->file->extra(HA_EXTRA_MARK_AS_LOG_TABLE) || table->file->ha_rnd_init(0)) goto err; @@ -635,11 +612,6 @@ err: if (need_close) close_performance_schema_table(thd, & open_tables_backup); - thd->query_start_used= save_query_start_used; - thd->start_time= save_start_time; - thd->time_after_lock= save_time_after_lock; - thd->user_time= save_user_time; - thd->time_zone_used= save_time_zone_used; DBUG_RETURN(result); } diff --git a/sql/sql_base.cc b/sql/sql_base.cc index cf3ef111780..28ce23ccd1a 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -7198,6 +7198,12 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name, else if (in_use != thd) { DBUG_PRINT("info", ("Table was in use by other thread")); + /* + Mark that table is going to be deleted from cache. This will + force threads that are in mysql_lock_tables() (but not yet + in thr_multi_lock()) to abort it's locks, close all tables and retry + */ + in_use->some_tables_deleted= 1; if (table->is_name_opened()) { DBUG_PRINT("info", ("Found another active instance of the table")); From 8277581b8952d0c3cde2069de1afbc8afbb9e3f2 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Aug 2007 12:35:05 +0300 Subject: [PATCH 18/74] Addendum to bug 29325 keep_files_on_create made a startup option sql/mysqld.cc: Addendum to bug #29325 keep_files_on_create made a startup option --- sql/mysqld.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 61980fa1887..0a860f84b57 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4828,7 +4828,8 @@ enum options_mysqld OPT_PORT_OPEN_TIMEOUT, OPT_MERGE, OPT_INNODB_ROLLBACK_ON_TIMEOUT, - OPT_SECURE_FILE_PRIV + OPT_SECURE_FILE_PRIV, + OPT_KEEP_FILES_ON_CREATE }; @@ -5830,6 +5831,11 @@ log and this option does nothing anymore.", (gptr*) &max_system_variables.join_buff_size, 0, GET_ULONG, REQUIRED_ARG, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD, IO_SIZE, 0}, + {"keep_files_on_create", OPT_KEEP_FILES_ON_CREATE, + "Don't overwrite stale .MYD and .MYI even if no directory is specified.", + (gptr*) &global_system_variables.keep_files_on_create, + (gptr*) &max_system_variables.keep_files_on_create, + 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"key_buffer_size", OPT_KEY_BUFFER_SIZE, "The size of the buffer used for index blocks for MyISAM tables. Increase this to get better index handling (for all reads and multiple writes) to as much as you can afford; 64M on a 256M machine that mainly runs MySQL is quite common.", (gptr*) &dflt_key_cache_var.param_buff_size, From 38af61e9f903545e70fb2523431ac1f439742b35 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Aug 2007 13:59:02 +0400 Subject: [PATCH 19/74] Add a test case for Bug#5719 "impossible to lock VIEW". It has been possible to lock a view in 5.1 for some time. mysql-test/r/lock.result: Update results (Bug#5719) mysql-test/t/lock.test: Add a test case for Bug#5719 "impossible to lock VIEW" --- mysql-test/r/lock.result | 70 ++++++++++++++++++++++++++++++++++++++++ mysql-test/t/lock.test | 65 +++++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) diff --git a/mysql-test/r/lock.result b/mysql-test/r/lock.result index e2000a9ec91..6152e403637 100644 --- a/mysql-test/r/lock.result +++ b/mysql-test/r/lock.result @@ -96,4 +96,74 @@ ERROR HY000: You can't combine write-locking of system tables with other tables LOCK TABLES mysql.time_zone READ, mysql.proc WRITE; ERROR HY000: You can't combine write-locking of system tables with other tables or lock types DROP TABLE t1; + +Bug#5719 impossible to lock VIEW + +Just covering existing behaviour with tests. +Consistency has not been found here. + +drop view if exists v_bug5719; +drop table if exists t1, t2, t3; +create table t1 (a int); +create temporary table t2 (a int); +create table t3 (a int); +create view v_bug5719 as select 1; +lock table v_bug5719 write; +select * from t1; +ERROR HY000: Table 't1' was not locked with LOCK TABLES + +Allowed to select from a temporary talbe under LOCK TABLES + +select * from t2; +a +select * from t3; +ERROR HY000: Table 't3' was not locked with LOCK TABLES +select * from v_bug5719; +1 +1 +drop view v_bug5719; + +sic: did not left LOCK TABLES mode automatically + +select * from t1; +ERROR HY000: Table 't1' was not locked with LOCK TABLES +unlock tables; +create view v_bug5719 as select * from t1; +lock tables v_bug5719 write; +select * from v_bug5719; +a + +Allowed to use an underlying table under LOCK TABLES + +select * from t1; +a + +Allowed to select from a temporary table under LOCK TABLES + +select * from t2; +a +select * from t3; +ERROR HY000: Table 't3' was not locked with LOCK TABLES +drop table t1; + +sic: left LOCK TABLES mode + +select * from t3; +a +select * from v_bug5719; +ERROR HY000: View 'test.v_bug5719' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +unlock tables; +drop view v_bug5719; + +When limitation to use temporary tables in views is removed, please +add a test that shows what happens under LOCK TABLES when a view +references a temporary table, is locked, and the underlying table +is dropped. + +create view v_bug5719 as select * from t2; +ERROR HY000: View's SELECT refers to a temporary table 't2' + +Cleanup. + +drop table t2, t3; End of 5.1 tests. diff --git a/mysql-test/t/lock.test b/mysql-test/t/lock.test index 2b8b430f096..6069bbf7018 100644 --- a/mysql-test/t/lock.test +++ b/mysql-test/t/lock.test @@ -148,5 +148,70 @@ LOCK TABLES mysql.time_zone READ, mysql.proc WRITE; DROP TABLE t1; +--echo +--echo Bug#5719 impossible to lock VIEW +--echo +--echo Just covering existing behaviour with tests. +--echo Consistency has not been found here. +--echo +--disable_warnings +drop view if exists v_bug5719; +drop table if exists t1, t2, t3; +--enable_warnings +create table t1 (a int); +create temporary table t2 (a int); +create table t3 (a int); +create view v_bug5719 as select 1; +lock table v_bug5719 write; +--error ER_TABLE_NOT_LOCKED +select * from t1; +--echo +--echo Allowed to select from a temporary talbe under LOCK TABLES +--echo +select * from t2; +--error ER_TABLE_NOT_LOCKED +select * from t3; +select * from v_bug5719; +drop view v_bug5719; +--echo +--echo sic: did not left LOCK TABLES mode automatically +--echo +--error ER_TABLE_NOT_LOCKED +select * from t1; +unlock tables; +create view v_bug5719 as select * from t1; +lock tables v_bug5719 write; +select * from v_bug5719; +--echo +--echo Allowed to use an underlying table under LOCK TABLES +--echo +select * from t1; +--echo +--echo Allowed to select from a temporary table under LOCK TABLES +--echo +select * from t2; +--error ER_TABLE_NOT_LOCKED +select * from t3; +drop table t1; +--echo +--echo sic: left LOCK TABLES mode +--echo +select * from t3; +--error ER_VIEW_INVALID +select * from v_bug5719; +unlock tables; +drop view v_bug5719; +--echo +--echo When limitation to use temporary tables in views is removed, please +--echo add a test that shows what happens under LOCK TABLES when a view +--echo references a temporary table, is locked, and the underlying table +--echo is dropped. +--echo +--error ER_VIEW_SELECT_TMPTABLE +create view v_bug5719 as select * from t2; +--echo +--echo Cleanup. +--echo +drop table t2, t3; --echo End of 5.1 tests. From def8d6b36399708c7e1dd28d13178b303ed14d14 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Aug 2007 12:49:27 +0200 Subject: [PATCH 20/74] CMakeLists.txt (several), make_win_bin_dist: Aligned client library build and use with the Unix version when it comes to what source to include directly in the builds, and what libraries to link with (bug#30118). Also reviewed, corrected and made more clear when static or dynamic Thread Local Storage is to be used. Some code duplication was removed, and some redundant library usage were removed, reducing the risk of incorrect TLS usage. client/CMakeLists.txt: - Removed code duplication by moving build of "mysqlclient" to the "libmysql" directory - Link clients with the new "mysqlclient_notls", to protect for the case the clients use more than the client API, and access thread data directly. - Synced explicit target addition of sources with Unix. dbug/CMakeLists.txt: No need to set CXX flags, no C++ code libmysql/CMakeLists.txt: - Aligned more with Unix version when it comes to included source files - Build both DLL and static library in this directory - Produce separe static TLS version of the static client library, for use when building clients in this build that might access TLS storage directly. mysys/CMakeLists.txt: We only have to build the static TLS version, as no clients are linking directly with the "mysys" library. scripts/make_win_bin_dist: Ajusted paths to new "mysqlclient.lib" location in source tree sql/CMakeLists.txt: Removed duplicate "ha_blackhole.cc" in file listing Removed explicit link to "dbug.lib" not needed Link with the static TLS "mysqlclient_notls" tests/CMakeLists.txt: Removed explicit link to "dbug", "mysys", "yassl", "taocrypt" and "zlib" not needed. Added explicit source addition "../mysys/my_memmem.c". No need for setting CXX flags, no C++ code. Use the static TLS "mysqlclient_notls" for linkage. zlib/CMakeLists.txt: No need for a dynamic TLS version of this library, no access to thread storage is done from it. Also no need to define MYSQL_CLIENT, not used, or __WIN32__ that is handled by the library header without this define. --- client/CMakeLists.txt | 114 ++++++-------------------------------- dbug/CMakeLists.txt | 1 - libmysql/CMakeLists.txt | 59 ++++++++++++++------ mysys/CMakeLists.txt | 14 ++--- scripts/make_win_bin_dist | 4 +- sql/CMakeLists.txt | 5 +- tests/CMakeLists.txt | 8 +-- zlib/CMakeLists.txt | 6 +- 8 files changed, 79 insertions(+), 132 deletions(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 8eaa04f8392..89675138750 100755 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -14,128 +14,48 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake") +# We use the "mysqlclient_notls" library here just as safety, in case +# any of the clients here would go beond the client API and access the +# Thread Local Storage directly. + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") -# The old Windows build method used renamed (.cc -> .cpp) source files, fails -# in #include in mysqlbinlog.cc. So disable that using the USING_CMAKE define. -ADD_DEFINITIONS(-DUSING_CMAKE -DYASSL_PREFIX -DUSE_TLS) - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/extra/yassl/include - ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/include - ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL ${CMAKE_SOURCE_DIR}/libmysql ${CMAKE_SOURCE_DIR}/regex - ${CMAKE_SOURCE_DIR}/mysys ${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/strings) -SET(YASSL_SOURCES ../extra/yassl/src/buffer.cpp - ../extra/yassl/src/cert_wrapper.cpp - ../extra/yassl/src/crypto_wrapper.cpp - ../extra/yassl/src/handshake.cpp - ../extra/yassl/src/lock.cpp - ../extra/yassl/src/log.cpp - ../extra/yassl/src/socket_wrapper.cpp - ../extra/yassl/src/ssl.cpp - ../extra/yassl/src/timer.cpp - ../extra/yassl/src/yassl_error.cpp - ../extra/yassl/src/yassl_imp.cpp - ../extra/yassl/src/yassl_int.cpp) - -SET(TAOCRYPT_SOURCES ../extra/yassl/taocrypt/src/aes.cpp - ../extra/yassl/taocrypt/src/aestables.cpp - ../extra/yassl/taocrypt/src/algebra.cpp - ../extra/yassl/taocrypt/src/arc4.cpp - ../extra/yassl/taocrypt/src/asn.cpp - ../extra/yassl/taocrypt/src/coding.cpp - ../extra/yassl/taocrypt/src/des.cpp - ../extra/yassl/taocrypt/src/dh.cpp - ../extra/yassl/taocrypt/src/dsa.cpp - ../extra/yassl/taocrypt/src/file.cpp - ../extra/yassl/taocrypt/src/hash.cpp - ../extra/yassl/taocrypt/src/integer.cpp - ../extra/yassl/taocrypt/src/md2.cpp - ../extra/yassl/taocrypt/src/md4.cpp - ../extra/yassl/taocrypt/src/md5.cpp - ../extra/yassl/taocrypt/src/misc.cpp - ../extra/yassl/taocrypt/src/random.cpp - ../extra/yassl/taocrypt/src/ripemd.cpp - ../extra/yassl/taocrypt/src/rsa.cpp - ../extra/yassl/taocrypt/src/sha.cpp) +ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc ../mysys/my_conio.c) +TARGET_LINK_LIBRARIES(mysql mysqlclient_notls wsock32) -ADD_LIBRARY(mysqlclient ../mysys/array.c ../strings/bchange.c ../strings/bmove.c - ../strings/bmove_upp.c ../mysys/charset-def.c ../mysys/charset.c - ../sql-common/client.c ../strings/ctype-big5.c ../strings/ctype-bin.c - ../strings/ctype-cp932.c ../strings/ctype-czech.c ../strings/ctype-euc_kr.c - ../strings/ctype-eucjpms.c ../strings/ctype-extra.c ../strings/ctype-gb2312.c - ../strings/ctype-gbk.c ../strings/ctype-latin1.c ../strings/ctype-mb.c - ../strings/ctype-simple.c ../strings/ctype-sjis.c ../strings/ctype-tis620.c - ../strings/ctype-uca.c ../strings/ctype-ucs2.c ../strings/ctype-ujis.c - ../strings/ctype-utf8.c ../strings/ctype-win1250ch.c ../strings/ctype.c - ../mysys/default.c ../libmysql/errmsg.c ../mysys/errors.c - ../libmysql/get_password.c ../strings/int2str.c ../strings/is_prefix.c - ../libmysql/libmysql.c ../mysys/list.c ../strings/llstr.c - ../strings/longlong2str.c ../libmysql/manager.c ../mysys/mf_cache.c - ../mysys/mf_dirname.c ../mysys/mf_fn_ext.c ../mysys/mf_format.c - ../mysys/mf_iocache.c ../mysys/mf_iocache2.c ../mysys/mf_loadpath.c - ../mysys/mf_pack.c ../mysys/mf_path.c ../mysys/mf_tempfile.c ../mysys/mf_unixpath.c - ../mysys/mf_wcomp.c ../mysys/mulalloc.c ../mysys/my_access.c ../mysys/my_alloc.c - ../mysys/my_chsize.c ../mysys/my_compress.c ../mysys/my_create.c - ../mysys/my_delete.c ../mysys/my_div.c ../mysys/my_error.c ../mysys/my_file.c - ../mysys/my_fopen.c ../mysys/my_fstream.c ../mysys/my_gethostbyname.c - ../mysys/my_getopt.c ../mysys/my_getwd.c ../mysys/my_init.c ../mysys/my_lib.c - ../mysys/my_malloc.c ../mysys/my_messnc.c ../mysys/my_net.c ../mysys/my_once.c - ../mysys/my_open.c ../mysys/my_pread.c ../mysys/my_pthread.c ../mysys/my_read.c - ../mysys/my_realloc.c ../mysys/my_rename.c ../mysys/my_seek.c - ../mysys/my_static.c ../strings/my_strtoll10.c ../mysys/my_symlink.c - ../mysys/my_symlink2.c ../mysys/my_thr_init.c ../sql-common/my_time.c - ../strings/my_vsnprintf.c ../mysys/my_wincond.c ../mysys/my_winthread.c - ../mysys/my_write.c ../sql/net_serv.cc ../sql-common/pack.c ../sql/password.c - ../mysys/safemalloc.c ../mysys/sha1.c ../strings/str2int.c - ../strings/str_alloc.c ../strings/strcend.c ../strings/strcont.c ../strings/strend.c - ../strings/strfill.c ../mysys/string.c ../strings/strinstr.c ../strings/strmake.c - ../strings/strmov.c ../strings/strnlen.c ../strings/strnmov.c ../strings/strtod.c - ../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c - ../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c - ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c - ${YASSL_SOURCES} ${TAOCRYPT_SOURCES} - ) - - -ADD_DEPENDENCIES(mysqlclient GenError) -ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc) -LINK_DIRECTORIES(${MYSQL_BINARY_DIR}/mysys ${MYSQL_BINARY_DIR}/zlib) -TARGET_LINK_LIBRARIES(mysql mysqlclient mysys zlib dbug wsock32) - -ADD_EXECUTABLE(mysqltest mysqltest.c) -TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys zlib dbug regex wsock32) +ADD_EXECUTABLE(mysqltest mysqltest.c ../mysys/my_getsystime.c ../mysys/my_copy.c) +TARGET_LINK_LIBRARIES(mysqltest mysqlclient_notls regex wsock32) ADD_EXECUTABLE(mysqlcheck mysqlcheck.c) -TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient dbug zlib wsock32) +TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient_notls wsock32) -ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c) -TARGET_LINK_LIBRARIES(mysqldump mysqlclient mysys dbug zlib wsock32) +ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c ../mysys/mf_getdate.c) +TARGET_LINK_LIBRARIES(mysqldump mysqlclient_notls wsock32) ADD_EXECUTABLE(mysqlimport mysqlimport.c) -TARGET_LINK_LIBRARIES(mysqlimport mysqlclient mysys dbug zlib wsock32) +TARGET_LINK_LIBRARIES(mysqlimport mysqlclient_notls wsock32) ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c ../mysys/my_getpagesize.c) -TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient mysys dbug zlib wsock32) +TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient_notls wsock32) ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs) ADD_EXECUTABLE(mysqlshow mysqlshow.c) -TARGET_LINK_LIBRARIES(mysqlshow mysqlclient mysys dbug zlib wsock32) +TARGET_LINK_LIBRARIES(mysqlshow mysqlclient_notls wsock32) -ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc ../mysys/mf_tempdir.c ../mysys/my_new.cc - ../mysys/my_bit.c ../mysys/my_bitmap.c - ../mysys/base64.c) -TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient dbug zlib wsock32) +ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc ../mysys/mf_tempdir.c ../mysys/my_new.cc) +TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient_notls wsock32) ADD_EXECUTABLE(mysqladmin mysqladmin.cc) -TARGET_LINK_LIBRARIES(mysqladmin mysqlclient mysys dbug zlib wsock32) +TARGET_LINK_LIBRARIES(mysqladmin mysqlclient_notls wsock32) ADD_EXECUTABLE(echo echo.c) diff --git a/dbug/CMakeLists.txt b/dbug/CMakeLists.txt index 375fd19fb40..34f44f9a720 100755 --- a/dbug/CMakeLists.txt +++ b/dbug/CMakeLists.txt @@ -13,7 +13,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -D__WIN32__") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 3b18531f6c0..c659c36117a 100755 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -14,14 +14,14 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake") -# Need to set USE_TLS, since __declspec(thread) approach to thread local -# storage does not work properly in DLLs. -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_TLS") -SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_TLS") -SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_TLS") -SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_TLS") -SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_TLS") -SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_TLS") +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + +# Note that we don't link with the libraries "strings" or "mysys" +# here, instead we recompile the files needed and include them +# directly. This means we don't have to worry here about if these +# libraries are compiled defining USE_TLS or not. Not that it *should* +# have been a problem anyway, they don't use thread local storage. INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib @@ -31,8 +31,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/strings) -ADD_LIBRARY(libmysql SHARED dll.c libmysql.def - ../mysys/array.c ../strings/bchange.c ../strings/bmove.c +SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c ../strings/bmove_upp.c ../mysys/charset-def.c ../mysys/charset.c ../sql-common/client.c ../strings/ctype-big5.c ../strings/ctype-bin.c ../strings/ctype-cp932.c ../strings/ctype-czech.c ../strings/ctype-euc_kr.c @@ -41,10 +40,11 @@ ADD_LIBRARY(libmysql SHARED dll.c libmysql.def ../strings/ctype-simple.c ../strings/ctype-sjis.c ../strings/ctype-tis620.c ../strings/ctype-uca.c ../strings/ctype-ucs2.c ../strings/ctype-ujis.c ../strings/ctype-utf8.c ../strings/ctype-win1250ch.c ../strings/ctype.c - ../mysys/default.c ../libmysql/errmsg.c ../mysys/errors.c - ../libmysql/get_password.c ../strings/int2str.c ../strings/is_prefix.c - ../libmysql/libmysql.c ../mysys/list.c ../strings/llstr.c - ../strings/longlong2str.c ../libmysql/manager.c ../mysys/mf_cache.c + ../mysys/default.c errmsg.c ../mysys/errors.c + ../mysys/hash.c ../mysys/my_sleep.c ../mysys/default_modify.c + get_password.c ../strings/int2str.c ../strings/is_prefix.c + libmysql.c ../mysys/list.c ../strings/llstr.c + ../strings/longlong2str.c manager.c ../mysys/mf_cache.c ../mysys/mf_dirname.c ../mysys/mf_fn_ext.c ../mysys/mf_format.c ../mysys/mf_iocache.c ../mysys/mf_iocache2.c ../mysys/mf_loadpath.c ../mysys/mf_pack.c ../mysys/mf_path.c ../mysys/mf_tempfile.c ../mysys/mf_unixpath.c @@ -67,8 +67,35 @@ ADD_LIBRARY(libmysql SHARED dll.c libmysql.def ../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c ../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c) -ADD_DEPENDENCIES(libmysql dbug vio mysys strings GenError zlib yassl taocrypt) -TARGET_LINK_LIBRARIES(libmysql mysys strings wsock32) + +# Need to set USE_TLS for building the DLL, since __declspec(thread) +# approach to thread local storage does not work properly in DLLs. +# +# The static library might be used to form another DLL, as is the case +# with the ODBC driver, so it has to be compiled with USE_TLS as well. +# +# We create a third library without USE_TLS for internal use. We can't +# be sure that some client application part of this build doesn't go +# beond the documented API, and try access the Thread Local Storage. +# The "_notls" means no Tls*() functions used, i.e. "static" TLS. + +ADD_LIBRARY(libmysql SHARED dll.c libmysql.def ${CLIENT_SOURCES}) +ADD_LIBRARY(mysqlclient STATIC ${CLIENT_SOURCES}) +ADD_LIBRARY(mysqlclient_notls STATIC ${CLIENT_SOURCES}) + +SET_TARGET_PROPERTIES(libmysql mysqlclient PROPERTIES COMPILE_FLAGS "-DUSE_TLS") + +SET(CLIENT_LIB_DEPS yassl taocrypt zlib dbug GenError) +SET(CLIENT_LIBS yassl taocrypt zlib debug dbug) + +ADD_DEPENDENCIES(libmysql ${CLIENT_LIB_DEPS}) +TARGET_LINK_LIBRARIES(libmysql ${CLIENT_LIBS} wsock32) + +ADD_DEPENDENCIES(mysqlclient ${CLIENT_LIB_DEPS}) +TARGET_LINK_LIBRARIES(mysqlclient ${CLIENT_LIBS}) + +ADD_DEPENDENCIES(mysqlclient_notls ${CLIENT_LIB_DEPS}) +TARGET_LINK_LIBRARIES(mysqlclient_notls ${CLIENT_LIBS}) ADD_EXECUTABLE(myTest mytest.c) TARGET_LINK_LIBRARIES(myTest libmysql) diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 608d7cb1ce9..4c11b57d736 100755 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -16,17 +16,13 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") -# Need to set USE_TLS, since mysys is linked into libmysql.dll and -# libmysqld.dll, and __declspec(thread) approach to thread local storage does -# not work properly in DLLs. -# Currently, USE_TLS crashes in Debug builds, so until that is fixed Debug -# .dlls cannot be loaded at runtime. -SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DUSE_TLS") -SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DUSE_TLS") -SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DUSE_TLS") -SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DUSE_TLS") +# Only the server link with this library, the client libraries and the client +# executables all link with recompiles of source found in the "mysys" directory. +# So we only need to create one version of this library, with the "static" +# Thread Local Storage model. INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys ) + ADD_LIBRARY(mysys array.c charset-def.c charset.c checksum.c default.c default_modify.c errors.c hash.c list.c md5.c mf_brkhant.c mf_cache.c mf_dirname.c mf_fn_ext.c mf_format.c mf_getdate.c mf_iocache.c mf_iocache2.c mf_keycache.c diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist index beb274ca1a3..c14423a06c1 100755 --- a/scripts/make_win_bin_dist +++ b/scripts/make_win_bin_dist @@ -287,7 +287,7 @@ cp include/mysql.h \ mkdir -p $DESTDIR/lib/opt cp libmysql/$TARGET/libmysql.dll \ libmysql/$TARGET/libmysql.lib \ - client/$TARGET/mysqlclient.lib \ + libmysql/$TARGET/mysqlclient.lib \ regex/$TARGET/regex.lib \ strings/$TARGET/strings.lib \ zlib/$TARGET/zlib.lib $DESTDIR/lib/opt/ @@ -297,7 +297,7 @@ if [ x"$PACK_DEBUG" = x"" -a -f "libmysql/debug/libmysql.lib" -o \ mkdir -p $DESTDIR/lib/debug cp libmysql/debug/libmysql.dll \ libmysql/debug/libmysql.lib \ - client/debug/mysqlclient.lib \ + libmysql/debug/mysqlclient.lib \ regex/debug/regex.lib \ strings/debug/strings.lib \ zlib/debug/zlib.lib $DESTDIR/lib/debug/ diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 0cbeb97184f..6726fdfd85a 100755 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -51,7 +51,7 @@ ADD_EXECUTABLE(mysqld${MYSQLD_EXE_SUFFIX} discover.cc ../libmysql/errmsg.c field.cc field_conv.cc filesort.cc gstream.cc ha_blackhole.cc ha_archive.cc ha_heap.cc ha_myisam.cc ha_myisammrg.cc - ha_innodb.cc ha_federated.cc ha_berkeley.cc ha_blackhole.cc + ha_innodb.cc ha_federated.cc ha_berkeley.cc handler.cc hash_filo.cc hash_filo.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 @@ -128,8 +128,9 @@ ADD_CUSTOM_COMMAND( DEPENDS ${PROJECT_SOURCE_DIR}/sql/message.mc) # Gen_lex_hash +# About "mysqlclient_notls", see note in "client/CMakeLists.txt" ADD_EXECUTABLE(gen_lex_hash gen_lex_hash.cc) -TARGET_LINK_LIBRARIES(gen_lex_hash dbug mysqlclient wsock32) +TARGET_LINK_LIBRARIES(gen_lex_hash mysqlclient_notls wsock32) GET_TARGET_PROPERTY(GEN_LEX_HASH_EXE gen_lex_hash LOCATION) ADD_CUSTOM_COMMAND( OUTPUT ${PROJECT_SOURCE_DIR}/sql/lex_hash.h diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5eade93621b..6c3964e9b12 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -13,12 +13,12 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") -SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +# About "mysqlclient_notls", see note in "client/CMakeLists.txt" +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") ADD_DEFINITIONS("-DMYSQL_CLIENT") INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) -ADD_EXECUTABLE(mysql_client_test mysql_client_test.c) -TARGET_LINK_LIBRARIES(mysql_client_test dbug mysys mysqlclient yassl taocrypt zlib wsock32) +ADD_EXECUTABLE(mysql_client_test mysql_client_test.c ../mysys/my_memmem.c) +TARGET_LINK_LIBRARIES(mysql_client_test mysqlclient_notls wsock32) diff --git a/zlib/CMakeLists.txt b/zlib/CMakeLists.txt index ac315b0dd85..123b7f6ec7f 100755 --- a/zlib/CMakeLists.txt +++ b/zlib/CMakeLists.txt @@ -13,10 +13,14 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# Note that this library is not using any "Thread Local Storage" (TLS), +# i.e. no data declared "__declspec(thread)" or allocated with TlsAlloc(). +# Not directly and indirectly using any of the macros for creating and +# using the storage, pthread_key*(), {,my_}{set,get}_specific*() .... + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") -ADD_DEFINITIONS(-DUSE_TLS -DMYSQL_CLIENT -D__WIN32__) ADD_LIBRARY(zlib adler32.c compress.c crc32.c crc32.h deflate.c deflate.h gzio.c infback.c inffast.c inffast.h inffixed.h inflate.c inflate.h inftrees.c inftrees.h trees.c trees.h uncompr.c zconf.h zlib.h zutil.c zutil.h) From 39371b1bcbb6bad75ecad0c044bf7de63a549741 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Aug 2007 15:37:33 +0200 Subject: [PATCH 21/74] Makefile.am: Add CMakeLists.txt to source distribution CMakeLists.txt: Added missing '${MYSQLD_EXE_SUFFIX}' to "mysqld" targets new in 5.1 Manual merge from 5.0 (bug#30118) CMakeLists.txt, mysqlbinlog.cc, lib_sql.cc: No need to test on USING_CMAKE, it is the only Windows build client/mysqlbinlog.cc: No need to test on USING_CMAKE, it is the only Windows build libmysqld/CMakeLists.txt: No need to test on USING_CMAKE, it is the only Windows build libmysqld/lib_sql.cc: No need to test on USING_CMAKE, it is the only Windows build libmysqld/Makefile.am: Add CMakeLists.txt to source distribution libmysqld/examples/Makefile.am: Add CMakeLists.txt to source distribution sql/CMakeLists.txt: Added missing '${MYSQLD_EXE_SUFFIX}' to "mysqld" targets new in 5.1 client/CMakeLists.txt: Manual merge from 5.0 (bug#30118) libmysql/CMakeLists.txt: Manual merge from 5.0 (bug#30118) mysys/CMakeLists.txt: Manual merge from 5.0 (bug#30118) zlib/CMakeLists.txt: Manual merge from 5.0 (bug#30118) --- client/CMakeLists.txt | 127 +++++++-------------------------- client/mysqlbinlog.cc | 8 --- libmysql/CMakeLists.txt | 56 +++++++++++---- libmysqld/CMakeLists.txt | 4 -- libmysqld/Makefile.am | 2 +- libmysqld/examples/Makefile.am | 1 + libmysqld/lib_sql.cc | 4 -- mysys/CMakeLists.txt | 21 +++--- sql/CMakeLists.txt | 8 +-- zlib/CMakeLists.txt | 2 - 10 files changed, 88 insertions(+), 145 deletions(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 8a670cf4c4b..0b37f4d3d1c 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -14,130 +14,54 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake") +# We use the "mysqlclient_notls" library here just as safety, in case +# any of the clients here would go beond the client API and access the +# Thread Local Storage directly. + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") -# The old Windows build method used renamed (.cc -> .cpp) source files, fails -# in #include in mysqlbinlog.cc. So disable that using the USING_CMAKE define. -ADD_DEFINITIONS(-DUSING_CMAKE -DYASSL_PREFIX -DUSE_TLS) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include - ${CMAKE_SOURCE_DIR}/zlib +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/extra/yassl/include - ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/include - ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL ${CMAKE_SOURCE_DIR}/libmysql ${CMAKE_SOURCE_DIR}/regex ${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/strings) -SET(YASSL_SOURCES ../extra/yassl/src/buffer.cpp - ../extra/yassl/src/cert_wrapper.cpp - ../extra/yassl/src/crypto_wrapper.cpp - ../extra/yassl/src/handshake.cpp - ../extra/yassl/src/lock.cpp - ../extra/yassl/src/log.cpp - ../extra/yassl/src/socket_wrapper.cpp - ../extra/yassl/src/ssl.cpp - ../extra/yassl/src/timer.cpp - ../extra/yassl/src/yassl_error.cpp - ../extra/yassl/src/yassl_imp.cpp - ../extra/yassl/src/yassl_int.cpp) - -SET(TAOCRYPT_SOURCES ../extra/yassl/taocrypt/src/aes.cpp - ../extra/yassl/taocrypt/src/aestables.cpp - ../extra/yassl/taocrypt/src/algebra.cpp - ../extra/yassl/taocrypt/src/arc4.cpp - ../extra/yassl/taocrypt/src/asn.cpp - ../extra/yassl/taocrypt/src/coding.cpp - ../extra/yassl/taocrypt/src/des.cpp - ../extra/yassl/taocrypt/src/dh.cpp - ../extra/yassl/taocrypt/src/dsa.cpp - ../extra/yassl/taocrypt/src/file.cpp - ../extra/yassl/taocrypt/src/hash.cpp - ../extra/yassl/taocrypt/src/integer.cpp - ../extra/yassl/taocrypt/src/md2.cpp - ../extra/yassl/taocrypt/src/md4.cpp - ../extra/yassl/taocrypt/src/md5.cpp - ../extra/yassl/taocrypt/src/misc.cpp - ../extra/yassl/taocrypt/src/random.cpp - ../extra/yassl/taocrypt/src/ripemd.cpp - ../extra/yassl/taocrypt/src/rsa.cpp - ../extra/yassl/taocrypt/src/sha.cpp) +ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc ../mysys/my_conio.c) +TARGET_LINK_LIBRARIES(mysql mysqlclient_notls wsock32) - -ADD_LIBRARY(mysqlclient ../mysys/array.c ../strings/bchange.c ../strings/bmove.c - ../strings/bmove_upp.c ../mysys/charset-def.c ../mysys/charset.c - ../sql-common/client.c ../strings/ctype-big5.c ../strings/ctype-bin.c - ../strings/ctype-cp932.c ../strings/ctype-czech.c ../strings/ctype-euc_kr.c - ../strings/ctype-eucjpms.c ../strings/ctype-extra.c ../strings/ctype-gb2312.c - ../strings/ctype-gbk.c ../strings/ctype-latin1.c ../strings/ctype-mb.c - ../strings/ctype-simple.c ../strings/ctype-sjis.c ../strings/ctype-tis620.c - ../strings/ctype-uca.c ../strings/ctype-ucs2.c ../strings/ctype-ujis.c - ../strings/ctype-utf8.c ../strings/ctype-win1250ch.c ../strings/ctype.c - ../mysys/default.c ../libmysql/errmsg.c ../mysys/errors.c - ../libmysql/get_password.c ../strings/int2str.c ../strings/is_prefix.c - ../libmysql/libmysql.c ../mysys/list.c ../strings/llstr.c - ../strings/longlong2str.c ../libmysql/manager.c ../mysys/mf_cache.c - ../mysys/mf_dirname.c ../mysys/mf_fn_ext.c ../mysys/mf_format.c - ../mysys/mf_iocache.c ../mysys/mf_iocache2.c ../mysys/mf_loadpath.c - ../mysys/mf_pack.c ../mysys/mf_path.c ../mysys/mf_tempfile.c ../mysys/mf_unixpath.c - ../mysys/mf_wcomp.c ../mysys/mulalloc.c ../mysys/my_access.c ../mysys/my_alloc.c - ../mysys/my_chsize.c ../mysys/my_compress.c ../mysys/my_create.c - ../mysys/my_delete.c ../mysys/my_div.c ../mysys/my_error.c ../mysys/my_file.c - ../mysys/my_fopen.c ../mysys/my_fstream.c ../mysys/my_gethostbyname.c - ../mysys/my_getopt.c ../mysys/my_getwd.c ../mysys/my_init.c ../mysys/my_lib.c - ../mysys/my_malloc.c ../mysys/my_messnc.c ../mysys/my_net.c ../mysys/my_once.c - ../mysys/my_open.c ../mysys/my_pread.c ../mysys/my_pthread.c ../mysys/my_read.c - ../mysys/my_realloc.c ../mysys/my_rename.c ../mysys/my_seek.c - ../mysys/my_static.c ../strings/my_strtoll10.c ../mysys/my_symlink.c - ../mysys/my_symlink2.c ../mysys/my_thr_init.c ../sql-common/my_time.c - ../strings/my_vsnprintf.c ../mysys/my_wincond.c ../mysys/my_winthread.c - ../mysys/my_write.c ../sql/net_serv.cc ../sql-common/pack.c ../sql/password.c - ../mysys/safemalloc.c ../mysys/sha1.c ../strings/str2int.c - ../strings/str_alloc.c ../strings/strcend.c ../strings/strcont.c ../strings/strend.c - ../strings/strfill.c ../mysys/string.c ../strings/strinstr.c ../strings/strmake.c - ../strings/strmov.c ../strings/strnlen.c ../strings/strnmov.c ../strings/strtod.c - ../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c - ../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c - ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c - ${YASSL_SOURCES} ${TAOCRYPT_SOURCES} - ) - -ADD_DEPENDENCIES(mysqlclient GenError) -ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc) -LINK_DIRECTORIES(${MYSQL_BINARY_DIR}/mysys ${MYSQL_BINARY_DIR}/zlib) -TARGET_LINK_LIBRARIES(mysql mysqlclient mysys zlib dbug wsock32) - -ADD_EXECUTABLE(mysqltest mysqltest.c) -TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys zlib dbug regex wsock32) +ADD_EXECUTABLE(mysqltest mysqltest.c ../mysys/my_getsystime.c ../mysys/my_copy.c) +TARGET_LINK_LIBRARIES(mysqltest mysqlclient_notls regex wsock32) ADD_EXECUTABLE(mysqlcheck mysqlcheck.c) -TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient dbug zlib wsock32) +TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient_notls wsock32) -ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c) -TARGET_LINK_LIBRARIES(mysqldump mysqlclient mysys dbug zlib wsock32) +ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c ../mysys/mf_getdate.c) +TARGET_LINK_LIBRARIES(mysqldump mysqlclient_notls wsock32) ADD_EXECUTABLE(mysqlimport mysqlimport.c) -TARGET_LINK_LIBRARIES(mysqlimport mysqlclient mysys dbug zlib wsock32) +TARGET_LINK_LIBRARIES(mysqlimport mysqlclient_notls wsock32) ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c ../mysys/my_getpagesize.c) -TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient dbug zlib wsock32) +TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient_notls wsock32) ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs) ADD_EXECUTABLE(mysqlshow mysqlshow.c) -TARGET_LINK_LIBRARIES(mysqlshow mysqlclient mysys dbug zlib wsock32) +TARGET_LINK_LIBRARIES(mysqlshow mysqlclient_notls wsock32) -ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc ../mysys/mf_tempdir.c ../mysys/my_new.cc - ../mysys/my_bit.c ../mysys/my_bitmap.c ../mysys/my_vle.c - ../mysys/base64.c) -TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient dbug zlib wsock32) +ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc + ../mysys/mf_tempdir.c + ../mysys/my_new.cc + ../mysys/my_bit.c + ../mysys/my_bitmap.c + ../mysys/my_vle.c + ../mysys/base64.c) +TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient_notls wsock32) ADD_EXECUTABLE(mysqladmin mysqladmin.cc) -TARGET_LINK_LIBRARIES(mysqladmin mysqlclient mysys dbug zlib wsock32) - -ADD_EXECUTABLE(mysqlslap mysqlslap.c) -SET_SOURCE_FILES_PROPERTIES(mysqlslap.c PROPERTIES COMPILE_FLAGS "-DTHREADS") -TARGET_LINK_LIBRARIES(mysqlslap mysqlclient mysys zlib wsock32 dbug) +TARGET_LINK_LIBRARIES(mysqladmin mysqlclient_notls wsock32) ADD_EXECUTABLE(echo echo.c) @@ -153,3 +77,4 @@ IF(EMBED_MANIFESTS) MYSQL_EMBED_MANIFEST("mysqladmin" "asInvoker") MYSQL_EMBED_MANIFEST("echo" "asInvoker") ENDIF(EMBED_MANIFESTS) + diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index edade347783..3a73b424748 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -1617,17 +1617,9 @@ int main(int argc, char** argv) the server */ -#if defined(__WIN__) && !defined(USING_CMAKE) -#include "my_decimal.h" -#include "decimal.c" -#include "my_decimal.cpp" -#include "log_event.cpp" -#include "log_event_old.cpp" -#else #include "my_decimal.h" #include "decimal.c" #include "my_decimal.cc" #include "log_event.cc" #include "log_event_old.cc" -#endif diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 7d4dcc1e919..c659c36117a 100644 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -12,13 +12,16 @@ # 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -# Need to set USE_TLS, since __declspec(thread) approach to thread local -# storage does not work properly in DLLs. INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake") -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_TLS") -SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_TLS") +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + +# Note that we don't link with the libraries "strings" or "mysys" +# here, instead we recompile the files needed and include them +# directly. This means we don't have to worry here about if these +# libraries are compiled defining USE_TLS or not. Not that it *should* +# have been a problem anyway, they don't use thread local storage. INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib @@ -28,8 +31,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/strings) -ADD_LIBRARY(libmysql SHARED dll.c libmysql.def - ../mysys/array.c ../strings/bchange.c ../strings/bmove.c +SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c ../strings/bmove_upp.c ../mysys/charset-def.c ../mysys/charset.c ../sql-common/client.c ../strings/ctype-big5.c ../strings/ctype-bin.c ../strings/ctype-cp932.c ../strings/ctype-czech.c ../strings/ctype-euc_kr.c @@ -38,10 +40,11 @@ ADD_LIBRARY(libmysql SHARED dll.c libmysql.def ../strings/ctype-simple.c ../strings/ctype-sjis.c ../strings/ctype-tis620.c ../strings/ctype-uca.c ../strings/ctype-ucs2.c ../strings/ctype-ujis.c ../strings/ctype-utf8.c ../strings/ctype-win1250ch.c ../strings/ctype.c - ../mysys/default.c ../libmysql/errmsg.c ../mysys/errors.c - ../libmysql/get_password.c ../strings/int2str.c ../strings/is_prefix.c - ../libmysql/libmysql.c ../mysys/list.c ../strings/llstr.c - ../strings/longlong2str.c ../libmysql/manager.c ../mysys/mf_cache.c + ../mysys/default.c errmsg.c ../mysys/errors.c + ../mysys/hash.c ../mysys/my_sleep.c ../mysys/default_modify.c + get_password.c ../strings/int2str.c ../strings/is_prefix.c + libmysql.c ../mysys/list.c ../strings/llstr.c + ../strings/longlong2str.c manager.c ../mysys/mf_cache.c ../mysys/mf_dirname.c ../mysys/mf_fn_ext.c ../mysys/mf_format.c ../mysys/mf_iocache.c ../mysys/mf_iocache2.c ../mysys/mf_loadpath.c ../mysys/mf_pack.c ../mysys/mf_path.c ../mysys/mf_tempfile.c ../mysys/mf_unixpath.c @@ -64,8 +67,35 @@ ADD_LIBRARY(libmysql SHARED dll.c libmysql.def ../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c ../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c) -ADD_DEPENDENCIES(libmysql dbug vio mysys strings GenError zlib yassl taocrypt) -TARGET_LINK_LIBRARIES(libmysql mysys strings wsock32) + +# Need to set USE_TLS for building the DLL, since __declspec(thread) +# approach to thread local storage does not work properly in DLLs. +# +# The static library might be used to form another DLL, as is the case +# with the ODBC driver, so it has to be compiled with USE_TLS as well. +# +# We create a third library without USE_TLS for internal use. We can't +# be sure that some client application part of this build doesn't go +# beond the documented API, and try access the Thread Local Storage. +# The "_notls" means no Tls*() functions used, i.e. "static" TLS. + +ADD_LIBRARY(libmysql SHARED dll.c libmysql.def ${CLIENT_SOURCES}) +ADD_LIBRARY(mysqlclient STATIC ${CLIENT_SOURCES}) +ADD_LIBRARY(mysqlclient_notls STATIC ${CLIENT_SOURCES}) + +SET_TARGET_PROPERTIES(libmysql mysqlclient PROPERTIES COMPILE_FLAGS "-DUSE_TLS") + +SET(CLIENT_LIB_DEPS yassl taocrypt zlib dbug GenError) +SET(CLIENT_LIBS yassl taocrypt zlib debug dbug) + +ADD_DEPENDENCIES(libmysql ${CLIENT_LIB_DEPS}) +TARGET_LINK_LIBRARIES(libmysql ${CLIENT_LIBS} wsock32) + +ADD_DEPENDENCIES(mysqlclient ${CLIENT_LIB_DEPS}) +TARGET_LINK_LIBRARIES(mysqlclient ${CLIENT_LIBS}) + +ADD_DEPENDENCIES(mysqlclient_notls ${CLIENT_LIB_DEPS}) +TARGET_LINK_LIBRARIES(mysqlclient_notls ${CLIENT_LIBS}) ADD_EXECUTABLE(myTest mytest.c) TARGET_LINK_LIBRARIES(myTest libmysql) diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index dd42bafcfe0..45a298b2efe 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -20,10 +20,6 @@ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") # storage does not work properly in DLLs. ADD_DEFINITIONS(-DUSE_TLS -DMYSQL_SERVER) -# The old Windows build method used renamed (.cc -> .cpp) source files, fails -# in #include in lib_sql.cc. So disable that using the USING_CMAKE define. -ADD_DEFINITIONS(-DUSING_CMAKE) - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/libmysqld ${CMAKE_SOURCE_DIR}/libmysql diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am index 024b85eed8e..6ecce474b50 100644 --- a/libmysqld/Makefile.am +++ b/libmysqld/Makefile.am @@ -22,7 +22,7 @@ MYSQLSHAREdir = $(pkgdatadir) MYSQLBASEdir= $(prefix) MYSQLLIBdir= $(libdir) -EXTRA_DIST = libmysqld.def +EXTRA_DIST = libmysqld.def CMakeLists.txt DEFS = -DEMBEDDED_LIBRARY -DMYSQL_SERVER \ -DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \ -DDATADIR="\"$(MYSQLDATAdir)\"" \ diff --git a/libmysqld/examples/Makefile.am b/libmysqld/examples/Makefile.am index ec5bbbb86e5..4a91724afee 100644 --- a/libmysqld/examples/Makefile.am +++ b/libmysqld/examples/Makefile.am @@ -19,6 +19,7 @@ client_sources = $(mysqltest_embedded_SOURCES) $(mysql_SOURCES) tests_sources = $(mysql_client_test_embedded_SOURCES) BUILT_SOURCES = link_sources CLEANFILES = $(client_sources) $(tests_sources) $(BUILT_SOURCES) +EXTRA_DIST = CMakeLists.txt link_sources: for f in $(client_sources); do \ diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 0ce9efca0cc..4a8387e9944 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -28,11 +28,7 @@ extern "C" extern unsigned long max_allowed_packet, net_buffer_length; } -#if defined(__WIN__) && !defined(USING_CMAKE) -#include "../sql/mysqld.cpp" -#else #include "../sql/mysqld.cc" -#endif C_MODE_START diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 1ae625c4c03..08279eda00c 100644 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -13,18 +13,23 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") -# Need to set USE_TLS, since mysys is linked into libmysql.dll and -# libmysqld.dll, and __declspec(thread) approach to thread local storage does -# not work properly in DLLs. -# Currently, USE_TLS crashes in Debug builds, so until that is fixed Debug -# .dlls cannot be loaded at runtime. -SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DUSE_TLS") -SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DUSE_TLS") +# Only the server link with this library, the client libraries and the client +# executables all link with recompiles of source found in the "mysys" directory. +# So we only need to create one version of this library, with the "static" +# Thread Local Storage model. +# +# Exception is the embedded server that needs this library compiled with +# dynamic TLS, i.e. define USE_TLS + +IF(EMBEDDED_ONLY) + ADD_DEFINITIONS(-DUSE_TLS) + ADD_DEFINITIONS(-DEMBEDDED_LIBRARY) +ENDIF(EMBEDDED_ONLY) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/include) + ADD_LIBRARY(mysys array.c charset-def.c charset.c checksum.c default.c default_modify.c errors.c hash.c list.c md5.c mf_brkhant.c mf_cache.c mf_dirname.c mf_fn_ext.c mf_format.c mf_getdate.c mf_iocache.c mf_iocache2.c mf_keycache.c diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index a8aa7d70586..6319ad8ac2e 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -91,19 +91,19 @@ IF(EMBED_MANIFESTS) MYSQL_EMBED_MANIFEST("mysqld" "asInvoker") ENDIF(EMBED_MANIFESTS) IF(WITH_ARCHIVE_STORAGE_ENGINE) - TARGET_LINK_LIBRARIES(mysqld archive) + TARGET_LINK_LIBRARIES(mysqld${MYSQLD_EXE_SUFFIX} archive) ENDIF(WITH_ARCHIVE_STORAGE_ENGINE) IF(WITH_BLACKHOLE_STORAGE_ENGINE) - TARGET_LINK_LIBRARIES(mysqld blackhole) + TARGET_LINK_LIBRARIES(mysqld${MYSQLD_EXE_SUFFIX} blackhole) ENDIF(WITH_BLACKHOLE_STORAGE_ENGINE) IF(WITH_CSV_STORAGE_ENGINE) - TARGET_LINK_LIBRARIES(mysqld csv) + TARGET_LINK_LIBRARIES(mysqld${MYSQLD_EXE_SUFFIX} csv) ENDIF(WITH_CSV_STORAGE_ENGINE) IF(WITH_EXAMPLE_STORAGE_ENGINE) TARGET_LINK_LIBRARIES(mysqld${MYSQLD_EXE_SUFFIX} example) ENDIF(WITH_EXAMPLE_STORAGE_ENGINE) IF(WITH_FEDERATED_STORAGE_ENGINE) - TARGET_LINK_LIBRARIES(mysqld federated) + TARGET_LINK_LIBRARIES(mysqld${MYSQLD_EXE_SUFFIX} federated) ENDIF(WITH_FEDERATED_STORAGE_ENGINE) IF(WITH_INNOBASE_STORAGE_ENGINE) TARGET_LINK_LIBRARIES(mysqld${MYSQLD_EXE_SUFFIX} innobase) diff --git a/zlib/CMakeLists.txt b/zlib/CMakeLists.txt index ac315b0dd85..04e33e34871 100644 --- a/zlib/CMakeLists.txt +++ b/zlib/CMakeLists.txt @@ -13,10 +13,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") -ADD_DEFINITIONS(-DUSE_TLS -DMYSQL_CLIENT -D__WIN32__) ADD_LIBRARY(zlib adler32.c compress.c crc32.c crc32.h deflate.c deflate.h gzio.c infback.c inffast.c inffast.h inffixed.h inflate.c inflate.h inftrees.c inftrees.h trees.c trees.h uncompr.c zconf.h zlib.h zutil.c zutil.h) From d0536d020fa1b253bf21add584d66b949b119832 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Aug 2007 17:11:35 +0300 Subject: [PATCH 22/74] Bug #30193: crash during drop table and kill When DROP TABLE detects that it has been killed by another thread it must unlock the table names it locked. Fixed by backporting the 5.1 error handling code. sql/sql_table.cc: Bug #30193: correct error handling when a thread is killed inside DROP TABLE. --- sql/sql_table.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index d83100aa439..e0104f11be5 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -256,8 +256,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, drop_locked_tables(thd, db, table->table_name); if (thd->killed) { - thd->no_warnings_for_error= 0; - DBUG_RETURN(-1); + error=-1; + goto err_with_placeholders; } alias= (lower_case_table_names == 2) ? table->alias : table->table_name; /* remove form file and isam files */ @@ -338,6 +338,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, } } +err_with_placeholders: if (!drop_temporary) unlock_table_names(thd, tables, (TABLE_LIST*) 0); thd->no_warnings_for_error= 0; From fb828592b4f6798e67f2b60f0ac56282adec5a85 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Aug 2007 18:51:11 +0200 Subject: [PATCH 23/74] myisamchk.c: Fix typo in usage. myisam/myisamchk.c: Fix typo in usage. --- myisam/myisamchk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 49e3ea0f142..a259fbf2c19 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -338,7 +338,7 @@ static struct my_option my_long_options[] = (gptr*) &ft_stopword_file, (gptr*) &ft_stopword_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"stats_method", OPT_STATS_METHOD, - "Specifies how index statistics collection code should threat NULLs. " + "Specifies how index statistics collection code should treat NULLs. " "Possible values of name are \"nulls_unequal\" (default behavior for 4.1/5.0), " "\"nulls_equal\" (emulate 4.0 behavior), and \"nulls_ignored\".", (gptr*) &myisam_stats_method_str, (gptr*) &myisam_stats_method_str, 0, @@ -453,7 +453,7 @@ static void usage(void) MySQL faster. You can check the calculated distribution\n\ by using '--description --verbose table_name'.\n\ --stats_method=name Specifies how index statistics collection code should\n\ - threat NULLs. Possible values of name are \"nulls_unequal\"\n\ + treat NULLs. Possible values of name are \"nulls_unequal\"\n\ (default for 4.1/5.0), \"nulls_equal\" (emulate 4.0), and \n\ \"nulls_ignored\".\n\ -d, --description Prints some information about table.\n\ From d24df2c6a786943cd84194bf5eb9f964a202988e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Aug 2007 21:49:27 +0400 Subject: [PATCH 24/74] sql_class.h: After merge changes. sql/sql_class.h: After merge changes. --- sql/sql_class.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_class.h b/sql/sql_class.h index afeef6db02e..d6a00dd55b7 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -423,6 +423,8 @@ typedef struct system_status_var #define last_system_status_var com_stmt_close +void mark_transaction_to_rollback(THD *thd, bool all); + #ifdef MYSQL_SERVER void free_tmp_table(THD *thd, TABLE *entry); @@ -2464,7 +2466,6 @@ public: /* Functions in sql_class.cc */ void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var); -void mark_transaction_to_rollback(THD *thd, bool all); void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var, STATUS_VAR *dec_var); From 4d2630ed467c57aac0bf96abde6d80e7ea45b247 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Aug 2007 20:51:04 +0200 Subject: [PATCH 25/74] make_win_bin_dist: Simplified copying of 'mysql-test' directory scripts/make_win_bin_dist: Simplified copying of 'mysql-test' directory --- scripts/make_win_bin_dist | 81 ++++++++++++++------------------------- 1 file changed, 28 insertions(+), 53 deletions(-) diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist index c14423a06c1..14ea77e3e0e 100755 --- a/scripts/make_win_bin_dist +++ b/scripts/make_win_bin_dist @@ -144,14 +144,16 @@ fi mkdir $DESTDIR mkdir $DESTDIR/bin -cp client/$TARGET/*.exe $DESTDIR/bin/ -cp extra/$TARGET/*.exe $DESTDIR/bin/ -cp myisam/$TARGET/*.exe $DESTDIR/bin/ -cp server-tools/instance-manager/$TARGET/*.exe $DESTDIR/bin/ -cp server-tools/instance-manager/$TARGET/*.pdb $DESTDIR/bin/ || true -cp server-tools/instance-manager/$TARGET/*.map $DESTDIR/bin/ || true -cp tests/$TARGET/*.exe $DESTDIR/bin/ -cp libmysql/$TARGET/libmysql.dll $DESTDIR/bin/ +cp client/$TARGET/*.exe $DESTDIR/bin/ +cp extra/$TARGET/*.exe $DESTDIR/bin/ +cp myisam/$TARGET/*.exe $DESTDIR/bin/ +cp server-tools/instance-manager/$TARGET/*.{exe,map} $DESTDIR/bin/ +if [ x"$TARGET" != x"release" ] ; then + cp server-tools/instance-manager/$TARGET/*.pdb $DESTDIR/bin/ +fi +cp tests/$TARGET/*.exe $DESTDIR/bin/ +cp libmysql/$TARGET/*.exe $DESTDIR/bin/ +cp libmysql/$TARGET/libmysql.dll $DESTDIR/bin/ # FIXME really needed?! mv $DESTDIR/bin/comp_err.exe $DESTDIR/bin/comp-err.exe @@ -164,8 +166,10 @@ fi # Depending on Visual Studio target, the optimized server has symbols cp sql/$TARGET/$BASENAME.exe $DESTDIR/bin/$BASENAME$EXE_SUFFIX.exe -cp sql/$TARGET/$BASENAME.pdb $DESTDIR/bin/$BASENAME$EXE_SUFFIX.pdb || true -cp sql/$TARGET/$BASENAME.map $DESTDIR/bin/$BASENAME$EXE_SUFFIX.map || true +cp sql/$TARGET/$BASENAME.map $DESTDIR/bin/$BASENAME$EXE_SUFFIX.map +if [ x"$TARGET" != x"release" ] ; then + cp sql/$TARGET/$BASENAME.pdb $DESTDIR/bin/$BASENAME$EXE_SUFFIX.pdb +fi if [ -f "sql/debug/mysqld-debug.exe" ] ; then BASENAME="mysqld-debug" # Old style non CMake build @@ -176,19 +180,16 @@ fi if [ x"$PACK_DEBUG" = x"" -a -f "sql/debug/$BASENAME.exe" -o \ x"$PACK_DEBUG" = x"yes" ] ; then cp sql/debug/$BASENAME.exe $DESTDIR/bin/mysqld-debug.exe - cp sql/debug/$BASENAME.pdb $DESTDIR/bin/mysqld-debug.pdb || true - cp sql/debug/$BASENAME.map $DESTDIR/bin/mysqld-debug.map || true + cp sql/debug/$BASENAME.pdb $DESTDIR/bin/mysqld-debug.pdb + cp sql/debug/$BASENAME.map $DESTDIR/bin/mysqld-debug.map fi # ---------------------------------------------------------------------- # Copy data directory, readme files etc # ---------------------------------------------------------------------- -# FIXME is there ever a data directory to copy? if [ -d win/data ] ; then cp -pR win/data $DESTDIR/ -elif [ -d data ] ; then - cp -pR data $DESTDIR/ fi # FIXME maybe a flag to define "release build", or do the @@ -288,6 +289,7 @@ mkdir -p $DESTDIR/lib/opt cp libmysql/$TARGET/libmysql.dll \ libmysql/$TARGET/libmysql.lib \ libmysql/$TARGET/mysqlclient.lib \ + mysys/$TARGET/mysys.lib \ regex/$TARGET/regex.lib \ strings/$TARGET/strings.lib \ zlib/$TARGET/zlib.lib $DESTDIR/lib/opt/ @@ -298,53 +300,24 @@ if [ x"$PACK_DEBUG" = x"" -a -f "libmysql/debug/libmysql.lib" -o \ cp libmysql/debug/libmysql.dll \ libmysql/debug/libmysql.lib \ libmysql/debug/mysqlclient.lib \ + mysys/debug/mysys.lib \ regex/debug/regex.lib \ strings/debug/strings.lib \ zlib/debug/zlib.lib $DESTDIR/lib/debug/ - - if [ -f "mysys/debug/mysys-nt.lib" ] ; then - cp mysys/debug/mysys-nt.lib $DESTDIR/lib/debug/ - else - cp mysys/debug/mysys.lib $DESTDIR/lib/debug/mysys-nt.lib - fi - -fi - -if [ -f "mysys/$TARGET/mysys-nt.lib" ] ; then - cp mysys/$TARGET/mysys-nt.lib $DESTDIR/lib/opt/ -else - cp mysys/$TARGET/mysys.lib $DESTDIR/lib/opt/mysys-nt.lib fi # ---------------------------------------------------------------------- # Copy the test directory # ---------------------------------------------------------------------- -mkdir -p $DESTDIR/mysql-test/include $DESTDIR/mysql-test/lib \ - $DESTDIR/mysql-test/r $DESTDIR/mysql-test/std_data \ - $DESTDIR/mysql-test/t +mkdir $DESTDIR/mysql-test cp mysql-test/mysql-test-run.pl $DESTDIR/mysql-test/ cp mysql-test/README $DESTDIR/mysql-test/ -cp mysql-test/install_test_db.sh $DESTDIR/mysql-test/install_test_db -cp mysql-test/include/*.inc $DESTDIR/mysql-test/include/ -cp mysql-test/include/*.test $DESTDIR/mysql-test/include/ -cp mysql-test/lib/*.pl $DESTDIR/mysql-test/lib/ -cp mysql-test/lib/*.sql $DESTDIR/mysql-test/lib/ || true -cp mysql-test/r/*.require $DESTDIR/mysql-test/r/ -# Need this trick, or we get "argument list too long". -ABS_DST=`pwd`/$DESTDIR -(cd mysql-test/r/ && cp *.result $ABS_DST/mysql-test/r/) -cp mysql-test/std_data/* $DESTDIR/mysql-test/std_data/ -cp mysql-test/t/*.opt $DESTDIR/mysql-test/t/ -cp mysql-test/t/*.sh $DESTDIR/mysql-test/t/ -cp mysql-test/t/*.slave-mi $DESTDIR/mysql-test/t/ -cp mysql-test/t/*.sql $DESTDIR/mysql-test/t/ -cp mysql-test/t/*.def $DESTDIR/mysql-test/t/ -(cd mysql-test/t/ && cp *.test $ABS_DST/mysql-test/t/) +cp -R mysql-test/{t,r,include,suite,std_data,lib} $DESTDIR/mysql-test/ # Note that this will not copy "extra" if a soft link if [ -d mysql-test/extra ] ; then - mkdir -p $DESTDIR/mysql-test/extra + mkdir $DESTDIR/mysql-test/extra cp -pR mysql-test/extra/* $DESTDIR/mysql-test/extra/ fi @@ -372,17 +345,19 @@ for i in `cd scripts && ls`; do \ fi; \ done -if [ -d "share" ] ; then - cp -pR share $DESTDIR/ -else - cp -pR sql/share $DESTDIR/ -fi +cp -pR sql/share $DESTDIR/ cp -pR sql-bench $DESTDIR/ rm -f $DESTDIR/sql-bench/*.sh $DESTDIR/sql-bench/Makefile* # The SQL initialisation code is really expected to be in "share" mv $DESTDIR/scripts/*.sql $DESTDIR/share/ || true +# ---------------------------------------------------------------------- +# Clean up from possibly copied SCCS directories +# ---------------------------------------------------------------------- + +rm -rf `find $DISTDIR -type d -name SCCS -print` + # ---------------------------------------------------------------------- # Copy other files specified on command line DEST=SOURCE # ---------------------------------------------------------------------- From cb3df6f2e9f286fceca4a4a0e125642e52baf342 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Aug 2007 23:08:52 +0400 Subject: [PATCH 26/74] mysqld.cc: Post merge changes. sql/mysqld.cc: Post merge changes. --- sql/mysqld.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 7fa13fe127f..50d5633ed88 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5071,8 +5071,7 @@ enum options_mysqld OPT_PLUGIN_DIR, OPT_LOG_OUTPUT, OPT_PORT_OPEN_TIMEOUT, - OPT_SECURE_FILE_PRIV, - OPT_KEEP_FILES_ON_CREATE + OPT_KEEP_FILES_ON_CREATE, OPT_GENERAL_LOG, OPT_SLOW_LOG, OPT_THREAD_HANDLING, @@ -5945,8 +5944,8 @@ log and this option does nothing anymore.", IO_SIZE, 0}, {"keep_files_on_create", OPT_KEEP_FILES_ON_CREATE, "Don't overwrite stale .MYD and .MYI even if no directory is specified.", - (gptr*) &global_system_variables.keep_files_on_create, - (gptr*) &max_system_variables.keep_files_on_create, + (uchar**) &global_system_variables.keep_files_on_create, + (uchar**) &max_system_variables.keep_files_on_create, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"key_buffer_size", OPT_KEY_BUFFER_SIZE, "The size of the buffer used for index blocks for MyISAM tables. Increase this to get better index handling (for all reads and multiple writes) to as much as you can afford; 64M on a 256M machine that mainly runs MySQL is quite common.", From c90493749aa8736c76b5765cda0ca925864bbe37 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Aug 2007 12:45:56 -0700 Subject: [PATCH 27/74] Fixed bug#28404. This patch adds cost estimation for the queries with ORDER BY / GROUP BY and LIMIT. If there was a ref/range access to the table whose rows were required to be ordered in the result set the optimizer always employed this access though a scan by a different index that was compatible with the required order could be cheaper to produce the first L rows of the result set. Now for such queries the optimizer makes a choice between the cheapest ref/range accesses not compatible with the given order and index scans compatible with it. mysql-test/r/distinct.result: Adjusted results for test cases affected fy the fix for bug #28404. mysql-test/r/endspace.result: Adjusted results for test cases affected fy the fix for bug #28404. mysql-test/r/group_by.result: Adjusted results for test cases affected fy the fix for bug #28404. mysql-test/r/group_min_max.result: Adjusted results for test cases affected fy the fix for bug #28404. mysql-test/r/innodb.result: Adjusted results for test cases affected fy the fix for bug #28404. mysql-test/r/innodb_mysql.result: Adjusted results for test cases affected fy the fix for bug #28404. mysql-test/r/merge.result: Adjusted results for test cases affected fy the fix for bug #28404. mysql-test/r/order_by.result: Added a test case for bug #28404. mysql-test/r/select_found.result: Adjusted results for test cases affected fy the fix for bug #28404. mysql-test/r/subselect.result: Adjusted results for test cases affected fy the fix for bug #28404. mysql-test/t/distinct.test: Changed a test case after adding the fix for bug #28404. mysql-test/t/order_by.test: Added a test case for bug #28404. sql/sql_select.cc: Fixed bug#28404. This patch adds cost estimation for the queries with ORDER BY / GROUP BY and LIMIT. Now for such queries the optimizer makes a choice between the cheapest ref/range accesses not compatible with the given order and index scans compatible with it. Modified the function test_if_skip_sort_order to make the above mentioned choice cost based. sql/sql_select.h: Fixed bug#28404. This patch adds cost estimation for the queries with ORDER BY / GROUP BY and LIMIT. Added a new field fot the JOIN_TAB structure. --- mysql-test/r/distinct.result | 8 +- mysql-test/r/endspace.result | 2 +- mysql-test/r/group_by.result | 2 +- mysql-test/r/group_min_max.result | 10 +- mysql-test/r/innodb.result | 2 +- mysql-test/r/innodb_mysql.result | 22 +-- mysql-test/r/merge.result | 2 +- mysql-test/r/order_by.result | 55 ++++++ mysql-test/r/select_found.result | 2 +- mysql-test/r/subselect.result | 2 +- mysql-test/t/distinct.test | 2 +- mysql-test/t/order_by.test | 37 ++++ sql/sql_select.cc | 312 ++++++++++++++++++++++-------- sql/sql_select.h | 6 + 14 files changed, 359 insertions(+), 105 deletions(-) diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result index 002dbc6ccb5..795d8956a08 100644 --- a/mysql-test/r/distinct.result +++ b/mysql-test/r/distinct.result @@ -209,16 +209,16 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 Using index explain SELECT distinct t1.a from t1 order by a desc limit 1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 Using index +1 SIMPLE t1 index NULL PRIMARY 4 NULL 1 Using index explain SELECT distinct a from t3 order by a desc limit 2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 index NULL a 5 NULL 204 Using index +1 SIMPLE t3 index NULL a 5 NULL 40 Using index explain SELECT distinct a,b from t3 order by a+1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort -explain SELECT distinct a,b from t3 order by a limit 10; +explain SELECT distinct a,b from t3 order by a limit 2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 index NULL a 5 NULL 204 Using temporary +1 SIMPLE t3 index NULL a 5 NULL 2 Using temporary explain SELECT a,b from t3 group by a,b order by a+1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort diff --git a/mysql-test/r/endspace.result b/mysql-test/r/endspace.result index 6fb33dee826..9c8d12362c4 100644 --- a/mysql-test/r/endspace.result +++ b/mysql-test/r/endspace.result @@ -154,7 +154,7 @@ teststring teststring explain select * from t1 order by text1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL key1 34 NULL 3 +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort alter table t1 modify text1 char(32) binary not null; select * from t1 order by text1; text1 diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index ebe59331357..e09c66ac362 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -1144,7 +1144,7 @@ CREATE TABLE t2 (a INT, b INT, KEY(a)); INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4); EXPLAIN SELECT a, SUM(b) FROM t2 GROUP BY a LIMIT 2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index NULL a 5 NULL 4 +1 SIMPLE t2 index NULL a 5 NULL 2 EXPLAIN SELECT a, SUM(b) FROM t2 IGNORE INDEX (a) GROUP BY a LIMIT 2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using temporary; Using filesort diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result index b6bf7260dc2..02b1459afd0 100644 --- a/mysql-test/r/group_min_max.result +++ b/mysql-test/r/group_min_max.result @@ -1963,20 +1963,20 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using temporary; Using filesort explain select a1,a2,count(a2) from t1 group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using index +1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using index explain extended select a1,a2,count(a2) from t1 where (a1 > 'a') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 128 75.00 Using where; Using index +1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using index Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,count(`test`.`t1`.`a2`) AS `count(a2)` from `test`.`t1` where (`test`.`t1`.`a1` > _latin1'a') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` explain extended select sum(ord(a1)) from t1 where (a1 > 'a') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 128 75.00 Using where; Using index +1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using index Warnings: Note 1003 select sum(ord(`test`.`t1`.`a1`)) AS `sum(ord(a1))` from `test`.`t1` where (`test`.`t1`.`a1` > _latin1'a') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` explain select distinct(a1) from t1 where ord(a2) = 98; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index +1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index select distinct(a1) from t1 where ord(a2) = 98; a1 a @@ -2256,7 +2256,7 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1_outer index NULL a 10 NULL 15 Using where; Using index -2 DEPENDENT SUBQUERY t1 index NULL a 10 NULL 15 Using index +2 DEPENDENT SUBQUERY t1 index NULL a 10 NULL 1 Using index EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 804c4b81c17..dce5e1a9a35 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -947,7 +947,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL PRIMARY 4 NULL # explain select * from t1 order by b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL b 4 NULL # +1 SIMPLE t1 ALL NULL NULL NULL NULL # Using filesort explain select * from t1 order by c; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL # Using filesort diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 273374d016b..bf12c31326a 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -851,13 +851,13 @@ EXPLAIN SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY a; id 1 select_type SIMPLE table t1 -type range +type index possible_keys bkey -key bkey -key_len 5 +key PRIMARY +key_len 4 ref NULL -rows 16 -Extra Using where; Using index; Using filesort +rows 32 +Extra Using where; Using index SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY a; a b 1 2 @@ -946,13 +946,13 @@ EXPLAIN SELECT * FROM t2 WHERE b=1 ORDER BY a; id 1 select_type SIMPLE table t2 -type ref +type index possible_keys bkey -key bkey -key_len 5 -ref const -rows 8 -Extra Using where; Using index; Using filesort +key PRIMARY +key_len 4 +ref NULL +rows 16 +Extra Using where; Using index SELECT * FROM t2 WHERE b=1 ORDER BY a; a b c 1 1 1 diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index bb4fc654b38..5aa4288500c 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -86,7 +86,7 @@ a b 19 Testing explain select a from t3 order by a desc limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 index NULL a 4 NULL 1131 Using index +1 SIMPLE t3 index NULL a 4 NULL 10 Using index select a from t3 order by a desc limit 10; a 699 diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index 25fbeadf21b..fd3fb89b5f4 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -1073,3 +1073,58 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY,b b 5 const 1 1 SIMPLE t2 ref a a 5 const 2 Using where; Using index DROP TABLE t1,t2; +CREATE TABLE t1( +id int auto_increment PRIMARY KEY, c2 int, c3 int, INDEX k2(c2), INDEX k3(c3)); +INSERT INTO t1 (c2,c3) VALUES +(31,34),(35,38),(34,31),(32,35),(31,39), +(11,14),(15,18),(14,11),(12,15),(11,19); +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +SELECT COUNT(*) FROM t1; +COUNT(*) +40960 +EXPLAIN SELECT id,c3 FROM t1 WHERE c2=11 ORDER BY c3 LIMIT 20; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index k2 k3 5 NULL 88 Using where +EXPLAIN SELECT id,c3 FROM t1 WHERE c2=11 ORDER BY c3 LIMIT 100; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref k2 k2 5 const 9300 Using where; Using filesort +EXPLAIN SELECT id,c3 FROM t1 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 100; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index k2 k3 5 NULL 316 Using where +EXPLAIN SELECT id,c3 FROM t1 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 2000; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range k2 k2 5 NULL 12937 Using where; Using filesort +SELECT id,c3 FROM t1 WHERE c2=11 ORDER BY c3 LIMIT 20; +id c3 +6 14 +16 14 +26 14 +36 14 +46 14 +56 14 +66 14 +76 14 +86 14 +96 14 +106 14 +116 14 +126 14 +136 14 +146 14 +156 14 +166 14 +176 14 +186 14 +196 14 +DROP TABLE t1; diff --git a/mysql-test/r/select_found.result b/mysql-test/r/select_found.result index 7abd65beb46..7896f8a9f4e 100644 --- a/mysql-test/r/select_found.result +++ b/mysql-test/r/select_found.result @@ -84,7 +84,7 @@ UNIQUE KEY e_n (email,name) EXPLAIN SELECT SQL_CALC_FOUND_ROWS DISTINCT email FROM t2 LEFT JOIN t1 ON kid = t2.id WHERE t1.id IS NULL LIMIT 10; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 system PRIMARY,kid NULL NULL NULL 0 const row not found -1 SIMPLE t2 index NULL e_n 104 NULL 200 +1 SIMPLE t2 index NULL e_n 104 NULL 10 SELECT SQL_CALC_FOUND_ROWS DISTINCT email FROM t2 LEFT JOIN t1 ON kid = t2.id WHERE t1.id IS NULL LIMIT 10; email email1 diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 40b9e489577..a25183a0e6d 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -3419,7 +3419,7 @@ EXPLAIN SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where -2 DEPENDENT SUBQUERY t1 index NULL a 8 NULL 9 Using filesort +2 DEPENDENT SUBQUERY t1 index NULL a 8 NULL 1 Using filesort DROP TABLE t1; create table t1( f1 int,f2 int); insert into t1 values (1,1),(2,2); diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test index 7310f98cd16..bfdb5f8b9f8 100644 --- a/mysql-test/t/distinct.test +++ b/mysql-test/t/distinct.test @@ -97,7 +97,7 @@ explain SELECT t1.a from t1 group by a order by a desc; explain SELECT distinct t1.a from t1 order by a desc limit 1; explain SELECT distinct a from t3 order by a desc limit 2; explain SELECT distinct a,b from t3 order by a+1; -explain SELECT distinct a,b from t3 order by a limit 10; +explain SELECT distinct a,b from t3 order by a limit 2; explain SELECT a,b from t3 group by a,b order by a+1; drop table t1,t2,t3,t4; diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index 1e520da9f00..fb08dbe74e6 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -739,3 +739,40 @@ INSERT INTO t2 VALUES (1,1),(1,2),(2,1),(2,2); EXPLAIN SELECT 1 FROM t1,t2 WHERE t1.b=2 AND t1.a=t2.a ORDER BY t2.b; DROP TABLE t1,t2; + +# End of 5.0 + +# +# Bug #28404: query with ORDER BY and ref access +# + +CREATE TABLE t1( + id int auto_increment PRIMARY KEY, c2 int, c3 int, INDEX k2(c2), INDEX k3(c3)); + +INSERT INTO t1 (c2,c3) VALUES + (31,34),(35,38),(34,31),(32,35),(31,39), + (11,14),(15,18),(14,11),(12,15),(11,19); + +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; + +SELECT COUNT(*) FROM t1; + +EXPLAIN SELECT id,c3 FROM t1 WHERE c2=11 ORDER BY c3 LIMIT 20; +EXPLAIN SELECT id,c3 FROM t1 WHERE c2=11 ORDER BY c3 LIMIT 100; +EXPLAIN SELECT id,c3 FROM t1 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 100; +EXPLAIN SELECT id,c3 FROM t1 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 2000; + +SELECT id,c3 FROM t1 WHERE c2=11 ORDER BY c3 LIMIT 20; + +DROP TABLE t1; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 6a381c1f367..c079f2e030f 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -6450,6 +6450,7 @@ void JOIN_TAB::cleanup() quick= 0; x_free(cache.buff); cache.buff= 0; + limit= 0; if (table) { if (table->key_read) @@ -12588,9 +12589,12 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, { int ref_key; uint ref_key_parts; + int order_direction; + uint used_key_parts; TABLE *table=tab->table; SQL_SELECT *select=tab->select; key_map usable_keys; + QUICK_SELECT_I *save_quick; DBUG_ENTER("test_if_skip_sort_order"); LINT_INIT(ref_key_parts); @@ -12625,6 +12629,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, else if (select && select->quick) // Range found by opt_range { int quick_type= select->quick->get_type(); + save_quick= select->quick; /* assume results are not ordered when index merge is used TODO: sergeyp: Results of all index merge selects actually are ordered @@ -12644,8 +12649,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, /* We come here when there is a REF key. */ - int order_direction; - uint used_key_parts; if (!usable_keys.is_set(ref_key)) { /* @@ -12706,63 +12709,30 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, } /* Check if we get the rows in requested sorted order by using the key */ if (usable_keys.is_set(ref_key) && - (order_direction = test_if_order_by_key(order,table,ref_key, - &used_key_parts))) - { - if (order_direction == -1) // If ORDER BY ... DESC - { - if (select && select->quick) - { - /* - Don't reverse the sort order, if it's already done. - (In some cases test_if_order_by_key() can be called multiple times - */ - if (!select->quick->reverse_sorted()) - { - QUICK_SELECT_DESC *tmp; - int quick_type= select->quick->get_type(); - if (quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE || - quick_type == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT || - quick_type == QUICK_SELECT_I::QS_TYPE_ROR_UNION || - quick_type == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX) - DBUG_RETURN(0); // Use filesort - - /* ORDER BY range_key DESC */ - tmp= new QUICK_SELECT_DESC((QUICK_RANGE_SELECT*)(select->quick), - used_key_parts); - if (!tmp || tmp->error) - { - delete tmp; - DBUG_RETURN(0); // Reverse sort not supported - } - select->quick=tmp; - } - DBUG_RETURN(1); - } - if (tab->ref.key_parts < used_key_parts) - { - /* - SELECT * FROM t1 WHERE a=1 ORDER BY a DESC,b DESC - - Use a traversal function that starts by reading the last row - with key part (A) and then traverse the index backwards. - */ - tab->read_first_record= join_read_last_key; - tab->read_record.read_record= join_read_prev_same; - /* fall through */ - } - } - else if (select && select->quick) - select->quick->sorted= 1; - DBUG_RETURN(1); /* No need to sort */ - } + (order_direction= test_if_order_by_key(order,table,ref_key, + &used_key_parts))) + goto check_reverse_order; } - else { - /* check if we can use a key to resolve the group */ - /* Tables using JT_NEXT are handled here */ + /* + Check whether there is an index compatible with the given order + usage of which is cheaper than usage of the ref_key index (ref_key>=0) + or a table scan. + It may be the case if ORDER/GROUP BY is used with LIMIT. + */ uint nr; key_map keys; + uint best_key_parts; + int best_key_direction; + ha_rows best_records; + double read_time; + int best_key= -1; + bool is_best_covering= FALSE; + double fanout= 1; + JOIN *join= tab->join; + uint tablenr= tab - join->join_tab; + ha_rows table_records= table->file->stats.records; + bool group= join->group && order == join->group_list; /* filesort() and join cache are usually faster than reading in @@ -12775,7 +12745,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, resolved with a key; This is because filesort() is usually faster than retrieving all rows through an index. */ - if (select_limit >= table->file->stats.records) + if (select_limit >= table_records) { keys= *table->file->keys_to_use_for_scanning(); keys.merge(table->covering_keys); @@ -12786,38 +12756,224 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, This is to allow users to use index in ORDER BY. */ if (table->force_index) - keys.merge(table->keys_in_use_for_query); + keys.merge(group ? table->keys_in_use_for_group_by : + table->keys_in_use_for_order_by); keys.intersect(usable_keys); } else keys= usable_keys; + read_time= join->best_positions[tablenr].read_time; + for (uint i= tablenr+1; i < join->tables; i++) + fanout*= join->best_positions[i].records_read; // fanout is always >= 1 + for (nr=0; nr < table->s->keys ; nr++) { - uint not_used; - if (keys.is_set(nr)) + int direction; + if (keys.is_set(nr) && + (direction= test_if_order_by_key(order, table, nr, &used_key_parts))) { - int flag; - if ((flag= test_if_order_by_key(order, table, nr, ¬_used))) - { - if (!no_changes) - { - tab->index=nr; - tab->read_first_record= (flag > 0 ? join_read_first: - join_read_last); - tab->type=JT_NEXT; // Read with index_first(), index_next() - if (table->covering_keys.is_set(nr)) - { - table->key_read=1; - table->file->extra(HA_EXTRA_KEYREAD); - } - } - DBUG_RETURN(1); - } + bool is_covering= table->covering_keys.is_set(nr) || + nr == table->s->primary_key && + table->file->primary_key_is_clustered(); + + /* + Don't use an index scan with ORDER BY without limit. + For GROUP BY without limit always use index scan + if there is a suitable index. + Why we hold to this asymmetry hardly can be explained + rationally. It's easy to demonstrate that using + temporary table + filesort could be cheaper for grouping + queries too. + */ + if (is_covering || + select_limit != HA_POS_ERROR || + ref_key < 0 && (group || table->force_index)) + { + double rec_per_key; + double index_scan_time; + KEY *keyinfo= tab->table->key_info+nr; + if (select_limit == HA_POS_ERROR) + select_limit= table_records; + if (group) + { + rec_per_key= keyinfo->rec_per_key[used_key_parts-1]; + set_if_bigger(rec_per_key, 1); + /* + With a grouping query each group containing on average + rec_per_key records produces only one row that will + be included into the result set. + */ + if (select_limit > table_records/rec_per_key) + select_limit= table_records; + else + select_limit= (ha_rows) (select_limit*rec_per_key); + } + /* + If tab=tk is not the last joined table tn then to get first + L records from the result set we can expect to retrieve + only L/fanout(tk,tn) where fanout(tk,tn) says how many + rows in the record set on average will match each row tk. + Usually our estimates for fanouts are too pessimistic. + So the estimate for L/fanout(tk,tn) will be too optimistic + and as result we'll choose an index scan when using ref/range + access + filesort will be cheaper. + */ + select_limit= (ha_rows) (select_limit < fanout ? + 1 : select_limit/fanout); + /* + We assume that each of the tested indexes is not correlated + with ref_key. Thus, to select first N records we have to scan + N/selectivity(ref_key) index entries. + selectivity(ref_key) = #scanned_records/#table_records = + table->quick_condition_rows/table_records. + In any case we can't select more than #table_records. + N/(table->quick_condition_rows/table_records) > table_records + <=> N > table->quick_condition_rows. + */ + if (select_limit > table->quick_condition_rows) + select_limit= table_records; + else + select_limit= (ha_rows) (select_limit * + (double) table_records / + table->quick_condition_rows); + rec_per_key= keyinfo->rec_per_key[keyinfo->key_parts-1]; + set_if_bigger(rec_per_key, 1); + /* + Here we take into account the fact that rows are + accessed in sequences rec_per_key records in each. + Rows in such a sequence are supposed to be ordered + by rowid/primary key. When reading the data + in a sequence we'll touch not more pages than the + table file contains. + TODO. Use the formula for a disk sweep sequential access + to calculate the cost of accessing data rows for one + index entry. + */ + index_scan_time= select_limit/rec_per_key * + min(rec_per_key, table->file->scan_time()); + if (is_covering || + ref_key < 0 && (group || table->force_index) || + index_scan_time < read_time) + { + ha_rows quick_records= table_records; + if (is_best_covering && !is_covering) + continue; + if (table->quick_keys.is_set(nr)) + quick_records= table->quick_rows[nr]; + if (best_key < 0 || + (select_limit <= min(quick_records,best_records) ? + keyinfo->key_parts < best_key_parts : + quick_records < best_records)) + { + best_key= nr; + best_key_parts= keyinfo->key_parts; + best_records= quick_records; + is_best_covering= is_covering; + best_key_direction= direction; + } + } + } } } + if (best_key >= 0) + { + bool quick_created= FALSE; + if (table->quick_keys.is_set(best_key) && best_key != ref_key) + { + key_map map; + map.clear_all(); // Force the creation of quick select + map.set_bit(best_key); // only best_key. + quick_created= + select->test_quick_select(join->thd, map, 0, + join->select_options & OPTION_FOUND_ROWS ? + HA_POS_ERROR : + join->unit->select_limit_cnt, + 0) > 0; + } + if (!no_changes) + { + if (!quick_created) + { + tab->index= best_key; + tab->read_first_record= best_key_direction > 0 ? + join_read_first:join_read_last; + tab->type=JT_NEXT; // Read with index_first(), index_next() + if (table->covering_keys.is_set(best_key)) + { + table->key_read=1; + table->file->extra(HA_EXTRA_KEYREAD); + } + table->file->ha_index_or_rnd_end(); + if (join->select_options & SELECT_DESCRIBE) + { + tab->ref.key= -1; + tab->ref.key_parts= 0; + if (tab->select) + tab->select->quick= 0; + if (select_limit < table_records) + tab->limit= select_limit; + } + } + } + used_key_parts= best_key_parts; + order_direction= best_key_direction; + } + else + DBUG_RETURN(0); + } + +check_reverse_order: + if (order_direction == -1) // If ORDER BY ... DESC + { + if (select && select->quick) + { + /* + Don't reverse the sort order, if it's already done. + (In some cases test_if_order_by_key() can be called multiple times + */ + if (!select->quick->reverse_sorted()) + { + QUICK_SELECT_DESC *tmp; + int quick_type= select->quick->get_type(); + if (quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE || + quick_type == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT || + quick_type == QUICK_SELECT_I::QS_TYPE_ROR_UNION || + quick_type == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX) + { + tab->limit= 0; + select->quick= save_quick; + DBUG_RETURN(0); // Use filesort + } + + /* ORDER BY range_key DESC */ + tmp= new QUICK_SELECT_DESC((QUICK_RANGE_SELECT*)(select->quick), + used_key_parts); + if (!tmp || tmp->error) + { + delete tmp; + select->quick= save_quick; + tab->limit= 0; + DBUG_RETURN(0); // Reverse sort not supported + } + select->quick=tmp; + } + } + else if (tab->ref.key >= 0 && tab->ref.key_parts < used_key_parts) + { + /* + SELECT * FROM t1 WHERE a=1 ORDER BY a DESC,b DESC + + Use a traversal function that starts by reading the last row + with key part (A) and then traverse the index backwards. + */ + tab->read_first_record= join_read_last_key; + tab->read_record.read_record= join_read_prev_same; + } } - DBUG_RETURN(0); // Can't use index. + else if (select && select->quick) + select->quick->sorted= 1; + DBUG_RETURN(1); } @@ -15524,7 +15680,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, if (tab->select && tab->select->quick) examined_rows= tab->select->quick->records; else if (tab->type == JT_NEXT || tab->type == JT_ALL) - examined_rows= tab->table->file->records(); + examined_rows= tab->limit ? tab->limit : tab->table->file->records(); else examined_rows=(ha_rows)join->best_positions[i].records_read; diff --git a/sql/sql_select.h b/sql/sql_select.h index 98f2a7829dd..61df43094c2 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -194,6 +194,12 @@ typedef struct st_join_table { enum join_type type; bool cached_eq_ref_table,eq_ref_table,not_used_in_distinct; bool sorted; + /* + If it's not 0 the number stored this field indicates that the index + scan has been chosen to access the table data and we expect to scan + this number of rows for the table. + */ + ha_rows limit; TABLE_REF ref; JOIN_CACHE cache; JOIN *join; From 8df5a067c33191720542790d3963438cdacaa6cc Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Aug 2007 21:59:26 +0200 Subject: [PATCH 28/74] Limit stack size of the server to 1 MB. Manual transfer of the fix for bug#20815 from 5.0 to 5.1 CMakeLists.txt: Limit stack size of the server to 1 MB. Manual transfer of the fix for bug#20815 from 5.0 to 5.1 --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6395ae17a14..48ae7837c1a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -136,6 +136,9 @@ IF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR # generate .map files SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MAP /MAPINFO:EXPORTS") + # set stack size (see bug#20815) + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:1048576") + # remove support for Exception handling STRING(REPLACE "/GX" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) From a53510f0be0bfdbaff6e60366d5e8cfc1d2d197f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 01:58:21 +0500 Subject: [PATCH 29/74] Fixed bug #27352. The SELECT query with more than 31 nested dependent SELECT queries returned wrong result. New error message has been added: ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT. It will be reported as: "Too high level of nesting for select". sql/sql_parse.cc: Fixed bug #27352. The Item_sum::register_sum_func method has been modified to return TRUE on exceeding of allowed level of SELECT nesting and to report corresponding error message. sql/unireg.h: Fixed bug #27352. Constant definition has been added: maximal allowed level of SELECT nesting. mysql-test/t/select.test: Updated test case for bug #27352. mysql-test/r/select.result: Updated test case for bug #27352. sql/share/errmsg.txt: Fixed bug #27352. New error message has been added: ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT. --- mysql-test/r/select.result | 10 ++++++++++ mysql-test/t/select.test | 30 ++++++++++++++++++++++++++++++ sql/share/errmsg.txt | 2 ++ sql/sql_parse.cc | 5 +++++ sql/unireg.h | 2 ++ 5 files changed, 49 insertions(+) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index bfe0b9d19df..5930c36029f 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -3995,4 +3995,14 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE f1 index inx inx 10 NULL 7 Using where; Using index 1 SIMPLE f2 ref inx inx 5 test.f1.b 1 Using where; Using index DROP TABLE t1; +CREATE TABLE t1 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1,11), (2,22), (2,22); +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2)))))))))))))))))))))))))))))))) > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +31 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used +32 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) > 0; +ERROR HY000: Too high level of nesting for select +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 56b2f1b02b8..8bfa12539fa 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -3370,4 +3370,34 @@ EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2 WHERE 1 AND f1.b NOT IN (100,2232,3343,51111); DROP TABLE t1; +# +# Bug #27352: Incorrect result of nested selects instead of error reporting +# + +CREATE TABLE t1 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1,11), (2,22), (2,22); + +let $n= 31; +let $q= COUNT(c2); +while ($n) +{ + let $q= (SELECT $q); + dec $n; +} +--disable_warnings +eval EXPLAIN SELECT c1 FROM t1 WHERE $q > 0; +--enable_warnings + +let $n= 64; +let $q= COUNT(c2); +while ($n) +{ + let $q= (SELECT $q); + dec $n; +} +--error ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT +eval EXPLAIN SELECT c1 FROM t1 WHERE $q > 0; + +DROP TABLE t1; + --echo End of 5.0 tests diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index a52ffa8216c..6d4ca33ccc7 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5635,3 +5635,5 @@ ER_NON_INSERTABLE_TABLE eng "The target table %-.100s of the %s is not insertable-into" ER_ADMIN_WRONG_MRG_TABLE eng "Table '%-.64s' is differently defined or of non-MyISAM type or doesn't exist" +ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT + eng "Too high level of nesting for select" diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ae3bc0f5597..78b3904a207 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5889,6 +5889,11 @@ mysql_new_select(LEX *lex, bool move_down) select_lex->init_query(); select_lex->init_select(); lex->nest_level++; + if (lex->nest_level > (int) MAX_SELECT_NESTING) + { + my_error(ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT,MYF(0),MAX_SELECT_NESTING); + DBUG_RETURN(1); + } select_lex->nest_level= lex->nest_level; /* Don't evaluate this subquery during statement prepare even if diff --git a/sql/unireg.h b/sql/unireg.h index 81ca18c1d32..d8301060cc4 100644 --- a/sql/unireg.h +++ b/sql/unireg.h @@ -81,6 +81,8 @@ RAND_TABLE_BIT) #define MAX_FIELDS 4096 /* Limit in the .frm file */ +#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1) + #define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD) #define MIN_SORT_MEMORY (32*1024-MALLOC_OVERHEAD) From 82d28fada7dc928564aefac802400c6684c11917 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 03:14:05 +0500 Subject: [PATCH 30/74] WL#3732 Information schema optimization client/mysqldump.c: table type compare is changed to case insensitive mysql-test/r/information_schema.result: test result mysql-test/r/information_schema_db.result: result fix mysql-test/suite/ndb/r/ndb_alter_table.result: result fix mysql-test/suite/ndb/r/ndb_temporary.result: result fix mysql-test/t/information_schema.test: test case sql/ha_ndbcluster.cc: char* variables are changed to LEX_STRING sql/ha_ndbcluster.h: char* variables are changed to LEX_STRING sql/ha_ndbcluster_binlog.cc: char* variables are changed to LEX_STRING sql/handler.cc: char* variables are changed to LEX_STRING sql/handler.h: char* variables are changed to LEX_STRING sql/sql_base.cc: Modified functions which are used during open table process according to table opening method and requested_object. sql/sql_select.cc: Add support for I_S tables into select_describe() function sql/sql_show.cc: 1. Added initialization of 'open_method' to 'st_field_info' structs. 2. Added initialization of 'i_s_requested_object' to 'ST_SCHEMA_TABLE' structs. 3. New function which calculates database name and table name values from 'where' condition if it's possible void get_lookup_field_values(THD *thd, COND *cond, TABLE_LIST *table, LOOKUP_FIELD_VALUES *lookup_field_vals); 4. New function which set table open method setup_table_open_method(TABLE_LIST *tables, ST_SCHEMA_TABLE *schema_table, enum enum_schema_tables schema_table_idx) 5. New function int make_db_list(THD *thd, List *files, LOOKUP_FIELD_VALUES *lookup_field_vals, bool *with_i_schema) 6. New function int make_table_name_list(THD *thd, List *files, LEX *lex, LOOKUP_FIELD_VALUES *lookup_field_vals, bool with_i_schema, LEX_STRING *db_name) 7. Modified 'get_all_tables' function according to new schema(see wl#3732). sql/sql_show.h: char* variables are changed to LEX_STRING sql/table.cc: Modified functions which are used during open table process according to table opening method and requested_object. sql/table.h: 1. added new constants(open_method) #define SKIP_OPEN_TABLE 0 #define OPEN_FRM_ONLY 1 #define OPEN_FULL_TABLE 2 2. Added new field 'open_method' into struct st_field_info; uint open_method; 3. Added new field into ST_SCHEMA_TABLE struct uint i_s_requested_object; /* the object we need to open(TABLE | VIEW) */. 4. Added new field to TABLE_LIST struct. uint i_s_requested_object; This field is set from ST_SCHEMA_TABLE.i_s_requested_object for processed table before opening. 5. Added new fields to TABLE_LIST struct, used for 'explain select' for I_S table bool has_db_lookup_value; bool has_table_lookup_value; uint table_open_method; sql/unireg.h: added new constants --- client/mysqldump.c | 3 +- mysql-test/r/information_schema.result | 40 +- mysql-test/r/information_schema_db.result | 4 +- mysql-test/suite/ndb/r/ndb_alter_table.result | 8 +- mysql-test/suite/ndb/r/ndb_temporary.result | 2 +- mysql-test/t/information_schema.test | 20 + sql/ha_ndbcluster.cc | 71 +- sql/ha_ndbcluster.h | 2 +- sql/ha_ndbcluster_binlog.cc | 8 +- sql/handler.cc | 4 +- sql/handler.h | 4 +- sql/sql_base.cc | 14 +- sql/sql_select.cc | 108 +- sql/sql_show.cc | 2260 +++++++++++------ sql/sql_show.h | 2 +- sql/table.cc | 22 +- sql/table.h | 15 +- sql/unireg.h | 5 + 18 files changed, 1650 insertions(+), 942 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index cfdde285040..ef68c11900a 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -4288,7 +4288,8 @@ char check_if_ignore_table(const char *table_name, char *table_type) If these two types, we do want to skip dumping the table */ if (!opt_no_data && - (!strcmp(table_type,"MRG_MyISAM") || !strcmp(table_type,"MRG_ISAM"))) + (!my_strcasecmp(&my_charset_latin1, table_type, "MRG_MyISAM") || + !strcmp(table_type,"MRG_ISAM"))) result= IGNORE_DATA; } mysql_free_result(res); diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 804c15f6aa1..f81277b1ff9 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -289,8 +289,8 @@ explain select a.ROUTINE_NAME from information_schema.ROUTINES a, information_schema.SCHEMATA b where a.ROUTINE_SCHEMA = b.SCHEMA_NAME; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE # ALL NULL NULL NULL NULL 2 -1 SIMPLE # ALL NULL NULL NULL NULL 2 Using where; Using join buffer +1 SIMPLE # ALL NULL NULL NULL NULL NULL +1 SIMPLE # ALL NULL NULL NULL NULL NULL Using where; Using join buffer select a.ROUTINE_NAME, b.name from information_schema.ROUTINES a, mysql.proc b where a.ROUTINE_NAME = convert(b.name using utf8) order by 1; ROUTINE_NAME name @@ -355,7 +355,7 @@ mysql test explain select * from v0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE # ALL NULL NULL NULL NULL 2 +1 SIMPLE # ALL NULL NULL NULL NULL NULL create view v1 (c) as select table_name from information_schema.tables where table_name="v1"; select * from v1; @@ -679,17 +679,11 @@ where table_schema='test'; table_name v2 v3 -Warnings: -Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them -Warning 1356 View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them select table_name from information_schema.views where table_schema='test'; table_name v2 v3 -Warnings: -Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them -Warning 1356 View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them select column_name from information_schema.columns where table_schema='test'; column_name @@ -1337,11 +1331,11 @@ from information_schema.tables order by object_schema; explain select * from v1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE tables ALL NULL NULL NULL NULL 2 Using filesort +1 SIMPLE tables ALL NULL NULL NULL NULL NULL Open_frm_only; Scanned all databases; Using filesort explain select * from (select table_name from information_schema.tables) as a; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY system NULL NULL NULL NULL 0 const row not found -2 DERIVED tables ALL NULL NULL NULL NULL 2 +2 DERIVED tables ALL NULL NULL NULL NULL NULL Skip_open_table; Scanned all databases drop view v1; create table t1 (f1 int(11)); create table t2 (f1 int(11), f2 int(11)); @@ -1445,4 +1439,28 @@ ABORTED_CONNECTS BINLOG_CACHE_DISK_USE DROP TABLE server_status; SET GLOBAL event_scheduler=0; +explain select table_name from information_schema.views where +table_schema='test' and table_name='v1'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE views ALL NULL TABLE_SCHEMA,TABLE_NAME NULL NULL NULL Using where; Open_frm_only; Scanned 0 databases +explain select * from information_schema.tables; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE tables ALL NULL NULL NULL NULL NULL Open_full_table; Scanned all databases +explain select * from information_schema.collations; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE collations ALL NULL NULL NULL NULL NULL +explain select * from information_schema.tables where +table_schema='test' and table_name= 't1'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE tables ALL NULL TABLE_SCHEMA,TABLE_NAME NULL NULL NULL Using where; Open_full_table; Scanned 0 databases +explain select table_name, table_type from information_schema.tables +where table_schema='test'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE tables ALL NULL TABLE_SCHEMA NULL NULL NULL Using where; Open_frm_only; Scanned 1 database +explain select b.table_name +from information_schema.tables a, information_schema.columns b +where a.table_name='t1' and a.table_schema='test' and b.table_name=a.table_name; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE a ALL NULL TABLE_SCHEMA,TABLE_NAME NULL NULL NULL Using where; Skip_open_table; Scanned 0 databases +1 SIMPLE b ALL NULL NULL NULL NULL NULL Using where; Open_frm_only; Scanned all databases; Using join buffer End of 5.1 tests. diff --git a/mysql-test/r/information_schema_db.result b/mysql-test/r/information_schema_db.result index a0fd33ac068..e5a5a583de3 100644 --- a/mysql-test/r/information_schema_db.result +++ b/mysql-test/r/information_schema_db.result @@ -74,11 +74,11 @@ drop table t1; select table_name, table_type, table_comment from information_schema.tables where table_schema='inf%' and func2(); table_name table_type table_comment -v1 VIEW View 'inf%.v1' references invalid table(s) or column(s) or function(s) or define +v1 VIEW VIEW select table_name, table_type, table_comment from information_schema.tables where table_schema='inf%' and func2(); table_name table_type table_comment -v1 VIEW View 'inf%.v1' references invalid table(s) or column(s) or function(s) or define +v1 VIEW VIEW drop view v1; drop function func1; drop function func2; diff --git a/mysql-test/suite/ndb/r/ndb_alter_table.result b/mysql-test/suite/ndb/r/ndb_alter_table.result index 13c445b44ca..5798db73403 100644 --- a/mysql-test/suite/ndb/r/ndb_alter_table.result +++ b/mysql-test/suite/ndb/r/ndb_alter_table.result @@ -34,13 +34,13 @@ col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null, col6 int not null, to_be_deleted int) ENGINE=ndbcluster; show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 NDBCLUSTER 10 Dynamic 0 # # # 0 # 1 # # # latin1_swedish_ci NULL # +t1 ndbcluster 10 Dynamic 0 # # # 0 # 1 # # # latin1_swedish_ci NULL # SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; insert into t1 values (0,4,3,5,"PENDING",1,7),(NULL,4,3,5,"PENDING",1,7),(31,4,3,5,"PENDING",1,7), (7,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7), (100,4,3,5,"PENDING",1,7), (99,4,3,5,"PENDING",1,7), (8,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 NDBCLUSTER 10 Dynamic 9 # # # 0 # 102 # # # latin1_swedish_ci NULL # +t1 ndbcluster 10 Dynamic 9 # # # 0 # 102 # # # latin1_swedish_ci NULL # select * from t1 order by col1; col1 col2 col3 col4 col5 col6 to_be_deleted 0 4 3 5 PENDING 1 7 @@ -60,7 +60,7 @@ change column col2 fourth varchar(30) not null after col3, modify column col6 int not null first; show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 NDBCLUSTER 10 Dynamic 9 # # # 0 # 102 # # # latin1_swedish_ci NULL # +t1 ndbcluster 10 Dynamic 9 # # # 0 # 102 # # # latin1_swedish_ci NULL # select * from t1 order by col1; col6 col1 col3 fourth col4 col4_5 col5 col7 col8 1 0 3 4 5 PENDING 0000-00-00 00:00:00 @@ -75,7 +75,7 @@ col6 col1 col3 fourth col4 col4_5 col5 col7 col8 insert into t1 values (2, NULL,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 NDBCLUSTER 10 Dynamic 10 # # # 0 # 103 # # # latin1_swedish_ci NULL # +t1 ndbcluster 10 Dynamic 10 # # # 0 # 103 # # # latin1_swedish_ci NULL # select * from t1 order by col1; col6 col1 col3 fourth col4 col4_5 col5 col7 col8 1 0 3 4 5 PENDING 0000-00-00 00:00:00 diff --git a/mysql-test/suite/ndb/r/ndb_temporary.result b/mysql-test/suite/ndb/r/ndb_temporary.result index 61fc1561e4f..7b7740003af 100644 --- a/mysql-test/suite/ndb/r/ndb_temporary.result +++ b/mysql-test/suite/ndb/r/ndb_temporary.result @@ -9,7 +9,7 @@ SET SESSION storage_engine=NDBCLUSTER; create table t1 (a int key); select engine from information_schema.tables where table_name = 't1'; engine -NDBCLUSTER +ndbcluster drop table t1; create temporary table t1 (a int key); show create table t1; diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 6fa2a9ebc51..774e75a79fa 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1100,4 +1100,24 @@ SELECT variable_name FROM server_status; DROP TABLE server_status; SET GLOBAL event_scheduler=0; + +# +# WL#3732 Information schema optimization +# + +explain select table_name from information_schema.views where +table_schema='test' and table_name='v1'; + +explain select * from information_schema.tables; +explain select * from information_schema.collations; + +explain select * from information_schema.tables where +table_schema='test' and table_name= 't1'; +explain select table_name, table_type from information_schema.tables +where table_schema='test'; + +explain select b.table_name +from information_schema.tables a, information_schema.columns b +where a.table_name='t1' and a.table_schema='test' and b.table_name=a.table_name; + --echo End of 5.1 tests. diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 48712600e79..3b68b3828d2 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -6883,7 +6883,7 @@ int ndbcluster_find_all_files(THD *thd) int ndbcluster_find_files(handlerton *hton, THD *thd, const char *db, const char *path, - const char *wild, bool dir, List *files) + const char *wild, bool dir, List *files) { DBUG_ENTER("ndbcluster_find_files"); DBUG_PRINT("enter", ("db: %s", db)); @@ -6950,21 +6950,22 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, my_hash_insert(&ndb_tables, (uchar*)thd->strdup(elmt.name)); } - char *file_name; - List_iterator it(*files); + LEX_STRING *file_name; + List_iterator it(*files); List delete_list; + char *file_name_str; while ((file_name=it++)) { bool file_on_disk= FALSE; - DBUG_PRINT("info", ("%s", file_name)); - if (hash_search(&ndb_tables, (uchar*) file_name, strlen(file_name))) + DBUG_PRINT("info", ("%s", file_name->str)); + if (hash_search(&ndb_tables, (uchar*) file_name->str, file_name->length)) { - DBUG_PRINT("info", ("%s existed in NDB _and_ on disk ", file_name)); + DBUG_PRINT("info", ("%s existed in NDB _and_ on disk ", file_name->str)); file_on_disk= TRUE; } // Check for .ndb file with this name - build_table_filename(name, sizeof(name), db, file_name, ha_ndb_ext, 0); + build_table_filename(name, sizeof(name), db, file_name->str, ha_ndb_ext, 0); DBUG_PRINT("info", ("Check access for %s", name)); if (my_access(name, F_OK)) { @@ -6972,33 +6973,34 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, // .ndb file did not exist on disk, another table type if (file_on_disk) { - // Ignore this ndb table - uchar *record= hash_search(&ndb_tables, (uchar*) file_name, - strlen(file_name)); + // Ignore this ndb table + uchar *record= hash_search(&ndb_tables, (uchar*) file_name->str, + file_name->length); DBUG_ASSERT(record); hash_delete(&ndb_tables, record); push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_TABLE_EXISTS_ERROR, "Local table %s.%s shadows ndb table", - db, file_name); + db, file_name->str); } continue; } if (file_on_disk) { // File existed in NDB and as frm file, put in ok_tables list - my_hash_insert(&ok_tables, (uchar*)file_name); + my_hash_insert(&ok_tables, (uchar*) file_name->str); continue; } DBUG_PRINT("info", ("%s existed on disk", name)); // The .ndb file exists on disk, but it's not in list of tables in ndb // Verify that handler agrees table is gone. - if (ndbcluster_table_exists_in_engine(hton, thd, db, file_name) == HA_ERR_NO_SUCH_TABLE) + if (ndbcluster_table_exists_in_engine(hton, thd, db, file_name->str) == + HA_ERR_NO_SUCH_TABLE) { - DBUG_PRINT("info", ("NDB says %s does not exists", file_name)); + DBUG_PRINT("info", ("NDB says %s does not exists", file_name->str)); it.remove(); // Put in list of tables to remove from disk - delete_list.push_back(thd->strdup(file_name)); + delete_list.push_back(thd->strdup(file_name->str)); } } @@ -7009,12 +7011,12 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, build_table_filename(name, sizeof(name), db, "", "", 0); for (i= 0; i < ok_tables.records; i++) { - file_name= (char*)hash_element(&ok_tables, i); + file_name_str= (char*)hash_element(&ok_tables, i); end= end1 + - tablename_to_filename(file_name, end1, sizeof(name) - (end1 - name)); + tablename_to_filename(file_name_str, end1, sizeof(name) - (end1 - name)); pthread_mutex_lock(&LOCK_open); ndbcluster_create_binlog_setup(ndb, name, end-name, - db, file_name, TRUE); + db, file_name_str, TRUE); pthread_mutex_unlock(&LOCK_open); } } @@ -7025,16 +7027,16 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, List create_list; for (i= 0 ; i < ndb_tables.records ; i++) { - file_name= (char*) hash_element(&ndb_tables, i); - if (!hash_search(&ok_tables, (uchar*) file_name, strlen(file_name))) + file_name_str= (char*) hash_element(&ndb_tables, i); + if (!hash_search(&ok_tables, (uchar*) file_name_str, strlen(file_name_str))) { - build_table_filename(name, sizeof(name), db, file_name, reg_ext, 0); + build_table_filename(name, sizeof(name), db, file_name_str, reg_ext, 0); if (my_access(name, F_OK)) { - DBUG_PRINT("info", ("%s must be discovered", file_name)); + DBUG_PRINT("info", ("%s must be discovered", file_name_str)); // File is in list of ndb tables and not in ok_tables // This table need to be created - create_list.push_back(thd->strdup(file_name)); + create_list.push_back(thd->strdup(file_name_str)); } } } @@ -7043,14 +7045,14 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, { // Delete old files List_iterator_fast it3(delete_list); - while ((file_name=it3++)) + while ((file_name_str= it3++)) { - DBUG_PRINT("info", ("Remove table %s/%s", db, file_name)); + DBUG_PRINT("info", ("Remove table %s/%s", db, file_name_str)); // Delete the table and all related files TABLE_LIST table_list; bzero((char*) &table_list,sizeof(table_list)); table_list.db= (char*) db; - table_list.alias= table_list.table_name= (char*)file_name; + table_list.alias= table_list.table_name= (char*)file_name_str; (void)mysql_rm_table_part2(thd, &table_list, FALSE, /* if_exists */ FALSE, /* drop_temporary */ @@ -7065,11 +7067,16 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, pthread_mutex_lock(&LOCK_open); // Create new files List_iterator_fast it2(create_list); - while ((file_name=it2++)) + while ((file_name_str=it2++)) { - DBUG_PRINT("info", ("Table %s need discovery", file_name)); - if (ndb_create_table_from_engine(thd, db, file_name) == 0) - files->push_back(thd->strdup(file_name)); + DBUG_PRINT("info", ("Table %s need discovery", file_name_str)); + if (ndb_create_table_from_engine(thd, db, file_name_str) == 0) + { + LEX_STRING *tmp_file_name= 0; + tmp_file_name= thd->make_lex_string(tmp_file_name, file_name_str, + strlen(file_name_str), TRUE); + files->push_back(tmp_file_name); + } } pthread_mutex_unlock(&LOCK_open); @@ -7083,8 +7090,8 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, uint count = 0; while (count++ < files->elements) { - file_name = (char *)files->pop(); - if (!strcmp(file_name, NDB_SCHEMA_TABLE)) + file_name = (LEX_STRING *)files->pop(); + if (!strcmp(file_name->str, NDB_SCHEMA_TABLE)) { DBUG_PRINT("info", ("skip %s.%s table, it should be hidden to user", NDB_REP_DB, NDB_SCHEMA_TABLE)); diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index 4f5a1359d2d..a6f992226c2 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -563,7 +563,7 @@ extern SHOW_VAR ndb_status_variables[]; int ndbcluster_discover(THD* thd, const char* dbname, const char* name, const void** frmblob, uint* frmlen); int ndbcluster_find_files(THD *thd,const char *db,const char *path, - const char *wild, bool dir, List *files); + const char *wild, bool dir, List *files); int ndbcluster_table_exists_in_engine(THD* thd, const char *db, const char *name); void ndbcluster_print_error(int error, const NdbOperation *error_op); diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index f388b60f3d5..c91faac388f 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -2480,8 +2480,8 @@ ndbcluster_check_if_local_tables_in_db(THD *thd, const char *dbname) { DBUG_ENTER("ndbcluster_check_if_local_tables_in_db"); DBUG_PRINT("info", ("Looking for files in directory %s", dbname)); - char *tabname; - List files; + LEX_STRING *tabname; + List files; char path[FN_REFLEN]; build_table_filename(path, sizeof(path), dbname, "", "", 0); @@ -2493,8 +2493,8 @@ ndbcluster_check_if_local_tables_in_db(THD *thd, const char *dbname) DBUG_PRINT("info",("found: %d files", files.elements)); while ((tabname= files.pop())) { - DBUG_PRINT("info", ("Found table %s", tabname)); - if (ndbcluster_check_if_local_table(dbname, tabname)) + DBUG_PRINT("info", ("Found table %s", tabname->str)); + if (ndbcluster_check_if_local_table(dbname, tabname->str)) DBUG_RETURN(true); } diff --git a/sql/handler.cc b/sql/handler.cc index e828c9cdde8..ca47c3e0056 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2834,7 +2834,7 @@ struct st_find_files_args const char *path; const char *wild; bool dir; - List *files; + List *files; }; static my_bool find_files_handlerton(THD *thd, plugin_ref plugin, @@ -2854,7 +2854,7 @@ static my_bool find_files_handlerton(THD *thd, plugin_ref plugin, int ha_find_files(THD *thd,const char *db,const char *path, - const char *wild, bool dir, List *files) + const char *wild, bool dir, List *files) { int error= 0; DBUG_ENTER("ha_find_files"); diff --git a/sql/handler.h b/sql/handler.h index ddea6c3a34c..60e936bef5b 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -700,7 +700,7 @@ struct handlerton int (*find_files)(handlerton *hton, THD *thd, const char *db, const char *path, - const char *wild, bool dir, List *files); + const char *wild, bool dir, List *files); int (*table_exists_in_engine)(handlerton *hton, THD* thd, const char *db, const char *name); uint32 license; /* Flag for Engine License */ @@ -1860,7 +1860,7 @@ int ha_create_table_from_engine(THD* thd, const char *db, const char *name); int ha_discover(THD* thd, const char* dbname, const char* name, uchar** frmblob, size_t* frmlen); int ha_find_files(THD *thd,const char *db,const char *path, - const char *wild, bool dir,List* files); + const char *wild, bool dir, List* files); int ha_table_exists_in_engine(THD* thd, const char* db, const char* name); /* key cache */ diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 3e594d4da4b..01306e09f48 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2759,11 +2759,10 @@ bool reopen_table(TABLE *table) sql_print_error("Table %s had a open data handler in reopen_table", table->alias); #endif + bzero((char*) &table_list, sizeof(TABLE_LIST)); table_list.db= table->s->db.str; table_list.table_name= table->s->table_name.str; table_list.table= table; - table_list.belong_to_view= 0; - table_list.next_local= 0; if (wait_for_locked_table_names(thd, &table_list)) DBUG_RETURN(1); // Thread was killed @@ -3295,15 +3294,19 @@ static int open_unireg_entry(THD *thd, TABLE *entry, TABLE_LIST *table_list, DBUG_ENTER("open_unireg_entry"); safe_mutex_assert_owner(&LOCK_open); - retry: if (!(share= get_table_share_with_create(thd, table_list, cache_key, cache_key_length, - OPEN_VIEW, &error))) + OPEN_VIEW | + table_list->i_s_requested_object, + &error))) DBUG_RETURN(1); if (share->is_view) { + if (table_list->i_s_requested_object & OPEN_TABLE_ONLY) + goto err; + /* Open view */ error= (int) open_new_frm(thd, share, alias, (uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE | @@ -3319,6 +3322,9 @@ retry: DBUG_RETURN((flags & OPEN_VIEW_NO_PARSE)? -1 : 0); } + if (table_list->i_s_requested_object & OPEN_VIEW_ONLY) + goto err; + while ((error= open_table_from_share(thd, share, alias, (uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE | diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 9ea67af1bf9..2d383ee1bfc 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1625,6 +1625,10 @@ JOIN::exec() DBUG_VOID_RETURN; } + if ((this->select_lex->options & OPTION_SCHEMA_TABLE) && + get_schema_tables_result(this, PROCESSED_BY_JOIN_EXEC)) + DBUG_VOID_RETURN; + if (select_options & SELECT_DESCRIBE) { /* @@ -1670,13 +1674,6 @@ JOIN::exec() */ curr_join->examined_rows= 0; - if ((curr_join->select_lex->options & OPTION_SCHEMA_TABLE) && - !thd->lex->describe && - get_schema_tables_result(curr_join, PROCESSED_BY_JOIN_EXEC)) - { - DBUG_VOID_RETURN; - } - /* Create a tmp table if distinct or if the sort is too complicated */ if (need_tmp) { @@ -12929,7 +12926,6 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order, /* Fill schema tables with data before filesort if it's necessary */ if ((join->select_lex->options & OPTION_SCHEMA_TABLE) && - !thd->lex->describe && get_schema_tables_result(join, PROCESSED_BY_CREATE_SORT_INDEX)) goto err; @@ -15382,6 +15378,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, { JOIN_TAB *tab=join->join_tab+i; TABLE *table=tab->table; + TABLE_LIST *table_list= tab->table->pos_in_table_list; char buff[512]; char buff1[512], buff2[512], buff3[512]; char keylen_str_buf[64]; @@ -15517,37 +15514,68 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, } else { - item_list.push_back(item_null); + if (table_list->schema_table && + table_list->schema_table->i_s_requested_object & OPTIMIZE_I_S_TABLE) + { + const char *tmp_buff; + int f_idx; + if (table_list->has_db_lookup_value) + { + f_idx= table_list->schema_table->idx_field1; + tmp_buff= table_list->schema_table->fields_info[f_idx].field_name; + tmp2.append(tmp_buff, strlen(tmp_buff), cs); + } + if (table_list->has_table_lookup_value) + { + if (table_list->has_db_lookup_value) + tmp2.append(','); + f_idx= table_list->schema_table->idx_field2; + tmp_buff= table_list->schema_table->fields_info[f_idx].field_name; + tmp2.append(tmp_buff, strlen(tmp_buff), cs); + } + if (tmp2.length()) + item_list.push_back(new Item_string(tmp2.ptr(),tmp2.length(),cs)); + else + item_list.push_back(item_null); + } + else + item_list.push_back(item_null); item_list.push_back(item_null); item_list.push_back(item_null); } /* Add "rows" field to item_list. */ - ha_rows examined_rows; - if (tab->select && tab->select->quick) - examined_rows= tab->select->quick->records; - else if (tab->type == JT_NEXT || tab->type == JT_ALL) - examined_rows= tab->table->file->records(); - else - examined_rows=(ha_rows)join->best_positions[i].records_read; - - item_list.push_back(new Item_int((longlong) (ulonglong) examined_rows, - MY_INT64_NUM_DECIMAL_DIGITS)); - - /* Add "filtered" field to item_list. */ - if (join->thd->lex->describe & DESCRIBE_EXTENDED) + if (table_list->schema_table) { - Item_float *filtered; - float f; - if (examined_rows) - f= (float) (100.0 * join->best_positions[i].records_read / - examined_rows); - else - f= 0.0; - item_list.push_back((filtered= new Item_float(f))); - filtered->decimals= 2; + item_list.push_back(item_null); } + else + { + ha_rows examined_rows; + if (tab->select && tab->select->quick) + examined_rows= tab->select->quick->records; + else if (tab->type == JT_NEXT || tab->type == JT_ALL) + examined_rows= tab->table->file->records(); + else + examined_rows=(ha_rows)join->best_positions[i].records_read; + + item_list.push_back(new Item_int((longlong) (ulonglong) examined_rows, + MY_INT64_NUM_DECIMAL_DIGITS)); + /* Add "filtered" field to item_list. */ + if (join->thd->lex->describe & DESCRIBE_EXTENDED) + { + Item_float *filtered; + float f; + if (examined_rows) + f= (float) (100.0 * join->best_positions[i].records_read / + examined_rows); + else + f= 0.0; + item_list.push_back((filtered= new Item_float(f))); + filtered->decimals= 2; + } + } /* Build "Extra" field and add it to item_list. */ my_bool key_read=table->key_read; @@ -15615,6 +15643,24 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, extra.append(STRING_WITH_LEN("; Using where")); } } + if (table_list->schema_table && + table_list->schema_table->i_s_requested_object & OPTIMIZE_I_S_TABLE) + { + if (!table_list->table_open_method) + extra.append(STRING_WITH_LEN("; Skip_open_table")); + else if (table_list->table_open_method == OPEN_FRM_ONLY) + extra.append(STRING_WITH_LEN("; Open_frm_only")); + else + extra.append(STRING_WITH_LEN("; Open_full_table")); + if (table_list->has_db_lookup_value && + table_list->has_table_lookup_value) + extra.append(STRING_WITH_LEN("; Scanned 0 databases")); + else if (table_list->has_db_lookup_value || + table_list->has_table_lookup_value) + extra.append(STRING_WITH_LEN("; Scanned 1 database")); + else + extra.append(STRING_WITH_LEN("; Scanned all databases")); + } if (key_read) { if (quick_type == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index a0c3355b49a..a6b768b7b26 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -443,13 +443,15 @@ bool mysqld_show_column_types(THD *thd) find_files_result -find_files(THD *thd, List *files, const char *db, +find_files(THD *thd, List *files, const char *db, const char *path, const char *wild, bool dir) { uint i; char *ext; MY_DIR *dirp; FILEINFO *file; + LEX_STRING *file_name= 0; + uint file_name_len; #ifndef NO_EMBEDDED_ACCESS_CHECKS uint col_access=thd->col_access; #endif @@ -498,10 +500,16 @@ find_files(THD *thd, List *files, const char *db, #endif if (!MY_S_ISDIR(file->mystat->st_mode)) continue; - VOID(filename_to_tablename(file->name, uname, sizeof(uname))); + + file_name_len= filename_to_tablename(file->name, uname, sizeof(uname)); if (wild && wild_compare(uname, wild, 0)) continue; - file->name= uname; + if (!(file_name= + thd->make_lex_string(file_name, uname, file_name_len, TRUE))) + { + my_dirend(dirp); + DBUG_RETURN(FIND_FILES_OOM); + } } else { @@ -510,16 +518,15 @@ find_files(THD *thd, List *files, const char *db, is_prefix(file->name, tmp_file_prefix)) continue; *ext=0; - VOID(filename_to_tablename(file->name, uname, sizeof(uname))); - file->name= uname; + file_name_len= filename_to_tablename(file->name, uname, sizeof(uname)); if (wild) { if (lower_case_table_names) { - if (wild_case_compare(files_charset_info, file->name, wild)) + if (wild_case_compare(files_charset_info, uname, wild)) continue; } - else if (wild_compare(file->name,wild,0)) + else if (wild_compare(uname, wild, 0)) continue; } } @@ -529,14 +536,16 @@ find_files(THD *thd, List *files, const char *db, { table_list.db= (char*) db; table_list.db_length= strlen(db); - table_list.table_name= file->name; - table_list.table_name_length= strlen(file->name); + table_list.table_name= uname; + table_list.table_name_length= file_name_len; table_list.grant.privilege=col_access; if (check_grant(thd, TABLE_ACLS, &table_list, 1, 1, 1)) continue; } #endif - if (files->push_back(thd->strdup(file->name))) + if (!(file_name= + thd->make_lex_string(file_name, uname, file_name_len, TRUE)) || + files->push_back(file_name)) { my_dirend(dirp); DBUG_RETURN(FIND_FILES_OOM); @@ -545,7 +554,7 @@ find_files(THD *thd, List *files, const char *db, DBUG_PRINT("info",("found: %d files", files->elements)); my_dirend(dirp); - VOID(ha_find_files(thd,db,path,wild,dir,files)); + VOID(ha_find_files(thd, db, path, wild, dir, files)); DBUG_RETURN(FIND_FILES_OK); } @@ -2179,10 +2188,11 @@ void calc_sum_of_all_status(STATUS_VAR *to) /* This is only used internally, but we need it here as a forward reference */ extern ST_SCHEMA_TABLE schema_tables[]; -typedef struct st_index_field_values +typedef struct st_lookup_field_values { - const char *db_value, *table_value; -} INDEX_FIELD_VALUES; + LEX_STRING db_value, table_value; + bool wild_db_value, wild_table_value; +} LOOKUP_FIELD_VALUES; /* @@ -2213,38 +2223,11 @@ bool schema_table_store_record(THD *thd, TABLE *table) } -void get_index_field_values(LEX *lex, INDEX_FIELD_VALUES *index_field_values) -{ - const char *wild= lex->wild ? lex->wild->ptr() : NullS; - switch (lex->sql_command) { - case SQLCOM_SHOW_DATABASES: - index_field_values->db_value= wild; - break; - case SQLCOM_SHOW_TABLES: - case SQLCOM_SHOW_TABLE_STATUS: - case SQLCOM_SHOW_TRIGGERS: - case SQLCOM_SHOW_EVENTS: - index_field_values->db_value= lex->select_lex.db; - index_field_values->table_value= wild; - break; - default: - index_field_values->db_value= NullS; - index_field_values->table_value= NullS; - break; - } -} - - int make_table_list(THD *thd, SELECT_LEX *sel, - char *db, char *table) + LEX_STRING *db_name, LEX_STRING *table_name) { Table_ident *table_ident; - LEX_STRING ident_db, ident_table; - ident_db.str= db; - ident_db.length= strlen(db); - ident_table.str= table; - ident_table.length= strlen(table); - table_ident= new Table_ident(thd, ident_db, ident_table, 1); + table_ident= new Table_ident(thd, *db_name, *table_name, 1); sel->init_query(); if (!sel->add_table_to_list(thd, table_ident, 0, 0, TL_READ)) return 1; @@ -2252,6 +2235,127 @@ int make_table_list(THD *thd, SELECT_LEX *sel, } +/** + @brief Get lookup value from the part of 'WHERE' condition + + @details This function gets lookup value from + the part of 'WHERE' condition if it's possible and + fill appropriate lookup_field_vals struct field + with this value. + + @param[in] thd thread handler + @param[in] item_func part of WHERE condition + @param[in] table I_S table + @param[in, out] lookup_field_vals Struct which holds lookup values + + @return void +*/ + +void get_lookup_value(THD *thd, Item_func *item_func, + TABLE_LIST *table, + LOOKUP_FIELD_VALUES *lookup_field_vals) +{ + ST_SCHEMA_TABLE *schema_table= table->schema_table; + ST_FIELD_INFO *field_info= schema_table->fields_info; + const char *field_name1= schema_table->idx_field1 >= 0 ? + field_info[schema_table->idx_field1].field_name : ""; + const char *field_name2= schema_table->idx_field2 >= 0 ? + field_info[schema_table->idx_field2].field_name : ""; + + if (item_func->functype() == Item_func::EQ_FUNC || + item_func->functype() == Item_func::EQUAL_FUNC) + { + int idx_field, idx_val; + char tmp[MAX_FIELD_WIDTH]; + String *tmp_str, str_buff(tmp, sizeof(tmp), system_charset_info); + Item_field *item_field; + CHARSET_INFO *cs= system_charset_info; + + if (item_func->arguments()[0]->type() == Item::FIELD_ITEM && + item_func->arguments()[1]->const_item()) + { + idx_field= 0; + idx_val= 1; + } + else if (item_func->arguments()[1]->type() == Item::FIELD_ITEM && + item_func->arguments()[0]->const_item()) + { + idx_field= 1; + idx_val= 0; + } + else + return; + + item_field= (Item_field*) item_func->arguments()[idx_field]; + if (table->table != item_field->field->table) + return; + tmp_str= item_func->arguments()[idx_val]->val_str(&str_buff); + + /* Lookup value is database name */ + if (!cs->coll->strnncollsp(cs, (uchar *) field_name1, strlen(field_name1), + (uchar *) item_field->field_name, + strlen(item_field->field_name), 0)) + { + thd->make_lex_string(&lookup_field_vals->db_value, tmp_str->ptr(), + tmp_str->length(), FALSE); + } + /* Lookup value is table name */ + else if (!cs->coll->strnncollsp(cs, (uchar *) field_name2, + strlen(field_name2), + (uchar *) item_field->field_name, + strlen(item_field->field_name), 0)) + { + thd->make_lex_string(&lookup_field_vals->table_value, tmp_str->ptr(), + tmp_str->length(), FALSE); + } + } + return; +} + + +/** + @brief Calculates lookup values from 'WHERE' condition + + @details This function calculates lookup value(database name, table name) + from 'WHERE' condition if it's possible and + fill lookup_field_vals struct fields with these values. + + @param[in] thd thread handler + @param[in] cond WHERE condition + @param[in] table I_S table + @param[in, out] lookup_field_vals Struct which holds lookup values + + @return void +*/ + +void calc_lookup_values_from_cond(THD *thd, COND *cond, TABLE_LIST *table, + LOOKUP_FIELD_VALUES *lookup_field_vals) +{ + if (!cond) + return; + + if (cond->type() == Item::COND_ITEM) + { + if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC) + { + List_iterator li(*((Item_cond*) cond)->argument_list()); + Item *item; + while ((item= li++)) + { + if (item->type() == Item::FUNC_ITEM) + get_lookup_value(thd, (Item_func*)item, table, lookup_field_vals); + else + calc_lookup_values_from_cond(thd, item, table, lookup_field_vals); + } + } + return; + } + else if (cond->type() == Item::FUNC_ITEM) + get_lookup_value(thd, (Item_func*) cond, table, lookup_field_vals); + return; +} + + bool uses_only_table_name_fields(Item *item, TABLE_LIST *table) { if (item->type() == Item::FUNC_ITEM) @@ -2269,21 +2373,23 @@ bool uses_only_table_name_fields(Item *item, TABLE_LIST *table) CHARSET_INFO *cs= system_charset_info; ST_SCHEMA_TABLE *schema_table= table->schema_table; ST_FIELD_INFO *field_info= schema_table->fields_info; - const char *field_name1= schema_table->idx_field1 >= 0 ? field_info[schema_table->idx_field1].field_name : ""; - const char *field_name2= schema_table->idx_field2 >= 0 ? field_info[schema_table->idx_field2].field_name : ""; + const char *field_name1= schema_table->idx_field1 >= 0 ? + field_info[schema_table->idx_field1].field_name : ""; + const char *field_name2= schema_table->idx_field2 >= 0 ? + field_info[schema_table->idx_field2].field_name : ""; if (table->table != item_field->field->table || (cs->coll->strnncollsp(cs, (uchar *) field_name1, strlen(field_name1), - (uchar *) item_field->field_name, + (uchar *) item_field->field_name, strlen(item_field->field_name), 0) && cs->coll->strnncollsp(cs, (uchar *) field_name2, strlen(field_name2), - (uchar *) item_field->field_name, + (uchar *) item_field->field_name, strlen(item_field->field_name), 0))) return 0; } else if (item->type() == Item::REF_ITEM) return uses_only_table_name_fields(item->real_item(), table); - if (item->type() == Item::SUBSELECT_ITEM && - !item->const_item()) + + if (item->type() == Item::SUBSELECT_ITEM && !item->const_item()) return 0; return 1; @@ -2346,6 +2452,61 @@ static COND * make_cond_for_info_schema(COND *cond, TABLE_LIST *table) } +/** + @brief Calculate lookup values(database name, table name) + + @details This function calculates lookup values(database name, table name) + from 'WHERE' condition or wild values (for 'SHOW' commands only) + from LEX struct and fill lookup_field_vals struct field + with these values. + + @param[in] thd thread handler + @param[in] cond WHERE condition + @param[in] table I_S table + @param[in, out] lookup_field_vals Struct which holds lookup values + + @return void +*/ + +void get_lookup_field_values(THD *thd, COND *cond, TABLE_LIST *tables, + LOOKUP_FIELD_VALUES *lookup_field_values) +{ + LEX *lex= thd->lex; + const char *wild= lex->wild ? lex->wild->ptr() : NullS; + bzero((char*) lookup_field_values, sizeof(LOOKUP_FIELD_VALUES)); + switch (lex->sql_command) { + case SQLCOM_SHOW_DATABASES: + if (wild) + { + lookup_field_values->db_value.str= (char*) wild; + lookup_field_values->db_value.length= strlen(wild); + lookup_field_values->wild_db_value= 1; + } + break; + case SQLCOM_SHOW_TABLES: + case SQLCOM_SHOW_TABLE_STATUS: + case SQLCOM_SHOW_TRIGGERS: + case SQLCOM_SHOW_EVENTS: + lookup_field_values->db_value.str= lex->select_lex.db; + lookup_field_values->db_value.length=strlen(lex->select_lex.db); + if (wild) + { + lookup_field_values->table_value.str= (char*)wild; + lookup_field_values->table_value.length= strlen(wild); + lookup_field_values->wild_table_value= 1; + } + break; + default: + /* + The "default" is for queries over I_S. + All previous cases handle SHOW commands. + */ + calc_lookup_values_from_cond(thd, cond, tables, lookup_field_values); + break; + } +} + + enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table) { return (enum enum_schema_tables) (schema_table - &schema_tables[0]); @@ -2363,81 +2524,83 @@ enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table) idx_field_vals idx_field_vals->db_name contains db name or wild string with_i_schema returns 1 if we added 'IS' name to list - otherwise returns 0 - is_wild_value if value is 1 then idx_field_vals->db_name is - wild string otherwise it's db name; + otherwise returns 0 RETURN zero success non-zero error */ -int make_db_list(THD *thd, List *files, - INDEX_FIELD_VALUES *idx_field_vals, - bool *with_i_schema, bool is_wild_value) +int make_db_list(THD *thd, List *files, + LOOKUP_FIELD_VALUES *lookup_field_vals, + bool *with_i_schema) { - LEX *lex= thd->lex; *with_i_schema= 0; - get_index_field_values(lex, idx_field_vals); - - if (is_wild_value) + if (lookup_field_vals->wild_db_value) { /* This part of code is only for SHOW DATABASES command. idx_field_vals->db_value can be 0 when we don't use LIKE clause (see also get_index_field_values() function) */ - if (!idx_field_vals->db_value || + if (!lookup_field_vals->db_value.str || !wild_case_compare(system_charset_info, INFORMATION_SCHEMA_NAME.str, - idx_field_vals->db_value)) + lookup_field_vals->db_value.str)) { *with_i_schema= 1; - if (files->push_back(thd->strdup(INFORMATION_SCHEMA_NAME.str))) + if (files->push_back(&INFORMATION_SCHEMA_NAME)) return 1; } return (find_files(thd, files, NullS, mysql_data_home, - idx_field_vals->db_value, 1) != FIND_FILES_OK); + lookup_field_vals->db_value.str, 1) != FIND_FILES_OK); } + /* - This part of code is for SHOW TABLES, SHOW TABLE STATUS commands. - idx_field_vals->db_value can't be 0 (see get_index_field_values() - function). + If we have db lookup vaule we just add it to list and + exit from the function */ - if (sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) + if (lookup_field_vals->db_value.str) { if (!my_strcasecmp(system_charset_info, INFORMATION_SCHEMA_NAME.str, - idx_field_vals->db_value)) + lookup_field_vals->db_value.str)) { *with_i_schema= 1; - return files->push_back(thd->strdup(INFORMATION_SCHEMA_NAME.str)); + if (files->push_back(&INFORMATION_SCHEMA_NAME)) + return 1; + return 0; } - return files->push_back(thd->strdup(idx_field_vals->db_value)); + if (files->push_back(&lookup_field_vals->db_value)) + return 1; + return 0; } /* Create list of existing databases. It is used in case of select from information schema table */ - if (files->push_back(thd->strdup(INFORMATION_SCHEMA_NAME.str))) + if (files->push_back(&INFORMATION_SCHEMA_NAME)) return 1; *with_i_schema= 1; return (find_files(thd, files, NullS, mysql_data_home, NullS, 1) != FIND_FILES_OK); } + struct st_add_schema_table { - List *files; + List *files; const char *wild; }; + static my_bool add_schema_table(THD *thd, plugin_ref plugin, void* p_data) { + LEX_STRING *file_name= 0; st_add_schema_table *data= (st_add_schema_table *)p_data; - List *file_list= data->files; + List *file_list= data->files; const char *wild= data->wild; ST_SCHEMA_TABLE *schema_table= plugin_data(plugin, ST_SCHEMA_TABLE *); DBUG_ENTER("add_schema_table"); @@ -2457,14 +2620,18 @@ static my_bool add_schema_table(THD *thd, plugin_ref plugin, DBUG_RETURN(0); } - if (file_list->push_back(thd->strdup(schema_table->table_name))) - DBUG_RETURN(1); - - DBUG_RETURN(0); + if ((file_name= thd->make_lex_string(file_name, schema_table->table_name, + strlen(schema_table->table_name), + TRUE)) && + !file_list->push_back(file_name)) + DBUG_RETURN(0); + DBUG_RETURN(1); } -int schema_tables_add(THD *thd, List *files, const char *wild) + +int schema_tables_add(THD *thd, List *files, const char *wild) { + LEX_STRING *file_name= 0; ST_SCHEMA_TABLE *tmp_schema_table= schema_tables; st_add_schema_table add_data; DBUG_ENTER("schema_tables_add"); @@ -2485,8 +2652,12 @@ int schema_tables_add(THD *thd, List *files, const char *wild) else if (wild_compare(tmp_schema_table->table_name, wild, 0)) continue; } - if (files->push_back(thd->strdup(tmp_schema_table->table_name))) - DBUG_RETURN(1); + if ((file_name= + thd->make_lex_string(file_name, tmp_schema_table->table_name, + strlen(tmp_schema_table->table_name), TRUE)) && + !files->push_back(file_name)) + continue; + DBUG_RETURN(1); } add_data.files= files; @@ -2499,37 +2670,380 @@ int schema_tables_add(THD *thd, List *files, const char *wild) } +/** + @brief Create table names list + + @details The function creates the list of table names in + database + + @param[in] thd thread handler + @param[in] table_names List of table names in database + @param[in] lex pointer to LEX struct + @param[in] lookup_field_vals pointer to LOOKUP_FIELD_VALUE struct + @param[in] with_i_schema TRUE means that we add I_S tables to list + @param[in] db_name database name + + @return Operation status + @retval 0 ok + @retval 1 fatal error + @retval 2 Not fatal error; Safe to ignore this file list +*/ + +static int +make_table_name_list(THD *thd, List *table_names, LEX *lex, + LOOKUP_FIELD_VALUES *lookup_field_vals, + bool with_i_schema, LEX_STRING *db_name) +{ + char path[FN_REFLEN]; + build_table_filename(path, sizeof(path), db_name->str, "", "", 0); + if (!lookup_field_vals->wild_table_value && + lookup_field_vals->table_value.str) + { + if (with_i_schema) + { + if (find_schema_table(thd, lookup_field_vals->table_value.str)) + { + if (table_names->push_back(&lookup_field_vals->table_value)) + return 1; + } + } + else + { + if (table_names->push_back(&lookup_field_vals->table_value)) + return 1; + /* + Check that table is relevant in current transaction. + (used for ndb engine, see ndbcluster_find_files(), ha_ndbcluster.cc) + */ + VOID(ha_find_files(thd, db_name->str, path, + lookup_field_vals->table_value.str, 0, + table_names)); + } + return 0; + } + + /* + This call will add all matching the wildcards (if specified) IS tables + to the list + */ + if (with_i_schema) + return (schema_tables_add(thd, table_names, + lookup_field_vals->table_value.str)); + + find_files_result res= find_files(thd, table_names, db_name->str, path, + lookup_field_vals->table_value.str, 0); + if (res != FIND_FILES_OK) + { + /* + Downgrade errors about problems with database directory to + warnings if this is not a 'SHOW' command. Another thread + may have dropped database, and we may still have a name + for that directory. + */ + if (res == FIND_FILES_DIR) + { + if (lex->sql_command != SQLCOM_SELECT) + return 1; + thd->clear_error(); + return 2; + } + return 1; + } + return 0; +} + + +/** + @brief Fill I_S table for SHOW COLUMNS|INDEX commands + + @param[in] thd thread handler + @param[in] tables TABLE_LIST for I_S table + @param[in] schema_table pointer to I_S structure + @param[in] open_tables_state_backup pointer to Open_tables_state object + which is used to save|restore original + status of variables related to + open tables state + + @return Operation status + @retval 0 success + @retval 1 error +*/ + +static int +fill_schema_show_cols_or_idxs(THD *thd, TABLE_LIST *tables, + ST_SCHEMA_TABLE *schema_table, + Open_tables_state *open_tables_state_backup) +{ + LEX *lex= thd->lex; + bool res; + LEX_STRING tmp_lex_string, tmp_lex_string1, *db_name, *table_name; + enum_sql_command save_sql_command= lex->sql_command; + TABLE_LIST *show_table_list= (TABLE_LIST*) tables->schema_select_lex-> + table_list.first; + TABLE *table= tables->table; + int error= 1; + DBUG_ENTER("fill_schema_show"); + + lex->all_selects_list= tables->schema_select_lex; + /* + Restore thd->temporary_tables to be able to process + temporary tables(only for 'show index' & 'show columns'). + This should be changed when processing of temporary tables for + I_S tables will be done. + */ + thd->temporary_tables= open_tables_state_backup->temporary_tables; + /* + Let us set fake sql_command so views won't try to merge + themselves into main statement. If we don't do this, + SELECT * from information_schema.xxxx will cause problems. + SQLCOM_SHOW_FIELDS is used because it satisfies 'only_view_structure()' + */ + lex->sql_command= SQLCOM_SHOW_FIELDS; + res= open_normal_and_derived_tables(thd, show_table_list, + MYSQL_LOCK_IGNORE_FLUSH); + lex->sql_command= save_sql_command; + /* + get_all_tables() returns 1 on failure and 0 on success thus + return only these and not the result code of ::process_table() + + We should use show_table_list->alias instead of + show_table_list->table_name because table_name + could be changed during opening of I_S tables. It's safe + to use alias because alias contains original table name + in this case(this part of code is used only for + 'show columns' & 'show statistics' commands). + */ + table_name= thd->make_lex_string(&tmp_lex_string1, show_table_list->alias, + strlen(show_table_list->alias), FALSE); + if (!show_table_list->view) + db_name= thd->make_lex_string(&tmp_lex_string, show_table_list->db, + show_table_list->db_length, FALSE); + else + db_name= &show_table_list->view_db; + + + error= test(schema_table->process_table(thd, show_table_list, + table, res, db_name, + table_name)); + thd->temporary_tables= 0; + close_tables_for_reopen(thd, &show_table_list); + DBUG_RETURN(error); +} + + +/** + @brief Fill I_S table for SHOW TABLE NAMES commands + + @param[in] thd thread handler + @param[in] table TABLE struct for I_S table + @param[in] db_name database name + @param[in] table_name table name + @param[in] with_i_schema I_S table if TRUE + + @return Operation status + @retval 0 success + @retval 1 error +*/ + +static int fill_schema_table_names(THD *thd, TABLE *table, + LEX_STRING *db_name, LEX_STRING *table_name, + bool with_i_schema) +{ + if (with_i_schema) + { + table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), + system_charset_info); + } + else + { + enum legacy_db_type not_used; + char path[FN_REFLEN]; + (void) build_table_filename(path, sizeof(path), db_name->str, + table_name->str, reg_ext, 0); + switch (mysql_frm_type(thd, path, ¬_used)) { + case FRMTYPE_ERROR: + table->field[3]->store(STRING_WITH_LEN("ERROR"), + system_charset_info); + break; + case FRMTYPE_TABLE: + table->field[3]->store(STRING_WITH_LEN("BASE TABLE"), + system_charset_info); + break; + case FRMTYPE_VIEW: + table->field[3]->store(STRING_WITH_LEN("VIEW"), + system_charset_info); + break; + default: + DBUG_ASSERT(0); + } + if (thd->net.last_errno == ER_NO_SUCH_TABLE) + { + thd->clear_error(); + return 0; + } + } + if (schema_table_store_record(thd, table)) + return 1; + return 0; +} + + +/** + @brief Get open table method + + @details The function calculates the method which will be used + for table opening: + SKIP_OPEN_TABLE - do not open table + OPEN_FRM_ONLY - open FRM file only + OPEN_FULL_TABLE - open FRM, data, index files + @param[in] tables I_S table table_list + @param[in] schema_table I_S table struct + @param[in] schema_table_idx I_S table index + + @return return a set of flags + @retval SKIP_OPEN_TABLE | OPEN_FRM_ONLY | OPEN_FULL_TABLE +*/ + +static uint get_table_open_method(TABLE_LIST *tables, + ST_SCHEMA_TABLE *schema_table, + enum enum_schema_tables schema_table_idx) +{ + /* + determine which method will be used for table opening + */ + if (schema_table->i_s_requested_object & OPTIMIZE_I_S_TABLE) + { + Field **ptr, *field; + int table_open_method= 0, field_indx= 0; + for (ptr=tables->table->field; (field= *ptr) ; ptr++) + { + if (bitmap_is_set(tables->table->read_set, field->field_index)) + table_open_method|= schema_table->fields_info[field_indx].open_method; + field_indx++; + } + return table_open_method; + } + /* I_S tables which use get_all_tables but can not be optimized */ + return (uint) OPEN_FULL_TABLE; +} + + +/** + @brief Fill I_S table with data from FRM file only + + @param[in] thd thread handler + @param[in] table TABLE struct for I_S table + @param[in] schema_table I_S table struct + @param[in] db_name database name + @param[in] table_name table name + @param[in] schema_table_idx I_S table index + + @return Operation status + @retval 0 Table is processed and we can continue + with new table + @retval 1 It's view and we have to use + open_tables function for this table +*/ + +static int fill_schema_table_from_frm(THD *thd,TABLE *table, + ST_SCHEMA_TABLE *schema_table, + LEX_STRING *db_name, + LEX_STRING *table_name, + enum enum_schema_tables schema_table_idx) +{ + TABLE_SHARE share; + TABLE tbl; + TABLE_LIST table_list; + char path[FN_REFLEN]; + uint res; + bzero((char*) &table_list, sizeof(TABLE_LIST)); + bzero((char*) &tbl, sizeof(TABLE)); + (void) build_table_filename(path, sizeof(path), db_name->str, + table_name->str, "", 0); + init_tmp_table_share(&share, "", 0, "", path); + if (!(res= open_table_def(thd, &share, OPEN_VIEW))) + { + share.tmp_table= NO_TMP_TABLE; + tbl.s= &share; + table_list.table= &tbl; + if (schema_table->i_s_requested_object & OPEN_TABLE_FROM_SHARE) + { + if (share.is_view || + open_table_from_share(thd, &share, table_name->str, 0, + (READ_KEYINFO | COMPUTE_TYPES | + EXTRA_RECORD | OPEN_FRM_FILE_ONLY), + thd->open_options, &tbl, FALSE)) + { + share.tmp_table= INTERNAL_TMP_TABLE; + free_table_share(&share); + return (share.is_view && + !(schema_table->i_s_requested_object & + ~(OPEN_TABLE_FROM_SHARE|OPTIMIZE_I_S_TABLE))); + } + } + table_list.view= (st_lex*) share.is_view; + res= schema_table->process_table(thd, &table_list, table, + res, db_name, table_name); + share.tmp_table= INTERNAL_TMP_TABLE; + if (schema_table->i_s_requested_object & OPEN_TABLE_FROM_SHARE) + closefrm(&tbl, true); + else + free_table_share(&share); + } + + if (res) + thd->clear_error(); + return 0; +} + + + +/** + @brief Fill I_S tables whose data are retrieved + from frm files and storage engine + + @details The information schema tables are internally represented as + temporary tables that are filled at query execution time. + Those I_S tables whose data are retrieved + from frm files and storage engine are filled by the function + get_all_tables(). + + @param[in] thd thread handler + @param[in] tables I_S table + @param[in] cond 'WHERE' condition + + @return Operation status + @retval 0 success + @retval 1 error +*/ + int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) { LEX *lex= thd->lex; TABLE *table= tables->table; - SELECT_LEX *select_lex= &lex->select_lex; SELECT_LEX *old_all_select_lex= lex->all_selects_list; enum_sql_command save_sql_command= lex->sql_command; SELECT_LEX *lsel= tables->schema_select_lex; ST_SCHEMA_TABLE *schema_table= tables->schema_table; SELECT_LEX sel; - INDEX_FIELD_VALUES idx_field_vals; - char path[FN_REFLEN], *base_name, *orig_base_name, *file_name; - uint len; + LOOKUP_FIELD_VALUES lookup_field_vals; + LEX_STRING *db_name, *table_name; bool with_i_schema; enum enum_schema_tables schema_table_idx; - List bases; - List_iterator_fast it(bases); + List db_names; + List_iterator_fast it(db_names); COND *partial_cond; uint derived_tables= lex->derived_tables; int error= 1; - enum legacy_db_type not_used; Open_tables_state open_tables_state_backup; bool save_view_prepare_mode= lex->view_prepare_mode; Query_tables_list query_tables_list_backup; #ifndef NO_EMBEDDED_ACCESS_CHECKS Security_context *sctx= thd->security_ctx; #endif + uint table_open_method; DBUG_ENTER("get_all_tables"); - LINT_INIT(len); - lex->view_prepare_mode= TRUE; lex->reset_n_backup_query_tables_list(&query_tables_list_backup); @@ -2540,183 +3054,145 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) */ thd->reset_n_backup_open_tables_state(&open_tables_state_backup); + /* + this branch processes SHOW FIELDS, SHOW INDEXES commands. + see sql_parse.cc, prepare_schema_table() function where + this values are initialized + */ if (lsel && lsel->table_list.first) { - TABLE_LIST *show_table_list= (TABLE_LIST*) lsel->table_list.first; - bool res; - - lex->all_selects_list= lsel; - /* - Restore thd->temporary_tables to be able to process - temporary tables(only for 'show index' & 'show columns'). - This should be changed when processing of temporary tables for - I_S tables will be done. - */ - thd->temporary_tables= open_tables_state_backup.temporary_tables; - /* - Let us set fake sql_command so views won't try to merge - themselves into main statement. If we don't do this, - SELECT * from information_schema.xxxx will cause problems. - SQLCOM_SHOW_FIELDS is used because it satisfies 'only_view_structure()' - */ - lex->sql_command= SQLCOM_SHOW_FIELDS; - res= open_normal_and_derived_tables(thd, show_table_list, - MYSQL_LOCK_IGNORE_FLUSH); - lex->sql_command= save_sql_command; - /* - get_all_tables() returns 1 on failure and 0 on success thus - return only these and not the result code of ::process_table() - - We should use show_table_list->alias instead of - show_table_list->table_name because table_name - could be changed during opening of I_S tables. It's safe - to use alias because alias contains original table name - in this case(this part of code is used only for - 'show columns' & 'show statistics' commands). - */ - error= test(schema_table->process_table(thd, show_table_list, - table, res, - (show_table_list->view ? - show_table_list->view_db.str : - show_table_list->db), - show_table_list->alias)); - thd->temporary_tables= 0; - close_tables_for_reopen(thd, &show_table_list); + error= fill_schema_show_cols_or_idxs(thd, tables, schema_table, + &open_tables_state_backup); goto err; } schema_table_idx= get_schema_table_idx(schema_table); + get_lookup_field_values(thd, cond, tables, &lookup_field_vals); + DBUG_PRINT("INDEX VALUES",("db_name='%s', table_name='%s'", + lookup_field_vals.db_value.str, + lookup_field_vals.table_value.str)); + if (lookup_field_vals.db_value.length && + !lookup_field_vals.wild_db_value && + lookup_field_vals.table_value.length && + !lookup_field_vals.wild_table_value) + partial_cond= 0; + else + partial_cond= make_cond_for_info_schema(cond, tables); - if (make_db_list(thd, &bases, &idx_field_vals, - &with_i_schema, 0)) + if (lookup_field_vals.db_value.length && !lookup_field_vals.wild_db_value) + tables->has_db_lookup_value= TRUE; + if (lookup_field_vals.table_value.length && + !lookup_field_vals.wild_table_value) + tables->has_table_lookup_value= TRUE; + + tables->table_open_method= table_open_method= + get_table_open_method(tables, schema_table, schema_table_idx); + + if (lex->describe) + { + /* EXPLAIN SELECT */ + error= 0; goto err; + } - partial_cond= make_cond_for_info_schema(cond, tables); + if (make_db_list(thd, &db_names, &lookup_field_vals, &with_i_schema)) + goto err; it.rewind(); /* To get access to new elements in basis list */ - - /* - Below we generate error for non existing database. - (to save old behaviour for SHOW TABLES FROM db) - */ - while ((orig_base_name= base_name= it++) || - ((sql_command_flags[save_sql_command] & CF_SHOW_TABLE_COMMAND) && - (base_name= select_lex->db) && !bases.elements)) + while ((db_name= it++)) { #ifndef NO_EMBEDDED_ACCESS_CHECKS - if (!check_access(thd,SELECT_ACL, base_name, + if (!check_access(thd,SELECT_ACL, db_name->str, &thd->col_access, 0, 1, with_i_schema) || sctx->master_access & (DB_ACLS | SHOW_DB_ACL) || - acl_get(sctx->host, sctx->ip, sctx->priv_user, base_name,0) || - !check_grant_db(thd, base_name)) + acl_get(sctx->host, sctx->ip, sctx->priv_user, db_name->str, 0) || + !check_grant_db(thd, db_name->str)) #endif { - List files; - if (with_i_schema) // information schema table names - { - if (schema_tables_add(thd, &files, idx_field_vals.table_value)) - goto err; - } - else - { - len= build_table_filename(path, sizeof(path), base_name, "", "", 0); - len= FN_LEN - len; - find_files_result res= find_files(thd, &files, base_name, - path, idx_field_vals.table_value, 0); - if (res != FIND_FILES_OK) - { - /* - Downgrade errors about problems with database directory to - warnings if this is not a 'SHOW' command. Another thread - may have dropped database, and we may still have a name - for that directory. - */ - if (res == FIND_FILES_DIR && lex->sql_command == SQLCOM_END) - { - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, - thd->net.last_errno, thd->net.last_error); - thd->clear_error(); - continue; - } - else - { - goto err; - } - } - if (lower_case_table_names) - orig_base_name= thd->strdup(base_name); - } + thd->no_warnings_for_error= 1; + List table_names; + int res= make_table_name_list(thd, &table_names, lex, + &lookup_field_vals, + with_i_schema, db_name); + if (res == 2) /* Not fatal error, continue */ + continue; + if (res) + goto err; - List_iterator_fast it_files(files); - while ((file_name= it_files++)) + List_iterator_fast it_files(table_names); + while ((table_name= it_files++)) { restore_record(table, s->default_values); table->field[schema_table->idx_field1]-> - store(base_name, strlen(base_name), system_charset_info); + store(db_name->str, db_name->length, system_charset_info); table->field[schema_table->idx_field2]-> - store(file_name, strlen(file_name),system_charset_info); + store(table_name->str, table_name->length, system_charset_info); + if (!partial_cond || partial_cond->val_int()) { + /* + If table is I_S.tables and open_table_method is 0 (eg SKIP_OPEN) + we can skip table opening and we don't have lookup value for + table name or lookup value is wild string(table name list is + already created by make_table_name_list() function). + */ + if (!table_open_method && schema_table_idx == SCH_TABLES && + (!lookup_field_vals.table_value.length || + lookup_field_vals.wild_table_value)) + { + if (schema_table_store_record(thd, table)) + goto err; /* Out of space in temporary table */ + continue; + } + + /* SHOW TABLE NAMES command */ if (schema_table_idx == SCH_TABLE_NAMES) { - if (lex->verbose || - (sql_command_flags[save_sql_command] & CF_STATUS_COMMAND) == 0) - { - if (with_i_schema) - { - table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), - system_charset_info); - } - else - { - build_table_filename(path, sizeof(path), - base_name, file_name, reg_ext, 0); - - switch (mysql_frm_type(thd, path, ¬_used)) { - case FRMTYPE_ERROR: - table->field[3]->store(STRING_WITH_LEN("ERROR"), - system_charset_info); - break; - case FRMTYPE_TABLE: - table->field[3]->store(STRING_WITH_LEN("BASE TABLE"), - system_charset_info); - break; - case FRMTYPE_VIEW: - table->field[3]->store(STRING_WITH_LEN("VIEW"), - system_charset_info); - break; - default: - DBUG_ASSERT(0); - } - } - } - if (schema_table_store_record(thd, table)) - goto err; + if (fill_schema_table_names(thd, tables->table, db_name, + table_name, with_i_schema)) + continue; } else { + if (!(table_open_method & ~OPEN_FRM_ONLY) && + !with_i_schema) + { + if (!fill_schema_table_from_frm(thd, table, schema_table, db_name, + table_name, schema_table_idx)) + continue; + } + int res; + LEX_STRING tmp_lex_string, orig_db_name; /* Set the parent lex of 'sel' because it is needed by sel.init_query() which is called inside make_table_list. */ + thd->no_warnings_for_error= 1; sel.parent_lex= lex; - if (make_table_list(thd, &sel, base_name, file_name)) + /* db_name can be changed in make_table_list() func */ + if (!thd->make_lex_string(&orig_db_name, db_name->str, + db_name->length, FALSE)) + goto err; + if (make_table_list(thd, &sel, db_name, table_name)) goto err; TABLE_LIST *show_table_list= (TABLE_LIST*) sel.table_list.first; lex->all_selects_list= &sel; lex->derived_tables= 0; lex->sql_command= SQLCOM_SHOW_FIELDS; + show_table_list->i_s_requested_object= + schema_table->i_s_requested_object; res= open_normal_and_derived_tables(thd, show_table_list, MYSQL_LOCK_IGNORE_FLUSH); lex->sql_command= save_sql_command; - /* - They can drop table after table names list creation and - before table opening. We open non existing table and - get ER_NO_SUCH_TABLE error. In this case we do not store - the record into I_S table and clear error. - */ + if (thd->net.last_errno == ER_NO_SUCH_TABLE) { + /* + Hide error for not existing table. + This error can occur for example when we use + where condition with db name and table name and this + table does not exist. + */ res= 0; thd->clear_error(); } @@ -2729,12 +3205,14 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) to use alias because alias contains original table name in this case. */ + thd->make_lex_string(&tmp_lex_string, show_table_list->alias, + strlen(show_table_list->alias), FALSE); res= schema_table->process_table(thd, show_table_list, table, - res, orig_base_name, - show_table_list->alias); + res, &orig_db_name, + &tmp_lex_string); close_tables_for_reopen(thd, &show_table_list); - DBUG_ASSERT(!lex->query_tables_own_last); } + DBUG_ASSERT(!lex->query_tables_own_last); if (res) goto err; } @@ -2760,11 +3238,11 @@ err: } -bool store_schema_shemata(THD* thd, TABLE *table, const char *db_name, +bool store_schema_shemata(THD* thd, TABLE *table, LEX_STRING *db_name, CHARSET_INFO *cs) { restore_record(table, s->default_values); - table->field[1]->store(db_name, strlen(db_name), system_charset_info); + table->field[1]->store(db_name->str, db_name->length, system_charset_info); table->field[2]->store(cs->csname, strlen(cs->csname), system_charset_info); table->field[3]->store(cs->name, strlen(cs->name), system_charset_info); return schema_table_store_record(thd, table); @@ -2778,9 +3256,9 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond) Returning error status in this case leads to client hangup. */ - INDEX_FIELD_VALUES idx_field_vals; - List files; - char *file_name; + LOOKUP_FIELD_VALUES lookup_field_vals; + List db_names; + LEX_STRING *db_name; bool with_i_schema; HA_CREATE_INFO create; TABLE *table= tables->table; @@ -2789,16 +3267,20 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond) #endif DBUG_ENTER("fill_schema_shemata"); - if (make_db_list(thd, &files, &idx_field_vals, - &with_i_schema, 1)) + get_lookup_field_values(thd, cond, tables, &lookup_field_vals); + DBUG_PRINT("INDEX VALUES",("db_name='%s', table_name='%s'", + lookup_field_vals.db_value.str, + lookup_field_vals.table_value.str)); + if (make_db_list(thd, &db_names, &lookup_field_vals, + &with_i_schema)) DBUG_RETURN(1); - List_iterator_fast it(files); - while ((file_name=it++)) + List_iterator_fast it(db_names); + while ((db_name=it++)) { if (with_i_schema) // information schema name is always first in list { - if (store_schema_shemata(thd, table, file_name, + if (store_schema_shemata(thd, table, db_name, system_charset_info)) DBUG_RETURN(1); with_i_schema= 0; @@ -2806,13 +3288,12 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond) } #ifndef NO_EMBEDDED_ACCESS_CHECKS if (sctx->master_access & (DB_ACLS | SHOW_DB_ACL) || - acl_get(sctx->host, sctx->ip, sctx->priv_user, file_name,0) || - !check_grant_db(thd, file_name)) + acl_get(sctx->host, sctx->ip, sctx->priv_user, db_name->str, 0) || + !check_grant_db(thd, db_name->str)) #endif { - load_db_opt_by_name(thd, file_name, &create); - - if (store_schema_shemata(thd, table, file_name, + load_db_opt_by_name(thd, db_name->str, &create); + if (store_schema_shemata(thd, table, db_name, create.default_table_charset)) DBUG_RETURN(1); } @@ -2823,8 +3304,8 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond) static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, TABLE *table, bool res, - const char *base_name, - const char *file_name) + LEX_STRING *db_name, + LEX_STRING *table_name) { const char *tmp_buff; MYSQL_TIME time; @@ -2832,8 +3313,8 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, DBUG_ENTER("get_schema_tables_record"); restore_record(table, s->default_values); - table->field[1]->store(base_name, strlen(base_name), cs); - table->field[2]->store(file_name, strlen(file_name), cs); + table->field[1]->store(db_name->str, db_name->length, cs); + table->field[2]->store(table_name->str, table_name->length, cs); if (res) { /* @@ -2856,12 +3337,11 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, } else { + char option_buff[350],*ptr; TABLE *show_table= tables->table; TABLE_SHARE *share= show_table->s; handler *file= show_table->file; - - file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_AUTO | - HA_STATUS_NO_LOCK); + handlerton *tmp_db_type= share->db_type(); if (share->tmp_table == SYSTEM_TMP_TABLE) table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), cs); else if (share->tmp_table) @@ -2875,89 +3355,15 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, continue; table->field[i]->set_notnull(); } - tmp_buff= file->table_type(); +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (share->db_type() == partition_hton && + share->partition_info_len) + tmp_db_type= share->default_part_db_type; +#endif + tmp_buff= (char *) ha_resolve_storage_engine_name(tmp_db_type); table->field[4]->store(tmp_buff, strlen(tmp_buff), cs); table->field[5]->store((longlong) share->frm_version, TRUE); - enum row_type row_type = file->get_row_type(); - switch (row_type) { - case ROW_TYPE_NOT_USED: - case ROW_TYPE_DEFAULT: - tmp_buff= ((share->db_options_in_use & - HA_OPTION_COMPRESS_RECORD) ? "Compressed" : - (share->db_options_in_use & HA_OPTION_PACK_RECORD) ? - "Dynamic" : "Fixed"); - break; - case ROW_TYPE_FIXED: - tmp_buff= "Fixed"; - break; - case ROW_TYPE_DYNAMIC: - tmp_buff= "Dynamic"; - break; - case ROW_TYPE_COMPRESSED: - tmp_buff= "Compressed"; - break; - case ROW_TYPE_REDUNDANT: - tmp_buff= "Redundant"; - break; - case ROW_TYPE_COMPACT: - tmp_buff= "Compact"; - break; - case ROW_TYPE_PAGES: - tmp_buff= "Paged"; - break; - } - table->field[6]->store(tmp_buff, strlen(tmp_buff), cs); - if (!tables->schema_table) - { - table->field[7]->store((longlong) file->stats.records, TRUE); - table->field[7]->set_notnull(); - } - table->field[8]->store((longlong) file->stats.mean_rec_length, TRUE); - table->field[9]->store((longlong) file->stats.data_file_length, TRUE); - if (file->stats.max_data_file_length) - { - table->field[10]->store((longlong) file->stats.max_data_file_length, - TRUE); - } - table->field[11]->store((longlong) file->stats.index_file_length, TRUE); - table->field[12]->store((longlong) file->stats.delete_length, TRUE); - if (show_table->found_next_number_field) - { - table->field[13]->store((longlong) file->stats.auto_increment_value, - TRUE); - table->field[13]->set_notnull(); - } - if (file->stats.create_time) - { - thd->variables.time_zone->gmt_sec_to_TIME(&time, - (my_time_t) file->stats.create_time); - table->field[14]->store_time(&time, MYSQL_TIMESTAMP_DATETIME); - table->field[14]->set_notnull(); - } - if (file->stats.update_time) - { - thd->variables.time_zone->gmt_sec_to_TIME(&time, - (my_time_t) file->stats.update_time); - table->field[15]->store_time(&time, MYSQL_TIMESTAMP_DATETIME); - table->field[15]->set_notnull(); - } - if (file->stats.check_time) - { - thd->variables.time_zone->gmt_sec_to_TIME(&time, - (my_time_t) file->stats.check_time); - table->field[16]->store_time(&time, MYSQL_TIMESTAMP_DATETIME); - table->field[16]->set_notnull(); - } - tmp_buff= (share->table_charset ? - share->table_charset->name : "default"); - table->field[17]->store(tmp_buff, strlen(tmp_buff), cs); - if (file->ha_table_flags() & (ulong) HA_HAS_CHECKSUM) - { - table->field[18]->store((longlong) file->checksum(), TRUE); - table->field[18]->set_notnull(); - } - char option_buff[350],*ptr; ptr=option_buff; if (share->min_rows) { @@ -2995,17 +3401,91 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, table->field[19]->store(option_buff+1, (ptr == option_buff ? 0 : (uint) (ptr-option_buff)-1), cs); + + if (share->comment.str) + table->field[20]->store(share->comment.str, share->comment.length, cs); + + if(file) { - char *comment; - comment= show_table->file->update_table_comment(share->comment.str); - if (comment) + file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_AUTO | + HA_STATUS_NO_LOCK); + enum row_type row_type = file->get_row_type(); + switch (row_type) { + case ROW_TYPE_NOT_USED: + case ROW_TYPE_DEFAULT: + tmp_buff= ((share->db_options_in_use & + HA_OPTION_COMPRESS_RECORD) ? "Compressed" : + (share->db_options_in_use & HA_OPTION_PACK_RECORD) ? + "Dynamic" : "Fixed"); + break; + case ROW_TYPE_FIXED: + tmp_buff= "Fixed"; + break; + case ROW_TYPE_DYNAMIC: + tmp_buff= "Dynamic"; + break; + case ROW_TYPE_COMPRESSED: + tmp_buff= "Compressed"; + break; + case ROW_TYPE_REDUNDANT: + tmp_buff= "Redundant"; + break; + case ROW_TYPE_COMPACT: + tmp_buff= "Compact"; + break; + case ROW_TYPE_PAGES: + tmp_buff= "Paged"; + break; + } + table->field[6]->store(tmp_buff, strlen(tmp_buff), cs); + if (!tables->schema_table) { - table->field[20]->store(comment, - (comment == share->comment.str ? - share->comment.length : - strlen(comment)), cs); - if (comment != share->comment.str) - my_free(comment, MYF(0)); + table->field[7]->store((longlong) file->stats.records, TRUE); + table->field[7]->set_notnull(); + } + table->field[8]->store((longlong) file->stats.mean_rec_length, TRUE); + table->field[9]->store((longlong) file->stats.data_file_length, TRUE); + if (file->stats.max_data_file_length) + { + table->field[10]->store((longlong) file->stats.max_data_file_length, + TRUE); + } + table->field[11]->store((longlong) file->stats.index_file_length, TRUE); + table->field[12]->store((longlong) file->stats.delete_length, TRUE); + if (show_table->found_next_number_field) + { + table->field[13]->store((longlong) file->stats.auto_increment_value, + TRUE); + table->field[13]->set_notnull(); + } + if (file->stats.create_time) + { + thd->variables.time_zone->gmt_sec_to_TIME(&time, + (my_time_t) file->stats.create_time); + table->field[14]->store_time(&time, MYSQL_TIMESTAMP_DATETIME); + table->field[14]->set_notnull(); + } + if (file->stats.update_time) + { + thd->variables.time_zone->gmt_sec_to_TIME(&time, + (my_time_t) file->stats.update_time); + table->field[15]->store_time(&time, MYSQL_TIMESTAMP_DATETIME); + table->field[15]->set_notnull(); + } + if (file->stats.check_time) + { + thd->variables.time_zone->gmt_sec_to_TIME(&time, + (my_time_t) file->stats.check_time); + table->field[16]->store_time(&time, MYSQL_TIMESTAMP_DATETIME); + table->field[16]->set_notnull(); + } + tmp_buff= (share->table_charset ? + share->table_charset->name : "default"); + table->field[17]->store(tmp_buff, strlen(tmp_buff), cs); + if (file->ha_table_flags() & (ulong) HA_HAS_CHECKSUM) + { + table->field[18]->store((longlong) file->checksum(), TRUE); + table->field[18]->set_notnull(); } } } @@ -3015,17 +3495,15 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, static int get_schema_column_record(THD *thd, TABLE_LIST *tables, TABLE *table, bool res, - const char *base_name, - const char *file_name) + LEX_STRING *db_name, + LEX_STRING *table_name) { LEX *lex= thd->lex; const char *wild= lex->wild ? lex->wild->ptr() : NullS; CHARSET_INFO *cs= system_charset_info; TABLE *show_table; - handler *file; Field **ptr,*field; int count; - uint base_name_length, file_name_length; DBUG_ENTER("get_schema_column_record"); if (res) @@ -3045,15 +3523,11 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, } show_table= tables->table; - file= show_table->file; count= 0; - file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK); restore_record(show_table, s->default_values); - base_name_length= strlen(base_name); - file_name_length= strlen(file_name); show_table->use_all_columns(); // Required for default - for (ptr=show_table->field; (field= *ptr) ; ptr++) + for (ptr= show_table->field; (field= *ptr) ; ptr++) { const char *tmp_buff; uchar *pos; @@ -3076,10 +3550,10 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, #ifndef NO_EMBEDDED_ACCESS_CHECKS uint col_access; - check_access(thd,SELECT_ACL | EXTRA_ACL, base_name, + check_access(thd,SELECT_ACL | EXTRA_ACL, db_name->str, &tables->grant.privilege, 0, 0, test(tables->schema_table)); col_access= get_column_grant(thd, &tables->grant, - base_name, file_name, + db_name->str, table_name->str, field->field_name) & COL_ACLS; if (lex->sql_command != SQLCOM_SHOW_FIELDS && !tables->schema_table && !col_access) @@ -3096,8 +3570,8 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, table->field[17]->store(tmp+1,end == tmp ? 0 : (uint) (end-tmp-1), cs); #endif - table->field[1]->store(base_name, base_name_length, cs); - table->field[2]->store(file_name, file_name_length, cs); + table->field[1]->store(db_name->str, db_name->length, cs); + table->field[2]->store(table_name->str, table_name->length, cs); table->field[3]->store(field->field_name, strlen(field->field_name), cs); table->field[4]->store((longlong) count, TRUE); @@ -3522,8 +3996,8 @@ err: static int get_schema_stat_record(THD *thd, TABLE_LIST *tables, TABLE *table, bool res, - const char *base_name, - const char *file_name) + LEX_STRING *db_name, + LEX_STRING *table_name) { CHARSET_INFO *cs= system_charset_info; DBUG_ENTER("get_schema_stat_record"); @@ -3535,7 +4009,7 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables, I.e. we are in SELECT FROM INFORMATION_SCHEMA.STATISTICS rather than in SHOW KEYS */ - if (!tables->view) + if (thd->net.last_errno) push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, thd->net.last_errno, thd->net.last_error); thd->clear_error(); @@ -3546,10 +4020,11 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables, else if (!tables->view) { TABLE *show_table= tables->table; - KEY *key_info=show_table->key_info; - show_table->file->info(HA_STATUS_VARIABLE | - HA_STATUS_NO_LOCK | - HA_STATUS_TIME); + KEY *key_info=show_table->s->key_info; + if (show_table->file) + show_table->file->info(HA_STATUS_VARIABLE | + HA_STATUS_NO_LOCK | + HA_STATUS_TIME); for (uint i=0 ; i < show_table->s->keys ; i++,key_info++) { KEY_PART_INFO *key_part= key_info->key_part; @@ -3557,35 +4032,40 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables, for (uint j=0 ; j < key_info->key_parts ; j++,key_part++) { restore_record(table, s->default_values); - table->field[1]->store(base_name, strlen(base_name), cs); - table->field[2]->store(file_name, strlen(file_name), cs); + table->field[1]->store(db_name->str, db_name->length, cs); + table->field[2]->store(table_name->str, table_name->length, cs); table->field[3]->store((longlong) ((key_info->flags & HA_NOSAME) ? 0 : 1), TRUE); - table->field[4]->store(base_name, strlen(base_name), cs); + table->field[4]->store(db_name->str, db_name->length, cs); table->field[5]->store(key_info->name, strlen(key_info->name), cs); table->field[6]->store((longlong) (j+1), TRUE); str=(key_part->field ? key_part->field->field_name : "?unknown field?"); table->field[7]->store(str, strlen(str), cs); - if (show_table->file->index_flags(i, j, 0) & HA_READ_ORDER) + if (show_table->file) { - table->field[8]->store(((key_part->key_part_flag & - HA_REVERSE_SORT) ? - "D" : "A"), 1, cs); - table->field[8]->set_notnull(); - } - KEY *key=show_table->key_info+i; - if (key->rec_per_key[j]) - { - ha_rows records=(show_table->file->stats.records / - key->rec_per_key[j]); - table->field[9]->store((longlong) records, TRUE); - table->field[9]->set_notnull(); + if (show_table->file->index_flags(i, j, 0) & HA_READ_ORDER) + { + table->field[8]->store(((key_part->key_part_flag & + HA_REVERSE_SORT) ? + "D" : "A"), 1, cs); + table->field[8]->set_notnull(); + } + KEY *key=show_table->key_info+i; + if (key->rec_per_key[j]) + { + ha_rows records=(show_table->file->stats.records / + key->rec_per_key[j]); + table->field[9]->store((longlong) records, TRUE); + table->field[9]->set_notnull(); + } + str= show_table->file->index_type(i); + table->field[13]->store(str, strlen(str), cs); } if (!(key_info->flags & HA_FULLTEXT) && (key_part->field && key_part->length != - show_table->field[key_part->fieldnr-1]->key_length())) + show_table->s->field[key_part->fieldnr-1]->key_length())) { table->field[10]->store((longlong) key_part->length / key_part->field->charset()->mbmaxlen, TRUE); @@ -3594,8 +4074,6 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables, uint flags= key_part->field ? key_part->field->flags : 0; const char *pos=(char*) ((flags & NOT_NULL_FLAG) ? "" : "YES"); table->field[12]->store(pos, strlen(pos), cs); - pos= show_table->file->index_type(i); - table->field[13]->store(pos, strlen(pos), cs); if (!show_table->s->keys_in_use.is_set(i)) table->field[14]->store(STRING_WITH_LEN("disabled"), cs); else @@ -3612,19 +4090,28 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables, static int get_schema_views_record(THD *thd, TABLE_LIST *tables, TABLE *table, bool res, - const char *base_name, - const char *file_name) + LEX_STRING *db_name, + LEX_STRING *table_name) { CHARSET_INFO *cs= system_charset_info; DBUG_ENTER("get_schema_views_record"); + LEX_STRING *tmp_db_name, *tmp_table_name; char definer[USER_HOST_BUFF_SIZE]; uint definer_len; bool updatable_view; + /* + if SELECT FROM I_S.VIEWS uses only fields + which have OPEN_FRM_ONLY flag then 'tables' + structure is zeroed and only tables->view is set. + (see fill_schema_table_from_frm() function). + So we should disable other fields filling. + */ + bool only_share= !tables->definer.user.str; if (tables->view) { Security_context *sctx= thd->security_ctx; - if (!tables->allowed_show) + if (!only_share && !tables->allowed_show) { if (!my_strcasecmp(system_charset_info, tables->definer.user.str, sctx->priv_user) && @@ -3633,79 +4120,88 @@ static int get_schema_views_record(THD *thd, TABLE_LIST *tables, tables->allowed_show= TRUE; } restore_record(table, s->default_values); - table->field[1]->store(tables->view_db.str, tables->view_db.length, cs); - table->field[2]->store(tables->view_name.str, tables->view_name.length, cs); - if (tables->allowed_show) + tmp_db_name= &tables->view_db; + tmp_table_name= &tables->view_name; + if (only_share) { - table->field[3]->store(tables->view_body_utf8.str, - tables->view_body_utf8.length, - cs); + tmp_db_name= db_name; + tmp_table_name= table_name; } - - if (tables->with_check != VIEW_CHECK_NONE) + table->field[1]->store(tmp_db_name->str, tmp_db_name->length, cs); + table->field[2]->store(tmp_table_name->str, tmp_table_name->length, cs); + if (!only_share) { - if (tables->with_check == VIEW_CHECK_LOCAL) - table->field[4]->store(STRING_WITH_LEN("LOCAL"), cs); - else - table->field[4]->store(STRING_WITH_LEN("CASCADED"), cs); - } - else - table->field[4]->store(STRING_WITH_LEN("NONE"), cs); - - updatable_view= 0; - if (tables->algorithm != VIEW_ALGORITHM_TMPTABLE) - { - /* - We should use tables->view->select_lex.item_list here and - can not use Field_iterator_view because the view always uses - temporary algorithm during opening for I_S and - TABLE_LIST fields 'field_translation' & 'field_translation_end' - are uninitialized is this case. - */ - List *fields= &tables->view->select_lex.item_list; - List_iterator it(*fields); - Item *item; - Item_field *field; - /* - check that at least one column in view is updatable - */ - while ((item= it++)) + if (tables->allowed_show) { - if ((field= item->filed_for_view_update()) && field->field && - !field->field->table->pos_in_table_list->schema_table) - { - updatable_view= 1; - break; - } + table->field[3]->store(tables->view_body_utf8.str, + tables->view_body_utf8.length, + cs); } - if (updatable_view && !tables->view->can_be_merged()) - updatable_view= 0; + + if (tables->with_check != VIEW_CHECK_NONE) + { + if (tables->with_check == VIEW_CHECK_LOCAL) + table->field[4]->store(STRING_WITH_LEN("LOCAL"), cs); + else + table->field[4]->store(STRING_WITH_LEN("CASCADED"), cs); + } + else + table->field[4]->store(STRING_WITH_LEN("NONE"), cs); + + updatable_view= 0; + if (tables->algorithm != VIEW_ALGORITHM_TMPTABLE) + { + /* + We should use tables->view->select_lex.item_list here and + can not use Field_iterator_view because the view always uses + temporary algorithm during opening for I_S and + TABLE_LIST fields 'field_translation' & 'field_translation_end' + are uninitialized is this case. + */ + List *fields= &tables->view->select_lex.item_list; + List_iterator it(*fields); + Item *item; + Item_field *field; + /* + check that at least one column in view is updatable + */ + while ((item= it++)) + { + if ((field= item->filed_for_view_update()) && field->field && + !field->field->table->pos_in_table_list->schema_table) + { + updatable_view= 1; + break; + } + } + if (updatable_view && !tables->view->can_be_merged()) + updatable_view= 0; + } + if (updatable_view) + table->field[5]->store(STRING_WITH_LEN("YES"), cs); + else + table->field[5]->store(STRING_WITH_LEN("NO"), cs); + definer_len= (strxmov(definer, tables->definer.user.str, "@", + tables->definer.host.str, NullS) - definer); + table->field[6]->store(definer, definer_len, cs); + if (tables->view_suid) + table->field[7]->store(STRING_WITH_LEN("DEFINER"), cs); + else + table->field[7]->store(STRING_WITH_LEN("INVOKER"), cs); + + table->field[8]->store(tables->view_creation_ctx->get_client_cs()->csname, + strlen(tables->view_creation_ctx-> + get_client_cs()->csname), cs); + + table->field[9]->store(tables->view_creation_ctx-> + get_connection_cl()->name, + strlen(tables->view_creation_ctx-> + get_connection_cl()->name), cs); } - if (updatable_view) - table->field[5]->store(STRING_WITH_LEN("YES"), cs); - else - table->field[5]->store(STRING_WITH_LEN("NO"), cs); - definer_len= (strxmov(definer, tables->definer.user.str, "@", - tables->definer.host.str, NullS) - definer); - table->field[6]->store(definer, definer_len, cs); - if (tables->view_suid) - table->field[7]->store(STRING_WITH_LEN("DEFINER"), cs); - else - table->field[7]->store(STRING_WITH_LEN("INVOKER"), cs); - - table->field[8]->store( - tables->view_creation_ctx->get_client_cs()->csname, - strlen(tables->view_creation_ctx->get_client_cs()->csname), - cs); - - table->field[9]->store( - tables->view_creation_ctx->get_connection_cl()->name, - strlen(tables->view_creation_ctx->get_connection_cl()->name), - cs); if (schema_table_store_record(thd, table)) DBUG_RETURN(1); - if (res) + if (res && thd->net.last_errno) push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, thd->net.last_errno, thd->net.last_error); } @@ -3715,16 +4211,16 @@ static int get_schema_views_record(THD *thd, TABLE_LIST *tables, } -bool store_constraints(THD *thd, TABLE *table, const char *db, - const char *tname, const char *key_name, +bool store_constraints(THD *thd, TABLE *table, LEX_STRING *db_name, + LEX_STRING *table_name, const char *key_name, uint key_len, const char *con_type, uint con_len) { CHARSET_INFO *cs= system_charset_info; restore_record(table, s->default_values); - table->field[1]->store(db, strlen(db), cs); + table->field[1]->store(db_name->str, db_name->length, cs); table->field[2]->store(key_name, key_len, cs); - table->field[3]->store(db, strlen(db), cs); - table->field[4]->store(tname, strlen(tname), cs); + table->field[3]->store(db_name->str, db_name->length, cs); + table->field[4]->store(table_name->str, table_name->length, cs); table->field[5]->store(con_type, con_len, cs); return schema_table_store_record(thd, table); } @@ -3732,13 +4228,13 @@ bool store_constraints(THD *thd, TABLE *table, const char *db, static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables, TABLE *table, bool res, - const char *base_name, - const char *file_name) + LEX_STRING *db_name, + LEX_STRING *table_name) { DBUG_ENTER("get_schema_constraints_record"); if (res) { - if (!tables->view) + if (thd->net.last_errno) push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, thd->net.last_errno, thd->net.last_error); thd->clear_error(); @@ -3760,14 +4256,14 @@ static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables, if (i == primary_key && !strcmp(key_info->name, primary_key_name)) { - if (store_constraints(thd, table, base_name, file_name, key_info->name, + if (store_constraints(thd, table, db_name, table_name, key_info->name, strlen(key_info->name), STRING_WITH_LEN("PRIMARY KEY"))) DBUG_RETURN(1); } else if (key_info->flags & HA_NOSAME) { - if (store_constraints(thd, table, base_name, file_name, key_info->name, + if (store_constraints(thd, table, db_name, table_name, key_info->name, strlen(key_info->name), STRING_WITH_LEN("UNIQUE"))) DBUG_RETURN(1); @@ -3779,7 +4275,7 @@ static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables, List_iterator_fast it(f_key_list); while ((f_key_info=it++)) { - if (store_constraints(thd, table, base_name, file_name, + if (store_constraints(thd, table, db_name, table_name, f_key_info->forein_id->str, strlen(f_key_info->forein_id->str), "FOREIGN KEY", 11)) @@ -3790,8 +4286,8 @@ static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables, } -static bool store_trigger(THD *thd, TABLE *table, const char *db, - const char *tname, LEX_STRING *trigger_name, +static bool store_trigger(THD *thd, TABLE *table, LEX_STRING *db_name, + LEX_STRING *table_name, LEX_STRING *trigger_name, enum trg_event_type event, enum trg_action_time_type timing, LEX_STRING *trigger_stmt, @@ -3805,12 +4301,12 @@ static bool store_trigger(THD *thd, TABLE *table, const char *db, LEX_STRING sql_mode_rep; restore_record(table, s->default_values); - table->field[1]->store(db, strlen(db), cs); + table->field[1]->store(db_name->str, db_name->length, cs); table->field[2]->store(trigger_name->str, trigger_name->length, cs); table->field[3]->store(trg_event_type_names[event].str, trg_event_type_names[event].length, cs); - table->field[5]->store(db, strlen(db), cs); - table->field[6]->store(tname, strlen(tname), cs); + table->field[5]->store(db_name->str, db_name->length, cs); + table->field[6]->store(table_name->str, table_name->length, cs); table->field[9]->store(trigger_stmt->str, trigger_stmt->length, cs); table->field[10]->store(STRING_WITH_LEN("ROW"), cs); table->field[11]->store(trg_action_time_type_names[timing].str, @@ -3833,8 +4329,8 @@ static bool store_trigger(THD *thd, TABLE *table, const char *db, static int get_schema_triggers_record(THD *thd, TABLE_LIST *tables, TABLE *table, bool res, - const char *base_name, - const char *file_name) + LEX_STRING *db_name, + LEX_STRING *table_name) { DBUG_ENTER("get_schema_triggers_record"); /* @@ -3843,7 +4339,7 @@ static int get_schema_triggers_record(THD *thd, TABLE_LIST *tables, */ if (res) { - if (!tables->view) + if (thd->net.last_errno) push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, thd->net.last_errno, thd->net.last_error); thd->clear_error(); @@ -3877,7 +4373,7 @@ static int get_schema_triggers_record(THD *thd, TABLE_LIST *tables, &db_cl_name)) continue; - if (store_trigger(thd, table, base_name, file_name, &trigger_name, + if (store_trigger(thd, table, db_name, table_name, &trigger_name, (enum trg_event_type) event, (enum trg_action_time_type) timing, &trigger_stmt, sql_mode, @@ -3893,15 +4389,16 @@ static int get_schema_triggers_record(THD *thd, TABLE_LIST *tables, } -void store_key_column_usage(TABLE *table, const char*db, const char *tname, - const char *key_name, uint key_len, - const char *con_type, uint con_len, longlong idx) +void store_key_column_usage(TABLE *table, LEX_STRING *db_name, + LEX_STRING *table_name, const char *key_name, + uint key_len, const char *con_type, uint con_len, + longlong idx) { CHARSET_INFO *cs= system_charset_info; - table->field[1]->store(db, strlen(db), cs); + table->field[1]->store(db_name->str, db_name->length, cs); table->field[2]->store(key_name, key_len, cs); - table->field[4]->store(db, strlen(db), cs); - table->field[5]->store(tname, strlen(tname), cs); + table->field[4]->store(db_name->str, db_name->length, cs); + table->field[5]->store(table_name->str, table_name->length, cs); table->field[6]->store(con_type, con_len, cs); table->field[7]->store((longlong) idx, TRUE); } @@ -3910,13 +4407,13 @@ void store_key_column_usage(TABLE *table, const char*db, const char *tname, static int get_schema_key_column_usage_record(THD *thd, TABLE_LIST *tables, TABLE *table, bool res, - const char *base_name, - const char *file_name) + LEX_STRING *db_name, + LEX_STRING *table_name) { DBUG_ENTER("get_schema_key_column_usage_record"); if (res) { - if (!tables->view) + if (thd->net.last_errno) push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, thd->net.last_errno, thd->net.last_error); thd->clear_error(); @@ -3943,7 +4440,7 @@ static int get_schema_key_column_usage_record(THD *thd, { f_idx++; restore_record(table, s->default_values); - store_key_column_usage(table, base_name, file_name, + store_key_column_usage(table, db_name, table_name, key_info->name, strlen(key_info->name), key_part->field->field_name, @@ -3970,7 +4467,7 @@ static int get_schema_key_column_usage_record(THD *thd, r_info= it1++; f_idx++; restore_record(table, s->default_values); - store_key_column_usage(table, base_name, file_name, + store_key_column_usage(table, db_name, table_name, f_key_info->forein_id->str, f_key_info->forein_id->length, f_info->str, f_info->length, @@ -4095,8 +4592,8 @@ static void store_schema_partitions_record(THD *thd, TABLE *schema_table, static int get_schema_partitions_record(THD *thd, TABLE_LIST *tables, TABLE *table, bool res, - const char *base_name, - const char *file_name) + LEX_STRING *db_name, + LEX_STRING *table_name) { CHARSET_INFO *cs= system_charset_info; char buff[61]; @@ -4111,7 +4608,7 @@ static int get_schema_partitions_record(THD *thd, TABLE_LIST *tables, if (res) { - if (!tables->view) + if (thd->net.last_errno) push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, thd->net.last_errno, thd->net.last_error); thd->clear_error(); @@ -4127,8 +4624,8 @@ static int get_schema_partitions_record(THD *thd, TABLE_LIST *tables, uint part_pos= 0, part_id= 0; restore_record(table, s->default_values); - table->field[1]->store(base_name, strlen(base_name), cs); - table->field[2]->store(file_name, strlen(file_name), cs); + table->field[1]->store(db_name->str, db_name->length, cs); + table->field[2]->store(table_name->str, table_name->length, cs); /* Partition method*/ @@ -4641,14 +5138,14 @@ int fill_status(THD *thd, TABLE_LIST *tables, COND *cond) static int get_referential_constraints_record(THD *thd, TABLE_LIST *tables, TABLE *table, bool res, - const char *base_name, const char *file_name) + LEX_STRING *db_name, LEX_STRING *table_name) { CHARSET_INFO *cs= system_charset_info; DBUG_ENTER("get_referential_constraints_record"); if (res) { - if (!tables->view) + if (thd->net.last_errno) push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, thd->net.last_errno, thd->net.last_error); thd->clear_error(); @@ -4668,8 +5165,8 @@ get_referential_constraints_record(THD *thd, TABLE_LIST *tables, while ((f_key_info= it++)) { restore_record(table, s->default_values); - table->field[1]->store(base_name, strlen(base_name), cs); - table->field[9]->store(file_name, strlen(file_name), cs); + table->field[1]->store(db_name->str, db_name->length, cs); + table->field[9]->store(table_name->str, table_name->length, cs); table->field[2]->store(f_key_info->forein_id->str, f_key_info->forein_id->length, cs); table->field[4]->store(f_key_info->referenced_db->str, @@ -4739,7 +5236,7 @@ static my_bool find_schema_table_in_plugin(THD *thd, plugin_ref plugin, RETURN 0 table not found - # pointer to 'shema_tables' element + # pointer to 'schema_tables' element */ ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name) @@ -4882,6 +5379,12 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list) TMP_TABLE_ALL_COLUMNS), HA_POS_ERROR, table_list->alias))) DBUG_RETURN(0); + my_bitmap_map* bitmaps= + (my_bitmap_map*) thd->alloc(bitmap_buffer_size(field_count)); + bitmap_init(&table->def_read_set, (my_bitmap_map*) bitmaps, field_count, + FALSE); + table->read_set= &table->def_read_set; + bitmap_clear_all(table->read_set); table_list->schema_table_param= tmp_table_param; DBUG_RETURN(table); } @@ -5225,6 +5728,13 @@ bool get_schema_tables_result(JOIN *join, { bool is_subselect= (&lex->unit != lex->current_select->master_unit() && lex->current_select->master_unit()->item); + + + /* skip I_S optimizations specific to get_all_tables */ + if (thd->lex->describe && + (table_list->schema_table->fill_table != get_all_tables)) + continue; + /* If schema table is already processed and the statement is not a subselect then @@ -5304,479 +5814,537 @@ int fill_schema_files(THD *thd, TABLE_LIST *tables, COND *cond) ST_FIELD_INFO schema_fields_info[]= { - {"CATALOG_NAME", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"SCHEMA_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Database"}, - {"DEFAULT_CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0}, - {"DEFAULT_COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0}, - {"SQL_PATH", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + {"CATALOG_NAME", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {"SCHEMA_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Database", + SKIP_OPEN_TABLE}, + {"DEFAULT_CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0, + SKIP_OPEN_TABLE}, + {"DEFAULT_COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"SQL_PATH", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO tables_fields_info[]= { - {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Name"}, - {"TABLE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"ENGINE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, "Engine"}, + {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Name", + SKIP_OPEN_TABLE}, + {"TABLE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY}, + {"ENGINE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, "Engine", OPEN_FRM_ONLY}, {"VERSION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Version"}, - {"ROW_FORMAT", 10, MYSQL_TYPE_STRING, 0, 1, "Row_format"}, + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Version", OPEN_FRM_ONLY}, + {"ROW_FORMAT", 10, MYSQL_TYPE_STRING, 0, 1, "Row_format", OPEN_FULL_TABLE}, {"TABLE_ROWS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Rows"}, + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Rows", OPEN_FULL_TABLE}, {"AVG_ROW_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Avg_row_length"}, + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Avg_row_length", OPEN_FULL_TABLE}, {"DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Data_length"}, + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Data_length", OPEN_FULL_TABLE}, {"MAX_DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Max_data_length"}, + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Max_data_length", OPEN_FULL_TABLE}, {"INDEX_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Index_length"}, + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Index_length", OPEN_FULL_TABLE}, {"DATA_FREE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Data_free"}, + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Data_free", OPEN_FULL_TABLE}, {"AUTO_INCREMENT", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Auto_increment"}, - {"CREATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, "Create_time"}, - {"UPDATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, "Update_time"}, - {"CHECK_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, "Check_time"}, - {"TABLE_COLLATION", 64, MYSQL_TYPE_STRING, 0, 1, "Collation"}, + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Auto_increment", OPEN_FULL_TABLE}, + {"CREATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, "Create_time", OPEN_FULL_TABLE}, + {"UPDATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, "Update_time", OPEN_FULL_TABLE}, + {"CHECK_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, "Check_time", OPEN_FULL_TABLE}, + {"TABLE_COLLATION", 64, MYSQL_TYPE_STRING, 0, 1, "Collation", OPEN_FRM_ONLY}, {"CHECKSUM", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Checksum"}, - {"CREATE_OPTIONS", 255, MYSQL_TYPE_STRING, 0, 1, "Create_options"}, - {"TABLE_COMMENT", 80, MYSQL_TYPE_STRING, 0, 0, "Comment"}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Checksum", OPEN_FULL_TABLE}, + {"CREATE_OPTIONS", 255, MYSQL_TYPE_STRING, 0, 1, "Create_options", + OPEN_FRM_ONLY}, + {"TABLE_COMMENT", 80, MYSQL_TYPE_STRING, 0, 0, "Comment", OPEN_FRM_ONLY}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO columns_fields_info[]= { - {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Field"}, + {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FRM_ONLY}, + {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY}, + {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY}, + {"COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Field", + OPEN_FRM_ONLY}, {"ORDINAL_POSITION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, - MY_I_S_UNSIGNED, 0}, + MY_I_S_UNSIGNED, 0, OPEN_FRM_ONLY}, {"COLUMN_DEFAULT", MAX_FIELD_VARCHARLENGTH, MYSQL_TYPE_STRING, 0, - 1, "Default"}, - {"IS_NULLABLE", 3, MYSQL_TYPE_STRING, 0, 0, "Null"}, - {"DATA_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, + 1, "Default", OPEN_FRM_ONLY}, + {"IS_NULLABLE", 3, MYSQL_TYPE_STRING, 0, 0, "Null", OPEN_FRM_ONLY}, + {"DATA_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY}, {"CHARACTER_MAXIMUM_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, - 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0}, + 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY}, {"CHARACTER_OCTET_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONGLONG, - 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0}, + 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY}, {"NUMERIC_PRECISION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, - 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0}, + 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY}, {"NUMERIC_SCALE", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONGLONG, - 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0}, - {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0}, - {"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 1, "Collation"}, - {"COLUMN_TYPE", 65535, MYSQL_TYPE_STRING, 0, 0, "Type"}, - {"COLUMN_KEY", 3, MYSQL_TYPE_STRING, 0, 0, "Key"}, - {"EXTRA", 20, MYSQL_TYPE_STRING, 0, 0, "Extra"}, - {"PRIVILEGES", 80, MYSQL_TYPE_STRING, 0, 0, "Privileges"}, - {"COLUMN_COMMENT", 255, MYSQL_TYPE_STRING, 0, 0, "Comment"}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY}, + {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FRM_ONLY}, + {"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 1, "Collation", OPEN_FRM_ONLY}, + {"COLUMN_TYPE", 65535, MYSQL_TYPE_STRING, 0, 0, "Type", OPEN_FRM_ONLY}, + {"COLUMN_KEY", 3, MYSQL_TYPE_STRING, 0, 0, "Key", OPEN_FRM_ONLY}, + {"EXTRA", 20, MYSQL_TYPE_STRING, 0, 0, "Extra", OPEN_FRM_ONLY}, + {"PRIVILEGES", 80, MYSQL_TYPE_STRING, 0, 0, "Privileges", OPEN_FRM_ONLY}, + {"COLUMN_COMMENT", 255, MYSQL_TYPE_STRING, 0, 0, "Comment", OPEN_FRM_ONLY}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO charsets_fields_info[]= { - {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Charset"}, - {"DEFAULT_COLLATE_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Default collation"}, - {"DESCRIPTION", 60, MYSQL_TYPE_STRING, 0, 0, "Description"}, - {"MAXLEN", 3, MYSQL_TYPE_LONGLONG, 0, 0, "Maxlen"}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Charset", + SKIP_OPEN_TABLE}, + {"DEFAULT_COLLATE_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Default collation", + SKIP_OPEN_TABLE}, + {"DESCRIPTION", 60, MYSQL_TYPE_STRING, 0, 0, "Description", + SKIP_OPEN_TABLE}, + {"MAXLEN", 3, MYSQL_TYPE_LONGLONG, 0, 0, "Maxlen", SKIP_OPEN_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO collation_fields_info[]= { - {"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Collation"}, - {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Charset"}, - {"ID", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Id"}, - {"IS_DEFAULT", 3, MYSQL_TYPE_STRING, 0, 0, "Default"}, - {"IS_COMPILED", 3, MYSQL_TYPE_STRING, 0, 0, "Compiled"}, - {"SORTLEN", 3, MYSQL_TYPE_LONGLONG, 0, 0, "Sortlen"}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + {"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Collation", SKIP_OPEN_TABLE}, + {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Charset", + SKIP_OPEN_TABLE}, + {"ID", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Id", + SKIP_OPEN_TABLE}, + {"IS_DEFAULT", 3, MYSQL_TYPE_STRING, 0, 0, "Default", SKIP_OPEN_TABLE}, + {"IS_COMPILED", 3, MYSQL_TYPE_STRING, 0, 0, "Compiled", SKIP_OPEN_TABLE}, + {"SORTLEN", 3, MYSQL_TYPE_LONGLONG, 0, 0, "Sortlen", SKIP_OPEN_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO engines_fields_info[]= { - {"ENGINE", 64, MYSQL_TYPE_STRING, 0, 0, "Engine"}, - {"SUPPORT", 8, MYSQL_TYPE_STRING, 0, 0, "Support"}, - {"COMMENT", 80, MYSQL_TYPE_STRING, 0, 0, "Comment"}, - {"TRANSACTIONS", 3, MYSQL_TYPE_STRING, 0, 0, "Transactions"}, - {"XA", 3, MYSQL_TYPE_STRING, 0, 0, "XA"}, - {"SAVEPOINTS", 3 ,MYSQL_TYPE_STRING, 0, 0, "Savepoints"}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + {"ENGINE", 64, MYSQL_TYPE_STRING, 0, 0, "Engine", SKIP_OPEN_TABLE}, + {"SUPPORT", 8, MYSQL_TYPE_STRING, 0, 0, "Support", SKIP_OPEN_TABLE}, + {"COMMENT", 80, MYSQL_TYPE_STRING, 0, 0, "Comment", SKIP_OPEN_TABLE}, + {"TRANSACTIONS", 3, MYSQL_TYPE_STRING, 0, 0, "Transactions", SKIP_OPEN_TABLE}, + {"XA", 3, MYSQL_TYPE_STRING, 0, 0, "XA", SKIP_OPEN_TABLE}, + {"SAVEPOINTS", 3 ,MYSQL_TYPE_STRING, 0, 0, "Savepoints", SKIP_OPEN_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO events_fields_info[]= { - {"EVENT_CATALOG", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"EVENT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Db"}, - {"EVENT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Name"}, - {"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0, "Definer"}, - {"TIME_ZONE", 64, MYSQL_TYPE_STRING, 0, 0, "Time zone"}, - {"EVENT_BODY", 8, MYSQL_TYPE_STRING, 0, 0, 0}, - {"EVENT_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 0, 0}, - {"EVENT_TYPE", 9, MYSQL_TYPE_STRING, 0, 0, "Type"}, - {"EXECUTE_AT", 0, MYSQL_TYPE_DATETIME, 0, 1, "Execute at"}, - {"INTERVAL_VALUE", 256, MYSQL_TYPE_STRING, 0, 1, "Interval value"}, - {"INTERVAL_FIELD", 18, MYSQL_TYPE_STRING, 0, 1, "Interval field"}, - {"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 0, 0}, - {"STARTS", 0, MYSQL_TYPE_DATETIME, 0, 1, "Starts"}, - {"ENDS", 0, MYSQL_TYPE_DATETIME, 0, 1, "Ends"}, - {"STATUS", 18, MYSQL_TYPE_STRING, 0, 0, "Status"}, - {"ON_COMPLETION", 12, MYSQL_TYPE_STRING, 0, 0, 0}, - {"CREATED", 0, MYSQL_TYPE_DATETIME, 0, 0, 0}, - {"LAST_ALTERED", 0, MYSQL_TYPE_DATETIME, 0, 0, 0}, - {"LAST_EXECUTED", 0, MYSQL_TYPE_DATETIME, 0, 1, 0}, - {"EVENT_COMMENT", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"ORIGINATOR", 10, MYSQL_TYPE_LONGLONG, 0, 0, "Originator"}, + {"EVENT_CATALOG", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {"EVENT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Db", + SKIP_OPEN_TABLE}, + {"EVENT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Name", + SKIP_OPEN_TABLE}, + {"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0, "Definer", SKIP_OPEN_TABLE}, + {"TIME_ZONE", 64, MYSQL_TYPE_STRING, 0, 0, "Time zone", SKIP_OPEN_TABLE}, + {"EVENT_BODY", 8, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"EVENT_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"EVENT_TYPE", 9, MYSQL_TYPE_STRING, 0, 0, "Type", SKIP_OPEN_TABLE}, + {"EXECUTE_AT", 0, MYSQL_TYPE_DATETIME, 0, 1, "Execute at", SKIP_OPEN_TABLE}, + {"INTERVAL_VALUE", 256, MYSQL_TYPE_STRING, 0, 1, "Interval value", + SKIP_OPEN_TABLE}, + {"INTERVAL_FIELD", 18, MYSQL_TYPE_STRING, 0, 1, "Interval field", + SKIP_OPEN_TABLE}, + {"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"STARTS", 0, MYSQL_TYPE_DATETIME, 0, 1, "Starts", SKIP_OPEN_TABLE}, + {"ENDS", 0, MYSQL_TYPE_DATETIME, 0, 1, "Ends", SKIP_OPEN_TABLE}, + {"STATUS", 18, MYSQL_TYPE_STRING, 0, 0, "Status", SKIP_OPEN_TABLE}, + {"ON_COMPLETION", 12, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"CREATED", 0, MYSQL_TYPE_DATETIME, 0, 0, 0, SKIP_OPEN_TABLE}, + {"LAST_ALTERED", 0, MYSQL_TYPE_DATETIME, 0, 0, 0, SKIP_OPEN_TABLE}, + {"LAST_EXECUTED", 0, MYSQL_TYPE_DATETIME, 0, 1, 0, SKIP_OPEN_TABLE}, + {"EVENT_COMMENT", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"ORIGINATOR", 10, MYSQL_TYPE_LONGLONG, 0, 0, "Originator", SKIP_OPEN_TABLE}, {"CHARACTER_SET_CLIENT", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, - "character_set_client"}, + "character_set_client", SKIP_OPEN_TABLE}, {"COLLATION_CONNECTION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, - "collation_connection"}, + "collation_connection", SKIP_OPEN_TABLE}, {"DATABASE_COLLATION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, - "Database Collation"}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + "Database Collation", SKIP_OPEN_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO coll_charset_app_fields_info[]= { - {"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0}, - {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + {"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO proc_fields_info[]= { - {"SPECIFIC_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"ROUTINE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"ROUTINE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Db"}, - {"ROUTINE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Name"}, - {"ROUTINE_TYPE", 9, MYSQL_TYPE_STRING, 0, 0, "Type"}, - {"DTD_IDENTIFIER", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"ROUTINE_BODY", 8, MYSQL_TYPE_STRING, 0, 0, 0}, - {"ROUTINE_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 1, 0}, - {"EXTERNAL_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"EXTERNAL_LANGUAGE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"PARAMETER_STYLE", 8, MYSQL_TYPE_STRING, 0, 0, 0}, - {"IS_DETERMINISTIC", 3, MYSQL_TYPE_STRING, 0, 0, 0}, - {"SQL_DATA_ACCESS", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"SQL_PATH", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"SECURITY_TYPE", 7, MYSQL_TYPE_STRING, 0, 0, "Security_type"}, - {"CREATED", 0, MYSQL_TYPE_DATETIME, 0, 0, "Created"}, - {"LAST_ALTERED", 0, MYSQL_TYPE_DATETIME, 0, 0, "Modified"}, - {"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 0, 0}, - {"ROUTINE_COMMENT", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Comment"}, - {"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0, "Definer"}, + {"SPECIFIC_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"ROUTINE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {"ROUTINE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Db", + SKIP_OPEN_TABLE}, + {"ROUTINE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Name", + SKIP_OPEN_TABLE}, + {"ROUTINE_TYPE", 9, MYSQL_TYPE_STRING, 0, 0, "Type", SKIP_OPEN_TABLE}, + {"DTD_IDENTIFIER", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {"ROUTINE_BODY", 8, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"ROUTINE_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {"EXTERNAL_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {"EXTERNAL_LANGUAGE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, + SKIP_OPEN_TABLE}, + {"PARAMETER_STYLE", 8, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"IS_DETERMINISTIC", 3, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"SQL_DATA_ACCESS", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, + SKIP_OPEN_TABLE}, + {"SQL_PATH", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {"SECURITY_TYPE", 7, MYSQL_TYPE_STRING, 0, 0, "Security_type", + SKIP_OPEN_TABLE}, + {"CREATED", 0, MYSQL_TYPE_DATETIME, 0, 0, "Created", SKIP_OPEN_TABLE}, + {"LAST_ALTERED", 0, MYSQL_TYPE_DATETIME, 0, 0, "Modified", SKIP_OPEN_TABLE}, + {"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"ROUTINE_COMMENT", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Comment", + SKIP_OPEN_TABLE}, + {"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0, "Definer", SKIP_OPEN_TABLE}, {"CHARACTER_SET_CLIENT", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, - "character_set_client"}, + "character_set_client", SKIP_OPEN_TABLE}, {"COLLATION_CONNECTION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, - "collation_connection"}, + "collation_connection", SKIP_OPEN_TABLE}, {"DATABASE_COLLATION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, - "Database Collation"}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + "Database Collation", SKIP_OPEN_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO stat_fields_info[]= { - {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Table"}, - {"NON_UNIQUE", 1, MYSQL_TYPE_LONGLONG, 0, 0, "Non_unique"}, - {"INDEX_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"INDEX_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Key_name"}, - {"SEQ_IN_INDEX", 2, MYSQL_TYPE_LONGLONG, 0, 0, "Seq_in_index"}, - {"COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Column_name"}, - {"COLLATION", 1, MYSQL_TYPE_STRING, 0, 1, "Collation"}, + {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FRM_ONLY}, + {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY}, + {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Table", OPEN_FRM_ONLY}, + {"NON_UNIQUE", 1, MYSQL_TYPE_LONGLONG, 0, 0, "Non_unique", OPEN_FRM_ONLY}, + {"INDEX_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY}, + {"INDEX_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Key_name", + OPEN_FRM_ONLY}, + {"SEQ_IN_INDEX", 2, MYSQL_TYPE_LONGLONG, 0, 0, "Seq_in_index", OPEN_FRM_ONLY}, + {"COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Column_name", + OPEN_FRM_ONLY}, + {"COLLATION", 1, MYSQL_TYPE_STRING, 0, 1, "Collation", OPEN_FRM_ONLY}, {"CARDINALITY", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 1, - "Cardinality"}, - {"SUB_PART", 3, MYSQL_TYPE_LONGLONG, 0, 1, "Sub_part"}, - {"PACKED", 10, MYSQL_TYPE_STRING, 0, 1, "Packed"}, - {"NULLABLE", 3, MYSQL_TYPE_STRING, 0, 0, "Null"}, - {"INDEX_TYPE", 16, MYSQL_TYPE_STRING, 0, 0, "Index_type"}, - {"COMMENT", 16, MYSQL_TYPE_STRING, 0, 1, "Comment"}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + "Cardinality", OPEN_FULL_TABLE}, + {"SUB_PART", 3, MYSQL_TYPE_LONGLONG, 0, 1, "Sub_part", OPEN_FRM_ONLY}, + {"PACKED", 10, MYSQL_TYPE_STRING, 0, 1, "Packed", OPEN_FRM_ONLY}, + {"NULLABLE", 3, MYSQL_TYPE_STRING, 0, 0, "Null", OPEN_FRM_ONLY}, + {"INDEX_TYPE", 16, MYSQL_TYPE_STRING, 0, 0, "Index_type", OPEN_FULL_TABLE}, + {"COMMENT", 16, MYSQL_TYPE_STRING, 0, 1, "Comment", OPEN_FRM_ONLY}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO view_fields_info[]= { - {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"VIEW_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 0, 0}, - {"CHECK_OPTION", 8, MYSQL_TYPE_STRING, 0, 0, 0}, - {"IS_UPDATABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0}, - {"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0, 0}, - {"SECURITY_TYPE", 7, MYSQL_TYPE_STRING, 0, 0, 0}, - {"CHARACTER_SET_CLIENT", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, 0}, - {"COLLATION_CONNECTION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, 0}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FRM_ONLY}, + {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY}, + {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY}, + {"VIEW_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"CHECK_OPTION", 8, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"IS_UPDATABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"SECURITY_TYPE", 7, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"CHARACTER_SET_CLIENT", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, 0, + OPEN_FULL_TABLE}, + {"COLLATION_CONNECTION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, 0, + OPEN_FULL_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO user_privileges_fields_info[]= { - {"GRANTEE", 81, MYSQL_TYPE_STRING, 0, 0, 0}, - {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"PRIVILEGE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"IS_GRANTABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + {"GRANTEE", 81, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {"PRIVILEGE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"IS_GRANTABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO schema_privileges_fields_info[]= { - {"GRANTEE", 81, MYSQL_TYPE_STRING, 0, 0, 0}, - {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"PRIVILEGE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"IS_GRANTABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + {"GRANTEE", 81, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"PRIVILEGE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"IS_GRANTABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO table_privileges_fields_info[]= { - {"GRANTEE", 81, MYSQL_TYPE_STRING, 0, 0, 0}, - {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"PRIVILEGE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"IS_GRANTABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + {"GRANTEE", 81, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"PRIVILEGE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"IS_GRANTABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO column_privileges_fields_info[]= { - {"GRANTEE", 81, MYSQL_TYPE_STRING, 0, 0, 0}, - {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"PRIVILEGE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"IS_GRANTABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + {"GRANTEE", 81, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"PRIVILEGE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"IS_GRANTABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO table_constraints_fields_info[]= { - {"CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"CONSTRAINT_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + {"CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE}, + {"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, + OPEN_FULL_TABLE}, + {"CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, + OPEN_FULL_TABLE}, + {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"CONSTRAINT_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, + OPEN_FULL_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO key_column_usage_fields_info[]= { - {"CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"ORDINAL_POSITION", 10 ,MYSQL_TYPE_LONGLONG, 0, 0, 0}, - {"POSITION_IN_UNIQUE_CONSTRAINT", 10 ,MYSQL_TYPE_LONGLONG, 0, 1, 0}, - {"REFERENCED_TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"REFERENCED_TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"REFERENCED_COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + {"CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE}, + {"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, + OPEN_FULL_TABLE}, + {"CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, + OPEN_FULL_TABLE}, + {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE}, + {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"ORDINAL_POSITION", 10 ,MYSQL_TYPE_LONGLONG, 0, 0, 0, OPEN_FULL_TABLE}, + {"POSITION_IN_UNIQUE_CONSTRAINT", 10 ,MYSQL_TYPE_LONGLONG, 0, 1, 0, + OPEN_FULL_TABLE}, + {"REFERENCED_TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, + OPEN_FULL_TABLE}, + {"REFERENCED_TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, + OPEN_FULL_TABLE}, + {"REFERENCED_COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, + OPEN_FULL_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO table_names_fields_info[]= { - {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"TABLE_SCHEMA",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Tables_in_"}, - {"TABLE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_type"}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {"TABLE_SCHEMA",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Tables_in_", + SKIP_OPEN_TABLE}, + {"TABLE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_type", + OPEN_FRM_ONLY}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO open_tables_fields_info[]= { - {"Database", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Database"}, - {"Table",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Table"}, - {"In_use", 1, MYSQL_TYPE_LONGLONG, 0, 0, "In_use"}, - {"Name_locked", 4, MYSQL_TYPE_LONGLONG, 0, 0, "Name_locked"}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + {"Database", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Database", + SKIP_OPEN_TABLE}, + {"Table",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Table", SKIP_OPEN_TABLE}, + {"In_use", 1, MYSQL_TYPE_LONGLONG, 0, 0, "In_use", SKIP_OPEN_TABLE}, + {"Name_locked", 4, MYSQL_TYPE_LONGLONG, 0, 0, "Name_locked", SKIP_OPEN_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO triggers_fields_info[]= { - {"TRIGGER_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"TRIGGER_SCHEMA",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"TRIGGER_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Trigger"}, - {"EVENT_MANIPULATION", 6, MYSQL_TYPE_STRING, 0, 0, "Event"}, - {"EVENT_OBJECT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"EVENT_OBJECT_SCHEMA",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"EVENT_OBJECT_TABLE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Table"}, - {"ACTION_ORDER", 4, MYSQL_TYPE_LONGLONG, 0, 0, 0}, - {"ACTION_CONDITION", 65535, MYSQL_TYPE_STRING, 0, 1, 0}, - {"ACTION_STATEMENT", 65535, MYSQL_TYPE_STRING, 0, 0, "Statement"}, - {"ACTION_ORIENTATION", 9, MYSQL_TYPE_STRING, 0, 0, 0}, - {"ACTION_TIMING", 6, MYSQL_TYPE_STRING, 0, 0, "Timing"}, - {"ACTION_REFERENCE_OLD_TABLE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"ACTION_REFERENCE_NEW_TABLE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"ACTION_REFERENCE_OLD_ROW", 3, MYSQL_TYPE_STRING, 0, 0, 0}, - {"ACTION_REFERENCE_NEW_ROW", 3, MYSQL_TYPE_STRING, 0, 0, 0}, - {"CREATED", 0, MYSQL_TYPE_DATETIME, 0, 1, "Created"}, - {"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 0, "sql_mode"}, - {"DEFINER", 65535, MYSQL_TYPE_STRING, 0, 0, "Definer"}, + {"TRIGGER_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE}, + {"TRIGGER_SCHEMA",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"TRIGGER_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Trigger", + OPEN_FULL_TABLE}, + {"EVENT_MANIPULATION", 6, MYSQL_TYPE_STRING, 0, 0, "Event", OPEN_FULL_TABLE}, + {"EVENT_OBJECT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, + OPEN_FULL_TABLE}, + {"EVENT_OBJECT_SCHEMA",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, + OPEN_FULL_TABLE}, + {"EVENT_OBJECT_TABLE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Table", + OPEN_FULL_TABLE}, + {"ACTION_ORDER", 4, MYSQL_TYPE_LONGLONG, 0, 0, 0, OPEN_FULL_TABLE}, + {"ACTION_CONDITION", 65535, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE}, + {"ACTION_STATEMENT", 65535, MYSQL_TYPE_STRING, 0, 0, "Statement", + OPEN_FULL_TABLE}, + {"ACTION_ORIENTATION", 9, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"ACTION_TIMING", 6, MYSQL_TYPE_STRING, 0, 0, "Timing", OPEN_FULL_TABLE}, + {"ACTION_REFERENCE_OLD_TABLE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, + OPEN_FULL_TABLE}, + {"ACTION_REFERENCE_NEW_TABLE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, + OPEN_FULL_TABLE}, + {"ACTION_REFERENCE_OLD_ROW", 3, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"ACTION_REFERENCE_NEW_ROW", 3, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"CREATED", 0, MYSQL_TYPE_DATETIME, 0, 1, "Created", OPEN_FULL_TABLE}, + {"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 0, "sql_mode", OPEN_FULL_TABLE}, + {"DEFINER", 65535, MYSQL_TYPE_STRING, 0, 0, "Definer", OPEN_FULL_TABLE}, {"CHARACTER_SET_CLIENT", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, - "character_set_client"}, + "character_set_client", OPEN_FULL_TABLE}, {"COLLATION_CONNECTION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, - "collation_connection"}, + "collation_connection", OPEN_FULL_TABLE}, {"DATABASE_COLLATION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, - "Database Collation"}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + "Database Collation", OPEN_FULL_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO partitions_fields_info[]= { - {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"TABLE_SCHEMA",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"PARTITION_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"SUBPARTITION_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, + {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE}, + {"TABLE_SCHEMA",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"PARTITION_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE}, + {"SUBPARTITION_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, + OPEN_FULL_TABLE}, {"PARTITION_ORDINAL_POSITION", 21 , MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0}, + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FULL_TABLE}, {"SUBPARTITION_ORDINAL_POSITION", 21 , MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0}, - {"PARTITION_METHOD", 12, MYSQL_TYPE_STRING, 0, 1, 0}, - {"SUBPARTITION_METHOD", 12, MYSQL_TYPE_STRING, 0, 1, 0}, - {"PARTITION_EXPRESSION", 65535, MYSQL_TYPE_STRING, 0, 1, 0}, - {"SUBPARTITION_EXPRESSION", 65535, MYSQL_TYPE_STRING, 0, 1, 0}, - {"PARTITION_DESCRIPTION", 65535, MYSQL_TYPE_STRING, 0, 1, 0}, - {"TABLE_ROWS", 21 , MYSQL_TYPE_LONGLONG, 0, MY_I_S_UNSIGNED, 0}, - {"AVG_ROW_LENGTH", 21 , MYSQL_TYPE_LONGLONG, 0, MY_I_S_UNSIGNED, 0}, - {"DATA_LENGTH", 21 , MYSQL_TYPE_LONGLONG, 0, MY_I_S_UNSIGNED, 0}, + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FULL_TABLE}, + {"PARTITION_METHOD", 12, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE}, + {"SUBPARTITION_METHOD", 12, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE}, + {"PARTITION_EXPRESSION", 65535, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE}, + {"SUBPARTITION_EXPRESSION", 65535, MYSQL_TYPE_STRING, 0, 1, 0, + OPEN_FULL_TABLE}, + {"PARTITION_DESCRIPTION", 65535, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE}, + {"TABLE_ROWS", 21 , MYSQL_TYPE_LONGLONG, 0, MY_I_S_UNSIGNED, 0, + OPEN_FULL_TABLE}, + {"AVG_ROW_LENGTH", 21 , MYSQL_TYPE_LONGLONG, 0, MY_I_S_UNSIGNED, 0, + OPEN_FULL_TABLE}, + {"DATA_LENGTH", 21 , MYSQL_TYPE_LONGLONG, 0, MY_I_S_UNSIGNED, 0, + OPEN_FULL_TABLE}, {"MAX_DATA_LENGTH", 21 , MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0}, - {"INDEX_LENGTH", 21 , MYSQL_TYPE_LONGLONG, 0, MY_I_S_UNSIGNED, 0}, - {"DATA_FREE", 21 , MYSQL_TYPE_LONGLONG, 0, MY_I_S_UNSIGNED, 0}, - {"CREATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, 0}, - {"UPDATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, 0}, - {"CHECK_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, 0}, + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FULL_TABLE}, + {"INDEX_LENGTH", 21 , MYSQL_TYPE_LONGLONG, 0, MY_I_S_UNSIGNED, 0, + OPEN_FULL_TABLE}, + {"DATA_FREE", 21 , MYSQL_TYPE_LONGLONG, 0, MY_I_S_UNSIGNED, 0, + OPEN_FULL_TABLE}, + {"CREATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, 0, OPEN_FULL_TABLE}, + {"UPDATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, 0, OPEN_FULL_TABLE}, + {"CHECK_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, 0, OPEN_FULL_TABLE}, {"CHECKSUM", 21 , MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0}, - {"PARTITION_COMMENT", 80, MYSQL_TYPE_STRING, 0, 0, 0}, - {"NODEGROUP", 12 , MYSQL_TYPE_STRING, 0, 0, 0}, - {"TABLESPACE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FULL_TABLE}, + {"PARTITION_COMMENT", 80, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"NODEGROUP", 12 , MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"TABLESPACE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, + OPEN_FULL_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO variables_fields_info[]= { - {"VARIABLE_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Variable_name"}, - {"VARIABLE_VALUE", 20480, MYSQL_TYPE_STRING, 0, 1, "Value"}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + {"VARIABLE_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Variable_name", + SKIP_OPEN_TABLE}, + {"VARIABLE_VALUE", 20480, MYSQL_TYPE_STRING, 0, 1, "Value", SKIP_OPEN_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO processlist_fields_info[]= { - {"ID", 4, MYSQL_TYPE_LONGLONG, 0, 0, "Id"}, - {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User"}, - {"HOST", LIST_PROCESS_HOST_LEN, MYSQL_TYPE_STRING, 0, 0, "Host"}, - {"DB", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, "Db"}, - {"COMMAND", 16, MYSQL_TYPE_STRING, 0, 0, "Command"}, - {"TIME", 7, MYSQL_TYPE_LONGLONG, 0, 0, "Time"}, - {"STATE", 64, MYSQL_TYPE_STRING, 0, 1, "State"}, - {"INFO", PROCESS_LIST_INFO_WIDTH, MYSQL_TYPE_STRING, 0, 1, "Info"}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + {"ID", 4, MYSQL_TYPE_LONGLONG, 0, 0, "Id", SKIP_OPEN_TABLE}, + {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User", SKIP_OPEN_TABLE}, + {"HOST", LIST_PROCESS_HOST_LEN, MYSQL_TYPE_STRING, 0, 0, "Host", + SKIP_OPEN_TABLE}, + {"DB", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, "Db", SKIP_OPEN_TABLE}, + {"COMMAND", 16, MYSQL_TYPE_STRING, 0, 0, "Command", SKIP_OPEN_TABLE}, + {"TIME", 7, MYSQL_TYPE_LONGLONG, 0, 0, "Time", SKIP_OPEN_TABLE}, + {"STATE", 64, MYSQL_TYPE_STRING, 0, 1, "State", SKIP_OPEN_TABLE}, + {"INFO", PROCESS_LIST_INFO_WIDTH, MYSQL_TYPE_STRING, 0, 1, "Info", + SKIP_OPEN_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO plugin_fields_info[]= { - {"PLUGIN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Name"}, - {"PLUGIN_VERSION", 20, MYSQL_TYPE_STRING, 0, 0, 0}, - {"PLUGIN_STATUS", 10, MYSQL_TYPE_STRING, 0, 0, "Status"}, - {"PLUGIN_TYPE", 80, MYSQL_TYPE_STRING, 0, 0, "Type"}, - {"PLUGIN_TYPE_VERSION", 20, MYSQL_TYPE_STRING, 0, 0, 0}, - {"PLUGIN_LIBRARY", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, "Library"}, - {"PLUGIN_LIBRARY_VERSION", 20, MYSQL_TYPE_STRING, 0, 1, 0}, - {"PLUGIN_AUTHOR", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"PLUGIN_DESCRIPTION", 65535, MYSQL_TYPE_STRING, 0, 1, 0}, - {"PLUGIN_LICENSE", 80, MYSQL_TYPE_STRING, 0, 1, "License"}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + {"PLUGIN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Name", + SKIP_OPEN_TABLE}, + {"PLUGIN_VERSION", 20, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"PLUGIN_STATUS", 10, MYSQL_TYPE_STRING, 0, 0, "Status", SKIP_OPEN_TABLE}, + {"PLUGIN_TYPE", 80, MYSQL_TYPE_STRING, 0, 0, "Type", SKIP_OPEN_TABLE}, + {"PLUGIN_TYPE_VERSION", 20, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"PLUGIN_LIBRARY", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, "Library", + SKIP_OPEN_TABLE}, + {"PLUGIN_LIBRARY_VERSION", 20, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {"PLUGIN_AUTHOR", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {"PLUGIN_DESCRIPTION", 65535, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {"PLUGIN_LICENSE", 80, MYSQL_TYPE_STRING, 0, 1, "License", SKIP_OPEN_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; ST_FIELD_INFO files_fields_info[]= { - {"FILE_ID", 4, MYSQL_TYPE_LONGLONG, 0, 0, 0}, - {"FILE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"FILE_TYPE", 20, MYSQL_TYPE_STRING, 0, 0, 0}, - {"TABLESPACE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"TABLE_CATALOG", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"LOGFILE_GROUP_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"LOGFILE_GROUP_NUMBER", 4, MYSQL_TYPE_LONGLONG, 0, 1, 0}, - {"ENGINE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"FULLTEXT_KEYS", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"DELETED_ROWS", 4, MYSQL_TYPE_LONGLONG, 0, 1, 0}, - {"UPDATE_COUNT", 4, MYSQL_TYPE_LONGLONG, 0, 1, 0}, - {"FREE_EXTENTS", 4, MYSQL_TYPE_LONGLONG, 0, 1, 0}, - {"TOTAL_EXTENTS", 4, MYSQL_TYPE_LONGLONG, 0, 1, 0}, - {"EXTENT_SIZE", 4, MYSQL_TYPE_LONGLONG, 0, 0, 0}, + {"FILE_ID", 4, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE}, + {"FILE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {"FILE_TYPE", 20, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"TABLESPACE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, + SKIP_OPEN_TABLE}, + {"TABLE_CATALOG", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {"LOGFILE_GROUP_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, + SKIP_OPEN_TABLE}, + {"LOGFILE_GROUP_NUMBER", 4, MYSQL_TYPE_LONGLONG, 0, 1, 0, SKIP_OPEN_TABLE}, + {"ENGINE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"FULLTEXT_KEYS", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {"DELETED_ROWS", 4, MYSQL_TYPE_LONGLONG, 0, 1, 0, SKIP_OPEN_TABLE}, + {"UPDATE_COUNT", 4, MYSQL_TYPE_LONGLONG, 0, 1, 0, SKIP_OPEN_TABLE}, + {"FREE_EXTENTS", 4, MYSQL_TYPE_LONGLONG, 0, 1, 0, SKIP_OPEN_TABLE}, + {"TOTAL_EXTENTS", 4, MYSQL_TYPE_LONGLONG, 0, 1, 0, SKIP_OPEN_TABLE}, + {"EXTENT_SIZE", 4, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE}, {"INITIAL_SIZE", 21, MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0}, + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, SKIP_OPEN_TABLE}, {"MAXIMUM_SIZE", 21, MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0}, + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, SKIP_OPEN_TABLE}, {"AUTOEXTEND_SIZE", 21, MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0}, - {"CREATION_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, 0}, - {"LAST_UPDATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, 0}, - {"LAST_ACCESS_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, 0}, - {"RECOVER_TIME", 4, MYSQL_TYPE_LONGLONG, 0, 1, 0}, - {"TRANSACTION_COUNTER", 4, MYSQL_TYPE_LONGLONG, 0, 1, 0}, + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, SKIP_OPEN_TABLE}, + {"CREATION_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, 0, SKIP_OPEN_TABLE}, + {"LAST_UPDATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, 0, SKIP_OPEN_TABLE}, + {"LAST_ACCESS_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, 0, SKIP_OPEN_TABLE}, + {"RECOVER_TIME", 4, MYSQL_TYPE_LONGLONG, 0, 1, 0, SKIP_OPEN_TABLE}, + {"TRANSACTION_COUNTER", 4, MYSQL_TYPE_LONGLONG, 0, 1, 0, SKIP_OPEN_TABLE}, {"VERSION", 21 , MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Version"}, - {"ROW_FORMAT", 10, MYSQL_TYPE_STRING, 0, 1, "Row_format"}, + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Version", SKIP_OPEN_TABLE}, + {"ROW_FORMAT", 10, MYSQL_TYPE_STRING, 0, 1, "Row_format", SKIP_OPEN_TABLE}, {"TABLE_ROWS", 21 , MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Rows"}, + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Rows", SKIP_OPEN_TABLE}, {"AVG_ROW_LENGTH", 21 , MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Avg_row_length"}, + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Avg_row_length", SKIP_OPEN_TABLE}, {"DATA_LENGTH", 21 , MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Data_length"}, + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Data_length", SKIP_OPEN_TABLE}, {"MAX_DATA_LENGTH", 21 , MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Max_data_length"}, + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Max_data_length", SKIP_OPEN_TABLE}, {"INDEX_LENGTH", 21 , MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Index_length"}, + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Index_length", SKIP_OPEN_TABLE}, {"DATA_FREE", 21 , MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Data_free"}, - {"CREATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, "Create_time"}, - {"UPDATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, "Update_time"}, - {"CHECK_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, "Check_time"}, + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Data_free", SKIP_OPEN_TABLE}, + {"CREATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, "Create_time", SKIP_OPEN_TABLE}, + {"UPDATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, "Update_time", SKIP_OPEN_TABLE}, + {"CHECK_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, "Check_time", SKIP_OPEN_TABLE}, {"CHECKSUM", 21 , MYSQL_TYPE_LONGLONG, 0, - (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Checksum"}, - {"STATUS", 20, MYSQL_TYPE_STRING, 0, 0, 0}, - {"EXTRA", 255, MYSQL_TYPE_STRING, 0, 1, 0}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Checksum", SKIP_OPEN_TABLE}, + {"STATUS", 20, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"EXTRA", 255, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; void init_fill_schema_files_row(TABLE* table) @@ -5791,18 +6359,24 @@ void init_fill_schema_files_row(TABLE* table) ST_FIELD_INFO referential_constraints_fields_info[]= { - {"CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"UNIQUE_CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, - {"UNIQUE_CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"UNIQUE_CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"MATCH_OPTION", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"UPDATE_RULE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"DELETE_RULE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"REFERENCED_TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} + {"CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE}, + {"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, + OPEN_FULL_TABLE}, + {"CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, + OPEN_FULL_TABLE}, + {"UNIQUE_CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, + OPEN_FULL_TABLE}, + {"UNIQUE_CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, + OPEN_FULL_TABLE}, + {"UNIQUE_CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, + OPEN_FULL_TABLE}, + {"MATCH_OPTION", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"UPDATE_RULE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"DELETE_RULE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"REFERENCED_TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, + OPEN_FULL_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; @@ -5816,69 +6390,75 @@ ST_FIELD_INFO referential_constraints_fields_info[]= ST_SCHEMA_TABLE schema_tables[]= { {"CHARACTER_SETS", charsets_fields_info, create_schema_table, - fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0}, + fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0, 0}, {"COLLATIONS", collation_fields_info, create_schema_table, - fill_schema_collation, make_old_format, 0, -1, -1, 0}, + fill_schema_collation, make_old_format, 0, -1, -1, 0, 0}, {"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info, - create_schema_table, fill_schema_coll_charset_app, 0, 0, -1, -1, 0}, + create_schema_table, fill_schema_coll_charset_app, 0, 0, -1, -1, 0, 0}, {"COLUMNS", columns_fields_info, create_schema_table, - get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0}, + get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0, + OPEN_TABLE_FROM_SHARE|OPTIMIZE_I_S_TABLE}, {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table, - fill_schema_column_privileges, 0, 0, -1, -1, 0}, + fill_schema_column_privileges, 0, 0, -1, -1, 0, 0}, {"ENGINES", engines_fields_info, create_schema_table, - fill_schema_engines, make_old_format, 0, -1, -1, 0}, + fill_schema_engines, make_old_format, 0, -1, -1, 0, 0}, {"EVENTS", events_fields_info, create_schema_table, - Events::fill_schema_events, make_old_format, 0, -1, -1, 0}, + Events::fill_schema_events, make_old_format, 0, -1, -1, 0, 0}, {"FILES", files_fields_info, create_schema_table, - fill_schema_files, 0, 0, -1, -1, 0}, + fill_schema_files, 0, 0, -1, -1, 0, 0}, {"GLOBAL_STATUS", variables_fields_info, create_schema_table, - fill_status, make_old_format, 0, -1, -1, 0}, + fill_status, make_old_format, 0, -1, -1, 0, 0}, {"GLOBAL_VARIABLES", variables_fields_info, create_schema_table, - fill_variables, make_old_format, 0, -1, -1, 0}, + fill_variables, make_old_format, 0, -1, -1, 0, 0}, {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table, - get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0}, + get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0, + OPEN_TABLE_ONLY}, {"OPEN_TABLES", open_tables_fields_info, create_schema_table, - fill_open_tables, make_old_format, 0, -1, -1, 1}, + fill_open_tables, make_old_format, 0, -1, -1, 1, 0}, {"PARTITIONS", partitions_fields_info, create_schema_table, - get_all_tables, 0, get_schema_partitions_record, 1, 2, 0}, + get_all_tables, 0, get_schema_partitions_record, 1, 2, 0, OPEN_TABLE_ONLY}, {"PLUGINS", plugin_fields_info, create_schema_table, - fill_plugins, make_old_format, 0, -1, -1, 0}, + fill_plugins, make_old_format, 0, -1, -1, 0, 0}, {"PROCESSLIST", processlist_fields_info, create_schema_table, - fill_schema_processlist, make_old_format, 0, -1, -1, 0}, + fill_schema_processlist, make_old_format, 0, -1, -1, 0, 0}, {"REFERENTIAL_CONSTRAINTS", referential_constraints_fields_info, create_schema_table, get_all_tables, 0, get_referential_constraints_record, - 1, 9, 0}, + 1, 9, 0, OPEN_TABLE_ONLY}, {"ROUTINES", proc_fields_info, create_schema_table, - fill_schema_proc, make_proc_old_format, 0, -1, -1, 0}, + fill_schema_proc, make_proc_old_format, 0, -1, -1, 0, 0}, {"SCHEMATA", schema_fields_info, create_schema_table, - fill_schema_shemata, make_schemata_old_format, 0, 1, -1, 0}, + fill_schema_shemata, make_schemata_old_format, 0, 1, -1, 0, 0}, {"SCHEMA_PRIVILEGES", schema_privileges_fields_info, create_schema_table, - fill_schema_schema_privileges, 0, 0, -1, -1, 0}, + fill_schema_schema_privileges, 0, 0, -1, -1, 0, 0}, {"SESSION_STATUS", variables_fields_info, create_schema_table, - fill_status, make_old_format, 0, -1, -1, 0}, + fill_status, make_old_format, 0, -1, -1, 0, 0}, {"SESSION_VARIABLES", variables_fields_info, create_schema_table, - fill_variables, make_old_format, 0, -1, -1, 0}, + fill_variables, make_old_format, 0, -1, -1, 0, 0}, {"STATISTICS", stat_fields_info, create_schema_table, - get_all_tables, make_old_format, get_schema_stat_record, 1, 2, 0}, + get_all_tables, make_old_format, get_schema_stat_record, 1, 2, 0, + OPEN_TABLE_ONLY|OPEN_TABLE_FROM_SHARE|OPTIMIZE_I_S_TABLE}, {"STATUS", variables_fields_info, create_schema_table, fill_status, - make_old_format, 0, -1, -1, 1}, + make_old_format, 0, -1, -1, 1, 0}, {"TABLES", tables_fields_info, create_schema_table, - get_all_tables, make_old_format, get_schema_tables_record, 1, 2, 0}, + get_all_tables, make_old_format, get_schema_tables_record, 1, 2, 0, + OPTIMIZE_I_S_TABLE}, {"TABLE_CONSTRAINTS", table_constraints_fields_info, create_schema_table, - get_all_tables, 0, get_schema_constraints_record, 3, 4, 0}, + get_all_tables, 0, get_schema_constraints_record, 3, 4, 0, OPEN_TABLE_ONLY}, {"TABLE_NAMES", table_names_fields_info, create_schema_table, - get_all_tables, make_table_names_old_format, 0, 1, 2, 1}, + get_all_tables, make_table_names_old_format, 0, 1, 2, 1, 0}, {"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table, - fill_schema_table_privileges, 0, 0, -1, -1, 0}, + fill_schema_table_privileges, 0, 0, -1, -1, 0, 0}, {"TRIGGERS", triggers_fields_info, create_schema_table, - get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0}, + get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0, + OPEN_TABLE_ONLY}, {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table, - fill_schema_user_privileges, 0, 0, -1, -1, 0}, + fill_schema_user_privileges, 0, 0, -1, -1, 0, 0}, {"VARIABLES", variables_fields_info, create_schema_table, fill_variables, - make_old_format, 0, -1, -1, 1}, + make_old_format, 0, -1, -1, 1, 0}, {"VIEWS", view_fields_info, create_schema_table, - get_all_tables, 0, get_schema_views_record, 1, 2, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0} + get_all_tables, 0, get_schema_views_record, 1, 2, 0, + OPEN_VIEW_ONLY|OPTIMIZE_I_S_TABLE}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }; diff --git a/sql/sql_show.h b/sql/sql_show.h index 57004323ca9..d63217584b2 100644 --- a/sql/sql_show.h +++ b/sql/sql_show.h @@ -29,7 +29,7 @@ enum find_files_result { FIND_FILES_DIR }; -find_files_result find_files(THD *thd, List *files, const char *db, +find_files_result find_files(THD *thd, List *files, const char *db, const char *path, const char *wild, bool dir); int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, diff --git a/sql/table.cc b/sql/table.cc index 5e036abe6b1..9faf3c06575 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -572,7 +572,15 @@ int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags) { if (head[2] == FRM_VER || head[2] == FRM_VER+1 || (head[2] >= FRM_VER+3 && head[2] <= FRM_VER+4)) + { + /* Open view only */ + if (db_flags & OPEN_VIEW_ONLY) + { + error_given= 1; + goto err; + } table_type= 1; + } else { error= 6; // Unkown .frm version @@ -1612,9 +1620,17 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, outparam->keys_in_use_for_query.init(); /* Allocate handler */ - if (!(outparam->file= get_new_handler(share, &outparam->mem_root, - share->db_type()))) - goto err; + outparam->file= 0; + if (!(prgflag & OPEN_FRM_FILE_ONLY)) + { + if (!(outparam->file= get_new_handler(share, &outparam->mem_root, + share->db_type()))) + goto err; + } + else + { + DBUG_ASSERT(!db_stat); + } error= 4; outparam->reginfo.lock_type= TL_UNLOCK; diff --git a/sql/table.h b/sql/table.h index e46036f3ee9..ffe7350f250 100644 --- a/sql/table.h +++ b/sql/table.h @@ -719,6 +719,10 @@ enum enum_schema_tables #define MY_I_S_UNSIGNED 2 +#define SKIP_OPEN_TABLE 0 // do not open table +#define OPEN_FRM_ONLY 1 // open FRM file only +#define OPEN_FULL_TABLE 2 // open FRM,MYD, MYI files + typedef struct st_field_info { const char* field_name; @@ -727,6 +731,7 @@ typedef struct st_field_info int value; uint field_flags; // Field atributes(maybe_null, signed, unsigned etc.) const char* old_name; + uint open_method; } ST_FIELD_INFO; @@ -743,11 +748,11 @@ typedef struct st_schema_table int (*fill_table) (THD *thd, TABLE_LIST *tables, COND *cond); /* Handle fileds for old SHOW */ int (*old_format) (THD *thd, struct st_schema_table *schema_table); - int (*process_table) (THD *thd, TABLE_LIST *tables, - TABLE *table, bool res, const char *base_name, - const char *file_name); + int (*process_table) (THD *thd, TABLE_LIST *tables, TABLE *table, + bool res, LEX_STRING *db_name, LEX_STRING *table_name); int idx_field1, idx_field2; bool hidden; + uint i_s_requested_object; /* the object we need to open(TABLE | VIEW) */ } ST_SCHEMA_TABLE; @@ -1091,6 +1096,10 @@ struct TABLE_LIST */ uint8 trg_event_map; + uint i_s_requested_object; + bool has_db_lookup_value; + bool has_table_lookup_value; + uint table_open_method; enum enum_schema_table_state schema_table_state; void calc_md5(char *buffer); void set_underlying_merge(); diff --git a/sql/unireg.h b/sql/unireg.h index 6c26f30f116..232ea5e70e7 100644 --- a/sql/unireg.h +++ b/sql/unireg.h @@ -153,6 +153,11 @@ #define OPEN_VIEW 8192 /* Allow open on view */ #define OPEN_VIEW_NO_PARSE 16384 /* Open frm only if it's a view, but do not parse view itself */ +#define OPEN_FRM_FILE_ONLY 32768 /* Open frm file only */ +#define OPEN_TABLE_ONLY OPEN_FRM_FILE_ONLY*2 /* Open view only */ +#define OPEN_VIEW_ONLY OPEN_TABLE_ONLY*2 /* Open table only */ +#define OPEN_TABLE_FROM_SHARE OPEN_VIEW_ONLY*2 /* For I_S tables*/ +#define OPTIMIZE_I_S_TABLE OPEN_TABLE_FROM_SHARE*2 /* For I_S tables*/ #define SC_INFO_LENGTH 4 /* Form format constant */ #define TE_INFO_LENGTH 3 #define MTYP_NOEMPTY_BIT 128 From 720ea4041e1f650ab83b7ffdad529236bc2f9fae Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 01:14:27 +0300 Subject: [PATCH 31/74] Simplify logging code a bit (to make code smaller and faster) Moved duplicated code to inline function store_timestamp() Save thd->time_zone_used when logging to table as CSV internally cases it to be changed Added MYSQL_LOCK_IGNORE_FLUSH to log tables to avoid deadlock in case of flush tables. Mark log tables with TIMESTAMP_NO_AUTO_SET to avoid automatic timestamping Set TABLE->no_replicate on open client/mysqlbinlog.cc: Fixed several memory leaks (most in case of error situations) mysql-test/r/events_logs_tests.result: Made long_query_timeout smaller to ensure next query comes into log mysql-test/r/variables.result: Make it safe to run test with --log mysql-test/t/events_logs_tests.test: Made long_query_timeout smaller to ensure next query comes into log mysql-test/t/variables.test: Make it safe to run test with --log sql/field.cc: Moved duplicated code to inline function store_timestamp() sql/field.h: Moved duplicated code to inline function store_timestamp() sql/handler.cc: Reorder checks in likely order Simplify checks if we should do binary logging (no_replicate is set once and for all when table is opened) sql/log.cc: Save thd->time_zone_used as CVS internally cases it to be changed Use Field_timestamp->store_timestamp instead of automatic timestamps. This gives us correct timestamp even if thd->set_time() is not called (in case of connect) and we don't have to store thd->query_start_used anymore. sql/sql_base.cc: Removed not needed comment Moved LINT_INIT() to after declaration Renamed temporary variable to avoid compiler warning Added MYSQL_LOCK_IGNORE_FLUSH to log tables to avoid deadlock in case of flush tables. Mark log tables with TIMESTAMP_NO_AUTO_SET to avoid automatic timestamping sql/table.cc: Set TABLE->no_replicate on open --- client/mysqlbinlog.cc | 24 ++++++++++++++++- mysql-test/r/events_logs_tests.result | 2 +- mysql-test/r/variables.result | 1 + mysql-test/t/events_logs_tests.test | 2 +- mysql-test/t/variables.test | 1 + sql/field.cc | 31 +++------------------- sql/field.h | 11 ++++++++ sql/handler.cc | 9 +++---- sql/log.cc | 36 +++++++++++++++---------- sql/sql_base.cc | 38 ++++++++++++++------------- sql/table.cc | 2 ++ 11 files changed, 89 insertions(+), 68 deletions(-) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index d8c4f4bbcbf..bf385b2afad 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -1087,6 +1087,7 @@ static int check_master_version(MYSQL *mysql_arg, break; case '4': *description_event= new Format_description_log_event(3); + break; case '5': /* The server is soon going to send us its Format_description log @@ -1310,9 +1311,15 @@ static void check_header(IO_CACHE* file, pos= my_b_tell(file); my_b_seek(file, (my_off_t)0); if (my_b_read(file, header, sizeof(header))) + { + delete *description_event; die("Failed reading header; Probably an empty file"); + } if (memcmp(header, BINLOG_MAGIC, sizeof(header))) + { + delete *description_event; die("File is not a binary log file"); + } /* Imagine we are running with --start-position=1000. We still need @@ -1333,9 +1340,12 @@ static void check_header(IO_CACHE* file, if (my_b_read(file, buf, sizeof(buf))) { if (file->error) + { + delete *description_event; die("\ Could not read entry at offset %lu : Error in log format or read error", tmp_pos); + } /* Otherwise this is just EOF : this log currently contains 0-2 events. Maybe it's going to be filled in the next @@ -1371,13 +1381,19 @@ Could not read entry at offset %lu : Error in log format or read error", break; else if (buf[4] == FORMAT_DESCRIPTION_EVENT) /* This is 5.0 */ { + Format_description_log_event *new_description_event; my_b_seek(file, tmp_pos); /* seek back to event's start */ - if (!(*description_event= (Format_description_log_event*) + if (!(new_description_event= (Format_description_log_event*) Log_event::read_log_event(file, *description_event))) /* EOF can't be hit here normally, so it's a real error */ + { + delete *description_event; die("Could not read a Format_description_log_event event \ at offset %lu ; this could be a log format error or read error", tmp_pos); + } + delete *description_event; + *description_event= new_description_event; DBUG_PRINT("info",("Setting description_event")); } else if (buf[4] == ROTATE_EVENT) @@ -1386,8 +1402,11 @@ at offset %lu ; this could be a log format error or read error", my_b_seek(file, tmp_pos); /* seek back to event's start */ if (!(ev= Log_event::read_log_event(file, *description_event))) /* EOF can't be hit here normally, so it's a real error */ + { + delete *description_event; die("Could not read a Rotate_log_event event at offset %lu ;" " this could be a log format error or read error", tmp_pos); + } delete ev; } else @@ -1457,7 +1476,10 @@ static int dump_local_log_entries(PRINT_EVENT_INFO *print_event_info, } if (!glob_description_event || !glob_description_event->is_valid()) + { + delete glob_description_event; die("Invalid Format_description log event; could be out of memory"); + } if (!start_position && my_b_read(file, tmp_buff, BIN_LOG_HEADER_SIZE)) { diff --git a/mysql-test/r/events_logs_tests.result b/mysql-test/r/events_logs_tests.result index 0d49060f4a9..b69a02c9819 100644 --- a/mysql-test/r/events_logs_tests.result +++ b/mysql-test/r/events_logs_tests.result @@ -41,7 +41,7 @@ SELECT user_host, query_time, db, sql_text FROM mysql.slow_log; user_host query_time db sql_text "Set new values" SET GLOBAL long_query_time=4; -SET SESSION long_query_time=1; +SET SESSION long_query_time=0.5; "Check that logging is working" SELECT SLEEP(2); SLEEP(2) diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index e6d09306fcb..19b48efe6b4 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -523,6 +523,7 @@ set tmp_table_size=100; set tx_isolation="READ-COMMITTED"; set wait_timeout=100; set log_warnings=1; +set global log_warnings=1; select @@session.insert_id; @@session.insert_id 1 diff --git a/mysql-test/t/events_logs_tests.test b/mysql-test/t/events_logs_tests.test index 0c56f32beff..8617129b90c 100644 --- a/mysql-test/t/events_logs_tests.test +++ b/mysql-test/t/events_logs_tests.test @@ -58,7 +58,7 @@ TRUNCATE mysql.slow_log; SELECT user_host, query_time, db, sql_text FROM mysql.slow_log; --echo "Set new values" SET GLOBAL long_query_time=4; -SET SESSION long_query_time=1; +SET SESSION long_query_time=0.5; --echo "Check that logging is working" SELECT SLEEP(2); --replace_column 1 USER_HOST 2 SLEEPVAL diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 8f55d83c3de..81db143b518 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -330,6 +330,7 @@ set tmp_table_size=100; set tx_isolation="READ-COMMITTED"; set wait_timeout=100; set log_warnings=1; +set global log_warnings=1; # # Bugs: #20392: INSERT_ID session variable has weird value diff --git a/sql/field.cc b/sql/field.cc index 3213f84ee3e..dd0c862d05b 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4487,15 +4487,7 @@ int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs) error= 1; } } - -#ifdef WORDS_BIGENDIAN - if (table && table->s->db_low_byte_first) - { - int4store(ptr,tmp); - } - else -#endif - longstore(ptr,tmp); + store_timestamp(tmp); return error; } @@ -4555,19 +4547,10 @@ int Field_timestamp::store(longlong nr, bool unsigned_val) WARN_DATA_TRUNCATED, nr, MYSQL_TIMESTAMP_DATETIME, 1); -#ifdef WORDS_BIGENDIAN - if (table && table->s->db_low_byte_first) - { - int4store(ptr,timestamp); - } - else -#endif - longstore(ptr,(uint32) timestamp); - + store_timestamp(timestamp); return error; } - double Field_timestamp::val_real(void) { ASSERT_COLUMN_MARKED_FOR_READ; @@ -4762,14 +4745,7 @@ void Field_timestamp::set_time() THD *thd= table ? table->in_use : current_thd; long tmp= (long) thd->query_start(); set_notnull(); -#ifdef WORDS_BIGENDIAN - if (table && table->s->db_low_byte_first) - { - int4store(ptr,tmp); - } - else -#endif - longstore(ptr,tmp); + store_timestamp(tmp); } /**************************************************************************** @@ -9571,4 +9547,3 @@ Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code, field_name); } } - diff --git a/sql/field.h b/sql/field.h index 2782042e911..3ff5e5b9653 100644 --- a/sql/field.h +++ b/sql/field.h @@ -952,6 +952,17 @@ public: longget(tmp,ptr); return tmp; } + inline void store_timestamp(my_time_t timestamp) + { +#ifdef WORDS_BIGENDIAN + if (table && table->s->db_low_byte_first) + { + int4store(ptr,timestamp); + } + else +#endif + longstore(ptr,(uint32) timestamp); + } bool get_date(MYSQL_TIME *ltime,uint fuzzydate); bool get_time(MYSQL_TIME *ltime); timestamp_auto_set_type get_auto_set_type() const; diff --git a/sql/handler.cc b/sql/handler.cc index f06ad282efa..bab384e19fd 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3462,8 +3462,7 @@ namespace { if (table->s->cached_row_logging_check == -1) { int const check(table->s->tmp_table == NO_TMP_TABLE && - binlog_filter->db_ok(table->s->db.str) && - !table->no_replicate); + binlog_filter->db_ok(table->s->db.str)); table->s->cached_row_logging_check= check; } @@ -3471,9 +3470,9 @@ namespace { table->s->cached_row_logging_check == 1); return (thd->current_stmt_binlog_row_based && + table->s->cached_row_logging_check && (thd->options & OPTION_BIN_LOG) && - mysql_bin_log.is_open() && - table->s->cached_row_logging_check); + mysql_bin_log.is_open()); } } @@ -3551,7 +3550,7 @@ namespace const uchar *before_record, const uchar *after_record) { - if (table->file->ha_table_flags() & HA_HAS_OWN_BINLOGGING) + if (table->no_replicate) return 0; bool error= 0; THD *const thd= table->in_use; diff --git a/sql/log.cc b/sql/log.cc index c7e122462e6..1ddc8b57580 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -320,11 +320,15 @@ bool Log_to_csv_event_handler:: uint field_index; Silence_log_table_errors error_handler; Open_tables_state open_tables_backup; - Field_timestamp *field0; ulonglong save_thd_options; - bool save_query_start_used; + bool save_time_zone_used; + + /* + CSV uses TIME_to_timestamp() internally if table needs to be repaired + which will set thd->time_zone_used + */ + save_time_zone_used= thd->time_zone_used; - save_query_start_used= thd->query_start_used; // Because of field->set_time() save_thd_options= thd->options; thd->options&= ~OPTION_BIN_LOG; @@ -376,8 +380,7 @@ bool Log_to_csv_event_handler:: DBUG_ASSERT(table->field[0]->type() == MYSQL_TYPE_TIMESTAMP); - field0= (Field_timestamp*) (table->field[0]); - field0->set_time(); + ((Field_timestamp*) table->field[0])->store_timestamp(event_time); /* do a write */ if (table->field[1]->store(user_host, user_host_len, client_cs) || @@ -387,7 +390,8 @@ bool Log_to_csv_event_handler:: table->field[5]->store(sql_text, sql_text_len, client_cs)) goto err; - /* mark tables as not null */ + + /* mark all fields as not null */ table->field[1]->set_notnull(); table->field[2]->set_notnull(); table->field[3]->set_notnull(); @@ -426,7 +430,7 @@ err: close_performance_schema_table(thd, & open_tables_backup); thd->options= save_thd_options; - thd->query_start_used= save_query_start_used; + thd->time_zone_used= save_time_zone_used; return result; } @@ -473,8 +477,15 @@ bool Log_to_csv_event_handler:: bool need_rnd_end= FALSE; Open_tables_state open_tables_backup; CHARSET_INFO *client_cs= thd->variables.character_set_client; + bool save_time_zone_used; DBUG_ENTER("Log_to_csv_event_handler::log_slow"); + /* + CSV uses TIME_to_timestamp() internally if table needs to be repaired + which will set thd->time_zone_used + */ + save_time_zone_used= thd->time_zone_used; + bzero(& table_list, sizeof(TABLE_LIST)); table_list.alias= table_list.table_name= SLOW_LOG_NAME.str; table_list.table_name_length= SLOW_LOG_NAME.length; @@ -505,12 +516,9 @@ bool Log_to_csv_event_handler:: if (table->s->fields < 11) goto err; - /* - We do not set a value for table->field[0], as it will use - default value. - */ - - /* store the value */ + /* store the time and user values */ + DBUG_ASSERT(table->field[0]->type() == MYSQL_TYPE_TIMESTAMP); + ((Field_timestamp*) table->field[0])->store_timestamp(current_time); if (table->field[1]->store(user_host, user_host_len, client_cs)) goto err; @@ -611,7 +619,7 @@ err: } if (need_close) close_performance_schema_table(thd, & open_tables_backup); - + thd->time_zone_used= save_time_zone_used; DBUG_RETURN(result); } diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 28ce23ccd1a..f9466fbeacc 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1314,24 +1314,20 @@ void close_temporary_tables(THD *thd) { TABLE *table; TABLE *next; - /* - TODO: 5.1 maintains prev link in temporary_tables - double-linked list so we could fix it. But it is not necessary - at this time when the list is being destroyed - */ TABLE *prev_table; /* Assume thd->options has OPTION_QUOTE_SHOW_CREATE */ bool was_quote_show= TRUE; + LINT_INIT(next); if (!thd->temporary_tables) return; if (!mysql_bin_log.is_open() || thd->current_stmt_binlog_row_based) { - TABLE *next; - for (table= thd->temporary_tables; table; table= next) + TABLE *tmp_next; + for (table= thd->temporary_tables; table; table= tmp_next) { - next=table->next; + tmp_next= table->next; close_temporary(table, 1, 1); } thd->temporary_tables= 0; @@ -1344,13 +1340,12 @@ void close_temporary_tables(THD *thd) char buf[256]; String s_query= String(buf, sizeof(buf), system_charset_info); bool found_user_tables= FALSE; - LINT_INIT(next); memcpy(buf, stub, stub_len); /* - insertion sort of temp tables by pseudo_thread_id to build ordered list - of sublists of equal pseudo_thread_id + Insertion sort of temp tables by pseudo_thread_id to build ordered list + of sublists of equal pseudo_thread_id */ for (prev_table= thd->temporary_tables, table= prev_table->next; @@ -7731,23 +7726,30 @@ TABLE * open_performance_schema_table(THD *thd, TABLE_LIST *one_table, Open_tables_state *backup) { - uint flags= ( MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK - | MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY - | MYSQL_LOCK_PERF_SCHEMA ); - + uint flags= ( MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK | + MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY | + MYSQL_LOCK_IGNORE_FLUSH | + MYSQL_LOCK_PERF_SCHEMA); + TABLE *table; + /* Save value that is changed in mysql_lock_tables() */ + ulonglong save_utime_after_lock= thd->utime_after_lock; DBUG_ENTER("open_performance_schema_table"); thd->reset_n_backup_open_tables_state(backup); - TABLE *table= open_ltable(thd, one_table, one_table->lock_type, flags); - if (table) + if ((table= open_ltable(thd, one_table, one_table->lock_type, flags))) { DBUG_ASSERT(table->s->table_category == TABLE_CATEGORY_PERFORMANCE); /* Make sure all columns get assigned to a default value */ table->use_all_columns(); table->no_replicate= 1; + /* + Don't set automatic timestamps as we may want to use time of logging, + not from query start + */ + table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET; } - + thd->utime_after_lock= save_utime_after_lock; DBUG_RETURN(table); } diff --git a/sql/table.cc b/sql/table.cc index f52c81d7889..7be78e0be98 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1863,6 +1863,8 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, bzero((char*) bitmaps, bitmap_size*3); #endif + outparam->no_replicate= test(outparam->file->ha_table_flags() & + HA_HAS_OWN_BINLOGGING); thd->status_var.opened_tables++; DBUG_RETURN (0); From f338fd010a0a29e4c52c41b3ef4962f36be6a1d1 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 08:08:33 +0300 Subject: [PATCH 32/74] Removed compiler warning --- sql/log.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index 1ddc8b57580..588a06fa7a4 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -380,7 +380,8 @@ bool Log_to_csv_event_handler:: DBUG_ASSERT(table->field[0]->type() == MYSQL_TYPE_TIMESTAMP); - ((Field_timestamp*) table->field[0])->store_timestamp(event_time); + ((Field_timestamp*) table->field[0])->store_timestamp((my_time_t) + event_time); /* do a write */ if (table->field[1]->store(user_host, user_host_len, client_cs) || @@ -518,7 +519,8 @@ bool Log_to_csv_event_handler:: /* store the time and user values */ DBUG_ASSERT(table->field[0]->type() == MYSQL_TYPE_TIMESTAMP); - ((Field_timestamp*) table->field[0])->store_timestamp(current_time); + ((Field_timestamp*) table->field[0])->store_timestamp((my_time_t) + current_time); if (table->field[1]->store(user_host, user_host_len, client_cs)) goto err; From 966e113a2abd065ca6e33381da3de1510ec27774 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 11:50:17 +0400 Subject: [PATCH 33/74] Fix for BUG#30123: mysqldump is unable to work with old servers. New server (as of 5.1.21) provides new features: - SHOW CREATE TRIGGER; - character set information for SHOW TRIGGERS and SHOW CREATE EVENT | FUNCTION | PROCEDURE statements. Mysqldump uses these features to generate proper dump. The bug happened when new mysqldump was used to dump older servers. The problem was that 5.1.21 new features are not available, so mysqldump exited with error code or just crashed. The fix is to detect if mysqldump has ben run against older server and don't use new 5.1.21 functionality in this case. Certainly, the dump generated for the older server suffers from the character set problems fixed by BUG#16291 and the like. client/mysqldump.c: Don't use new server features if they are not available. --- client/mysqldump.c | 556 ++++++++++++++++++++++++++++++--------------- 1 file changed, 373 insertions(+), 183 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index cfdde285040..9cb1c640d7b 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1227,6 +1227,125 @@ static int switch_character_set_results(MYSQL *mysql, const char *cs_name) return mysql_real_query(mysql, query_buffer, query_length); } +/** + Rewrite CREATE TRIGGER statement, enclosing DEFINER clause in + version-specific comment. + + This function parses the CREATE TRIGGER statement and encloses + DEFINER-clause in version-specific comment: + input query: CREATE DEFINER=a@b TRIGGER ... + rewritten query: CREATE * / / *!50017 DEFINER=a@b * / / *!50003 TRIGGER ... + + @note This function will go away when WL#3995 is implemented. + + @param[in] trigger_def_str CREATE TRIGGER statement string. + @param[in] trigger_def_length length of the trigger_def_str. + + @return pointer to the new allocated query string. +*/ + +static char *cover_definer_clause_in_trigger(const char *trigger_def_str, + uint trigger_def_length) +{ + char *query_str= NULL; + char *definer_begin= my_case_str(trigger_def_str, trigger_def_length, + C_STRING_WITH_LEN(" DEFINER")); + char *definer_end; + + if (!definer_begin) + return NULL; + + definer_end= my_case_str(definer_begin, strlen(definer_begin), + C_STRING_WITH_LEN(" TRIGGER")); + + if (definer_end) + { + char *query_str_tail; + + /* + Allocate memory for new query string: original string + from SHOW statement and version-specific comments. + */ + query_str= alloc_query_str(trigger_def_length + 23); + + query_str_tail= strnmov(query_str, + trigger_def_str, + definer_begin - trigger_def_str); + + query_str_tail= strmov(query_str_tail, + "*/ /*!50017"); + + query_str_tail= strnmov(query_str_tail, + definer_begin, + definer_end - definer_begin); + + query_str_tail= strxmov(query_str_tail, + "*/ /*!50003", + definer_end, + NullS); + } + + return query_str; +} + +/** + Rewrite CREATE FUNCTION or CREATE PROCEDURE statement, enclosing DEFINER + clause in version-specific comment. + + This function parses the CREATE FUNCTION | PROCEDURE statement and + encloses DEFINER-clause in version-specific comment: + input query: CREATE DEFINER=a@b FUNCTION ... + rewritten query: CREATE * / / *!50020 DEFINER=a@b * / / *!50003 FUNCTION ... + + @note This function will go away when WL#3995 is implemented. + + @param[in] def_str CREATE FUNCTION|PROCEDURE statement string. + @param[in] def_length length of the def_str. + + @return pointer to the new allocated query string. +*/ + +static char *cover_definer_clause_in_sp(const char *def_str, + uint def_str_length) +{ + char *query_str= NULL; + char *definer_begin= my_case_str(def_str, def_str_length, + C_STRING_WITH_LEN(" DEFINER")); + char *definer_end; + + if (!definer_begin) + return NULL; + + definer_end= my_case_str(definer_begin, strlen(definer_begin), + C_STRING_WITH_LEN(" PROCEDURE")); + + if (!definer_end) + { + definer_end= my_case_str(definer_begin, strlen(definer_begin), + C_STRING_WITH_LEN(" FUNCTION")); + } + + if (definer_end) + { + char *query_str_tail; + + /* + Allocate memory for new query string: original string + from SHOW statement and version-specific comments. + */ + query_str= alloc_query_str(def_str_length + 23); + + query_str_tail= strnmov(query_str, def_str, definer_begin - def_str); + query_str_tail= strmov(query_str_tail, "*/ /*!50020"); + query_str_tail= strnmov(query_str_tail, definer_begin, + definer_end - definer_begin); + query_str_tail= strxmov(query_str_tail, "*/ /*!50003", + definer_end, NullS); + } + + return query_str; +} + /* Open a new .sql file to dump the table or view into @@ -1766,16 +1885,36 @@ static uint dump_events_for_db(char *db) fprintf(sql_file, "DELIMITER %s\n", delimiter); - if (switch_db_collation(sql_file, db_name_buff, delimiter, db_cl_name, - row[6], &db_cl_altered)) + if (mysql_num_fields(event_res) >= 7) { - DBUG_RETURN(1); - } + if (switch_db_collation(sql_file, db_name_buff, delimiter, + db_cl_name, row[6], &db_cl_altered)) + { + DBUG_RETURN(1); + } - switch_cs_variables(sql_file, delimiter, - row[4], /* character_set_client */ - row[4], /* character_set_results */ - row[5]); /* collation_connection */ + switch_cs_variables(sql_file, delimiter, + row[4], /* character_set_client */ + row[4], /* character_set_results */ + row[5]); /* collation_connection */ + } + else + { + /* + mysqldump is being run against the server, that does not + provide character set information in SHOW CREATE + statements. + + NOTE: the dump may be incorrect, since character set + information is required in order to restore event properly. + */ + + fprintf(sql_file, + "--\n" + "-- WARNING: old server version. " + "The following dump may be incomplete.\n" + "--\n"); + } switch_sql_mode(sql_file, delimiter, row[1]); @@ -1788,13 +1927,17 @@ static uint dump_events_for_db(char *db) restore_time_zone(sql_file, delimiter); restore_sql_mode(sql_file, delimiter); - restore_cs_variables(sql_file, delimiter); - if (db_cl_altered) + if (mysql_num_fields(event_res) >= 7) { - if (restore_db_collation(sql_file, db_name_buff, delimiter, - db_cl_name)) - DBUG_RETURN(1); + restore_cs_variables(sql_file, delimiter); + + if (db_cl_altered) + { + if (restore_db_collation(sql_file, db_name_buff, delimiter, + db_cl_name)) + DBUG_RETURN(1); + } } } } /* end of event printing */ @@ -1929,74 +2072,44 @@ static uint dump_routines_for_db(char *db) } else if (strlen(row[2])) { - char *query_str= NULL; - char *definer_begin; - if (opt_drop) fprintf(sql_file, "/*!50003 DROP %s IF EXISTS %s */;\n", routine_type[i], routine_name); - /* - Cover DEFINER-clause in version-specific comments. + char *query_str= cover_definer_clause_in_sp(row[2], strlen(row[2])); - TODO: this is definitely a BAD IDEA to parse SHOW CREATE output. - However, we can not use INFORMATION_SCHEMA instead: - 1. INFORMATION_SCHEMA provides data in UTF8, but here we - need data in the original character set; - 2. INFORMATION_SCHEMA does not provide information about - routine parameters now. - */ - - definer_begin= my_case_str(row[2], strlen(row[2]), - C_STRING_WITH_LEN(" DEFINER")); - - if (definer_begin) + if (mysql_num_fields(routine_res) >= 6) { - char *definer_end= my_case_str(definer_begin, - strlen(definer_begin), - C_STRING_WITH_LEN(" PROCEDURE")); - - if (!definer_end) + if (switch_db_collation(sql_file, db_name_buff, ";", + db_cl_name, row[5], &db_cl_altered)) { - definer_end= my_case_str(definer_begin, strlen(definer_begin), - C_STRING_WITH_LEN(" FUNCTION")); + DBUG_RETURN(1); } - if (definer_end) - { - char *query_str_tail; - - /* - Allocate memory for new query string: original string - from SHOW statement and version-specific comments. - */ - query_str= alloc_query_str(strlen(row[2]) + 23); - - query_str_tail= strnmov(query_str, row[2], - definer_begin - row[2]); - query_str_tail= strmov(query_str_tail, "*/ /*!50020"); - query_str_tail= strnmov(query_str_tail, definer_begin, - definer_end - definer_begin); - query_str_tail= strxmov(query_str_tail, "*/ /*!50003", - definer_end, NullS); - } + switch_cs_variables(sql_file, ";", + row[3], /* character_set_client */ + row[3], /* character_set_results */ + row[4]); /* collation_connection */ } - - /* - we need to change sql_mode only for the CREATE - PROCEDURE/FUNCTION otherwise we may need to re-quote routine_name - */ - - if (switch_db_collation(sql_file, db_name_buff, ";", - db_cl_name, row[5], &db_cl_altered)) + else { - DBUG_RETURN(1); + /* + mysqldump is being run against the server, that does not + provide character set information in SHOW CREATE + statements. + + NOTE: the dump may be incorrect, since character set + information is required in order to restore stored + procedure/function properly. + */ + + fprintf(sql_file, + "--\n" + "-- WARNING: old server version. " + "The following dump may be incomplete.\n" + "--\n"); } - switch_cs_variables(sql_file, ";", - row[3], /* character_set_client */ - row[3], /* character_set_results */ - row[4]); /* collation_connection */ switch_sql_mode(sql_file, ";", row[1]); @@ -2007,12 +2120,16 @@ static uint dump_routines_for_db(char *db) (const char *) (query_str != NULL ? query_str : row[2])); restore_sql_mode(sql_file, ";"); - restore_cs_variables(sql_file, ";"); - if (db_cl_altered) + if (mysql_num_fields(routine_res) > 3) { - if (restore_db_collation(sql_file, db_name_buff, ";", db_cl_name)) - DBUG_RETURN(1); + restore_cs_variables(sql_file, ";"); + + if (db_cl_altered) + { + if (restore_db_collation(sql_file, db_name_buff, ";", db_cl_name)) + DBUG_RETURN(1); + } } my_free(query_str, MYF(MY_ALLOW_ZERO_PTR)); @@ -2551,153 +2668,212 @@ continue_xml: DBUG_RETURN((uint) num_fields); } /* get_table_structure */ +static void dump_trigger_old(MYSQL_RES *show_triggers_rs, + MYSQL_ROW *show_trigger_row, + const char *table_name) +{ + FILE *sql_file= md_result_file; -/* + char quoted_table_name_buf[NAME_LEN * 2 + 3]; + char *quoted_table_name= quote_name(table_name, quoted_table_name_buf, 1); - dump_triggers_for_table + char name_buff[NAME_LEN * 4 + 3]; - Dumps the triggers given a table/db name. This should be called after - the tables have been dumped in case a trigger depends on the existence - of a table + DBUG_ENTER("dump_trigger_old"); + fprintf(sql_file, + "--\n" + "-- WARNING: old server version. " + "The following dump may be incomplete.\n" + "--\n"); + + if (opt_compact) + fprintf(sql_file, "/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;\n"); + + fprintf(sql_file, + "DELIMITER ;;\n" + "/*!50003 SET SESSION SQL_MODE=\"%s\" */;;\n" + "/*!50003 CREATE */ ", + (*show_trigger_row)[6]); + + if (mysql_num_fields(show_triggers_rs) > 7) + { + /* + mysqldump can be run against the server, that does not support + definer in triggers (there is no DEFINER column in SHOW TRIGGERS + output). So, we should check if we have this column before + accessing it. + */ + + uint user_name_len; + char user_name_str[USERNAME_LENGTH + 1]; + char quoted_user_name_str[USERNAME_LENGTH * 2 + 3]; + uint host_name_len; + char host_name_str[HOSTNAME_LENGTH + 1]; + char quoted_host_name_str[HOSTNAME_LENGTH * 2 + 3]; + + parse_user((*show_trigger_row)[7], + strlen((*show_trigger_row)[7]), + user_name_str, &user_name_len, + host_name_str, &host_name_len); + + fprintf(sql_file, + "/*!50017 DEFINER=%s@%s */ ", + quote_name(user_name_str, quoted_user_name_str, FALSE), + quote_name(host_name_str, quoted_host_name_str, FALSE)); + } + + fprintf(sql_file, + "/*!50003 TRIGGER %s %s %s ON %s FOR EACH ROW%s%s */;;\n" + "DELIMITER ;\n", + quote_name((*show_trigger_row)[0], name_buff, 0), /* Trigger */ + (*show_trigger_row)[4], /* Timing */ + (*show_trigger_row)[1], /* Event */ + quoted_table_name, + (strchr(" \t\n\r", *((*show_trigger_row)[3]))) ? "" : " ", + (*show_trigger_row)[3] /* Statement */); + + if (opt_compact) + fprintf(sql_file, "/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;\n"); + + DBUG_VOID_RETURN; +} + +static int dump_trigger(MYSQL_RES *show_create_trigger_rs, + const char *db_name, + const char *db_cl_name) +{ + FILE *sql_file= md_result_file; + MYSQL_ROW row; + int db_cl_altered; + + DBUG_ENTER("dump_trigger"); + + while ((row= mysql_fetch_row(show_create_trigger_rs))) + { + char *query_str= cover_definer_clause_in_trigger(row[2], strlen(row[2])); + + + if (switch_db_collation(sql_file, db_name, ";", + db_cl_name, row[5], &db_cl_altered)) + DBUG_RETURN(TRUE); + + switch_cs_variables(sql_file, ";", + row[3], /* character_set_client */ + row[3], /* character_set_results */ + row[4]); /* collation_connection */ + + switch_sql_mode(sql_file, ";", row[1]); + + fprintf(sql_file, + "DELIMITER ;;\n" + "/*!50003 %s */;;\n" + "DELIMITER ;\n", + (const char *) (query_str != NULL ? query_str : row[2])); + + restore_sql_mode(sql_file, ";"); + restore_cs_variables(sql_file, ";"); + + if (db_cl_altered) + { + if (restore_db_collation(sql_file, db_name, ";", db_cl_name)) + DBUG_RETURN(TRUE); + } + + my_free(query_str, MYF(MY_ALLOW_ZERO_PTR)); + } + + DBUG_RETURN(FALSE); +} + +/** + Dump the triggers for a given table. + + This should be called after the tables have been dumped in case a trigger + depends on the existence of a table. + + @param[in] table_name + @param[in] db_name + + @return Error status. + @retval TRUE error has occurred. + @retval FALSE operation succeed. */ -static void dump_triggers_for_table(char *table, char *db_name) +static int dump_triggers_for_table(char *table_name, char *db_name) { - char *result_table; - char name_buff[NAME_LEN*4+3], table_buff[NAME_LEN*2+3]; - char query_buff[QUERY_LENGTH]; - uint old_opt_compatible_mode=opt_compatible_mode; FILE *sql_file= md_result_file; - MYSQL_RES *result; + char name_buff[NAME_LEN*4+3]; + char query_buff[QUERY_LENGTH]; + uint old_opt_compatible_mode= opt_compatible_mode; + MYSQL_RES *show_triggers_rs; MYSQL_ROW row; char db_cl_name[MY_CS_NAME_SIZE]; - int db_cl_altered; DBUG_ENTER("dump_triggers_for_table"); - DBUG_PRINT("enter", ("db: %s, table: %s", db_name, table)); + DBUG_PRINT("enter", ("db: %s, table_name: %s", db_name, table_name)); /* Do not use ANSI_QUOTES on triggers in dump */ opt_compatible_mode&= ~MASK_ANSI_QUOTES; - result_table= quote_name(table, table_buff, 1); - - my_snprintf(query_buff, sizeof(query_buff), - "SHOW TRIGGERS LIKE %s", - quote_for_like(table, name_buff)); - - if (mysql_query_with_error_report(mysql, &result, query_buff)) - { - if (path) - my_fclose(sql_file, MYF(MY_WME)); - DBUG_VOID_RETURN; - } /* Get database collation. */ if (fetch_db_collation(db_name, db_cl_name, sizeof (db_cl_name))) - DBUG_VOID_RETURN; + DBUG_RETURN(TRUE); - if (switch_character_set_results(mysql, "binary")) - DBUG_VOID_RETURN; + /* Get list of triggers. */ + + my_snprintf(query_buff, sizeof(query_buff), + "SHOW TRIGGERS LIKE %s", + quote_for_like(table_name, name_buff)); + + if (mysql_query_with_error_report(mysql, &show_triggers_rs, query_buff)) + DBUG_RETURN(TRUE); + + if (mysql_num_rows(show_triggers_rs)) + fprintf(sql_file, "\n"); /* Dump triggers. */ - while ((row= mysql_fetch_row(result))) + while ((row= mysql_fetch_row(show_triggers_rs))) { - MYSQL_RES *res2; my_snprintf(query_buff, sizeof (query_buff), "SHOW CREATE TRIGGER %s", quote_name(row[0], name_buff, TRUE)); - if (mysql_query_with_error_report(mysql, &res2, query_buff)) + if (mysql_query(mysql, query_buff)) { - if (path) - my_fclose(sql_file, MYF(MY_WME)); - maybe_exit(EX_MYSQLERR); - DBUG_VOID_RETURN; - } - - while ((row= mysql_fetch_row(res2))) - { - char *query_str= NULL; - char *definer_begin; - /* - Cover DEFINER-clause in version-specific comments. + mysqldump is being run against old server, that does not support + SHOW CREATE TRIGGER statement. We should use SHOW TRIGGERS output. - TODO: this is definitely a BAD IDEA to parse SHOW CREATE output. - However, we can not use INFORMATION_SCHEMA instead: - 1. INFORMATION_SCHEMA provides data in UTF8, but here we - need data in the original character set; - 2. INFORMATION_SCHEMA does not provide information about - routine parameters now. + NOTE: the dump may be incorrect, as old SHOW TRIGGERS does not + provide all the necessary information to restore trigger properly. */ - definer_begin= my_case_str(row[2], strlen(row[2]), - C_STRING_WITH_LEN(" DEFINER")); - - if (definer_begin) - { - char *definer_end= my_case_str(definer_begin, strlen(definer_begin), - C_STRING_WITH_LEN(" TRIGGER")); - - if (definer_end) - { - char *query_str_tail; - - /* - Allocate memory for new query string: original string - from SHOW statement and version-specific comments. - */ - query_str= alloc_query_str(strlen(row[2]) + 23); - - query_str_tail= strnmov(query_str, row[2], - definer_begin - row[2]); - query_str_tail= strmov(query_str_tail, "*/ /*!50017"); - query_str_tail= strnmov(query_str_tail, definer_begin, - definer_end - definer_begin); - query_str_tail= strxmov(query_str_tail, "*/ /*!50003", - definer_end, NullS); - } - } - - if (switch_db_collation(sql_file, db_name, ";", - db_cl_name, row[5], &db_cl_altered)) - DBUG_VOID_RETURN; - - switch_cs_variables(sql_file, ";", - row[3], /* character_set_client */ - row[3], /* character_set_results */ - row[4]); /* collation_connection */ - - switch_sql_mode(sql_file, ";", row[1]); - - fprintf(sql_file, - "DELIMITER ;;\n" - "/*!50003 %s */;;\n" - "DELIMITER ;\n", - (const char *) (query_str != NULL ? query_str : row[2])); - - restore_sql_mode(sql_file, ";"); - restore_cs_variables(sql_file, ";"); - - if (db_cl_altered) - { - if (restore_db_collation(sql_file, db_name, ";", db_cl_name)) - DBUG_VOID_RETURN; - } - - my_free(query_str, MYF(MY_ALLOW_ZERO_PTR)); + dump_trigger_old(show_triggers_rs, &row, table_name); } - mysql_free_result(res2); + else + { + MYSQL_RES *show_create_trigger_rs= mysql_store_result(mysql); + + if (!show_create_trigger_rs || + dump_trigger(show_create_trigger_rs, db_name, db_cl_name)) + { + DBUG_RETURN(TRUE); + } + + mysql_free_result(show_create_trigger_rs); + } + } - mysql_free_result(result); + if (mysql_num_rows(show_triggers_rs)) + fprintf(sql_file, "\n"); - if (switch_character_set_results(mysql, default_charset)) - DBUG_VOID_RETURN; + mysql_free_result(show_triggers_rs); /* make sure to set back opt_compatible mode to @@ -2705,7 +2881,7 @@ static void dump_triggers_for_table(char *table, char *db_name) */ opt_compatible_mode=old_opt_compatible_mode; - DBUG_VOID_RETURN; + DBUG_RETURN(FALSE); } static void add_load_option(DYNAMIC_STRING *str, const char *option, @@ -3775,7 +3951,14 @@ static int dump_all_tables_in_db(char *database) order_by= 0; if (opt_dump_triggers && ! opt_xml && mysql_get_server_version(mysql) >= 50009) - dump_triggers_for_table(table, database); + { + if (dump_triggers_for_table(table, database)) + { + if (path) + my_fclose(md_result_file, MYF(MY_WME)); + maybe_exit(EX_MYSQLERR); + } + } } } if (opt_events && !opt_xml && @@ -3985,7 +4168,14 @@ static int dump_selected_tables(char *db, char **table_names, int tables) dump_table(*pos, db); if (opt_dump_triggers && mysql_get_server_version(mysql) >= 50009) - dump_triggers_for_table(*pos, db); + { + if (dump_triggers_for_table(*pos, db)) + { + if (path) + my_fclose(md_result_file, MYF(MY_WME)); + maybe_exit(EX_MYSQLERR); + } + } } /* Dump each selected view */ From 46362c4b2ec8a9dbf0f86083bfeb13ab986db12d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 09:52:55 +0200 Subject: [PATCH 34/74] README.txt-1: Rename: mysql-test/suite/funcs_1/README.txt -> mysql-test/suite/funcs_1/README.txt-1 README.txt: Rename: BitKeeper/deleted/.del-README.txt -> mysql-test/suite/funcs_1/README.txt README.txt-old-delete: Rename: mysql-test/suite/funcs_1/README.txt -> mysql-test/suite/funcs_1/README.txt-old-delete README.txt: Rename: mysql-test/suite/funcs_1/README.txt-1 -> mysql-test/suite/funcs_1/README.txt .del-README.txt-old-delete: Delete: mysql-test/suite/funcs_1/README.txt-old-delete BitKeeper/deleted/.del-README.txt-old-delete: Delete: mysql-test/suite/funcs_1/README.txt-old-delete mysql-test/suite/funcs_1/README.txt: Rename: mysql-test/suite/funcs_1/README.txt-1 -> mysql-test/suite/funcs_1/README.txt From 6930e7dedfec2723ef6b9e38f974e3d1123d022f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 13:07:37 +0500 Subject: [PATCH 35/74] Many files: Post-merge fix. mysql-test/r/binlog_unsafe.result: Post-merge fix. mysql-test/r/events_bugs.result: Post-merge fix. mysql-test/r/events_trans.result: Post-merge fix. mysql-test/r/sp.result: Post-merge fix. mysql-test/r/sp_gis.result: Post-merge fix. mysql-test/r/xml.result: Post-merge fix. --- mysql-test/r/binlog_unsafe.result | 4 ++-- mysql-test/r/events_bugs.result | 16 ++++++++-------- mysql-test/r/events_trans.result | 2 +- mysql-test/r/sp.result | 8 ++++---- mysql-test/r/sp_gis.result | 4 ++-- mysql-test/r/xml.result | 18 +++++++++--------- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/mysql-test/r/binlog_unsafe.result b/mysql-test/r/binlog_unsafe.result index 624c7feec1f..fb89631f30b 100644 --- a/mysql-test/r/binlog_unsafe.result +++ b/mysql-test/r/binlog_unsafe.result @@ -5,9 +5,9 @@ CREATE TABLE t3 (b INT AUTO_INCREMENT PRIMARY KEY); CREATE VIEW v1(a,b) AS SELECT a,b FROM t2,t3; INSERT INTO t1 SELECT UUID(); Warnings: -Warning 1589 Statement is not safe to log in statement format. +Warning 1590 Statement is not safe to log in statement format. SHOW WARNINGS; Level Warning -Code 1589 +Code 1590 Message Statement is not safe to log in statement format. DROP TABLE t1,t2,t3; diff --git a/mysql-test/r/events_bugs.result b/mysql-test/r/events_bugs.result index 557c8e0b477..6e3b1404048 100644 --- a/mysql-test/r/events_bugs.result +++ b/mysql-test/r/events_bugs.result @@ -31,7 +31,7 @@ create event e_55 on schedule at 10000101000000 do drop table t; ERROR HY000: Incorrect AT value: '10000101000000' create event e_55 on schedule at 20000101000000 do drop table t; Warnings: -Note 1585 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. +Note 1586 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. show events; Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation create event e_55 on schedule at 20200101000000 starts 10000101000000 do drop table t; @@ -457,22 +457,22 @@ CREATE EVENT e4 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' DO SELECT 1; Warnings: -Note 1585 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. +Note 1586 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. CREATE EVENT e4 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' ENDS '1999-01-02 00:00:00' DISABLE DO SELECT 1; Warnings: -Note 1585 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. +Note 1586 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. CREATE EVENT e4 ON SCHEDULE AT '1999-01-01 00:00:00' DO SELECT 1; Warnings: -Note 1585 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. +Note 1586 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. CREATE EVENT e4 ON SCHEDULE AT '1999-01-01 00:00:00' DISABLE DO SELECT 1; Warnings: -Note 1585 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. +Note 1586 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. SHOW EVENTS; Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation events_test e1 root@localhost +05:00 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci @@ -482,19 +482,19 @@ The following should succeed giving a warning. ALTER EVENT e1 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' ENDS '1999-01-02 00:00:00' ON COMPLETION PRESERVE; Warnings: -Note 1541 Event execution time is in the past. Event has been disabled +Note 1542 Event execution time is in the past. Event has been disabled CREATE EVENT e4 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' ENDS '1999-01-02 00:00:00' ON COMPLETION PRESERVE DO SELECT 1; Warnings: -Note 1541 Event execution time is in the past. Event has been disabled +Note 1542 Event execution time is in the past. Event has been disabled CREATE EVENT e5 ON SCHEDULE AT '1999-01-01 00:00:00' ON COMPLETION PRESERVE DO SELECT 1; Warnings: -Note 1541 Event execution time is in the past. Event has been disabled +Note 1542 Event execution time is in the past. Event has been disabled The following should succeed without warnings. ALTER EVENT e2 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00'; ALTER EVENT e3 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' diff --git a/mysql-test/r/events_trans.result b/mysql-test/r/events_trans.result index 1f87bcea68e..dce08d3b9f9 100644 --- a/mysql-test/r/events_trans.result +++ b/mysql-test/r/events_trans.result @@ -63,7 +63,7 @@ begin work; insert into t1 (a) values ("OK: create event if not exists"); create event if not exists e1 on schedule every 2 day do select 2; Warnings: -Note 1534 Event 'e1' already exists +Note 1535 Event 'e1' already exists rollback work; select * from t1; a diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index ebdab4a3f89..163bbb4aab4 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -5670,7 +5670,7 @@ drop function if exists pi; create function pi() returns varchar(50) return "pie, my favorite desert."; Warnings: -Note 1582 This function 'pi' has the same name as a native function +Note 1583 This function 'pi' has the same name as a native function SET @save_sql_mode=@@sql_mode; SET SQL_MODE='IGNORE_SPACE'; select pi(), pi (); @@ -5719,15 +5719,15 @@ use test; create function `database`() returns varchar(50) return "Stored function database"; Warnings: -Note 1582 This function 'database' has the same name as a native function +Note 1583 This function 'database' has the same name as a native function create function `current_user`() returns varchar(50) return "Stored function current_user"; Warnings: -Note 1582 This function 'current_user' has the same name as a native function +Note 1583 This function 'current_user' has the same name as a native function create function md5(x varchar(50)) returns varchar(50) return "Stored function md5"; Warnings: -Note 1582 This function 'md5' has the same name as a native function +Note 1583 This function 'md5' has the same name as a native function SET SQL_MODE='IGNORE_SPACE'; select database(), database (); database() database () diff --git a/mysql-test/r/sp_gis.result b/mysql-test/r/sp_gis.result index b4fe0872d64..c640e5c46f2 100644 --- a/mysql-test/r/sp_gis.result +++ b/mysql-test/r/sp_gis.result @@ -7,11 +7,11 @@ return 1; create function x() returns int return 2; Warnings: -Note 1582 This function 'x' has the same name as a native function +Note 1583 This function 'x' has the same name as a native function create function y() returns int return 3; Warnings: -Note 1582 This function 'y' has the same name as a native function +Note 1583 This function 'y' has the same name as a native function select a(); a() 1 diff --git a/mysql-test/r/xml.result b/mysql-test/r/xml.result index 95ad19a886f..aac7c4e850a 100644 --- a/mysql-test/r/xml.result +++ b/mysql-test/r/xml.result @@ -647,32 +647,32 @@ select extractValue('a','/a'); extractValue('a','/a') NULL Warnings: -Warning 1522 Incorrect XML value: 'parse error at line 1 pos 5: unexpected END-OF-INPUT' +Warning 1523 Incorrect XML value: 'parse error at line 1 pos 5: unexpected END-OF-INPUT' select extractValue('a<','/a'); extractValue('a<','/a') NULL Warnings: -Warning 1522 Incorrect XML value: 'parse error at line 1 pos 6: END-OF-INPUT unexpected (ident or '/' wanted)' +Warning 1523 Incorrect XML value: 'parse error at line 1 pos 6: END-OF-INPUT unexpected (ident or '/' wanted)' select extractValue('aaaa' wanted)' +Warning 1523 Incorrect XML value: 'parse error at line 1 pos 8: END-OF-INPUT unexpected ('>' wanted)' select extractValue('a','/a'); extractValue('a','/a') NULL Warnings: -Warning 1522 Incorrect XML value: 'parse error at line 1 pos 12: '' unexpected (END-OF-INPUT wanted)' +Warning 1523 Incorrect XML value: 'parse error at line 1 pos 12: '' unexpected (END-OF-INPUT wanted)' select extractValue('a','/a'); extractValue('a','/a') NULL Warnings: -Warning 1522 Incorrect XML value: 'parse error at line 1 pos 7: '>' unexpected (ident or string wanted)' +Warning 1523 Incorrect XML value: 'parse error at line 1 pos 7: '>' unexpected (ident or string wanted)' select extractValue('1','position()'); ERROR HY000: XPATH syntax error: '' select extractValue('1','last()'); @@ -723,17 +723,17 @@ select extractValue('<01>10:39:15<02>140','//* extractValue('<01>10:39:15<02>140','//*') NULL Warnings: -Warning 1522 Incorrect XML value: 'parse error at line 1 pos 13: unknown token unexpected (ident or '/' wanted)' +Warning 1523 Incorrect XML value: 'parse error at line 1 pos 13: unknown token unexpected (ident or '/' wanted)' select extractValue('<.>test','//*'); extractValue('<.>test','//*') NULL Warnings: -Warning 1522 Incorrect XML value: 'parse error at line 1 pos 2: unknown token unexpected (ident or '/' wanted)' +Warning 1523 Incorrect XML value: 'parse error at line 1 pos 2: unknown token unexpected (ident or '/' wanted)' select extractValue('<->test','//*'); extractValue('<->test','//*') NULL Warnings: -Warning 1522 Incorrect XML value: 'parse error at line 1 pos 2: unknown token unexpected (ident or '/' wanted)' +Warning 1523 Incorrect XML value: 'parse error at line 1 pos 2: unknown token unexpected (ident or '/' wanted)' select extractValue('<:>test','//*'); extractValue('<:>test','//*') test From c28ca5e2e2c2917536fd2e0b857d67aad114004d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 11:06:53 +0200 Subject: [PATCH 36/74] Re-apply fixes originally made by Kent, they got lost because of a merge conflict with the CMakeLists.txt dependency fix (numer 29982 in our bugs DB). These changes are for bug#30118. client/CMakeLists.txt: Manual merge from 5.0 (bug#30118) libmysql/CMakeLists.txt: Manual merge from 5.0 (bug#30118) mysys/CMakeLists.txt: Manual merge from 5.0 (bug#30118) sql/CMakeLists.txt: Added missing '${MYSQLD_EXE_SUFFIX}' to "mysqld" targets new in 5.1 zlib/CMakeLists.txt: Manual merge from 5.0 (bug#30118) --- client/CMakeLists.txt | 127 ++++++++-------------------------------- libmysql/CMakeLists.txt | 56 ++++++++++++++---- mysys/CMakeLists.txt | 21 ++++--- sql/CMakeLists.txt | 8 +-- zlib/CMakeLists.txt | 3 +- 5 files changed, 87 insertions(+), 128 deletions(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 8a670cf4c4b..0b37f4d3d1c 100755 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -14,130 +14,54 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake") +# We use the "mysqlclient_notls" library here just as safety, in case +# any of the clients here would go beond the client API and access the +# Thread Local Storage directly. + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") -# The old Windows build method used renamed (.cc -> .cpp) source files, fails -# in #include in mysqlbinlog.cc. So disable that using the USING_CMAKE define. -ADD_DEFINITIONS(-DUSING_CMAKE -DYASSL_PREFIX -DUSE_TLS) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include - ${CMAKE_SOURCE_DIR}/zlib +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/extra/yassl/include - ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/include - ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL ${CMAKE_SOURCE_DIR}/libmysql ${CMAKE_SOURCE_DIR}/regex ${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/strings) -SET(YASSL_SOURCES ../extra/yassl/src/buffer.cpp - ../extra/yassl/src/cert_wrapper.cpp - ../extra/yassl/src/crypto_wrapper.cpp - ../extra/yassl/src/handshake.cpp - ../extra/yassl/src/lock.cpp - ../extra/yassl/src/log.cpp - ../extra/yassl/src/socket_wrapper.cpp - ../extra/yassl/src/ssl.cpp - ../extra/yassl/src/timer.cpp - ../extra/yassl/src/yassl_error.cpp - ../extra/yassl/src/yassl_imp.cpp - ../extra/yassl/src/yassl_int.cpp) - -SET(TAOCRYPT_SOURCES ../extra/yassl/taocrypt/src/aes.cpp - ../extra/yassl/taocrypt/src/aestables.cpp - ../extra/yassl/taocrypt/src/algebra.cpp - ../extra/yassl/taocrypt/src/arc4.cpp - ../extra/yassl/taocrypt/src/asn.cpp - ../extra/yassl/taocrypt/src/coding.cpp - ../extra/yassl/taocrypt/src/des.cpp - ../extra/yassl/taocrypt/src/dh.cpp - ../extra/yassl/taocrypt/src/dsa.cpp - ../extra/yassl/taocrypt/src/file.cpp - ../extra/yassl/taocrypt/src/hash.cpp - ../extra/yassl/taocrypt/src/integer.cpp - ../extra/yassl/taocrypt/src/md2.cpp - ../extra/yassl/taocrypt/src/md4.cpp - ../extra/yassl/taocrypt/src/md5.cpp - ../extra/yassl/taocrypt/src/misc.cpp - ../extra/yassl/taocrypt/src/random.cpp - ../extra/yassl/taocrypt/src/ripemd.cpp - ../extra/yassl/taocrypt/src/rsa.cpp - ../extra/yassl/taocrypt/src/sha.cpp) +ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc ../mysys/my_conio.c) +TARGET_LINK_LIBRARIES(mysql mysqlclient_notls wsock32) - -ADD_LIBRARY(mysqlclient ../mysys/array.c ../strings/bchange.c ../strings/bmove.c - ../strings/bmove_upp.c ../mysys/charset-def.c ../mysys/charset.c - ../sql-common/client.c ../strings/ctype-big5.c ../strings/ctype-bin.c - ../strings/ctype-cp932.c ../strings/ctype-czech.c ../strings/ctype-euc_kr.c - ../strings/ctype-eucjpms.c ../strings/ctype-extra.c ../strings/ctype-gb2312.c - ../strings/ctype-gbk.c ../strings/ctype-latin1.c ../strings/ctype-mb.c - ../strings/ctype-simple.c ../strings/ctype-sjis.c ../strings/ctype-tis620.c - ../strings/ctype-uca.c ../strings/ctype-ucs2.c ../strings/ctype-ujis.c - ../strings/ctype-utf8.c ../strings/ctype-win1250ch.c ../strings/ctype.c - ../mysys/default.c ../libmysql/errmsg.c ../mysys/errors.c - ../libmysql/get_password.c ../strings/int2str.c ../strings/is_prefix.c - ../libmysql/libmysql.c ../mysys/list.c ../strings/llstr.c - ../strings/longlong2str.c ../libmysql/manager.c ../mysys/mf_cache.c - ../mysys/mf_dirname.c ../mysys/mf_fn_ext.c ../mysys/mf_format.c - ../mysys/mf_iocache.c ../mysys/mf_iocache2.c ../mysys/mf_loadpath.c - ../mysys/mf_pack.c ../mysys/mf_path.c ../mysys/mf_tempfile.c ../mysys/mf_unixpath.c - ../mysys/mf_wcomp.c ../mysys/mulalloc.c ../mysys/my_access.c ../mysys/my_alloc.c - ../mysys/my_chsize.c ../mysys/my_compress.c ../mysys/my_create.c - ../mysys/my_delete.c ../mysys/my_div.c ../mysys/my_error.c ../mysys/my_file.c - ../mysys/my_fopen.c ../mysys/my_fstream.c ../mysys/my_gethostbyname.c - ../mysys/my_getopt.c ../mysys/my_getwd.c ../mysys/my_init.c ../mysys/my_lib.c - ../mysys/my_malloc.c ../mysys/my_messnc.c ../mysys/my_net.c ../mysys/my_once.c - ../mysys/my_open.c ../mysys/my_pread.c ../mysys/my_pthread.c ../mysys/my_read.c - ../mysys/my_realloc.c ../mysys/my_rename.c ../mysys/my_seek.c - ../mysys/my_static.c ../strings/my_strtoll10.c ../mysys/my_symlink.c - ../mysys/my_symlink2.c ../mysys/my_thr_init.c ../sql-common/my_time.c - ../strings/my_vsnprintf.c ../mysys/my_wincond.c ../mysys/my_winthread.c - ../mysys/my_write.c ../sql/net_serv.cc ../sql-common/pack.c ../sql/password.c - ../mysys/safemalloc.c ../mysys/sha1.c ../strings/str2int.c - ../strings/str_alloc.c ../strings/strcend.c ../strings/strcont.c ../strings/strend.c - ../strings/strfill.c ../mysys/string.c ../strings/strinstr.c ../strings/strmake.c - ../strings/strmov.c ../strings/strnlen.c ../strings/strnmov.c ../strings/strtod.c - ../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c - ../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c - ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c - ${YASSL_SOURCES} ${TAOCRYPT_SOURCES} - ) - -ADD_DEPENDENCIES(mysqlclient GenError) -ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc) -LINK_DIRECTORIES(${MYSQL_BINARY_DIR}/mysys ${MYSQL_BINARY_DIR}/zlib) -TARGET_LINK_LIBRARIES(mysql mysqlclient mysys zlib dbug wsock32) - -ADD_EXECUTABLE(mysqltest mysqltest.c) -TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys zlib dbug regex wsock32) +ADD_EXECUTABLE(mysqltest mysqltest.c ../mysys/my_getsystime.c ../mysys/my_copy.c) +TARGET_LINK_LIBRARIES(mysqltest mysqlclient_notls regex wsock32) ADD_EXECUTABLE(mysqlcheck mysqlcheck.c) -TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient dbug zlib wsock32) +TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient_notls wsock32) -ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c) -TARGET_LINK_LIBRARIES(mysqldump mysqlclient mysys dbug zlib wsock32) +ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c ../mysys/mf_getdate.c) +TARGET_LINK_LIBRARIES(mysqldump mysqlclient_notls wsock32) ADD_EXECUTABLE(mysqlimport mysqlimport.c) -TARGET_LINK_LIBRARIES(mysqlimport mysqlclient mysys dbug zlib wsock32) +TARGET_LINK_LIBRARIES(mysqlimport mysqlclient_notls wsock32) ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c ../mysys/my_getpagesize.c) -TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient dbug zlib wsock32) +TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient_notls wsock32) ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs) ADD_EXECUTABLE(mysqlshow mysqlshow.c) -TARGET_LINK_LIBRARIES(mysqlshow mysqlclient mysys dbug zlib wsock32) +TARGET_LINK_LIBRARIES(mysqlshow mysqlclient_notls wsock32) -ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc ../mysys/mf_tempdir.c ../mysys/my_new.cc - ../mysys/my_bit.c ../mysys/my_bitmap.c ../mysys/my_vle.c - ../mysys/base64.c) -TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient dbug zlib wsock32) +ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc + ../mysys/mf_tempdir.c + ../mysys/my_new.cc + ../mysys/my_bit.c + ../mysys/my_bitmap.c + ../mysys/my_vle.c + ../mysys/base64.c) +TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient_notls wsock32) ADD_EXECUTABLE(mysqladmin mysqladmin.cc) -TARGET_LINK_LIBRARIES(mysqladmin mysqlclient mysys dbug zlib wsock32) - -ADD_EXECUTABLE(mysqlslap mysqlslap.c) -SET_SOURCE_FILES_PROPERTIES(mysqlslap.c PROPERTIES COMPILE_FLAGS "-DTHREADS") -TARGET_LINK_LIBRARIES(mysqlslap mysqlclient mysys zlib wsock32 dbug) +TARGET_LINK_LIBRARIES(mysqladmin mysqlclient_notls wsock32) ADD_EXECUTABLE(echo echo.c) @@ -153,3 +77,4 @@ IF(EMBED_MANIFESTS) MYSQL_EMBED_MANIFEST("mysqladmin" "asInvoker") MYSQL_EMBED_MANIFEST("echo" "asInvoker") ENDIF(EMBED_MANIFESTS) + diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 7d4dcc1e919..c659c36117a 100755 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -12,13 +12,16 @@ # 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -# Need to set USE_TLS, since __declspec(thread) approach to thread local -# storage does not work properly in DLLs. INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake") -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_TLS") -SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_TLS") +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + +# Note that we don't link with the libraries "strings" or "mysys" +# here, instead we recompile the files needed and include them +# directly. This means we don't have to worry here about if these +# libraries are compiled defining USE_TLS or not. Not that it *should* +# have been a problem anyway, they don't use thread local storage. INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib @@ -28,8 +31,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/strings) -ADD_LIBRARY(libmysql SHARED dll.c libmysql.def - ../mysys/array.c ../strings/bchange.c ../strings/bmove.c +SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c ../strings/bmove_upp.c ../mysys/charset-def.c ../mysys/charset.c ../sql-common/client.c ../strings/ctype-big5.c ../strings/ctype-bin.c ../strings/ctype-cp932.c ../strings/ctype-czech.c ../strings/ctype-euc_kr.c @@ -38,10 +40,11 @@ ADD_LIBRARY(libmysql SHARED dll.c libmysql.def ../strings/ctype-simple.c ../strings/ctype-sjis.c ../strings/ctype-tis620.c ../strings/ctype-uca.c ../strings/ctype-ucs2.c ../strings/ctype-ujis.c ../strings/ctype-utf8.c ../strings/ctype-win1250ch.c ../strings/ctype.c - ../mysys/default.c ../libmysql/errmsg.c ../mysys/errors.c - ../libmysql/get_password.c ../strings/int2str.c ../strings/is_prefix.c - ../libmysql/libmysql.c ../mysys/list.c ../strings/llstr.c - ../strings/longlong2str.c ../libmysql/manager.c ../mysys/mf_cache.c + ../mysys/default.c errmsg.c ../mysys/errors.c + ../mysys/hash.c ../mysys/my_sleep.c ../mysys/default_modify.c + get_password.c ../strings/int2str.c ../strings/is_prefix.c + libmysql.c ../mysys/list.c ../strings/llstr.c + ../strings/longlong2str.c manager.c ../mysys/mf_cache.c ../mysys/mf_dirname.c ../mysys/mf_fn_ext.c ../mysys/mf_format.c ../mysys/mf_iocache.c ../mysys/mf_iocache2.c ../mysys/mf_loadpath.c ../mysys/mf_pack.c ../mysys/mf_path.c ../mysys/mf_tempfile.c ../mysys/mf_unixpath.c @@ -64,8 +67,35 @@ ADD_LIBRARY(libmysql SHARED dll.c libmysql.def ../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c ../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c) -ADD_DEPENDENCIES(libmysql dbug vio mysys strings GenError zlib yassl taocrypt) -TARGET_LINK_LIBRARIES(libmysql mysys strings wsock32) + +# Need to set USE_TLS for building the DLL, since __declspec(thread) +# approach to thread local storage does not work properly in DLLs. +# +# The static library might be used to form another DLL, as is the case +# with the ODBC driver, so it has to be compiled with USE_TLS as well. +# +# We create a third library without USE_TLS for internal use. We can't +# be sure that some client application part of this build doesn't go +# beond the documented API, and try access the Thread Local Storage. +# The "_notls" means no Tls*() functions used, i.e. "static" TLS. + +ADD_LIBRARY(libmysql SHARED dll.c libmysql.def ${CLIENT_SOURCES}) +ADD_LIBRARY(mysqlclient STATIC ${CLIENT_SOURCES}) +ADD_LIBRARY(mysqlclient_notls STATIC ${CLIENT_SOURCES}) + +SET_TARGET_PROPERTIES(libmysql mysqlclient PROPERTIES COMPILE_FLAGS "-DUSE_TLS") + +SET(CLIENT_LIB_DEPS yassl taocrypt zlib dbug GenError) +SET(CLIENT_LIBS yassl taocrypt zlib debug dbug) + +ADD_DEPENDENCIES(libmysql ${CLIENT_LIB_DEPS}) +TARGET_LINK_LIBRARIES(libmysql ${CLIENT_LIBS} wsock32) + +ADD_DEPENDENCIES(mysqlclient ${CLIENT_LIB_DEPS}) +TARGET_LINK_LIBRARIES(mysqlclient ${CLIENT_LIBS}) + +ADD_DEPENDENCIES(mysqlclient_notls ${CLIENT_LIB_DEPS}) +TARGET_LINK_LIBRARIES(mysqlclient_notls ${CLIENT_LIBS}) ADD_EXECUTABLE(myTest mytest.c) TARGET_LINK_LIBRARIES(myTest libmysql) diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 1ae625c4c03..08279eda00c 100755 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -13,18 +13,23 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") -# Need to set USE_TLS, since mysys is linked into libmysql.dll and -# libmysqld.dll, and __declspec(thread) approach to thread local storage does -# not work properly in DLLs. -# Currently, USE_TLS crashes in Debug builds, so until that is fixed Debug -# .dlls cannot be loaded at runtime. -SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DUSE_TLS") -SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DUSE_TLS") +# Only the server link with this library, the client libraries and the client +# executables all link with recompiles of source found in the "mysys" directory. +# So we only need to create one version of this library, with the "static" +# Thread Local Storage model. +# +# Exception is the embedded server that needs this library compiled with +# dynamic TLS, i.e. define USE_TLS + +IF(EMBEDDED_ONLY) + ADD_DEFINITIONS(-DUSE_TLS) + ADD_DEFINITIONS(-DEMBEDDED_LIBRARY) +ENDIF(EMBEDDED_ONLY) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/include) + ADD_LIBRARY(mysys array.c charset-def.c charset.c checksum.c default.c default_modify.c errors.c hash.c list.c md5.c mf_brkhant.c mf_cache.c mf_dirname.c mf_fn_ext.c mf_format.c mf_getdate.c mf_iocache.c mf_iocache2.c mf_keycache.c diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index c792e10c3af..7e0d28070ad 100755 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -91,19 +91,19 @@ IF(EMBED_MANIFESTS) MYSQL_EMBED_MANIFEST("mysqld" "asInvoker") ENDIF(EMBED_MANIFESTS) IF(WITH_ARCHIVE_STORAGE_ENGINE) - TARGET_LINK_LIBRARIES(mysqld archive) + TARGET_LINK_LIBRARIES(mysqld${MYSQLD_EXE_SUFFIX} archive) ENDIF(WITH_ARCHIVE_STORAGE_ENGINE) IF(WITH_BLACKHOLE_STORAGE_ENGINE) - TARGET_LINK_LIBRARIES(mysqld blackhole) + TARGET_LINK_LIBRARIES(mysqld${MYSQLD_EXE_SUFFIX} blackhole) ENDIF(WITH_BLACKHOLE_STORAGE_ENGINE) IF(WITH_CSV_STORAGE_ENGINE) - TARGET_LINK_LIBRARIES(mysqld csv) + TARGET_LINK_LIBRARIES(mysqld${MYSQLD_EXE_SUFFIX} csv) ENDIF(WITH_CSV_STORAGE_ENGINE) IF(WITH_EXAMPLE_STORAGE_ENGINE) TARGET_LINK_LIBRARIES(mysqld${MYSQLD_EXE_SUFFIX} example) ENDIF(WITH_EXAMPLE_STORAGE_ENGINE) IF(WITH_FEDERATED_STORAGE_ENGINE) - TARGET_LINK_LIBRARIES(mysqld federated) + TARGET_LINK_LIBRARIES(mysqld${MYSQLD_EXE_SUFFIX} federated) ENDIF(WITH_FEDERATED_STORAGE_ENGINE) IF(WITH_INNOBASE_STORAGE_ENGINE) TARGET_LINK_LIBRARIES(mysqld${MYSQLD_EXE_SUFFIX} innobase) diff --git a/zlib/CMakeLists.txt b/zlib/CMakeLists.txt index 123b7f6ec7f..3d176e59c88 100755 --- a/zlib/CMakeLists.txt +++ b/zlib/CMakeLists.txt @@ -18,10 +18,9 @@ # Not directly and indirectly using any of the macros for creating and # using the storage, pthread_key*(), {,my_}{set,get}_specific*() .... -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") ADD_LIBRARY(zlib adler32.c compress.c crc32.c crc32.h deflate.c deflate.h gzio.c infback.c inffast.c inffast.h inffixed.h inflate.c inflate.h inftrees.c inftrees.h trees.c trees.h uncompr.c zconf.h zlib.h zutil.c zutil.h) - \ No newline at end of file + From 072a190820c2df7749bae76074b2eb2a4f90ee27 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 14:17:51 +0500 Subject: [PATCH 37/74] powermacg5 problem fix we need a copy of I_S name because the name can be changed in case of lowercase_table_name!=0 --- sql/sql_show.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index a6b768b7b26..282982495d4 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2535,6 +2535,10 @@ int make_db_list(THD *thd, List *files, LOOKUP_FIELD_VALUES *lookup_field_vals, bool *with_i_schema) { + LEX_STRING *i_s_name_copy= 0; + i_s_name_copy= thd->make_lex_string(i_s_name_copy, + INFORMATION_SCHEMA_NAME.str, + INFORMATION_SCHEMA_NAME.length, TRUE); *with_i_schema= 0; if (lookup_field_vals->wild_db_value) { @@ -2549,7 +2553,7 @@ int make_db_list(THD *thd, List *files, lookup_field_vals->db_value.str)) { *with_i_schema= 1; - if (files->push_back(&INFORMATION_SCHEMA_NAME)) + if (files->push_back(i_s_name_copy)) return 1; } return (find_files(thd, files, NullS, mysql_data_home, @@ -2567,7 +2571,7 @@ int make_db_list(THD *thd, List *files, lookup_field_vals->db_value.str)) { *with_i_schema= 1; - if (files->push_back(&INFORMATION_SCHEMA_NAME)) + if (files->push_back(i_s_name_copy)) return 1; return 0; } @@ -2580,7 +2584,7 @@ int make_db_list(THD *thd, List *files, Create list of existing databases. It is used in case of select from information schema table */ - if (files->push_back(&INFORMATION_SCHEMA_NAME)) + if (files->push_back(i_s_name_copy)) return 1; *with_i_schema= 1; return (find_files(thd, files, NullS, From 8a2384d5e982324abb2d5e1490f963825d0d3194 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 12:37:00 +0200 Subject: [PATCH 38/74] Many files: Post-merge fix. mysql-test/suite/rpl/r/rpl_udf.result: Post-merge fix. mysql-test/suite/ndb/r/ndb_dd_basic.result: Post-merge fix. mysql-test/suite/ndb/r/ndb_dd_ddl.result: Post-merge fix. mysql-test/suite/ndb/r/ndb_gis.result: Post-merge fix. mysql-test/suite/ndb/r/ndb_row_format.result: Post-merge fix. mysql-test/suite/ndb/r/ndb_single_user.result: Post-merge fix. --- mysql-test/suite/ndb/r/ndb_dd_basic.result | 6 +++--- mysql-test/suite/ndb/r/ndb_dd_ddl.result | 2 +- mysql-test/suite/ndb/r/ndb_gis.result | 4 ++-- mysql-test/suite/ndb/r/ndb_row_format.result | 2 +- mysql-test/suite/ndb/r/ndb_single_user.result | 10 +++++----- mysql-test/suite/rpl/r/rpl_udf.result | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/mysql-test/suite/ndb/r/ndb_dd_basic.result b/mysql-test/suite/ndb/r/ndb_dd_basic.result index bc1762ce407..b23d178acde 100644 --- a/mysql-test/suite/ndb/r/ndb_dd_basic.result +++ b/mysql-test/suite/ndb/r/ndb_dd_basic.result @@ -5,20 +5,20 @@ INITIAL_SIZE 16M UNDO_BUFFER_SIZE = 1M ENGINE=MYISAM; Warnings: -Error 1475 Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP' +Error 1476 Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP' ALTER LOGFILE GROUP lg1 ADD UNDOFILE 'undofile02.dat' INITIAL_SIZE = 4M ENGINE=XYZ; Warnings: Warning 1286 Unknown table engine 'XYZ' -Error 1475 Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP' +Error 1476 Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP' CREATE TABLESPACE ts1 ADD DATAFILE 'datafile.dat' USE LOGFILE GROUP lg1 INITIAL_SIZE 12M; Warnings: -Error 1475 Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP' +Error 1476 Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP' set storage_engine=ndb; CREATE LOGFILE GROUP lg1 ADD UNDOFILE 'undofile.dat' diff --git a/mysql-test/suite/ndb/r/ndb_dd_ddl.result b/mysql-test/suite/ndb/r/ndb_dd_ddl.result index 55f1f56fd0c..33536038b1b 100644 --- a/mysql-test/suite/ndb/r/ndb_dd_ddl.result +++ b/mysql-test/suite/ndb/r/ndb_dd_ddl.result @@ -16,7 +16,7 @@ ERROR HY000: Failed to create LOGFILE GROUP SHOW WARNINGS; Level Code Message Error 1296 Got error 1514 'Currently there is a limit of one logfile group' from NDB -Error 1525 Failed to create LOGFILE GROUP +Error 1526 Failed to create LOGFILE GROUP CREATE LOGFILE GROUP lg1 ADD UNDOFILE 'undofile.dat' INITIAL_SIZE 1M diff --git a/mysql-test/suite/ndb/r/ndb_gis.result b/mysql-test/suite/ndb/r/ndb_gis.result index 54f1fc23489..1d593f471d1 100644 --- a/mysql-test/suite/ndb/r/ndb_gis.result +++ b/mysql-test/suite/ndb/r/ndb_gis.result @@ -463,7 +463,7 @@ drop table t1; End of 4.1 tests CREATE TABLE t1 (name VARCHAR(100), square GEOMETRY); Warnings: -Error 1475 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK' +Error 1476 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK' INSERT INTO t1 VALUES("center", GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))')); INSERT INTO t1 VALUES("small", GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))')); INSERT INTO t1 VALUES("big", GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))')); @@ -1013,7 +1013,7 @@ drop table t1; End of 4.1 tests CREATE TABLE t1 (name VARCHAR(100), square GEOMETRY); Warnings: -Error 1475 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK' +Error 1476 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK' INSERT INTO t1 VALUES("center", GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))')); INSERT INTO t1 VALUES("small", GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))')); INSERT INTO t1 VALUES("big", GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))')); diff --git a/mysql-test/suite/ndb/r/ndb_row_format.result b/mysql-test/suite/ndb/r/ndb_row_format.result index 37c239986f6..44880e28c83 100644 --- a/mysql-test/suite/ndb/r/ndb_row_format.result +++ b/mysql-test/suite/ndb/r/ndb_row_format.result @@ -8,7 +8,7 @@ ENGINE=NDB; ERROR HY000: Can't create table 'test.t1' (errno: 138) SHOW WARNINGS; Level Code Message -Error 1475 Table storage engine 'ndbcluster' does not support the create option 'Row format FIXED incompatible with variable sized attribute' +Error 1476 Table storage engine 'ndbcluster' does not support the create option 'Row format FIXED incompatible with variable sized attribute' Error 1005 Can't create table 'test.t1' (errno: 138) CREATE TABLE t1 ( a INT KEY, diff --git a/mysql-test/suite/ndb/r/ndb_single_user.result b/mysql-test/suite/ndb/r/ndb_single_user.result index f916422a509..11e8f098416 100644 --- a/mysql-test/suite/ndb/r/ndb_single_user.result +++ b/mysql-test/suite/ndb/r/ndb_single_user.result @@ -11,7 +11,7 @@ ERROR HY000: Failed to create LOGFILE GROUP show warnings; Level Code Message Error 1296 Got error 299 'Operation not allowed or aborted due to single user mode' from NDB -Error 1525 Failed to create LOGFILE GROUP +Error 1526 Failed to create LOGFILE GROUP create table t1 (a int key, b int unique, c int) engine ndb; CREATE LOGFILE GROUP lg1 ADD UNDOFILE 'undofile.dat' @@ -27,14 +27,14 @@ ERROR HY000: Failed to create TABLESPACE show warnings; Level Code Message Error 1296 Got error 299 'Operation not allowed or aborted due to single user mode' from NDB -Error 1525 Failed to create TABLESPACE +Error 1526 Failed to create TABLESPACE DROP LOGFILE GROUP lg1 ENGINE =NDB; ERROR HY000: Failed to drop LOGFILE GROUP show warnings; Level Code Message Error 1296 Got error 299 'Operation not allowed or aborted due to single user mode' from NDB -Error 1526 Failed to drop LOGFILE GROUP +Error 1527 Failed to drop LOGFILE GROUP CREATE TABLESPACE ts1 ADD DATAFILE 'datafile.dat' USE LOGFILE GROUP lg1 @@ -47,7 +47,7 @@ ERROR HY000: Failed to alter: DROP DATAFILE show warnings; Level Code Message Error 1296 Got error 299 'Operation not allowed or aborted due to single user mode' from NDB -Error 1530 Failed to alter: DROP DATAFILE +Error 1531 Failed to alter: DROP DATAFILE ALTER TABLESPACE ts1 DROP DATAFILE 'datafile.dat' ENGINE NDB; @@ -57,7 +57,7 @@ ERROR HY000: Failed to drop TABLESPACE show warnings; Level Code Message Error 1296 Got error 299 'Operation not allowed or aborted due to single user mode' from NDB -Error 1526 Failed to drop TABLESPACE +Error 1527 Failed to drop TABLESPACE DROP TABLESPACE ts1 ENGINE NDB; DROP LOGFILE GROUP lg1 diff --git a/mysql-test/suite/rpl/r/rpl_udf.result b/mysql-test/suite/rpl/r/rpl_udf.result index d21cfd2539b..1fa9cb3ffc2 100644 --- a/mysql-test/suite/rpl/r/rpl_udf.result +++ b/mysql-test/suite/rpl/r/rpl_udf.result @@ -182,19 +182,19 @@ CREATE TABLE t1(sum INT, price FLOAT(24)) ENGINE=MyISAM; affected rows: 0 INSERT INTO t1 VALUES(myfunc_int(100), myfunc_double(50.00)); Warnings: -Warning 1589 Statement is not safe to log in statement format. +Warning 1590 Statement is not safe to log in statement format. affected rows: 1 INSERT INTO t1 VALUES(myfunc_int(10), myfunc_double(5.00)); Warnings: -Warning 1589 Statement is not safe to log in statement format. +Warning 1590 Statement is not safe to log in statement format. affected rows: 1 INSERT INTO t1 VALUES(myfunc_int(200), myfunc_double(25.00)); Warnings: -Warning 1589 Statement is not safe to log in statement format. +Warning 1590 Statement is not safe to log in statement format. affected rows: 1 INSERT INTO t1 VALUES(myfunc_int(1), myfunc_double(500.00)); Warnings: -Warning 1589 Statement is not safe to log in statement format. +Warning 1590 Statement is not safe to log in statement format. affected rows: 1 SELECT * FROM t1 ORDER BY sum; sum price From 71c3c0cfd57e1d37e4f04427388f8c473283540c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 14:14:33 +0300 Subject: [PATCH 39/74] Bug #25228: rpl_relayspace.test fails on powermacg5, vm-win2003-32-a A test case was waiting for a fixed number of seconds for a specific state of the slave IO thread to take place. Fixed by waiting in a loop for that specific thread state instead (or timeout). mysql-test/t/rpl_relayspace.test: Bug #25228: fixed test case --- mysql-test/t/rpl_relayspace.test | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mysql-test/t/rpl_relayspace.test b/mysql-test/t/rpl_relayspace.test index 70315c14f34..d4ef2fe59bd 100644 --- a/mysql-test/t/rpl_relayspace.test +++ b/mysql-test/t/rpl_relayspace.test @@ -14,6 +14,22 @@ connection slave; reset slave; start slave io_thread; # Give the I/O thread time to block. +let $run= 1; +let $counter= 300; +while ($run) +{ + let $io_state= query_get_value("SHOW SLAVE STATUS", Slave_IO_State, 1); + if (`SELECT '$io_state' = 'Waiting for the slave SQL thread to free enough relay log space'`){ + let $run= 0; + } + sleep 0.1; + if (!$counter){ + --echo "Failed while waiting for slave IO thread block" + SHOW SLAVE STATUS; + exit; + } + dec $counter; +} sleep 2; # A bug caused the I/O thread to refuse stopping. stop slave io_thread; From 97bb72f139b95cf2ecd2c8ed0ac9a3b449ef8977 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 14:43:11 +0200 Subject: [PATCH 40/74] add mysqlslap back to windows builds for 5.1 client/CMakeLists.txt: add mysqlslap back in for 5.1 --- client/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 0b37f4d3d1c..2ef55c23c90 100755 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -63,6 +63,10 @@ TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient_notls wsock32) ADD_EXECUTABLE(mysqladmin mysqladmin.cc) TARGET_LINK_LIBRARIES(mysqladmin mysqlclient_notls wsock32) +ADD_EXECUTABLE(mysqlslap mysqlslap.c) +SET_SOURCE_FILES_PROPERTIES(mysqlslap.c PROPERTIES COMPILE_FLAGS "-DTHREADS") +TARGET_LINK_LIBRARIES(mysqlslap mysqlclient mysys zlib wsock32 dbug) + ADD_EXECUTABLE(echo echo.c) IF(EMBED_MANIFESTS) From 712d7fa244581e6c82c3c2783271b231f748cfe9 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 18:31:54 +0200 Subject: [PATCH 41/74] .del-readme.txt-grumble-grumble: Rename: BitKeeper/deleted/.del-readme.txt -> BitKeeper/deleted/.del-readme.txt-grumble-grumble BitKeeper/deleted/.del-readme.txt-grumble-grumble: Rename: BitKeeper/deleted/.del-readme.txt -> BitKeeper/deleted/.del-readme.txt-grumble-grumble From 9ce04bc2f55df61850c2e79009cfc72c39c2aa84 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 18:57:18 +0200 Subject: [PATCH 42/74] merge fix --- libmysql/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index c659c36117a..653f54dad09 100755 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -66,7 +66,8 @@ SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c ../strings/strmov.c ../strings/strnlen.c ../strings/strnmov.c ../strings/strtod.c ../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c ../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c - ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c) + ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c + ../mysys/my_getsystime.c) # Need to set USE_TLS for building the DLL, since __declspec(thread) # approach to thread local storage does not work properly in DLLs. From c6c57ed783eabf5d9c99a3c1fd4f5ea5518c069c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 14:43:12 -0400 Subject: [PATCH 43/74] Bug#29903 The CMake build method does not produce the embedded library. - Changes to correct and test Windows embedded build. BitKeeper/etc/ignore: Bug#29903 The CMake build method does not produce the embedded library. - Ignore auto-generated Windows embedded resources. CMakeLists.txt: Bug#29903 The CMake build method does not produce the embedded library. - Hardcode CSV for all configurations. - Add client directory for gen_lex_hash dependency. client/CMakeLists.txt: Bug#29903 The CMake build method does not produce the embedded library. - Build the mysqlclient library and echo for the embedded solution. client/client_priv.h: Bug#29903 The CMake build method does not produce the embedded library. - Defined new option. client/mysql.cc: Bug#29903 The CMake build method does not produce the embedded library. - Add server-arg command line parameter libmysqld/CMakeLists.txt: Bug#29903 The CMake build method does not produce the embedded library. - Added auto generated resources; sql_yacc.cc, sql_yacc.h, message.rc message.h and lex_hash.h. - Link csv library to libmsyqld. libmysqld/Makefile.am: Bug#29903 The CMake build method does not produce the embedded library. - Include CMakeLists.txt in dist. libmysqld/examples/CMakeLists.txt: Bug#29903 The CMake build method does not produce the embedded library. - Follow existing naming convention. libmysqld/examples/Makefile.am: Bug#29903 The CMake build method does not produce the embedded library. - Include CMakeLists.txt in dist. mysql-test/mysql-test-run.pl: Bug#29903 The CMake build method does not produce the embedded library. - Move embedded option block earlier in the script. - Added the path to the libmysqld.dll to Windows path. win/README: Bug#29903 The CMake build method does not produce the embedded library. - Add instructions for building/testing the embedded library. --- .bzrignore | 3 ++ CMakeLists.txt | 37 ++++++++--------- client/CMakeLists.txt | 69 ++++++++++++++++--------------- client/client_priv.h | 2 +- client/mysql.cc | 48 +++++++++++++++------ libmysqld/CMakeLists.txt | 63 +++++++++++++++++++++++++--- libmysqld/Makefile.am | 2 +- libmysqld/examples/CMakeLists.txt | 6 +-- libmysqld/examples/Makefile.am | 1 + mysql-test/mysql-test-run.pl | 31 ++++++++++++++ win/README | 15 +++++++ 11 files changed, 202 insertions(+), 75 deletions(-) diff --git a/.bzrignore b/.bzrignore index d44aefea583..f003a1f5d08 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1099,6 +1099,7 @@ libmysqld/item_sum.cc libmysqld/item_timefunc.cc libmysqld/item_uniq.cc libmysqld/key.cc +libmysqld/lex_hash.h libmysqld/lib_sql.cpp libmysqld/libmysql.c libmysqld/link_sources @@ -1107,6 +1108,8 @@ libmysqld/log.cc libmysqld/log_event.cc libmysqld/log_event_old.cc libmysqld/md5.c +libmysqld/message.h +libmysqld/message.rc libmysqld/mf_iocache.cc libmysqld/mini_client.cc libmysqld/my_decimal.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 3dc62977846..6452257af9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,22 +18,24 @@ PROJECT(MySql) # This reads user configuration, generated by configure.js. INCLUDE(win/configure.data) -# By default, CMake will create Release, Debug, RelWithDebInfo and MinSizeRel -# configurations. The EMBEDDED_ONLY build parameter is necessary because CMake -# doesn't support custom build configurations for VS2005. Since the Debug -# configuration does not work properly with USE_TLS defined -# (see mysys/CMakeLists.txt) the easiest way to debug the Embedded Server is to -# use the RelWithDebInfo configuration without optimizations. -# -# Debug default CXX_FLAGS "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1" -# RelWithDebInfo default CXX_FLAGS "/MD /Zi /O2 /Ob1 /D NDEBUG" -# -IF(NOT EMBEDDED_ONLY) - # Hardcode support for CSV storage engine - SET(WITH_CSV_STORAGE_ENGINE TRUE) -ELSE(NOT EMBEDDED_ONLY) +# Hardcode support for CSV storage engine +SET(WITH_CSV_STORAGE_ENGINE TRUE) + +# CMAKE will not allow custom VS7+ configurations. mysqld and libmysqld +# cannot be built at the same time as they require different configurations +IF(EMBEDDED_ONLY) + ADD_DEFINITIONS(-DEMBEDDED_LIBRARY) + # By default, CMake will create Release, Debug, RelWithDebInfo and MinSizeRel + # configurations. The EMBEDDED_ONLY build parameter is necessary because CMake + # doesn't support custom build configurations for VS2005. Since the Debug + # configuration does not work properly with USE_TLS defined + # (see mysys/CMakeLists.txt) the easiest way to debug the Embedded Server is to + # use the RelWithDebInfo configuration without optimizations. + # + # Debug default CXX_FLAGS "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1" + # RelWithDebInfo default CXX_FLAGS "/MD /Zi /O2 /Ob1 /D NDEBUG" SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /Zi /Od /Ob0 /D NDEBUG" CACHE STRING "No Optimization" FORCE) -ENDIF(NOT EMBEDDED_ONLY) +ENDIF(EMBEDDED_ONLY) CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/mysql_version.h.in ${CMAKE_SOURCE_DIR}/include/mysql_version.h @ONLY) @@ -241,14 +243,11 @@ ENDIF(WITH_FEDERATED_STORAGE_ENGINE) IF(WITH_INNOBASE_STORAGE_ENGINE) ADD_SUBDIRECTORY(storage/innobase) ENDIF(WITH_INNOBASE_STORAGE_ENGINE) -# CMAKE will not allow custom VS7+ configurations. mysqld and libmysqld -# cannot be built at the same time as they require different configurations +ADD_SUBDIRECTORY(client) IF(EMBEDDED_ONLY) - ADD_DEFINITIONS(-DEMBEDDED_LIBRARY) ADD_SUBDIRECTORY(libmysqld) ADD_SUBDIRECTORY(libmysqld/examples) ELSE(EMBEDDED_ONLY) - ADD_SUBDIRECTORY(client) ADD_SUBDIRECTORY(sql) ADD_SUBDIRECTORY(server-tools/instance-manager) ADD_SUBDIRECTORY(libmysql) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 8a670cf4c4b..d8a967e02d8 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -104,40 +104,43 @@ ADD_LIBRARY(mysqlclient ../mysys/array.c ../strings/bchange.c ../strings/bmove.c ) ADD_DEPENDENCIES(mysqlclient GenError) -ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc) -LINK_DIRECTORIES(${MYSQL_BINARY_DIR}/mysys ${MYSQL_BINARY_DIR}/zlib) -TARGET_LINK_LIBRARIES(mysql mysqlclient mysys zlib dbug wsock32) -ADD_EXECUTABLE(mysqltest mysqltest.c) -TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys zlib dbug regex wsock32) - -ADD_EXECUTABLE(mysqlcheck mysqlcheck.c) -TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient dbug zlib wsock32) - -ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c) -TARGET_LINK_LIBRARIES(mysqldump mysqlclient mysys dbug zlib wsock32) - -ADD_EXECUTABLE(mysqlimport mysqlimport.c) -TARGET_LINK_LIBRARIES(mysqlimport mysqlclient mysys dbug zlib wsock32) - -ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c ../mysys/my_getpagesize.c) -TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient dbug zlib wsock32) -ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs) - -ADD_EXECUTABLE(mysqlshow mysqlshow.c) -TARGET_LINK_LIBRARIES(mysqlshow mysqlclient mysys dbug zlib wsock32) - -ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc ../mysys/mf_tempdir.c ../mysys/my_new.cc - ../mysys/my_bit.c ../mysys/my_bitmap.c ../mysys/my_vle.c - ../mysys/base64.c) -TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient dbug zlib wsock32) - -ADD_EXECUTABLE(mysqladmin mysqladmin.cc) -TARGET_LINK_LIBRARIES(mysqladmin mysqlclient mysys dbug zlib wsock32) - -ADD_EXECUTABLE(mysqlslap mysqlslap.c) -SET_SOURCE_FILES_PROPERTIES(mysqlslap.c PROPERTIES COMPILE_FLAGS "-DTHREADS") -TARGET_LINK_LIBRARIES(mysqlslap mysqlclient mysys zlib wsock32 dbug) +IF(NOT EMBEDDED_ONLY) + ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc) + LINK_DIRECTORIES(${MYSQL_BINARY_DIR}/mysys ${MYSQL_BINARY_DIR}/zlib) + TARGET_LINK_LIBRARIES(mysql mysqlclient mysys zlib dbug wsock32) + + ADD_EXECUTABLE(mysqltest mysqltest.c) + TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys zlib dbug regex wsock32) + + ADD_EXECUTABLE(mysqlcheck mysqlcheck.c) + TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient dbug zlib wsock32) + + ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c) + TARGET_LINK_LIBRARIES(mysqldump mysqlclient mysys dbug zlib wsock32) + + ADD_EXECUTABLE(mysqlimport mysqlimport.c) + TARGET_LINK_LIBRARIES(mysqlimport mysqlclient mysys dbug zlib wsock32) + + ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c ../mysys/my_getpagesize.c) + TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient dbug zlib wsock32) + ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs) + + ADD_EXECUTABLE(mysqlshow mysqlshow.c) + TARGET_LINK_LIBRARIES(mysqlshow mysqlclient mysys dbug zlib wsock32) + + ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc ../mysys/mf_tempdir.c ../mysys/my_new.cc + ../mysys/my_bit.c ../mysys/my_bitmap.c ../mysys/my_vle.c + ../mysys/base64.c) + TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient dbug zlib wsock32) + + ADD_EXECUTABLE(mysqladmin mysqladmin.cc) + TARGET_LINK_LIBRARIES(mysqladmin mysqlclient mysys dbug zlib wsock32) + + ADD_EXECUTABLE(mysqlslap mysqlslap.c) + SET_SOURCE_FILES_PROPERTIES(mysqlslap.c PROPERTIES COMPILE_FLAGS "-DTHREADS") + TARGET_LINK_LIBRARIES(mysqlslap mysqlclient mysys zlib wsock32 dbug) +ENDIF(NOT EMBEDDED_ONLY) ADD_EXECUTABLE(echo echo.c) diff --git a/client/client_priv.h b/client/client_priv.h index 8bc8ef692de..f992f19938b 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -48,7 +48,7 @@ enum options_client OPT_PROMPT, OPT_IGN_LINES,OPT_TRANSACTION,OPT_MYSQL_PROTOCOL, OPT_SHARED_MEMORY_BASE_NAME, OPT_FRM, OPT_SKIP_OPTIMIZATION, OPT_COMPATIBLE, OPT_RECONNECT, OPT_DELIMITER, OPT_SECURE_AUTH, - OPT_OPEN_FILES_LIMIT, OPT_SET_CHARSET, OPT_CREATE_OPTIONS, + OPT_OPEN_FILES_LIMIT, OPT_SET_CHARSET, OPT_CREATE_OPTIONS, OPT_SERVER_ARG, OPT_START_POSITION, OPT_STOP_POSITION, OPT_START_DATETIME, OPT_STOP_DATETIME, OPT_SIGINT_IGNORE, OPT_HEXBLOB, OPT_ORDER_BY_PRIMARY, OPT_COUNT, #ifdef HAVE_NDBCLUSTER_DB diff --git a/client/mysql.cc b/client/mysql.cc index fe057c8b8a4..cd6a9fa40b2 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -51,6 +51,9 @@ const char *VER= "14.13"; /* Buffer to hold 'version' and 'version_comment' */ #define MAX_SERVER_VERSION_LENGTH 128 +/* Array of options to pass to libemysqld */ +#define MAX_SERVER_ARGS 64 + void* sql_alloc(unsigned size); // Don't use mysqld alloc for these void sql_element_free(void *ptr); #include "sql_string.h" @@ -302,7 +305,10 @@ static COMMANDS commands[] = { }; static const char *load_default_groups[]= { "mysql","client",0 }; -static const char *server_default_groups[]= + +static int embedded_server_arg_count= 0; +static char *embedded_server_args[MAX_SERVER_ARGS]; +static const char *embedded_server_groups[]= { "server", "embedded", "mysql_SERVER", 0 }; #ifdef HAVE_READLINE @@ -347,15 +353,6 @@ static sig_handler handle_sigint(int sig); int main(int argc,char *argv[]) { char buff[80]; - char *defaults, *extra_defaults, *group_suffix; - char *emb_argv[4]; - int emb_argc; - - /* Get --defaults-xxx args for mysql_server_init() */ - emb_argc= get_defaults_options(argc, argv, &defaults, &extra_defaults, - &group_suffix)+1; - memcpy((char*) emb_argv, (char*) argv, emb_argc * sizeof(*argv)); - emb_argv[emb_argc]= 0; MY_INIT(argv[0]); DBUG_ENTER("main"); @@ -416,7 +413,8 @@ int main(int argc,char *argv[]) my_end(0); exit(1); } - if (mysql_server_init(emb_argc, emb_argv, (char**) server_default_groups)) + if (mysql_server_init(embedded_server_arg_count, embedded_server_args, + (char**) embedded_server_groups)) { free_defaults(defaults_argv); my_end(0); @@ -539,6 +537,8 @@ sig_handler mysql_end(int sig) my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR)); #endif my_free(current_prompt,MYF(MY_ALLOW_ZERO_PTR)); + while (embedded_server_arg_count > 1) + my_free(embedded_server_args[--embedded_server_arg_count],MYF(0)); mysql_server_end(); free_defaults(defaults_argv); my_end(info_flag ? MY_CHECK_ERROR : 0); @@ -761,6 +761,8 @@ static struct my_option my_long_options[] = {"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it" " uses old (pre-4.1.1) protocol", (uchar**) &opt_secure_auth, (uchar**) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"server-arg", OPT_SERVER_ARG, "Send embedded server this as a parameter.", + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"show-warnings", OPT_SHOW_WARNINGS, "Show warnings after every statement.", (uchar**) &show_warnings, (uchar**) &show_warnings, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -888,7 +890,29 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib, opt->name); break; - break; + case OPT_SERVER_ARG: +#ifdef EMBEDDED_LIBRARY + /* + When the embedded server is being tested, the client needs to be + able to pass command-line arguments to the embedded server so it can + locate the language files and data directory. + */ + if (!embedded_server_arg_count) + { + embedded_server_arg_count= 1; + embedded_server_args[0]= (char*) ""; + } + if (embedded_server_arg_count == MAX_SERVER_ARGS-1 || + !(embedded_server_args[embedded_server_arg_count++]= + my_strdup(argument, MYF(MY_FAE)))) + { + put_info("Can't use server argument", INFO_ERROR); + return 0; + } +#else /*EMBEDDED_LIBRARY */ + printf("WARNING: --server-arg option not supported in this configuration.\n"); +#endif + break; case 'A': opt_rehash= 0; break; diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index dd42bafcfe0..3a6873112f3 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -25,16 +25,20 @@ ADD_DEFINITIONS(-DUSE_TLS -DMYSQL_SERVER) ADD_DEFINITIONS(-DUSING_CMAKE) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include - ${CMAKE_SOURCE_DIR}/libmysqld - ${CMAKE_SOURCE_DIR}/libmysql + ${CMAKE_SOURCE_DIR}/libmysqld + ${CMAKE_SOURCE_DIR}/libmysql ${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/regex ${CMAKE_SOURCE_DIR}/extra/yassl/include ${CMAKE_SOURCE_DIR}/zlib ) -SET_SOURCE_FILES_PROPERTIES(${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc - ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h +SET_SOURCE_FILES_PROPERTIES(sql_yacc.cc + sql_yacc.h + message.h + message.rc + ${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc + lex_hash.h PROPERTIES GENERATED 1) ADD_LIBRARY(mysqldemb emb_qcache.cc libmysqld.c lib_sql.cc @@ -80,10 +84,54 @@ ADD_LIBRARY(mysqldemb emb_qcache.cc libmysqld.c lib_sql.cc ../sql/scheduler.cc ../vio/vio.c ../vio/viosocket.c ../vio/viossl.c ../vio/viosslfactories.c - ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc - ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h) + sql_yacc.cc + sql_yacc.h + message.h + message.rc + lex_hash.h) ADD_DEPENDENCIES(mysqldemb GenError) +# Sql Parser custom command +ADD_CUSTOM_COMMAND( + SOURCE ${PROJECT_SOURCE_DIR}/sql/sql_yacc.yy + OUTPUT sql_yacc.cc + COMMAND bison.exe + ARGS -y -p MYSQL --defines=sql_yacc.h + --output=sql_yacc.cc ${PROJECT_SOURCE_DIR}/sql/sql_yacc.yy + DEPENDS ${PROJECT_SOURCE_DIR}/sql/sql_yacc.yy +) + +ADD_CUSTOM_COMMAND( + OUTPUT sql_yacc.h + COMMAND echo + DEPENDS ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc +) + +# Windows message file +ADD_CUSTOM_COMMAND( + SOURCE ${CMAKE_SOURCE_DIR}/sql/message.mc + OUTPUT message.rc message.h + COMMAND mc + ARGS ${CMAKE_SOURCE_DIR}/sql/message.mc + DEPENDS ${CMAKE_SOURCE_DIR}/sql/message.mc +) + +# Gen_lex_hash +ADD_EXECUTABLE(gen_lex_hash ../sql/gen_lex_hash.cc) +TARGET_LINK_LIBRARIES(gen_lex_hash dbug mysqlclient wsock32) +GET_TARGET_PROPERTY(GEN_LEX_HASH_EXE gen_lex_hash LOCATION) +ADD_CUSTOM_COMMAND( + OUTPUT lex_hash.h + COMMAND ${GEN_LEX_HASH_EXE} ARGS > lex_hash.h + DEPENDS ${GEN_LEX_HASH_EXE} +) + +# Remove the auto-generated files as part of 'Clean Solution' +SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES + "lex_hash.h;message.rc;message.h;sql_yacc.h;sql_yacc.cc") + +ADD_DEPENDENCIES(mysqldemb gen_lex_hash) + # Seems we cannot make a library without at least one source file. So use a # dummy empty file FILE(WRITE cmake_dummy.c " ") @@ -120,3 +168,6 @@ ENDIF(WITH_ARCHIVE_STORAGE_ENGINE) IF(WITH_BLACKHOLE_STORAGE_ENGINE) TARGET_LINK_LIBRARIES(libmysqld blackhole) ENDIF(WITH_BLACKHOLE_STORAGE_ENGINE) +IF(WITH_CSV_STORAGE_ENGINE) + TARGET_LINK_LIBRARIES(libmysqld csv) +ENDIF(WITH_CSV_STORAGE_ENGINE) diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am index 024b85eed8e..6ecce474b50 100644 --- a/libmysqld/Makefile.am +++ b/libmysqld/Makefile.am @@ -22,7 +22,7 @@ MYSQLSHAREdir = $(pkgdatadir) MYSQLBASEdir= $(prefix) MYSQLLIBdir= $(libdir) -EXTRA_DIST = libmysqld.def +EXTRA_DIST = libmysqld.def CMakeLists.txt DEFS = -DEMBEDDED_LIBRARY -DMYSQL_SERVER \ -DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \ -DDATADIR="\"$(MYSQLDATAdir)\"" \ diff --git a/libmysqld/examples/CMakeLists.txt b/libmysqld/examples/CMakeLists.txt index 59fa390399d..13956fe0a10 100644 --- a/libmysqld/examples/CMakeLists.txt +++ b/libmysqld/examples/CMakeLists.txt @@ -23,11 +23,11 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include # Currently does not work with DBUG, there are missing symbols reported. ADD_DEFINITIONS(-DDBUG_OFF) ADD_DEFINITIONS(-DUSE_TLS) -ADD_EXECUTABLE(test_libmysqld ../../client/completion_hash.cc +ADD_EXECUTABLE(mysql_embedded ../../client/completion_hash.cc ../../client/mysql.cc ../../client/readline.cc ../../client/sql_string.cc) -TARGET_LINK_LIBRARIES(test_libmysqld mysys yassl taocrypt zlib dbug regex strings wsock32) -ADD_DEPENDENCIES(test_libmysqld libmysqld) +TARGET_LINK_LIBRARIES(mysql_embedded mysys yassl taocrypt zlib dbug regex strings wsock32) +ADD_DEPENDENCIES(mysql_embedded libmysqld) ADD_EXECUTABLE(mysqltest_embedded ../../client/mysqltest.c) TARGET_LINK_LIBRARIES(mysqltest_embedded mysys yassl taocrypt zlib dbug regex strings wsock32) diff --git a/libmysqld/examples/Makefile.am b/libmysqld/examples/Makefile.am index ec5bbbb86e5..4a91724afee 100644 --- a/libmysqld/examples/Makefile.am +++ b/libmysqld/examples/Makefile.am @@ -19,6 +19,7 @@ client_sources = $(mysqltest_embedded_SOURCES) $(mysql_SOURCES) tests_sources = $(mysql_client_test_embedded_SOURCES) BUILT_SOURCES = link_sources CLEANFILES = $(client_sources) $(tests_sources) $(BUILT_SOURCES) +EXTRA_DIST = CMakeLists.txt link_sources: for f in $(client_sources); do \ diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 1effa7c878d..dba463bb0d2 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -693,6 +693,37 @@ sub command_line_setup () { $glob_timers= mtr_init_timers(); + # -------------------------------------------------------------------------- + # Embedded server flag + # -------------------------------------------------------------------------- + if ( $opt_embedded_server ) + { + $glob_use_embedded_server= 1; + # Add the location for libmysqld.dll to the path. + if ( $glob_win32 ) + { + my $lib_mysqld= + mtr_path_exists(vs_config_dirs('libmysqld','')); + $lib_mysqld= $glob_cygwin_perl ? ":".`cygpath "$lib_mysqld"` + : ";".$lib_mysqld; + chomp($lib_mysqld); + $ENV{'PATH'}="$ENV{'PATH'}".$lib_mysqld; + } + + push(@glob_test_mode, "embedded"); + $opt_skip_rpl= 1; # We never run replication with embedded + $opt_skip_ndbcluster= 1; # Turn off use of NDB cluster + $opt_skip_ssl= 1; # Turn off use of SSL + + # Turn off use of bin log + push(@opt_extra_mysqld_opt, "--skip-log-bin"); + + if ( $opt_extern ) + { + mtr_error("Can't use --extern with --embedded-server"); + } + } + # # Find the mysqld executable to be able to find the mysqld version # number as early as possible diff --git a/win/README b/win/README index afa4bd65163..d4b6ee1e3df 100644 --- a/win/README +++ b/win/README @@ -65,6 +65,8 @@ The options right now are: EMBED_MANIFESTS Embed custom manifests into final exes, otherwise VS default will be used. (Note - This option should only be used by MySQL AB.) + EMBEDDED_ONLY Configure solution to produce libmysqld.dll + default will be used. So the command line could look like: @@ -98,3 +100,16 @@ may be necessary to clean the build tree to remove any stale objects. Please see this link: http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/ At step 5 you only need to add the libraries advapi32.lib and user32.lib to the file "corewin_express.vsprops" in order to avoid link errors. + +3. Testing the Windows embedded library requires a two step process. The extra +step is necessary because the testsuite requires mysqld to run properly but both +the embedded library and the mysqld executable cannot be built at the same time. +Here's the process for building and testing the embedded library: + + A. Follow steps 1 - 7 listed above to produce the Release configuration. + B. Perform step 5 from above again adding "--EMBEDDED-ONLY" to previously + supplied options. + C. Complete the build steps above to produce the Release configuration. Make + sure to Rebuild the solution so that all libraries are re-built. + D. Run the testsuite as usual. + From 29bd01e6c11c0d9df7f556f157b1b00e06306f60 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 21:51:37 +0200 Subject: [PATCH 44/74] CMakeLists.txt, README, configure.js Several adjustments to make client libraries pass the link test on both win32 and winx64, Visual Studio 2003 and 2005 (bug#30118) win/README: - Removed references to PARTITION engine, 5.1 only win/configure.js: - Removed references to PARTITION engine, 5.1 only extra/CMakeLists.txt: Use the special 'debug' list element to mark that "dbug" library is only to be linked against if build type "Debug". myisam/CMakeLists.txt: Use the special 'debug' list element to mark that "dbug" library is only to be linked against if build type "Debug". scripts/CMakeLists.txt: Use the special 'debug' list element to mark that "dbug" library is only to be linked against if build type "Debug". server-tools/instance-manager/CMakeLists.txt: Use the special 'debug' list element to mark that "dbug" library is only to be linked against if build type "Debug". sql/CMakeLists.txt: Use the special 'debug' list element to mark that "dbug" library is only to be linked against if build type "Debug". mysys/CMakeLists.txt: Restored include path to "mysys" itself dbug/CMakeLists.txt: Changed to optionally be included to give a file list only extra/yassl/CMakeLists.txt: Changed to optionally be included to give a file list only extra/yassl/taocrypt/CMakeLists.txt: Changed to optionally be included to give a file list only zlib/CMakeLists.txt: Changed to optionally be included to give a file list only libmysql/CMakeLists.txt: For compatibility with Visual Studio 2005, list all files that are to be part of the library build, i.e. libraries can't be built from other libraries. Set SOURCE_SUBLIBS and include the file listings from "zlib", "dbug", "taocrypt" and "yassl" --- CMakeLists.txt | 90 ++++++++------------ dbug/CMakeLists.txt | 11 ++- extra/CMakeLists.txt | 8 +- extra/yassl/CMakeLists.txt | 12 ++- extra/yassl/taocrypt/CMakeLists.txt | 8 +- libmysql/CMakeLists.txt | 56 +++++++++--- myisam/CMakeLists.txt | 8 +- mysys/CMakeLists.txt | 3 +- scripts/CMakeLists.txt | 2 +- server-tools/instance-manager/CMakeLists.txt | 2 +- sql/CMakeLists.txt | 2 +- win/README | 3 +- win/configure.js | 1 - zlib/CMakeLists.txt | 9 +- 14 files changed, 118 insertions(+), 97 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3703548ebc3..f4b97315ce0 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,53 +22,38 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/mysql_version.h.in ${CMAKE_SOURCE_DIR}/include/mysql_version.h @ONLY) # Set standard options -ADD_DEFINITIONS(-D WITH_MYISAM_STORAGE_ENGINE) ADD_DEFINITIONS(-D CMAKE_BUILD) ADD_DEFINITIONS(-D HAVE_YASSL) # Set debug options SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DFORCE_INIT_OF_VARS") -SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DFORCE_INIT_OF_VARS") - -SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_myisam_plugin") +# Note that some engines are always compiled in, MyISAM, MyISAMMRG, HEAP IF(WITH_ARCHIVE_STORAGE_ENGINE) ADD_DEFINITIONS(-D HAVE_ARCHIVE_DB) ENDIF(WITH_ARCHIVE_STORAGE_ENGINE) -IF (WITH_HEAP_STORAGE_ENGINE) - ADD_DEFINITIONS(-D WITH_HEAP_STORAGE_ENGINE) - SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_heap_plugin") -ENDIF (WITH_HEAP_STORAGE_ENGINE) - -IF (WITH_MYISAMMRG_STORAGE_ENGINE) - ADD_DEFINITIONS(-D WITH_MYISAMMRG_STORAGE_ENGINE) - SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_myisammrg_plugin") -ENDIF (WITH_MYISAMMRG_STORAGE_ENGINE) - -IF(WITH_INNOBASE_STORAGE_ENGINE) - ADD_DEFINITIONS(-D HAVE_INNOBASE_DB) - ADD_DEFINITIONS(-D WITH_INNOBASE_STORAGE_ENGINE) - SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_innobase_plugin") -ENDIF(WITH_INNOBASE_STORAGE_ENGINE) - -IF(WITH_FEDERATED_STORAGE_ENGINE) - ADD_DEFINITIONS(-D HAVE_FEDERATED_DB) - ADD_DEFINITIONS(-D WITH_FEDERATED_STORAGE_ENGINE) - SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_federated_plugin") -ENDIF(WITH_FEDERATED_STORAGE_ENGINE) - IF(WITH_BERKELEY_STORAGE_ENGINE) ADD_DEFINITIONS(-D HAVE_BERKELEY_DB) - ADD_DEFINITIONS(-D WITH_BERKELEY_STORAGE_ENGINE) - SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_berkeley_plugin") ENDIF(WITH_BERKELEY_STORAGE_ENGINE) IF (WITH_BLACKHOLE_STORAGE_ENGINE) ADD_DEFINITIONS(-D HAVE_BLACKHOLE_DB) ENDIF (WITH_BLACKHOLE_STORAGE_ENGINE) +IF(WITH_EXAMPLE_STORAGE_ENGINE) + ADD_DEFINITIONS(-D HAVE_EXAMPLE_DB) +ENDIF(WITH_EXAMPLE_STORAGE_ENGINE) + +IF(WITH_FEDERATED_STORAGE_ENGINE) + ADD_DEFINITIONS(-D HAVE_FEDERATED_DB) +ENDIF(WITH_FEDERATED_STORAGE_ENGINE) + +IF(WITH_INNOBASE_STORAGE_ENGINE) + ADD_DEFINITIONS(-D HAVE_INNOBASE_DB) +ENDIF(WITH_INNOBASE_STORAGE_ENGINE) + SET(localstatedir "C:\\mysql\\data") CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-huge.cnf.sh ${CMAKE_SOURCE_DIR}/support-files/my-huge.ini @ONLY) @@ -102,37 +87,28 @@ ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 8") IF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR CMAKE_GENERATOR MATCHES "Visual Studio 8") - # replace /MDd with /MTd - STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG_INIT - ${CMAKE_CXX_FLAGS_DEBUG_INIT}) - STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG_INIT - ${CMAKE_C_FLAGS_DEBUG_INIT}) - STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE - ${CMAKE_C_FLAGS_RELEASE}) - STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELWITHDEBINFO - ${CMAKE_C_FLAGS_RELWITHDEBINFO}) - STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG - ${CMAKE_C_FLAGS_DEBUG}) - STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE - ${CMAKE_CXX_FLAGS_RELEASE}) - STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO - ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}) - STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG - ${CMAKE_CXX_FLAGS_DEBUG}) - # generate map files - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MAP /MAPINFO:EXPORTS") + # replace /MDd with /MTd + STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) + STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO}) + STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) + STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG_INIT ${CMAKE_C_FLAGS_DEBUG_INIT}) - # set stack size (see bug#20815) - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:1048576") + STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) + STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}) + STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) + STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG_INIT ${CMAKE_CXX_FLAGS_DEBUG_INIT}) + + # generate map files, set stack size (see bug#20815) + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MAP /MAPINFO:EXPORTS") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:1048576") + + # remove support for Exception handling + STRING(REPLACE "/GX" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) + STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) + STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_INIT ${CMAKE_CXX_FLAGS_INIT}) + STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_DEBUG_INIT ${CMAKE_CXX_FLAGS_DEBUG_INIT}) - # remove support for Exception handling - STRING(REPLACE "/GX" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) - STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) - STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_INIT - ${CMAKE_CXX_FLAGS_INIT}) - STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_DEBUG_INIT - ${CMAKE_CXX_FLAGS_DEBUG_INIT}) ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR CMAKE_GENERATOR MATCHES "Visual Studio 8") @@ -196,6 +172,8 @@ IF(EMBED_MANIFESTS) ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64") ENDIF(EMBED_MANIFESTS) +# FIXME "debug" only needed if build type is "Debug", but +# CMAKE_BUILD_TYPE is not set during configure time. ADD_SUBDIRECTORY(vio) ADD_SUBDIRECTORY(dbug) ADD_SUBDIRECTORY(strings) diff --git a/dbug/CMakeLists.txt b/dbug/CMakeLists.txt index 34f44f9a720..8b27f79dcf4 100755 --- a/dbug/CMakeLists.txt +++ b/dbug/CMakeLists.txt @@ -13,7 +13,12 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/dbug) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) -ADD_LIBRARY(dbug dbug.c factorial.c sanity.c) +SET(DBUG_SOURCES dbug.c factorial.c sanity.c) + +IF(NOT SOURCE_SUBLIBS) + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) + ADD_LIBRARY(dbug ${DBUG_SOURCES}) +ENDIF(NOT SOURCE_SUBLIBS) diff --git a/extra/CMakeLists.txt b/extra/CMakeLists.txt index 8608e72127b..a909bc93820 100755 --- a/extra/CMakeLists.txt +++ b/extra/CMakeLists.txt @@ -20,7 +20,7 @@ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) ADD_EXECUTABLE(comp_err comp_err.c) -TARGET_LINK_LIBRARIES(comp_err dbug mysys strings zlib wsock32) +TARGET_LINK_LIBRARIES(comp_err debug dbug mysys strings zlib wsock32) GET_TARGET_PROPERTY(COMP_ERR_EXE comp_err LOCATION) @@ -39,13 +39,13 @@ ADD_CUSTOM_TARGET(GenError DEPENDS ${PROJECT_SOURCE_DIR}/include/mysqld_error.h) ADD_EXECUTABLE(my_print_defaults my_print_defaults.c) -TARGET_LINK_LIBRARIES(my_print_defaults strings mysys dbug taocrypt wsock32) +TARGET_LINK_LIBRARIES(my_print_defaults strings mysys debug dbug taocrypt wsock32) ADD_EXECUTABLE(perror perror.c) -TARGET_LINK_LIBRARIES(perror strings mysys dbug wsock32) +TARGET_LINK_LIBRARIES(perror strings mysys debug dbug wsock32) ADD_EXECUTABLE(replace replace.c) -TARGET_LINK_LIBRARIES(replace strings mysys dbug wsock32) +TARGET_LINK_LIBRARIES(replace strings mysys debug dbug wsock32) IF(EMBED_MANIFESTS) MYSQL_EMBED_MANIFEST("my_print_defaults" "asInvoker") diff --git a/extra/yassl/CMakeLists.txt b/extra/yassl/CMakeLists.txt index 5cc97f22a36..26e682cbb0c 100755 --- a/extra/yassl/CMakeLists.txt +++ b/extra/yassl/CMakeLists.txt @@ -13,9 +13,15 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -ADD_DEFINITIONS("-DWIN32 -D_LIB -DYASSL_PREFIX") +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/extra/yassl/include + ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/include + ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL) -INCLUDE_DIRECTORIES(include taocrypt/include taocrypt/mySTL) -ADD_LIBRARY(yassl src/buffer.cpp src/cert_wrapper.cpp src/crypto_wrapper.cpp src/handshake.cpp src/lock.cpp +ADD_DEFINITIONS("-D_LIB -DYASSL_PREFIX") + +SET(YASSL_SOURCES src/buffer.cpp src/cert_wrapper.cpp src/crypto_wrapper.cpp src/handshake.cpp src/lock.cpp src/log.cpp src/socket_wrapper.cpp src/ssl.cpp src/timer.cpp src/yassl_error.cpp src/yassl_imp.cpp src/yassl_int.cpp) +IF(NOT SOURCE_SUBLIBS) + ADD_LIBRARY(yassl ${YASSL_SOURCES}) +ENDIF(NOT SOURCE_SUBLIBS) diff --git a/extra/yassl/taocrypt/CMakeLists.txt b/extra/yassl/taocrypt/CMakeLists.txt index baa8f97dff6..e91fa021de5 100755 --- a/extra/yassl/taocrypt/CMakeLists.txt +++ b/extra/yassl/taocrypt/CMakeLists.txt @@ -13,9 +13,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -INCLUDE_DIRECTORIES(mySTL include) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL + ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/include) -ADD_LIBRARY(taocrypt src/aes.cpp src/aestables.cpp src/algebra.cpp src/arc4.cpp src/asn.cpp src/coding.cpp +SET(TAOCRYPT_SOURCES src/aes.cpp src/aestables.cpp src/algebra.cpp src/arc4.cpp src/asn.cpp src/coding.cpp src/des.cpp src/dh.cpp src/dsa.cpp src/file.cpp src/hash.cpp src/integer.cpp src/md2.cpp src/md4.cpp src/md5.cpp src/misc.cpp src/random.cpp src/ripemd.cpp src/rsa.cpp src/sha.cpp include/aes.hpp include/algebra.hpp include/arc4.hpp include/asn.hpp include/block.hpp @@ -23,3 +24,6 @@ ADD_LIBRARY(taocrypt src/aes.cpp src/aestables.cpp src/algebra.cpp src/arc4.cpp include/error.hpp include/file.hpp include/hash.hpp include/hmac.hpp include/integer.hpp include/md2.hpp include/md5.hpp include/misc.hpp include/modarith.hpp include/modes.hpp include/random.hpp include/ripemd.hpp include/rsa.hpp include/sha.hpp) +IF(NOT SOURCE_SUBLIBS) + ADD_LIBRARY(taocrypt ${TAOCRYPT_SOURCES}) +ENDIF(NOT SOURCE_SUBLIBS) diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index c659c36117a..59e70d68a6d 100755 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -24,13 +24,43 @@ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") # have been a problem anyway, they don't use thread local storage. INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include - ${CMAKE_SOURCE_DIR}/zlib - ${CMAKE_SOURCE_DIR}/extra/yassl/include ${CMAKE_SOURCE_DIR}/libmysql ${CMAKE_SOURCE_DIR}/regex ${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/strings) +# We include the source file listing instead of referencing the +# libraries. At least with CMake 2.4 and Visual Studio 2005 a static +# library created from other static libraries would not be complete, +# i.e. the libraries listed in TARGET_LINK_LIBRARIES() were just +# ignored. + + +# Include and add the directory path +SET(SOURCE_SUBLIBS TRUE) + +INCLUDE(${CMAKE_SOURCE_DIR}/zlib/CMakeLists.txt) +FOREACH(rpath ${ZLIB_SOURCES}) + SET(LIB_SOURCES ${LIB_SOURCES} ../zlib/${rpath}) +ENDFOREACH(rpath) + +# FIXME only needed if build type is "Debug", but CMAKE_BUILD_TYPE is +# not set during configure time. +INCLUDE(${CMAKE_SOURCE_DIR}/dbug/CMakeLists.txt) +FOREACH(rpath ${DBUG_SOURCES}) + SET(LIB_SOURCES ${LIB_SOURCES} ../dbug/${rpath}) +ENDFOREACH(rpath) + +INCLUDE(${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/CMakeLists.txt) +FOREACH(rpath ${TAOCRYPT_SOURCES}) + SET(LIB_SOURCES ${LIB_SOURCES} ../extra/yassl/taocrypt/${rpath}) +ENDFOREACH(rpath) + +INCLUDE(${CMAKE_SOURCE_DIR}/extra/yassl/CMakeLists.txt) +FOREACH(rpath ${YASSL_SOURCES}) + SET(LIB_SOURCES ${LIB_SOURCES} ../extra/yassl/${rpath}) +ENDFOREACH(rpath) + SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c ../strings/bmove_upp.c ../mysys/charset-def.c ../mysys/charset.c ../sql-common/client.c ../strings/ctype-big5.c ../strings/ctype-bin.c @@ -66,7 +96,8 @@ SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c ../strings/strmov.c ../strings/strnlen.c ../strings/strnmov.c ../strings/strtod.c ../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c ../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c - ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c) + ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c + ${LIB_SOURCES}) # Need to set USE_TLS for building the DLL, since __declspec(thread) # approach to thread local storage does not work properly in DLLs. @@ -79,23 +110,20 @@ SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c # beond the documented API, and try access the Thread Local Storage. # The "_notls" means no Tls*() functions used, i.e. "static" TLS. -ADD_LIBRARY(libmysql SHARED dll.c libmysql.def ${CLIENT_SOURCES}) -ADD_LIBRARY(mysqlclient STATIC ${CLIENT_SOURCES}) +ADD_LIBRARY(libmysql SHARED ${CLIENT_SOURCES} dll.c libmysql.def) +ADD_LIBRARY(mysqlclient STATIC ${CLIENT_SOURCES}) ADD_LIBRARY(mysqlclient_notls STATIC ${CLIENT_SOURCES}) SET_TARGET_PROPERTIES(libmysql mysqlclient PROPERTIES COMPILE_FLAGS "-DUSE_TLS") -SET(CLIENT_LIB_DEPS yassl taocrypt zlib dbug GenError) -SET(CLIENT_LIBS yassl taocrypt zlib debug dbug) +ADD_DEPENDENCIES(libmysql GenError) +TARGET_LINK_LIBRARIES(libmysql wsock32) -ADD_DEPENDENCIES(libmysql ${CLIENT_LIB_DEPS}) -TARGET_LINK_LIBRARIES(libmysql ${CLIENT_LIBS} wsock32) +ADD_DEPENDENCIES(mysqlclient GenError) +TARGET_LINK_LIBRARIES(mysqlclient) -ADD_DEPENDENCIES(mysqlclient ${CLIENT_LIB_DEPS}) -TARGET_LINK_LIBRARIES(mysqlclient ${CLIENT_LIBS}) - -ADD_DEPENDENCIES(mysqlclient_notls ${CLIENT_LIB_DEPS}) -TARGET_LINK_LIBRARIES(mysqlclient_notls ${CLIENT_LIBS}) +ADD_DEPENDENCIES(mysqlclient_notls GenError) +TARGET_LINK_LIBRARIES(mysqlclient_notls) ADD_EXECUTABLE(myTest mytest.c) TARGET_LINK_LIBRARIES(myTest libmysql) diff --git a/myisam/CMakeLists.txt b/myisam/CMakeLists.txt index 94a7ffc9952..a557d61b87f 100755 --- a/myisam/CMakeLists.txt +++ b/myisam/CMakeLists.txt @@ -30,16 +30,16 @@ ADD_LIBRARY(myisam ft_boolean_search.c ft_nlq_search.c ft_parser.c ft_static.c f rt_split.c sort.c sp_key.c ft_eval.h myisamdef.h rt_index.h mi_rkey.c) ADD_EXECUTABLE(myisam_ftdump myisam_ftdump.c) -TARGET_LINK_LIBRARIES(myisam_ftdump myisam mysys dbug strings zlib wsock32) +TARGET_LINK_LIBRARIES(myisam_ftdump myisam mysys debug dbug strings zlib wsock32) ADD_EXECUTABLE(myisamchk myisamchk.c) -TARGET_LINK_LIBRARIES(myisamchk myisam mysys dbug strings zlib wsock32) +TARGET_LINK_LIBRARIES(myisamchk myisam mysys debug dbug strings zlib wsock32) ADD_EXECUTABLE(myisamlog myisamlog.c) -TARGET_LINK_LIBRARIES(myisamlog myisam mysys dbug strings zlib wsock32) +TARGET_LINK_LIBRARIES(myisamlog myisam mysys debug dbug strings zlib wsock32) ADD_EXECUTABLE(myisampack myisampack.c) -TARGET_LINK_LIBRARIES(myisampack myisam mysys dbug strings zlib wsock32) +TARGET_LINK_LIBRARIES(myisampack myisam mysys debug dbug strings zlib wsock32) IF(EMBED_MANIFESTS) MYSQL_EMBED_MANIFEST("myisam_ftdump" "asInvoker") diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 4c11b57d736..8aaf0b5f00f 100755 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -13,7 +13,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") # Only the server link with this library, the client libraries and the client @@ -21,7 +20,7 @@ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") # So we only need to create one version of this library, with the "static" # Thread Local Storage model. -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys ) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys) ADD_LIBRARY(mysys array.c charset-def.c charset.c checksum.c default.c default_modify.c errors.c hash.c list.c md5.c mf_brkhant.c mf_cache.c mf_dirname.c mf_fn_ext.c diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index e9113b098da..6fbfcab72d4 100755 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -24,7 +24,7 @@ ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tabl # Build comp_sql - used for embedding SQL in C or C++ programs ADD_EXECUTABLE(comp_sql comp_sql.c) -TARGET_LINK_LIBRARIES(comp_sql dbug mysys strings) +TARGET_LINK_LIBRARIES(comp_sql debug dbug mysys strings) # Use comp_sql to build mysql_fix_privilege_tables_sql.c GET_TARGET_PROPERTY(COMP_SQL_EXE comp_sql LOCATION) diff --git a/server-tools/instance-manager/CMakeLists.txt b/server-tools/instance-manager/CMakeLists.txt index b7e2f08ff6e..1452cdaf20b 100755 --- a/server-tools/instance-manager/CMakeLists.txt +++ b/server-tools/instance-manager/CMakeLists.txt @@ -30,7 +30,7 @@ ADD_EXECUTABLE(mysqlmanager buffer.cc command.cc commands.cc guardian.cc instanc ../../libmysql/errmsg.c) ADD_DEPENDENCIES(mysqlmanager GenError) -TARGET_LINK_LIBRARIES(mysqlmanager dbug mysys strings taocrypt vio yassl zlib wsock32) +TARGET_LINK_LIBRARIES(mysqlmanager debug dbug mysys strings taocrypt vio yassl zlib wsock32) IF(EMBED_MANIFESTS) MYSQL_EMBED_MANIFEST("mysqlmanager" "asInvoker") diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 735b930168d..0c4aeaf6043 100755 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -84,7 +84,7 @@ ADD_EXECUTABLE(mysqld${MYSQLD_EXE_SUFFIX} ${PROJECT_SOURCE_DIR}/sql/lex_hash.h) TARGET_LINK_LIBRARIES(mysqld${MYSQLD_EXE_SUFFIX} - heap myisam myisammrg mysys yassl zlib dbug yassl + heap myisam myisammrg mysys yassl zlib debug dbug yassl taocrypt strings vio regex wsock32) IF(EMBED_MANIFESTS) diff --git a/win/README b/win/README index d13f37965c1..cfc3cc9ef6f 100644 --- a/win/README +++ b/win/README @@ -37,7 +37,6 @@ From the root of your bk clone, execute the command: win\configure . The options right now are WITH_INNOBASE_STORAGE_ENGINE Enable particular storage engines - WITH_PARTITION_STORAGE_ENGINE WITH_ARCHIVE_STORAGE_ENGINE WITH_BERKELEY_STORAGE_ENGINE WITH_BLACKHOLE_STORAGE_ENGINE @@ -57,7 +56,7 @@ The options right now are So the command line could look like: -win\configure WITH_INNOBASE_STORAGE_ENGINE WITH_PARTITION_STORAGE_ENGINE MYSQL_SERVER_SUFFIX=-pro +win\configure WITH_INNOBASE_STORAGE_ENGINE WITH_ARCHIVE_STORAGE_ENGINE MYSQL_SERVER_SUFFIX=-my-suffix Step 5 ------ diff --git a/win/configure.js b/win/configure.js index 7cdf6176e50..1408dba9aea 100755 --- a/win/configure.js +++ b/win/configure.js @@ -44,7 +44,6 @@ try case "WITH_EXAMPLE_STORAGE_ENGINE": case "WITH_FEDERATED_STORAGE_ENGINE": case "WITH_INNOBASE_STORAGE_ENGINE": - case "WITH_PARTITION_STORAGE_ENGINE": case "__NT__": case "DISABLE_GRANT_OPTIONS": case "EMBED_MANIFESTS": diff --git a/zlib/CMakeLists.txt b/zlib/CMakeLists.txt index 123b7f6ec7f..43235b631f6 100755 --- a/zlib/CMakeLists.txt +++ b/zlib/CMakeLists.txt @@ -18,10 +18,13 @@ # Not directly and indirectly using any of the macros for creating and # using the storage, pthread_key*(), {,my_}{set,get}_specific*() .... -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/zlib) + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") -ADD_LIBRARY(zlib adler32.c compress.c crc32.c crc32.h deflate.c deflate.h gzio.c infback.c inffast.c inffast.h +SET(ZLIB_SOURCES adler32.c compress.c crc32.c crc32.h deflate.c deflate.h gzio.c infback.c inffast.c inffast.h inffixed.h inflate.c inflate.h inftrees.c inftrees.h trees.c trees.h uncompr.c zconf.h zlib.h zutil.c zutil.h) - \ No newline at end of file +IF(NOT SOURCE_SUBLIBS) + ADD_LIBRARY(zlib ${ZLIB_SOURCES}) +ENDIF(NOT SOURCE_SUBLIBS) From f2204146721cd2257ccc1f5954db680aa58b06ed Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 22:02:19 +0200 Subject: [PATCH 45/74] after-merge fix sql/table.cc: do not attempt to set no_replicate if OPEN_FRM_FILE_ONLY was set --- sql/table.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/table.cc b/sql/table.cc index 8eb1da9cad1..12fffe1dde7 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1878,7 +1878,8 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, bzero((char*) bitmaps, bitmap_size*3); #endif - outparam->no_replicate= test(outparam->file->ha_table_flags() & + outparam->no_replicate= outparam->file && + test(outparam->file->ha_table_flags() & HA_HAS_OWN_BINLOGGING); thd->status_var.opened_tables++; From edc99e12b452b754cd7ac505a503a757e840f31c Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 4 Aug 2007 00:26:46 +0200 Subject: [PATCH 46/74] CMakeLists.txt: Removed space between '-D' and symbol CMakeLists.txt: Removed space between '-D' and symbol --- CMakeLists.txt | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f4b97315ce0..e2fb39fee9a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,8 +22,8 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/mysql_version.h.in ${CMAKE_SOURCE_DIR}/include/mysql_version.h @ONLY) # Set standard options -ADD_DEFINITIONS(-D CMAKE_BUILD) -ADD_DEFINITIONS(-D HAVE_YASSL) +ADD_DEFINITIONS(-DCMAKE_BUILD) +ADD_DEFINITIONS(-DHAVE_YASSL) # Set debug options SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DFORCE_INIT_OF_VARS") @@ -31,27 +31,27 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DFORCE_INIT_OF_VARS") # Note that some engines are always compiled in, MyISAM, MyISAMMRG, HEAP IF(WITH_ARCHIVE_STORAGE_ENGINE) - ADD_DEFINITIONS(-D HAVE_ARCHIVE_DB) + ADD_DEFINITIONS(-DHAVE_ARCHIVE_DB) ENDIF(WITH_ARCHIVE_STORAGE_ENGINE) IF(WITH_BERKELEY_STORAGE_ENGINE) - ADD_DEFINITIONS(-D HAVE_BERKELEY_DB) + ADD_DEFINITIONS(-DHAVE_BERKELEY_DB) ENDIF(WITH_BERKELEY_STORAGE_ENGINE) IF (WITH_BLACKHOLE_STORAGE_ENGINE) - ADD_DEFINITIONS(-D HAVE_BLACKHOLE_DB) + ADD_DEFINITIONS(-DHAVE_BLACKHOLE_DB) ENDIF (WITH_BLACKHOLE_STORAGE_ENGINE) IF(WITH_EXAMPLE_STORAGE_ENGINE) - ADD_DEFINITIONS(-D HAVE_EXAMPLE_DB) + ADD_DEFINITIONS(-DHAVE_EXAMPLE_DB) ENDIF(WITH_EXAMPLE_STORAGE_ENGINE) IF(WITH_FEDERATED_STORAGE_ENGINE) - ADD_DEFINITIONS(-D HAVE_FEDERATED_DB) + ADD_DEFINITIONS(-DHAVE_FEDERATED_DB) ENDIF(WITH_FEDERATED_STORAGE_ENGINE) IF(WITH_INNOBASE_STORAGE_ENGINE) - ADD_DEFINITIONS(-D HAVE_INNOBASE_DB) + ADD_DEFINITIONS(-DHAVE_INNOBASE_DB) ENDIF(WITH_INNOBASE_STORAGE_ENGINE) SET(localstatedir "C:\\mysql\\data") @@ -67,14 +67,14 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-small.cnf.sh ${CMAKE_SOURCE_DIR}/support-files/my-small.ini @ONLY) IF(__NT__) - ADD_DEFINITIONS(-D __NT__) + ADD_DEFINITIONS(-D__NT__) ENDIF(__NT__) # in some places we use DBUG_OFF -SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D DBUG_OFF") -SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -D DBUG_OFF") -SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D DBUG_OFF") -SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -D DBUG_OFF") +SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDBUG_OFF") +SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDBUG_OFF") +SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DDBUG_OFF") +SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DDBUG_OFF") IF(CMAKE_GENERATOR MATCHES "Visual Studio 8") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /wd4996") @@ -112,7 +112,7 @@ IF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR CMAKE_GENERATOR MATCHES "Visual Studio 8") -ADD_DEFINITIONS("-D_WINDOWS -D__WIN__ -D _CRT_SECURE_NO_DEPRECATE") +ADD_DEFINITIONS("-D_WINDOWS -D__WIN__ -D_CRT_SECURE_NO_DEPRECATE") IF(EMBED_MANIFESTS) # Search for the tools (mt, makecat, signtool) necessary for embedding From 21792097899511211e82d22daa2e8cbe5008bd37 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 18:56:24 -0400 Subject: [PATCH 47/74] Bug#29903 The CMake build method does not produce the embedded library. - Additional changes to correct link failure in Do-linkall script. libmysqld/libmysqld.def: Bug#29903 The CMake build method does not produce the embedded library. - Missing exports. --- libmysqld/libmysqld.def | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libmysqld/libmysqld.def b/libmysqld/libmysqld.def index c1025cd3846..78ff08e510a 100644 --- a/libmysqld/libmysqld.def +++ b/libmysqld/libmysqld.def @@ -1,6 +1,6 @@ LIBRARY LIBMYSQLD -DESCRIPTION 'MySQL 5.0 Embedded Server Library' -VERSION 5.0 +DESCRIPTION 'MySQL 5.1 Embedded Server Library' +VERSION 5.1 EXPORTS _dig_vec_upper _dig_vec_lower @@ -48,6 +48,7 @@ EXPORTS mysql_errno mysql_error mysql_escape_string + mysql_hex_string mysql_fetch_field mysql_fetch_field_direct mysql_fetch_fields @@ -62,11 +63,13 @@ EXPORTS mysql_get_host_info mysql_get_proto_info mysql_get_server_info + mysql_get_client_version mysql_get_ssl_cipher mysql_info mysql_init mysql_insert_id mysql_kill + mysql_set_server_option mysql_list_dbs mysql_list_fields mysql_list_processes @@ -172,4 +175,3 @@ EXPORTS my_charset_bin my_charset_same modify_defaults_file - mysql_set_server_option From ac107ac16ae28fa8ec293e234e43fc6f04b67590 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 21:08:48 -0400 Subject: [PATCH 48/74] Bug#29903 The CMake build method does not produce the embedded library. - GCov fix. mysql-test/r/mysql.result: Bug#29903 The CMake build method does not produce the embedded library. -Result mysql-test/t/mysql.test: Bug#29903 The CMake build method does not produce the embedded library. - Test for warning message. --- mysql-test/r/mysql.result | 1 + mysql-test/t/mysql.test | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index 57e1f2e4ef6..f5b369f246a 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -177,3 +177,4 @@ ERROR at line 1: DELIMITER cannot contain a backslash character 1 1 End of 5.0 tests +WARNING: --server-arg option not supported in this configuration. diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index e7131efa0f3..16f5fecf051 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -275,3 +275,10 @@ EOF --exec $MYSQL --character-sets-dir="540bytelengthstringxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -e "select 1" 2>&1 --echo End of 5.0 tests + +# +# Bug #29903: The CMake build method does not produce the embedded library. +# +--disable_query_log +--exec $MYSQL --server-arg=no-defaults test -e "quit" +--enable_query_log From b77248f6c5d45bd4fe4505b82a20d491bd83e2da Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 21:10:57 -0700 Subject: [PATCH 49/74] Fixed a memory leak in the patch for bug 28404. --- sql/sql_select.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 6d5577c2713..3de5b3b76ac 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -12911,8 +12911,11 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, { tab->ref.key= -1; tab->ref.key_parts= 0; - if (tab->select) - tab->select->quick= 0; + if (select && select->quick) + { + delete select->quick; + select->quick= 0; + } if (select_limit < table_records) tab->limit= select_limit; } From 06cb99ca5aab1a2b1aa65990ef0ddda6e34509ec Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 4 Aug 2007 02:51:58 -0400 Subject: [PATCH 50/74] Post Merge Fixup. --- CMakeLists.txt | 37 ++++++++++++++++++------------------- libmysql/CMakeLists.txt | 28 ++++++++++++++-------------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 49a71867952..76d1bdb5921 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,22 +18,24 @@ PROJECT(MySql) # This reads user configuration, generated by configure.js. INCLUDE(win/configure.data) -# By default, CMake will create Release, Debug, RelWithDebInfo and MinSizeRel -# configurations. The EMBEDDED_ONLY build parameter is necessary because CMake -# doesn't support custom build configurations for VS2005. Since the Debug -# configuration does not work properly with USE_TLS defined -# (see mysys/CMakeLists.txt) the easiest way to debug the Embedded Server is to -# use the RelWithDebInfo configuration without optimizations. -# -# Debug default CXX_FLAGS "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1" -# RelWithDebInfo default CXX_FLAGS "/MD /Zi /O2 /Ob1 /D NDEBUG" -# -IF(NOT EMBEDDED_ONLY) - # Hardcode support for CSV storage engine - SET(WITH_CSV_STORAGE_ENGINE TRUE) -ELSE(NOT EMBEDDED_ONLY) +# Hardcode support for CSV storage engine +SET(WITH_CSV_STORAGE_ENGINE TRUE) + +# CMAKE will not allow custom VS7+ configurations. mysqld and libmysqld +# cannot be built at the same time as they require different configurations +IF(EMBEDDED_ONLY) + ADD_DEFINITIONS(-DEMBEDDED_LIBRARY) + # By default, CMake will create Release, Debug, RelWithDebInfo and MinSizeRel + # configurations. The EMBEDDED_ONLY build parameter is necessary because CMake + # doesn't support custom build configurations for VS2005. Since the Debug + # configuration does not work properly with USE_TLS defined + # (see mysys/CMakeLists.txt) the easiest way to debug the Embedded Server is to + # use the RelWithDebInfo configuration without optimizations. + # + # Debug default CXX_FLAGS "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1" + # RelWithDebInfo default CXX_FLAGS "/MD /Zi /O2 /Ob1 /D NDEBUG" SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /Zi /Od /Ob0 /D NDEBUG" CACHE STRING "No Optimization" FORCE) -ENDIF(NOT EMBEDDED_ONLY) +ENDIF(EMBEDDED_ONLY) CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/mysql_version.h.in ${CMAKE_SOURCE_DIR}/include/mysql_version.h @ONLY) @@ -246,16 +248,13 @@ ENDIF(WITH_FEDERATED_STORAGE_ENGINE) IF(WITH_INNOBASE_STORAGE_ENGINE) ADD_SUBDIRECTORY(storage/innobase) ENDIF(WITH_INNOBASE_STORAGE_ENGINE) -# CMAKE will not allow custom VS7+ configurations. mysqld and libmysqld -# cannot be built at the same time as they require different configurations +ADD_SUBDIRECTORY(libmysql) IF(EMBEDDED_ONLY) - ADD_DEFINITIONS(-DEMBEDDED_LIBRARY) ADD_SUBDIRECTORY(libmysqld) ADD_SUBDIRECTORY(libmysqld/examples) ELSE(EMBEDDED_ONLY) ADD_SUBDIRECTORY(client) ADD_SUBDIRECTORY(sql) ADD_SUBDIRECTORY(server-tools/instance-manager) - ADD_SUBDIRECTORY(libmysql) ADD_SUBDIRECTORY(tests) ENDIF(EMBEDDED_ONLY) diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 46e651f6a64..2e6ca55e618 100755 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -110,24 +110,24 @@ SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c # beond the documented API, and try access the Thread Local Storage. # The "_notls" means no Tls*() functions used, i.e. "static" TLS. -ADD_LIBRARY(libmysql SHARED ${CLIENT_SOURCES} dll.c libmysql.def) ADD_LIBRARY(mysqlclient STATIC ${CLIENT_SOURCES}) -ADD_LIBRARY(mysqlclient_notls STATIC ${CLIENT_SOURCES}) - -SET_TARGET_PROPERTIES(libmysql mysqlclient PROPERTIES COMPILE_FLAGS "-DUSE_TLS") - -ADD_DEPENDENCIES(libmysql GenError) -TARGET_LINK_LIBRARIES(libmysql wsock32) - ADD_DEPENDENCIES(mysqlclient GenError) TARGET_LINK_LIBRARIES(mysqlclient) +ADD_LIBRARY(mysqlclient_notls STATIC ${CLIENT_SOURCES}) ADD_DEPENDENCIES(mysqlclient_notls GenError) TARGET_LINK_LIBRARIES(mysqlclient_notls) -ADD_EXECUTABLE(myTest mytest.c) -TARGET_LINK_LIBRARIES(myTest libmysql) - -IF(EMBED_MANIFESTS) - MYSQL_EMBED_MANIFEST("myTest" "asInvoker") -ENDIF(EMBED_MANIFESTS) +IF(NOT EMBEDDED_ONLY) + ADD_LIBRARY(libmysql SHARED ${CLIENT_SOURCES} dll.c libmysql.def) + SET_TARGET_PROPERTIES(libmysql mysqlclient PROPERTIES COMPILE_FLAGS "-DUSE_TLS") + ADD_DEPENDENCIES(libmysql GenError) + TARGET_LINK_LIBRARIES(libmysql wsock32) + + ADD_EXECUTABLE(myTest mytest.c) + TARGET_LINK_LIBRARIES(myTest libmysql) + + IF(EMBED_MANIFESTS) + MYSQL_EMBED_MANIFEST("myTest" "asInvoker") + ENDIF(EMBED_MANIFESTS) +ENDIF(NOT EMBEDDED_ONLY) From ac2217cb67ede63cedf1d91b8dfd0e2174a895f8 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 4 Aug 2007 03:12:43 -0700 Subject: [PATCH 51/74] Post-merge fix. --- mysql-test/r/innodb_mysql.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index bf12c31326a..c66082cae44 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -857,7 +857,7 @@ key PRIMARY key_len 4 ref NULL rows 32 -Extra Using where; Using index +Extra Using where SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY a; a b 1 2 From 81d07e8cecdbf1caaf4dd88fb3841aa7ad33afb3 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 4 Aug 2007 13:41:01 -0700 Subject: [PATCH 52/74] Made sure that the test case for bug 28404 use the correct statistics. --- mysql-test/r/order_by.result | 14 +++++++++----- mysql-test/t/order_by.test | 9 ++++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index fd3fb89b5f4..79a9bf15cbf 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -1090,21 +1090,25 @@ INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +UPDATE t1 SET c2=20 WHERE id%100 = 0; SELECT COUNT(*) FROM t1; COUNT(*) 40960 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK EXPLAIN SELECT id,c3 FROM t1 WHERE c2=11 ORDER BY c3 LIMIT 20; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index k2 k3 5 NULL 88 Using where -EXPLAIN SELECT id,c3 FROM t1 WHERE c2=11 ORDER BY c3 LIMIT 100; +EXPLAIN SELECT id,c3 FROM t1 WHERE c2=11 ORDER BY c3 LIMIT 4000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref k2 k2 5 const 9300 Using where; Using filesort -EXPLAIN SELECT id,c3 FROM t1 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 100; +EXPLAIN SELECT id,c3 FROM t1 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 20; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index k2 k3 5 NULL 316 Using where -EXPLAIN SELECT id,c3 FROM t1 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 2000; +1 SIMPLE t1 index k2 k3 5 NULL 63 Using where +EXPLAIN SELECT id,c3 FROM t1 WHERE c2 BETWEEN 20 AND 30 ORDER BY c3 LIMIT 4000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range k2 k2 5 NULL 12937 Using where; Using filesort +1 SIMPLE t1 range k2 k2 5 NULL 349 Using where; Using filesort SELECT id,c3 FROM t1 WHERE c2=11 ORDER BY c3 LIMIT 20; id c3 6 14 diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index fb08dbe74e6..c4331d38e14 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -765,13 +765,16 @@ INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +UPDATE t1 SET c2=20 WHERE id%100 = 0; SELECT COUNT(*) FROM t1; +ANALYZE TABLE t1; + EXPLAIN SELECT id,c3 FROM t1 WHERE c2=11 ORDER BY c3 LIMIT 20; -EXPLAIN SELECT id,c3 FROM t1 WHERE c2=11 ORDER BY c3 LIMIT 100; -EXPLAIN SELECT id,c3 FROM t1 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 100; -EXPLAIN SELECT id,c3 FROM t1 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 2000; +EXPLAIN SELECT id,c3 FROM t1 WHERE c2=11 ORDER BY c3 LIMIT 4000; +EXPLAIN SELECT id,c3 FROM t1 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 20; +EXPLAIN SELECT id,c3 FROM t1 WHERE c2 BETWEEN 20 AND 30 ORDER BY c3 LIMIT 4000; SELECT id,c3 FROM t1 WHERE c2=11 ORDER BY c3 LIMIT 20; From 4c33942f5a57bb0bf1fc52ebd1c559088de14655 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 4 Aug 2007 17:15:33 -0700 Subject: [PATCH 53/74] Made the test case for bug 28404 platform independent. --- mysql-test/r/order_by.result | 25 ++++++++++++------------- mysql-test/t/order_by.test | 16 ++++++++-------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index 79a9bf15cbf..ff4882d6cd8 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -1094,22 +1094,21 @@ UPDATE t1 SET c2=20 WHERE id%100 = 0; SELECT COUNT(*) FROM t1; COUNT(*) 40960 -ANALYZE TABLE t1; -Table Op Msg_type Msg_text -test.t1 analyze status OK -EXPLAIN SELECT id,c3 FROM t1 WHERE c2=11 ORDER BY c3 LIMIT 20; +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 SELECT * FROM t1 ORDER BY id; +EXPLAIN SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 20; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index k2 k3 5 NULL 88 Using where -EXPLAIN SELECT id,c3 FROM t1 WHERE c2=11 ORDER BY c3 LIMIT 4000; +1 SIMPLE t2 index k2 k3 5 NULL 111 Using where +EXPLAIN SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 4000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref k2 k2 5 const 9300 Using where; Using filesort -EXPLAIN SELECT id,c3 FROM t1 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 20; +1 SIMPLE t2 ref k2 k2 5 const 7341 Using where; Using filesort +EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 20; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index k2 k3 5 NULL 63 Using where -EXPLAIN SELECT id,c3 FROM t1 WHERE c2 BETWEEN 20 AND 30 ORDER BY c3 LIMIT 4000; +1 SIMPLE t2 index k2 k3 5 NULL 73 Using where +EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 20 AND 30 ORDER BY c3 LIMIT 4000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range k2 k2 5 NULL 349 Using where; Using filesort -SELECT id,c3 FROM t1 WHERE c2=11 ORDER BY c3 LIMIT 20; +1 SIMPLE t2 range k2 k2 5 NULL 386 Using where; Using filesort +SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 20; id c3 6 14 16 14 @@ -1131,4 +1130,4 @@ id c3 176 14 186 14 196 14 -DROP TABLE t1; +DROP TABLE t1,t2; diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index c4331d38e14..37398616299 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -766,16 +766,16 @@ INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; UPDATE t1 SET c2=20 WHERE id%100 = 0; - SELECT COUNT(*) FROM t1; -ANALYZE TABLE t1; +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 SELECT * FROM t1 ORDER BY id; -EXPLAIN SELECT id,c3 FROM t1 WHERE c2=11 ORDER BY c3 LIMIT 20; -EXPLAIN SELECT id,c3 FROM t1 WHERE c2=11 ORDER BY c3 LIMIT 4000; -EXPLAIN SELECT id,c3 FROM t1 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 20; -EXPLAIN SELECT id,c3 FROM t1 WHERE c2 BETWEEN 20 AND 30 ORDER BY c3 LIMIT 4000; +EXPLAIN SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 20; +EXPLAIN SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 4000; +EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 20; +EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 20 AND 30 ORDER BY c3 LIMIT 4000; -SELECT id,c3 FROM t1 WHERE c2=11 ORDER BY c3 LIMIT 20; +SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 20; -DROP TABLE t1; +DROP TABLE t1,t2; From 35249143023c2a59631a1b26759a56826852c149 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 4 Aug 2007 20:31:48 -0700 Subject: [PATCH 54/74] Removed warnings after fix for bug 28404. --- sql/sql_select.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3de5b3b76ac..979a35e8cd1 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -12596,7 +12596,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, TABLE *table=tab->table; SQL_SELECT *select=tab->select; key_map usable_keys; - QUICK_SELECT_I *save_quick; + QUICK_SELECT_I *save_quick= 0; DBUG_ENTER("test_if_skip_sort_order"); LINT_INIT(ref_key_parts); @@ -12734,7 +12734,10 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, JOIN *join= tab->join; uint tablenr= tab - join->join_tab; ha_rows table_records= table->file->stats.records; - bool group= join->group && order == join->group_list; + bool group= join->group && order == join->group_list; + LINT_INIT(best_key_parts); + LINT_INIT(best_key_direction); + LINT_INIT(best_records); /* filesort() and join cache are usually faster than reading in From af2d0f87c98df8c856e4ff975f84920e97101363 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 5 Aug 2007 13:17:07 +0400 Subject: [PATCH 55/74] Fix for bug #21281 "Pending write lock is incorrectly removed when its statement being KILLed". When statement which was trying to obtain write lock on then table and which was blocked by existing read lock was killed, concurrent statements that were trying to obtain read locks on the same table and that were blocked by the presence of this pending write lock were not woken up and had to wait until this first read lock goes away. This problem was caused by the fact that we forgot to wake up threads which pending requests could have been satisfied after removing lock request for the killed thread. The patch solves the problem by waking up those threads in such situation. Test for this bug will be added to 5.1 only as it has much better facilities for its implementation. Particularly, by using I_S.PROCESSLIST and wait_condition.inc script we can wait until thread will be blocked on certain table lock without relying on unconditional sleep (which usage increases time needed for test runs and might cause spurious test failures on slower platforms). mysys/thr_lock.c: After removing lock request from the list of waiting lock requests (e.g. when we discover that current thread was killed) we should wake up other threads waiting for the same lock which pending requests now can be satisfied. To implement this behavior we move code responsible for waking up threads which pending requests can be satisfied from thr_unlock() to new wake_up_waiters() procedure and use it in wait_for_lock() and hr_abort_locks_for_thread(). --- mysys/thr_lock.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index 93884921687..02c9f08c946 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -383,6 +383,9 @@ static inline my_bool have_specific_lock(THR_LOCK_DATA *data, } +static void wake_up_waiters(THR_LOCK *lock); + + static enum enum_thr_lock_result wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data, my_bool in_wait_list) @@ -444,8 +447,13 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data, else wait->last=data->prev; data->type= TL_UNLOCK; /* No lock */ + check_locks(data->lock, "killed or timed out wait_for_lock", 1); + wake_up_waiters(data->lock); + } + else + { + check_locks(data->lock, "aborted wait_for_lock", 0); } - check_locks(data->lock,"failed wait_for_lock",0); } else { @@ -771,6 +779,26 @@ void thr_unlock(THR_LOCK_DATA *data) lock->read_no_write_count--; data->type=TL_UNLOCK; /* Mark unlocked */ check_locks(lock,"after releasing lock",1); + wake_up_waiters(lock); + pthread_mutex_unlock(&lock->mutex); + DBUG_VOID_RETURN; +} + + +/** + @brief Wake up all threads which pending requests for the lock + can be satisfied. + + @param lock Lock for which threads should be woken up + +*/ + +static void wake_up_waiters(THR_LOCK *lock) +{ + THR_LOCK_DATA *data; + enum thr_lock_type lock_type; + + DBUG_ENTER("wake_up_waiters"); if (!lock->write.data) /* If no active write locks */ { @@ -820,11 +848,7 @@ void thr_unlock(THR_LOCK_DATA *data) data=lock->write_wait.data; /* Free this too */ } if (data->type >= TL_WRITE_LOW_PRIORITY) - { - check_locks(lock,"giving write lock",0); - pthread_mutex_unlock(&lock->mutex); - DBUG_VOID_RETURN; - } + goto end; /* Release possible read locks together with the write lock */ } if (lock->read_wait.data) @@ -879,8 +903,7 @@ void thr_unlock(THR_LOCK_DATA *data) free_all_read_locks(lock,0); } end: - check_locks(lock,"thr_unlock",0); - pthread_mutex_unlock(&lock->mutex); + check_locks(lock, "after waking up waiters", 0); DBUG_VOID_RETURN; } @@ -1094,6 +1117,7 @@ my_bool thr_abort_locks_for_thread(THR_LOCK *lock, pthread_t thread) lock->write_wait.last= data->prev; } } + wake_up_waiters(lock); pthread_mutex_unlock(&lock->mutex); DBUG_RETURN(found); } From 8860704088c0269b2e2c2ec95db3b480e2a6216c Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 5 Aug 2007 13:55:37 +0400 Subject: [PATCH 56/74] Added test for bug #21281 "Pending write lock is incorrectly removed when its statement being KILLed". The bug itself was fixed by separate patch in 5.0 tree. mysql-test/r/lock_multi.result: Added test for bug #21281 "Pending write lock is incorrectly removed when its statement being KILLed". mysql-test/t/lock_multi.test: Added test for bug #21281 "Pending write lock is incorrectly removed when its statement being KILLed". --- mysql-test/r/lock_multi.result | 10 ++++++++++ mysql-test/t/lock_multi.test | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/mysql-test/r/lock_multi.result b/mysql-test/r/lock_multi.result index 2445b3e0c69..a3f7ab4505c 100644 --- a/mysql-test/r/lock_multi.result +++ b/mysql-test/r/lock_multi.result @@ -95,3 +95,13 @@ alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; // unlock tables; drop table t1; +create table t1 (i int); +lock table t1 read; +update t1 set i= 10;; +select * from t1;; +kill query ID; +i +ERROR 70100: Query execution was interrupted +unlock tables; +drop table t1; +End of 5.1 tests diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test index 4a6b4ff5e56..b7c406f9637 100644 --- a/mysql-test/t/lock_multi.test +++ b/mysql-test/t/lock_multi.test @@ -270,3 +270,38 @@ drop table t1; # End of 5.0 tests + +# +# Bug #21281 "Pending write lock is incorrectly removed when its +# statement being KILLed" +# +create table t1 (i int); +connection locker; +lock table t1 read; +connection writer; +--send update t1 set i= 10; +connection reader; +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Locked" and info = "update t1 set i= 10"; +--source include/wait_condition.inc +--send select * from t1; +connection default; +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Locked" and info = "select * from t1"; +--source include/wait_condition.inc +let $ID= `select id from information_schema.processlist where state = "Locked" and info = "update t1 set i= 10"`; +--replace_result $ID ID +eval kill query $ID; +connection reader; +--reap +connection writer; +--error ER_QUERY_INTERRUPTED +--reap +connection locker; +unlock tables; +connection default; +drop table t1; + +--echo End of 5.1 tests From 5807eb18b8f34bd68f081c1f4295713e4124e5d9 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 5 Aug 2007 14:02:33 +0300 Subject: [PATCH 57/74] rpl_row_tabledefs_2myisam.result: merged 5.1-main to 5.1-opt : error numbers changed. Many files: merged 5.1-main to 5.1-opt : error numbers changed rpl_extraCol_innodb.result: merged 5.1-main to 5.1-opt : error numbers changed mysql-test/suite/rpl/r/rpl_extraCol_innodb.result: merged 5.1-main to 5.1-opt : error numbers changed mysql-test/suite/rpl/r/rpl_extraCol_myisam.result: merged 5.1-main to 5.1-opt : error numbers changed mysql-test/suite/rpl/r/rpl_incident.result: merged 5.1-main to 5.1-opt : error numbers changed mysql-test/suite/rpl/r/rpl_loaddata_fatal.result: merged 5.1-main to 5.1-opt : error numbers changed mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result: merged 5.1-main to 5.1-opt : error numbers changed. mysql-test/suite/rpl/r/rpl_row_tabledefs_3innodb.result: merged 5.1-main to 5.1-opt : error numbers changed mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result: merged 5.1-main to 5.1-opt : error numbers changed --- .../suite/rpl/r/rpl_extraCol_innodb.result | 28 +++++++++---------- .../suite/rpl/r/rpl_extraCol_myisam.result | 28 +++++++++---------- mysql-test/suite/rpl/r/rpl_incident.result | 4 +-- .../suite/rpl/r/rpl_loaddata_fatal.result | 4 +-- .../rpl/r/rpl_row_tabledefs_2myisam.result | 12 ++++---- .../rpl/r/rpl_row_tabledefs_3innodb.result | 12 ++++---- .../suite/rpl_ndb/r/rpl_ndb_extraCol.result | 28 +++++++++---------- 7 files changed, 58 insertions(+), 58 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_extraCol_innodb.result b/mysql-test/suite/rpl/r/rpl_extraCol_innodb.result index c3159987b30..b14c8c2a725 100644 --- a/mysql-test/suite/rpl/r/rpl_extraCol_innodb.result +++ b/mysql-test/suite/rpl/r/rpl_extraCol_innodb.result @@ -72,7 +72,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 252, test.t3 has type 3 Skip_Counter 0 Exec_Master_Log_Pos # @@ -90,7 +90,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 252, test.t3 has type 3 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -134,7 +134,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 246, test.t4 has type 3 Skip_Counter 0 Exec_Master_Log_Pos # @@ -152,7 +152,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 246, test.t4 has type 3 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -196,7 +196,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 5 type mismatch - received type 4, test.t5 has type 246 Skip_Counter 0 Exec_Master_Log_Pos # @@ -214,7 +214,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 5 type mismatch - received type 4, test.t5 has type 246 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -257,7 +257,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 3 type mismatch - received type 16, test.t6 has type 3 Skip_Counter 0 Exec_Master_Log_Pos # @@ -275,7 +275,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 3 type mismatch - received type 16, test.t6 has type 3 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=3; *** Drop t6 *** @@ -369,7 +369,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 254, test.t10 has type 5 Skip_Counter 0 Exec_Master_Log_Pos # @@ -387,7 +387,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 254, test.t10 has type 5 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -430,7 +430,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 15, test.t11 has type 252 Skip_Counter 0 Exec_Master_Log_Pos # @@ -448,7 +448,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 15, test.t11 has type 252 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -755,7 +755,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 8, test.t17 has type 2 Skip_Counter 0 Exec_Master_Log_Pos # @@ -773,7 +773,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 8, test.t17 has type 2 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; diff --git a/mysql-test/suite/rpl/r/rpl_extraCol_myisam.result b/mysql-test/suite/rpl/r/rpl_extraCol_myisam.result index 9d6c3ed5d33..c13bd79c621 100644 --- a/mysql-test/suite/rpl/r/rpl_extraCol_myisam.result +++ b/mysql-test/suite/rpl/r/rpl_extraCol_myisam.result @@ -72,7 +72,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 252, test.t3 has type 3 Skip_Counter 0 Exec_Master_Log_Pos # @@ -90,7 +90,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 252, test.t3 has type 3 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -134,7 +134,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 246, test.t4 has type 3 Skip_Counter 0 Exec_Master_Log_Pos # @@ -152,7 +152,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 246, test.t4 has type 3 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -196,7 +196,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 5 type mismatch - received type 4, test.t5 has type 246 Skip_Counter 0 Exec_Master_Log_Pos # @@ -214,7 +214,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 5 type mismatch - received type 4, test.t5 has type 246 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -257,7 +257,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 3 type mismatch - received type 16, test.t6 has type 3 Skip_Counter 0 Exec_Master_Log_Pos # @@ -275,7 +275,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 3 type mismatch - received type 16, test.t6 has type 3 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=3; *** Drop t6 *** @@ -369,7 +369,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 254, test.t10 has type 5 Skip_Counter 0 Exec_Master_Log_Pos # @@ -387,7 +387,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 254, test.t10 has type 5 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -430,7 +430,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 15, test.t11 has type 252 Skip_Counter 0 Exec_Master_Log_Pos # @@ -448,7 +448,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 15, test.t11 has type 252 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -755,7 +755,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 8, test.t17 has type 2 Skip_Counter 0 Exec_Master_Log_Pos # @@ -773,7 +773,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 8, test.t17 has type 2 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; diff --git a/mysql-test/suite/rpl/r/rpl_incident.result b/mysql-test/suite/rpl/r/rpl_incident.result index 84fd9c0ee4f..c3cec758d89 100644 --- a/mysql-test/suite/rpl/r/rpl_incident.result +++ b/mysql-test/suite/rpl/r/rpl_incident.result @@ -44,7 +44,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1587 +Last_Errno 1588 Last_Error The incident LOST_EVENTS occured on the master. Message: Skip_Counter 0 Exec_Master_Log_Pos # @@ -62,7 +62,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1587 +Last_SQL_Errno 1588 Last_SQL_Error The incident LOST_EVENTS occured on the master. Message: SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE; diff --git a/mysql-test/suite/rpl/r/rpl_loaddata_fatal.result b/mysql-test/suite/rpl/r/rpl_loaddata_fatal.result index 6c73c275ff0..0216ef65570 100644 --- a/mysql-test/suite/rpl/r/rpl_loaddata_fatal.result +++ b/mysql-test/suite/rpl/r/rpl_loaddata_fatal.result @@ -65,7 +65,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1590 +Last_Errno 1591 Last_Error Fatal error: Not enough memory Skip_Counter 0 Exec_Master_Log_Pos 325 @@ -83,7 +83,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1590 +Last_SQL_Errno 1591 Last_SQL_Error Fatal error: Not enough memory SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE; diff --git a/mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result b/mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result index 816fba54bd8..07ac657584c 100644 --- a/mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result +++ b/mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result @@ -214,7 +214,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 3, test.t4 has type 4 Skip_Counter 0 Exec_Master_Log_Pos # @@ -232,7 +232,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 3, test.t4 has type 4 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -257,7 +257,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 1 type mismatch - received type 3, test.t5 has type 4 Skip_Counter 0 Exec_Master_Log_Pos # @@ -275,7 +275,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 1 type mismatch - received type 3, test.t5 has type 4 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -300,7 +300,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 3, test.t6 has type 4 Skip_Counter 0 Exec_Master_Log_Pos # @@ -318,7 +318,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 3, test.t6 has type 4 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; diff --git a/mysql-test/suite/rpl/r/rpl_row_tabledefs_3innodb.result b/mysql-test/suite/rpl/r/rpl_row_tabledefs_3innodb.result index 0c5d57c1d00..a17d495a116 100644 --- a/mysql-test/suite/rpl/r/rpl_row_tabledefs_3innodb.result +++ b/mysql-test/suite/rpl/r/rpl_row_tabledefs_3innodb.result @@ -214,7 +214,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 3, test.t4 has type 4 Skip_Counter 0 Exec_Master_Log_Pos # @@ -232,7 +232,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 3, test.t4 has type 4 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -257,7 +257,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 1 type mismatch - received type 3, test.t5 has type 4 Skip_Counter 0 Exec_Master_Log_Pos # @@ -275,7 +275,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 1 type mismatch - received type 3, test.t5 has type 4 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -300,7 +300,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 3, test.t6 has type 4 Skip_Counter 0 Exec_Master_Log_Pos # @@ -318,7 +318,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 3, test.t6 has type 4 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; diff --git a/mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result b/mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result index edb4dfbf392..0d17720678d 100644 --- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result +++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result @@ -72,7 +72,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 252, test.t3 has type 3 Skip_Counter 0 Exec_Master_Log_Pos # @@ -90,7 +90,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 252, test.t3 has type 3 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -134,7 +134,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 246, test.t4 has type 3 Skip_Counter 0 Exec_Master_Log_Pos # @@ -152,7 +152,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 246, test.t4 has type 3 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -196,7 +196,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 5 type mismatch - received type 4, test.t5 has type 246 Skip_Counter 0 Exec_Master_Log_Pos # @@ -214,7 +214,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 5 type mismatch - received type 4, test.t5 has type 246 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -257,7 +257,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 3 type mismatch - received type 16, test.t6 has type 3 Skip_Counter 0 Exec_Master_Log_Pos # @@ -275,7 +275,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 3 type mismatch - received type 16, test.t6 has type 3 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=3; *** Drop t6 *** @@ -369,7 +369,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 254, test.t10 has type 5 Skip_Counter 0 Exec_Master_Log_Pos # @@ -387,7 +387,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 254, test.t10 has type 5 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -430,7 +430,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 15, test.t11 has type 252 Skip_Counter 0 Exec_Master_Log_Pos # @@ -448,7 +448,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 15, test.t11 has type 252 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -756,7 +756,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1532 +Last_Errno 1533 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 8, test.t17 has type 2 Skip_Counter 0 Exec_Master_Log_Pos # @@ -774,7 +774,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1532 +Last_SQL_Errno 1533 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 8, test.t17 has type 2 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; From 4e6e122061b71f9378a161793367ae5120310ed4 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 5 Aug 2007 14:16:49 -0700 Subject: [PATCH 58/74] Fix bug #30219. This bug manifested itself for queries with grouping by columns of the BIT type. It led to wrong comparisons of bit-field values and wrong result sets. Bit-field values never cannot be compared as binary values. Yet the class Field_bit had an implementation of the cmp method that compared bit-fields values as binary values. Also the get_image and set_image methods of the base class Field cannot be used for objects of the Field_bit class. Now these methods are declared as virtual and specific implementations of the methods are provided for the class Field_bit. mysql-test/r/type_bit.result: Added a test case for bug #30219. mysql-test/t/type_bit.test: Added a test case for bug #30219. sql/field.h: Fix bug #30219. This bug manifested itself for queries with grouping by columns of the BIT type. It led to wrong comparisons of bit-field values and wrong result sets. Bit-field values never cannot be compared as binary values. Yet the class Field_bit had an implementation of the cmp method that compared bit-fields values as binary values. Also the get_image and set_image methods of the base class Field cannot be used for objects of the Field_bit class. Now these methods are declared as virtual and specific implementations of these methods are provided for the class Field_bit. --- mysql-test/r/type_bit.result | 32 ++++++++++++++++++++++++++++++++ mysql-test/t/type_bit.test | 24 ++++++++++++++++++++++++ sql/field.h | 13 ++++++++++--- 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result index fad0e1f7974..324dcc2775b 100644 --- a/mysql-test/r/type_bit.result +++ b/mysql-test/r/type_bit.result @@ -618,4 +618,36 @@ bit_field int_field  2 handler t1 close; drop table t1; +CREATE TABLE t1 (b BIT(2)); +INSERT INTO t1 (b) VALUES (1), (3), (0), (3); +SELECT b+0, COUNT(DISTINCT b) FROM t1 GROUP BY b; +b+0 COUNT(DISTINCT b) +0 1 +1 1 +3 1 +DROP TABLE t1; +CREATE TABLE t1 (b BIT(2), a VARCHAR(5)); +INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z"); +SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b; +b+0 COUNT(DISTINCT a) +0 1 +1 1 +3 2 +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(5), b BIT(2)); +INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z"); +SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b; +b+0 COUNT(DISTINCT a) +0 1 +1 1 +3 2 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b BIT(2)); +INSERT INTO t1 (b, a) VALUES (1, 1), (3, 2), (0, 3), (3, 4); +SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b; +b+0 COUNT(DISTINCT a) +0 1 +1 1 +3 2 +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test index 48ad24ff6b7..2c7f87f342d 100644 --- a/mysql-test/t/type_bit.test +++ b/mysql-test/t/type_bit.test @@ -272,4 +272,28 @@ handler t1 read a=(1); handler t1 close; drop table t1; +# +# Bug #30219: GROUP BY a column of the BIT type +# + +CREATE TABLE t1 (b BIT(2)); +INSERT INTO t1 (b) VALUES (1), (3), (0), (3); +SELECT b+0, COUNT(DISTINCT b) FROM t1 GROUP BY b; +DROP TABLE t1; + +CREATE TABLE t1 (b BIT(2), a VARCHAR(5)); +INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z"); +SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b; +DROP TABLE t1; + +CREATE TABLE t1 (a CHAR(5), b BIT(2)); +INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z"); +SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b; +DROP TABLE t1; + +CREATE TABLE t1 (a INT, b BIT(2)); +INSERT INTO t1 (b, a) VALUES (1, 1), (3, 2), (0, 3), (3, 4); +SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b; +DROP TABLE t1; + --echo End of 5.0 tests diff --git a/sql/field.h b/sql/field.h index fbf402ab5c3..92705b9aac4 100644 --- a/sql/field.h +++ b/sql/field.h @@ -231,9 +231,9 @@ public: if (null_ptr) null_ptr=ADD_TO_PTR(null_ptr,ptr_diff,uchar*); } - inline void get_image(char *buff,uint length, CHARSET_INFO *cs) + virtual void get_image(char *buff, uint length, CHARSET_INFO *cs) { memcpy(buff,ptr,length); } - inline void set_image(char *buff,uint length, CHARSET_INFO *cs) + virtual void set_image(char *buff,uint length, CHARSET_INFO *cs) { memcpy(ptr,buff,length); } @@ -1430,13 +1430,20 @@ public: String *val_str(String*, String *); my_decimal *val_decimal(my_decimal *); int cmp(const char *a, const char *b) - { return cmp_binary(a, b); } + { + DBUG_ASSERT(ptr == a); + return Field_bit::key_cmp(b, bytes_in_rec+test(bit_len)); + } int key_cmp(const byte *a, const byte *b) { return cmp_binary((char *) a, (char *) b); } int key_cmp(const byte *str, uint length); int cmp_offset(uint row_offset); int cmp_binary_offset(uint row_offset) { return cmp_offset(row_offset); } + void get_image(char *buff, uint length, CHARSET_INFO *cs) + { get_key_image(buff, length, itRAW); } + void set_image(char *buff,uint length, CHARSET_INFO *cs) + { Field_bit::store(buff, length, cs); } uint get_key_image(char *buff, uint length, imagetype type); void set_key_image(char *buff, uint length) { Field_bit::store(buff, length, &my_charset_bin); } From 57e225bbc4906a4540dcbdcf79e1acdefd70ebea Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Aug 2007 01:29:53 +0200 Subject: [PATCH 59/74] mysql-test-run.pl: Search "relwithdebinfo" directory in CMake Visual Studio build Search for "mysqld-debug" even in source tree mysql-test/mysql-test-run.pl: Search "relwithdebinfo" directory in CMake Visual Studio build Search for "mysqld-debug" even in source tree --- mysql-test/mysql-test-run.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 43b1ef7ac86..5c362cddfa1 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -708,6 +708,7 @@ sub command_line_setup () { if (!$opt_extern) { $exe_mysqld= mtr_exe_exists (vs_config_dirs('sql', 'mysqld'), + vs_config_dirs('sql', 'mysqld-debug'), "$glob_basedir/sql/mysqld", "$path_client_bindir/mysqld-max-nt", "$path_client_bindir/mysqld-max", @@ -2436,6 +2437,7 @@ sub vs_config_dirs ($$) { } return ("$glob_basedir/$path_part/release/$exe", + "$glob_basedir/$path_part/relwithdebinfo/$exe", "$glob_basedir/$path_part/debug/$exe"); } From 29e8718970ceaf735abbf5f534b25fca97c11d85 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 5 Aug 2007 17:12:57 -0700 Subject: [PATCH 60/74] Fixed compiler error for Windows in the patch for bug 30219. --- sql/field.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/field.h b/sql/field.h index 92705b9aac4..4fcdb50f8c7 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1432,7 +1432,7 @@ public: int cmp(const char *a, const char *b) { DBUG_ASSERT(ptr == a); - return Field_bit::key_cmp(b, bytes_in_rec+test(bit_len)); + return Field_bit::key_cmp((const byte *) b, bytes_in_rec+test(bit_len)); } int key_cmp(const byte *a, const byte *b) { return cmp_binary((char *) a, (char *) b); } From dd75eb67ed1d8c6ecbeb9a5101787f0637a72db3 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Aug 2007 08:28:16 +0200 Subject: [PATCH 61/74] make_win_bin_dist: Copy embedded .pdb and static debug lib scripts/make_win_bin_dist: Copy embedded .pdb and static debug lib --- scripts/make_win_bin_dist | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist index 14ea77e3e0e..6b6342b268f 100755 --- a/scripts/make_win_bin_dist +++ b/scripts/make_win_bin_dist @@ -219,16 +219,22 @@ copy_embedded() $DESTDIR/include cp libmysqld/libmysqld.def $DESTDIR/include/ cp libmysqld/$TARGET/mysqlserver.lib $DESTDIR/Embedded/static/release/ + cp libmysqld/$TARGET/mysqlserver.pdb $DESTDIR/Embedded/static/release/ cp libmysqld/$TARGET/libmysqld.dll $DESTDIR/Embedded/DLL/release/ cp libmysqld/$TARGET/libmysqld.exp $DESTDIR/Embedded/DLL/release/ cp libmysqld/$TARGET/libmysqld.lib $DESTDIR/Embedded/DLL/release/ + cp libmysqld/$TARGET/libmysqld.pdb $DESTDIR/Embedded/DLL/release/ if [ x"$PACK_DEBUG" = x"" -a -f "libmysqld/debug/libmysqld.lib" -o \ x"$PACK_DEBUG" = x"yes" ] ; then - mkdir -p $DESTDIR/Embedded/DLL/debug + mkdir -p $DESTDIR/Embedded/DLL/debug \ + $DESTDIR/Embedded/static/debug + cp libmysqld/debug/mysqlserver.lib $DESTDIR/Embedded/DLL/debug/ + cp libmysqld/debug/mysqlserver.pdb $DESTDIR/Embedded/DLL/debug/ cp libmysqld/debug/libmysqld.dll $DESTDIR/Embedded/DLL/debug/ cp libmysqld/debug/libmysqld.exp $DESTDIR/Embedded/DLL/debug/ cp libmysqld/debug/libmysqld.lib $DESTDIR/Embedded/DLL/debug/ + cp libmysqld/debug/libmysqld.pdb $DESTDIR/Embedded/DLL/debug/ fi } From e20e0dc48792c5eb4e27521975234cc815dc8ad1 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Aug 2007 08:31:09 +0200 Subject: [PATCH 62/74] make_win_bin_dist: Corrected install path scripts/make_win_bin_dist: Corrected install path --- scripts/make_win_bin_dist | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist index 6b6342b268f..849226c94ea 100755 --- a/scripts/make_win_bin_dist +++ b/scripts/make_win_bin_dist @@ -229,8 +229,8 @@ copy_embedded() x"$PACK_DEBUG" = x"yes" ] ; then mkdir -p $DESTDIR/Embedded/DLL/debug \ $DESTDIR/Embedded/static/debug - cp libmysqld/debug/mysqlserver.lib $DESTDIR/Embedded/DLL/debug/ - cp libmysqld/debug/mysqlserver.pdb $DESTDIR/Embedded/DLL/debug/ + cp libmysqld/debug/mysqlserver.lib $DESTDIR/Embedded/static/debug/ + cp libmysqld/debug/mysqlserver.pdb $DESTDIR/Embedded/static/debug/ cp libmysqld/debug/libmysqld.dll $DESTDIR/Embedded/DLL/debug/ cp libmysqld/debug/libmysqld.exp $DESTDIR/Embedded/DLL/debug/ cp libmysqld/debug/libmysqld.lib $DESTDIR/Embedded/DLL/debug/ From 0c56799e324e2f1b60a742193b79503128d506f2 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Aug 2007 00:53:32 -0700 Subject: [PATCH 63/74] Post-merge fixes. --- sql/field.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/field.h b/sql/field.h index 1861a5d6e6f..f19dfdd371a 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1575,7 +1575,7 @@ public: int cmp(const uchar *a, const uchar *b) { DBUG_ASSERT(ptr == a); - return Field_bit::key_cmp((const byte *) b, bytes_in_rec+test(bit_len)); + return Field_bit::key_cmp(b, bytes_in_rec+test(bit_len)); } int cmp_binary_offset(uint row_offset) { return cmp_offset(row_offset); } @@ -1587,7 +1587,7 @@ public: void get_image(uchar *buff, uint length, CHARSET_INFO *cs) { get_key_image(buff, length, itRAW); } void set_image(const uchar *buff,uint length, CHARSET_INFO *cs) - { Field_bit::store(buff, length, cs); } + { Field_bit::store((char *) buff, length, cs); } uint get_key_image(uchar *buff, uint length, imagetype type); void set_key_image(const uchar *buff, uint length) { Field_bit::store((char*) buff, length, &my_charset_bin); } From 1d139a65654e5102edfaf1b19e3c74b850dc32ce Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Aug 2007 01:01:22 -0700 Subject: [PATCH 64/74] Removed a query from the test case for bug 39219 that displayed in valgrind a problem for BIT type values different from the one reported for the bug. --- mysql-test/r/type_bit.result | 8 -------- mysql-test/t/type_bit.test | 5 ----- 2 files changed, 13 deletions(-) diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result index 324dcc2775b..7c765d6d50b 100644 --- a/mysql-test/r/type_bit.result +++ b/mysql-test/r/type_bit.result @@ -618,14 +618,6 @@ bit_field int_field  2 handler t1 close; drop table t1; -CREATE TABLE t1 (b BIT(2)); -INSERT INTO t1 (b) VALUES (1), (3), (0), (3); -SELECT b+0, COUNT(DISTINCT b) FROM t1 GROUP BY b; -b+0 COUNT(DISTINCT b) -0 1 -1 1 -3 1 -DROP TABLE t1; CREATE TABLE t1 (b BIT(2), a VARCHAR(5)); INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z"); SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b; diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test index 2c7f87f342d..6423d017afb 100644 --- a/mysql-test/t/type_bit.test +++ b/mysql-test/t/type_bit.test @@ -276,11 +276,6 @@ drop table t1; # Bug #30219: GROUP BY a column of the BIT type # -CREATE TABLE t1 (b BIT(2)); -INSERT INTO t1 (b) VALUES (1), (3), (0), (3); -SELECT b+0, COUNT(DISTINCT b) FROM t1 GROUP BY b; -DROP TABLE t1; - CREATE TABLE t1 (b BIT(2), a VARCHAR(5)); INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z"); SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b; From c7f2a5e71877a74a3b23f38b8f14705296c6a418 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Aug 2007 14:22:24 +0400 Subject: [PATCH 65/74] A fix and a test case for Bug#29306 "Truncated data in MS Access with decimal (3,1) columns in a VIEW". mysql_list_fields() C API function would incorrectly set MYSQL_FIELD::decimals member for some view columns. The problem was in an incomplete implementation of Item_ident_for_show::make_field(), which is responsible for view columns metadata. sql/item.cc: A fix for Bug#29306 -- properly initialize decimals in Item_ident_for_show::make_field tests/mysql_client_test.c: Add a test case forBug#29306. Fix warnings. --- sql/item.cc | 2 +- tests/mysql_client_test.c | 54 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/sql/item.cc b/sql/item.cc index 2fc58eebe75..e286c5e501c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1621,7 +1621,7 @@ void Item_ident_for_show::make_field(Send_field *tmp_field) tmp_field->type=field->type(); tmp_field->flags= field->table->maybe_null ? (field->flags & ~NOT_NULL_FLAG) : field->flags; - tmp_field->decimals= 0; + tmp_field->decimals= field->decimals(); } /**********************************************/ diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 75c86902972..cbeea064ffd 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -15570,7 +15570,7 @@ static void test_bug27876() int rc; MYSQL_RES *result; - char utf8_func[] = + unsigned char utf8_func[] = { 0xd1, 0x84, 0xd1, 0x83, 0xd0, 0xbd, 0xd0, 0xba, 0xd1, 0x86, 0xd0, 0xb8, 0xd0, 0xb9, 0xd0, 0xba, @@ -15578,7 +15578,7 @@ static void test_bug27876() 0x00 }; - char utf8_param[] = + unsigned char utf8_param[] = { 0xd0, 0xbf, 0xd0, 0xb0, 0xd1, 0x80, 0xd0, 0xb0, 0xd0, 0xbc, 0xd0, 0xb5, 0xd1, 0x82, 0xd1, 0x8a, @@ -15735,6 +15735,55 @@ static void test_bug27592() } +/** + Bug#29306 Truncated data in MS Access with decimal (3,1) columns in a VIEW +*/ + +static void test_bug29306() +{ + MYSQL_FIELD *field; + int rc; + MYSQL_RES *res; + + DBUG_ENTER("test_bug29306"); + myheader("test_bug29306"); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS tab17557"); + myquery(rc); + rc= mysql_query(mysql, "DROP VIEW IF EXISTS view17557"); + myquery(rc); + rc= mysql_query(mysql, "CREATE TABLE tab17557 (dd decimal (3,1))"); + myquery(rc); + rc= mysql_query(mysql, "CREATE VIEW view17557 as SELECT dd FROM tab17557"); + myquery(rc); + rc= mysql_query(mysql, "INSERT INTO tab17557 VALUES (7.6)"); + myquery(rc); + + /* Checking the view */ + res= mysql_list_fields(mysql, "view17557", NULL); + while ((field= mysql_fetch_field(res))) + { + if (! opt_silent) + { + printf("field name %s\n", field->name); + printf("field table %s\n", field->table); + printf("field decimals %d\n", field->decimals); + if (field->decimals < 1) + printf("Error! No decimals! \n"); + printf("\n\n"); + } + DIE_UNLESS(field->decimals == 1); + } + mysql_free_result(res); + + rc= mysql_query(mysql, "DROP TABLE tab17557"); + myquery(rc); + rc= mysql_query(mysql, "DROP VIEW view17557"); + myquery(rc); + + DBUG_VOID_RETURN; +} + /* Read and parse arguments and MySQL options from my.cnf */ @@ -16019,6 +16068,7 @@ static struct my_tests_st my_tests[]= { { "test_bug28505", test_bug28505 }, { "test_bug28934", test_bug28934 }, { "test_bug27592", test_bug27592 }, + { "test_bug29306", test_bug29306 }, { 0, 0 } }; From 1f83b351818fca51a14bc34a224c4a80e14c9476 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Aug 2007 04:57:28 -0700 Subject: [PATCH 66/74] Bug #29536: timestamp inconsistent in replication around 1970 MySQL replicates the time zone only when operations that involve it are performed. This is controlled by a flag. But this flag is set only on successful operation. The flag must be set also when there is an error that involves a timezone (so the master would replicate the error to the slaves). Fixed by moving the setting of the flag before the operation (so it apples to errors as well). mysql-test/r/rpl_timezone.result: Bug #29536: test case mysql-test/t/rpl_timezone.test: Bug #29536: test case sql/field.cc: Bug #29536: move setting of the flag before the operation (so it apples to errors as well). sql/time.cc: Bug #29536: move setting of the flag before the operation (so it apples to errors as well). --- mysql-test/r/rpl_timezone.result | 18 ++++++++++++++++++ mysql-test/t/rpl_timezone.test | 29 +++++++++++++++++++++++++++-- sql/field.cc | 6 +++--- sql/time.cc | 2 +- 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/rpl_timezone.result b/mysql-test/r/rpl_timezone.result index 10dc8eb7e3c..7a18a26afd3 100644 --- a/mysql-test/r/rpl_timezone.result +++ b/mysql-test/r/rpl_timezone.result @@ -130,3 +130,21 @@ t 2005-01-01 08:00:00 drop table t1, t2; set global time_zone= @my_time_zone; +End of 4.1 tests +CREATE TABLE t1 (a INT, b TIMESTAMP); +INSERT INTO t1 VALUES (1, NOW()); +SET @@session.time_zone='Japan'; +UPDATE t1 SET b= '1970-01-01 08:59:59' WHERE a= 1; +Warnings: +Warning 1264 Out of range value adjusted for column 'b' at row 1 +SELECT * FROM t1 ORDER BY a; +a b +1 0000-00-00 00:00:00 +SET @@session.time_zone='Japan'; +SELECT * FROM t1 ORDER BY a; +a b +1 0000-00-00 00:00:00 +SET @@session.time_zone = default; +DROP TABLE t1; +SET @@session.time_zone = default; +End of 5.0 tests diff --git a/mysql-test/t/rpl_timezone.test b/mysql-test/t/rpl_timezone.test index 6ed5b21ace0..28ca250340e 100644 --- a/mysql-test/t/rpl_timezone.test +++ b/mysql-test/t/rpl_timezone.test @@ -126,8 +126,33 @@ connection master; drop table t1, t2; sync_slave_with_master; -# End of 4.1 tests - # Restore original timezone connection master; set global time_zone= @my_time_zone; + +--echo End of 4.1 tests + +# +# Bug #29536: timestamp inconsistent in replication around 1970 +# +connection master; + +CREATE TABLE t1 (a INT, b TIMESTAMP); +INSERT INTO t1 VALUES (1, NOW()); + +SET @@session.time_zone='Japan'; +UPDATE t1 SET b= '1970-01-01 08:59:59' WHERE a= 1; +SELECT * FROM t1 ORDER BY a; + +sync_slave_with_master; +SET @@session.time_zone='Japan'; +# must procdure the same result as the SELECT on the master +SELECT * FROM t1 ORDER BY a; + +SET @@session.time_zone = default; +connection master; +DROP TABLE t1; +SET @@session.time_zone = default; + + +--echo End of 5.0 tests diff --git a/sql/field.cc b/sql/field.cc index 3f74210807b..8191d885a27 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4462,6 +4462,7 @@ longlong Field_timestamp::val_int(void) MYSQL_TIME time_tmp; THD *thd= table ? table->in_use : current_thd; + thd->time_zone_used= 1; #ifdef WORDS_BIGENDIAN if (table && table->s->db_low_byte_first) temp=uint4korr(ptr); @@ -4473,7 +4474,6 @@ longlong Field_timestamp::val_int(void) return(0); /* purecov: inspected */ thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp, (my_time_t)temp); - thd->time_zone_used= 1; return time_tmp.year * LL(10000000000) + time_tmp.month * LL(100000000) + time_tmp.day * 1000000L + time_tmp.hour * 10000L + @@ -4492,6 +4492,7 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr) to= (char*) val_buffer->ptr(); val_buffer->length(field_length); + thd->time_zone_used= 1; #ifdef WORDS_BIGENDIAN if (table && table->s->db_low_byte_first) temp=uint4korr(ptr); @@ -4507,7 +4508,6 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr) val_buffer->set_charset(&my_charset_bin); // Safety thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp,(my_time_t)temp); - thd->time_zone_used= 1; temp= time_tmp.year % 100; if (temp < YY_PART_YEAR - 1) @@ -4557,6 +4557,7 @@ bool Field_timestamp::get_date(MYSQL_TIME *ltime, uint fuzzydate) { long temp; THD *thd= table ? table->in_use : current_thd; + thd->time_zone_used= 1; #ifdef WORDS_BIGENDIAN if (table && table->s->db_low_byte_first) temp=uint4korr(ptr); @@ -4572,7 +4573,6 @@ bool Field_timestamp::get_date(MYSQL_TIME *ltime, uint fuzzydate) else { thd->variables.time_zone->gmt_sec_to_TIME(ltime, (my_time_t)temp); - thd->time_zone_used= 1; } return 0; } diff --git a/sql/time.cc b/sql/time.cc index b4a8b047998..fb8a51fd0eb 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -228,11 +228,11 @@ my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, my_bool *in_dst_time_ my_time_t timestamp; *in_dst_time_gap= 0; + thd->time_zone_used= 1; timestamp= thd->variables.time_zone->TIME_to_gmt_sec(t, in_dst_time_gap); if (timestamp) { - thd->time_zone_used= 1; return timestamp; } From 730f7722b4e81dcc3af4ebe1b02b47029f498a46 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Aug 2007 06:55:50 -0700 Subject: [PATCH 67/74] Bug 29536 : error message changed 5.0-opt -> 5.1-opt --- mysql-test/suite/rpl/r/rpl_timezone.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/rpl/r/rpl_timezone.result b/mysql-test/suite/rpl/r/rpl_timezone.result index fa7b77a37ea..cd71dbe628e 100644 --- a/mysql-test/suite/rpl/r/rpl_timezone.result +++ b/mysql-test/suite/rpl/r/rpl_timezone.result @@ -111,7 +111,7 @@ INSERT INTO t1 VALUES (1, NOW()); SET @@session.time_zone='Japan'; UPDATE t1 SET b= '1970-01-01 08:59:59' WHERE a= 1; Warnings: -Warning 1264 Out of range value adjusted for column 'b' at row 1 +Warning 1264 Out of range value for column 'b' at row 1 SELECT * FROM t1 ORDER BY a; a b 1 0000-00-00 00:00:00 From e10a415630f0dbed35cacd2a267398a121405f05 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Aug 2007 22:42:13 +0400 Subject: [PATCH 68/74] Fix failing ddl_i18n* tests in the team tree. --- client/mysqldump.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 9cb1c640d7b..b8933612db4 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -2121,7 +2121,7 @@ static uint dump_routines_for_db(char *db) restore_sql_mode(sql_file, ";"); - if (mysql_num_fields(routine_res) > 3) + if (mysql_num_fields(routine_res) >= 6) { restore_cs_variables(sql_file, ";"); @@ -2819,6 +2819,9 @@ static int dump_triggers_for_table(char *table_name, char *db_name) /* Get database collation. */ + if (switch_character_set_results(mysql, "binary")) + DBUG_RETURN(TRUE); + if (fetch_db_collation(db_name, db_cl_name, sizeof (db_cl_name))) DBUG_RETURN(TRUE); @@ -2831,9 +2834,6 @@ static int dump_triggers_for_table(char *table_name, char *db_name) if (mysql_query_with_error_report(mysql, &show_triggers_rs, query_buff)) DBUG_RETURN(TRUE); - if (mysql_num_rows(show_triggers_rs)) - fprintf(sql_file, "\n"); - /* Dump triggers. */ while ((row= mysql_fetch_row(show_triggers_rs))) @@ -2870,11 +2870,11 @@ static int dump_triggers_for_table(char *table_name, char *db_name) } - if (mysql_num_rows(show_triggers_rs)) - fprintf(sql_file, "\n"); - mysql_free_result(show_triggers_rs); + if (switch_character_set_results(mysql, default_charset)) + DBUG_RETURN(TRUE); + /* make sure to set back opt_compatible mode to original value From ae3536fe4e8587c10319fb9309087580142c482e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Aug 2007 22:49:47 +0400 Subject: [PATCH 69/74] Fix warnings. --- client/mysqldump.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index b8933612db4..da24cedc7d7 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -2072,11 +2072,12 @@ static uint dump_routines_for_db(char *db) } else if (strlen(row[2])) { + char *query_str; if (opt_drop) fprintf(sql_file, "/*!50003 DROP %s IF EXISTS %s */;\n", routine_type[i], routine_name); - char *query_str= cover_definer_clause_in_sp(row[2], strlen(row[2])); + query_str= cover_definer_clause_in_sp(row[2], strlen(row[2])); if (mysql_num_fields(routine_res) >= 6) { @@ -2705,10 +2706,10 @@ static void dump_trigger_old(MYSQL_RES *show_triggers_rs, accessing it. */ - uint user_name_len; + size_t user_name_len; char user_name_str[USERNAME_LENGTH + 1]; char quoted_user_name_str[USERNAME_LENGTH * 2 + 3]; - uint host_name_len; + size_t host_name_len; char host_name_str[HOSTNAME_LENGTH + 1]; char quoted_host_name_str[HOSTNAME_LENGTH * 2 + 3]; @@ -3893,7 +3894,7 @@ static int init_dumping(char *database, int init_func(char*)) /* Return 1 if we should copy the table */ -my_bool include_table(uchar* hash_key, uint len) +my_bool include_table(const char* hash_key, uint len) { return !hash_search(&ignore_table, (uchar*) hash_key, len); } From 6e2a24650453445d95513bbc01f2e7877de014af Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Aug 2007 22:52:50 +0400 Subject: [PATCH 70/74] Fix "db_cl_altered might be used uninitialized" warning. --- client/mysqldump.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index da24cedc7d7..5afab7c7828 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1820,7 +1820,7 @@ static uint dump_events_for_db(char *db) MYSQL_ROW row, event_list_row; char db_cl_name[MY_CS_NAME_SIZE]; - int db_cl_altered; + int db_cl_altered= FALSE; DBUG_ENTER("dump_events_for_db"); DBUG_PRINT("enter", ("db: '%s'", db)); @@ -2005,7 +2005,7 @@ static uint dump_routines_for_db(char *db) MYSQL_ROW row, routine_list_row; char db_cl_name[MY_CS_NAME_SIZE]; - int db_cl_altered; + int db_cl_altered= FALSE; DBUG_ENTER("dump_routines_for_db"); DBUG_PRINT("enter", ("db: '%s'", db)); @@ -2746,7 +2746,7 @@ static int dump_trigger(MYSQL_RES *show_create_trigger_rs, { FILE *sql_file= md_result_file; MYSQL_ROW row; - int db_cl_altered; + int db_cl_altered= FALSE; DBUG_ENTER("dump_trigger"); From e887155203fc4ec7d657508efaf0ee945d5f9e6b Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Aug 2007 21:11:09 +0200 Subject: [PATCH 71/74] Raise version number after cloning 5.1.21-beta --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index ca806e36599..7b86917b9fa 100644 --- a/configure.in +++ b/configure.in @@ -10,7 +10,7 @@ AC_CANONICAL_SYSTEM # # When changing major version number please also check switch statement # in mysqlbinlog::check_master_version(). -AM_INIT_AUTOMAKE(mysql, 5.1.21-beta) +AM_INIT_AUTOMAKE(mysql, 5.1.22-beta) AM_CONFIG_HEADER([include/config.h:config.h.in]) PROTOCOL_VERSION=10 From 090cdfe27b0e2e4d0fa03e3360362d168ab53e6e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Aug 2007 23:43:53 +0400 Subject: [PATCH 72/74] Fix one more warning. --- client/mysqldump.c | 1 - 1 file changed, 1 deletion(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 5afab7c7828..b11beef647e 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -2803,7 +2803,6 @@ static int dump_trigger(MYSQL_RES *show_create_trigger_rs, static int dump_triggers_for_table(char *table_name, char *db_name) { - FILE *sql_file= md_result_file; char name_buff[NAME_LEN*4+3]; char query_buff[QUERY_LENGTH]; uint old_opt_compatible_mode= opt_compatible_mode; From dea279ac8a8c883567cd18d4748d0dc78f846124 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Aug 2007 14:02:07 +0400 Subject: [PATCH 73/74] Apply patch for Bug#27806 table comments not passed in to storage engine during "CREATE ... LIKE ..." Only affects engine writers. No change in server behaviour. sql/table.cc: Apply patch for Bug#27806 table comments not passed in to storage engine during "CREATE ... LIKE ..." --- sql/table.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/table.cc b/sql/table.cc index 12fffe1dde7..27f9ccc418e 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2484,6 +2484,7 @@ void update_create_info_from_table(HA_CREATE_INFO *create_info, TABLE *table) create_info->row_type= share->row_type; create_info->default_table_charset= share->table_charset; create_info->table_charset= 0; + create_info->comment= share->comment; DBUG_VOID_RETURN; } From 6930ac54068b88ce5ca2476f70d74ddb42f5d9fc Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Aug 2007 15:49:19 +0400 Subject: [PATCH 74/74] A fix for Bug#28830 Test case log_state fails on VMWare Windows clone due to loaded system mysql-test/r/log_state.result: Update results (Bug#28830) mysql-test/t/log_state.test: A fix for Bug#28830 Test case log_state fails on VMWare Windows clone due to loaded system - make the test more deterministic. --- mysql-test/r/log_state.result | 4 ++-- mysql-test/t/log_state.test | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/log_state.result b/mysql-test/r/log_state.result index 0c6be16b9b7..3a3ef584ce3 100644 --- a/mysql-test/r/log_state.result +++ b/mysql-test/r/log_state.result @@ -37,14 +37,14 @@ set session long_query_time=1; select sleep(2); sleep(2) 0 -select * from mysql.slow_log; +select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%'; start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text set global slow_query_log= ON; set session long_query_time=1; select sleep(2); sleep(2) 0 -select * from mysql.slow_log; +select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%'; start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text TIMESTAMP USER_HOST QUERY_TIME 00:00:00 1 0 test 0 0 1 select sleep(2) show global variables diff --git a/mysql-test/t/log_state.test b/mysql-test/t/log_state.test index b0bb818b783..c67da261ef1 100644 --- a/mysql-test/t/log_state.test +++ b/mysql-test/t/log_state.test @@ -28,7 +28,7 @@ connection con1; set session long_query_time=1; select sleep(2); --replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME -select * from mysql.slow_log; +select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%'; connection default; set global slow_query_log= ON; @@ -36,7 +36,7 @@ connection con1; set session long_query_time=1; select sleep(2); --replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME -select * from mysql.slow_log; +select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%'; connection default; show global variables where Variable_name = 'log' or Variable_name = 'log_slow_queries' or