From 994c0f83083ceee30430f28b8f1ced9b71944dbb Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Sat, 6 Feb 2010 23:54:30 +0400 Subject: Bug #45640: optimizer bug produces wrong results Grouping by a subquery in a query with a distinct aggregate function lead to a wrong result (wrong and unordered grouping values). There are two related problems: 1) The query like this: SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) c FROM t1 GROUP BY aa returned wrong result, because the outer reference "t1.a" in the subquery was substituted with the Item_ref item. The Item_ref item obtains data from the result_field object that refreshes once after the end of each group. This data is not applicable to filesort since filesort() doesn't care about groups (and doesn't update result_field objects with copy_fields() and so on). Also that data is not applicable to group separation algorithm: end_send_group() checks every record with test_if_group_changed() that evaluates Item_ref items, but it refreshes those Item_ref-s only after the end of group, that is a vicious circle and the grouped column values in the output are shifted. Fix: if a) we grouping by a subquery and b) that subquery has outer references to FROM list of the grouping query, then we substitute these outer references with Item_direct_ref like references under aggregate functions: Item_direct_ref obtains data directly from the current record. 2) The query with a non-trivial grouping expression like: SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) c FROM t1 GROUP BY aa+0 also returned wrong result, since JOIN::exec() substitutes references to top-level aliases in SELECT list with Item_copy caching items. Item_copy items have same refreshing policy as Item_ref items, so the whole groping expression with Item_copy inside returns wrong result in filesort() and end_send_group(). Fix: include aliased items into GROUP BY item tree instead of Item_ref references to them. mysql-test/r/group_by.result: Test case for bug #45640 mysql-test/t/group_by.test: Test case for bug #45640 sql/item.cc: Bug #45640: optimizer bug produces wrong results Item_field::fix_fields() has been modified to resolve aliases in GROUP BY item trees into aliased items instead of Item_ref items. sql/item.h: Bug #45640: optimizer bug produces wrong results - Item::find_item_processor() has been introduced. - Item_ref::walk() has been modified to apply processors to itself too (not only to referenced item). sql/mysql_priv.h: Bug #45640: optimizer bug produces wrong results fix_inner_refs() has been modified to accept group_list parameter. sql/sql_lex.cc: Bug #45640: optimizer bug produces wrong results Initialization of st_select_lex::group_fix_field has been added. sql/sql_lex.h: Bug #45640: optimizer bug produces wrong results The st_select_lex::group_fix_field field has been introduced to control alias resolution in Itef_fied::fix_fields. sql/sql_select.cc: Bug #45640: optimizer bug produces wrong results - The fix_inner_refs function has been modified to treat subquery outer references like outer fields under aggregate functions, if they are included in GROUP BY item tree. - The find_order_in_list function has been modified to fix Item_field alias fields included in the GROUP BY item trees in a special manner. --- sql/mysql_priv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/mysql_priv.h') diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 34f29e7c458..1b775e658f1 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1192,7 +1192,7 @@ int setup_group(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, List &fields, List &all_fields, ORDER *order, bool *hidden_group_fields); bool fix_inner_refs(THD *thd, List &all_fields, SELECT_LEX *select, - Item **ref_pointer_array); + Item **ref_pointer_array, ORDER *group_list= NULL); bool handle_select(THD *thd, LEX *lex, select_result *result, ulong setup_tables_done_option); -- cgit v1.2.1 From e0fb0d9d018e0bc1a2da9f62a929cf669efd8343 Mon Sep 17 00:00:00 2001 From: Magne Mahre Date: Tue, 9 Feb 2010 11:30:50 +0100 Subject: Bug#47974 'TYPE=storage_engine' is deprecated and will be removed in MySQL 6.0 CREATE TABLE... TYPE= returns the warning "The syntax 'TYPE=storage_engine' is deprecated and will be removed in MySQL 6.0. Please use 'ENGINE=storage_engine' instead" This syntax is deprecated already from version 5.4.4, so the message has been changed. In addition, the deprecation macro was changed to reflect the ServerPT decision not to include version number in the warning message. A number of test result files have been changed as a consequence of the change in the deprecation macro. --- sql/mysql_priv.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'sql/mysql_priv.h') diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 1b775e658f1..90b02f5337a 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -118,13 +118,15 @@ char* query_table_status(THD *thd,const char *db,const char *table_name); #define WARN_DEPRECATED(Thd,Ver,Old,New) \ do { \ DBUG_ASSERT(strncmp(Ver, MYSQL_SERVER_VERSION, sizeof(Ver)-1) > 0); \ - if (((uchar*)Thd) != NULL) \ + if (((uchar*)Thd) != NULL) \ push_warning_printf(((THD *)Thd), MYSQL_ERROR::WARN_LEVEL_WARN, \ - ER_WARN_DEPRECATED_SYNTAX, ER(ER_WARN_DEPRECATED_SYNTAX_WITH_VER), \ - (Old), (Ver), (New)); \ + ER_WARN_DEPRECATED_SYNTAX, \ + ER(ER_WARN_DEPRECATED_SYNTAX), \ + (Old), (New)); \ else \ - sql_print_warning("The syntax '%s' is deprecated and will be removed " \ - "in a future release. Please use %s instead.", (Old), (New)); \ + sql_print_warning("'%s' is deprecated and will be removed " \ + "in a future release. Please use '%s' instead.", \ + (Old), (New)); \ } while(0) extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *system_charset_info; -- cgit v1.2.1 From c3cd608aef94f8b8507997faac9e81eebc32a2d6 Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Fri, 19 Mar 2010 11:06:40 +0200 Subject: Bug #51648 DBUG_SYNC_POINT is not defined on all platforms and mtr cant pre-check that DBUG_SYNC_POINT has at least one strong limitation that it's not defined on all platforms. It has issues cooperating with @@debug. All in all its functionality is superseded by DEBUG_SYNC facility and there is no reason to maintain the old less flexible one. Fixed with adding debug_sync_set_action() function as a facility to set up a sync-action in the server sources code and re-writing existing simulations (found 3) to use it. Couple of tests have been reworked as well. The patch offers a pattern for setting sync-points in replication threads where the standard DEBUG_SYNC does not suffice to reach goals. mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test: rewriting the test from GET_LOCK()-based to DEBUG_SYNC-based; a pattern of usage DEBUG_SYNC for replication testing is provided. mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result: results are changed. mysql-test/suite/rpl/t/rpl_get_master_version_and_clock.test: rewriting the test from GET_LOCK()-based to DEBUG_SYNC-based; limiting the test to run only with MIXED binlog-format as the test last some 10 secs sensitively contributing to the total of tests run. mysql-test/suite/rpl/t/rpl_show_slave_running.test: rewriting the test from GET_LOCK()-based to DEBUG_SYNC-based. sql/debug_sync.cc: adding debug_sync_set_action() function as a facility to set up a sync-action in the server sources code. sql/debug_sync.h: externalizing debug_sync_set_action(). sql/item_func.cc: purging sources from DBUG_SYNC_POINT. sql/mysql_priv.h: purging sources from DBUG_SYNC_POINT. sql/slave.cc: rewriting failure simulations to base on DEBUG_SYNC rather than GET_LOCK()-based DBUG_SYNC_POINT. sql/sql_repl.cc: removing an orphan failure simulation line because no counterpart in tests existing. --- sql/mysql_priv.h | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'sql/mysql_priv.h') diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 90b02f5337a..098ea514cb6 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -580,20 +580,6 @@ protected: /* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */ #define UNDEF_POS (-1) -#ifdef EXTRA_DEBUG -/** - Sync points allow us to force the server to reach a certain line of code - and block there until the client tells the server it is ok to go on. - The client tells the server to block with SELECT GET_LOCK() - and unblocks it with SELECT RELEASE_LOCK(). Used for debugging difficult - concurrency problems -*/ -#define DBUG_SYNC_POINT(lock_name,lock_timeout) \ - debug_sync_point(lock_name,lock_timeout) -void debug_sync_point(const char* lock_name, uint lock_timeout); -#else -#define DBUG_SYNC_POINT(lock_name,lock_timeout) -#endif /* EXTRA_DEBUG */ /* BINLOG_DUMP options */ -- cgit v1.2.1 From 291fd9698340f3d83ff096542720f7335cb078d2 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 29 Mar 2010 17:13:53 +0200 Subject: pluggable auth with plugin examples Makefile.am: add new API files to the check_abi rule, remove duplicates client/CMakeLists.txt: now a client can use dlopen too client/Makefile.am: be csh-friendly include/my_global.h: add dummy plugs for dlopen and co. for the code that needs them to work in static builds mysys/Makefile.am: be csh-friendly plugin/auth/dialog.c: typo fixed --- sql/mysql_priv.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sql/mysql_priv.h') diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 2fc12ea10c0..c9afe10a97d 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1067,9 +1067,6 @@ int write_bin_log(THD *thd, bool clear_error, char const *query, ulong query_length); /* sql_connect.cc */ -int check_user(THD *thd, enum enum_server_command command, - const char *passwd, uint passwd_len, const char *db, - bool check_count); pthread_handler_t handle_one_connection(void *arg); bool init_new_connection_handler_thread(); void reset_mqh(LEX_USER *lu, bool get_them); @@ -1082,6 +1079,9 @@ bool login_connection(THD *thd); void end_connection(THD *thd); void prepare_new_connection_state(THD* thd); void update_global_user_stats(THD* thd, bool create_user, time_t now); +int get_or_create_user_conn(THD *thd, const char *user, + const char *host, USER_RESOURCES *mqh); +int check_for_max_user_connections(THD *thd, USER_CONN *uc); int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent); bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create); -- cgit v1.2.1 From e65caec1387ecc3b25a3a97c5ccedb9c16caa0ef Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 31 Mar 2010 16:12:37 +0300 Subject: Bug #37168: Missing variable - skip_name_resolve Added a read-only global boolean variable skip_name_resolve. --- sql/mysql_priv.h | 1 + 1 file changed, 1 insertion(+) (limited to 'sql/mysql_priv.h') diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 098ea514cb6..56175d069c5 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1990,6 +1990,7 @@ extern my_bool opt_log, opt_slow_log; extern ulong log_output_options; extern my_bool opt_log_queries_not_using_indexes; extern bool opt_disable_networking, opt_skip_show_db; +extern bool opt_skip_name_resolve; extern bool opt_ignore_builtin_innodb; extern my_bool opt_character_set_client_handshake; extern bool volatile abort_loop, shutdown_in_progress; -- cgit v1.2.1 From e24e1668bc112afe4b4f6b3dc4d5b8d10635f60b Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 8 Apr 2010 14:10:05 +0200 Subject: MWL#43 CREATE TABLE options (by Sanja) Docs/sp-imp-spec.txt: New sql_mode added. include/my_base.h: Flag in frm of create options. libmysqld/CMakeLists.txt: New files added. libmysqld/Makefile.am: New files added. mysql-test/r/events_bugs.result: New sql_mode added. mysql-test/r/information_schema.result: New sql_mode added. mysql-test/r/sp.result: New sql_mode added. mysql-test/r/system_mysql_db.result: New sql_mode added. mysql-test/suite/funcs_1/r/is_columns_mysql.result: New sql_mode added. mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result: New sql_mode added. mysql-test/t/events_bugs.test: New sql_mode added. mysql-test/t/sp.test: New sql_mode added. scripts/mysql_system_tables.sql: New sql_mode added. scripts/mysql_system_tables_fix.sql: New sql_mode added. sql/CMakeLists.txt: New files added. sql/Makefile.am: New files added. sql/event_db_repository.cc: New sql_mode added. sql/field.cc: Create options support added. sql/field.h: Create options support added. sql/ha_partition.cc: Create options support added. sql/handler.cc: Create options support added. sql/handler.h: Create options support added. sql/log_event.h: New sql_mode added. sql/mysql_priv.h: New sql_mode added. sql/mysqld.cc: New sql_mode added. sql/share/errmsg.txt: New error messages added. sql/sp.cc: New sql_mode added. sql/sp_head.cc: Create options support added. sql/sql_class.cc: Create options support added. Debug added. sql/sql_class.h: Create options support added. sql/sql_insert.cc: my_safe_a* moved to mysqld_priv.h sql/sql_lex.h: Create options support added. sql/sql_parse.cc: Create options support added. sql/sql_show.cc: Create options support added. sql/sql_table.cc: Create options support added. sql/sql_view.cc: New sql_mode added. sql/sql_yacc.yy: Create options support added. sql/structs.h: Create options support added. sql/table.cc: Create options support added. sql/table.h: Create options support added. sql/unireg.cc: Create options support added. storage/example/ha_example.cc: Create options example. storage/example/ha_example.h: Create options example. storage/pbxt/src/discover_xt.cc: Create options support added. --- sql/mysql_priv.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sql/mysql_priv.h') diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index c9afe10a97d..c178f348206 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -520,7 +520,7 @@ protected: #define MODE_PIPES_AS_CONCAT 2 #define MODE_ANSI_QUOTES 4 #define MODE_IGNORE_SPACE 8 -#define MODE_NOT_USED 16 +#define MODE_IGNORE_BAD_TABLE_OPTIONS 16 #define MODE_ONLY_FULL_GROUP_BY 32 #define MODE_NO_UNSIGNED_SUBTRACTION 64 #define MODE_NO_DIR_IN_CREATE 128 @@ -1508,7 +1508,8 @@ bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum enum_field_types t char *change, List *interval_list, CHARSET_INFO *cs, uint uint_geom_type, - Virtual_column_info *vcol_info); + Virtual_column_info *vcol_info, + engine_option_value *create_options); Create_field * new_create_field(THD *thd, char *field_name, enum_field_types type, char *length, char *decimals, uint type_modifier, -- cgit v1.2.1 From 5dd5d70506611ea68c7103fcf97512e3114fffae Mon Sep 17 00:00:00 2001 From: Kristofer Pettersson Date: Mon, 3 May 2010 18:14:39 +0200 Subject: Bug#50373 --secure-file-priv="" Iterative patch improvement. Previously committed patch caused wrong result on Windows. The previous patch also broke secure_file_priv for symlinks since not all file paths which must be compared against this variable are normalized using the same norm. The server variable opt_secure_file_priv wasn't normalized properly and caused the operations LOAD DATA INFILE .. INTO TABLE .. and SELECT load_file(..) to do different interpretations of the --secure-file-priv option. The patch moves code to the server initialization routines so that the path always is normalized once and only once. It was also intended that setting the option to an empty string should be equal to lifting all previously set restrictions. This is also fixed by this patch. mysql-test/r/loaddata.result: * Removed test code which will currently break the much used --mem feature of mtr. mysql-test/t/loaddata.test: * Removed test code which will currently break the much used --mem feature of mtr. sql/item_strfunc.cc: * Replaced string comparing code on opt_secure_file_priv with an interface which guarantees that both file paths are normalized using the same norm on all platforms. sql/mysql_priv.h: * Added signature for is_secure_file_path() sql/mysqld.cc: * New function for checking if a path compatible with the secure path restriction. * Added initialization of the opt_secure_file_priv variable. sql/sql_class.cc: * Replaced string comparing code on opt_secure_file_priv with an interface which guarantees that both file paths are normalized using the same norm on all platforms. sql/sql_load.cc: * Replaced string comparing code on opt_secure_file_priv with an interface which guarantees that both file paths are normalized using the same norm on all platforms. --- sql/mysql_priv.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sql/mysql_priv.h') diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 56175d069c5..f410f6dbcc2 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1832,6 +1832,12 @@ void sql_perror(const char *message); bool fn_format_relative_to_data_home(char * to, const char *name, const char *dir, const char *extension); +/** + Test a file path to determine if the path is compatible with the secure file + path restriction. +*/ +bool is_secure_file_path(char *path); + #ifdef MYSQL_SERVER File open_binlog(IO_CACHE *log, const char *log_file_name, const char **errmsg); -- cgit v1.2.1 From fcfb218f71b7d371a10df020994fc0a618639327 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 9 May 2010 21:30:06 +0200 Subject: Cherry-pick fix for Bug#53371, security hole with bypassing grants using special path in db/table names. Bump MariaDB version for security fix release. --- sql/mysql_priv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/mysql_priv.h') diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 499d7d2fc24..0e032c857ce 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -2300,7 +2300,7 @@ void update_create_info_from_table(HA_CREATE_INFO *info, TABLE *form); int rename_file_ext(const char * from,const char * to,const char * ext); bool check_db_name(LEX_STRING *db); bool check_column_name(const char *name); -bool check_table_name(const char *name, uint length); +bool check_table_name(const char *name, uint length, bool check_for_path_chars); char *get_field(MEM_ROOT *mem, Field *field); bool get_field(MEM_ROOT *mem, Field *field, class String *res); int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr); -- cgit v1.2.1 From d120c5b562629dda782e3c9a66cfeaa48cbb01d1 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Tue, 25 May 2010 23:14:18 -0700 Subject: Changed the fixes for the following bugs: Bug #39022: completed Bug #39653: reverted as invalid Bug #45640: ameliorated, simplified, optimized Bug #48483: completed Bug #49324: improved Bug #51242/52336: reverted, applied a real fix. --- sql/mysql_priv.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sql/mysql_priv.h') diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 5ceaf00d1f2..6629374187a 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -640,7 +640,8 @@ enum enum_parsing_place IN_HAVING, SELECT_LIST, IN_WHERE, - IN_ON + IN_ON, + IN_GROUP_BY }; struct st_table; @@ -1196,7 +1197,7 @@ int setup_group(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, List &fields, List &all_fields, ORDER *order, bool *hidden_group_fields); bool fix_inner_refs(THD *thd, List &all_fields, SELECT_LEX *select, - Item **ref_pointer_array, ORDER *group_list= NULL); + Item **ref_pointer_array); bool handle_select(THD *thd, LEX *lex, select_result *result, ulong setup_tables_done_option); -- cgit v1.2.1