diff options
34 files changed, 259 insertions, 181 deletions
diff --git a/configure.in b/configure.in index 409bd166a8a..8871189a119 100644 --- a/configure.in +++ b/configure.in @@ -2661,7 +2661,8 @@ AC_OUTPUT(Makefile extra/Makefile mysys/Makefile isam/Makefile dnl merge/Makefile dbug/Makefile scripts/Makefile dnl include/Makefile sql-bench/Makefile tools/Makefile dnl tests/Makefile Docs/Makefile support-files/Makefile dnl - mysql-test/Makefile dnl + support-files/MacOSX/Makefile mysql-test/Makefile dnl + netware/Makefile dnl include/mysql_version.h dnl , , [ test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h diff --git a/include/ft_global.h b/include/ft_global.h index 9acdf6aaaf3..4aa916e91cf 100644 --- a/include/ft_global.h +++ b/include/ft_global.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (C) 2000-2003 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/my_sys.h b/include/my_sys.h index 7e6202c0d03..c4fc157e6f2 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -137,7 +137,7 @@ extern ulonglong safemalloc_mem_limit; #define CALLER_INFO , __FILE__, __LINE__ #define ORIG_CALLER_INFO , sFile, uLine #else -#define my_checkmalloc() (0) +#define my_checkmalloc() #undef TERMINATE #define TERMINATE(A) {} #define QUICK_SAFEMALLOC diff --git a/include/mysql.h b/include/mysql.h index d4236a3f5b2..d16563ac7e2 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -86,6 +86,12 @@ typedef struct st_mysql_field { char *def; /* Default value (set by mysql_list_fields) */ unsigned long length; /* Width of column */ unsigned long max_length; /* Max width of selected set */ + unsigned int name_length; + unsigned int org_name_length; + unsigned int table_length; + unsigned int org_table_length; + unsigned int db_length; + unsigned int def_length; unsigned int flags; /* Div flags */ unsigned int decimals; /* Number of decimals in field */ unsigned int charsetnr; /* Character set */ diff --git a/include/mysql_com.h b/include/mysql_com.h index 2e8c3f265b8..7eac3b113d2 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -232,7 +232,7 @@ my_bool net_realloc(NET *net, unsigned long length); #ifndef EMBEDDED_LIBRARY my_bool net_flush(NET *net); #else -#define net_flush(A) (0) +#define net_flush(A) #endif my_bool my_net_write(NET *net,const char *packet,unsigned long len); diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index 190dc5206b1..6fa71348002 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -283,7 +283,6 @@ static void _ftb_init_index_search(FT_INFO *ftb) { int i; FTB_WORD *ftbw; - MI_INFO *info=ftb->info; if ((ftb->state != READY && ftb->state !=INDEX_DONE) || ftb->keynr == NO_SUCH_KEY) @@ -436,7 +435,7 @@ static void _ftb_climb_the_tree(FTB *ftb, FTB_WORD *ftbw, FT_SEG_ITERATOR *ftsi_ { weight /= ftbe->ythresh; ftbe->cur_weight += weight; - if (++ftbe->yesses == ythresh) + if ((int) ++ftbe->yesses == ythresh) { yn=ftbe->flags; weight=ftbe->cur_weight*ftbe->weight; @@ -477,9 +476,9 @@ static void _ftb_climb_the_tree(FTB *ftb, FTB_WORD *ftbw, FT_SEG_ITERATOR *ftsi_ if (ftbe->ythresh) weight/=3; ftbe->cur_weight += weight; - if (ftbe->yesses < ythresh) + if ((int) ftbe->yesses < ythresh) break; - yn= (ftbe->yesses++ == ythresh) ? ftbe->flags : 0 ; + yn= ((int) ftbe->yesses++ == ythresh) ? ftbe->flags : 0 ; weight*= ftbe->weight; } } diff --git a/myisam/ft_dump.c b/myisam/ft_dump.c index 3ecb0652eea..fc3252273e9 100644 --- a/myisam/ft_dump.c +++ b/myisam/ft_dump.c @@ -58,7 +58,7 @@ int main(int argc,char *argv[]) { int error=0, subkeys; uint keylen, keylen2=0, inx, doc_cnt=0; - float weight; + float weight= 1.0; double gws, min_gws=0, avg_gws=0; MI_INFO *info; char buf[MAX_LEN], buf2[MAX_LEN], buf_maxlen[MAX_LEN], buf_min_gws[MAX_LEN]; @@ -166,12 +166,13 @@ int main(int argc,char *argv[]) } } if (dump) + { if (subkeys>=0) printf("%9qx %20.7f %s\n",info->lastpos,weight,buf); else printf("%9qx => %17d %s\n",info->lastpos,-subkeys,buf); - - if(verbose && (total%HOW_OFTEN_TO_WRITE)==0) + } + if (verbose && (total%HOW_OFTEN_TO_WRITE)==0) printf("%10ld\r",total); } diff --git a/myisam/ft_stopwords.c b/myisam/ft_stopwords.c index 5415a08e5e3..5163aca60bd 100644 --- a/myisam/ft_stopwords.c +++ b/myisam/ft_stopwords.c @@ -17,8 +17,10 @@ /* Written by Sergei A. Golubchik, who has a shared copyright to this code */ #include "ftdefs.h" +#include "my_handler.h" -typedef struct st_ft_stopwords { +typedef struct st_ft_stopwords +{ const char * pos; uint len; } FT_STOPWORD; @@ -33,28 +35,75 @@ static int FT_STOPWORD_cmp(void* cmp_arg __attribute__((unused)), (uchar *)w2->pos,w2->len,0); } -int ft_init_stopwords(const char **sws) +static void FT_STOPWORD_free(FT_STOPWORD *w, TREE_FREE action, + void *arg __attribute__((unused))) { - FT_STOPWORD sw; + if (action == free_free) + my_free((gptr) w->pos, MYF(0)); +} +static int ft_add_stopword(const char *w) +{ + FT_STOPWORD sw; + return !w || + (((sw.len= (uint) strlen(sw.pos=w)) >= ft_min_word_len) && + (tree_insert(stopwords3, &sw, 0, stopwords3->custom_arg)==NULL)); +} - if(!stopwords3) +int ft_init_stopwords() +{ + if (!stopwords3) { - if(!(stopwords3=(TREE *)my_malloc(sizeof(TREE),MYF(0)))) return -1; + if (!(stopwords3=(TREE *)my_malloc(sizeof(TREE),MYF(0)))) + return -1; init_tree(stopwords3,0,0,sizeof(FT_STOPWORD),(qsort_cmp2)&FT_STOPWORD_cmp, - 0, NULL, NULL); + 0, + (ft_stopword_file ? (tree_element_free)&FT_STOPWORD_free : 0), + NULL); } - if(!sws) return 0; - - for(;*sws;sws++) + if (ft_stopword_file) + { + File fd; + uint len; + byte *buffer, *start, *end; + FT_WORD w; + int error=-1; + + if (!*ft_stopword_file) + return 0; + + if ((fd=my_open(ft_stopword_file, O_RDONLY, MYF(MY_WME))) == -1) + return -1; + len=(uint)my_seek(fd, 0L, MY_SEEK_END, MYF(0)); + my_seek(fd, 0L, MY_SEEK_SET, MYF(0)); + if (!(start=buffer=my_malloc(len+1, MYF(MY_WME)))) + goto err0; + len=my_read(fd, buffer, len, MYF(MY_WME)); + end=start+len; + while (ft_simple_get_word(&start, end, &w)) + { + if (ft_add_stopword(my_strdup_with_length(w.pos, w.len, MYF(0)))) + goto err1; + } + error=0; +err1: + my_free(buffer, MYF(0)); +err0: + my_close(fd, MYF(MY_WME)); + return error; + } + else { - if( (sw.len= (uint) strlen(sw.pos=*sws)) < ft_min_word_len) continue; - if(!tree_insert(stopwords3, &sw, 0, stopwords3->custom_arg)) + /* compatibility mode: to be removed */ + char **sws=(char **)ft_precompiled_stopwords; + + for (;*sws;sws++) { - delete_tree(stopwords3); /* purecov: inspected */ - return -1; /* purecov: inspected */ + if (ft_add_stopword(*sws)) + return -1; } + ft_stopword_file="(built-in)"; /* for SHOW VARIABLES */ } return 0; } @@ -64,7 +113,7 @@ int is_stopword(char *word, uint len) FT_STOPWORD sw; sw.pos=word; sw.len=len; - return tree_search(stopwords3, &sw, stopwords3->custom_arg) != NULL; + return tree_search(stopwords3,&sw, stopwords3->custom_arg) != NULL; } @@ -72,7 +121,7 @@ void ft_free_stopwords() { if (stopwords3) { - delete_tree(stopwords3); /* purecov: inspected */ + delete_tree(stopwords3); /* purecov: inspected */ my_free((char*) stopwords3,MYF(0)); stopwords3=0; } diff --git a/myisam/mi_delete.c b/myisam/mi_delete.c index 2b19139e668..96c6400f078 100644 --- a/myisam/mi_delete.c +++ b/myisam/mi_delete.c @@ -33,6 +33,8 @@ static int underflow(MI_INFO *info,MI_KEYDEF *keyinfo,uchar *anc_buff, static uint remove_key(MI_KEYDEF *keyinfo,uint nod_flag,uchar *keypos, uchar *lastkey,uchar *page_end, my_off_t *next_block); +static int _mi_ck_real_delete(register MI_INFO *info, MI_KEYDEF *keyinfo, + uchar *key, uint key_length, my_off_t *root); int mi_delete(MI_INFO *info,const byte *record) @@ -132,8 +134,9 @@ int _mi_ck_delete(register MI_INFO *info, uint keynr, uchar *key, &info->s->state.key_root[keynr]); } /* _mi_ck_delete */ -int _mi_ck_real_delete(register MI_INFO *info, MI_KEYDEF *keyinfo, - uchar *key, uint key_length, my_off_t *root) + +static int _mi_ck_real_delete(register MI_INFO *info, MI_KEYDEF *keyinfo, + uchar *key, uint key_length, my_off_t *root) { int error; uint nod_flag; diff --git a/myisam/sort.c b/myisam/sort.c index d86aeb6aa3b..d642638f06b 100644 --- a/myisam/sort.c +++ b/myisam/sort.c @@ -79,9 +79,11 @@ static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info,uchar **sort_keys, static uint NEAR_F read_to_buffer_varlen(IO_CACHE *fromfile,BUFFPEK *buffpek, uint sort_length); static int NEAR_F write_merge_key(MI_SORT_PARAM *info, IO_CACHE *to_file, - char* key, uint sort_length, uint count); -static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info, IO_CACHE *to_file, - char* key, uint sort_length, uint count); + char *key, uint sort_length, uint count); +static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info, + IO_CACHE *to_file, + char* key, uint sort_length, + uint count); inline int my_var_write(MI_SORT_PARAM *info,IO_CACHE *to_file,char *bufs); /* Creates a index of sorted keys @@ -621,11 +623,11 @@ inline int my_var_write(MI_SORT_PARAM *info,IO_CACHE *to_file,char *bufs) int err; uint16 len = _mi_keylength(info->keyinfo,bufs); - if (err=my_b_write(to_file,(byte*)&len,sizeof(len))) - return(err); - if (err=my_b_write(to_file,(byte*)bufs,(uint) len)) - return(err); - return(0); + if ((err= my_b_write(to_file,(byte*)&len,sizeof(len)))) + return (err); + if ((err= my_b_write(to_file,(byte*)bufs,(uint) len))) + return (err); + return (0); } @@ -647,7 +649,7 @@ static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, register uchar **sort_k buffpek->count=count; for (end=sort_keys+count ; sort_keys != end ; sort_keys++) { - if (err=my_var_write(info,tempfile,*sort_keys)) + if ((err= my_var_write(info,tempfile,*sort_keys))) DBUG_RETURN(err); } DBUG_RETURN(0); @@ -800,7 +802,8 @@ static uint NEAR_F read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek, } /* read_to_buffer_varlen */ -static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info, IO_CACHE *to_file,char* key, +static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info, + IO_CACHE *to_file,char* key, uint sort_length, uint count) { uint idx; @@ -809,17 +812,19 @@ static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info, IO_CACHE *to_file, for (idx=1;idx<=count;idx++) { int err; - if (err = my_var_write(info,to_file,bufs)) - return(err); + if ((err= my_var_write(info,to_file,bufs))) + return (err); bufs=bufs+sort_length; } return(0); } -static int NEAR_F write_merge_key(MI_SORT_PARAM *info, IO_CACHE *to_file,char* key, - uint sort_length, uint count) + +static int NEAR_F write_merge_key(MI_SORT_PARAM *info __attribute__((unused)), + IO_CACHE *to_file, char* key, + uint sort_length, uint count) { - return(my_b_write(to_file,(byte*) key,(uint) sort_length*count)); + return my_b_write(to_file,(byte*) key,(uint) sort_length*count); } /* diff --git a/myisam/sp_test.c b/myisam/sp_test.c index 1a7c2785964..7ae41c2088c 100644 --- a/myisam/sp_test.c +++ b/myisam/sp_test.c @@ -23,7 +23,6 @@ #define MAX_REC_LENGTH 1024 #define KEYALG HA_KEY_ALG_RTREE -static void create_point(char *record,uint rownr); static void create_linestring(char *record,uint rownr); static void print_record(char * record,my_off_t offs,const char * tail); @@ -33,7 +32,6 @@ static void print_key(const char *key,const char * tail); static int run_test(const char *filename); static int read_with_pos(MI_INFO * file, int silent); -static int rtree_CreatePointWKB(double *ords, uint n_dims, uchar *wkb); static int rtree_CreateLineStringWKB(double *ords, uint n_dims, uint n_points, uchar *wkb); static void rtree_PrintWKB(uchar *wkb, uint n_dims); @@ -362,7 +360,7 @@ static void print_record(char * record, my_off_t offs,const char * tail) -#ifndef NOT_USED +#ifdef NOT_USED static void create_point(char *record,uint rownr) { uint tmp; @@ -449,6 +447,8 @@ static void print_key(const char *key,const char * tail) +#ifdef NOT_USED + static int rtree_CreatePointWKB(double *ords, uint n_dims, uchar *wkb) { uint i; @@ -465,8 +465,11 @@ static int rtree_CreatePointWKB(double *ords, uint n_dims, uchar *wkb) } return 5 + n_dims * 8; } +#endif + -static int rtree_CreateLineStringWKB(double *ords, uint n_dims, uint n_points, uchar *wkb) +static int rtree_CreateLineStringWKB(double *ords, uint n_dims, uint n_points, + uchar *wkb) { uint i; uint n_ords = n_dims * n_points; diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index b13dfa4de7a..ba48808a319 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -173,11 +173,11 @@ select max(t2.a2), max(t1.a1) from t1, t2; max(t2.a2) max(t1.a1) NULL NULL explain select min(a2) from t1; -Comment -Select tables optimized away +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away explain select max(t1.a1), max(t2.a2) from t1, t2; -Comment -No matching min/max row +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No matching min/max row insert into t2 values('AAA', 10, 0.5); select max(t1.a1), max(t2.a1) from t1, t2 where t2.a2=9; max(t1.a1) max(t2.a1) diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 40e2c72ff32..e6f3256d779 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -266,10 +266,10 @@ userid count(*) explain select spid,count(*) from t1 where spid between 1 and 2 group by spid desc; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range spID spID 5 NULL 2 Using where; Using index -explain select spid,count(*) from t1 where spid between 1 and 2 group by spid order by null; +explain select spid,count(*) from t1 where spid between 1 and 2 group by spid; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range spID spID 5 NULL 2 Using where; Using index -explain select spid,count(*) from t1 where spid between 1 and 2 group by spid; +explain select spid,count(*) from t1 where spid between 1 and 2 group by spid order by null; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range spID spID 5 NULL 2 Using where; Using index select spid,count(*) from t1 where spid between 1 and 2 group by spid; @@ -285,7 +285,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort explain select sql_big_result spid,sum(userid) from t1 group by spid desc order by null; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 6 +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 select sql_big_result spid,sum(userid) from t1 group by spid desc; spid sum(userid) 5 3 @@ -522,13 +522,13 @@ a b 2 2 1 1 explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort -t2 ALL a NULL NULL NULL 4 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort +1 SIMPLE t2 ALL a NULL NULL NULL 4 Using where explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 6 Using temporary -t2 ALL a NULL NULL NULL 4 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary +1 SIMPLE t2 ALL a NULL NULL NULL 4 Using where drop table t1,t2; create table t1 (a int, b int); insert into t1 values (1, 4); diff --git a/mysql-test/r/rpl_insert_id.result b/mysql-test/r/rpl_insert_id.result index d524818985e..45e0186ac4d 100644 --- a/mysql-test/r/rpl_insert_id.result +++ b/mysql-test/r/rpl_insert_id.result @@ -1,10 +1,12 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; +start slave; drop table if exists t1; +Warnings: +Note 1051 Unknown table 't1' create table t1(a int auto_increment, key(a)); create table t2(b int auto_increment, c int, key(b)); insert into t1 values (1),(2),(3); diff --git a/mysql-test/r/rpl_master_pos_wait.result b/mysql-test/r/rpl_master_pos_wait.result index 22c7aef621c..801ffad6975 100644 --- a/mysql-test/r/rpl_master_pos_wait.result +++ b/mysql-test/r/rpl_master_pos_wait.result @@ -1,9 +1,9 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; +start slave; select master_pos_wait('master-bin.999999',0,10); master_pos_wait('master-bin.999999',0,10) -1 diff --git a/mysql-test/t/rpl000009.test b/mysql-test/t/rpl000009.test index 1fbdd65e1fb..e349d891415 100644 --- a/mysql-test/t/rpl000009.test +++ b/mysql-test/t/rpl000009.test @@ -12,7 +12,7 @@ create database mysqltest; save_master_pos; connection slave; sync_with_master; -create database mysqltest; +create database mysqltest2; create table mysqltest2.foo (n int); insert into mysqltest2.foo values(4); connection master; diff --git a/mysql-test/t/rpl_insert_id.test b/mysql-test/t/rpl_insert_id.test index 3f3636d3082..93062f39c20 100644 --- a/mysql-test/t/rpl_insert_id.test +++ b/mysql-test/t/rpl_insert_id.test @@ -1,9 +1,7 @@ -#see if queries that use both -#auto_increment and LAST_INSERT_ID() -#are replicated well +# See if queries that use both auto_increment and LAST_INSERT_ID() +# are replicated well source include/master-slave.inc; connection master; -drop table if exists t1; create table t1(a int auto_increment, key(a)); create table t2(b int auto_increment, c int, key(b)); insert into t1 values (1),(2),(3); diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 03575858c3e..bb872df3e5c 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -91,7 +91,10 @@ select * from t3 where a in (select b from t2); select * from t3 where a not in (select b from t2); select * from t3 where a = some (select b from t2); select * from t3 where a <> any (select b from t2); + +# Rewrite: select * from t3 where not exists (select b from t2 where a <> b); select * from t3 where a = all (select b from t2); + select * from t3 where a <> all (select b from t2); insert into t2 values (100, 5); select * from t3 where a < any (select b from t2); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 30dad9d3f18..7bec9983a20 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -421,21 +421,8 @@ void Item_func_interval::fix_length_and_dec() } maybe_null= 0; max_length= 2; - used_tables_cache|= item->used_tables(); - with_sum_func= with_sum_func || item->with_sum_func; -} - - -void Item_func_interval::split_sum_func(List<Item> &fields) -{ - if (item->with_sum_func && item->type() != SUM_FUNC_ITEM) - item->split_sum_func(fields); - else if (item->used_tables() || item->type() == SUM_FUNC_ITEM) - { - fields.push_front(item); - item= new Item_ref((Item**) fields.head_ref(), 0, item->name); - } - Item_int_func::split_sum_func(fields); + used_tables_cache|= row->used_tables(); + with_sum_func= with_sum_func || row->with_sum_func; } @@ -938,30 +925,34 @@ Item_func_case::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) } -void Item_func_case::split_sum_func(List<Item> &fields) +void Item_func_case::split_sum_func(Item **ref_pointer_array, + List<Item> &fields) { if (first_expr) { if (first_expr->with_sum_func && first_expr->type() != SUM_FUNC_ITEM) - first_expr->split_sum_func(fields); + first_expr->split_sum_func(ref_pointer_array, fields); else if (first_expr->used_tables() || first_expr->type() == SUM_FUNC_ITEM) { + uint el= fields.elements; fields.push_front(first_expr); - first_expr= new Item_ref((Item**) fields.head_ref(), 0, - first_expr->name); + ref_pointer_array[el]= first_expr; + first_expr= new Item_ref(ref_pointer_array + el, 0, first_expr->name); } } if (else_expr) { if (else_expr->with_sum_func && else_expr->type() != SUM_FUNC_ITEM) - else_expr->split_sum_func(fields); + else_expr->split_sum_func(ref_pointer_array, fields); else if (else_expr->used_tables() || else_expr->type() == SUM_FUNC_ITEM) { + uint el= fields.elements; fields.push_front(else_expr); - else_expr= new Item_ref((Item**) fields.head_ref(), 0, else_expr->name); + ref_pointer_array[el]= else_expr; + else_expr= new Item_ref(ref_pointer_array + el, 0, else_expr->name); } } - Item_func::split_sum_func(fields); + Item_func::split_sum_func(ref_pointer_array, fields); } diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 6e47bbcc3d1..97e69b5dfe6 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -304,7 +304,6 @@ public: args[0]->top_level_item(); return Item_func::fix_fields(thd, tlist, ref); } - void split_sum_func(List<Item> &fields); void fix_length_and_dec(); const char *func_name() const { return "if"; } }; @@ -354,7 +353,7 @@ public: const char *func_name() const { return "case"; } void print(String *str); bool fix_fields(THD *thd, struct st_table_list *tlist, Item **ref); - void split_sum_func(List<Item> &fields); + void split_sum_func(Item **ref_pointer_array, List<Item> &fields); Item *find_item(String *str); void set_outer_resolving(); }; diff --git a/sql/item_func.cc b/sql/item_func.cc index b2faae9425c..6494573458c 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1069,18 +1069,23 @@ longlong Item_func_field::val_int() return 0; } -void Item_func_field::split_sum_func(List<Item> &fields) + +void Item_func_field::split_sum_func(Item **ref_pointer_array, + List<Item> &fields) { if (item->with_sum_func && item->type() != SUM_FUNC_ITEM) - item->split_sum_func(fields); + item->split_sum_func(ref_pointer_array, fields); else if (item->used_tables() || item->type() == SUM_FUNC_ITEM) { + uint el= fields.elements; fields.push_front(item); - item= new Item_ref((Item**) fields.head_ref(), 0, item->name); - } - Item_func::split_sum_func(fields); + ref_pointer_array[el]= item; + item= new Item_ref(ref_pointer_array + el, 0, item->name); + } + Item_func::split_sum_func(ref_pointer_array, fields); } + longlong Item_func_ascii::val_int() { String *res=args[0]->val_str(&value); diff --git a/sql/item_func.h b/sql/item_func.h index 9c5982358f8..7fec2467ff1 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -612,7 +612,7 @@ public: return (item->fix_fields(thd, tlist, &item) || item->check_cols(1) || Item_func::fix_fields(thd, tlist, ref)); } - void split_sum_func(List<Item> &fields); + void split_sum_func(Item **ref_pointer_array, List<Item> &fields); void update_used_tables() { item->update_used_tables() ; Item_func::update_used_tables(); diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 037bb60de3d..d5d8e6eeb1d 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -597,16 +597,19 @@ null: return 0; } -void Item_func_concat_ws::split_sum_func(List<Item> &fields) +void Item_func_concat_ws::split_sum_func(Item **ref_pointer_array, + List<Item> &fields) { if (separator->with_sum_func && separator->type() != SUM_FUNC_ITEM) - separator->split_sum_func(fields); + separator->split_sum_func(ref_pointer_array, fields); else if (separator->used_tables() || separator->type() == SUM_FUNC_ITEM) { + uint el= fields.elements; fields.push_front(separator); - separator= new Item_ref((Item**) fields.head_ref(), 0, separator->name); - } - Item_str_func::split_sum_func(fields); + ref_pointer_array[el]= separator; + separator= new Item_ref(ref_pointer_array + el, 0, separator->name); + } + Item_str_func::split_sum_func(ref_pointer_array, fields); } void Item_func_concat_ws::fix_length_and_dec() @@ -1583,16 +1586,19 @@ void Item_func_elt::fix_length_and_dec() } -void Item_func_elt::split_sum_func(List<Item> &fields) +void Item_func_elt::split_sum_func(Item **ref_pointer_array, + List<Item> &fields) { if (item->with_sum_func && item->type() != SUM_FUNC_ITEM) - item->split_sum_func(fields); + item->split_sum_func(ref_pointer_array, fields); else if (item->used_tables() || item->type() == SUM_FUNC_ITEM) { + uint el= fields.elements; fields.push_front(item); - item= new Item_ref((Item**) fields.head_ref(), 0, item->name); - } - Item_str_func::split_sum_func(fields); + ref_pointer_array[el]= item; + item= new Item_ref(ref_pointer_array + el, 0, item->name); + } + Item_str_func::split_sum_func(ref_pointer_array, fields); } @@ -1642,16 +1648,19 @@ String *Item_func_elt::val_str(String *str) } -void Item_func_make_set::split_sum_func(List<Item> &fields) +void Item_func_make_set::split_sum_func(Item **ref_pointer_array, + List<Item> &fields) { if (item->with_sum_func && item->type() != SUM_FUNC_ITEM) - item->split_sum_func(fields); + item->split_sum_func(ref_pointer_array, fields); else if (item->used_tables() || item->type() == SUM_FUNC_ITEM) { + uint el= fields.elements; fields.push_front(item); - item= new Item_ref((Item**) fields.head_ref(), 0, item->name); - } - Item_str_func::split_sum_func(fields); + ref_pointer_array[el]= item; + item= new Item_ref(ref_pointer_array + el, 0, item->name); + } + Item_str_func::split_sum_func(ref_pointer_array, fields); } diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 75ef626bbd4..3a7810fa306 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -105,8 +105,7 @@ public: separator->check_cols(1) || Item_func::fix_fields(thd, tlist, ref)); } - void split_sum_func(List<Item> &fields); - const char *func_name() const { return "concat_ws"; } + void split_sum_func(Item **ref_pointer_array, List<Item> &fields); const char *func_name() const { return "concat_ws"; } void set_outer_resolving() { @@ -381,7 +380,7 @@ public: item->check_cols(1) || Item_func::fix_fields(thd, tlist, ref)); } - void split_sum_func(List<Item> &fields); + void split_sum_func(Item **ref_pointer_array, List<Item> &fields); void fix_length_and_dec(); void update_used_tables(); const char *func_name() const { return "elt"; } @@ -408,7 +407,7 @@ public: item->check_cols(1) || Item_func::fix_fields(thd, tlist, ref)); } - void split_sum_func(List<Item> &fields); + void split_sum_func(Item **ref_pointer_array, List<Item> &fields); void fix_length_and_dec(); void update_used_tables(); const char *func_name() const { return "make_set"; } diff --git a/sql/log.cc b/sql/log.cc index 878606f73e0..6b06bd781ce 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -30,8 +30,6 @@ #include <stdarg.h> #include <m_ctype.h> // For test_if_number -#define files_charset_info &my_charset_latin1 - MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log; extern I_List<i_string> binlog_do_db, binlog_ignore_db; @@ -1546,8 +1544,8 @@ static bool test_if_number(register const char *str, while (*str++ == ' ') ; if (*--str == '-' || *str == '+') str++; - while (my_isdigit(files_charset_info,*str) || (allow_wildcards && - (*str == wild_many || *str == wild_one))) + while (my_isdigit(files_charset_info,*str) || + (allow_wildcards && (*str == wild_many || *str == wild_one))) { flag=1; str++; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 5512272d71c..3336a7fa642 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -63,6 +63,7 @@ char* query_table_status(THD *thd,const char *db,const char *table_name); #endif #define my_thd_charset default_charset_info +#define files_charset_info system_charset_info /*************************************************************************** Configuration parameters @@ -518,7 +519,7 @@ int mysqld_show_logs(THD *thd); void mysqld_list_fields(THD *thd,TABLE_LIST *table, const char *wild); int mysqld_dump_create_info(THD *thd, TABLE *table, int fd = -1); int mysqld_show_create(THD *thd, TABLE_LIST *table_list); -int mysqld_show_create_db(THD *thd, const char *dbname, HA_CREATE_INFO *create); +int mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create); void mysqld_list_processes(THD *thd,const char *user,bool verbose); int mysqld_show_status(THD *thd); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 08c5889257b..cc00894633c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -983,7 +983,7 @@ static void clean_up_mutexes() { (void) pthread_mutex_destroy(&LOCK_mysql_create_db); (void) pthread_mutex_destroy(&LOCK_Acl); - (void) pthread_mutex_destroy(&LOCK_grant); + (void) rwlock_destroy(&LOCK_grant); (void) pthread_mutex_destroy(&LOCK_open); (void) pthread_mutex_destroy(&LOCK_thread_count); (void) pthread_mutex_destroy(&LOCK_mapped_file); @@ -998,7 +998,10 @@ static void clean_up_mutexes() (void) pthread_mutex_destroy(&LOCK_bytes_received); (void) pthread_mutex_destroy(&LOCK_timezone); (void) pthread_mutex_destroy(&LOCK_user_conn); +#ifdef HAVE_REPLICATION (void) pthread_mutex_destroy(&LOCK_rpl_status); + (void) pthread_cond_destroy(&COND_rpl_status); +#endif (void) pthread_mutex_destroy(&LOCK_active_mi); (void) pthread_mutex_destroy(&LOCK_global_system_variables); (void) pthread_cond_destroy(&COND_thread_count); @@ -1006,7 +1009,6 @@ static void clean_up_mutexes() (void) pthread_cond_destroy(&COND_thread_cache); (void) pthread_cond_destroy(&COND_flush_thread_cache); (void) pthread_cond_destroy(&COND_manager); - (void) pthread_cond_destroy(&COND_rpl_status); } /**************************************************************************** diff --git a/sql/sql_db.cc b/sql/sql_db.cc index ffc7f3c9ca2..c2efd392495 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -605,7 +605,7 @@ bool mysql_change_db(THD *thd, const char *name) } -int mysqld_show_create_db(THD *thd, const char *dbname, +int mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create_info) { int length; diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 7683abb41fe..954dceff303 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -158,9 +158,11 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, if (!lock) goto err0; // mysql_lock_tables() printed error message already - /* In ::external_lock InnoDB resets the fields which tell it that - the handle is used in the HANDLER interface. Tell it again that - we are using it for HANDLER. */ + /* + In ::external_lock InnoDB resets the fields which tell it that + the handle is used in the HANDLER interface. Tell it again that + we are using it for HANDLER. + */ table->file->init_table_handle_for_HANDLER(); @@ -273,23 +275,15 @@ err0: return -1; } -/************************************************************************** - Monty: It could easily happen, that the following service functions are - already defined somewhere in the code, but I failed to find them. - If this is the case, just say a word and I'll use old functions here. -**************************************************************************/ - -/* - Note: this function differs from find_locked_table() because we're looking - here for alias, not real table name -*/ static TABLE **find_table_ptr_by_name(THD *thd, const char *db, - const char *alias) + const char *table_name, bool is_alias) { int dblen; TABLE **ptr; + if (!db || ! *db) + db= thd->db ? thd->db : ""; dblen=strlen(db)+1; ptr= &(thd->handler_tables); @@ -299,7 +293,6 @@ static TABLE **find_table_ptr_by_name(THD *thd, const char *db, !my_strcasecmp(system_charset_info, (is_alias ? table->table_name : table->real_name), table_name)) - !my_strcasecmp(system_charset_info,table->table_name,alias)) break; ptr= &(table->next); } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 69e8b68bab0..d9bfc901475 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -22,8 +22,6 @@ #include <myisam.h> #include <my_dir.h> -#define files_charset_info system_charset_info - #ifdef HAVE_INNOBASE_DB #include "ha_innodb.h" #endif @@ -937,7 +935,7 @@ int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd) goto err; } if (lower_case_table_names) - casedn_str(tbl_name); + my_casedn_str(files_charset_info, tbl_name); remove_escape(table_list->real_name); if (!(table=open_ltable(thd, table_list, TL_READ_NO_INSERT))) @@ -953,7 +951,7 @@ int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd) thd->query = tbl_name; if ((error = mysqld_dump_create_info(thd, table, -1))) { - my_error(ER_GET_ERRNO, MYF(0)); + my_error(ER_GET_ERRNO, MYF(0), my_errno); goto err; } net_flush(&thd->net); @@ -966,9 +964,9 @@ err: } -#ifndef EMBEDDED_LIBRARY - /* Execute one command from socket (query or simple command) */ + +#ifndef EMBEDDED_LIBRARY bool do_command(THD *thd) { char *packet; @@ -1268,9 +1266,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd, my_casedn_str(files_charset_info, table_list.real_name); remove_escape(table_list.real_name); // This can't have wildcards - if (!(table=open_ltable(thd, table_list, TL_READ_NO_INSERT))) - DBUG_RETURN(1); - if (check_access(thd,SELECT_ACL,table_list.db,&thd->col_access)) break; table_list.grant.privilege=thd->col_access; @@ -2649,11 +2644,12 @@ mysql_execute_command(THD *thd) do_db/ignore_db. And as this query involves no tables, tables_ok() above was not called. So we have to check rules again here. */ +#ifdef HAVE_REPLICATION if (thd->slave_thread && (!db_ok(lex->name, replicate_do_db, replicate_ignore_db) || !db_ok_with_wild_table(lex->name))) break; - +#endif if (check_access(thd,CREATE_ACL,lex->name,0,1)) break; res=mysql_create_db(thd,lex->name,&lex->create_info,0); @@ -2673,10 +2669,12 @@ mysql_execute_command(THD *thd) do_db/ignore_db. And as this query involves no tables, tables_ok() above was not called. So we have to check rules again here. */ +#ifdef HAVE_REPLICATION if (thd->slave_thread && (!db_ok(lex->name, replicate_do_db, replicate_ignore_db) || !db_ok_with_wild_table(lex->name))) break; +#endif if (check_access(thd,DROP_ACL,lex->name,0,1)) break; if (thd->locked_tables || thd->active_transaction()) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index b084238a3a4..7cda3d59c59 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -528,7 +528,7 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild) table_list.db=(char*) db; table_list.real_name= table_list.alias= file_name; if (lower_case_table_names) - casedn_str(file_name); + my_casedn_str(files_charset_info, file_name); if (!(table = open_ltable(thd, &table_list, TL_READ))) { for (uint i=0 ; i < field_list.elements ; i++) @@ -958,7 +958,7 @@ mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild) restore_record(table,2); // Get empty record if (thd->protocol->send_fields(&field_list,2)) DBUG_VOID_RETURN; - VOID(net_flush(&thd->net)); + net_flush(&thd->net); DBUG_VOID_RETURN; } @@ -981,7 +981,7 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd) { if (protocol->write()) DBUG_RETURN(-1); - VOID(net_flush(&thd->net)); + net_flush(&thd->net); } else { diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 4cecebfa90c..39800ae6206 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -236,7 +236,7 @@ void udf_free() if (initialized) { initialized= 0; - pthread_mutex_destroy(&THR_LOCK_udf); + rwlock_destroy(&THR_LOCK_udf); } DBUG_VOID_RETURN; } diff --git a/sql/table.cc b/sql/table.cc index 051048b72d1..a54cc4d5a73 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -95,11 +95,11 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, if (my_read(file,(byte*) head,64,MYF(MY_NABP))) goto err_not_open; if (head[0] != (uchar) 254 || head[1] != 1 || - (head[2] != FRM_VER && head[2] > FRM_VER+2)) + (head[2] != FRM_VER && head[2] != FRM_VER+1 && head[2] != FRM_VER+3)) goto err_not_open; /* purecov: inspected */ new_field_pack_flag=head[27]; new_frm_ver= (head[2] - FRM_VER); - field_pack_length= new_frm_ver < 2 ? 11 : 15; + field_pack_length= new_frm_ver < 2 ? 11 : 17; error=3; if (!(pos=get_form_pos(file,head,(TYPELIB*) 0))) @@ -156,7 +156,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, for (i=0 ; i < keys ; i++, keyinfo++) { - if (new_frm_ver == 2) + if (new_frm_ver == 3) { keyinfo->flags= (uint) uint2korr(strpos) ^ HA_NOSAME; keyinfo->key_length= (uint) uint2korr(strpos+2); @@ -348,19 +348,25 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, for (i=0 ; i < outparam->fields; i++, strpos+=field_pack_length, field_ptr++) { - uint pack_flag= uint2korr(strpos+6); - uint interval_nr= (uint) strpos[10]; + uint pack_flag, interval_nr, unireg_type, recpos, field_length; enum_field_types field_type; CHARSET_INFO *charset=NULL; LEX_STRING comment; - if (new_frm_ver == 2) + if (new_frm_ver == 3) { /* new frm file in 4.1 */ - uint comment_length=uint2korr(strpos+13); - field_type=(enum_field_types) (uint) strpos[11]; - if (!(charset=get_charset((uint) strpos[12], MYF(0)))) - charset=outparam->table_charset?outparam->table_charset:default_charset_info; + field_length= uint2korr(strpos+3); + recpos= uint3korr(strpos+5); + pack_flag= uint2korr(strpos+8); + unireg_type= (uint) strpos[10]; + interval_nr= (uint) strpos[12]; + + uint comment_length=uint2korr(strpos+15); + field_type=(enum_field_types) (uint) strpos[13]; + if (!(charset=get_charset((uint) strpos[14], MYF(0)))) + charset= (outparam->table_charset ? outparam->table_charset: + default_charset_info); if (!comment_length) { comment.str= (char*) ""; @@ -375,19 +381,26 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, } else { + field_length= (uint) strpos[3]; + recpos= uint2korr(strpos+4), + pack_flag= uint2korr(strpos+6); + unireg_type= (uint) strpos[8]; + interval_nr= (uint) strpos[10]; + /* old frm file */ field_type= (enum_field_types) f_packtype(pack_flag); - charset=outparam->table_charset?outparam->table_charset:default_charset_info; + charset=(outparam->table_charset ? outparam->table_charset : + default_charset_info); bzero((char*) &comment, sizeof(comment)); } *field_ptr=reg_field= - make_field(record+uint2korr(strpos+4), - (uint32) strpos[3], // field_length + make_field(record+recpos, + (uint32) field_length, null_pos,null_bit, pack_flag, field_type, charset, - (Field::utype) MTYP_TYPENR((uint) strpos[8]), + (Field::utype) MTYP_TYPENR(unireg_type), (interval_nr ? outparam->intervals+interval_nr-1 : (TYPELIB*) 0), @@ -1052,7 +1065,7 @@ File create_frm(register my_string name, uint reclength, uchar *fileinfo, if ((file=my_create(name,CREATE_MODE,O_RDWR | O_TRUNC,MYF(MY_WME))) >= 0) { bzero((char*) fileinfo,64); - fileinfo[0]=(uchar) 254; fileinfo[1]= 1; fileinfo[2]= FRM_VER+2; // Header + fileinfo[0]=(uchar) 254; fileinfo[1]= 1; fileinfo[2]= FRM_VER+3; // Header fileinfo[3]= (uchar) ha_checktype(create_info->db_type); fileinfo[4]=1; int2store(fileinfo+6,IO_SIZE); /* Next block starts here */ @@ -1154,7 +1167,7 @@ bool check_db_name(char *name) char *start=name; if (lower_case_table_names) - casedn_str(name); + my_casedn_str(files_charset_info, name); while (*name) { @@ -1250,7 +1263,7 @@ db_type get_table_type(const char *name) error=my_read(file,(byte*) head,4,MYF(MY_NABP)); my_close(file,MYF(0)); if (error || head[0] != (uchar) 254 || head[1] != 1 || - (head[2] < FRM_VER && head[2] > FRM_VER+2)) + (head[2] != FRM_VER && head[2] != FRM_VER+1 && head[2] != FRM_VER+3)) DBUG_RETURN(DB_TYPE_UNKNOWN); DBUG_RETURN(ha_checktype((enum db_type) (uint) *(head+3))); } diff --git a/sql/unireg.cc b/sql/unireg.cc index a171ba42ff3..1cd38d4d161 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -28,7 +28,7 @@ #include "mysql_priv.h" #include <m_ctype.h> -#define FCOMP 15 /* Bytes for a packed field */ +#define FCOMP 17 /* Bytes for a packed field */ static uchar * pack_screens(List<create_field> &create_fields, uint *info_length, uint *screens, bool small_file); @@ -451,15 +451,15 @@ static bool pack_fields(File file,List<create_field> &create_fields) buff[0]= (uchar) field->row; buff[1]= (uchar) field->col; buff[2]= (uchar) field->sc_length; - buff[3]= (uchar) field->length; + int2store(buff+3, field->length); uint recpos=(uint) field->offset+1; - int2store(buff+4,recpos); - int2store(buff+6,field->pack_flag); - int2store(buff+8,field->unireg_check); - buff[10]= (uchar) field->interval_id; - buff[11]= (uchar) field->sql_type; - buff[12]= (uchar) field->charset->number; - int2store(buff+13, field->comment.length); + int3store(buff+5,recpos); + int2store(buff+8,field->pack_flag); + int2store(buff+10,field->unireg_check); + buff[12]= (uchar) field->interval_id; + buff[13]= (uchar) field->sql_type; + buff[14]= (uchar) field->charset->number; + int2store(buff+15, field->comment.length); comment_length+= field->comment.length; set_if_bigger(int_count,field->interval_id); if (my_write(file,(byte*) buff,FCOMP,MYF_RW)) |