From 76a0983151a5d5f050ee99d14b55abffd9364873 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 29 Oct 2000 13:49:42 +0100 Subject: [PATCH 1/8] mysqldump.c Dumping via SHOW CREATE added. Autofallback to the old behaviour for pre-3.23.26 servers. client/mysqldump.c: Dumping via SHOW CREATE added. Autofallback to the old behaviour for pre-3.23.26 servers. --- client/mysqldump.c | 372 +++++++++++++++++++++++++++------------------ 1 file changed, 227 insertions(+), 145 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 5ec559c5227..b1c77b209aa 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -594,176 +594,258 @@ static uint getTableStructure(char *table, char* db) if (verbose) fprintf(stderr, "# Retrieving table structure for table %s...\n", table); + sprintf(insert_pat,"SET OPTION SQL_QUOTE_SHOW_CREATE=%d", opt_quoted); table_name=quote_name(table,table_buff); - sprintf(insert_pat,"show fields from %s",table_name); - if (mysql_query(sock,insert_pat) || !(tableRes=mysql_store_result(sock))) - { - fprintf(stderr, "%s: Can't get info about table: '%s'\nerror: %s\n", - my_progname, table, mysql_error(sock)); - safe_exit(EX_MYSQLERR); - DBUG_RETURN(0); - } - /* Make an sql-file, if path was given iow. option -T was given */ - if (!tFlag) + if (mysql_query(sock,insert_pat)) { - if (path) - { - char filename[FN_REFLEN], tmp_path[FN_REFLEN]; - strmov(tmp_path,path); - convert_dirname(tmp_path); - sql_file= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4), - O_WRONLY, MYF(MY_WME)); - if (!sql_file) /* If file couldn't be opened */ - { - safe_exit(EX_MYSQLERR); - DBUG_RETURN(0); - } - write_heder(sql_file, db); - } - fprintf(sql_file, "\n#\n# Table structure for table '%s'\n#\n\n", table); - if (opt_drop) - fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",table_name); - fprintf(sql_file, "CREATE TABLE %s (\n", table_name); - } - if (cFlag) - sprintf(insert_pat, "INSERT %sINTO %s (", delayed, table_name); - else - { - sprintf(insert_pat, "INSERT %sINTO %s VALUES ", delayed, table_name); - if (!extended_insert) - strcat(insert_pat,"("); - } - - strpos=strend(insert_pat); - while ((row=mysql_fetch_row(tableRes))) - { - ulong *lengths=mysql_fetch_lengths(tableRes); - if (init) - { - if (!tFlag) - fputs(",\n",sql_file); - if (cFlag) - strpos=strmov(strpos,", "); - } - init=1; - if (cFlag) - strpos=strmov(strpos,quote_name(row[SHOW_FIELDNAME],name_buff)); + /* using SHOW CREATE statement */ if (!tFlag) { - if (opt_keywords) - fprintf(sql_file, " %s.%s %s", table_name, - quote_name(row[SHOW_FIELDNAME],name_buff), row[SHOW_TYPE]); - else - fprintf(sql_file, " %s %s", quote_name(row[SHOW_FIELDNAME],name_buff), - row[SHOW_TYPE]); - if (row[SHOW_DEFAULT]) + /* Make an sql-file, if path was given iow. option -T was given */ + char buff[20+FN_REFLEN]; + + sprintf(buff,"show create table %s",table_name); + if (mysql_query(sock, buff)) { - fputs(" DEFAULT ", sql_file); - unescape(sql_file,row[SHOW_DEFAULT],lengths[SHOW_DEFAULT]); + fprintf(stderr, "%s: Can't get CREATE TABLE for table '%s' (%s)\n", + my_progname, table, mysql_error(sock)); + safe_exit(EX_MYSQLERR); + DBUG_RETURN(0); } - if (!row[SHOW_NULL][0]) - fputs(" NOT NULL", sql_file); - if (row[SHOW_EXTRA][0]) - fprintf(sql_file, " %s",row[SHOW_EXTRA]); + + if (path) + { + char filename[FN_REFLEN], tmp_path[FN_REFLEN]; + strmov(tmp_path,path); + convert_dirname(tmp_path); + sql_file= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4), + O_WRONLY, MYF(MY_WME)); + if (!sql_file) /* If file couldn't be opened */ + { + safe_exit(EX_MYSQLERR); + DBUG_RETURN(0); + } + write_heder(sql_file, db); + } + fprintf(sql_file, "\n#\n# Table structure for table '%s'\n#\n\n", table); + if (opt_drop) + fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",table_name); + + tableRes=mysql_store_result(sock); + row=mysql_fetch_row(tableRes); + fprintf(sql_file, "%s;\n", row[1]); + mysql_free_result(tableRes); } - } - numFields = (uint) mysql_num_rows(tableRes); - mysql_free_result(tableRes); - if (!tFlag) - { - /* Make an sql-file, if path was given iow. option -T was given */ - char buff[20+FN_REFLEN]; - uint keynr,primary_key; - sprintf(buff,"show keys from %s",table_name); - if (mysql_query(sock, buff)) + sprintf(insert_pat,"show fields from %s",table_name); + if (mysql_query(sock,insert_pat) || !(tableRes=mysql_store_result(sock))) { - fprintf(stderr, "%s: Can't get keys for table '%s' (%s)\n", - my_progname, table, mysql_error(sock)); - if (sql_file != stdout) - my_fclose(sql_file, MYF(MY_WME)); + fprintf(stderr, "%s: Can't get info about table: '%s'\nerror: %s\n", + my_progname, table, mysql_error(sock)); safe_exit(EX_MYSQLERR); DBUG_RETURN(0); } - tableRes=mysql_store_result(sock); - /* Find first which key is primary key */ - keynr=0; - primary_key=INT_MAX; - while ((row=mysql_fetch_row(tableRes))) + if (cFlag) + sprintf(insert_pat, "INSERT %sINTO %s (", delayed, table_name); + else { - if (atoi(row[3]) == 1) - { - keynr++; -#ifdef FORCE_PRIMARY_KEY - if (atoi(row[1]) == 0 && primary_key == INT_MAX) - primary_key=keynr; -#endif - if (!strcmp(row[2],"PRIMARY")) - { - primary_key=keynr; - break; - } - } + sprintf(insert_pat, "INSERT %sINTO %s VALUES ", delayed, table_name); + if (!extended_insert) + strcat(insert_pat,"("); } - mysql_data_seek(tableRes,0); - keynr=0; - while ((row=mysql_fetch_row(tableRes))) - { - if (atoi(row[3]) == 1) - { - if (keynr++) - putc(')', sql_file); - if (atoi(row[1])) /* Test if duplicate key */ - /* Duplicate allowed */ - fprintf(sql_file, ",\n KEY %s (",quote_name(row[2],name_buff)); - else if (keynr == primary_key) - fputs(",\n PRIMARY KEY (",sql_file); /* First UNIQUE is primary */ - else - fprintf(sql_file, ",\n UNIQUE %s (",quote_name(row[2],name_buff)); - } - else - putc(',', sql_file); - fputs(quote_name(row[4],name_buff), sql_file); - if (row[7]) - fprintf(sql_file, "(%s)",row[7]); /* Sub key */ - } - if (keynr) - putc(')', sql_file); - fputs("\n)",sql_file); - /* Get MySQL specific create options */ - if (create_options) + strpos=strend(insert_pat); + while ((row=mysql_fetch_row(tableRes))) { - sprintf(buff,"show table status like '%s'",table); + ulong *lengths=mysql_fetch_lengths(tableRes); + if (init) + { + if (cFlag) + strpos=strmov(strpos,", "); + } + init=1; + if (cFlag) + strpos=strmov(strpos,quote_name(row[SHOW_FIELDNAME],name_buff)); + } + numFields = (uint) mysql_num_rows(tableRes); + mysql_free_result(tableRes); + } + else + { + /* fprintf(stderr, "%s: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n", + my_progname, mysql_error(sock)); */ + + sprintf(insert_pat,"show fields from %s",table_name); + if (mysql_query(sock,insert_pat) || !(tableRes=mysql_store_result(sock))) + { + fprintf(stderr, "%s: Can't get info about table: '%s'\nerror: %s\n", + my_progname, table, mysql_error(sock)); + safe_exit(EX_MYSQLERR); + DBUG_RETURN(0); + } + + /* Make an sql-file, if path was given iow. option -T was given */ + if (!tFlag) + { + if (path) + { + char filename[FN_REFLEN], tmp_path[FN_REFLEN]; + strmov(tmp_path,path); + convert_dirname(tmp_path); + sql_file= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4), + O_WRONLY, MYF(MY_WME)); + if (!sql_file) /* If file couldn't be opened */ + { + safe_exit(EX_MYSQLERR); + DBUG_RETURN(0); + } + write_heder(sql_file, db); + } + fprintf(sql_file, "\n#\n# Table structure for table '%s'\n#\n\n", table); + if (opt_drop) + fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",table_name); + fprintf(sql_file, "CREATE TABLE %s (\n", table_name); + } + if (cFlag) + sprintf(insert_pat, "INSERT %sINTO %s (", delayed, table_name); + else + { + sprintf(insert_pat, "INSERT %sINTO %s VALUES ", delayed, table_name); + if (!extended_insert) + strcat(insert_pat,"("); + } + + strpos=strend(insert_pat); + while ((row=mysql_fetch_row(tableRes))) + { + ulong *lengths=mysql_fetch_lengths(tableRes); + if (init) + { + if (!tFlag) + fputs(",\n",sql_file); + if (cFlag) + strpos=strmov(strpos,", "); + } + init=1; + if (cFlag) + strpos=strmov(strpos,quote_name(row[SHOW_FIELDNAME],name_buff)); + if (!tFlag) + { + if (opt_keywords) + fprintf(sql_file, " %s.%s %s", table_name, + quote_name(row[SHOW_FIELDNAME],name_buff), row[SHOW_TYPE]); + else + fprintf(sql_file, " %s %s", quote_name(row[SHOW_FIELDNAME],name_buff), + row[SHOW_TYPE]); + if (row[SHOW_DEFAULT]) + { + fputs(" DEFAULT ", sql_file); + unescape(sql_file,row[SHOW_DEFAULT],lengths[SHOW_DEFAULT]); + } + if (!row[SHOW_NULL][0]) + fputs(" NOT NULL", sql_file); + if (row[SHOW_EXTRA][0]) + fprintf(sql_file, " %s",row[SHOW_EXTRA]); + } + } + numFields = (uint) mysql_num_rows(tableRes); + mysql_free_result(tableRes); + if (!tFlag) + { + /* Make an sql-file, if path was given iow. option -T was given */ + char buff[20+FN_REFLEN]; + uint keynr,primary_key; + sprintf(buff,"show keys from %s",table_name); if (mysql_query(sock, buff)) { - if (mysql_errno(sock) != ER_PARSE_ERROR) - { /* If old MySQL version */ - if (verbose) - fprintf(stderr, - "# Warning: Couldn't get status information for table '%s' (%s)\n", - table,mysql_error(sock)); - } + fprintf(stderr, "%s: Can't get keys for table '%s' (%s)\n", + my_progname, table, mysql_error(sock)); + if (sql_file != stdout) + my_fclose(sql_file, MYF(MY_WME)); + safe_exit(EX_MYSQLERR); + DBUG_RETURN(0); } - else if (!(tableRes=mysql_store_result(sock)) || - !(row=mysql_fetch_row(tableRes))) + + tableRes=mysql_store_result(sock); + /* Find first which key is primary key */ + keynr=0; + primary_key=INT_MAX; + while ((row=mysql_fetch_row(tableRes))) { - fprintf(stderr, - "Error: Couldn't read status information for table '%s' (%s)\n", - table,mysql_error(sock)); + if (atoi(row[3]) == 1) + { + keynr++; + #ifdef FORCE_PRIMARY_KEY + if (atoi(row[1]) == 0 && primary_key == INT_MAX) + primary_key=keynr; + #endif + if (!strcmp(row[2],"PRIMARY")) + { + primary_key=keynr; + break; + } + } } - else + mysql_data_seek(tableRes,0); + keynr=0; + while ((row=mysql_fetch_row(tableRes))) { - fputs("/*!",sql_file); - print_value(sql_file,tableRes,row,"type=","Type",0); - print_value(sql_file,tableRes,row,"","Create_options",0); - print_value(sql_file,tableRes,row,"comment=","Comment",1); - fputs(" */",sql_file); + if (atoi(row[3]) == 1) + { + if (keynr++) + putc(')', sql_file); + if (atoi(row[1])) /* Test if duplicate key */ + /* Duplicate allowed */ + fprintf(sql_file, ",\n KEY %s (",quote_name(row[2],name_buff)); + else if (keynr == primary_key) + fputs(",\n PRIMARY KEY (",sql_file); /* First UNIQUE is primary */ + else + fprintf(sql_file, ",\n UNIQUE %s (",quote_name(row[2],name_buff)); + } + else + putc(',', sql_file); + fputs(quote_name(row[4],name_buff), sql_file); + if (row[7]) + fprintf(sql_file, "(%s)",row[7]); /* Sub key */ } - mysql_free_result(tableRes); /* Is always safe to free */ + if (keynr) + putc(')', sql_file); + fputs("\n)",sql_file); + + /* Get MySQL specific create options */ + if (create_options) + { + sprintf(buff,"show table status like '%s'",table); + if (mysql_query(sock, buff)) + { + if (mysql_errno(sock) != ER_PARSE_ERROR) + { /* If old MySQL version */ + if (verbose) + fprintf(stderr, + "# Warning: Couldn't get status information for table '%s' (%s)\n", + table,mysql_error(sock)); + } + } + else if (!(tableRes=mysql_store_result(sock)) || + !(row=mysql_fetch_row(tableRes))) + { + fprintf(stderr, + "Error: Couldn't read status information for table '%s' (%s)\n", + table,mysql_error(sock)); + } + else + { + fputs("/*!",sql_file); + print_value(sql_file,tableRes,row,"type=","Type",0); + print_value(sql_file,tableRes,row,"","Create_options",0); + print_value(sql_file,tableRes,row,"comment=","Comment",1); + fputs(" */",sql_file); + } + mysql_free_result(tableRes); /* Is always safe to free */ + } + fputs(";\n", sql_file); } - fputs(";\n", sql_file); } if (cFlag) { From d0a28b8944094bd1c2f78953daf0872d70ea59f2 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 31 Oct 2000 21:24:08 -0600 Subject: [PATCH 2/8] manual.texi Added mirrors. Docs/manual.texi: Added mirrors. --- Docs/manual.texi | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Docs/manual.texi b/Docs/manual.texi index eedf6d69355..fa137ad3f8d 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -3879,6 +3879,14 @@ Italy [tzone.it] @ @c @uref{http://mysql.iol.ie, WWW} @c @uref{ftp://ftp.iol.ie/pub/mysql, FTP} +@item +@c Added 20001031 +@c EMAIL: dave@esat.net (Dave Rynne) +@c @image{Flags/ireland} +Ireland [Esat Net] @ +@uref{http://ftp.esat.net/mirrors/download.sourceforge.net/pub/mirrors/mysql/, WWW} +@uref{ftp://ftp.esat.net/mirrors/download.sourceforge.net/pub/mirrors/mysql/, FTP} + @item @c EMAIL: W.Sylwestrzak@icm.edu.pl (Wojtek Sylwestrzak) @c mirroring nightly at 05:25 @@ -3900,6 +3908,14 @@ Poland [Sunsite] @ @c @uref{http://mysql.leirianet.pt, WWW} @c @uref{ftp://ftp.leirianet.pt/pub/mysql/,FTP} +@item +@c Added 20001031 +@c bofh@netc.pt (Bruno Rodrigues) +@image{Flags/portugal} +Portugal [Netc] @ +@uref{http://ftp.netc.pt/pub/mysql/, WWW} +@uref{ftp://ftp.netc.pt/pub/mysql/, FTP} + @item @c EMAIL: kuzmin@dn.ru (Roma Kuzmin) @c @image{Flags/russia} @@ -4273,6 +4289,14 @@ Taiwan [TTN] @ @c EX: serge@oneway.net @c @image{Flags/taiwan} Taiwan [Oneway] @ @c @uref{ftp://ftp.oneway.com.tw/pub/mysql/, FTP} + +@item +@c Added 20001031 +@c EMAIL: ijliao@php.nctu.edu.tw (Ying-Chieh Liao) +@image{Flags/taiwan} +Taiwan [nctu.edu/HsinChu] @ +@uref{http://mysql.nctu.edu.tw/, WWW} + @end itemize @strong{Australia:} From a6ee3f0718174b54165b1956de1a90ee9e2aa7c9 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 31 Oct 2000 21:28:37 -0600 Subject: [PATCH 3/8] manual.texi Typo fix. Docs/manual.texi: Typo fix. --- Docs/manual.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index fa137ad3f8d..a09b4365fb9 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -3911,7 +3911,7 @@ Poland [Sunsite] @ @item @c Added 20001031 @c bofh@netc.pt (Bruno Rodrigues) -@image{Flags/portugal} +@c @image{Flags/portugal} Portugal [Netc] @ @uref{http://ftp.netc.pt/pub/mysql/, WWW} @uref{ftp://ftp.netc.pt/pub/mysql/, FTP} @@ -4293,7 +4293,7 @@ Taiwan [TTN] @ @item @c Added 20001031 @c EMAIL: ijliao@php.nctu.edu.tw (Ying-Chieh Liao) -@image{Flags/taiwan} +@c @image{Flags/taiwan} Taiwan [nctu.edu/HsinChu] @ @uref{http://mysql.nctu.edu.tw/, WWW} From e735267f69bd02a9f7246d72d07100e6179bc33e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Nov 2000 17:36:21 +0100 Subject: [PATCH 4/8] Ill-minded FULLTEXT impilict initialization hack removed. From now on FULLTEXT search is initialized expilictly in mysql_select() sql/item_func.cc: FULLTEXT expilict initialization sql/opt_ft.h: FULLTEXT expilict initialization sql/opt_range.h: FULLTEXT expilict initialization sql/ha_myisam.cc: FULLTEXT expilict initialization sql/ha_myisam.h: FULLTEXT expilict initialization sql/handler.h: FULLTEXT expilict initialization sql/item_func.h: FULLTEXT expilict initialization sql/sql_select.cc: FULLTEXT expilict initialization myisam/ft_search.c: FULLTEXT expilict initialization --- myisam/ft_search.c | 4 ---- sql/ha_myisam.cc | 30 ++++++++---------------------- sql/ha_myisam.h | 5 +++-- sql/handler.h | 6 +++--- sql/item_func.cc | 27 +++++++++++---------------- sql/item_func.h | 2 +- sql/opt_ft.h | 11 +---------- sql/opt_range.h | 2 +- sql/sql_select.cc | 31 ++++++++++++++++--------------- 9 files changed, 44 insertions(+), 74 deletions(-) diff --git a/myisam/ft_search.c b/myisam/ft_search.c index 035e149089f..9baab10df1e 100644 --- a/myisam/ft_search.c +++ b/myisam/ft_search.c @@ -158,7 +158,6 @@ FT_DOCLIST * ft_init_search(void *info, uint keynr, byte *key, ALL_IN_ONE aio; FT_DOCLIST *dlist; FT_DOC *dptr; - my_off_t saved_lastpos; /* black magic ON */ if ((int) (keynr = _mi_check_index((MI_INFO *)info,keynr)) < 0) @@ -174,8 +173,6 @@ FT_DOCLIST * ft_init_search(void *info, uint keynr, byte *key, aio.keyinfo=aio.info->s->keyinfo+keynr; aio.key_root=aio.info->s->state.key_root[keynr]; - saved_lastpos=aio.info->lastpos; - if (!(wtree=ft_parse(NULL,key,key_len))) return NULL; init_tree(&aio.dtree,0,sizeof(FT_SUPERDOC),(qsort_cmp)&FT_SUPERDOC_cmp,0, @@ -204,7 +201,6 @@ FT_DOCLIST * ft_init_search(void *info, uint keynr, byte *key, } err: - aio.info->lastpos=saved_lastpos; delete_tree(&aio.dtree); delete_tree(wtree); my_free((char*) wtree,MYF(0)); diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 7b1d274922d..76433a8eae5 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -353,7 +353,7 @@ int ha_myisam::restore(THD* thd, HA_CHECK_OPT *check_opt) int error = 0; const char* errmsg = ""; - + if (my_copy(src_path, fn_format(dst_path, table->path, "", MI_NAME_DEXT, 4), MYF(MY_WME))) { @@ -361,11 +361,11 @@ int ha_myisam::restore(THD* thd, HA_CHECK_OPT *check_opt) errmsg = "failed in my_copy( Error %d)"; goto err; } - + tmp_check_opt.init(); tmp_check_opt.quick = 1; return repair(thd, &tmp_check_opt); - + err: { MI_CHECK param; @@ -375,7 +375,7 @@ int ha_myisam::restore(THD* thd, HA_CHECK_OPT *check_opt) param.table_name = table->table_name; param.testflag = 0; mi_check_print_error(¶m,errmsg, errno ); - return error; + return error; } } @@ -450,7 +450,7 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt) llstr(file->state->records, llbuff), llstr(start_records, llbuff2), table->path); - } + } return error; } @@ -496,7 +496,7 @@ int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool optimize) DBUG_RETURN(HA_ADMIN_FAILED); } - if (!optimize || + if (!optimize || ((file->state->del || share->state.split != file->state->records) && (!param.opt_rep_quick || !(share->state.changed & STATE_NOT_OPTIMIZED_KEYS)))) @@ -621,9 +621,9 @@ bool ha_myisam::check_and_repair(THD *thd) { sql_print_error("Warning: Recovering table: '%s'",table->path); check_opt.quick= !check_opt.retry_without_quick && !marked_crashed; - check_opt.flags=(((myisam_recover_options & HA_RECOVER_BACKUP) ? + check_opt.flags=(((myisam_recover_options & HA_RECOVER_BACKUP) ? T_BACKUP_DATA : 0) | - (!(myisam_recover_options & HA_RECOVER_FORCE) ? + (!(myisam_recover_options & HA_RECOVER_FORCE) ? T_SAFE_REPAIR : 0)) | T_AUTO_REPAIR; if (repair(thd, &check_opt)) error=1; @@ -1079,20 +1079,6 @@ ha_rows ha_myisam::records_in_range(int inx, end_search_flag); } -int ha_myisam::ft_init(uint inx, const byte *key, uint keylen, bool presort) -{ - if (ft_handler) - return -1; - - // Do the search! - ft_handler=ft_init_search(file,inx,(byte*) key,keylen,presort); - - if (!ft_handler) - return (my_errno ? my_errno : -1); - - return 0; -} - int ha_myisam::ft_read(byte * buf) { int error; diff --git a/sql/ha_myisam.h b/sql/ha_myisam.h index e0165d46920..d9f322fe9ca 100644 --- a/sql/ha_myisam.h +++ b/sql/ha_myisam.h @@ -71,8 +71,9 @@ class ha_myisam: public handler int index_first(byte * buf); int index_last(byte * buf); int index_next_same(byte *buf, const byte *key, uint keylen); - int ft_init(uint inx,const byte *key, uint keylen, bool presort=1); - void *ft_init_ext(uint inx,const byte *key, uint keylen, bool presort=0) + int ft_init() + { if(!ft_handler) return 1; ft_reinit_search(ft_handler); return 0; } + void *ft_init_ext(uint inx,const byte *key, uint keylen, bool presort) { return ft_init_search(file,inx,(byte*) key,keylen,presort); } int ft_read(byte *buf); int rnd_init(bool scan=1); diff --git a/sql/handler.h b/sql/handler.h index b7872ead98a..84c14538f4b 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -222,9 +222,9 @@ public: virtual int index_first(byte * buf)=0; virtual int index_last(byte * buf)=0; virtual int index_next_same(byte *buf, const byte *key, uint keylen); - virtual int ft_init(uint inx,const byte *key, uint keylen, bool presort=1) + virtual int ft_init() { return -1; } - virtual void *ft_init_ext(uint inx,const byte *key, uint keylen, bool presort=0) + virtual void *ft_init_ext(uint inx,const byte *key, uint keylen, bool presort) { return (void *)NULL; } virtual int ft_read(byte *buf) { return -1; } virtual int rnd_init(bool scan=1)=0; @@ -257,7 +257,7 @@ public: virtual int restore(THD* thd, HA_CHECK_OPT* check_opt); // assumes .frm file must exist, and you must have already called // generate_table() - it will just copy the data file and run repair - + virtual int dump(THD* thd, int fd = -1) { return ER_DUMP_NOT_IMPLEMENTED; } virtual void deactivate_non_unique_index(ha_rows rows) {} virtual bool activate_all_index(THD *thd) {return 0;} diff --git a/sql/item_func.cc b/sql/item_func.cc index 3ea7eadd238..39a4bee1366 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1840,9 +1840,6 @@ err: double Item_func_match::val() { - if (first_call) - init_search(); - // Don't know how to return an error from val(), so NULL will be returned if ((null_value=(ft_handler==NULL))) return 0.0; @@ -1853,8 +1850,7 @@ double Item_func_match::val() } else { - /* implicit initialization was done, so we'll have to find - ft_relevance manually in ft_handler array */ + /* we'll have to find ft_relevance manually in ft_handler array */ int a,b,c; FT_DOC *docs=ft_handler->doc; @@ -1881,9 +1877,8 @@ double Item_func_match::val() void Item_func_match::init_search() { - if (!first_call) + if (ft_handler) return; - first_call=false; if (master) { @@ -1893,20 +1888,19 @@ void Item_func_match::init_search() return; } - if (join_key) - { - ft_handler=((FT_DOCLIST *)table->file->ft_handler); - return; - } - - /* join won't use this ft-key, but we must to init it anyway */ String *ft_tmp=0; char tmp1[FT_QUERY_MAXLEN]; String tmp2(tmp1,sizeof(tmp1)); ft_tmp=key_item()->val_str(&tmp2); ft_handler=(FT_DOCLIST *) - table->file->ft_init_ext(key, (byte*) ft_tmp->ptr(), ft_tmp->length()); + table->file->ft_init_ext(key, (byte*) ft_tmp->ptr(), ft_tmp->length(), join_key); + + if (join_key) + { + table->file->ft_handler=ft_handler; + return; + } } bool Item_func_match::fix_fields(THD *thd,struct st_table_list *tlist) @@ -1917,6 +1911,8 @@ bool Item_func_match::fix_fields(THD *thd,struct st_table_list *tlist) /* Why testing for const_item ? Monty */ /* I'll remove it later, but this should include modifications to find_best and auto_close as complement to auto_init code above. SerG */ + /* I'd rather say now that const_item is assumed in quite a bit of + places, so it would be difficult to remove. SerG */ if (Item_func::fix_fields(thd,tlist) || !const_item()) return 1; @@ -1996,7 +1992,6 @@ bool Item_func_match::fix_index() } this->key=max_key; - first_call=1; maybe_null=1; join_key=0; diff --git a/sql/item_func.h b/sql/item_func.h index 7b6d9acdcdc..9b696f75aa1 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -838,7 +838,7 @@ public: List fields; TABLE *table; uint key; - bool first_call, join_key; + bool join_key; Item_func_match *master; FT_DOCLIST *ft_handler; diff --git a/sql/opt_ft.h b/sql/opt_ft.h index 1c95a7cfea7..dcbbb8abcec 100644 --- a/sql/opt_ft.h +++ b/sql/opt_ft.h @@ -31,16 +31,7 @@ public: FT_SELECT(TABLE *table, TABLE_REF *tref) : QUICK_SELECT (table,tref->key,1), ref(tref) {} - int init() - { -#if 0 - if (cp_buffer_from_ref(ref)) // as ft-key doesn't use store_key's - return -1; -#endif - return error=file->ft_init(ref->key, - ref->key_buff, - ref->key_length); - } + int init() { return error=file->ft_init(); } int get_next() { return error=file->ft_read(record); } }; diff --git a/sql/opt_range.h b/sql/opt_range.h index 250c172a988..586c35f397f 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -71,7 +71,7 @@ public: double read_time; QUICK_SELECT(TABLE *table,uint index_arg,bool no_alloc=0); - virtual ~QUICK_SELECT(); // fixed by Sasha needs to be virtual + virtual ~QUICK_SELECT(); void reset(void) { next=0; it.rewind(); } virtual int init() { return 0; } virtual int get_next(); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index d97a59cb898..7e7fed76877 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -486,7 +486,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List &fields,COND *conds, as in other cases the join is done before the sort. */ if ((order || group) && join.join_tab[join.const_tables].type != JT_ALL && - join.join_tab[join.const_tables].type != JT_FT && /* Beware! SerG */ + join.join_tab[join.const_tables].type != JT_FT && (order && simple_order || group && simple_group)) { if (add_ref_to_table_cond(thd,&join.join_tab[join.const_tables])) @@ -522,6 +522,19 @@ mysql_select(THD *thd,TABLE_LIST *tables,List &fields,COND *conds, goto err; } + /* Perform FULLTEXT search before all regular searches */ + if (ftfuncs.elements) + { + List_iterator li(ftfuncs); + Item_func_match *ifm; + DBUG_PRINT("info",("Performing FULLTEXT search")); + thd->proc_info="FULLTEXT searching"; + + while ((ifm=li++)) + { + ifm->init_search(); + } + } /* Create a tmp table if distinct or if the sort is too complicated */ if (need_tmp) { @@ -4438,26 +4451,14 @@ join_ft_read_first(JOIN_TAB *tab) if (cp_buffer_from_ref(&tab->ref)) // as ft-key doesn't use store_key's return -1; // see also FT_SELECT::init() #endif - if ((error=table->file->ft_init(tab->ref.key, - tab->ref.key_buff, - tab->ref.key_length))) - { - if (error != HA_ERR_KEY_NOT_FOUND) - { - sql_print_error("ft_read_first/init: Got error %d when reading table %s",error, - table->path); - table->file->print_error(error,MYF(0)); - return 1; - } - return -1; - } + table->file->ft_init(); error=table->file->ft_read(table->record[0]); if (error) { if (error != HA_ERR_END_OF_FILE) { - sql_print_error("ft_read_first/read: Got error %d when reading table %s", + sql_print_error("ft_read_first: Got error %d when reading table %s", error, table->path); table->file->print_error(error,MYF(0)); return 1; From 79a35fed8d3dff31396cefb67a8f6b311747e4dd Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Nov 2000 16:39:25 -0600 Subject: [PATCH 5/8] manual.texi Added mirror in Argentina. Docs/manual.texi: Added mirror in Argentina. --- Docs/manual.texi | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Docs/manual.texi b/Docs/manual.texi index a09b4365fb9..e7e6f352f25 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -4154,6 +4154,15 @@ USA [LinuxWired/Scottsdale, AZ] @ @strong{South America:} @itemize @bullet + +@item +@c Added 20001102 +@c nico@bannerlandia.com (Nicolas Moldavsky) +@c @image{Flags/argentina} +Argentina [bannerlandia.com] @ +@uref{http://mysql.bannerlandia.com.ar/, WWW} +@uref{ftp://mysql.bannerlandia.com.ar/mirrors/mysql/, FTP} + @c @item @c Not ok 20000919; Non-existent (Matt) @c EMAIL: gaiser@matrix.com.br (Roberto Gaiser) From 63d3ee2bb439ab4eac2022e59c23d9a9700db380 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Nov 2000 16:43:56 -0600 Subject: [PATCH 6/8] manual.texi Added mirror in USA. Docs/manual.texi: Added mirror in USA. --- Docs/manual.texi | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index e7e6f352f25..9db9ace3b6c 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -4149,6 +4149,12 @@ USA [LinuxWired/Scottsdale, AZ] @ @uref{http://mysql.linuxwired.net/, WWW} @uref{ftp://ftp.linuxwired.net/pub/mirrors/mysql/, FTP} +@item +@c EMAIL: dan@surfsouth.com (Dan Muntz) +@c @image{Flags/usa} +USA [Venoma.Org/Valdosta, GA] @ +@uref{http://mysql.venoma.org/, WWW} + @end itemize @strong{South America:} @@ -4157,7 +4163,7 @@ USA [LinuxWired/Scottsdale, AZ] @ @item @c Added 20001102 -@c nico@bannerlandia.com (Nicolas Moldavsky) +@c EMAIL: nico@bannerlandia.com (Nicolas Moldavsky) @c @image{Flags/argentina} Argentina [bannerlandia.com] @ @uref{http://mysql.bannerlandia.com.ar/, WWW} From 2122fc26030b3f96e940bb589a93d22d5c126219 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 4 Nov 2000 15:48:06 +0100 Subject: [PATCH 7/8] fixed bug with FULLTEXT and ORDER BY include/ft_global.h: fixed bug with ORDER BY sql/ha_myisam.cc: fixed bug with ORDER BY sql/item_func.cc: fixed bug with ORDER BY sql/item_func.h: fixed bug with ORDER BY sql/sql_select.cc: fixed bug with ORDER BY --- include/ft_global.h | 5 ++-- sql/ha_myisam.cc | 3 ++- sql/item_func.cc | 56 ++++++++++++++++++++++++--------------------- sql/item_func.h | 2 +- sql/sql_select.cc | 2 +- 5 files changed, 37 insertions(+), 31 deletions(-) diff --git a/include/ft_global.h b/include/ft_global.h index 90641313235..3937bd87c7f 100644 --- a/include/ft_global.h +++ b/include/ft_global.h @@ -47,8 +47,9 @@ void ft_free_stopwords(void); FT_DOCLIST * ft_init_search(void *, uint, byte *, uint, my_bool); int ft_read_next(FT_DOCLIST *, char *); -#define ft_close_search(handler) my_free(((gptr)(handler)),MYF(0)) -#define ft_get_relevance(handler) ((handler)->doc[(handler)->curdoc].weight) +#define ft_close_search(handler) my_free(((gptr)(handler)),MYF(0)) +#define ft_get_relevance(handler) ((handler)->doc[(handler)->curdoc].weight) +#define ft_reinit_search(handler) (((FT_DOCLIST *)(handler))->curdoc=-1) #ifdef __cplusplus } diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 76433a8eae5..630a672d346 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -1088,7 +1088,8 @@ int ha_myisam::ft_read(byte * buf) thread_safe_increment(ha_read_next_count,&LOCK_status); // why ? - error=ft_read_next((FT_DOCLIST *) ft_handler,(char*) buf); + if (error=ft_read_next((FT_DOCLIST *) ft_handler,(char*) buf)) + ft_handler=NULL; // Magic here ! See Item_func_match::val() table->status=error ? STATUS_NOT_FOUND: 0; return error; diff --git a/sql/item_func.cc b/sql/item_func.cc index 39a4bee1366..47bc089b3e0 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1846,43 +1846,46 @@ double Item_func_match::val() if (join_key) { - return ft_get_relevance(ft_handler); + if (table->file->ft_handler) + return ft_get_relevance(ft_handler); + + join_key=0; // Magic here ! See ha_myisam::ft_read() } - else + + /* we'll have to find ft_relevance manually in ft_handler array */ + + int a,b,c; + FT_DOC *docs=ft_handler->doc; + my_off_t docid=table->file->row_position(); + + if ((null_value=(docid==HA_OFFSET_ERROR))) + return 0.0; + + // Assuming docs[] is sorted by dpos... + + for (a=0, b=ft_handler->ndocs, c=(a+b)/2; b-a>1; c=(a+b)/2) { - /* we'll have to find ft_relevance manually in ft_handler array */ - - int a,b,c; - FT_DOC *docs=ft_handler->doc; - my_off_t docid=table->file->row_position(); - - if ((null_value=(docid==HA_OFFSET_ERROR))) - return 0.0; - - // Assuming docs[] is sorted by dpos... - - for (a=0, b=ft_handler->ndocs, c=(a+b)/2; b-a>1; c=(a+b)/2) - { - if (docs[c].dpos > docid) - b=c; - else - a=c; - } - if (docs[a].dpos == docid) - return docs[a].weight; + if (docs[c].dpos > docid) + b=c; else - return 0.0; + a=c; } + if (docs[a].dpos == docid) + return docs[a].weight; + else + return 0.0; + } -void Item_func_match::init_search() +void Item_func_match::init_search(bool no_order) { if (ft_handler) return; if (master) { - master->init_search(); + join_key=master->join_key=join_key|master->join_key; + master->init_search(no_order); ft_handler=master->ft_handler; join_key=master->join_key; return; @@ -1894,7 +1897,8 @@ void Item_func_match::init_search() ft_tmp=key_item()->val_str(&tmp2); ft_handler=(FT_DOCLIST *) - table->file->ft_init_ext(key, (byte*) ft_tmp->ptr(), ft_tmp->length(), join_key); + table->file->ft_init_ext(key, (byte*) ft_tmp->ptr(), ft_tmp->length(), + join_key && !no_order); if (join_key) { diff --git a/sql/item_func.h b/sql/item_func.h index 9b696f75aa1..bc196dc58a5 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -863,5 +863,5 @@ public: longlong val_int() { return val()!=0.0; } bool fix_index(); - void init_search(); + void init_search(bool no_order); }; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 7e7fed76877..189b01c9782 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -532,7 +532,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List &fields,COND *conds, while ((ifm=li++)) { - ifm->init_search(); + ifm->init_search(test(order)); } } /* Create a tmp table if distinct or if the sort is too complicated */ From 9184f1313400781d0e1d4ddb0a0a86d756f743c8 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 5 Nov 2000 04:19:39 +0100 Subject: [PATCH 8/8] configure.in fixed to properly handle 1 digit branch configure.in: fixed to properly handle 1 digit branch BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 7 +------ configure.in | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index fd6e2466e56..f9f0dff3fac 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -1,6 +1 @@ -monty@donna.mysql.com -mwagner@evoq.home.mwagner.org -paul@central.snake.net -sasha@mysql.sashanet.com -serg@serg.mysql.com -tim@threads.polyesthetic.msg +sasha@work.mysql.com diff --git a/configure.in b/configure.in index bd78c787189..4a8b5dbfa4c 100644 --- a/configure.in +++ b/configure.in @@ -16,7 +16,7 @@ SHARED_LIB_VERSION=10:0:0 # Remember that regexps needs to quote [ and ] since this is run through m4 MYSQL_NO_DASH_VERSION=`echo $VERSION | sed -e "s|-.*$||"` MYSQL_BASE_VERSION=`echo $MYSQL_NO_DASH_VERSION | sed -e "s|\.[[^.]]*$||"` -F_PART=`echo $MYSQL_BASE_VERSION | sed -e "s|\.||g"| sed -e "s|[[a-zA-Z]]\+||"` +F_PART=`echo $MYSQL_BASE_VERSION | sed -e "s|\.||g"| sed -e "s|[a-zA-Z]\+||"|sed -e "s|^\(..\)$|\\10|"` L_PART=`echo $MYSQL_NO_DASH_VERSION | sed -e "s|^[[0-9]]\.[[0-9]]*\.||" | sed -e "s|^\(.\)$|0\\1|" | sed -e "s|[[a-z]]||"` MYSQL_VERSION_ID=${F_PART}${L_PART}