diff options
author | Sergei Golubchik <sergii@pisem.net> | 2014-11-19 17:23:39 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2014-11-19 17:23:39 +0100 |
commit | 3495801e2e94df5a10cae6e056f65defa038a6b6 (patch) | |
tree | de524b4bf45dbc19a95262843f2b72d0f5adb7bc /sql | |
parent | df7b27f1fe308fd4011fa020bebd7c69bcd43383 (diff) | |
parent | 496fda66fdc34b447ef4dec26d1250b034a321e3 (diff) | |
download | mariadb-git-3495801e2e94df5a10cae6e056f65defa038a6b6.tar.gz |
5.5 merge
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.h | 1 | ||||
-rw-r--r-- | sql/item_func.h | 4 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 14 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 15 | ||||
-rw-r--r-- | sql/item_timefunc.h | 9 | ||||
-rw-r--r-- | sql/multi_range_read.cc | 15 | ||||
-rw-r--r-- | sql/spatial.cc | 8 | ||||
-rw-r--r-- | sql/sql_lex.h | 9 | ||||
-rw-r--r-- | sql/sql_load.cc | 24 | ||||
-rw-r--r-- | sql/sql_string.h | 4 | ||||
-rw-r--r-- | sql/sql_union.cc | 24 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 30 |
12 files changed, 100 insertions, 57 deletions
diff --git a/sql/item.h b/sql/item.h index 36bd68e1b0b..f337db92ef3 100644 --- a/sql/item.h +++ b/sql/item.h @@ -4359,6 +4359,7 @@ public: return arg->walk(processor, walk_subquery, args) || (this->*processor)(args); } + bool check_partition_func_processor(uchar *int_arg) {return TRUE;} bool check_vcol_func_processor(uchar *arg) { return trace_unsupported_by_check_vcol_func_processor("values"); diff --git a/sql/item_func.h b/sql/item_func.h index 18265f672dd..e40f2d771c6 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1740,6 +1740,7 @@ public: bool register_field_in_bitmap(uchar *arg); bool set_entry(THD *thd, bool create_if_not_exists); void cleanup(); + bool check_vcol_func_processor(uchar *int_arg) {return TRUE;} }; @@ -1779,6 +1780,7 @@ public: { return this; } + bool check_vcol_func_processor(uchar *int_arg) { return TRUE;} }; @@ -1861,6 +1863,7 @@ public: bool eq(const Item *item, bool binary_cmp) const; void cleanup(); + bool check_vcol_func_processor(uchar *int_arg) { return TRUE;} }; @@ -2159,7 +2162,6 @@ public: longlong val_int(); void fix_length_and_dec() { max_length= 21; unsigned_flag=1; } - bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_vcol_func_processor(uchar *int_arg) { return trace_unsupported_by_check_vcol_func_processor(func_name()); diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 339d053eade..402dbef00b7 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -3274,6 +3274,18 @@ String *Item_func_lpad::val_str(String *str) res->set_charset(&my_charset_bin); pad->set_charset(&my_charset_bin); } +#if MARIADB_VERSION_ID < 1000000 + /* + Well-formedness is handled on a higher level in 10.0, + no needs to check it here again. + */ else + { + // This will chop off any trailing illegal characters from pad. + String *well_formed_pad= args[2]->check_well_formed_result(pad, false); + if (!well_formed_pad) + goto err; + } +#endif res_char_length= res->numchars(); @@ -4195,7 +4207,7 @@ String *Item_func_uncompress::val_str(String *str) goto err; if ((err= uncompress((Byte*)buffer.ptr(), &new_size, - ((const Bytef*)res->ptr())+4,res->length())) == Z_OK) + ((const Bytef*)res->ptr())+4,res->length()-4)) == Z_OK) { buffer.length((uint32) new_size); return &buffer; diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index c872ca631e4..389d9d5380c 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -451,16 +451,14 @@ err: Create a formated date/time value in a string. */ -bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, - timestamp_type type, String *str) +static bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, + timestamp_type type, MY_LOCALE *locale, String *str) { char intbuff[15]; uint hours_i; uint weekday; ulong length; const char *ptr, *end; - THD *thd= current_thd; - MY_LOCALE *locale= thd->variables.lc_time_names; str->length(0); @@ -1802,6 +1800,8 @@ overflow: void Item_func_date_format::fix_length_and_dec() { THD* thd= current_thd; + locale= thd->variables.lc_time_names; + /* Must use this_item() in case it's a local SP variable (for ->max_length and ->str_value) @@ -1965,7 +1965,7 @@ String *Item_func_date_format::val_str(String *str) if (!make_date_time(&date_time_format, &l_time, is_time_format ? MYSQL_TIMESTAMP_TIME : MYSQL_TIMESTAMP_DATE, - str)) + locale, str)) return str; null_date: @@ -1976,8 +1976,9 @@ null_date: void Item_func_from_unixtime::fix_length_and_dec() { - thd= current_thd; + THD *thd= current_thd; thd->time_zone_used= 1; + tz= thd->variables.time_zone; decimals= args[0]->decimals; Item_temporal_func::fix_length_and_dec(); } @@ -1998,7 +1999,7 @@ bool Item_func_from_unixtime::get_date(MYSQL_TIME *ltime, if (args[0]->null_value || sign || sec > TIMESTAMP_MAX_VALUE) return (null_value= 1); - thd->variables.time_zone->gmt_sec_to_TIME(ltime, (my_time_t)sec); + tz->gmt_sec_to_TIME(ltime, (my_time_t)sec); ltime->second_part= sec_part; diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index cb8b59501a4..839a5a4845d 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -736,6 +736,7 @@ public: class Item_func_date_format :public Item_str_func { + MY_LOCALE *locale; int fixed_length; const bool is_time_format; String value; @@ -753,7 +754,7 @@ public: class Item_func_from_unixtime :public Item_temporal_func { - THD *thd; + Time_zone *tz; public: Item_func_from_unixtime(Item *a) :Item_temporal_func(a) {} const char *func_name() const { return "from_unixtime"; } @@ -1088,10 +1089,4 @@ public: bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); }; - -/* Function prototypes */ - -bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, - timestamp_type type, String *str); - #endif /* ITEM_TIMEFUNC_INCLUDED */ diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc index 2d22adce8d9..3f55ff3684d 100644 --- a/sql/multi_range_read.cc +++ b/sql/multi_range_read.cc @@ -684,8 +684,19 @@ int Mrr_ordered_rndpos_reader::refill_from_index_reader() rowid_buffer->write_ptr2= (uchar*)&range_info; rowid_buffer->write(); } - - index_reader->interrupt_read(); + + /* + When index_reader_needs_refill=TRUE, this means we've got all of index + tuples for lookups keys that index_reader had. We are not in the middle + of an index read, so there is no need to call interrupt_read. + + Actually, we must not call interrupt_read(), because it could be that we + haven't read a single row (because all index lookups returned + HA_ERR_KEY_NOT_FOUND). In this case, interrupt_read() will cause [harmless] + valgrind warnings when trying to save garbage from table->record[0]. + */ + if (!index_reader_needs_refill) + index_reader->interrupt_read(); /* Sort the buffer contents by rowid */ rowid_buffer->sort((qsort2_cmp)rowid_cmp_reverse, (void*)file); diff --git a/sql/spatial.cc b/sql/spatial.cc index 1d9ee1aa0ae..bfe302f332e 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -1237,11 +1237,15 @@ int Gis_polygon::store_shapes(Gcalc_shape_transporter *trn) const trn->start_ring(); get_point(&first_x, &first_y, data); data+= POINT_DATA_SIZE; - n_points--; + prev_x= first_x; prev_y= first_y; if (trn->add_point(first_x, first_y)) return 1; + + if (--n_points == 0) + goto single_point_ring; + while (--n_points) { double x, y; @@ -1266,6 +1270,8 @@ int Gis_polygon::store_shapes(Gcalc_shape_transporter *trn) const return 1; } data+= POINT_DATA_SIZE; + +single_point_ring: trn->complete_ring(); } diff --git a/sql/sql_lex.h b/sql/sql_lex.h index e15901a9c54..88491743d39 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -104,6 +104,15 @@ struct sys_var_with_base LEX_STRING base_name; }; +struct LEX_TYPE +{ + enum enum_field_types type; + char *length, *dec; + CHARSET_INFO *charset; + void set(int t, char *l, char *d, CHARSET_INFO *cs) + { type= (enum_field_types)t; length= l; dec= d; charset= cs; } +}; + #ifdef MYSQL_SERVER /* The following hack is needed because mysql_yacc.cc does not define diff --git a/sql/sql_load.cc b/sql/sql_load.cc index c0d9b58569e..6ecdddc3008 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -148,14 +148,8 @@ static int read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, bool ignore_check_option_errors); #ifndef EMBEDDED_LIBRARY -static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex, - const char* db_arg, /* table's database */ - const char* table_name_arg, - bool is_concurrent, - enum enum_duplicates duplicates, - bool ignore, - bool transactional_table, - int errocode); +static bool write_execute_load_query_log_event(THD *, sql_exchange*, const + char*, const char*, bool, enum enum_duplicates, bool, bool, int); #endif /* EMBEDDED_LIBRARY */ /* @@ -284,9 +278,15 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, if (!fields_vars.elements) { - Field **field; - for (field=table->field; *field ; field++) - fields_vars.push_back(new Item_field(*field)); + Field_iterator_table_ref field_iterator; + field_iterator.set(table_list); + for (; !field_iterator.end_of_fields(); field_iterator.next()) + { + Item *item; + if (!(item= field_iterator.create_item(thd))) + DBUG_RETURN(TRUE); + fields_vars.push_back(item->real_item()); + } bitmap_set_all(table->write_set); /* Let us also prepare SET clause, altough it is probably empty @@ -724,7 +724,7 @@ static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex, { if (n++) query_str.append(", "); - if (item->type() == Item::FIELD_ITEM) + if (item->real_type() == Item::FIELD_ITEM) append_identifier(thd, &query_str, item->name, strlen(item->name)); else { diff --git a/sql/sql_string.h b/sql/sql_string.h index 8c7e69edf4b..c287f051d98 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -253,7 +253,9 @@ public: */ inline void chop() { - Ptr[str_length--]= '\0'; + str_length--; + Ptr[str_length]= '\0'; + DBUG_ASSERT(strlen(Ptr) == str_length); } inline void free() diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 2126db4bf19..77a3b1eec8f 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -315,18 +315,6 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, can_skip_order_by= is_union_select && !(sl->braces && sl->explicit_limit); - /* - Remove all references from the select_lex_units to the subqueries that - are inside the ORDER BY clause. - */ - if (can_skip_order_by) - { - for (ORDER *ord= (ORDER *)sl->order_list.first; ord; ord= ord->next) - { - (*ord->item)->walk(&Item::eliminate_subselect_processor, FALSE, NULL); - } - } - saved_error= join->prepare(&sl->ref_pointer_array, sl->table_list.first, sl->with_wild, @@ -350,6 +338,18 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, if (saved_error || (saved_error= thd_arg->is_fatal_error)) goto err; /* + Remove all references from the select_lex_units to the subqueries that + are inside the ORDER BY clause. + */ + if (can_skip_order_by) + { + for (ORDER *ord= (ORDER *)sl->order_list.first; ord; ord= ord->next) + { + (*ord->item)->walk(&Item::eliminate_subselect_processor, FALSE, NULL); + } + } + + /* Use items list of underlaid select for derived tables to preserve information about fields lengths and exact types */ diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 637464ff450..74426f88a69 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -902,6 +902,7 @@ static bool sp_create_assignment_instr(THD *thd, bool no_lookahead) LEX_STRING lex_str; LEX_STRING *lex_str_ptr; LEX_SYMBOL symbol; + LEX_TYPE lex_type; Table_ident *table; char *simple_string; Item *item; @@ -1669,13 +1670,14 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %type <string> text_string hex_or_bin_String opt_gconcat_separator +%type <lex_type> field_def + %type <num> type type_with_opt_collate int_type real_type order_dir lock_option udf_type opt_if_exists opt_local opt_table_options table_options table_option opt_if_not_exists create_or_replace opt_no_write_to_binlog opt_temporary all_or_any opt_distinct opt_ignore_leaves fulltext_options spatial_type union_option - field_def union_opt select_derived_init transaction_access_mode_types opt_natural_language_mode opt_query_expansion opt_ev_status opt_ev_on_completion ev_on_completion opt_ev_comment @@ -6016,11 +6018,11 @@ field_spec: field_def { LEX *lex=Lex; - if (add_field_to_list(lex->thd, &$1, (enum enum_field_types) $3, - lex->length,lex->dec,lex->type, + if (add_field_to_list(lex->thd, &$1, $3.type, + $3.length, $3.dec, lex->type, lex->default_value, lex->on_update_value, &lex->comment, - lex->change,&lex->interval_list,lex->charset, + lex->change, &lex->interval_list, $3.charset, lex->uint_geom_type, lex->vcol_info, lex->option_list)) MYSQL_YYABORT; @@ -6028,13 +6030,15 @@ field_spec: ; field_def: - type opt_attribute {} - | type opt_generated_always AS '(' virtual_column_func ')' - vcol_opt_specifier - vcol_opt_attribute + type opt_attribute + { $$.set($1, Lex->length, Lex->dec, Lex->charset); } + | type opt_generated_always AS + { $<lex_type>$.set($1, Lex->length, Lex->dec, Lex->charset); } + '(' virtual_column_func ')' vcol_opt_specifier vcol_opt_attribute { - $$= (enum enum_field_types)MYSQL_TYPE_VIRTUAL; - Lex->vcol_info->set_field_type((enum enum_field_types) $1); + $$= $<lex_type>4; + Lex->vcol_info->set_field_type($$.type); + $$.type= (enum enum_field_types)MYSQL_TYPE_VIRTUAL; } ; @@ -7529,11 +7533,11 @@ alter_list_item: { LEX *lex=Lex; if (add_field_to_list(lex->thd,&$4, - (enum enum_field_types) $6, - lex->length,lex->dec,lex->type, + $6.type, + $6.length, $6.dec, lex->type, lex->default_value, lex->on_update_value, &lex->comment, - $4.str, &lex->interval_list, lex->charset, + $4.str, &lex->interval_list, $6.charset, lex->uint_geom_type, lex->vcol_info, lex->option_list)) MYSQL_YYABORT; |