From f41c5961d0f0e643fb0ed3dddc2440b1676583a0 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Thu, 1 Oct 2009 16:33:30 +0500 Subject: [PATCH 01/14] Bug#46018 group_concat(distinct ...) uses max_heap_table_size for memory allocations Use min(max_heap_table_size, tmp_table_size) instead per-file comments: sql/item_sum.cc Bug#46018 group_concat(distinct ...) uses max_heap_table_size for memory allocations Item_sum_**::setup fixed, so they use ram_limitation() for Unique-s they embed sql/item_sum.h Bug#46018 group_concat(distinct ...) uses max_heap_table_size for memory allocations Item_sum::ram_limitation() declared --- sql/item_sum.cc | 18 ++++++++++++++---- sql/item_sum.h | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 08a48c6ce2f..5ec4ff999ab 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -28,6 +28,17 @@ #include "mysql_priv.h" #include "sql_select.h" +/** + Calculate the affordable RAM limit for structures like TREE or Unique + used in Item_sum_* +*/ + +ulonglong Item_sum::ram_limitation(THD *thd) +{ + return min(thd->variables.tmp_table_size, + thd->variables.max_heap_table_size); +} + /** Prepare an aggregate function item for checking context conditions. @@ -1045,7 +1056,7 @@ bool Item_sum_distinct::setup(THD *thd) are converted to binary representation as well. */ tree= new Unique(simple_raw_key_cmp, &tree_key_length, tree_key_length, - thd->variables.max_heap_table_size); + ram_limitation(thd)); is_evaluated= FALSE; DBUG_RETURN(tree == 0); @@ -2683,8 +2694,7 @@ bool Item_sum_count_distinct::setup(THD *thd) } } DBUG_ASSERT(tree == 0); - tree= new Unique(compare_key, cmp_arg, tree_key_length, - thd->variables.max_heap_table_size); + tree= new Unique(compare_key,cmp_arg,tree_key_length, ram_limitation(thd)); /* The only time tree_key_length could be 0 is if someone does count(distinct) on a char(0) field - stupid thing to do, @@ -3529,7 +3539,7 @@ bool Item_func_group_concat::setup(THD *thd) unique_filter= new Unique(group_concat_key_cmp_with_distinct, (void*)this, tree_key_length, - thd->variables.max_heap_table_size); + ram_limitation(thd)); DBUG_RETURN(FALSE); } diff --git a/sql/item_sum.h b/sql/item_sum.h index d991327d847..49c3c9892c0 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -256,6 +256,7 @@ protected: Item **orig_args, *tmp_orig_args[2]; table_map used_tables_cache; bool forced_const; + static ulonglong ram_limitation(THD *thd); public: From de7619823d3846fa514d7f540a7e5af898b142a8 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Fri, 9 Oct 2009 19:44:22 +0500 Subject: [PATCH 02/14] Bug#47216 programs should quit if the file specified by --defaults-file option isn't found added code to exit a tool if the forced config file wasn't found per-file comments: client/mysql.cc Bug#47216 programs should quit if the file specified by --defaults-file option isn't found added code to exit a tool if the forced config file wasn't found client/mysql_upgrade.c Bug#47216 programs should quit if the file specified by --defaults-file option isn't found added code to exit a tool if the forced config file wasn't found client/mysqladmin.cc Bug#47216 programs should quit if the file specified by --defaults-file option isn't found added code to exit a tool if the forced config file wasn't found client/mysqlcheck.c Bug#47216 programs should quit if the file specified by --defaults-file option isn't found added code to exit a tool if the forced config file wasn't found client/mysqldump.c Bug#47216 programs should quit if the file specified by --defaults-file option isn't found added code to exit a tool if the forced config file wasn't found client/mysqlimport.c Bug#47216 programs should quit if the file specified by --defaults-file option isn't found added code to exit a tool if the forced config file wasn't found client/mysqlshow.c Bug#47216 programs should quit if the file specified by --defaults-file option isn't found added code to exit a tool if the forced config file wasn't found client/mysqlslap.c Bug#47216 programs should quit if the file specified by --defaults-file option isn't found added code to exit a tool if the forced config file wasn't found mysql-test/t/mysql.test Bug#47216 programs should quit if the file specified by --defaults-file option isn't found test added sql/mysqld.cc Bug#47216 programs should quit if the file specified by --defaults-file option isn't found added code to exit a tool if the forced config file wasn't found storage/myisam/myisamchk.c Bug#47216 programs should quit if the file specified by --defaults-file option isn't found added code to exit a tool if the forced config file wasn't found storage/myisam/myisampack.c Bug#47216 programs should quit if the file specified by --defaults-file option isn't found added code to exit a tool if the forced config file wasn't found --- client/mysql.cc | 6 +++++- client/mysql_upgrade.c | 3 ++- client/mysqladmin.cc | 3 ++- client/mysqlbinlog.cc | 4 ++-- client/mysqlcheck.c | 5 ++--- client/mysqldump.c | 3 ++- client/mysqlimport.c | 3 ++- client/mysqlshow.c | 4 +++- client/mysqlslap.c | 6 +++++- client/mysqltest.cc | 4 +++- extra/my_print_defaults.c | 3 ++- mysys/default.c | 14 +++++++++----- sql/mysqld.cc | 3 ++- storage/archive/archive_reader.c | 3 ++- storage/myisam/myisamchk.c | 4 +++- storage/myisam/myisampack.c | 4 +++- tests/mysql_client_test.c | 4 +++- tests/thread_test.c | 5 ++--- 18 files changed, 54 insertions(+), 27 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 28da6d75c1b..99ba42f20a8 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1113,7 +1113,11 @@ int main(int argc,char *argv[]) close(stdout_fileno_copy); /* Clean up dup(). */ } - load_defaults("my",load_default_groups,&argc,&argv); + if (load_defaults("my",load_default_groups,&argc,&argv)) + { + my_end(0); + exit(1); + } defaults_argv=argv; if (get_options(argc, (char **) argv)) { diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 52c3636219d..1634803edf5 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -814,7 +814,8 @@ int main(int argc, char **argv) init_dynamic_string(&conn_args, "", 512, 256)) die("Out of memory"); - load_defaults("my", load_default_groups, &argc, &argv); + if (load_defaults("my", load_default_groups, &argc, &argv)) + die(NULL); defaults_argv= argv; /* Must be freed by 'free_defaults' */ if (handle_options(&argc, &argv, my_long_options, get_one_option)) diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 2b93c149523..cf8cf85a112 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -304,7 +304,8 @@ int main(int argc,char *argv[]) MY_INIT(argv[0]); mysql_init(&mysql); - load_defaults("my",load_default_groups,&argc,&argv); + if (load_defaults("my",load_default_groups,&argc,&argv)) + exit(1); save_argv = argv; /* Save for free_defaults */ if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) { diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index ebe34231238..80b0d2fc3d7 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -1349,8 +1349,8 @@ static int parse_args(int *argc, char*** argv) int ho_error; result_file = stdout; - load_defaults("my",load_default_groups,argc,argv); - if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) + if ((ho_error= load_defaults("my",load_default_groups,argc,argv)) || + (ho_error= handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); if (debug_info_flag) my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 1533e602639..b56016b6a35 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -344,9 +344,8 @@ static int get_options(int *argc, char ***argv) exit(0); } - load_defaults("my", load_default_groups, argc, argv); - - if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) + if ((ho_error= load_defaults("my", load_default_groups, argc, argv)) || + (ho_error=handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); if (!what_to_do) diff --git a/client/mysqldump.c b/client/mysqldump.c index e9e3124b9cb..16dcb53cae1 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -858,7 +858,8 @@ static int get_options(int *argc, char ***argv) opt_net_buffer_length= *mysql_params->p_net_buffer_length; md_result_file= stdout; - load_defaults("my",load_default_groups,argc,argv); + if (load_defaults("my",load_default_groups,argc,argv)) + return 1; defaults_argv= *argv; if (hash_init(&ignore_table, charset_info, 16, 0, 0, diff --git a/client/mysqlimport.c b/client/mysqlimport.c index ef38d760e5d..53c889f0758 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -596,7 +596,8 @@ int main(int argc, char **argv) char **argv_to_free; MY_INIT(argv[0]); - load_defaults("my",load_default_groups,&argc,&argv); + if (load_defaults("my",load_default_groups,&argc,&argv)) + return 1; /* argv is changed in the program */ argv_to_free= argv; if (get_options(&argc, &argv)) diff --git a/client/mysqlshow.c b/client/mysqlshow.c index 15f791ca8fb..b6c8c5fc992 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -63,7 +63,9 @@ int main(int argc, char **argv) char *wild; MYSQL mysql; MY_INIT(argv[0]); - load_defaults("my",load_default_groups,&argc,&argv); + if (load_defaults("my",load_default_groups,&argc,&argv)) + exit(1); + get_options(&argc,&argv); wild=0; diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 5983b911866..759a745cbe6 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -299,7 +299,11 @@ int main(int argc, char **argv) MY_INIT(argv[0]); - load_defaults("my",load_default_groups,&argc,&argv); + if (load_defaults("my",load_default_groups,&argc,&argv)) + { + my_end(0); + exit(1); + } defaults_argv=argv; if (get_options(&argc,&argv)) { diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 04a7e7b0c6f..ae3442a22a9 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -5931,7 +5931,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), int parse_args(int argc, char **argv) { - load_defaults("my",load_default_groups,&argc,&argv); + if (load_defaults("my",load_default_groups,&argc,&argv)) + exit(1); + default_argv= argv; if ((handle_options(&argc, &argv, my_long_options, get_one_option))) diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c index 06f7e51c380..11f8db97da1 100644 --- a/extra/my_print_defaults.c +++ b/extra/my_print_defaults.c @@ -189,6 +189,7 @@ int main(int argc, char **argv) config_file); } error= 2; + exit(error); } for (argument= arguments+1 ; *argument ; argument++) @@ -196,5 +197,5 @@ int main(int argc, char **argv) my_free((char*) load_default_groups,MYF(0)); free_defaults(arguments); - exit(error); + exit(0); } diff --git a/mysys/default.c b/mysys/default.c index 1c021b4584f..6cd01a193a0 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -479,9 +479,13 @@ int my_load_defaults(const char *conf_file, const char **groups, ctx.args= &args; ctx.group= &group; - error= my_search_option_files(conf_file, argc, argv, &args_used, - handle_default_option, (void *) &ctx, - dirs); + if ((error= my_search_option_files(conf_file, argc, argv, &args_used, + handle_default_option, (void *) &ctx, + dirs))) + { + free_root(&alloc,MYF(0)); + DBUG_RETURN(error); + } /* Here error contains <> 0 only if we have a fully specified conf_file or a forced default file @@ -528,10 +532,10 @@ int my_load_defaults(const char *conf_file, const char **groups, exit(0); } - if (error == 0 && default_directories) + if (default_directories) *default_directories= dirs; - DBUG_RETURN(error); + DBUG_RETURN(0); err: fprintf(stderr,"Fatal error in defaults handling. Program aborted\n"); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 896be4a7f19..4c070f53e23 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3283,7 +3283,8 @@ static int init_common_variables(const char *conf_file_name, int argc, orig_argc=argc; orig_argv=argv; - load_defaults(conf_file_name, groups, &argc, &argv); + if (load_defaults(conf_file_name, groups, &argc, &argv)) + return 1; defaults_argv=argv; defaults_argc=argc; if (get_options(&defaults_argc, defaults_argv)) diff --git a/storage/archive/archive_reader.c b/storage/archive/archive_reader.c index 84d4e318b49..0d641de3e15 100644 --- a/storage/archive/archive_reader.c +++ b/storage/archive/archive_reader.c @@ -390,7 +390,8 @@ static void print_version(void) static void get_options(int *argc, char ***argv) { - load_defaults("my", load_default_groups, argc, argv); + if (load_defaults("my", load_default_groups, argc, argv)) + exit(1); default_argv= *argv; handle_options(argc, argv, my_long_options, get_one_option); diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index 611fb6325c8..de0e53e6a36 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -740,7 +740,9 @@ static void get_options(register int *argc,register char ***argv) { int ho_error; - load_defaults("my", load_default_groups, argc, argv); + if (load_defaults("my", load_default_groups, argc, argv)) + exit(1); + default_argv= *argv; if (isatty(fileno(stdout))) check_param.testflag|=T_WRITE_LOOP; diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c index 908c32e48d3..9ebd11b2516 100644 --- a/storage/myisam/myisampack.c +++ b/storage/myisam/myisampack.c @@ -208,7 +208,9 @@ int main(int argc, char **argv) char **default_argv; MY_INIT(argv[0]); - load_defaults("my",load_default_groups,&argc,&argv); + if (load_defaults("my",load_default_groups,&argc,&argv)) + exit(1); + default_argv= argv; get_options(&argc,&argv); diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 9394b0df40b..078e95067a5 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -18458,7 +18458,9 @@ int main(int argc, char **argv) MY_INIT(argv[0]); - load_defaults("my", client_test_load_default_groups, &argc, &argv); + if (load_defaults("my", client_test_load_default_groups, &argc, &argv)) + exit(1); + defaults_argv= argv; get_options(&argc, &argv); diff --git a/tests/thread_test.c b/tests/thread_test.c index 8e1c58ebbec..5b76eeff2f7 100644 --- a/tests/thread_test.c +++ b/tests/thread_test.c @@ -176,9 +176,8 @@ static void get_options(int argc, char **argv) { int ho_error; - load_defaults("my",load_default_groups,&argc,&argv); - - if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + if ((ho_error= load_defaults("my",load_default_groups,&argc,&argv)) || + (ho_error= handle_options(&argc, &argv, my_long_options, get_one_option))) exit(ho_error); free_defaults(argv); From 1035de6282a24838b545f58d2adf90ce6ee10d06 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Mon, 2 Nov 2009 09:31:00 -0700 Subject: [PATCH 03/14] Bug#9801 Views: imperfect error message Backport for 5.5 The root cause of this bug is that the grammar for GROUP BY clauses, when using WITH CUBE or WITH ROLLUP, cause conflicts with the grammar for VIEW, when using WITH CHECK OPTION. The solution is to implement two token look ahead when parsing a WITH token, to disambiguate the non standard WITH CUBE and WITH ROLLUP syntaxes. Patch based on code from Marc Alff and Antony Curtis --- mysql-test/r/fulltext.result | 2 +- mysql-test/r/view.result | 13 ++++++++ mysql-test/t/view.test | 26 ++++++++++++++++ sql/sql_lex.cc | 58 ++++++++++++++++++++++++++++++++++++ sql/sql_lex.h | 11 +++++++ sql/sql_yacc.yy | 26 ++++++++++++---- 6 files changed, 130 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index abab18e0e99..40f408b0fc8 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -49,7 +49,7 @@ a b Full-text indexes are called collections Only MyISAM tables support collections select * from t1 where MATCH(a,b) AGAINST ("indexes" IN BOOLEAN MODE WITH QUERY EXPANSION); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH QUERY EXPANSION)' at line 1 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'QUERY EXPANSION)' at line 1 explain select * from t1 where MATCH(a,b) AGAINST ("collections"); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 fulltext a a 0 1 Using where diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 69bcf349f51..f9156d4ae70 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -3958,3 +3958,16 @@ DROP TABLE t1; # ----------------------------------------------------------------- # -- End of 5.1 tests. # ----------------------------------------------------------------- +drop table if exists t_9801; +drop view if exists v_9801; +create table t_9801 (s1 int); +create view v_9801 as +select sum(s1) from t_9801 with check option; +ERROR HY000: CHECK OPTION on non-updatable view 'test.v_9801' +create view v_9801 as +select sum(s1) from t_9801 group by s1 with check option; +ERROR HY000: CHECK OPTION on non-updatable view 'test.v_9801' +create view v_9801 as +select sum(s1) from t_9801 group by s1 with rollup with check option; +ERROR HY000: CHECK OPTION on non-updatable view 'test.v_9801' +drop table t_9801; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index b2490847dbc..e180d4ebab8 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -3905,3 +3905,29 @@ DROP TABLE t1; --echo # ----------------------------------------------------------------- --echo # -- End of 5.1 tests. --echo # ----------------------------------------------------------------- + +# +# Bug#9801 (Views: imperfect error message) +# + +--disable_warnings +drop table if exists t_9801; +drop view if exists v_9801; +--enable_warnings + +create table t_9801 (s1 int); + +--error ER_VIEW_NONUPD_CHECK +create view v_9801 as + select sum(s1) from t_9801 with check option; + +--error ER_VIEW_NONUPD_CHECK +create view v_9801 as + select sum(s1) from t_9801 group by s1 with check option; + + --error ER_VIEW_NONUPD_CHECK +create view v_9801 as + select sum(s1) from t_9801 group by s1 with rollup with check option; + +drop table t_9801; + diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 2adbc44eb12..88bed97cd35 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -24,6 +24,8 @@ #include "sp.h" #include "sp_head.h" +static int lex_one_token(void *arg, void *yythd); + /* We are using pointer to this variable for distinguishing between assignment to NEW row field (when parsing trigger definition) and structured variable. @@ -117,6 +119,8 @@ Lex_input_stream::Lex_input_stream(THD *thd, yylineno(1), yytoklen(0), yylval(NULL), + lookahead_token(-1), + lookahead_yylval(NULL), m_ptr(buffer), m_tok_start(NULL), m_tok_end(NULL), @@ -779,6 +783,60 @@ bool consume_comment(Lex_input_stream *lip, int remaining_recursions_permitted) */ int MYSQLlex(void *arg, void *yythd) +{ + THD *thd= (THD *)yythd; + Lex_input_stream *lip= & thd->m_parser_state->m_lip; + YYSTYPE *yylval=(YYSTYPE*) arg; + int token; + + if (lip->lookahead_token >= 0) + { + /* + The next token was already parsed in advance, + return it. + */ + token= lip->lookahead_token; + lip->lookahead_token= -1; + *yylval= *(lip->lookahead_yylval); + lip->lookahead_yylval= NULL; + return token; + } + + token= lex_one_token(arg, yythd); + + switch(token) { + case WITH: + /* + Parsing 'WITH' 'ROLLUP' or 'WITH' 'CUBE' requires 2 look ups, + which makes the grammar LALR(2). + Replace by a single 'WITH_ROLLUP' or 'WITH_CUBE' token, + to transform the grammar into a LALR(1) grammar, + which sql_yacc.yy can process. + */ + token= lex_one_token(arg, yythd); + switch(token) { + case CUBE_SYM: + return WITH_CUBE_SYM; + case ROLLUP_SYM: + return WITH_ROLLUP_SYM; + default: + /* + Save the token following 'WITH' + */ + lip->lookahead_yylval= lip->yylval; + lip->yylval= NULL; + lip->lookahead_token= token; + return WITH; + } + break; + default: + break; + } + + return token; +} + +int lex_one_token(void *arg, void *yythd) { reg1 uchar c= 0; bool comment_closed; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 4a4acde6e76..be7375fa3fa 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1411,6 +1411,17 @@ public: /** Interface with bison, value of the last token parsed. */ LEX_YYSTYPE yylval; + /** + LALR(2) resolution, look ahead token. + Value of the next token to return, if any, + or -1, if no token was parsed in advance. + Note: 0 is a legal token, and represents YYEOF. + */ + int lookahead_token; + + /** LALR(2) resolution, value of the look ahead token.*/ + LEX_YYSTYPE lookahead_yylval; + private: /** Pointer to the current position in the raw input stream. */ const char *m_ptr; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 6eb0d152617..e21ef0040fa 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -521,10 +521,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %pure_parser /* We have threads */ /* - Currently there are 169 shift/reduce conflicts. + Currently there are 168 shift/reduce conflicts. We should not introduce new conflicts any more. */ -%expect 169 +%expect 168 /* Comments for TOKENS. @@ -1118,6 +1118,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token WHERE /* SQL-2003-R */ %token WHILE_SYM %token WITH /* SQL-2003-R */ +%token WITH_CUBE_SYM /* INTERNAL */ +%token WITH_ROLLUP_SYM /* INTERNAL */ %token WORK_SYM /* SQL-2003-N */ %token WRAPPER_SYM %token WRITE_SYM /* SQL-2003-N */ @@ -9153,8 +9155,15 @@ group_list: olap_opt: /* empty */ {} - | WITH CUBE_SYM + | WITH_CUBE_SYM { + /* + 'WITH CUBE' is reserved in the MySQL syntax, but not implemented, + and cause LALR(2) conflicts. + This syntax is not standard. + MySQL syntax: GROUP BY col1, col2, col3 WITH CUBE + SQL-2003: GROUP BY ... CUBE(col1, col2, col3) + */ LEX *lex=Lex; if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE) { @@ -9164,10 +9173,17 @@ olap_opt: } lex->current_select->olap= CUBE_TYPE; my_error(ER_NOT_SUPPORTED_YET, MYF(0), "CUBE"); - MYSQL_YYABORT; /* To be deleted in 5.1 */ + MYSQL_YYABORT; } - | WITH ROLLUP_SYM + | WITH_ROLLUP_SYM { + /* + 'WITH ROLLUP' is needed for backward compatibility, + and cause LALR(2) conflicts. + This syntax is not standard. + MySQL syntax: GROUP BY col1, col2, col3 WITH ROLLUP + SQL-2003: GROUP BY ... ROLLUP(col1, col2, col3) + */ LEX *lex= Lex; if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE) { From 567bf9d37cc89083ed9ed8ba96aba5963c30cdaa Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Tue, 3 Nov 2009 17:54:41 +0400 Subject: [PATCH 04/14] Bug#41371 Select returns 1 row with condition "col is not null and col is null" For application compatibility reasons MySQL converts " IS NULL" predicates to " = LAST_INSERT_ID()" in the first SELECT following an INSERT regardless of whether they're top level predicates or not. This causes wrong and obscure results when these predicates are combined with others on the same columns. Fixed by only doing the transformation on a single top-level predicate if a special SQL mode is turned on (sql_auto_is_null). Also made sql_auto_is_null off by default. per-file comments: mysql-test/r/func_isnull.result Bug#41371 Select returns 1 row with condition "col is not null and col is null" test result updated mysql-test/t/func_isnull.test Bug#41371 Select returns 1 row with condition "col is not null and col is null" test case added sql/mysqld.cc Bug#41371 Select returns 1 row with condition "col is not null and col is null" sql_auto_is_null now is OFF by default. sql/sql_select.cc Bug#41371 Select returns 1 row with condition "col is not null and col is null" remove_eq_conds() split in two parts - one only checks the upper condition, the req_remove_eq_conds() recursively checks all the condition tree. mysql-test/extra/rpl_tests/rpl_insert_id.test Bug#41371 Select returns 1 row with condition "col is not null and col is null" test fixed (set the sql_auto_is_null variable) mysql-test/r/mysqlbinlog.result Bug#41371 Select returns 1 row with condition "col is not null and col is null" result updated mysql-test/r/mysqlbinlog2.result Bug#41371 Select returns 1 row with condition "col is not null and col is null" result updated mysql-test/r/odbc.result Bug#41371 Select returns 1 row with condition "col is not null and col is null" result updated mysql-test/r/query_cache.result Bug#41371 Select returns 1 row with condition "col is not null and col is null" result updated mysql-test/r/user_var-binlog.result Bug#41371 Select returns 1 row with condition "col is not null and col is null" result updated mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result Bug#41371 Select returns 1 row with condition "col is not null and col is null" result updated mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result Bug#41371 Select returns 1 row with condition "col is not null and col is null" result updated mysql-test/suite/rpl/r/rpl_insert_id.result Bug#41371 Select returns 1 row with condition "col is not null and col is null" result updated mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result Bug#41371 Select returns 1 row with condition "col is not null and col is null" result updated mysql-test/suite/rpl/r/rpl_sp.result Bug#41371 Select returns 1 row with condition "col is not null and col is null" result updated mysql-test/t/odbc.test Bug#41371 Select returns 1 row with condition "col is not null and col is null" test fixed (set the sql_auto_is_null variable) --- mysql-test/extra/rpl_tests/rpl_insert_id.test | 2 + mysql-test/r/func_isnull.result | 5 + mysql-test/r/mysqlbinlog.result | 16 +- mysql-test/r/mysqlbinlog2.result | 70 ++++---- mysql-test/r/odbc.result | 4 +- mysql-test/r/query_cache.result | 5 +- mysql-test/r/user_var-binlog.result | 2 +- .../binlog/r/binlog_row_ctype_ucs.result | 2 +- .../binlog/r/binlog_stm_ctype_ucs.result | 2 +- mysql-test/suite/rpl/r/rpl_insert_id.result | 2 + .../suite/rpl/r/rpl_row_mysqlbinlog.result | 8 +- mysql-test/suite/rpl/r/rpl_sp.result | 2 +- mysql-test/t/func_isnull.test | 12 ++ mysql-test/t/odbc.test | 4 + sql/mysqld.cc | 2 +- sql/sql_select.cc | 154 ++++++++++++------ 16 files changed, 185 insertions(+), 107 deletions(-) diff --git a/mysql-test/extra/rpl_tests/rpl_insert_id.test b/mysql-test/extra/rpl_tests/rpl_insert_id.test index bd815d9de02..f7cb1ff90a9 100644 --- a/mysql-test/extra/rpl_tests/rpl_insert_id.test +++ b/mysql-test/extra/rpl_tests/rpl_insert_id.test @@ -117,6 +117,7 @@ sync_slave_with_master; --echo # connection master; +set @@session.sql_auto_is_null=1; eval create table t1(a int auto_increment, key(a)) engine=$engine_type; eval create table t2(a int) engine=$engine_type; insert into t1 (a) values (null); @@ -548,4 +549,5 @@ connection master; drop table t1, t2; drop procedure foo; SET @@global.concurrent_insert= @old_concurrent_insert; +set @@session.sql_auto_is_null=default; sync_slave_with_master; diff --git a/mysql-test/r/func_isnull.result b/mysql-test/r/func_isnull.result index 20ddc87ee78..79aecc7d82b 100644 --- a/mysql-test/r/func_isnull.result +++ b/mysql-test/r/func_isnull.result @@ -5,3 +5,8 @@ flush tables; select * from t1 where isnull(to_days(mydate)); id mydate drop table t1; +CREATE TABLE t1 (id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY(id)); +INSERT INTO t1( id ) VALUES ( NULL ); +SELECT t1.id FROM t1 WHERE (id is not null and id is null ); +id +DROP TABLE t1; diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index 5f32561798b..ff060f02c06 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -21,7 +21,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -67,7 +67,7 @@ DELIMITER /*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -99,7 +99,7 @@ DELIMITER /*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -121,7 +121,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -167,7 +167,7 @@ DELIMITER /*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -199,7 +199,7 @@ DELIMITER /*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -299,7 +299,7 @@ DELIMITER /*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -349,7 +349,7 @@ DELIMITER /*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/r/mysqlbinlog2.result b/mysql-test/r/mysqlbinlog2.result index dba9bdc9d70..62df4731d47 100644 --- a/mysql-test/r/mysqlbinlog2.result +++ b/mysql-test/r/mysqlbinlog2.result @@ -22,7 +22,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1579609942/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -65,7 +65,7 @@ SET INSERT_ID=1/*!*/; use test/*!*/; SET TIMESTAMP=1579609942/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -104,7 +104,7 @@ SET INSERT_ID=4/*!*/; use test/*!*/; SET TIMESTAMP=1579609946/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -130,7 +130,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1579609942/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -165,7 +165,7 @@ SET INSERT_ID=4/*!*/; use test/*!*/; SET TIMESTAMP=1579609946/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -188,7 +188,7 @@ SET INSERT_ID=3/*!*/; use test/*!*/; SET TIMESTAMP=1579609944/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -218,7 +218,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1579609942/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -249,7 +249,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1579609942/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -284,7 +284,7 @@ SET INSERT_ID=6/*!*/; use test/*!*/; SET TIMESTAMP=1579609943/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -307,7 +307,7 @@ SET INSERT_ID=1/*!*/; use test/*!*/; SET TIMESTAMP=1579609942/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -338,7 +338,7 @@ SET INSERT_ID=6/*!*/; use test/*!*/; SET TIMESTAMP=1579609943/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -361,7 +361,7 @@ SET INSERT_ID=4/*!*/; use test/*!*/; SET TIMESTAMP=1579609946/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -380,7 +380,7 @@ SET INSERT_ID=6/*!*/; use test/*!*/; SET TIMESTAMP=1579609943/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -402,7 +402,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1579609942/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -448,7 +448,7 @@ SET INSERT_ID=3/*!*/; use test/*!*/; SET TIMESTAMP=1579609944/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -471,7 +471,7 @@ SET INSERT_ID=6/*!*/; use test/*!*/; SET TIMESTAMP=1579609943/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -493,7 +493,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1579609942/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -523,7 +523,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1579609942/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -566,7 +566,7 @@ SET INSERT_ID=1/*!*/; use test/*!*/; SET TIMESTAMP=1579609942/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -604,7 +604,7 @@ SET INSERT_ID=4/*!*/; use test/*!*/; SET TIMESTAMP=1579609946/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -630,7 +630,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1579609942/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -664,7 +664,7 @@ SET INSERT_ID=4/*!*/; use test/*!*/; SET TIMESTAMP=1579609946/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -687,7 +687,7 @@ SET INSERT_ID=3/*!*/; use test/*!*/; SET TIMESTAMP=1579609944/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -717,7 +717,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1579609942/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -747,7 +747,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1579609942/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -782,7 +782,7 @@ SET INSERT_ID=6/*!*/; use test/*!*/; SET TIMESTAMP=1579609943/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -805,7 +805,7 @@ SET INSERT_ID=1/*!*/; use test/*!*/; SET TIMESTAMP=1579609942/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -836,7 +836,7 @@ SET INSERT_ID=6/*!*/; use test/*!*/; SET TIMESTAMP=1579609943/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -858,7 +858,7 @@ SET INSERT_ID=4/*!*/; use test/*!*/; SET TIMESTAMP=1579609946/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -877,7 +877,7 @@ SET INSERT_ID=6/*!*/; use test/*!*/; SET TIMESTAMP=1579609943/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -899,7 +899,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1579609942/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -945,7 +945,7 @@ SET INSERT_ID=3/*!*/; use test/*!*/; SET TIMESTAMP=1579609944/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -968,7 +968,7 @@ SET INSERT_ID=6/*!*/; use test/*!*/; SET TIMESTAMP=1579609943/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -990,7 +990,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1579609942/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1020,7 +1020,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1579609942/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/r/odbc.result b/mysql-test/r/odbc.result index 5629d3dab33..3dbac12ca7c 100644 --- a/mysql-test/r/odbc.result +++ b/mysql-test/r/odbc.result @@ -1,4 +1,5 @@ drop table if exists t1; +set @@session.sql_auto_is_null=1; select {fn length("hello")}, { date "1997-10-20" }; {fn length("hello")} 1997-10-20 5 1997-10-20 @@ -7,9 +8,9 @@ insert into t1 SET A=NULL,B=1; insert into t1 SET a=null,b=2; select * from t1 where a is null and b=2; a b -2 2 select * from t1 where a is null; a b +2 2 explain select * from t1 where b is null; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE @@ -25,3 +26,4 @@ SELECT sql_no_cache a, last_insert_id() FROM t1; a last_insert_id() 1 1 DROP TABLE t1; +set @@session.sql_auto_is_null=default; diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index 89057603c3d..6c6d357a462 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -342,19 +342,18 @@ create table mysqltest.t1 (i int not null auto_increment, a int, primary key (i) insert into mysqltest.t1 (a) values (1); select * from mysqltest.t1 where i is null; i a -1 1 create table t1(a int); select * from t1; a show status like "Qcache_queries_in_cache"; Variable_name Value -Qcache_queries_in_cache 1 +Qcache_queries_in_cache 2 select * from mysqltest.t1; i a 1 1 show status like "Qcache_queries_in_cache"; Variable_name Value -Qcache_queries_in_cache 2 +Qcache_queries_in_cache 3 drop database mysqltest; show status like "Qcache_queries_in_cache"; Variable_name Value diff --git a/mysql-test/r/user_var-binlog.result b/mysql-test/r/user_var-binlog.result index 05efea79fe7..b9587bedc05 100644 --- a/mysql-test/r/user_var-binlog.result +++ b/mysql-test/r/user_var-binlog.result @@ -22,7 +22,7 @@ SET @`a b`:=_latin1 0x68656C6C6F COLLATE `latin1_swedish_ci`/*!*/; use test/*!*/; SET TIMESTAMP=10000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result b/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result index 8daed8d5c25..f0519a9d724 100644 --- a/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result +++ b/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result @@ -16,7 +16,7 @@ DELIMITER /*!*/; ROLLBACK/*!*/; SET TIMESTAMP=10000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result b/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result index b7edf7fedb8..7214d07c783 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result +++ b/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result @@ -16,7 +16,7 @@ SET @`v`:=_ucs2 0x006100620063 COLLATE `ucs2_general_ci`/*!*/; use test/*!*/; SET TIMESTAMP=10000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/rpl/r/rpl_insert_id.result b/mysql-test/suite/rpl/r/rpl_insert_id.result index e171e247b6c..f0be00c9966 100644 --- a/mysql-test/suite/rpl/r/rpl_insert_id.result +++ b/mysql-test/suite/rpl/r/rpl_insert_id.result @@ -97,6 +97,7 @@ drop table t1; # # Bug#14553: NULL in WHERE resets LAST_INSERT_ID # +set @@session.sql_auto_is_null=1; create table t1(a int auto_increment, key(a)) engine=myisam; create table t2(a int) engine=myisam; insert into t1 (a) values (null); @@ -531,3 +532,4 @@ id last_id drop table t1, t2; drop procedure foo; SET @@global.concurrent_insert= @old_concurrent_insert; +set @@session.sql_auto_is_null=default; diff --git a/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result b/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result index 2cb316c6a1f..b5adcefe373 100644 --- a/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result +++ b/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result @@ -159,7 +159,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -181,7 +181,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -290,7 +290,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -321,7 +321,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/rpl/r/rpl_sp.result b/mysql-test/suite/rpl/r/rpl_sp.result index e2946bb487a..29de7e8fe82 100644 --- a/mysql-test/suite/rpl/r/rpl_sp.result +++ b/mysql-test/suite/rpl/r/rpl_sp.result @@ -619,7 +619,7 @@ DELIMITER /*!*/; ROLLBACK/*!*/; SET TIMESTAMP=t/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/t/func_isnull.test b/mysql-test/t/func_isnull.test index 6218efb882f..424f6dc6640 100644 --- a/mysql-test/t/func_isnull.test +++ b/mysql-test/t/func_isnull.test @@ -13,3 +13,15 @@ select * from t1 where isnull(to_days(mydate)); drop table t1; # End of 4.1 tests + +# +# Bug #41371 Select returns 1 row with condition "col is not null and col is null" +# + +CREATE TABLE t1 (id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY(id)); +INSERT INTO t1( id ) VALUES ( NULL ); +SELECT t1.id FROM t1 WHERE (id is not null and id is null ); +DROP TABLE t1; + +# End of 5.1 tests + diff --git a/mysql-test/t/odbc.test b/mysql-test/t/odbc.test index 6a754bb32a7..f1d60e15bc8 100644 --- a/mysql-test/t/odbc.test +++ b/mysql-test/t/odbc.test @@ -3,6 +3,8 @@ drop table if exists t1; --enable_warnings +set @@session.sql_auto_is_null=1; + # # Test some ODBC compatibility # @@ -32,3 +34,5 @@ SELECT sql_no_cache a, last_insert_id() FROM t1; DROP TABLE t1; # End of 4.1 tests + +set @@session.sql_auto_is_null=default; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index ee31339c77e..c432b3d9e0a 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -7792,7 +7792,7 @@ static int mysql_init_variables(void) log_error_file_ptr= log_error_file; lc_messages_dir_ptr= lc_messages_dir; mysql_data_home= mysql_real_data_home; - thd_startup_options= (OPTION_AUTO_IS_NULL | OPTION_BIN_LOG | + thd_startup_options= (OPTION_BIN_LOG | OPTION_QUOTE_SHOW_CREATE | OPTION_SQL_NOTES); protocol_version= PROTOCOL_VERSION; what_to_log= ~ (1L << (uint) COM_TIME); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 01b21dd7e2d..1d19ba7e96e 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -9119,18 +9119,26 @@ optimize_cond(JOIN *join, COND *conds, List *join_list, /** - Remove const and eq items. + Handles the reqursive job for remove_eq_conds() - @return - Return new item, or NULL if no condition @n - cond_value is set to according: - - COND_OK : query is possible (field = constant) - - COND_TRUE : always true ( 1 = 1 ) - - COND_FALSE : always false ( 1 = 2 ) + Remove const and eq items. Return new item, or NULL if no condition + cond_value is set to according: + COND_OK query is possible (field = constant) + COND_TRUE always true ( 1 = 1 ) + COND_FALSE always false ( 1 = 2 ) + + SYNPOSIS + remove_eq_conds() + thd THD environment + cond the condition to handle + cond_value the resulting value of the condition + + RETURN + *COND with the simplified condition */ -COND * -remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value) +static COND * +internal_remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value) { if (cond->type() == Item::COND_ITEM) { @@ -9144,7 +9152,7 @@ remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value) Item *item; while ((item=li++)) { - Item *new_item=remove_eq_conds(thd, item, &tmp_cond_value); + Item *new_item=internal_remove_eq_conds(thd, item, &tmp_cond_value); if (!new_item) li.remove(); else if (item != new_item) @@ -9192,6 +9200,86 @@ remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value) } else if (cond->type() == Item::FUNC_ITEM && ((Item_func*) cond)->functype() == Item_func::ISNULL_FUNC) + { + Item_func_isnull *func=(Item_func_isnull*) cond; + Item **args= func->arguments(); + if (args[0]->type() == Item::FIELD_ITEM) + { + Field *field=((Item_field*) args[0])->field; + /* fix to replace 'NULL' dates with '0' (shreeve@uci.edu) */ + /* + datetime_field IS NULL has to be modified to + datetime_field == 0 + */ + if (((field->type() == MYSQL_TYPE_DATE) || + (field->type() == MYSQL_TYPE_DATETIME)) && + (field->flags & NOT_NULL_FLAG) && !field->table->maybe_null) + { + COND *new_cond; + if ((new_cond= new Item_func_eq(args[0],new Item_int("0", 0, 2)))) + { + cond=new_cond; + /* + Item_func_eq can't be fixed after creation so we do not check + cond->fixed, also it do not need tables so we use 0 as second + argument. + */ + cond->fix_fields(thd, &cond); + } + } + } + if (cond->const_item()) + { + *cond_value= eval_const_cond(cond) ? Item::COND_TRUE : Item::COND_FALSE; + return (COND*) 0; + } + } + else if (cond->const_item()) + { + *cond_value= eval_const_cond(cond) ? Item::COND_TRUE : Item::COND_FALSE; + return (COND*) 0; + } + else if ((*cond_value= cond->eq_cmp_result()) != Item::COND_OK) + { // boolan compare function + Item *left_item= ((Item_func*) cond)->arguments()[0]; + Item *right_item= ((Item_func*) cond)->arguments()[1]; + if (left_item->eq(right_item,1)) + { + if (!left_item->maybe_null || + ((Item_func*) cond)->functype() == Item_func::EQUAL_FUNC) + return (COND*) 0; // Compare of identical items + } + } + *cond_value=Item::COND_OK; + return cond; // Point at next and level +} + + +/** + Remove const and eq items. Return new item, or NULL if no condition + cond_value is set to according: + COND_OK query is possible (field = constant) + COND_TRUE always true ( 1 = 1 ) + COND_FALSE always false ( 1 = 2 ) + + SYNPOSIS + remove_eq_conds() + thd THD environment + cond the condition to handle + cond_value the resulting value of the condition + + NOTES + calls the inner_remove_eq_conds to check all the tree reqursively + + RETURN + *COND with the simplified condition +*/ + +COND * +remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value) +{ + if (cond->type() == Item::FUNC_ITEM && + ((Item_func*) cond)->functype() == Item_func::ISNULL_FUNC) { /* Handles this special case for some ODBC applications: @@ -9235,52 +9323,16 @@ remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value) clear for next row */ thd->substitute_null_with_insert_id= FALSE; - } - /* fix to replace 'NULL' dates with '0' (shreeve@uci.edu) */ - else if (((field->type() == MYSQL_TYPE_DATE) || - (field->type() == MYSQL_TYPE_DATETIME)) && - (field->flags & NOT_NULL_FLAG) && - !field->table->maybe_null) - { - COND *new_cond; - if ((new_cond= new Item_func_eq(args[0],new Item_int("0", 0, 2)))) - { - cond=new_cond; - /* - Item_func_eq can't be fixed after creation so we do not check - cond->fixed, also it do not need tables so we use 0 as second - argument. - */ - cond->fix_fields(thd, &cond); - } + + *cond_value= Item::COND_OK; + return cond; } } - if (cond->const_item()) - { - *cond_value= eval_const_cond(cond) ? Item::COND_TRUE : Item::COND_FALSE; - return (COND*) 0; - } } - else if (cond->const_item()) - { - *cond_value= eval_const_cond(cond) ? Item::COND_TRUE : Item::COND_FALSE; - return (COND*) 0; - } - else if ((*cond_value= cond->eq_cmp_result()) != Item::COND_OK) - { // boolan compare function - Item *left_item= ((Item_func*) cond)->arguments()[0]; - Item *right_item= ((Item_func*) cond)->arguments()[1]; - if (left_item->eq(right_item,1)) - { - if (!left_item->maybe_null || - ((Item_func*) cond)->functype() == Item_func::EQUAL_FUNC) - return (COND*) 0; // Compare of identical items - } - } - *cond_value=Item::COND_OK; - return cond; // Point at next and level + return internal_remove_eq_conds(thd, cond, cond_value); // Scan all the condition } + /* Check if equality can be used in removing components of GROUP BY/DISTINCT From baf4e699feec69441177b252cb9b019f24b6d8aa Mon Sep 17 00:00:00 2001 From: "Horst.Hunger" Date: Thu, 5 Nov 2009 16:34:02 +0100 Subject: [PATCH 05/14] Patch for bug#47146: Patch after review. Taken from the Makefile.am for archive and changed for example. Copyright line has been changed. The target "dtrace_shared_file" has been removed. --- storage/example/Makefile.am | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/storage/example/Makefile.am b/storage/example/Makefile.am index ce269aee59b..5071c217ef3 100644 --- a/storage/example/Makefile.am +++ b/storage/example/Makefile.am @@ -1,5 +1,5 @@ -# Copyright (C) 2005-2006 MySQL AB -# +# Copyright (C) 2005-2006 MySQL AB, 2009 Sun Microsystems, Inc. +# All rights reserved. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. @@ -50,11 +50,18 @@ libexample_a_SOURCES= ha_example.cc EXTRA_DIST = CMakeLists.txt plug.in if HAVE_DTRACE_DASH_G +# The object for static and dynamic linking of example differ +# For static linkage of example to mysqld +# That's actually not needed as example is only dynamic loadable, but for completion libexample_a_LIBADD = probes_mysql.o -libexample_a_DEPENDENCIES = probes_mysql.o -CLEANFILES = -BUILT_SOURCES = +libexample_a_DEPENDENCIES = probes_mysql.o dtrace_files dtrace_providers +# For example as shared library +ha_example_la_LIBADD = probes_sh_mysql.o +ha_example_la_DEPENDENCIES = probes_sh_mysql.o $(DTRACESHAREDFILES) dtrace_providers + +CLEANFILES = $(DTRACEPROVIDER) dtrace_files dtrace_providers $(DTRACESHAREDFILES) DTRACEFILES = libexample_a-ha_example.o +DTRACESHAREDFILES = .libs/ha_example_la-ha_example.o DTRACEPROVIDER = probes_mysql.d dtrace_files: @@ -66,8 +73,12 @@ probes_mysql.d: $(CP) $(top_srcdir)/include/probes_mysql.d.base probes_mysql.d echo timestamp > dtrace_sources +probes_sh_mysql.o: $(DTRACEPROVIDER) $(DTRACESHAREDFILES) + $(DTRACE) $(DTRACEFLAGS) -G -s $(DTRACEPROVIDER) $(DTRACESHAREDFILES) -o $@ + probes_mysql.o: $(DTRACEPROVIDER) $(DTRACEFILES) $(DTRACE) $(DTRACEFLAGS) -G -s $(DTRACEPROVIDER) $(DTRACEFILES) -o $@ + endif # Don't update the files from bitkeeper From eb852073c3fcb53630ea70fa775d30e15cbc903a Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 9 Nov 2009 13:45:40 +0400 Subject: [PATCH 06/14] Backporting Bug#37129 LDML lacks rule --- mysql-test/r/ctype_ldml.result | Bin 7967 -> 9019 bytes mysql-test/std_data/Index.xml | 12 +++++++++++- mysql-test/t/ctype_ldml.test | 19 +++++++++++++++++++ strings/ctype-uca.c | 11 +++++++++++ strings/ctype.c | 5 ++++- 5 files changed, 45 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/ctype_ldml.result b/mysql-test/r/ctype_ldml.result index 812f7f87d7dd63a2104bbee3bd2ee462c568bd21..388b1373cf968d87d8e46d3bf008b79698c9b5d6 100644 GIT binary patch delta 810 zcma)4O>fgc5EW1)b}#e-qy$ydTo2m3b0{?KrLXcvKvO)=1G(iRK%}{_zm9`M^ zETM})PJx9X>_vemCabzm%seHVaG9LvK0i2~iijV0LHhQoH9V1i>)<*<)QQv@RYFLM z_FTsvJ21Ap0|%r9CXLvf!@lkI`nGGntQSjEGye#szg7zObuj&L_wmNQJ=k+bU>c*3 z;>ai&n@wn2RcKWzxS&!s(u?(cuJ2z$CSt`USl8f_E{io?gAh@( znPJv6dOBj!5mVe6)>>+#M8ha{=*Ss3y)it89e4OzwKsIP9T&RqK-=%=W{KWYtwjFS zp=ge5HnY~K>J_7%Y^zk8C4XC`eIIjg?CH7G(-$kbwyymOXQsX1w4Sl{KL?6kzhbM& zAQeB$xD|2tnh0&M0PhO$qOSh8kf7V{@Xh6$Nzd=(FTOs^Khlc$;4;rEJ$u&p_A}qS F_ZyZr*>eB@ delta 19 bcmdn(Hs5Z7mmfn0-K8+awR{#g| diff --git a/mysql-test/std_data/Index.xml b/mysql-test/std_data/Index.xml index 40fe70ebca0..4feb868583e 100644 --- a/mysql-test/std_data/Index.xml +++ b/mysql-test/std_data/Index.xml @@ -1,10 +1,20 @@ + + + \u0000 + \u0020 + \u0028 + \u0029 + \u002B + \u002D + + a - b + b diff --git a/mysql-test/t/ctype_ldml.test b/mysql-test/t/ctype_ldml.test index d0a5e5e4896..e177c4522ae 100644 --- a/mysql-test/t/ctype_ldml.test +++ b/mysql-test/t/ctype_ldml.test @@ -4,11 +4,30 @@ drop table if exists t1; --enable_warnings +--echo In the following tests we change the order of letter "b" +--echo making it equal to letter "a", and check that it works +--echo with all Unicode character sets set names utf8; --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR show variables like 'character_sets_dir%'; +show collation like 'utf8_phone_ci'; +CREATE TABLE t1 ( + name VARCHAR(64), + phone VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_phone_ci +); +INSERT INTO t1 VALUES ('Svoj','+7 912 800 80 02'); +INSERT INTO t1 VALUES ('Hf','+7 (912) 800 80 04'); +INSERT INTO t1 VALUES ('Bar','+7-912-800-80-01'); +INSERT INTO t1 VALUES ('Ramil','(7912) 800 80 03'); +INSERT INTO t1 VALUES ('Sanja','+380 (912) 8008005'); +SELECT * FROM t1 ORDER BY phone; +SELECT * FROM t1 WHERE phone='+7(912)800-80-01'; +SELECT * FROM t1 WHERE phone='79128008001'; +SELECT * FROM t1 WHERE phone='7 9 1 2 8 0 0 8 0 0 1'; +DROP TABLE t1; + show collation like 'utf8_test_ci'; create table t1 (c1 char(1) character set utf8 collate utf8_test_ci); insert into t1 values ('a'); diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index ecf92c1b7d4..ee4d052b3b3 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -7661,6 +7661,13 @@ static my_coll_lexem_num my_coll_lexem_next(MY_COLL_LEXEM *lexem) goto ex; } + if (beg[0] == '=') + { + beg++; + rc= MY_COLL_LEXEM_DIFF; + goto ex; + } + if (beg[0] == '<') { for (beg++, lexem->diff= 1; @@ -7821,6 +7828,10 @@ static int my_coll_rule_parse(MY_COLL_RULE *rule, size_t mitems, item.diff[1]= 0; item.diff[2]= 0; } + else if (lexem.diff == 0) + { + item.diff[0]= item.diff[1]= item.diff[2]= 0; + } if (nitems >= mitems) { my_coll_lexem_print_error(&lexem,errstr,errsize-1,"Too many rules"); diff --git a/strings/ctype.c b/strings/ctype.c index 75d76aceea3..4891e657b6e 100644 --- a/strings/ctype.c +++ b/strings/ctype.c @@ -74,6 +74,7 @@ struct my_cs_file_section_st #define _CS_DIFF1 19 #define _CS_DIFF2 20 #define _CS_DIFF3 21 +#define _CS_IDENTICAL 22 static struct my_cs_file_section_st sec[] = @@ -108,6 +109,7 @@ static struct my_cs_file_section_st sec[] = {_CS_DIFF1, "charsets/charset/collation/rules/p"}, {_CS_DIFF2, "charsets/charset/collation/rules/s"}, {_CS_DIFF3, "charsets/charset/collation/rules/t"}, + {_CS_IDENTICAL, "charsets/charset/collation/rules/i"}, {0, NULL} }; @@ -269,6 +271,7 @@ static int cs_value(MY_XML_PARSER *st,const char *attr, size_t len) case _CS_DIFF1: case _CS_DIFF2: case _CS_DIFF3: + case _CS_IDENTICAL: { /* Convert collation description from @@ -276,7 +279,7 @@ static int cs_value(MY_XML_PARSER *st,const char *attr, size_t len) into ICU Collation Customization expression. */ char arg[16]; - const char *cmd[]= {"&","<","<<","<<<"}; + const char *cmd[]= {"&","<","<<","<<<","="}; i->cs.tailoring= i->tailoring; mstr(arg,attr,len,sizeof(arg)-1); if (i->tailoring_length + 20 < sizeof(i->tailoring)) From 3bb7d3eebf5678d67933d7ae7cf1b9da8c70dbff Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 9 Nov 2009 14:53:49 +0400 Subject: [PATCH 07/14] Backporting test for Bug#158 ENUM and SET types does not accept valid cp1251 character --- mysql-test/r/ctype_cp1251.result | 11 +++++++++++ mysql-test/t/ctype_cp1251.test | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/mysql-test/r/ctype_cp1251.result b/mysql-test/r/ctype_cp1251.result index 47797af3cbe..bf0bc07c50e 100644 --- a/mysql-test/r/ctype_cp1251.result +++ b/mysql-test/r/ctype_cp1251.result @@ -70,3 +70,14 @@ we_ivo NULL we_martin NULL we_toshko NULL drop table t1; +CREATE TABLE t1 ( +e1 enum('ябълка'), +e2 enum('мляко') +) ENGINE=MYISAM character set cp1251; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `e1` enum('ябълка') DEFAULT NULL, + `e2` enum('мляко') DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=cp1251 +DROP TABLE t1; diff --git a/mysql-test/t/ctype_cp1251.test b/mysql-test/t/ctype_cp1251.test index 463a9cea4bc..b6a1cfc3f98 100644 --- a/mysql-test/t/ctype_cp1251.test +++ b/mysql-test/t/ctype_cp1251.test @@ -47,4 +47,14 @@ insert into t1 (a) values ('air'), select * from t1 where a like 'we_%'; drop table t1; +# +# Bug#158 ENUM and SET types does not accept valid cp1251 character +# +CREATE TABLE t1 ( + e1 enum('ябълка'), + e2 enum('мляко') +) ENGINE=MYISAM character set cp1251; +SHOW CREATE TABLE t1; +DROP TABLE t1; + # End of 4.1 tests From 510844e72a81d82bc435a056d6ca0b313a3c972d Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 9 Nov 2009 15:17:10 +0400 Subject: [PATCH 08/14] # # Bug#24690 Stored functions: RETURNing UTF8 strings # do not return UTF8_UNICODE_CI collation # # Bug#17903: cast to char results in binary # Regression. The character set was not being properly initialized # for CAST() with a type like CHAR(2) BINARY, which resulted in # incorrect results or even a server crash. # Backporting from mysql-6.0-codebase. mysql-test/r/sp-ucs2.result: mysql-test/t/sp-ucs2.test: Adding tests sql/mysql_priv.h: Adding prototype sql/sp.cc Remember COLLATE clause for non-default collations sql/sql_parse.cc Adding a new helper function sql/sql_yacc.yy - Allow "CHARACTER SET cs COLLATE cl" in SP parameters, RETURNS, DECLARE - Minor reorganization for "ASCII" and "UNICODE" related rules, to make the code more readable, also to allow these aliases: * "VARCHAR(10) ASCII BINARY" -> CHARACTER SET latin1 COLLATE latin1_bin * "VARCHAR(10) BINARY ASCII" -> CHARACTER SET latin1 COLLATE latin1_bin * "VARCHAR(10) UNICODE BINARY" -> CHARACTER SET ucs2 COLLATE ucs2_bin * "VARCHAR(10) BINARY UNICODE" -> CHARACTER SET ucs2 COLLATE ucs2_bin Previously these four aliases returned the error "This version of MySQL does not yet support return value collation". Note: This patch allows "VARCHAR(10) CHARACTER SET cs COLLATE cl" and the above four aliases. "VARCHAR(10) COLLATE cl" is still not allowed i.e. when COLLATE is given without CHARACTER SET. If we want to support this, we need an architecture decision which character set to use by default. --- mysql-test/r/sp-ucs2.result | 108 ++++++++++++++++++++++++++++++++ mysql-test/t/sp-ucs2.test | 120 ++++++++++++++++++++++++++++++++++++ sql/mysql_priv.h | 2 + sql/sp.cc | 5 ++ sql/sql_parse.cc | 34 ++++++++++ sql/sql_yacc.yy | 118 +++++++++++++++++++++++++---------- 6 files changed, 353 insertions(+), 34 deletions(-) diff --git a/mysql-test/r/sp-ucs2.result b/mysql-test/r/sp-ucs2.result index ce6be5b0a65..3806a84a849 100644 --- a/mysql-test/r/sp-ucs2.result +++ b/mysql-test/r/sp-ucs2.result @@ -12,3 +12,111 @@ a foo string drop function bug17615| drop table t3| +CREATE FUNCTION f(f1 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_unicode_ci) +RETURNS VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_danish_ci +BEGIN +DECLARE f2 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_swedish_ci; +DECLARE f3 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_bin; +SET f1= concat(collation(f1), ' ', collation(f2), ' ', collation(f3)); +RETURN f1; +END| +SELECT f('a')| +f('a') +ucs2_unicode_ci ucs2_swedish_ci ucs2_bin +SELECT collation(f('a'))| +collation(f('a')) +ucs2_danish_ci +DROP FUNCTION f| +CREATE FUNCTION f() +RETURNS VARCHAR(64) UNICODE BINARY +BEGIN +RETURN ''; +END| +SHOW CREATE FUNCTION f; +DROP FUNCTION f; +CREATE FUNCTION f() +RETURNS VARCHAR(64) BINARY UNICODE +BEGIN +RETURN ''; +END| +Function sql_mode Create Function character_set_client collation_connection Database Collation +f CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET ucs2 COLLATE ucs2_bin +BEGIN +RETURN ''; +END latin1 latin1_swedish_ci latin1_swedish_ci +SHOW CREATE FUNCTION f; +DROP FUNCTION f; +# +# Testing keywords ASCII + BINARY +# +CREATE FUNCTION f() +RETURNS VARCHAR(64) ASCII BINARY +BEGIN +RETURN ''; +END| +Function sql_mode Create Function character_set_client collation_connection Database Collation +f CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET ucs2 COLLATE ucs2_bin +BEGIN +RETURN ''; +END latin1 latin1_swedish_ci latin1_swedish_ci +SHOW CREATE FUNCTION f; +DROP FUNCTION f; +CREATE FUNCTION f() +RETURNS VARCHAR(64) BINARY ASCII +BEGIN +RETURN ''; +END| +Function sql_mode Create Function character_set_client collation_connection Database Collation +f CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET latin1 COLLATE latin1_bin +BEGIN +RETURN ''; +END latin1 latin1_swedish_ci latin1_swedish_ci +SHOW CREATE FUNCTION f; +DROP FUNCTION f; +# +# Testing COLLATE in OUT parameter +# +CREATE PROCEDURE p1(IN f1 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_czech_ci, +OUT f2 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_polish_ci) +BEGIN +SET f2= f1; +SET f2= concat(collation(f1), ' ', collation(f2)); +END| +Function sql_mode Create Function character_set_client collation_connection Database Collation +f CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET latin1 COLLATE latin1_bin +BEGIN +RETURN ''; +END latin1 latin1_swedish_ci latin1_swedish_ci +CREATE FUNCTION f1() +RETURNS VARCHAR(64) CHARACTER SET ucs2 +BEGIN +DECLARE f1 VARCHAR(64) CHARACTER SET ucs2; +DECLARE f2 VARCHAR(64) CHARACTER SET ucs2; +SET f1='str'; +CALL p1(f1, f2); +RETURN f2; +END| +SELECT f1()| +f1() +ucs2_czech_ci ucs2_polish_ci +DROP PROCEDURE p1| +DROP FUNCTION f1| +CREATE FUNCTION f(f1 VARCHAR(64) COLLATE ucs2_unicode_ci) +RETURNS VARCHAR(64) CHARACTER SET ucs2 +BEGIN +RETURN 'str'; +END| +ERROR 42000: This version of MySQL doesn't yet support 'COLLATE with no CHARACTER SET in SP parameters, RETURNS, DECLARE' +CREATE FUNCTION f(f1 VARCHAR(64) CHARACTER SET ucs2) +RETURNS VARCHAR(64) COLLATE ucs2_unicode_ci +BEGIN +RETURN 'str'; +END| +ERROR 42000: This version of MySQL doesn't yet support 'COLLATE with no CHARACTER SET in SP parameters, RETURNS, DECLARE' +CREATE FUNCTION f(f1 VARCHAR(64) CHARACTER SET ucs2) +RETURNS VARCHAR(64) CHARACTER SET ucs2 +BEGIN +DECLARE f2 VARCHAR(64) COLLATE ucs2_unicode_ci; +RETURN 'str'; +END| +ERROR 42000: This version of MySQL doesn't yet support 'COLLATE with no CHARACTER SET in SP parameters, RETURNS, DECLARE' diff --git a/mysql-test/t/sp-ucs2.test b/mysql-test/t/sp-ucs2.test index 7dd88b04871..0480d8f0799 100644 --- a/mysql-test/t/sp-ucs2.test +++ b/mysql-test/t/sp-ucs2.test @@ -25,4 +25,124 @@ drop function bug17615| drop table t3| +# +# Testing COLLATE clause in +# - IN parameter +# - RETURNS +# - DELCARE +# + +CREATE FUNCTION f(f1 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_unicode_ci) + RETURNS VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_danish_ci +BEGIN + DECLARE f2 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_swedish_ci; + DECLARE f3 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_bin; + SET f1= concat(collation(f1), ' ', collation(f2), ' ', collation(f3)); + RETURN f1; +END| +SELECT f('a')| +SELECT collation(f('a'))| +DROP FUNCTION f| + +# +# Testing keywords UNICODE + BINARY +# +CREATE FUNCTION f() + RETURNS VARCHAR(64) UNICODE BINARY +BEGIN + RETURN ''; +END| +SHOW CREATE FUNCTION f; +DROP FUNCTION f; + +CREATE FUNCTION f() + RETURNS VARCHAR(64) BINARY UNICODE +BEGIN + RETURN ''; +END| +SHOW CREATE FUNCTION f; +DROP FUNCTION f; + + +# +# Testing keywords ASCII + BINARY +# +CREATE FUNCTION f() + RETURNS VARCHAR(64) ASCII BINARY +BEGIN + RETURN ''; +END| +SHOW CREATE FUNCTION f; +DROP FUNCTION f; + +CREATE FUNCTION f() + RETURNS VARCHAR(64) BINARY ASCII +BEGIN + RETURN ''; +END| +SHOW CREATE FUNCTION f; +DROP FUNCTION f; + +# +# Testing COLLATE in OUT parameter +# + +CREATE PROCEDURE p1(IN f1 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_czech_ci, + OUT f2 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_polish_ci) +BEGIN + SET f2= f1; + SET f2= concat(collation(f1), ' ', collation(f2)); +END| + + +CREATE FUNCTION f1() + RETURNS VARCHAR(64) CHARACTER SET ucs2 +BEGIN + DECLARE f1 VARCHAR(64) CHARACTER SET ucs2; + DECLARE f2 VARCHAR(64) CHARACTER SET ucs2; + SET f1='str'; + CALL p1(f1, f2); + RETURN f2; +END| + + +SELECT f1()| +DROP PROCEDURE p1| +DROP FUNCTION f1| + + +# +# COLLATE with no CHARACTER SET in IN param +# +--error ER_NOT_SUPPORTED_YET +CREATE FUNCTION f(f1 VARCHAR(64) COLLATE ucs2_unicode_ci) + RETURNS VARCHAR(64) CHARACTER SET ucs2 +BEGIN + RETURN 'str'; +END| + + +# +# COLLATE with no CHARACTER SET in RETURNS +# +--error ER_NOT_SUPPORTED_YET +CREATE FUNCTION f(f1 VARCHAR(64) CHARACTER SET ucs2) + RETURNS VARCHAR(64) COLLATE ucs2_unicode_ci +BEGIN + RETURN 'str'; +END| + + +# +# COLLATE with no CHARACTER SET in DECLARE +# +--error ER_NOT_SUPPORTED_YET +CREATE FUNCTION f(f1 VARCHAR(64) CHARACTER SET ucs2) + RETURNS VARCHAR(64) CHARACTER SET ucs2 +BEGIN + DECLARE f2 VARCHAR(64) COLLATE ucs2_unicode_ci; + RETURN 'str'; +END| + + delimiter ;| diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 7413c18fdd8..b95e5e50f5a 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -858,6 +858,8 @@ bool check_string_char_length(LEX_STRING *str, const char *err_msg, bool no_error); bool check_host_name(LEX_STRING *str); +CHARSET_INFO *merge_charset_and_collation(CHARSET_INFO *cs, CHARSET_INFO *cl); + bool parse_sql(THD *thd, Parser_state *parser_state, Object_creation_ctx *creation_ctx); diff --git a/sql/sp.cc b/sql/sp.cc index 5898e553320..6c268e87711 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -693,6 +693,11 @@ sp_returns_type(THD *thd, String &result, sp_head *sp) { result.append(STRING_WITH_LEN(" CHARSET ")); result.append(field->charset()->csname); + if (!(field->charset()->state & MY_CS_PRIMARY)) + { + result.append(STRING_WITH_LEN(" COLLATE ")); + result.append(field->charset()->name); + } } delete field; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 08af00bb024..3b99d0e4c5f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -7951,3 +7951,37 @@ bool parse_sql(THD *thd, /** @} (end of group Runtime_Environment) */ + + + +/** + Check and merge "CHARACTER SET cs [ COLLATE cl ]" clause + + @param cs character set pointer. + @param cl collation pointer. + + Check if collation "cl" is applicable to character set "cs". + + If "cl" is NULL (e.g. when COLLATE clause is not specified), + then simply "cs" is returned. + + @return Error status. + @retval NULL, if "cl" is not applicable to "cs". + @retval pointer to merged CHARSET_INFO on success. +*/ + + +CHARSET_INFO* +merge_charset_and_collation(CHARSET_INFO *cs, CHARSET_INFO *cl) +{ + if (cl) + { + if (!my_charset_same(cs, cl)) + { + my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), cl->name, cs->csname); + return NULL; + } + return cl; + } + return cs; +} diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index e21ef0040fa..05283718162 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1172,7 +1172,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); text_string opt_gconcat_separator %type - type int_type real_type order_dir lock_option + type type_with_opt_collate int_type real_type order_dir lock_option udf_type if_exists opt_local opt_table_options table_options table_option opt_if_not_exists opt_no_write_to_binlog delete_option opt_temporary all_or_any opt_distinct @@ -1297,7 +1297,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); handler opt_precision opt_ignore opt_column opt_restrict grant revoke set lock unlock string_list field_options field_option - field_opt_list opt_binary table_lock_list table_lock + field_opt_list opt_binary ascii unicode table_lock_list table_lock ref_list opt_on_delete opt_on_delete_list opt_on_delete_item use opt_delete_options opt_delete_option varchar nchar nvarchar opt_outer table_list table_name table_alias_ref_list table_alias_ref @@ -2259,7 +2259,7 @@ sp_init_param: ; sp_fdparam: - ident sp_init_param type + ident sp_init_param type_with_opt_collate { LEX *lex= Lex; sp_pcontext *spc= lex->spcont; @@ -2296,7 +2296,7 @@ sp_pdparams: ; sp_pdparam: - sp_opt_inout sp_init_param ident type + sp_opt_inout sp_init_param ident type_with_opt_collate { LEX *lex= Lex; sp_pcontext *spc= lex->spcont; @@ -2376,7 +2376,7 @@ sp_decl: lex->sphead->reset_lex(YYTHD); lex->spcont->declare_var_boundary($2); } - type + type_with_opt_collate sp_opt_default { THD *thd= YYTHD; @@ -4835,14 +4835,14 @@ default_collation: HA_CREATE_INFO *cinfo= &Lex->create_info; if ((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) && cinfo->default_table_charset && $4 && - !my_charset_same(cinfo->default_table_charset,$4)) - { - my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), - $4->name, cinfo->default_table_charset->csname); - MYSQL_YYABORT; - } - Lex->create_info.default_table_charset= $4; - Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; + !($4= merge_charset_and_collation(cinfo->default_table_charset, + $4))) + { + MYSQL_YYABORT; + } + + Lex->create_info.default_table_charset= $4; + Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; } ; @@ -5360,6 +5360,28 @@ attribute: } ; + +type_with_opt_collate: + type opt_collate + { + $$= $1; + + if (Lex->charset) /* Lex->charset is scanned in "type" */ + { + if (!(Lex->charset= merge_charset_and_collation(Lex->charset, $2))) + MYSQL_YYABORT; + } + else if ($2) + { + my_error(ER_NOT_SUPPORTED_YET, MYF(0), + "COLLATE with no CHARACTER SET " + "in SP parameters, RETURNS, DECLARE"); + MYSQL_YYABORT; + } + } + ; + + now_or_signed_literal: NOW_SYM optional_braces { @@ -5442,11 +5464,21 @@ opt_default: | DEFAULT {} ; -opt_binary: - /* empty */ { Lex->charset=NULL; } - | ASCII_SYM opt_bin_mod { Lex->charset=&my_charset_latin1; } - | BYTE_SYM { Lex->charset=&my_charset_bin; } - | UNICODE_SYM opt_bin_mod + +ascii: + ASCII_SYM { Lex->charset= &my_charset_latin1; } + | BINARY ASCII_SYM + { + Lex->charset= &my_charset_latin1_bin; + } + | ASCII_SYM BINARY + { + Lex->charset= &my_charset_latin1_bin; + } + ; + +unicode: + UNICODE_SYM { if (!(Lex->charset=get_charset_by_csname("ucs2", MY_CS_PRIMARY,MYF(0)))) @@ -5455,8 +5487,40 @@ opt_binary: MYSQL_YYABORT; } } + | UNICODE_SYM BINARY + { + if (!(Lex->charset=get_charset_by_name("ucs2_bin", MYF(0)))) + { + my_error(ER_UNKNOWN_COLLATION, MYF(0), "ucs2_bin"); + MYSQL_YYABORT; + } + } + | BINARY UNICODE_SYM + { + if (!(Lex->charset=get_charset_by_name("ucs2_bin", MYF(0)))) + { + my_error(ER_UNKNOWN_COLLATION, MYF(0), "ucs2_bin"); + MYSQL_YYABORT; + } + } + ; + +opt_binary: + /* empty */ { Lex->charset=NULL; } + | ascii + | unicode + | BYTE_SYM { Lex->charset=&my_charset_bin; } | charset charset_name opt_bin_mod { Lex->charset=$2; } - | BINARY opt_bin_charset { Lex->type|= BINCMP_FLAG; } + | BINARY + { + Lex->charset= NULL; + Lex->type|= BINCMP_FLAG; + } + | BINARY charset charset_name + { + Lex->charset= $3; + Lex->type|= BINCMP_FLAG; + } ; opt_bin_mod: @@ -5464,20 +5528,6 @@ opt_bin_mod: | BINARY { Lex->type|= BINCMP_FLAG; } ; -opt_bin_charset: - /* empty */ { Lex->charset= NULL; } - | ASCII_SYM { Lex->charset=&my_charset_latin1; } - | UNICODE_SYM - { - if (!(Lex->charset=get_charset_by_csname("ucs2", - MY_CS_PRIMARY,MYF(0)))) - { - my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), "ucs2"); - MYSQL_YYABORT; - } - } - | charset charset_name { Lex->charset=$2; } - ; opt_primary: /* empty */ @@ -13666,7 +13716,7 @@ sf_tail: lex->interval_list.empty(); lex->type= 0; } - type /* $11 */ + type_with_opt_collate /* $11 */ { /* $12 */ LEX *lex= Lex; sp_head *sp= lex->sphead; From d17f4d9d5cbb1d12a20c49c23509f031f66b83b4 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 9 Nov 2009 15:35:18 +0400 Subject: [PATCH 09/14] Bug#26180 Can't add columns to tables created with utf8 (regular) text indexes Backporting from 6.0. --- mysql-test/r/ctype_utf8.result | 17 +++++++++++++ mysql-test/t/ctype_utf8.test | 13 ++++++++++ sql/sql_table.cc | 44 ++++++++++++++++++++++++++++++++-- 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 4ff48bd380a..668b1b0febe 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -1881,6 +1881,23 @@ CONVERT(a, CHAR) CONVERT(b, CHAR) DROP TABLE t1; End of 5.0 tests Start of 5.4 tests +CREATE TABLE t1 ( +clipid INT NOT NULL, +Tape TINYTEXT, +PRIMARY KEY (clipid), +KEY tape(Tape(255)) +) CHARACTER SET=utf8; +ALTER TABLE t1 ADD mos TINYINT DEFAULT 0 AFTER clipid; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `clipid` int(11) NOT NULL, + `mos` tinyint(4) DEFAULT '0', + `Tape` tinytext, + PRIMARY KEY (`clipid`), + KEY `tape` (`Tape`(255)) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 +DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( predicted_order int NOT NULL, diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 7e93b638acb..0a26c472f49 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -1459,6 +1459,19 @@ DROP TABLE t1; --echo Start of 5.4 tests +# +# Bug#26180: Can't add columns to tables created with utf8 text indexes +# +CREATE TABLE t1 ( + clipid INT NOT NULL, + Tape TINYTEXT, + PRIMARY KEY (clipid), + KEY tape(Tape(255)) +) CHARACTER SET=utf8; +ALTER TABLE t1 ADD mos TINYINT DEFAULT 0 AFTER clipid; +SHOW CREATE TABLE t1; +DROP TABLE t1; + # # Bug#26474: Add Sinhala script (Sri Lanka) collation to MySQL # diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 4d474738843..91106fcabac 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5933,6 +5933,35 @@ bool alter_table_manage_keys(TABLE *table, int indexes_were_disabled, } +/** + maximum possible length for certain blob types. + + @param[in] type Blob type (e.g. MYSQL_TYPE_TINY_BLOB) + + @return + length +*/ + +static uint +blob_length_by_type(enum_field_types type) +{ + switch (type) + { + case MYSQL_TYPE_TINY_BLOB: + return 255; + case MYSQL_TYPE_BLOB: + return 65535; + case MYSQL_TYPE_MEDIUM_BLOB: + return 16777215; + case MYSQL_TYPE_LONG_BLOB: + return 4294967295U; + default: + DBUG_ASSERT(0); // we should never go here + return 0; + } +} + + /** Prepare column and key definitions for CREATE TABLE in ALTER TABLE. @@ -6228,6 +6257,14 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, BLOBs may have cfield->length == 0, which is why we test it before checking whether cfield->length < key_part_length (in chars). + + In case of TEXTs we check the data type maximum length *in bytes* + to key part length measured *in characters* (i.e. key_part_length + devided to mbmaxlen). This is because it's OK to have: + CREATE TABLE t1 (a tinytext, key(a(254)) character set utf8); + In case of this example: + - data type maximum length is 255. + - key_part_length is 1016 (=254*4, where 4 is mbmaxlen) */ if (!Field::type_can_have_key_part(cfield->field->type()) || !Field::type_can_have_key_part(cfield->sql_type) || @@ -6235,8 +6272,11 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, (key_info->flags & HA_SPATIAL) || (cfield->field->field_length == key_part_length && !f_is_blob(key_part->key_type)) || - (cfield->length && (cfield->length < key_part_length / - key_part->field->charset()->mbmaxlen))) + (cfield->length && (((cfield->sql_type >= MYSQL_TYPE_TINY_BLOB && + cfield->sql_type <= MYSQL_TYPE_BLOB) ? + blob_length_by_type(cfield->sql_type) : + cfield->length) < + key_part_length / key_part->field->charset()->mbmaxlen))) key_part_length= 0; // Use whole field } key_part_length /= key_part->field->charset()->mbmaxlen; From 96817d2483b52ffa7609bf6b9f4a1ba962de39e0 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Wed, 11 Nov 2009 05:12:56 +0400 Subject: [PATCH 10/14] Bug#47126 equal flag values causing unexpected behaviour Although the MY_SYNC_DIR flag supported in my_create(), my_delete(), my_rename() and my_symlink(), this feature is not used in the mysql code now. So technically we can declare the MY_SYNC_DIR as 0, but I decided to assign a new value for it as it's probably safer and worths nothing. per-file comments: include/my_sys.h Bug#47126 equal flag values causing unexpected behaviour assign unique value for the MY_SYNC_DIR --- include/my_sys.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/my_sys.h b/include/my_sys.h index 9121f0f249e..3c8df28b151 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -60,7 +60,7 @@ extern int NEAR my_errno; /* Last error in mysys */ #define MY_WME 16 /* Write message on error */ #define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */ #define MY_IGNORE_BADFD 32 /* my_sync: ignore 'bad descriptor' errors */ -#define MY_SYNC_DIR 1024 /* my_create/delete/rename: sync directory */ +#define MY_SYNC_DIR 8192 /* my_create/delete/rename: sync directory */ #define MY_RAID 64 /* Support for RAID */ #define MY_FULL_IO 512 /* For my_read - loop intil I/O is complete */ #define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */ From 91f92a1606071fb39044a9206c58a1818b95f360 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Wed, 11 Nov 2009 12:01:09 +0200 Subject: [PATCH 11/14] revert patch for bug #47146 because it breaks Solaris builds --- storage/example/Makefile.am | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/storage/example/Makefile.am b/storage/example/Makefile.am index 5071c217ef3..ce269aee59b 100644 --- a/storage/example/Makefile.am +++ b/storage/example/Makefile.am @@ -1,5 +1,5 @@ -# Copyright (C) 2005-2006 MySQL AB, 2009 Sun Microsystems, Inc. -# All rights reserved. +# Copyright (C) 2005-2006 MySQL AB +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. @@ -50,18 +50,11 @@ libexample_a_SOURCES= ha_example.cc EXTRA_DIST = CMakeLists.txt plug.in if HAVE_DTRACE_DASH_G -# The object for static and dynamic linking of example differ -# For static linkage of example to mysqld -# That's actually not needed as example is only dynamic loadable, but for completion libexample_a_LIBADD = probes_mysql.o -libexample_a_DEPENDENCIES = probes_mysql.o dtrace_files dtrace_providers -# For example as shared library -ha_example_la_LIBADD = probes_sh_mysql.o -ha_example_la_DEPENDENCIES = probes_sh_mysql.o $(DTRACESHAREDFILES) dtrace_providers - -CLEANFILES = $(DTRACEPROVIDER) dtrace_files dtrace_providers $(DTRACESHAREDFILES) +libexample_a_DEPENDENCIES = probes_mysql.o +CLEANFILES = +BUILT_SOURCES = DTRACEFILES = libexample_a-ha_example.o -DTRACESHAREDFILES = .libs/ha_example_la-ha_example.o DTRACEPROVIDER = probes_mysql.d dtrace_files: @@ -73,12 +66,8 @@ probes_mysql.d: $(CP) $(top_srcdir)/include/probes_mysql.d.base probes_mysql.d echo timestamp > dtrace_sources -probes_sh_mysql.o: $(DTRACEPROVIDER) $(DTRACESHAREDFILES) - $(DTRACE) $(DTRACEFLAGS) -G -s $(DTRACEPROVIDER) $(DTRACESHAREDFILES) -o $@ - probes_mysql.o: $(DTRACEPROVIDER) $(DTRACEFILES) $(DTRACE) $(DTRACEFLAGS) -G -s $(DTRACEPROVIDER) $(DTRACEFILES) -o $@ - endif # Don't update the files from bitkeeper From 9a1020e7bd6ba00b13364c6ab5a3a4f017262a13 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Wed, 11 Nov 2009 10:34:41 -0700 Subject: [PATCH 12/14] Bug#9801 Views: imperfect error message Backport to 5.5: adjusted the test outputs in the funcs_1 test suite --- mysql-test/suite/funcs_1/r/innodb_views.result | 8 ++++---- mysql-test/suite/funcs_1/r/memory_views.result | 8 ++++---- mysql-test/suite/funcs_1/r/myisam_views.result | 8 ++++---- mysql-test/suite/funcs_1/r/ndb_views.result | 8 ++++---- mysql-test/suite/funcs_1/r/storedproc.result | 13 +++++++------ 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/mysql-test/suite/funcs_1/r/innodb_views.result b/mysql-test/suite/funcs_1/r/innodb_views.result index a335e135a4f..393a560f7a4 100644 --- a/mysql-test/suite/funcs_1/r/innodb_views.result +++ b/mysql-test/suite/funcs_1/r/innodb_views.result @@ -3546,11 +3546,11 @@ CREATE VIEW v1 or REPLACE AS Select * from tb2 my_table; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'or REPLACE AS Select * from tb2 my_table' at line 1 CREATE VIEW v1 WITH CASCADED CHECK OPTION AS Select * from tb2 my_table limit 50; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS Select * +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CASCADED CHECK OPTION AS Select * from tb2 my_table limit 50' at line 1 CREATE VIEW v1 WITH LOCAL CHECK OPTION AS Select * from tb2 my_table limit 50; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH LOCAL CHECK OPTION AS Select * +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LOCAL CHECK OPTION AS Select * from tb2 my_table limit 50' at line 1 SELECT * FROM tb2 my_table CREATE VIEW As v1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE VIEW As v1' at line 1 @@ -3580,7 +3580,7 @@ FROM test.tb2 my_table CHECK OPTION WITH CASCADED; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHECK OPTION WITH CASCADED' at line 2 CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH CASCADED CHECK OPTION +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table' at line 1 CREATE OR REPLACE AS SELECT F59, F60 FROM test.tb2 my_table VIEW v1 WITH CASCADED CHECK OPTION; @@ -3609,7 +3609,7 @@ FROM test.tb2 my_table CHECK OPTION WITH LOCAL; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHECK OPTION WITH LOCAL' at line 2 CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH CASCADED CHECK OPTION +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table' at line 1 CREATE OR REPLACE AS SELECT F59, F60 FROM test.tb2 my_table VIEW v1 WITH LOCAL CHECK OPTION; diff --git a/mysql-test/suite/funcs_1/r/memory_views.result b/mysql-test/suite/funcs_1/r/memory_views.result index ccbd086b71f..2991f578cb7 100644 --- a/mysql-test/suite/funcs_1/r/memory_views.result +++ b/mysql-test/suite/funcs_1/r/memory_views.result @@ -3547,11 +3547,11 @@ CREATE VIEW v1 or REPLACE AS Select * from tb2 my_table; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'or REPLACE AS Select * from tb2 my_table' at line 1 CREATE VIEW v1 WITH CASCADED CHECK OPTION AS Select * from tb2 my_table limit 50; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS Select * +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CASCADED CHECK OPTION AS Select * from tb2 my_table limit 50' at line 1 CREATE VIEW v1 WITH LOCAL CHECK OPTION AS Select * from tb2 my_table limit 50; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH LOCAL CHECK OPTION AS Select * +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LOCAL CHECK OPTION AS Select * from tb2 my_table limit 50' at line 1 SELECT * FROM tb2 my_table CREATE VIEW As v1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE VIEW As v1' at line 1 @@ -3581,7 +3581,7 @@ FROM test.tb2 my_table CHECK OPTION WITH CASCADED; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHECK OPTION WITH CASCADED' at line 2 CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH CASCADED CHECK OPTION +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table' at line 1 CREATE OR REPLACE AS SELECT F59, F60 FROM test.tb2 my_table VIEW v1 WITH CASCADED CHECK OPTION; @@ -3610,7 +3610,7 @@ FROM test.tb2 my_table CHECK OPTION WITH LOCAL; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHECK OPTION WITH LOCAL' at line 2 CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH CASCADED CHECK OPTION +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table' at line 1 CREATE OR REPLACE AS SELECT F59, F60 FROM test.tb2 my_table VIEW v1 WITH LOCAL CHECK OPTION; diff --git a/mysql-test/suite/funcs_1/r/myisam_views.result b/mysql-test/suite/funcs_1/r/myisam_views.result index 9b07a0ae45b..2901405b505 100644 --- a/mysql-test/suite/funcs_1/r/myisam_views.result +++ b/mysql-test/suite/funcs_1/r/myisam_views.result @@ -4049,11 +4049,11 @@ CREATE VIEW v1 or REPLACE AS Select * from tb2 my_table; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'or REPLACE AS Select * from tb2 my_table' at line 1 CREATE VIEW v1 WITH CASCADED CHECK OPTION AS Select * from tb2 my_table limit 50; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS Select * +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CASCADED CHECK OPTION AS Select * from tb2 my_table limit 50' at line 1 CREATE VIEW v1 WITH LOCAL CHECK OPTION AS Select * from tb2 my_table limit 50; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH LOCAL CHECK OPTION AS Select * +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LOCAL CHECK OPTION AS Select * from tb2 my_table limit 50' at line 1 SELECT * FROM tb2 my_table CREATE VIEW As v1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE VIEW As v1' at line 1 @@ -4083,7 +4083,7 @@ FROM test.tb2 my_table CHECK OPTION WITH CASCADED; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHECK OPTION WITH CASCADED' at line 2 CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH CASCADED CHECK OPTION +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table' at line 1 CREATE OR REPLACE AS SELECT F59, F60 FROM test.tb2 my_table VIEW v1 WITH CASCADED CHECK OPTION; @@ -4112,7 +4112,7 @@ FROM test.tb2 my_table CHECK OPTION WITH LOCAL; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHECK OPTION WITH LOCAL' at line 2 CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH CASCADED CHECK OPTION +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table' at line 1 CREATE OR REPLACE AS SELECT F59, F60 FROM test.tb2 my_table VIEW v1 WITH LOCAL CHECK OPTION; diff --git a/mysql-test/suite/funcs_1/r/ndb_views.result b/mysql-test/suite/funcs_1/r/ndb_views.result index b75f4955986..561f26c4293 100644 --- a/mysql-test/suite/funcs_1/r/ndb_views.result +++ b/mysql-test/suite/funcs_1/r/ndb_views.result @@ -3546,11 +3546,11 @@ CREATE VIEW v1 or REPLACE AS Select * from tb2 my_table; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'or REPLACE AS Select * from tb2 my_table' at line 1 CREATE VIEW v1 WITH CASCADED CHECK OPTION AS Select * from tb2 my_table limit 50; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS Select * +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CASCADED CHECK OPTION AS Select * from tb2 my_table limit 50' at line 1 CREATE VIEW v1 WITH LOCAL CHECK OPTION AS Select * from tb2 my_table limit 50; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH LOCAL CHECK OPTION AS Select * +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LOCAL CHECK OPTION AS Select * from tb2 my_table limit 50' at line 1 SELECT * FROM tb2 my_table CREATE VIEW As v1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE VIEW As v1' at line 1 @@ -3580,7 +3580,7 @@ FROM test.tb2 my_table CHECK OPTION WITH CASCADED; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHECK OPTION WITH CASCADED' at line 2 CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH CASCADED CHECK OPTION +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table' at line 1 CREATE OR REPLACE AS SELECT F59, F60 FROM test.tb2 my_table VIEW v1 WITH CASCADED CHECK OPTION; @@ -3609,7 +3609,7 @@ FROM test.tb2 my_table CHECK OPTION WITH LOCAL; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHECK OPTION WITH LOCAL' at line 2 CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH CASCADED CHECK OPTION +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table' at line 1 CREATE OR REPLACE AS SELECT F59, F60 FROM test.tb2 my_table VIEW v1 WITH LOCAL CHECK OPTION; diff --git a/mysql-test/suite/funcs_1/r/storedproc.result b/mysql-test/suite/funcs_1/r/storedproc.result index ab917fce339..254336db331 100644 --- a/mysql-test/suite/funcs_1/r/storedproc.result +++ b/mysql-test/suite/funcs_1/r/storedproc.result @@ -2806,7 +2806,7 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp SELECT * from t1 where f2=f1' at line 1 CREATE PROCEDURE with() SELECT * from t1 where f2=f1; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'with() +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '() SELECT * from t1 where f2=f1' at line 1 CREATE PROCEDURE write() SELECT * from t1 where f2=f1; @@ -5660,7 +5660,7 @@ CREATE PROCEDURE sp1() with:BEGIN SELECT @x; END// -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'with:BEGIN +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':BEGIN SELECT @x; END' at line 2 DROP PROCEDURE IF EXISTS sp1; @@ -9220,7 +9220,7 @@ CREATE PROCEDURE sp1() BEGIN declare with char; END// -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'with char; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'char; END' at line 3 DROP PROCEDURE IF EXISTS sp1; Warnings: @@ -11576,8 +11576,9 @@ BEGIN declare with condition for sqlstate '02000'; declare exit handler for with set @var2 = 1; END// -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'with condition for sqlstate '02000'; -declare exit handler for with set @var2 = 1' at line 3 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'condition for sqlstate '02000'; +declare exit handler for with set @var2 = 1; +END' at line 3 DROP PROCEDURE IF EXISTS sp1; Warnings: Note 1305 PROCEDURE sp1 does not exist @@ -13681,7 +13682,7 @@ CREATE PROCEDURE sp1( ) BEGIN declare with handler for sqlstate '02000' set @var2 = 1; END// -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'with handler for sqlstate '02000' set @var2 = 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'handler for sqlstate '02000' set @var2 = 1; END' at line 3 DROP PROCEDURE IF EXISTS sp1; Warnings: From 146a098ff7949ebbb8b96acb1dc7c9fdff5983cf Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Sun, 15 Nov 2009 23:19:53 +0400 Subject: [PATCH 13/14] result updates for the 'row-only' tests --- mysql-test/r/mysqlbinlog_row.result | 2 +- mysql-test/r/mysqlbinlog_row_innodb.result | 8 ++++---- mysql-test/r/mysqlbinlog_row_myisam.result | 8 ++++---- mysql-test/r/mysqlbinlog_row_trans.result | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/mysqlbinlog_row.result b/mysql-test/r/mysqlbinlog_row.result index 9b562ac0fff..85416138c6d 100644 --- a/mysql-test/r/mysqlbinlog_row.result +++ b/mysql-test/r/mysqlbinlog_row.result @@ -339,7 +339,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/r/mysqlbinlog_row_innodb.result b/mysql-test/r/mysqlbinlog_row_innodb.result index 86f0b67ebb3..cf59d23bcf1 100644 --- a/mysql-test/r/mysqlbinlog_row_innodb.result +++ b/mysql-test/r/mysqlbinlog_row_innodb.result @@ -2256,7 +2256,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8 *//*!*/; @@ -3879,7 +3879,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8 *//*!*/; @@ -4246,7 +4246,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8 *//*!*/; @@ -4807,7 +4807,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8 *//*!*/; diff --git a/mysql-test/r/mysqlbinlog_row_myisam.result b/mysql-test/r/mysqlbinlog_row_myisam.result index b9366d941f8..973786d698e 100644 --- a/mysql-test/r/mysqlbinlog_row_myisam.result +++ b/mysql-test/r/mysqlbinlog_row_myisam.result @@ -2256,7 +2256,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8 *//*!*/; @@ -3901,7 +3901,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8 *//*!*/; @@ -4274,7 +4274,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8 *//*!*/; @@ -4845,7 +4845,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8 *//*!*/; diff --git a/mysql-test/r/mysqlbinlog_row_trans.result b/mysql-test/r/mysqlbinlog_row_trans.result index 9c3348a9e76..43a9a6182f8 100644 --- a/mysql-test/r/mysqlbinlog_row_trans.result +++ b/mysql-test/r/mysqlbinlog_row_trans.result @@ -135,7 +135,7 @@ ROLLBACK/*!*/; use test/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; From 408dd52a6ad1698619fb933b62966fa8b843f859 Mon Sep 17 00:00:00 2001 From: Guilhem Bichot Date: Wed, 18 Nov 2009 21:36:17 +0100 Subject: [PATCH 14/14] Backport of the fix for BUG#40368 "mysqld_safe not honouring underscore same as dash on server options" from 6.0 (revision-id:guilhem@mysql.com-20090505113602-l12kxupeatve18dh). Such bug led "mysqld_safe --core_file_size=#" to not work because mysqld_safe wouldn't recognize that "ulimit -c" is needed; only --core-file-size=# worked. Same for --open_files_limit and other options with _ where mysqld_safe needs to do something more than passing to mysqld. Original fix by Erik Ljungstrom erik at ibiblio dot org ; slightly modified here. Tested on all internally accessible Unix. --- scripts/mysqld_safe.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 95c4419273f..70b9b9f630e 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -160,7 +160,13 @@ parse_arguments() { fi for arg do - val=`echo "$arg" | sed -e "s;--[^=]*=;;"` + # the parameter after "=", or the whole $arg if no match + val=`echo "$arg" | sed -e 's;^--[^=]*=;;'` + # what's before "=", or the whole $arg if no match + optname=`echo "$arg" | sed -e 's/^\(--[^=]*\)=.*$/\1/'` + # replace "_" by "-" ; mysqld_safe must accept "_" like mysqld does. + optname_subst=`echo "$optname" | sed 's/_/-/g'` + arg=`echo $arg | sed "s/^$optname/$optname_subst/"` case "$arg" in # these get passed explicitly to mysqld --basedir=*) MY_BASEDIR_VERSION="$val" ;;