From 0aff963ad72d8061e85956e99efffb3bf0bfa504 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 18 Oct 2005 00:48:34 +0400 Subject: [PATCH 1/7] fix for im_life_cycle test: replace im instance port number with a constant string. The lack of this --replace resulted in the test failing on all build hosts mysql-test/r/im_life_cycle.result: fix result mysql-test/t/im_life_cycle.imtest: replace instance port number in result, as it could be set differently for different test runs. --- mysql-test/r/im_life_cycle.result | 2 +- mysql-test/t/im_life_cycle.imtest | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/im_life_cycle.result b/mysql-test/r/im_life_cycle.result index 810953e0578..f8eaf0ccb46 100644 --- a/mysql-test/r/im_life_cycle.result +++ b/mysql-test/r/im_life_cycle.result @@ -21,7 +21,7 @@ instance_name status version mysqld2 online VERSION SHOW VARIABLES LIKE 'port'; Variable_name Value -port 9312 +port IM_MYSQLD1_PORT STOP INSTANCE mysqld2; SHOW INSTANCES; instance_name status diff --git a/mysql-test/t/im_life_cycle.imtest b/mysql-test/t/im_life_cycle.imtest index fff57e16eab..c2b1c9a56ec 100644 --- a/mysql-test/t/im_life_cycle.imtest +++ b/mysql-test/t/im_life_cycle.imtest @@ -46,6 +46,7 @@ SHOW INSTANCE STATUS mysqld2; --connect (mysql_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK) --connection mysql_con +--replace_result $IM_MYSQLD1_PORT IM_MYSQLD1_PORT SHOW VARIABLES LIKE 'port'; --connection default From 72a2de023193f1bd127831ebfddd35e4c8c8e103 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 18 Oct 2005 17:53:09 -0500 Subject: [PATCH 2/7] readd the my_cgets call that SergeyV originally put in --- client/mysql.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/mysql.cc b/client/mysql.cc index 8d5e576ca23..27277f0eb93 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1010,10 +1010,12 @@ static int read_and_execute(bool interactive) #elif defined(__WIN__) if (!tmpbuf.is_alloced()) tmpbuf.alloc(65535); + tmpbuf.length(0); buffer.length(0); unsigned long clen; do { + line= my_cgets((char*)tmpbuf.ptr(), tmpbuf.alloced_length()-1, &clen); buffer.append(line, clen); /* if we got buffer fully filled than there is a chance that From a43ec392af5109f3c3f99ca670148e5eafdd6f68 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Oct 2005 02:53:03 +0200 Subject: [PATCH 3/7] mysql.spec.sh: Enabled yaSSL mysql-test-run.pl: Increased test case timeout from 15 min mysql-test/mysql-test-run.pl: Increased test case timeout from 15 min support-files/mysql.spec.sh: Enabled yaSSL --- mysql-test/mysql-test-run.pl | 2 +- support-files/mysql.spec.sh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 35f26199fc8..063d1e2f2cc 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -242,7 +242,7 @@ our $opt_sleep_time_after_restart= 1; our $opt_sleep_time_for_delete= 10; our $opt_testcase_timeout; our $opt_suite_timeout; -my $default_testcase_timeout= 10; # 10 min max +my $default_testcase_timeout= 15; # 15 min max my $default_suite_timeout= 120; # 2 hours max our $opt_socket; diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index d4d0b4e810b..65d74474386 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -239,6 +239,7 @@ sh -c "PATH=\"${MYSQL_BUILD_PATH:-$PATH}\" \ --with-unix-socket-path=/var/lib/mysql/mysql.sock \ --prefix=/ \ --with-extra-charsets=complex \ + --with-yassl \ --exec-prefix=%{_exec_prefix} \ --libexecdir=%{_sbindir} \ --libdir=%{_libdir} \ @@ -684,6 +685,9 @@ fi # itself - note that they must be ordered by date (important when # merging BK trees) %changelog +* Wed Oct 19 2005 Kent Boortz + +- Enabled yaSSL support * Sat Oct 15 2005 Kent Boortz From e27cb111cd1c451dcba8111c2ed1ca97037dd5ad Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Oct 2005 22:00:12 +0200 Subject: [PATCH 4/7] mysql.spec.sh: Made yaSSL support an option (off by default) support-files/mysql.spec.sh: Made yaSSL support an option (off by default) --- support-files/mysql.spec.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 65d74474386..265f576cd86 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -1,8 +1,15 @@ %define mysql_version @VERSION@ + # use "rpmbuild --with static" or "rpm --define '_with_static 1'" (for RPM 3.x) # to enable static linking (off by default) %{?_with_static:%define STATIC_BUILD 1} %{!?_with_static:%define STATIC_BUILD 0} + +# use "rpmbuild --with yassl" or "rpm --define '_with_yassl 1'" (for RPM 3.x) +# to build with yaSSL support (off by default) +%{?_with_yassl:%define YASSL_BUILD 1} +%{!?_with_yassl:%define YASSL_BUILD 0} + %if %{STATIC_BUILD} %define release 0 %else @@ -239,7 +246,9 @@ sh -c "PATH=\"${MYSQL_BUILD_PATH:-$PATH}\" \ --with-unix-socket-path=/var/lib/mysql/mysql.sock \ --prefix=/ \ --with-extra-charsets=complex \ +%if %{YASSL_BUILD} --with-yassl \ +%endif --exec-prefix=%{_exec_prefix} \ --libexecdir=%{_sbindir} \ --libdir=%{_libdir} \ @@ -687,6 +696,10 @@ fi %changelog * Wed Oct 19 2005 Kent Boortz +- Made yaSSL support an option (off by default) + +* Wed Oct 19 2005 Kent Boortz + - Enabled yaSSL support * Sat Oct 15 2005 Kent Boortz From ad731d3888ff0ef87313d41c365a30fdf18cee68 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 20 Oct 2005 13:37:54 +0200 Subject: [PATCH 5/7] configure.in: Set the version number to 5.0.16 configure.in: Set the version number to 5.0.16 --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index c700c5b9896..40ff480bb94 100644 --- a/configure.in +++ b/configure.in @@ -7,7 +7,7 @@ AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! # remember to also change ndb version below and update version.c in ndb -AM_INIT_AUTOMAKE(mysql, 5.0.15) +AM_INIT_AUTOMAKE(mysql, 5.0.16) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 @@ -18,7 +18,7 @@ SHARED_LIB_VERSION=15:0:0 # ndb version NDB_VERSION_MAJOR=5 NDB_VERSION_MINOR=0 -NDB_VERSION_BUILD=15 +NDB_VERSION_BUILD=16 NDB_VERSION_STATUS="" # Set all version vars based on $VERSION. How do we do this more elegant ? From a5f2355cf6d9d4dd71de428410d0b805340c2d71 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 21 Oct 2005 03:25:07 +0400 Subject: [PATCH 6/7] Fix Bug#14107 (IM test failures on QNX) (v.2 with post-review fixes) server-tools/instance-manager/instance.cc: On QNX one cannot use fork() in multithreaded environment. Therefore we should use QNX's spawn() --- server-tools/instance-manager/instance.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/server-tools/instance-manager/instance.cc b/server-tools/instance-manager/instance.cc index 945f8abe3c2..0756f0b4d9f 100644 --- a/server-tools/instance-manager/instance.cc +++ b/server-tools/instance-manager/instance.cc @@ -138,15 +138,25 @@ static int wait_process(My_process_info *pi) static int start_process(Instance_options *instance_options, My_process_info *pi) { +#ifndef __QNX__ *pi= fork(); +#else + /* + On QNX one cannot use fork() in multithreaded environment and we + should use spawn() or one of it's siblings instead. + Here we use spawnv(), which is a combination of fork() and execv() + in one call. It returns the pid of newly created process (>0) or -1 + */ + *pi= spawnv(P_NOWAIT, instance_options->mysqld_path, instance_options->argv); +#endif switch (*pi) { - case 0: + case 0: /* never happens on QNX */ execv(instance_options->mysqld_path, instance_options->argv); /* exec never returns */ exit(1); - case 1: - log_info("cannot fork() to start instance %s", + case -1: + log_info("cannot create a new process to start instance %s", instance_options->instance_name); return 1; } From ccc051cd40bb58e66bf99ae471a4346be01be3c0 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 21 Oct 2005 04:01:52 +0300 Subject: [PATCH 7/7] fix for bug #12595 (ESCAPE must be exactly 1 character long) ESCAPE has length of 1 if specified and sql_mode is NO_BACKSLASH_ESCAPES or has length of 0 or 1 in every other situation. (approved patch applied on a up-to-date tree re-commit) mysql-test/r/select.result: results of test for bug 12595 mysql-test/t/select.test: test for bug #12595 (ESCAPE must be exactly one character long) sql/item_cmpfunc.cc: if ESCAPE was in the statement check whether its length is different than 1. In NO_BACKSLASH_ESCAPES mode only length of 1 is allowed, otherwise the length could be 0 or 1 character (code point in the sense of Unicode). sql/item_cmpfunc.h: pass variable from the parsing stage - whether ESCAPE clause was found in the statement sql/sql_help.cc: pass FALSE for escape_used_in_parsing because we want the default mode of no error checking - our internal code. sql/sql_lex.cc: initialized variable used to transfer information during parsing up in the stack when reducing in the grammar sql/sql_lex.h: new variable used for transfering information when reducing in the grammar. sql/sql_yacc.yy: initialize Lex->escape_used and then use it when reducing. This is needed as fix for bug #12595 to distinguish between situation where ESCAPE was found and when not because internally we may pass a string an empty string and there is no other way to find out whether this is correct or not in case of NO_BACKSLASH_ESCAPES mode, which allows only length of 1 if ESCAPE is part of the SQL statement. --- mysql-test/r/select.result | 57 ++++++++++++++++++++++++++++++++++++++ mysql-test/t/select.test | 39 ++++++++++++++++++++++++++ sql/item_cmpfunc.cc | 9 ++++++ sql/item_cmpfunc.h | 7 +++-- sql/sql_help.cc | 3 +- sql/sql_lex.cc | 1 + sql/sql_lex.h | 2 ++ sql/sql_yacc.yy | 12 +++++--- 8 files changed, 123 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index abf607dd438..fb61095cf22 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2965,6 +2965,63 @@ NULL SELECT IFNULL(NULL, NULL); IFNULL(NULL, NULL) NULL +SET @OLD_SQL_MODE12595=@@SQL_MODE, @@SQL_MODE=''; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode +CREATE TABLE BUG_12595(a varchar(100)); +INSERT INTO BUG_12595 VALUES ('hakan%'), ('hakank'), ("ha%an"); +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +a +hakan% +hakank +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE ''; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha%%an' ESCAPE '%'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE '\\'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SET @@SQL_MODE='NO_BACKSLASH_ESCAPES'; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode NO_BACKSLASH_ESCAPES +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE '\\'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\n%' ESCAPE '\n'; +ERROR HY000: Incorrect arguments to ESCAPE +SET @@SQL_MODE=@OLD_SQL_MODE12595; +DROP TABLE BUG_12595; create table t1 (a char(1)); create table t2 (a char(1)); insert into t1 values ('a'),('b'),('c'); diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 6fc149e2e1f..af51a705122 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -2517,6 +2517,45 @@ SELECT CAST(IFNULL(NULL, NULL) AS DECIMAL); SELECT ABS(IFNULL(NULL, NULL)); SELECT IFNULL(NULL, NULL); +# +# BUG #12595 (ESCAPE must be exactly one) +# +SET @OLD_SQL_MODE12595=@@SQL_MODE, @@SQL_MODE=''; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; + +CREATE TABLE BUG_12595(a varchar(100)); +INSERT INTO BUG_12595 VALUES ('hakan%'), ('hakank'), ("ha%an"); +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +-- error 1210 +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +# this should work when sql_mode is not NO_BACKSLASH_ESCAPES +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE ''; +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +SELECT * FROM BUG_12595 WHERE a LIKE 'ha%%an' ESCAPE '%'; +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE '\\'; +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; + +SET @@SQL_MODE='NO_BACKSLASH_ESCAPES'; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +-- error 1210 +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +-- error 1210 +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE '\\'; +#this gives an error when NO_BACKSLASH_ESCAPES is set +-- error 1210 +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +-- error 1210 +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\n%' ESCAPE '\n'; + +SET @@SQL_MODE=@OLD_SQL_MODE12595; +DROP TABLE BUG_12595; + # # Bug #6495 Illogical requirement for column qualification in NATURAL join # diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 138ebaaf9a5..761d15c8a3e 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2958,6 +2958,15 @@ bool Item_func_like::fix_fields(THD *thd, Item **ref) String *escape_str= escape_item->val_str(&tmp_value1); if (escape_str) { + if (escape_used_in_parsing && ( + (((thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES) && + escape_str->numchars() != 1) || + escape_str->numchars() > 1))) + { + my_error(ER_WRONG_ARGUMENTS,MYF(0),"ESCAPE"); + return TRUE; + } + if (use_mb(cmp.cmp_collation.collation)) { CHARSET_INFO *cs= escape_str->charset(); diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index aa50593abf4..bfd32223d4c 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -985,13 +985,16 @@ class Item_func_like :public Item_bool_func2 enum { alphabet_size = 256 }; Item *escape_item; + + bool escape_used_in_parsing; public: int escape; - Item_func_like(Item *a,Item *b, Item *escape_arg) + Item_func_like(Item *a,Item *b, Item *escape_arg, bool escape_used) :Item_bool_func2(a,b), canDoTurboBM(FALSE), pattern(0), pattern_len(0), - bmGs(0), bmBc(0), escape_item(escape_arg) {} + bmGs(0), bmBc(0), escape_item(escape_arg), + escape_used_in_parsing(escape_used) {} longlong val_int(); enum Functype functype() const { return LIKE_FUNC; } optimize_type select_optimize() const; diff --git a/sql/sql_help.cc b/sql/sql_help.cc index f4d835541cf..b47412981ea 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -599,7 +599,8 @@ SQL_SELECT *prepare_select_for_name(THD *thd, const char *mask, uint mlen, { Item *cond= new Item_func_like(new Item_field(pfname), new Item_string(mask,mlen,pfname->charset()), - new Item_string("\\",1,&my_charset_latin1)); + new Item_string("\\",1,&my_charset_latin1), + FALSE); if (thd->is_fatal_error) return 0; // OOM return prepare_simple_select(thd, cond, table, error); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index f6d4767089b..11f056d6510 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -175,6 +175,7 @@ void lex_start(THD *thd, uchar *buf,uint length) lex->spcont= NULL; lex->proc_list.first= 0; lex->query_tables_own_last= 0; + lex->escape_used= FALSE; if (lex->sroutines.records) my_hash_reset(&lex->sroutines); diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 1c90d3ed97b..1e935c6dc2a 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -894,6 +894,8 @@ typedef struct st_lex during replication ("LOCAL 'filename' REPLACE INTO" part). */ uchar *fname_start, *fname_end; + + bool escape_used; st_lex(); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 14f617b9f8b..94ce04fb5b1 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4314,9 +4314,9 @@ predicate: { $$= new Item_func_eq(new Item_func_soundex($1), new Item_func_soundex($4)); } | bit_expr LIKE simple_expr opt_escape - { $$= new Item_func_like($1,$3,$4); } + { $$= new Item_func_like($1,$3,$4,Lex->escape_used); } | bit_expr not LIKE simple_expr opt_escape - { $$= new Item_func_not(new Item_func_like($1,$4,$5)); } + { $$= new Item_func_not(new Item_func_like($1,$4,$5, Lex->escape_used)); } | bit_expr REGEXP bit_expr { $$= new Item_func_regex($1,$3); } | bit_expr not REGEXP bit_expr { $$= negate_expression(YYTHD, new Item_func_regex($1,$4)); } @@ -5678,10 +5678,14 @@ having_clause: ; opt_escape: - ESCAPE_SYM simple_expr { $$= $2; } + ESCAPE_SYM simple_expr + { + Lex->escape_used= TRUE; + $$= $2; + } | /* empty */ { - + Lex->escape_used= FALSE; $$= ((YYTHD->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES) ? new Item_string("", 0, &my_charset_latin1) : new Item_string("\\", 1, &my_charset_latin1));