summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-09-03 15:53:38 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-09-03 15:53:38 +0300
commitc9cf6b13f6f9aaae57efb514e0b0f51e7ea09798 (patch)
tree810d8e37f7b3dded1323a79ce43f14603679c0a7 /sql
parentb795adcff72a84421576748646e2446e3ef24202 (diff)
parent33ae1616e01b564d03c507769564d37c582783cf (diff)
downloadmariadb-git-c9cf6b13f6f9aaae57efb514e0b0f51e7ea09798.tar.gz
Merge 10.3 into 10.4
Diffstat (limited to 'sql')
-rw-r--r--sql/debug_sync.cc4
-rw-r--r--sql/log_event.cc37
-rw-r--r--sql/log_event.h2
-rw-r--r--sql/log_event_old.cc6
-rw-r--r--sql/mysqld.cc3
-rw-r--r--sql/net_serv.cc3
-rw-r--r--sql/opt_range.cc16
-rw-r--r--sql/rpl_filter.cc52
-rw-r--r--sql/sql_insert.cc6
-rw-r--r--sql/sql_select.cc3
-rw-r--r--sql/sql_test.cc6
-rw-r--r--sql/wsrep_mysqld.cc9
12 files changed, 90 insertions, 57 deletions
diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc
index 39ceaadc671..c037af40e33 100644
--- a/sql/debug_sync.cc
+++ b/sql/debug_sync.cc
@@ -1,4 +1,5 @@
/* Copyright (c) 2009, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2013, 2020, 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
@@ -319,7 +320,8 @@ static char *debug_sync_bmove_len(char *to, char *to_end,
DBUG_ASSERT(to_end);
DBUG_ASSERT(!length || from);
set_if_smaller(length, (size_t) (to_end - to));
- memcpy(to, from, length);
+ if (length)
+ memcpy(to, from, length);
return (to + length);
}
diff --git a/sql/log_event.cc b/sql/log_event.cc
index deca177fa43..76f97da9496 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -3878,7 +3878,7 @@ bool Log_event::print_base64(IO_CACHE* file,
ev->need_flashback_review= need_flashback_review;
if (print_event_info->verbose)
{
- if (ev->print_verbose(file, print_event_info))
+ if (ev->print_verbose(&print_event_info->tail_cache, print_event_info))
goto err;
}
else
@@ -3902,22 +3902,9 @@ bool Log_event::print_base64(IO_CACHE* file,
}
#else
if (print_event_info->verbose)
- {
- /*
- Verbose event printout can't start before encoded data
- got enquoted. This is done at this point though multi-row
- statement remain vulnerable.
- TODO: fix MDEV-10362 to remove this workaround.
- */
- if (print_event_info->base64_output_mode !=
- BASE64_OUTPUT_DECODE_ROWS)
- my_b_printf(file, "'%s\n", print_event_info->delimiter);
- error= ev->print_verbose(file, print_event_info);
- }
+ error= ev->print_verbose(&print_event_info->tail_cache, print_event_info);
else
- {
ev->count_row_events(print_event_info);
- }
#endif
delete ev;
if (unlikely(error))
@@ -12033,7 +12020,7 @@ bool copy_cache_to_file_wrapped(IO_CACHE *body,
FILE *file,
bool do_wrap,
const char *delimiter,
- bool is_verbose)
+ bool is_verbose /*TODO: remove */)
{
const my_off_t cache_size= my_b_tell(body);
@@ -12066,8 +12053,7 @@ bool copy_cache_to_file_wrapped(IO_CACHE *body,
my_fprintf(file, fmt_frag, 1);
if (my_b_copy_to_file(body, file, SIZE_T_MAX))
goto err;
- if (!is_verbose)
- my_fprintf(file, fmt_delim, delimiter);
+ my_fprintf(file, fmt_delim, delimiter);
my_fprintf(file, fmt_binlog2, delimiter);
}
@@ -12076,8 +12062,7 @@ bool copy_cache_to_file_wrapped(IO_CACHE *body,
my_fprintf(file, str_binlog);
if (my_b_copy_to_file(body, file, SIZE_T_MAX))
goto err;
- if (!is_verbose)
- my_fprintf(file, fmt_delim, delimiter);
+ my_fprintf(file, fmt_delim, delimiter);
}
reinit_io_cache(body, WRITE_CACHE, 0, FALSE, TRUE);
@@ -12163,7 +12148,6 @@ bool copy_cache_to_string_wrapped(IO_CACHE *cache,
goto err;
str += (add_to_len= uint32(cache->end_of_file - (cache_size/2 + 1)));
to->length += add_to_len;
- if (!is_verbose)
{
str += (add_to_len= sprintf(str , fmt_delim, delimiter));
to->length += add_to_len;
@@ -12179,7 +12163,6 @@ bool copy_cache_to_string_wrapped(IO_CACHE *cache,
goto err;
str += cache->end_of_file;
to->length += (size_t)cache->end_of_file;
- if (!is_verbose)
to->length += sprintf(str , fmt_delim, delimiter);
}
@@ -12227,6 +12210,7 @@ bool Rows_log_event::print_helper(FILE *file,
{
IO_CACHE *const head= &print_event_info->head_cache;
IO_CACHE *const body= &print_event_info->body_cache;
+ IO_CACHE *const tail= &print_event_info->tail_cache;
#ifdef WHEN_FLASHBACK_REVIEW_READY
IO_CACHE *const sql= &print_event_info->review_sql_cache;
#endif
@@ -12257,7 +12241,8 @@ bool Rows_log_event::print_helper(FILE *file,
if (copy_event_cache_to_file_and_reinit(head, file) ||
copy_cache_to_file_wrapped(body, file, do_print_encoded,
print_event_info->delimiter,
- print_event_info->verbose))
+ print_event_info->verbose) ||
+ copy_event_cache_to_file_and_reinit(tail, file))
goto err;
}
else
@@ -12275,6 +12260,11 @@ bool Rows_log_event::print_helper(FILE *file,
return 1;
output_buf.append(tmp_str.str, tmp_str.length);
my_free(tmp_str.str);
+ if (copy_event_cache_to_string_and_reinit(tail, &tmp_str))
+ return 1;
+ output_buf.append(tmp_str.str, tmp_str.length);
+ my_free(tmp_str.str);
+
#ifdef WHEN_FLASHBACK_REVIEW_READY
if (copy_event_cache_to_string_and_reinit(sql, &tmp_str))
return 1;
@@ -15097,6 +15087,7 @@ st_print_event_info::st_print_event_info()
base64_output_mode=BASE64_OUTPUT_UNSPEC;
open_cached_file(&head_cache, NULL, NULL, 0, flags);
open_cached_file(&body_cache, NULL, NULL, 0, flags);
+ open_cached_file(&tail_cache, NULL, NULL, 0, flags);
#ifdef WHEN_FLASHBACK_REVIEW_READY
open_cached_file(&review_sql_cache, NULL, NULL, 0, flags);
#endif
diff --git a/sql/log_event.h b/sql/log_event.h
index 0468dc40a1d..49e244f1151 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -889,6 +889,7 @@ typedef struct st_print_event_info
*/
IO_CACHE head_cache;
IO_CACHE body_cache;
+ IO_CACHE tail_cache;
#ifdef WHEN_FLASHBACK_REVIEW_READY
/* Storing the SQL for reviewing */
IO_CACHE review_sql_cache;
@@ -899,6 +900,7 @@ typedef struct st_print_event_info
~st_print_event_info() {
close_cached_file(&head_cache);
close_cached_file(&body_cache);
+ close_cached_file(&tail_cache);
#ifdef WHEN_FLASHBACK_REVIEW_READY
close_cached_file(&review_sql_cache);
#endif
diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc
index 8ec823d3d64..c71a1f39e28 100644
--- a/sql/log_event_old.cc
+++ b/sql/log_event_old.cc
@@ -1848,6 +1848,7 @@ bool Old_rows_log_event::print_helper(FILE *file,
{
IO_CACHE *const head= &print_event_info->head_cache;
IO_CACHE *const body= &print_event_info->body_cache;
+ IO_CACHE *const tail= &print_event_info->tail_cache;
bool do_print_encoded=
print_event_info->base64_output_mode != BASE64_OUTPUT_DECODE_ROWS &&
print_event_info->base64_output_mode != BASE64_OUTPUT_NEVER &&
@@ -1867,8 +1868,9 @@ bool Old_rows_log_event::print_helper(FILE *file,
{
if (copy_event_cache_to_file_and_reinit(head, file) ||
copy_cache_to_file_wrapped(body, file, do_print_encoded,
- print_event_info->delimiter,
- print_event_info->verbose))
+ print_event_info->delimiter,
+ print_event_info->verbose) ||
+ copy_event_cache_to_file_and_reinit(tail, file))
goto err;
}
return 0;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 856d9bb0d98..c9bf6045867 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -3837,7 +3837,8 @@ rpl_make_log_name(const char *opt,
const char *ext)
{
DBUG_ENTER("rpl_make_log_name");
- DBUG_PRINT("enter", ("opt: %s, def: %s, ext: %s", opt, def, ext));
+ DBUG_PRINT("enter", ("opt: %s, def: %s, ext: %s", opt ? opt : "(null)",
+ def, ext));
char buff[FN_REFLEN];
const char *base= opt ? opt : def;
unsigned int options=
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index 5d2ad6d17a6..b324f4a362f 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -607,7 +607,8 @@ net_write_buff(NET *net, const uchar *packet, size_t len)
return net_real_write(net, packet, len) ? 1 : 0;
/* Send out rest of the blocks as full sized blocks */
}
- memcpy((char*) net->write_pos,packet,len);
+ if (len)
+ memcpy((char*) net->write_pos,packet,len);
net->write_pos+= len;
return 0;
}
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 86935f3ef27..eed7baab377 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -8195,13 +8195,15 @@ SEL_TREE *Item_bool_func::get_full_func_mm_tree(RANGE_OPT_PARAM *param,
table_map param_comp= ~(param->prev_tables | param->read_tables |
param->current_table);
#ifdef HAVE_SPATIAL
- Field::geometry_type sav_geom_type;
- const bool geometry= field_item->field->type() == MYSQL_TYPE_GEOMETRY;
- if (geometry)
+ Field::geometry_type sav_geom_type= Field::GEOM_GEOMETRY, *geom_type=
+ field_item->field->type() == MYSQL_TYPE_GEOMETRY
+ ? &(static_cast<Field_geom*>(field_item->field))->geom_type
+ : NULL;
+ if (geom_type)
{
- sav_geom_type= ((Field_geom*) field_item->field)->geom_type;
+ sav_geom_type= *geom_type;
/* We have to be able to store all sorts of spatial features here */
- ((Field_geom*) field_item->field)->geom_type= Field::GEOM_GEOMETRY;
+ *geom_type= Field::GEOM_GEOMETRY;
}
#endif /*HAVE_SPATIAL*/
@@ -8232,9 +8234,9 @@ SEL_TREE *Item_bool_func::get_full_func_mm_tree(RANGE_OPT_PARAM *param,
}
#ifdef HAVE_SPATIAL
- if (geometry)
+ if (geom_type)
{
- ((Field_geom*) field_item->field)->geom_type= sav_geom_type;
+ *geom_type= sav_geom_type;
}
#endif /*HAVE_SPATIAL*/
DBUG_RETURN(ftree);
diff --git a/sql/rpl_filter.cc b/sql/rpl_filter.cc
index b167b849923..3d1c3102e49 100644
--- a/sql/rpl_filter.cc
+++ b/sql/rpl_filter.cc
@@ -349,14 +349,20 @@ Rpl_filter::set_do_table(const char* table_spec)
int status;
if (do_table_inited)
- my_hash_reset(&do_table);
+ {
+ my_hash_free(&do_table);
+ do_table_inited= 0;
+ }
status= parse_filter_rule(table_spec, &Rpl_filter::add_do_table);
- if (!do_table.records)
+ if (do_table_inited && status)
{
- my_hash_free(&do_table);
- do_table_inited= 0;
+ if (!do_table.records)
+ {
+ my_hash_free(&do_table);
+ do_table_inited= 0;
+ }
}
return status;
@@ -369,14 +375,20 @@ Rpl_filter::set_ignore_table(const char* table_spec)
int status;
if (ignore_table_inited)
- my_hash_reset(&ignore_table);
+ {
+ my_hash_free(&ignore_table);
+ ignore_table_inited= 0;
+ }
status= parse_filter_rule(table_spec, &Rpl_filter::add_ignore_table);
- if (!ignore_table.records)
+ if (ignore_table_inited && status)
{
- my_hash_free(&ignore_table);
- ignore_table_inited= 0;
+ if (!ignore_table.records)
+ {
+ my_hash_free(&ignore_table);
+ ignore_table_inited= 0;
+ }
}
return status;
@@ -411,14 +423,20 @@ Rpl_filter::set_wild_do_table(const char* table_spec)
int status;
if (wild_do_table_inited)
+ {
free_string_array(&wild_do_table);
+ wild_do_table_inited= 0;
+ }
status= parse_filter_rule(table_spec, &Rpl_filter::add_wild_do_table);
- if (!wild_do_table.elements)
+ if (wild_do_table_inited && status)
{
- delete_dynamic(&wild_do_table);
- wild_do_table_inited= 0;
+ if (!wild_do_table.elements)
+ {
+ delete_dynamic(&wild_do_table);
+ wild_do_table_inited= 0;
+ }
}
return status;
@@ -431,14 +449,20 @@ Rpl_filter::set_wild_ignore_table(const char* table_spec)
int status;
if (wild_ignore_table_inited)
+ {
free_string_array(&wild_ignore_table);
+ wild_ignore_table_inited= 0;
+ }
status= parse_filter_rule(table_spec, &Rpl_filter::add_wild_ignore_table);
- if (!wild_ignore_table.elements)
+ if (wild_ignore_table_inited && status)
{
- delete_dynamic(&wild_ignore_table);
- wild_ignore_table_inited= 0;
+ if (!wild_ignore_table.elements)
+ {
+ delete_dynamic(&wild_ignore_table);
+ wild_ignore_table_inited= 0;
+ }
}
return status;
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 52641291eb2..7dd83d625e8 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1815,15 +1815,13 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
}
if (table->vfield)
{
- my_bool abort_on_warning= thd->abort_on_warning;
/*
We have not yet called update_virtual_fields(VOL_UPDATE_FOR_READ)
in handler methods for the just read row in record[1].
*/
table->move_fields(table->field, table->record[1], table->record[0]);
- thd->abort_on_warning= 0;
- table->update_virtual_fields(table->file, VCOL_UPDATE_FOR_REPLACE);
- thd->abort_on_warning= abort_on_warning;
+ if (table->update_virtual_fields(table->file, VCOL_UPDATE_FOR_REPLACE))
+ goto err;
table->move_fields(table->field, table->record[0], table->record[1]);
}
if (info->handle_duplicates == DUP_UPDATE)
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index a813de0ef85..ee166c319d1 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -23512,6 +23512,9 @@ check_reverse_order:
else if (select && select->quick)
select->quick->need_sorted_output();
+ tab->read_record.unlock_row= (tab->type == JT_EQ_REF) ?
+ join_read_key_unlock_row : rr_unlock_row;
+
} // QEP has been modified
/*
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index a3506687a72..08dc137bebe 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -388,10 +388,10 @@ void print_sjm(SJ_MATERIALIZATION_INFO *sjm)
/*
Debugging help: force List<...>::elem function not be removed as unused.
*/
-Item* (List<Item>:: *dbug_list_item_elem_ptr)(uint)= &List<Item>::elem;
-Item_equal* (List<Item_equal>:: *dbug_list_item_equal_elem_ptr)(uint)=
+Item* (List<Item>::*dbug_list_item_elem_ptr)(uint)= &List<Item>::elem;
+Item_equal* (List<Item_equal>::*dbug_list_item_equal_elem_ptr)(uint)=
&List<Item_equal>::elem;
-TABLE_LIST* (List<TABLE_LIST>:: *dbug_list_table_list_elem_ptr)(uint) =
+TABLE_LIST* (List<TABLE_LIST>::*dbug_list_table_list_elem_ptr)(uint) =
&List<TABLE_LIST>::elem;
#endif
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index fab47fc03d0..aaf17012118 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -2671,7 +2671,14 @@ int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len)
definer_host.length= 0;
}
- stmt_query.append(STRING_WITH_LEN("CREATE "));
+ const LEX_CSTRING command[2]=
+ {{ C_STRING_WITH_LEN("CREATE ") },
+ { C_STRING_WITH_LEN("CREATE OR REPLACE ") }};
+
+ if (thd->lex->create_info.or_replace())
+ stmt_query.append(command[1]);
+ else
+ stmt_query.append(command[0]);
append_definer(thd, &stmt_query, &definer_user, &definer_host);