From a76ecc5bc78365a2ecdf1f96d9c238d5ecbe30c4 Mon Sep 17 00:00:00 2001 From: "sergefp@mysql.com" <> Date: Mon, 18 Apr 2005 05:21:44 +0400 Subject: [PATCH 1/7] Fix for BUG#9103: Don't produce data truncation warnings from within cp_buffer_from_ref(). This function is only used to make index search tuples and data truncation that occurs here has no relation with truncated values being saved into tables. --- mysql-test/r/update.result | 14 ++++++++++++++ mysql-test/t/update.test | 12 ++++++++++++ sql/opt_range.cc | 2 +- sql/sql_select.cc | 19 +++++++++++++------ sql/sql_select.h | 2 +- 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result index 4a9e95fb89e..d83952e118b 100644 --- a/mysql-test/r/update.result +++ b/mysql-test/r/update.result @@ -226,3 +226,17 @@ select * from t1; a b 0 2 drop table t1; +create table t1 (a int, b varchar(10), key b(b(5))) engine=myisam; +create table t2 (a int, b varchar(10)) engine=myisam; +insert into t1 values ( 1, 'abcd1e'); +insert into t1 values ( 2, 'abcd2e'); +insert into t2 values ( 1, 'abcd1e'); +insert into t2 values ( 2, 'abcd2e'); +analyze table t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +update t1, t2 set t1.a = t2.a where t2.b = t1.b; +show warnings; +Level Code Message +drop table t1, t2; diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test index 8eb3a924ee3..6a90fb95760 100644 --- a/mysql-test/t/update.test +++ b/mysql-test/t/update.test @@ -189,3 +189,15 @@ insert into t1 values (0, '1'); update t1 set b = b + 1 where a = 0; select * from t1; drop table t1; + +# BUG#9103 "Erroneous data truncation warnings on multi-table updates" +create table t1 (a int, b varchar(10), key b(b(5))) engine=myisam; +create table t2 (a int, b varchar(10)) engine=myisam; +insert into t1 values ( 1, 'abcd1e'); +insert into t1 values ( 2, 'abcd2e'); +insert into t2 values ( 1, 'abcd1e'); +insert into t2 values ( 2, 'abcd2e'); +analyze table t1,t2; +update t1, t2 set t1.a = t2.a where t2.b = t1.b; +show warnings; +drop table t1, t2; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index e2cae0598a0..33223b83894 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2574,7 +2574,7 @@ QUICK_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table, TABLE_REF *ref) if (!quick) return 0; /* no ranges found */ - if (cp_buffer_from_ref(ref)) + if (cp_buffer_from_ref(thd, ref)) { if (thd->is_fatal_error) goto err; // out of memory diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3f133a473ac..14dc8463e38 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -6185,7 +6185,7 @@ join_read_const(JOIN_TAB *tab) TABLE *table= tab->table; if (table->status & STATUS_GARBAGE) // If first read { - if (cp_buffer_from_ref(&tab->ref)) + if (cp_buffer_from_ref(tab->join->thd, &tab->ref)) error=HA_ERR_KEY_NOT_FOUND; else { @@ -6248,7 +6248,7 @@ join_read_always_key(JOIN_TAB *tab) if (!table->file->inited) table->file->ha_index_init(tab->ref.key); - if (cp_buffer_from_ref(&tab->ref)) + if (cp_buffer_from_ref(tab->join->thd, &tab->ref)) return -1; if ((error=table->file->index_read(table->record[0], tab->ref.key_buff, @@ -6275,7 +6275,7 @@ join_read_last_key(JOIN_TAB *tab) if (!table->file->inited) table->file->ha_index_init(tab->ref.key); - if (cp_buffer_from_ref(&tab->ref)) + if (cp_buffer_from_ref(tab->join->thd, &tab->ref)) return -1; if ((error=table->file->index_read_last(table->record[0], tab->ref.key_buff, @@ -6449,7 +6449,7 @@ join_ft_read_first(JOIN_TAB *tab) if (!table->file->inited) table->file->ha_index_init(tab->ref.key); #if NOT_USED_YET - if (cp_buffer_from_ref(&tab->ref)) // as ft-key doesn't use store_key's + if (cp_buffer_from_ref(tab->join->thd, &tab->ref)) // as ft-key doesn't use store_key's return -1; // see also FT_SELECT::init() #endif table->file->ft_init(); @@ -8168,7 +8168,8 @@ cmp_buffer_with_ref(JOIN_TAB *tab) { memcpy(tab->ref.key_buff2, tab->ref.key_buff, tab->ref.key_length); } - if ((tab->ref.key_err=cp_buffer_from_ref(&tab->ref)) || diff) + if ((tab->ref.key_err= cp_buffer_from_ref(tab->join->thd, &tab->ref)) || + diff) return 1; return memcmp(tab->ref.key_buff2, tab->ref.key_buff, tab->ref.key_length) != 0; @@ -8176,11 +8177,17 @@ cmp_buffer_with_ref(JOIN_TAB *tab) bool -cp_buffer_from_ref(TABLE_REF *ref) +cp_buffer_from_ref(THD *thd, TABLE_REF *ref) { + enum enum_check_fields save_count_cuted_fields= thd->count_cuted_fields; + thd->count_cuted_fields= CHECK_FIELD_IGNORE; for (store_key **copy=ref->key_copy ; *copy ; copy++) if ((*copy)->copy()) + { + thd->count_cuted_fields= save_count_cuted_fields; return 1; // Something went wrong + } + thd->count_cuted_fields= save_count_cuted_fields; return 0; } diff --git a/sql/sql_select.h b/sql/sql_select.h index ab3b442ef74..caf4574fbec 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -445,7 +445,7 @@ public: const char *name() const { return "const"; } }; -bool cp_buffer_from_ref(TABLE_REF *ref); +bool cp_buffer_from_ref(THD *thd, TABLE_REF *ref); bool error_if_full_join(JOIN *join); int report_error(TABLE *table, int error); int safe_index_read(JOIN_TAB *tab); From 4a4c9017add2b693c64526b5f46181c128459d5b Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 19 Apr 2005 13:12:19 +0200 Subject: [PATCH 2/7] BUG#9568 mysql segfaults from CTRL-R - Segfault because of passing a 64-bit pointer to 32 bit integer. - Add new include config_readline.h which will calculate some new defines based on what is found in config.h - This file was originally included in readline 4.3 as config.h.in, only the part that makes new defines have been moved to this file. --- cmd-line-utils/readline/bind.c | 4 +--- cmd-line-utils/readline/callback.c | 4 +--- cmd-line-utils/readline/complete.c | 4 +--- cmd-line-utils/readline/config_readline.h | 26 +++++++++++++++++++++++ cmd-line-utils/readline/display.c | 4 +--- cmd-line-utils/readline/funmap.c | 4 +--- cmd-line-utils/readline/histexpand.c | 4 +--- cmd-line-utils/readline/histfile.c | 4 +--- cmd-line-utils/readline/history.c | 4 +--- cmd-line-utils/readline/histsearch.c | 4 +--- cmd-line-utils/readline/input.c | 4 +--- cmd-line-utils/readline/isearch.c | 4 +--- cmd-line-utils/readline/keymaps.c | 4 +--- cmd-line-utils/readline/kill.c | 4 +--- cmd-line-utils/readline/macro.c | 4 +--- cmd-line-utils/readline/mbutil.c | 4 +--- cmd-line-utils/readline/misc.c | 4 +--- cmd-line-utils/readline/nls.c | 4 +--- cmd-line-utils/readline/parens.c | 4 +--- cmd-line-utils/readline/readline.c | 4 +--- cmd-line-utils/readline/rltty.c | 4 +--- cmd-line-utils/readline/search.c | 4 +--- cmd-line-utils/readline/shell.c | 4 +--- cmd-line-utils/readline/signals.c | 4 +--- cmd-line-utils/readline/terminal.c | 4 +--- cmd-line-utils/readline/text.c | 4 +--- cmd-line-utils/readline/tilde.c | 4 +--- cmd-line-utils/readline/undo.c | 4 +--- cmd-line-utils/readline/util.c | 4 +--- cmd-line-utils/readline/vi_mode.c | 4 +--- cmd-line-utils/readline/xmalloc.c | 4 +--- 31 files changed, 56 insertions(+), 90 deletions(-) create mode 100644 cmd-line-utils/readline/config_readline.h diff --git a/cmd-line-utils/readline/bind.c b/cmd-line-utils/readline/bind.c index fd01049f09f..0e8efc5c636 100644 --- a/cmd-line-utils/readline/bind.c +++ b/cmd-line-utils/readline/bind.c @@ -21,9 +21,7 @@ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include #include diff --git a/cmd-line-utils/readline/callback.c b/cmd-line-utils/readline/callback.c index a8f4323c929..737f483eed0 100644 --- a/cmd-line-utils/readline/callback.c +++ b/cmd-line-utils/readline/callback.c @@ -21,9 +21,7 @@ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include "rlconf.h" diff --git a/cmd-line-utils/readline/complete.c b/cmd-line-utils/readline/complete.c index 693550c9945..749875e0e5e 100644 --- a/cmd-line-utils/readline/complete.c +++ b/cmd-line-utils/readline/complete.c @@ -21,9 +21,7 @@ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include #include diff --git a/cmd-line-utils/readline/config_readline.h b/cmd-line-utils/readline/config_readline.h new file mode 100644 index 00000000000..99da4445228 --- /dev/null +++ b/cmd-line-utils/readline/config_readline.h @@ -0,0 +1,26 @@ +/* config-readline.h Maintained by hand. Contains the readline specific + parts from config.h.in in readline 4.3 */ + +#if defined (HAVE_CONFIG_H) +# include +#endif + +/* Ultrix botches type-ahead when switching from canonical to + non-canonical mode, at least through version 4.3 */ +#if !defined (HAVE_TERMIOS_H) || !defined (HAVE_TCGETATTR) || defined (ultrix) +# define TERMIOS_MISSING +#endif + +#if defined (STRCOLL_BROKEN) +# undef HAVE_STRCOLL +#endif + +#if defined (__STDC__) && defined (HAVE_STDARG_H) +# define PREFER_STDARG +# define USE_VARARGS +#else +# if defined (HAVE_VARARGS_H) +# define PREFER_VARARGS +# define USE_VARARGS +# endif +#endif diff --git a/cmd-line-utils/readline/display.c b/cmd-line-utils/readline/display.c index f393e7e8516..7c393f1c8a5 100644 --- a/cmd-line-utils/readline/display.c +++ b/cmd-line-utils/readline/display.c @@ -21,9 +21,7 @@ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include diff --git a/cmd-line-utils/readline/funmap.c b/cmd-line-utils/readline/funmap.c index fe9a1da43d7..53fd22754ab 100644 --- a/cmd-line-utils/readline/funmap.c +++ b/cmd-line-utils/readline/funmap.c @@ -21,9 +21,7 @@ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #if !defined (BUFSIZ) #include diff --git a/cmd-line-utils/readline/histexpand.c b/cmd-line-utils/readline/histexpand.c index f01d54c5b1d..eed8d5a365e 100644 --- a/cmd-line-utils/readline/histexpand.c +++ b/cmd-line-utils/readline/histexpand.c @@ -22,9 +22,7 @@ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include diff --git a/cmd-line-utils/readline/histfile.c b/cmd-line-utils/readline/histfile.c index 60a91251b7a..77f757eac1d 100644 --- a/cmd-line-utils/readline/histfile.c +++ b/cmd-line-utils/readline/histfile.c @@ -25,9 +25,7 @@ you can call. I think I have done that. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include diff --git a/cmd-line-utils/readline/history.c b/cmd-line-utils/readline/history.c index 4242f33efe1..759ff9e0de9 100644 --- a/cmd-line-utils/readline/history.c +++ b/cmd-line-utils/readline/history.c @@ -25,9 +25,7 @@ you can call. I think I have done that. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include diff --git a/cmd-line-utils/readline/histsearch.c b/cmd-line-utils/readline/histsearch.c index d94fd6cd9c6..ffc97d720db 100644 --- a/cmd-line-utils/readline/histsearch.c +++ b/cmd-line-utils/readline/histsearch.c @@ -22,9 +22,7 @@ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include #if defined (HAVE_STDLIB_H) diff --git a/cmd-line-utils/readline/input.c b/cmd-line-utils/readline/input.c index 1442c5ef155..d9c52dfcec8 100644 --- a/cmd-line-utils/readline/input.c +++ b/cmd-line-utils/readline/input.c @@ -21,9 +21,7 @@ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include #include diff --git a/cmd-line-utils/readline/isearch.c b/cmd-line-utils/readline/isearch.c index 137842a841f..1de16c6a56c 100644 --- a/cmd-line-utils/readline/isearch.c +++ b/cmd-line-utils/readline/isearch.c @@ -26,9 +26,7 @@ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include diff --git a/cmd-line-utils/readline/keymaps.c b/cmd-line-utils/readline/keymaps.c index 12506d3aab2..9972d83e4f1 100644 --- a/cmd-line-utils/readline/keymaps.c +++ b/cmd-line-utils/readline/keymaps.c @@ -20,9 +20,7 @@ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #if defined (HAVE_STDLIB_H) # include diff --git a/cmd-line-utils/readline/kill.c b/cmd-line-utils/readline/kill.c index f8c6961bbd3..32a661f076f 100644 --- a/cmd-line-utils/readline/kill.c +++ b/cmd-line-utils/readline/kill.c @@ -21,9 +21,7 @@ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include diff --git a/cmd-line-utils/readline/macro.c b/cmd-line-utils/readline/macro.c index 7ab4b6ca657..7f5c39f7d86 100644 --- a/cmd-line-utils/readline/macro.c +++ b/cmd-line-utils/readline/macro.c @@ -21,9 +21,7 @@ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include diff --git a/cmd-line-utils/readline/mbutil.c b/cmd-line-utils/readline/mbutil.c index debad6320ce..3113b7b0538 100644 --- a/cmd-line-utils/readline/mbutil.c +++ b/cmd-line-utils/readline/mbutil.c @@ -21,9 +21,7 @@ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include #include diff --git a/cmd-line-utils/readline/misc.c b/cmd-line-utils/readline/misc.c index 94ad433473b..858d09dbe90 100644 --- a/cmd-line-utils/readline/misc.c +++ b/cmd-line-utils/readline/misc.c @@ -21,9 +21,7 @@ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #if defined (HAVE_UNISTD_H) # include diff --git a/cmd-line-utils/readline/nls.c b/cmd-line-utils/readline/nls.c index 706c8195c10..6555c50c22b 100644 --- a/cmd-line-utils/readline/nls.c +++ b/cmd-line-utils/readline/nls.c @@ -21,9 +21,7 @@ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include diff --git a/cmd-line-utils/readline/parens.c b/cmd-line-utils/readline/parens.c index 54ef1f3695f..5d4a08a0ce8 100644 --- a/cmd-line-utils/readline/parens.c +++ b/cmd-line-utils/readline/parens.c @@ -23,9 +23,7 @@ #include "rlconf.h" -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include #include diff --git a/cmd-line-utils/readline/readline.c b/cmd-line-utils/readline/readline.c index 28801f19dfc..2c0bb499b7b 100644 --- a/cmd-line-utils/readline/readline.c +++ b/cmd-line-utils/readline/readline.c @@ -22,9 +22,7 @@ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include #include "posixstat.h" diff --git a/cmd-line-utils/readline/rltty.c b/cmd-line-utils/readline/rltty.c index 09702e9e755..9a2cef4b279 100644 --- a/cmd-line-utils/readline/rltty.c +++ b/cmd-line-utils/readline/rltty.c @@ -22,9 +22,7 @@ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include #include diff --git a/cmd-line-utils/readline/search.c b/cmd-line-utils/readline/search.c index ac47596a3f8..637534924f1 100644 --- a/cmd-line-utils/readline/search.c +++ b/cmd-line-utils/readline/search.c @@ -22,9 +22,7 @@ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include #include diff --git a/cmd-line-utils/readline/shell.c b/cmd-line-utils/readline/shell.c index ad27cc14884..fd6a2816309 100644 --- a/cmd-line-utils/readline/shell.c +++ b/cmd-line-utils/readline/shell.c @@ -22,9 +22,7 @@ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include diff --git a/cmd-line-utils/readline/signals.c b/cmd-line-utils/readline/signals.c index 0a1468b6b2a..4609598ff98 100644 --- a/cmd-line-utils/readline/signals.c +++ b/cmd-line-utils/readline/signals.c @@ -21,9 +21,7 @@ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include /* Just for NULL. Yuck. */ #include diff --git a/cmd-line-utils/readline/terminal.c b/cmd-line-utils/readline/terminal.c index 397b10a1d46..a506fa6de09 100644 --- a/cmd-line-utils/readline/terminal.c +++ b/cmd-line-utils/readline/terminal.c @@ -21,9 +21,7 @@ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include #include "posixstat.h" diff --git a/cmd-line-utils/readline/text.c b/cmd-line-utils/readline/text.c index 81a468fdbda..d98b266edfe 100644 --- a/cmd-line-utils/readline/text.c +++ b/cmd-line-utils/readline/text.c @@ -21,9 +21,7 @@ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #if defined (HAVE_UNISTD_H) # include diff --git a/cmd-line-utils/readline/tilde.c b/cmd-line-utils/readline/tilde.c index fab4aab65ad..456a6bcb357 100644 --- a/cmd-line-utils/readline/tilde.c +++ b/cmd-line-utils/readline/tilde.c @@ -19,9 +19,7 @@ along with Readline; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #if defined (HAVE_UNISTD_H) # ifdef _MINIX diff --git a/cmd-line-utils/readline/undo.c b/cmd-line-utils/readline/undo.c index df913195fad..947da3d00d0 100644 --- a/cmd-line-utils/readline/undo.c +++ b/cmd-line-utils/readline/undo.c @@ -22,9 +22,7 @@ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include diff --git a/cmd-line-utils/readline/util.c b/cmd-line-utils/readline/util.c index 2a6e4e3398a..403b3d544d9 100644 --- a/cmd-line-utils/readline/util.c +++ b/cmd-line-utils/readline/util.c @@ -21,9 +21,7 @@ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include #include diff --git a/cmd-line-utils/readline/vi_mode.c b/cmd-line-utils/readline/vi_mode.c index 01df589f625..e8ad05d866f 100644 --- a/cmd-line-utils/readline/vi_mode.c +++ b/cmd-line-utils/readline/vi_mode.c @@ -31,9 +31,7 @@ #if defined (VI_MODE) -#if defined (HAVE_CONFIG_H) -# include -#endif +#include "config_readline.h" #include diff --git a/cmd-line-utils/readline/xmalloc.c b/cmd-line-utils/readline/xmalloc.c index 8985d340d39..698807addf9 100644 --- a/cmd-line-utils/readline/xmalloc.c +++ b/cmd-line-utils/readline/xmalloc.c @@ -20,9 +20,7 @@ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY -#if defined (HAVE_CONFIG_H) -#include -#endif +#include "config_readline.h" #include From ff665c9513658c383f2b5cc0261eaf998c1b158d Mon Sep 17 00:00:00 2001 From: "jani@a193-229-222-105.elisa-laajakaista.fi" <> Date: Wed, 20 Apr 2005 10:37:03 +0300 Subject: [PATCH 3/7] Fixed Bug#8046 --mysqld of mysqld_safe must contain substring "mysqld" --- configure.in | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/configure.in b/configure.in index ff4527ee09f..f4ced66a06d 100644 --- a/configure.in +++ b/configure.in @@ -451,33 +451,33 @@ PS=$ac_cv_path_PS # Linux style if $PS p $$ 2> /dev/null | grep $0 > /dev/null then - FIND_PROC="$PS p \$\$PID | grep mysqld > /dev/null" + FIND_PROC="$PS p \$\$PID | grep \$\$MYSQLD > /dev/null" # Solaris elif $PS -fp $$ 2> /dev/null | grep $0 > /dev/null then - FIND_PROC="$PS -p \$\$PID | grep mysqld > /dev/null" + FIND_PROC="$PS -p \$\$PID | grep \$\$MYSQLD > /dev/null" # BSD style elif $PS -uaxww 2> /dev/null | grep $0 > /dev/null then - FIND_PROC="$PS -uaxww | grep mysqld | grep \" \$\$PID \" > /dev/null" + FIND_PROC="$PS -uaxww | grep \$\$MYSQLD | grep \" \$\$PID \" > /dev/null" # SysV style elif $PS -ef 2> /dev/null | grep $0 > /dev/null then - FIND_PROC="$PS -ef | grep mysqld | grep \" \$\$PID \" > /dev/null" + FIND_PROC="$PS -ef | grep \$\$MYSQLD | grep \" \$\$PID \" > /dev/null" # Do anybody use this? elif $PS $$ 2> /dev/null | grep $0 > /dev/null then - FIND_PROC="$PS \$\$PID | grep mysqld > /dev/null" + FIND_PROC="$PS \$\$PID | grep \$\$MYSQLD > /dev/null" else case $SYSTEM_TYPE in *freebsd*) - FIND_PROC="$PS p \$\$PID | grep mysqld > /dev/null" + FIND_PROC="$PS p \$\$PID | grep \$\$MYSQLD > /dev/null" ;; *darwin*) - FIND_PROC="$PS -uaxww | grep mysqld | grep \" \$\$PID \" > /dev/null" + FIND_PROC="$PS -uaxww | grep \$\$MYSQLD | grep \" \$\$PID \" > /dev/null" ;; *cygwin*) - FIND_PROC="$PS -e | grep mysqld | grep \" \$\$PID \" > /dev/null" + FIND_PROC="$PS -e | grep \$\$MYSQLD | grep \" \$\$PID \" > /dev/null" ;; *netware*) FIND_PROC= From b26d29a081026bdcd9ab3441566beb04a758d42e Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 20 Apr 2005 12:02:07 +0200 Subject: [PATCH 4/7] After review fix --- cmd-line-utils/readline/config_readline.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd-line-utils/readline/config_readline.h b/cmd-line-utils/readline/config_readline.h index 99da4445228..141989ec3c9 100644 --- a/cmd-line-utils/readline/config_readline.h +++ b/cmd-line-utils/readline/config_readline.h @@ -1,12 +1,16 @@ -/* config-readline.h Maintained by hand. Contains the readline specific - parts from config.h.in in readline 4.3 */ +/* + config-readline.h Maintained by hand. Contains the readline specific + parts from config.h.in in readline 4.3 +*/ #if defined (HAVE_CONFIG_H) # include #endif -/* Ultrix botches type-ahead when switching from canonical to - non-canonical mode, at least through version 4.3 */ +/* + Ultrix botches type-ahead when switching from canonical to + non-canonical mode, at least through version 4.3 +*/ #if !defined (HAVE_TERMIOS_H) || !defined (HAVE_TCGETATTR) || defined (ultrix) # define TERMIOS_MISSING #endif From 189d6b502bbdf3b9e295177dc4f61ed28ca72db6 Mon Sep 17 00:00:00 2001 From: "pem@mysql.comhem.se" <> Date: Wed, 20 Apr 2005 15:37:07 +0200 Subject: [PATCH 5/7] Fixed BUG#6898: Stored procedure crash if GOTO statements exist Bug in the optimizer caused an infinite loop for weird code. --- mysql-test/r/sp.result | 9 +++++++++ mysql-test/t/sp.test | 16 ++++++++++++++++ sql/sp_head.cc | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 4bb1640f0eb..d911fc68b7c 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -2958,4 +2958,13 @@ select @x| set global query_cache_size = @qcs1| delete from t1| drop function bug9902| +drop procedure if exists bug6898| +create procedure bug6898() +begin +goto label1; +label label1; +begin end; +goto label1; +end| +drop procedure bug6898| drop table t1,t2; diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 4101a7a4bfa..d5298645f76 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -3628,6 +3628,22 @@ delete from t1| drop function bug9902| +# +# BUG#6898: Stored procedure crash if GOTO statements exist +# +--disable_warnings +drop procedure if exists bug6898| +--enable_warnings +create procedure bug6898() +begin + goto label1; + label label1; + begin end; + goto label1; +end| +drop procedure bug6898| + + # # BUG#NNNN: New bug synopsis # diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 0fe9c449540..c505ef05b57 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1499,7 +1499,7 @@ sp_instr_jump::opt_shortcut_jump(sp_head *sp, sp_instr *start) { uint ndest; - if (start == i) + if (start == i || this == i) break; ndest= i->opt_shortcut_jump(sp, start); if (ndest == dest) From 54dfe4a66a5bc2a17098aa0597b3a1a299cb61f0 Mon Sep 17 00:00:00 2001 From: "pem@mysql.comhem.se" <> Date: Wed, 20 Apr 2005 17:59:28 +0200 Subject: [PATCH 6/7] Fixed BUG#7047: Stored procedure crash if alter procedure by simply disallowing alter procedure/function in an SP (as for drop). --- mysql-test/r/sp-error.result | 13 +++++++++++-- mysql-test/t/sp-error.test | 14 ++++++++++++++ sql/share/errmsg.txt | 2 +- sql/sql_yacc.yy | 10 ++++++++++ 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 3f224d790f7..5ee1d46f3c9 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -457,9 +457,9 @@ ERROR 42S22: Unknown column 'aa' in 'order clause' drop procedure bug2653_1| drop procedure bug2653_2| create procedure bug4344() drop procedure bug4344| -ERROR HY000: Can't drop a PROCEDURE from within another stored routine +ERROR HY000: Can't drop or alter a PROCEDURE from within another stored routine create procedure bug4344() drop function bug4344| -ERROR HY000: Can't drop a FUNCTION from within another stored routine +ERROR HY000: Can't drop or alter a FUNCTION from within another stored routine drop procedure if exists bug3294| create procedure bug3294() begin @@ -585,4 +585,13 @@ end; end; end| drop procedure bug9073| +create procedure bug7047() +alter procedure bug7047| +ERROR HY000: Can't drop or alter a PROCEDURE from within another stored routine +create function bug7047() returns int +begin +alter function bug7047; +return 0; +end| +ERROR HY000: Can't drop or alter a FUNCTION from within another stored routine drop table t1| diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index ecbc98f86e9..cb4ebf080f4 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -817,6 +817,20 @@ end| drop procedure bug9073| +# +# BUG#7047: Stored procedure crash if alter procedure +# +--error ER_SP_NO_DROP_SP +create procedure bug7047() + alter procedure bug7047| +--error ER_SP_NO_DROP_SP +create function bug7047() returns int +begin + alter function bug7047; + return 0; +end| + + # # BUG#NNNN: New bug synopsis # diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index e93229a4a3e..8d7a1fe0093 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5213,7 +5213,7 @@ ER_VIEW_INVALID eng "View '%-.64s.%-.64s' references invalid table(s) or column(s) or function(s)" rus "View '%-.64s.%-.64s' ссылается на несуществующие таблицы или столбцы или функции" ER_SP_NO_DROP_SP - eng "Can't drop a %s from within another stored routine" + eng "Can't drop or alter a %s from within another stored routine" ER_SP_GOTO_IN_HNDLR eng "GOTO is not allowed in a stored procedure handler" ER_TRG_ALREADY_EXISTS diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 9aa5d7fb4fc..7f5255aa764 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3305,6 +3305,11 @@ alter: { LEX *lex= Lex; + if (lex->sphead) + { + my_error(ER_SP_NO_DROP_SP, MYF(0), "PROCEDURE"); + YYABORT; + } bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics)); } sp_a_chistics @@ -3318,6 +3323,11 @@ alter: { LEX *lex= Lex; + if (lex->sphead) + { + my_error(ER_SP_NO_DROP_SP, MYF(0), "FUNCTION"); + YYABORT; + } bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics)); } sp_a_chistics From c2959178ca9c3eacbd59d854899ecdcdb7ff72de Mon Sep 17 00:00:00 2001 From: "sergefp@mysql.com" <> Date: Thu, 21 Apr 2005 01:55:33 +0400 Subject: [PATCH 7/7] Fix for BUG#10037 * Add 0.01 to cost of 'range'+'using index' scan to avoid optimizer choice races with 'index' scan. --- mysql-test/r/range.result | 4 ++-- sql/opt_range.cc | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 256c4ee6431..fea5754d704 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -256,12 +256,12 @@ INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2); explain select * from t1, t2 where (t1.key1 table->file->ref_length) + 1); read_time=((double) (records+keys_per_block-1)/ (double) keys_per_block); - return read_time; + /* Add 0.01 to avoid cost races between 'range' and 'index' */ + return read_time + 0.01; } @@ -7912,6 +7913,8 @@ int QUICK_GROUP_MIN_MAX_SELECT::reset(void) file->extra(HA_EXTRA_KEYREAD); /* We need only the key attributes */ result= file->ha_index_init(index); result= file->index_last(record); + if (result == HA_ERR_END_OF_FILE) + DBUG_RETURN(0); if (result) DBUG_RETURN(result); if (quick_prefix_select && quick_prefix_select->reset())