diff options
author | Nirbhay Choubey <nirbhay@mariadb.com> | 2015-02-18 17:15:57 -0500 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@mariadb.com> | 2015-02-18 17:15:57 -0500 |
commit | 3c9137deeb84dff9fa52734fb5fc3966c6746c00 (patch) | |
tree | 3ce5922ee55d6683c2348e1b1772d961754d1cd6 /sql | |
parent | d8ee54c63321e81ef99465bbadc8e4fb45fe7569 (diff) | |
parent | fdd6c111c254c5044cd9b6c2f7e4d0c74f427a79 (diff) | |
download | mariadb-git-3c9137deeb84dff9fa52734fb5fc3966c6746c00.tar.gz |
Merge branch '5.5' into 5.5-galera
Merge banch 5.5 till revision :
fdd6c11 - MDEV-7419 Function cli_safe_read not exported
Conflicts:
.bzrignore
debian/dist/Debian/mariadb-galera-server-5.5.files.in
debian/dist/Ubuntu/mariadb-galera-server-5.5.files.in
storage/tokudb/CMakeLists.txt
support-files/build-tags
Diffstat (limited to 'sql')
-rw-r--r-- | sql/CMakeLists.txt | 11 | ||||
-rw-r--r-- | sql/handler.cc | 4 | ||||
-rw-r--r-- | sql/handler.h | 9 | ||||
-rw-r--r-- | sql/item_func.cc | 13 | ||||
-rw-r--r-- | sql/item_geofunc.cc | 8 | ||||
-rw-r--r-- | sql/sql_base.cc | 3 | ||||
-rw-r--r-- | sql/sql_db.cc | 6 | ||||
-rw-r--r-- | sql/sql_delete.cc | 5 | ||||
-rw-r--r-- | sql/sql_derived.cc | 3 | ||||
-rw-r--r-- | sql/sql_plugin.cc | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 4 | ||||
-rw-r--r-- | sql/sql_table.cc | 14 | ||||
-rw-r--r-- | sql/sql_view.cc | 6 | ||||
-rw-r--r-- | sql/sys_vars.cc | 2 | ||||
-rw-r--r-- | sql/table.cc | 34 | ||||
-rw-r--r-- | sql/table.h | 19 | ||||
-rw-r--r-- | sql/udf_example.c | 5 |
17 files changed, 112 insertions, 36 deletions
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 39301ef5fc9..7fcdf601d81 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -1,4 +1,5 @@ -# Copyright (c) 2006, 2013, Oracle and/or its affiliates. +# Copyright (c) 2006, 2014, Oracle and/or its affiliates. +# Copyright (c) 2010, 2015, MariaDB # # 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 @@ -275,14 +276,15 @@ IF(WIN32 OR HAVE_DLOPEN AND NOT DISABLE_SHARED) ENDIF() FOREACH(tool glibtoolize libtoolize aclocal autoconf autoheader automake gtar - tar bzr) + tar git) STRING(TOUPPER ${tool} TOOL) FIND_PROGRAM(${TOOL}_EXECUTABLE ${tool} DOC "path to the executable") MARK_AS_ADVANCED(${TOOL}_EXECUTABLE) ENDFOREACH() CONFIGURE_FILE( - ${CMAKE_SOURCE_DIR}/cmake/make_dist.cmake.in ${CMAKE_BINARY_DIR}/make_dist.cmake @ONLY) + ${CMAKE_SOURCE_DIR}/cmake/make_dist.cmake.in + ${CMAKE_BINARY_DIR}/make_dist.cmake @ONLY) ADD_CUSTOM_TARGET(dist COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/make_dist.cmake @@ -292,8 +294,7 @@ ADD_CUSTOM_TARGET(dist ADD_CUSTOM_TARGET(distclean COMMAND ${CMAKE_COMMAND} -E echo WARNING: distclean target is not functional - COMMAND ${CMAKE_COMMAND} -E echo Use 'bzr clean-tree' with --unknown and/or - --ignored parameter instead + COMMAND ${CMAKE_COMMAND} -E echo Use 'git clean -fdx' instead VERBATIM ) diff --git a/sql/handler.cc b/sql/handler.cc index 53c875da6a2..2337eaced55 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -89,9 +89,7 @@ static const LEX_STRING sys_table_aliases[]= }; const char *ha_row_type[] = { - "", "FIXED", "DYNAMIC", "COMPRESSED", "REDUNDANT", "COMPACT", - "PAGE", - "?","?","?" + "", "FIXED", "DYNAMIC", "COMPRESSED", "REDUNDANT", "COMPACT", "PAGE" }; const char *tx_isolation_names[] = diff --git a/sql/handler.h b/sql/handler.h index f4550cb1b22..692d69cd7c5 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -370,9 +370,10 @@ enum legacy_db_type enum row_type { ROW_TYPE_NOT_USED=-1, ROW_TYPE_DEFAULT, ROW_TYPE_FIXED, ROW_TYPE_DYNAMIC, ROW_TYPE_COMPRESSED, - ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT, - /** Unused. Reserved for future versions. */ - ROW_TYPE_PAGE }; + ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT, ROW_TYPE_PAGE }; + +/* not part of the enum, so that it shouldn't be in switch(row_type) */ +#define ROW_TYPE_MAX ((uint)ROW_TYPE_PAGE + 1) enum enum_binlog_func { BFN_RESET_LOGS= 1, @@ -1254,7 +1255,7 @@ class partition_info; struct st_partition_iter; #define NOT_A_PARTITION_ID ((uint32)-1) -enum ha_choice { HA_CHOICE_UNDEF, HA_CHOICE_NO, HA_CHOICE_YES }; +enum ha_choice { HA_CHOICE_UNDEF, HA_CHOICE_NO, HA_CHOICE_YES, HA_CHOICE_MAX }; typedef struct st_ha_create_information { diff --git a/sql/item_func.cc b/sql/item_func.cc index e1607529dea..34569cb938f 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2014, Oracle and/or its affiliates. - Copyright (c) 2009, 2014, Monty Program Ab. + Copyright (c) 2009, 2015, MariaDB 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 @@ -3671,8 +3671,12 @@ bool udf_handler::get_arguments() { f_args.args[i]= (char*) res->ptr(); f_args.lengths[i]= res->length(); - break; } + else + { + f_args.lengths[i]= 0; + } + break; } case INT_RESULT: *((longlong*) to) = args[i]->val_int(); @@ -4494,6 +4498,11 @@ longlong Item_func_sleep::val_int() mysql_cond_destroy(&cond); + DBUG_EXECUTE_IF("sleep_inject_query_done_debug_sync", { + debug_sync_set_action + (thd, STRING_WITH_LEN("dispatch_command_end SIGNAL query_done")); + };); + return test(!error); // Return 1 killed } diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index a38e9d416a7..5e1c0add54b 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -1286,6 +1286,13 @@ String *Item_func_buffer::val_str(String *str_value) if (dist > 0.0) mbr.buffer(dist); + else + { + /* This happens when dist is too far negative. */ + if (mbr.xmax + dist < mbr.xmin || mbr.ymax + dist < mbr.ymin) + goto return_empty_result; + } + collector.set_extent(mbr.xmin, mbr.xmax, mbr.ymin, mbr.ymax); /* If the distance given is 0, the Buffer function is in fact NOOP, @@ -1313,6 +1320,7 @@ String *Item_func_buffer::val_str(String *str_value) goto mem_error; +return_empty_result: str_value->set_charset(&my_charset_bin); if (str_value->reserve(SRID_SIZE, 512)) goto mem_error; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index e155287906f..31416075519 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2031,6 +2031,9 @@ unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list, bool check_alias) { TABLE_LIST *dup; + + table= table->find_table_for_update(); + if (table->table && table->table->file->ht->db_type == DB_TYPE_MRG_MYISAM) { TABLE_LIST *child; diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 0464128bd97..f72a8918f61 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -1,6 +1,6 @@ /* - Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2009, 2013, Monty Program Ab. + Copyright (c) 2000, 2014, Oracle and/or its affiliates. + Copyright (c) 2009, 2015, MariaDB 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 @@ -917,7 +917,7 @@ update_binlog: if (!(query= (char*) thd->alloc(MAX_DROP_TABLE_Q_LEN))) goto exit; /* not much else we can do */ - query_pos= query_data_start= strmov(query,"DROP TABLE "); + query_pos= query_data_start= strmov(query,"DROP TABLE IF EXISTS "); query_end= query + MAX_DROP_TABLE_Q_LEN; db_len= strlen(db); diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 445364ca57b..8fed26555db 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -661,9 +661,10 @@ multi_delete::initialize_tables(JOIN *join) delete_while_scanning= 1; for (walk= delete_tables; walk; walk= walk->next_local) { - tables_to_delete_from|= walk->table->map; + TABLE_LIST *tbl= walk->correspondent_table->find_table_for_update(); + tables_to_delete_from|= tbl->table->map; if (delete_while_scanning && - unique_table(thd, walk, join->tables_list, false)) + unique_table(thd, tbl, join->tables_list, false)) { /* If the table we are going to delete from appears diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 004cccb41a9..56748fa110d 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -507,6 +507,9 @@ bool mysql_derived_merge_for_insert(THD *thd, LEX *lex, TABLE_LIST *derived) DBUG_RETURN(FALSE); if (derived->is_materialized_derived()) DBUG_RETURN(mysql_derived_prepare(thd, lex, derived)); + if ((thd->lex->sql_command == SQLCOM_UPDATE_MULTI || + thd->lex->sql_command == SQLCOM_DELETE_MULTI)) + DBUG_RETURN(FALSE); if (!derived->is_multitable()) { if (!derived->single_table_updatable()) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index dd0f0a7d9e3..9683199a2f3 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -3922,7 +3922,7 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, we copy string values to a plugin's memroot. */ if (mysqld_server_started && - ((o->flags & (PLUGIN_VAR_STR | PLUGIN_VAR_NOCMDOPT | + ((o->flags & (PLUGIN_VAR_TYPEMASK | PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_MEMALLOC)) == PLUGIN_VAR_STR)) { sysvar_str_t* str= (sysvar_str_t *)o; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index bdb2d1c3346..387fdb35ace 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1,5 +1,5 @@ -/* Copyright (c) 2000, 2013 Oracle and/or its affiliates. - Copyright (c) 2009, 2013 Monty Program Ab. +/* Copyright (c) 2000, 2014 Oracle and/or its affiliates. + Copyright (c) 2009, 2015 MariaDB 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 diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 5ab78197494..5e1fd283337 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -7711,12 +7711,12 @@ err: /* - Recreates tables by calling mysql_alter_table(). + Recreates one table by calling mysql_alter_table(). SYNOPSIS mysql_recreate_table() thd Thread handler - tables Tables to recreate + table_list Table to recreate RETURN Like mysql_alter_table(). @@ -7725,9 +7725,9 @@ bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list) { HA_CREATE_INFO create_info; Alter_info alter_info; + TABLE_LIST *next_table= table_list->next_global; DBUG_ENTER("mysql_recreate_table"); - DBUG_ASSERT(!table_list->next_global); /* table_list->table has been closed and freed. Do not reference uninitialized data. open_tables() could fail. @@ -7739,15 +7739,19 @@ bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list) table_list->lock_type= TL_READ_NO_INSERT; /* Same applies to MDL request. */ table_list->mdl_request.set_type(MDL_SHARED_NO_WRITE); + /* hide following tables from open_tables() */ + table_list->next_global= NULL; bzero((char*) &create_info, sizeof(create_info)); create_info.row_type=ROW_TYPE_NOT_USED; create_info.default_table_charset=default_charset_info; /* Force alter table to recreate table */ alter_info.flags= (ALTER_CHANGE_COLUMN | ALTER_RECREATE); - DBUG_RETURN(mysql_alter_table(thd, NullS, NullS, &create_info, + bool res= mysql_alter_table(thd, NullS, NullS, &create_info, table_list, &alter_info, 0, - (ORDER *) 0, 0, 0)); + (ORDER *) 0, 0, 0); + table_list->next_global= next_table; + DBUG_RETURN(res); } diff --git a/sql/sql_view.cc b/sql/sql_view.cc index b711f05be02..09784f7257a 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -730,7 +730,7 @@ err: /* number of required parameters for making view */ -static const int required_view_parameters= 14; +static const int required_view_parameters= 15; /* table of VIEW .frm field descriptors @@ -781,6 +781,9 @@ static File_option view_parameters[]= {{(char*) STRING_WITH_LEN("view_body_utf8")}, my_offsetof(TABLE_LIST, view_body_utf8), FILE_OPTIONS_ESTRING}, + {{ C_STRING_WITH_LEN("mariadb-version")}, + my_offsetof(TABLE_LIST, mariadb_version), + FILE_OPTIONS_ULONGLONG}, {{NullS, 0}, 0, FILE_OPTIONS_STRING} }; @@ -877,6 +880,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, } view->file_version= 1; + view->mariadb_version= MYSQL_VERSION_ID; view->calc_md5(md5); if (!(view->md5.str= (char*) thd->memdup(md5, 32))) { diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 88760e2d602..f5eb6708137 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -3973,7 +3973,7 @@ static Sys_var_ulong Sys_sp_cache_size( "The soft upper limit for number of cached stored routines for " "one connection.", GLOBAL_VAR(stored_program_cache_size), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(256, 512 * 1024), DEFAULT(256), BLOCK_SIZE(1)); + VALID_RANGE(0, 512 * 1024), DEFAULT(256), BLOCK_SIZE(1)); export const char *plugin_maturity_names[]= { "unknown", "experimental", "alpha", "beta", "gamma", "stable", 0 }; diff --git a/sql/table.cc b/sql/table.cc index 0f34364065a..caebf3e6bbe 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1,5 +1,5 @@ -/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. - Copyright (c) 2008, 2014, SkySQL Ab. +/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. + Copyright (c) 2008, 2015, MariaDB 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 @@ -893,6 +893,23 @@ static bool create_key_infos(uchar *strpos, uint keys, KEY *keyinfo, return 0; } +/** ensures that the enum value (read from frm) is within limits + + if not - issues a warning and resets the value to 0 + (that is, 0 is assumed to be a default value) +*/ +static uint enum_value_with_check(THD *thd, TABLE_SHARE *share, + const char *name, uint value, uint limit) +{ + if (value < limit) + return value; + + sql_print_warning("%s.frm: invalid value %d for the field %s", + share->normalized_path.str, value, name); + return 0; +} + + /* Read data from a binary .frm file from MySQL 3.23 - 5.0 into TABLE_SHARE */ @@ -986,9 +1003,12 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, if (!head[32]) // New frm file in 3.23 { share->avg_row_length= uint4korr(head+34); - share->transactional= (ha_choice) (head[39] & 3); - share->page_checksum= (ha_choice) ((head[39] >> 2) & 3); - share->row_type= (row_type) head[40]; + share->transactional= (ha_choice) + enum_value_with_check(thd, share, "transactional", (head[39] & 3), HA_CHOICE_MAX); + share->page_checksum= (ha_choice) + enum_value_with_check(thd, share, "page_checksum", (head[39] >> 2) & 3, HA_CHOICE_MAX); + share->row_type= (row_type) + enum_value_with_check(thd, share, "row_format", head[40], ROW_TYPE_MAX); share->table_charset= get_charset((((uint) head[41]) << 8) + (uint) head[38],MYF(0)); share->null_field_first= 1; @@ -2706,7 +2726,9 @@ partititon_err: outparam->no_replicate= outparam->file && test(outparam->file->ha_table_flags() & HA_HAS_OWN_BINLOGGING); - thd->status_var.opened_tables++; + /* Increment the opened_tables counter, only when open flags set. */ + if (db_stat) + thd->status_var.opened_tables++; thd->lex->context_analysis_only= save_context_analysis_only; DBUG_RETURN (0); diff --git a/sql/table.h b/sql/table.h index ac15e389f75..7a1e380f14c 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1807,6 +1807,7 @@ struct TABLE_LIST LEX_STRING timestamp; /* GMT time stamp of last operation */ st_lex_user definer; /* definer of view */ ulonglong file_version; /* version of file's field set */ + ulonglong mariadb_version; /* version of server on creation */ ulonglong updatable_view; /* VIEW can be updated */ /** @brief The declared algorithm, if this is a view. @@ -1983,6 +1984,24 @@ struct TABLE_LIST TABLE_LIST *find_underlying_table(TABLE *table); TABLE_LIST *first_leaf_for_name_resolution(); TABLE_LIST *last_leaf_for_name_resolution(); + /** + @brief + Find the bottom in the chain of embedded table VIEWs. + + @detail + This is used for single-table UPDATE/DELETE when they are modifying a + single-table VIEW. + */ + TABLE_LIST *find_table_for_update() + { + TABLE_LIST *tbl= this; + while(!tbl->is_multitable() && tbl->single_table_updatable() && + tbl->merge_underlying_list) + { + tbl= tbl->merge_underlying_list; + } + return tbl; + } TABLE *get_real_join_table(); bool is_leaf_for_name_resolution(); inline TABLE_LIST *top_table() diff --git a/sql/udf_example.c b/sql/udf_example.c index 36a5eafb704..a48801d1c4a 100644 --- a/sql/udf_example.c +++ b/sql/udf_example.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2010, Oracle and/or its affiliates. + Copyright (c) 2000, 2014, Oracle and/or its affiliates. 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 @@ -296,9 +296,12 @@ char *metaphon(UDF_INIT *initid __attribute__((unused)), if (!word) /* Null argument */ { + /* The length is expected to be zero when the argument is NULL. */ + assert(args->lengths[0] == 0); *is_null=1; return 0; } + w_end=word+args->lengths[0]; org_result=result; |