From d45bf758ad6eff99532242fd87ed2854cef4f0dc Mon Sep 17 00:00:00 2001 From: "serg@serg.mysql.com" <> Date: Wed, 26 Sep 2001 12:56:19 +0200 Subject: [PATCH 1/5] manual cleanups --- BitKeeper/etc/logging_ok | 1 + Docs/manual.texi | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index efa9faefd05..18c9c43349e 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -1 +1,2 @@ Miguel@light.local +serg@serg.mysql.com diff --git a/Docs/manual.texi b/Docs/manual.texi index 6dd44a79288..88e4adceb9b 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -30991,7 +30991,8 @@ mysql> select ATAN(-2); @end example @findex ATAN2() -@item ATAN2(Y,X) +@item ATAN(Y,X) +@itemx ATAN2(Y,X) Returns the arc tangent of the two variables @code{X} and @code{Y}. It is similar to calculating the arc tangent of @code{Y / X}, except that the signs of both arguments are used to determine the quadrant of the @@ -30999,7 +31000,7 @@ result: @example mysql> select ATAN(-2,2); -> -0.785398 -mysql> select ATAN(PI(),0); +mysql> select ATAN2(PI(),0); -> 1.570796 @end example @@ -32203,6 +32204,18 @@ MySQL will directly use disk-based temporary tables if needed. MySQL will also, in this case, prefer sorting to doing a temporary table with a key on the @code{GROUP BY} elements. +@item +@code{SQL_BUFFER_RESULT} will force the result to be put into a temporary +table. This will help MySQL free the table locks early and will help +in cases where it takes a long time to send the result set to the client. + +@item +@code{SQL_SMALL_RESULT}, a MySQL-specific option, can be used +with @code{GROUP BY} or @code{DISTINCT} to tell the optimizer that the +result set will be small. In this case, MySQL will use fast +temporary tables to store the resulting table instead of using sorting. In +MySQL Version 3.23 this shouldn't normally be needed. + @item @cindex @code{GROUP BY}, extensions to ANSI SQL If you use @code{GROUP BY}, the output rows will be sorted according to the @@ -32221,18 +32234,6 @@ If you are not getting the results you expect from your query, please read the @code{GROUP BY} description. @xref{Group by functions}. -@item -@code{SQL_BUFFER_RESULT} will force the result to be put into a temporary -table. This will help MySQL free the table locks early and will help -in cases where it takes a long time to send the result set to the client. - -@item -@code{SQL_SMALL_RESULT}, a MySQL-specific option, can be used -with @code{GROUP BY} or @code{DISTINCT} to tell the optimizer that the -result set will be small. In this case, MySQL will use fast -temporary tables to store the resulting table instead of using sorting. In -MySQL Version 3.23 this shouldn't normally be needed. - @item @code{STRAIGHT_JOIN} forces the optimizer to join the tables in the order in which they are listed in the @code{FROM} clause. You can use this to speed up From 530882c55b39839bb1aab52012073d71c1660951 Mon Sep 17 00:00:00 2001 From: "paul@central.snake.net" <> Date: Fri, 28 Sep 2001 10:49:31 -0500 Subject: [PATCH 2/5] manual.texi typos --- Docs/manual.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index 128fd814e31..cd730aa321a 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -13948,8 +13948,8 @@ MySQL. Some of the examples use the table @code{shop} to hold the price of each article (item number) for certain traders (dealers). Supposing that each -trader has a single fixed price per article, then (@code{item}, -@code{trader}) is a primary key for the records. +trader has a single fixed price per article, then (@code{article}, +@code{dealer}) is a primary key for the records. Start the command line tool @code{mysql} and select a database: @@ -14158,7 +14158,7 @@ splitting of the concatenated column in the client. @subsection Using user variables You can use MySQL user variables to remember results without -having to store them in a temporary variables in the client. +having to store them in temporary variables in the client. @xref{Variables}. For example, to find the articles with the highest and lowest price you From 993be5c8a0cf55282e9917fd1e67d8472278b1a5 Mon Sep 17 00:00:00 2001 From: "serg@serg.mysql.com" <> Date: Mon, 1 Oct 2001 14:37:15 +0200 Subject: [PATCH 3/5] three column types (added to parser - but not to the manual - long time ago) documented --- Docs/manual.texi | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Docs/manual.texi b/Docs/manual.texi index e9b9e885ff7..cf2f18eb80e 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -28179,6 +28179,13 @@ column that only can take 2 values: A @code{CHAR(0)}, that is not defined as @code{NOT NULL}, will only occupy one bit and can only take 2 values: @code{NULL} or @code{""}. @xref{CHAR}. +@tindex BOOL +@tindex BIT +@item BIT +@itemx BOOL +@itemx CHAR +These three are synonyms for @code{CHAR(1)}. + @tindex CHARACTER VARYING @tindex CHAR VARYING @tindex VARCHAR From d28f23c14ffc8b0a738a2c3bda3d0d4d9c075e9b Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Tue, 2 Oct 2001 21:08:08 +0300 Subject: [PATCH 4/5] Fixed bug in INSERT DELAYED Fixed some problems in SHOW CREATE TABLE Fixed calculation of checksums in myisamchk --- Docs/manual.texi | 3 +++ client/mysql.cc | 2 +- myisam/mi_check.c | 24 ++++++++++-------------- sql/sql_insert.cc | 11 +++++++++-- sql/sql_show.cc | 13 ++++++++++++- 5 files changed, 35 insertions(+), 18 deletions(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index 128fd814e31..be415284e7e 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -46854,6 +46854,9 @@ not yet 100% confident in this code. @appendixsubsec Changes in release 3.23.43 @itemize @bullet @item +Fixed a bug in @code{INSERT DELAYED} and @code{FLUSH TABLES} introduced +in 3.23.42. +@item Fixed unlikely bug, which returned not matching rows, in SELECT with many tables and multi-column indexes and 'range' type. @item diff --git a/client/mysql.cc b/client/mysql.cc index 96536c9d5f0..5ae8df39863 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -937,7 +937,7 @@ static bool add_line(String &buffer,char *line,char *in_string) { // mSQL or postgreSQL style command ? if (!(inchar = (uchar) *++pos)) break; // readline adds one '\' - if (*in_string || inchar == 'N') + if (*in_string || inchar == 'N') // \N is short for NULL { // Don't allow commands in string *out++='\\'; *out++= (char) inchar; diff --git a/myisam/mi_check.c b/myisam/mi_check.c index fa4687e27f5..93598ce2d76 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -1194,8 +1194,6 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, param->glob_crc=0; if (param->testflag & T_CALC_CHECKSUM) param->calc_checksum=1; - if (!rep_quick) - share->state.checksum=0; info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); for (i=0 ; i < info->s->base.keys ; i++) @@ -1290,9 +1288,9 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, else { info->state->data_file_length=sort_info->max_pos; - if (param->testflag & T_CALC_CHECKSUM) - share->state.checksum=param->glob_crc; } + if (param->testflag & T_CALC_CHECKSUM) + share->state.checksum=param->glob_crc; if (!(param->testflag & T_SILENT)) { @@ -1878,8 +1876,6 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, param->glob_crc=0; if (param->testflag & T_CALC_CHECKSUM) param->calc_checksum=1; - if (! rep_quick) - share->state.checksum=0; rec_per_key_part= param->rec_per_key_part; for (sort_info->key=0 ; sort_info->key < share->base.keys ; @@ -1999,7 +1995,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, "Can't change size of datafile, error: %d", my_errno); } - else if (param->testflag & T_CALC_CHECKSUM) + if (param->testflag & T_CALC_CHECKSUM) share->state.checksum=param->glob_crc; if (my_chsize(share->kfile,info->state->key_file_length,MYF(0))) @@ -2478,7 +2474,7 @@ int sort_write_record(SORT_INFO *sort_info) DBUG_RETURN(1); } sort_info->filepos+=share->base.pack_reclength; - info->s->state.checksum+=mi_static_checksum(info, sort_info->record); + /* sort_info->param->glob_crc+=mi_static_checksum(info, sort_info->record); */ break; case DYNAMIC_RECORD: if (! info->blobs) @@ -2502,7 +2498,7 @@ int sort_write_record(SORT_INFO *sort_info) } info->checksum=mi_checksum(info,sort_info->record); reclength=_mi_rec_pack(info,from,sort_info->record); - info->s->state.checksum+=info->checksum; + /* sort_info->param->glob_crc+=info->checksum; */ block_length=reclength+ 3 + test(reclength >= (65520-3)); if (block_length < share->base.min_block_length) block_length=share->base.min_block_length; @@ -2516,7 +2512,7 @@ int sort_write_record(SORT_INFO *sort_info) DBUG_RETURN(1); } sort_info->filepos+=block_length; - info->s->state.checksum+=info->checksum; + /* sort_info->param->glob_crc+=info->checksum; */ break; case COMPRESSED_RECORD: reclength=info->packed_length; @@ -2529,7 +2525,7 @@ int sort_write_record(SORT_INFO *sort_info) mi_check_print_error(param,"%d when writing to datafile",my_errno); DBUG_RETURN(1); } - info->s->state.checksum+=info->checksum; + /* sort_info->param->glob_crc+=info->checksum; */ sort_info->filepos+=reclength+length; break; } @@ -2746,9 +2742,9 @@ static int sort_delete_record(MI_CHECK *param) DBUG_RETURN(1); } } - if (info->s->calc_checksum) - info->s->state.checksum-=(*info->s->calc_checksum)(info, - sort_info->record); + if (param->calc_checksum) + param->glob_crc-=(*info->s->calc_checksum)(info, + sort_info->record); } error=flush_io_cache(&info->rec_cache) || (*info->s->delete_record)(info); info->dfile=old_file; /* restore actual value */ diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index cd738999383..f7ff3ed159c 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -841,6 +841,7 @@ void kill_delayed_threads(void) delayed_insert *tmp; while ((tmp=it++)) { + /* Ensure that the thread doesn't kill itself while we are looking at it */ pthread_mutex_lock(&tmp->mutex); tmp->thd.killed=1; if (tmp->thd.mysys_var) @@ -848,9 +849,15 @@ void kill_delayed_threads(void) pthread_mutex_lock(&tmp->thd.mysys_var->mutex); if (tmp->thd.mysys_var->current_cond) { - pthread_mutex_lock(tmp->thd.mysys_var->current_mutex); + /* + We need the following test because the main mutex may be locked + in handle_delayed_insert() + */ + if (&tmp->mutex != tmp->thd.mysys_var->current_mutex) + pthread_mutex_lock(tmp->thd.mysys_var->current_mutex); pthread_cond_broadcast(tmp->thd.mysys_var->current_cond); - pthread_mutex_unlock(tmp->thd.mysys_var->current_mutex); + if (&tmp->mutex != tmp->thd.mysys_var->current_mutex) + pthread_mutex_unlock(tmp->thd.mysys_var->current_mutex); } pthread_mutex_unlock(&tmp->thd.mysys_var->mutex); } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 5869feefdc3..6ae7eeb41d3 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -390,7 +390,7 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild) if (table->db_create_options & HA_OPTION_DELAY_KEY_WRITE) ptr=strmov(ptr," delay_key_write=1"); if (table->row_type != ROW_TYPE_DEFAULT) - ptr=strxmov(ptr, " format=", ha_row_type[(uint) table->row_type], + ptr=strxmov(ptr, " row_format=", ha_row_type[(uint) table->row_type], NullS); if (file->raid_type) { @@ -910,6 +910,12 @@ store_create_info(THD *thd, TABLE *table, String *packet) p = longlong10_to_str(table->max_rows, buff, 10); packet->append(buff, (uint) (p - buff)); } + if (table->avg_row_length) + { + packet->append(" AVG_ROW_LENGTH="); + p=longlong10_to_str(table->avg_row_length, buff,10); + packet->append(buff, (uint) (p - buff)); + } if (table->db_create_options & HA_OPTION_PACK_KEYS) packet->append(" PACK_KEYS=1", 12); @@ -919,6 +925,11 @@ store_create_info(THD *thd, TABLE *table, String *packet) packet->append(" CHECKSUM=1", 11); if (table->db_create_options & HA_OPTION_DELAY_KEY_WRITE) packet->append(" DELAY_KEY_WRITE=1",18); + if (table->row_type != ROW_TYPE_DEFAULT) + { + packet->append(" ROW_FORMAT=",12); + packet->append(ha_row_type[(uint) table->row_type]); + } table->file->append_create_info(packet); if (table->comment && table->comment[0]) { From db82d30bf0419d509101110ade2f8f7902900fa1 Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Tue, 2 Oct 2001 22:21:14 +0300 Subject: [PATCH 5/5] Fix for make dist Made replication test portable Fixed buffer overrun bug in replication --- client/Makefile.am | 4 ++-- mysql-test/t/rpl000017-slave.sh | 4 ++-- sql/slave.cc | 8 ++++---- strings/strmake.c | 3 ++- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/client/Makefile.am b/client/Makefile.am index 380c9f2acbe..d1b16870f67 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -19,13 +19,13 @@ INCLUDES = -I$(srcdir)/../include \ -I../include -I$(srcdir)/.. -I$(top_srcdir) \ -I.. -noinst_HEADERS = client_priv.h LIBS = @CLIENT_LIBS@ LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysql/libmysqlclient.la bin_PROGRAMS = mysql mysqladmin mysqlcheck mysqlshow \ mysqldump mysqlimport mysqltest mysqlbinlog noinst_PROGRAMS = insert_test select_test thread_test -noinst_HEADERS = sql_string.h completion_hash.h my_readline.h +noinst_HEADERS = sql_string.h completion_hash.h my_readline.h \ + client_priv.h mysql_SOURCES = mysql.cc readline.cc sql_string.cc completion_hash.cc mysql_LDADD = @readline_link@ @TERMCAP_LIB@ $(LDADD) $(CXXLDFLAGS) mysql_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) diff --git a/mysql-test/t/rpl000017-slave.sh b/mysql-test/t/rpl000017-slave.sh index 269e144e278..0588859c591 100755 --- a/mysql-test/t/rpl000017-slave.sh +++ b/mysql-test/t/rpl000017-slave.sh @@ -3,7 +3,7 @@ master-bin.001 4 127.0.0.1 replicate -aaaaaaaaaaaaaaab -9306 +aaaaaaaaaaaaaaabthispartofthepasswordisnotused +$MASTER_MYPORT 1 EOF diff --git a/sql/slave.cc b/sql/slave.cc index 52cde738b9a..2e0861bbd56 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -299,7 +299,7 @@ static int init_strvar_from_file(char* var, int max_size, IO_CACHE* f, } else if (default_val) { - strmake(var, default_val, max_size); + strmake(var, default_val, max_size-1); return 0; } return 1; @@ -530,14 +530,14 @@ int init_master_info(MASTER_INFO* mi) } mi->log_file_name[length-1]= 0; // kill \n - char buf[FN_REFLEN]; - if(!my_b_gets(&mi->file, buf, sizeof(buf))) + /* Reuse fname buffer */ + if(!my_b_gets(&mi->file, fname, sizeof(fname))) { msg="Error reading log file position from master info file"; goto error; } + mi->pos = strtoull(fname,(char**) 0, 10); - mi->pos = strtoull(buf,(char**) 0, 10); mi->fd = fd; if(init_strvar_from_file(mi->host, sizeof(mi->host), &mi->file, master_host) || diff --git a/strings/strmake.c b/strings/strmake.c index d4edce689a5..66a230338a1 100644 --- a/strings/strmake.c +++ b/strings/strmake.c @@ -22,7 +22,8 @@ strmake(dst,src,length) moves length characters, or until end, of src to dst and appends a closing NUL to dst. - strmake() returns pointer to closing null; + Note that is strlen(src) >= length then dst[length] will be set to \0 + strmake() returns pointer to closing null */ #include