summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-04-24 20:59:57 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2018-04-24 20:59:57 +0300
commit7396dfcca7a1eb906edabec02fb59d168f09343d (patch)
tree5971546f2d27f5a8dc186e0f63ae3d2ac9208a6a /sql
parentf79c5a658cc33a10d7744a748a4328254e2cbaf7 (diff)
parent7b5543b21d31bd1517b49c2524a05b5b83fd9691 (diff)
downloadmariadb-git-7396dfcca7a1eb906edabec02fb59d168f09343d.tar.gz
Merge 10.2 into 10.3
Diffstat (limited to 'sql')
-rw-r--r--sql/field.h2
-rw-r--r--sql/filesort.cc17
-rw-r--r--sql/gen_lex_hash.cc30
-rw-r--r--sql/handler.cc15
-rw-r--r--sql/handler.h2
-rw-r--r--sql/item_cmpfunc.cc12
-rw-r--r--sql/item_func.cc4
-rw-r--r--sql/item_func.h1
-rw-r--r--sql/item_strfunc.cc14
-rw-r--r--sql/item_strfunc.h1
-rw-r--r--sql/key.cc6
-rw-r--r--sql/lock.cc4
-rw-r--r--sql/log.cc7
-rw-r--r--sql/log_event.cc119
-rw-r--r--sql/log_event_old.cc10
-rw-r--r--sql/mf_iocache.cc3
-rw-r--r--sql/opt_subselect.cc1
-rw-r--r--sql/password.c4
-rw-r--r--sql/plistsort.c10
-rw-r--r--sql/records.cc2
-rw-r--r--sql/slave.cc2
-rw-r--r--sql/sp.cc6
-rw-r--r--sql/sql_acl.cc4
-rw-r--r--sql/sql_admin.cc4
-rw-r--r--sql/sql_base.cc28
-rw-r--r--sql/sql_base.h2
-rw-r--r--sql/sql_class.h2
-rw-r--r--sql/sql_db.cc2
-rw-r--r--sql/sql_insert.cc8
-rw-r--r--sql/sql_lex.cc6
-rw-r--r--sql/sql_parse.cc2
-rw-r--r--sql/sql_partition.cc6
-rw-r--r--sql/sql_partition_admin.cc2
-rw-r--r--sql/sql_plugin.cc14
-rw-r--r--sql/sql_prepare.cc2
-rw-r--r--sql/sql_priv.h4
-rw-r--r--sql/sql_select.cc2
-rw-r--r--sql/sql_statistics.cc2
-rw-r--r--sql/sql_string.cc12
-rw-r--r--sql/sql_table.cc10
-rw-r--r--sql/sql_trigger.cc3
-rw-r--r--sql/sql_truncate.cc5
-rw-r--r--sql/table.cc23
-rw-r--r--sql/table.h10
-rw-r--r--sql/uniques.cc2
-rw-r--r--sql/uniques.h2
46 files changed, 287 insertions, 142 deletions
diff --git a/sql/field.h b/sql/field.h
index fd097e02074..e7ec0b681e2 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1558,7 +1558,7 @@ public:
}
virtual bool sp_prepare_and_store_item(THD *thd, Item **value);
- friend int cre_myisam(char * name, register TABLE *form, uint options,
+ friend int cre_myisam(char * name, TABLE *form, uint options,
ulonglong auto_increment_value);
friend class Copy_field;
friend class Item_avg_field;
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 00dfa08bba8..4585330ea54 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -1166,12 +1166,11 @@ Type_handler_real_result::make_sort_key(uchar *to, Item *item,
/** Make a sort-key from record. */
-static void make_sortkey(register Sort_param *param,
- register uchar *to, uchar *ref_pos)
+static void make_sortkey(Sort_param *param, uchar *to, uchar *ref_pos)
{
- reg3 Field *field;
- reg1 SORT_FIELD *sort_field;
- reg5 uint length;
+ Field *field;
+ SORT_FIELD *sort_field;
+ uint length;
for (sort_field=param->local_sortorder ;
sort_field != param->end ;
@@ -1261,7 +1260,7 @@ static void make_sortkey(register Sort_param *param,
static void register_used_fields(Sort_param *param)
{
- reg1 SORT_FIELD *sort_field;
+ SORT_FIELD *sort_field;
TABLE *table=param->sort_form;
for (sort_field= param->local_sortorder ;
@@ -1460,7 +1459,7 @@ static bool check_if_pq_applicable(Sort_param *param,
int merge_many_buff(Sort_param *param, uchar *sort_buffer,
BUFFPEK *buffpek, uint *maxbuffer, IO_CACHE *t_file)
{
- register uint i;
+ uint i;
IO_CACHE t_file2,*from_file,*to_file,*temp;
BUFFPEK *lastbuff;
DBUG_ENTER("merge_many_buff");
@@ -1515,7 +1514,7 @@ cleanup:
uint read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek,
uint rec_length)
{
- register uint count;
+ uint count;
uint length;
if ((count=(uint) MY_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
@@ -1819,7 +1818,7 @@ int merge_buffers(Sort_param *param, IO_CACHE *from_file,
}
else
{
- register uchar *end;
+ uchar *end;
src= buffpek->key+offset;
for (end= src+buffpek->mem_count*rec_length ;
src != end ;
diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc
index b2bc1aee091..721ad4d3a8a 100644
--- a/sql/gen_lex_hash.cc
+++ b/sql/gen_lex_hash.cc
@@ -401,8 +401,8 @@ int main(int argc,char **argv)
static SYMBOL *get_hash_symbol(const char *s,\n\
unsigned int len,bool function)\n\
{\n\
- register uchar *hash_map;\n\
- register const char *cur_str= s;\n\
+ uchar *hash_map;\n\
+ const char *cur_str= s;\n\
\n\
if (len == 0) {\n\
DBUG_PRINT(\"warning\", (\"get_hash_symbol() received a request for a zero-length symbol, which is probably a mistake.\"));\
@@ -414,25 +414,25 @@ static SYMBOL *get_hash_symbol(const char *s,\n\
if (function){\n\
if (len>sql_functions_max_len) return 0;\n\
hash_map= sql_functions_map;\n\
- register uint32 cur_struct= uint4korr(hash_map+((len-1)*4));\n\
+ uint32 cur_struct= uint4korr(hash_map+((len-1)*4));\n\
\n\
for (;;){\n\
- register uchar first_char= (uchar)cur_struct;\n\
+ uchar first_char= (uchar)cur_struct;\n\
\n\
if (first_char == 0)\n\
{\n\
- register int16 ires= (int16)(cur_struct>>16);\n\
+ int16 ires= (int16)(cur_struct>>16);\n\
if (ires==array_elements(symbols)) return 0;\n\
- register SYMBOL *res;\n\
+ SYMBOL *res;\n\
if (ires>=0) \n\
res= symbols+ires;\n\
else\n\
res= sql_functions-ires-1;\n\
- register uint count= (uint) (cur_str - s);\n\
+ uint count= (uint) (cur_str - s);\n\
return lex_casecmp(cur_str,res->name+count,len-count) ? 0 : res;\n\
}\n\
\n\
- register uchar cur_char= (uchar)to_upper_lex[(uchar)*cur_str];\n\
+ uchar cur_char= (uchar)to_upper_lex[(uchar)*cur_str];\n\
if (cur_char<first_char) return 0;\n\
cur_struct>>=8;\n\
if (cur_char>(uchar)cur_struct) return 0;\n\
@@ -448,20 +448,20 @@ static SYMBOL *get_hash_symbol(const char *s,\n\
}else{\n\
if (len>symbols_max_len) return 0;\n\
hash_map= symbols_map;\n\
- register uint32 cur_struct= uint4korr(hash_map+((len-1)*4));\n\
+ uint32 cur_struct= uint4korr(hash_map+((len-1)*4));\n\
\n\
for (;;){\n\
- register uchar first_char= (uchar)cur_struct;\n\
+ uchar first_char= (uchar)cur_struct;\n\
\n\
- if (first_char==0){\n\
- register int16 ires= (int16)(cur_struct>>16);\n\
+ if (first_char==0) {\n\
+ int16 ires= (int16)(cur_struct>>16);\n\
if (ires==array_elements(symbols)) return 0;\n\
- register SYMBOL *res= symbols+ires;\n\
- register uint count= (uint) (cur_str - s);\n\
+ SYMBOL *res= symbols+ires;\n\
+ uint count= (uint) (cur_str - s);\n\
return lex_casecmp(cur_str,res->name+count,len-count)!=0 ? 0 : res;\n\
}\n\
\n\
- register uchar cur_char= (uchar)to_upper_lex[(uchar)*cur_str];\n\
+ uchar cur_char= (uchar)to_upper_lex[(uchar)*cur_str];\n\
if (cur_char<first_char) return 0;\n\
cur_struct>>=8;\n\
if (cur_char>(uchar)cur_struct) return 0;\n\
diff --git a/sql/handler.cc b/sql/handler.cc
index b8450e94e55..ef1d599c6f5 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -2983,7 +2983,7 @@ int handler::ha_rnd_init_with_error(bool scan)
*/
int handler::read_first_row(uchar * buf, uint primary_key)
{
- register int error;
+ int error;
DBUG_ENTER("handler::read_first_row");
/*
@@ -4469,18 +4469,6 @@ handler::check_if_supported_inplace_alter(TABLE *altered_table,
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
}
-
-/*
- Default implementation to support in-place alter table
- and old online add/drop index API
-*/
-
-void handler::notify_table_changed()
-{
- ha_create_partitioning_metadata(table->s->path.str, NULL, CHF_INDEX_FLAG);
-}
-
-
void Alter_inplace_info::report_unsupported_error(const char *not_supported,
const char *try_instead)
{
@@ -4579,7 +4567,6 @@ handler::ha_create_partitioning_metadata(const char *name,
*/
DBUG_ASSERT(m_lock_type == F_UNLCK ||
(!old_name && strcmp(name, table_share->path.str)));
- mark_trx_read_write();
return create_partitioning_metadata(name, old_name, action_flag);
}
diff --git a/sql/handler.h b/sql/handler.h
index c5d92cbbaab..549fcb264be 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -4271,7 +4271,7 @@ protected:
@note No errors are allowed during notify_table_changed().
*/
- virtual void notify_table_changed();
+ virtual void notify_table_changed() { }
public:
/* End of On-line/in-place ALTER TABLE interface. */
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index fc07235c265..55522f8624c 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -5855,8 +5855,8 @@ void Item_func_like::turboBM_compute_bad_character_shifts()
bool Item_func_like::turboBM_matches(const char* text, int text_len) const
{
- register int bcShift;
- register int turboShift;
+ int bcShift;
+ int turboShift;
int shift = pattern_len;
int j = 0;
int u = 0;
@@ -5870,7 +5870,7 @@ bool Item_func_like::turboBM_matches(const char* text, int text_len) const
{
while (j <= tlmpl)
{
- register int i= plm1;
+ int i= plm1;
while (i >= 0 && pattern[i] == text[i + j])
{
i--;
@@ -5880,7 +5880,7 @@ bool Item_func_like::turboBM_matches(const char* text, int text_len) const
if (i < 0)
return 1;
- register const int v = plm1 - i;
+ const int v= plm1 - i;
turboShift = u - v;
bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
shift = MY_MAX(turboShift, bcShift);
@@ -5901,7 +5901,7 @@ bool Item_func_like::turboBM_matches(const char* text, int text_len) const
{
while (j <= tlmpl)
{
- register int i = plm1;
+ int i= plm1;
while (i >= 0 && likeconv(cs,pattern[i]) == likeconv(cs,text[i + j]))
{
i--;
@@ -5911,7 +5911,7 @@ bool Item_func_like::turboBM_matches(const char* text, int text_len) const
if (i < 0)
return 1;
- register const int v = plm1 - i;
+ const int v= plm1 - i;
turboShift = u - v;
bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
shift = MY_MAX(turboShift, bcShift);
diff --git a/sql/item_func.cc b/sql/item_func.cc
index ae6c61e83f4..59cf5b53154 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -3077,8 +3077,8 @@ longlong Item_func_ord::val_int()
#ifdef USE_MB
if (use_mb(res->charset()))
{
- register const char *str=res->ptr();
- register uint32 n=0, l=my_ismbchar(res->charset(),str,str+res->length());
+ const char *str=res->ptr();
+ uint32 n=0, l=my_ismbchar(res->charset(),str,str+res->length());
if (!l)
return (longlong)((uchar) *str);
while (l--)
diff --git a/sql/item_func.h b/sql/item_func.h
index c5fb759c2ac..29ff14f7b39 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -3001,6 +3001,7 @@ public:
Item_func_uuid_short(THD *thd): Item_longlong_func(thd) {}
const char *func_name() const { return "uuid_short"; }
longlong val_int();
+ bool const_item() const { return false; }
void fix_length_and_dec()
{ max_length= 21; unsigned_flag=1; }
table_map used_tables() const { return RAND_TABLE_BIT; }
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 85e578f4595..d84e5ad61f6 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1078,7 +1078,7 @@ String *Item_func_reverse::val_str(String *str)
#ifdef USE_MB
if (use_mb(res->charset()))
{
- register uint32 l;
+ uint32 l;
while (ptr < end)
{
if ((l= my_ismbchar(res->charset(),ptr,end)))
@@ -1128,7 +1128,7 @@ String *Item_func_replace::val_str_internal(String *str,
bool alloced=0;
#ifdef USE_MB
const char *ptr,*end,*strend,*search,*search_end;
- register uint32 l;
+ uint32 l;
bool binary_cmp;
#endif
THD *thd= 0;
@@ -1188,7 +1188,7 @@ redo:
{
if (*ptr == *search)
{
- register char *i,*j;
+ char *i,*j;
i=(char*) ptr+1; j=(char*) search+1;
while (j != search_end)
if (*i++ != *j++) goto skip;
@@ -1799,14 +1799,14 @@ String *Item_func_substr_index::val_str(String *str)
const char *search= delimiter->ptr();
const char *search_end= search+delimiter_length;
int32 n=0,c=count,pass;
- register uint32 l;
+ uint32 l;
for (pass=(count>0);pass<2;++pass)
{
while (ptr < end)
{
if (*ptr == *search)
{
- register char *i,*j;
+ char *i,*j;
i=(char*) ptr+1; j=(char*) search+1;
while (j != search_end)
if (*i++ != *j++) goto skip;
@@ -1974,7 +1974,7 @@ String *Item_func_rtrim::val_str(String *str)
end= ptr+res->length();
#ifdef USE_MB
char *p=ptr;
- register uint32 l;
+ uint32 l;
#endif
if (remove_length == 1)
{
@@ -2059,7 +2059,7 @@ String *Item_func_trim::val_str(String *str)
if (use_mb(collation.collation))
{
char *p=ptr;
- register uint32 l;
+ uint32 l;
loop:
while (ptr + remove_length < end)
{
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index cff9fdee072..b3462a60d36 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -1630,6 +1630,7 @@ public:
DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
fix_char_length(MY_UUID_STRING_LENGTH);
}
+ bool const_item() const { return false; }
table_map used_tables() const { return RAND_TABLE_BIT; }
const char *func_name() const{ return "uuid"; }
String *val_str(String *);
diff --git a/sql/key.cc b/sql/key.cc
index 8642820ff3f..34196a973c5 100644
--- a/sql/key.cc
+++ b/sql/key.cc
@@ -52,8 +52,8 @@
int find_ref_key(KEY *key, uint key_count, uchar *record, Field *field,
uint *key_length, uint *keypart)
{
- reg2 int i;
- reg3 KEY *key_info;
+ int i;
+ KEY *key_info;
uint fieldpos;
fieldpos= field->offset(record);
@@ -499,7 +499,7 @@ int key_cmp(KEY_PART_INFO *key_part, const uchar *key, uint key_length)
if (key_part->null_bit)
{
/* This key part allows null values; NULL is lower than everything */
- register bool field_is_null= key_part->field->is_null();
+ bool field_is_null= key_part->field->is_null();
if (*key) // If range key is null
{
/* the range is expecting a null value */
diff --git a/sql/lock.cc b/sql/lock.cc
index 2d9409fc7c3..1bb80e01fb0 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -379,7 +379,7 @@ end:
static int lock_external(THD *thd, TABLE **tables, uint count)
{
- reg1 uint i;
+ uint i;
int lock_type,error;
DBUG_ENTER("lock_external");
@@ -539,7 +539,7 @@ void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked,TABLE *table)
{
if (locked)
{
- reg1 uint i;
+ uint i;
for (i=0; i < locked->table_count; i++)
{
if (locked->table[i] == table)
diff --git a/sql/log.cc b/sql/log.cc
index d1a1ba5564c..f61cba21f9d 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -2459,7 +2459,7 @@ static int find_uniq_filename(char *name, ulong next_log_number)
uint i;
char buff[FN_REFLEN], ext_buf[FN_REFLEN];
struct st_my_dir *dir_info;
- reg1 struct fileinfo *file_info;
+ struct fileinfo *file_info;
ulong max_found, next, UNINIT_VAR(number);
size_t buf_length, length;
char *start, *end;
@@ -8516,10 +8516,9 @@ void MYSQL_BIN_LOG::set_max_size(ulong max_size_arg)
0 String is not a number
*/
-static bool test_if_number(register const char *str,
- ulong *res, bool allow_wildcards)
+static bool test_if_number(const char *str, ulong *res, bool allow_wildcards)
{
- reg2 int flag;
+ int flag;
const char *start;
DBUG_ENTER("test_if_number");
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 8c089ded4e1..c6bd8f90907 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2000, 2016, Oracle and/or its affiliates.
- Copyright (c) 2009, 2016, MariaDB
+ Copyright (c) 2000, 2018, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2018, 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
@@ -4831,6 +4831,24 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
db= (char *)start;
query= (char *)(start + db_len + 1);
q_len= data_len - db_len -1;
+
+ if (data_len && (data_len < db_len ||
+ data_len < q_len ||
+ data_len != (db_len + q_len + 1)))
+ {
+ q_len= 0;
+ query= NULL;
+ DBUG_VOID_RETURN;
+ }
+
+ uint32 max_length= uint32(event_len - ((const char*)(end + db_len + 1) -
+ (buf - common_header_len)));
+ if (q_len != max_length)
+ {
+ q_len= 0;
+ query= NULL;
+ DBUG_VOID_RETURN;
+ }
/**
Append the db length at the end of the buffer. This will be used by
Query_cache::send_result_to_client() in case the query cache is On.
@@ -5377,6 +5395,19 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi,
you.
*/
thd->catalog= catalog_len ? (char *) catalog : (char *)"";
+
+ size_t valid_len= Well_formed_prefix(system_charset_info,
+ db, db_len, NAME_LEN).length();
+
+ if (valid_len != db_len)
+ {
+ rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR,
+ ER_THD(thd, ER_SLAVE_FATAL_ERROR),
+ "Invalid database name in Query event.");
+ thd->is_slave_error= true;
+ goto end;
+ }
+
new_db.length= db_len;
new_db.str= (char *) rpl_filter->get_rewrite_db(db, &new_db.length);
thd->set_db(&new_db); /* allocates a copy of 'db' */
@@ -5518,7 +5549,23 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi,
}
else
thd->variables.collation_database= thd->db_charset;
-
+
+ {
+ const CHARSET_INFO *cs= thd->charset();
+ /*
+ We cannot ask for parsing a statement using a character set
+ without state_maps (parser internal data).
+ */
+ if (!cs->state_map)
+ {
+ rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR,
+ ER_THD(thd, ER_SLAVE_FATAL_ERROR),
+ "character_set cannot be parsed");
+ thd->is_slave_error= true;
+ goto end;
+ }
+ }
+
/*
Record any GTID in the same transaction, so slave state is
transactionally consistent.
@@ -6074,7 +6121,13 @@ int Start_log_event_v3::do_apply_event(rpl_group_info *rgi)
*/
break;
default:
- /* this case is impossible */
+ /*
+ This case is not expected. It can be either an event corruption or an
+ unsupported binary log version.
+ */
+ rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR,
+ ER_THD(thd, ER_SLAVE_FATAL_ERROR),
+ "Binlog version not supported");
DBUG_RETURN(1);
}
DBUG_RETURN(error);
@@ -6993,6 +7046,9 @@ int Load_log_event::copy_log_event(const char *buf, ulong event_len,
fields = (char*)field_lens + num_fields;
table_name = fields + field_block_len;
+ if (strlen(table_name) > NAME_LEN)
+ goto err;
+
db = table_name + table_name_len + 1;
DBUG_EXECUTE_IF ("simulate_invalid_address",
db_len = data_len;);
@@ -9066,6 +9122,13 @@ User_var_log_event(const char* buf, uint event_len,
buf+= description_event->common_header_len +
description_event->post_header_len[USER_VAR_EVENT-1];
name_len= uint4korr(buf);
+ /* Avoid reading out of buffer */
+ if ((buf - buf_start) + UV_NAME_LEN_SIZE + name_len > event_len)
+ {
+ error= true;
+ goto err;
+ }
+
name= (char *) buf + UV_NAME_LEN_SIZE;
/*
@@ -9122,7 +9185,12 @@ User_var_log_event(const char* buf, uint event_len,
Old events will not have this extra byte, thence,
we keep the flags set to UNDEF_F.
*/
- size_t bytes_read= ((val + val_len) - buf_start);
+ size_t bytes_read= (val + val_len) - buf_start;
+ if (bytes_read > size_t(event_len))
+ {
+ error= true;
+ goto err;
+ }
if ((data_written - bytes_read) > 0)
{
flags= (uint) *(buf + UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE +
@@ -9354,7 +9422,12 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi)
}
if (!(charset= get_charset(charset_number, MYF(MY_WME))))
+ {
+ rgi->rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR,
+ ER_THD(thd, ER_SLAVE_FATAL_ERROR),
+ "Invalid character set for User var event");
DBUG_RETURN(1);
+ }
LEX_CSTRING user_var_name;
user_var_name.str= name;
user_var_name.length= name_len;
@@ -9369,12 +9442,26 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi)
{
switch (type) {
case REAL_RESULT:
+ if (val_len != 8)
+ {
+ rgi->rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR,
+ ER_THD(thd, ER_SLAVE_FATAL_ERROR),
+ "Invalid variable length at User var event");
+ return 1;
+ }
float8get(real_val, val);
it= new (thd->mem_root) Item_float(thd, real_val, 0);
val= (char*) &real_val; // Pointer to value in native format
val_len= 8;
break;
case INT_RESULT:
+ if (val_len != 8)
+ {
+ rgi->rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR,
+ ER_THD(thd, ER_SLAVE_FATAL_ERROR),
+ "Invalid variable length at User var event");
+ return 1;
+ }
int_val= (longlong) uint8korr(val);
it= new (thd->mem_root) Item_int(thd, int_val);
val= (char*) &int_val; // Pointer to value in native format
@@ -9382,6 +9469,13 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi)
break;
case DECIMAL_RESULT:
{
+ if (val_len < 3)
+ {
+ rgi->rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR,
+ ER_THD(thd, ER_SLAVE_FATAL_ERROR),
+ "Invalid variable length at User var event");
+ return 1;
+ }
Item_decimal *dec= new (thd->mem_root) Item_decimal(thd, (uchar*) val+2, val[0], val[1]);
it= dec;
val= (char *)dec->val_decimal(NULL);
@@ -10797,6 +10891,14 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len,
DBUG_PRINT("debug", ("Reading from %p", ptr_after_width));
m_width = net_field_length(&ptr_after_width);
DBUG_PRINT("debug", ("m_width=%lu", m_width));
+
+ /* Avoid reading out of buffer */
+ if (ptr_after_width + (m_width + 7) / 8 > (uchar*)buf + event_len)
+ {
+ m_cols.bitmap= NULL;
+ DBUG_VOID_RETURN;
+ }
+
/* if my_bitmap_init fails, catched in is_valid() */
if (likely(!my_bitmap_init(&m_cols,
m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL,
@@ -10845,7 +10947,12 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len,
const uchar* const ptr_rows_data= (const uchar*) ptr_after_width;
- size_t const data_size= event_len - (ptr_rows_data - (const uchar *) buf);
+ size_t const read_size= ptr_rows_data - (const unsigned char *) buf;
+ if (read_size > event_len)
+ {
+ DBUG_VOID_RETURN;
+ }
+ size_t const data_size= event_len - read_size;
DBUG_PRINT("info",("m_table_id: %lu m_flags: %d m_width: %lu data_size: %lu",
m_table_id, m_flags, m_width, (ulong) data_size));
diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc
index 20986050203..b1552bfcbba 100644
--- a/sql/log_event_old.cc
+++ b/sql/log_event_old.cc
@@ -1,4 +1,5 @@
-/* Copyright (c) 2007, 2016, Oracle and/or its affiliates.
+/* Copyright (c) 2007, 2018, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2018, 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
@@ -1233,6 +1234,13 @@ Old_rows_log_event::Old_rows_log_event(const char *buf, uint event_len,
DBUG_PRINT("debug", ("Reading from %p", ptr_after_width));
m_width = net_field_length(&ptr_after_width);
DBUG_PRINT("debug", ("m_width=%lu", m_width));
+ /* Avoid reading out of buffer */
+ if (ptr_after_width + m_width > (uchar *)buf + event_len)
+ {
+ m_cols.bitmap= NULL;
+ DBUG_VOID_RETURN;
+ }
+
/* if my_bitmap_init fails, catched in is_valid() */
if (likely(!my_bitmap_init(&m_cols,
m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL,
diff --git a/sql/mf_iocache.cc b/sql/mf_iocache.cc
index 3d3b4da11db..d1f56244cb6 100644
--- a/sql/mf_iocache.cc
+++ b/sql/mf_iocache.cc
@@ -49,8 +49,7 @@ extern "C" {
*/
-int _my_b_net_read(register IO_CACHE *info, uchar *Buffer,
- size_t Count __attribute__((unused)))
+int _my_b_net_read(IO_CACHE *info, uchar *Buffer, size_t)
{
ulong read_length;
NET *net= &(current_thd)->net;
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index a723980ad50..3abf879e6da 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -5961,5 +5961,6 @@ bool JOIN::choose_tableless_subquery_plan()
tmp_having= having;
}
}
+ exec_const_cond= conds;
return FALSE;
}
diff --git a/sql/password.c b/sql/password.c
index 5e9684acb25..75ac210acd3 100644
--- a/sql/password.c
+++ b/sql/password.c
@@ -90,7 +90,7 @@
void hash_password(ulong *result, const char *password, uint password_len)
{
- register ulong nr=1345345333L, add=7, nr2=0x12345671L;
+ ulong nr=1345345333L, add=7, nr2=0x12345671L;
ulong tmp;
const char *password_end= password + password_len;
for (; password < password_end; password++)
@@ -325,7 +325,7 @@ hex2octet(uint8 *to, const char *str, uint len)
const char *str_end= str + len;
while (str < str_end)
{
- register char tmp= char_val(*str++);
+ char tmp= char_val(*str++);
*to++= (tmp << 4) | char_val(*str++);
}
}
diff --git a/sql/plistsort.c b/sql/plistsort.c
index 99657410fe0..e66bd7c7276 100644
--- a/sql/plistsort.c
+++ b/sql/plistsort.c
@@ -91,7 +91,7 @@ recursion_point:
}
{
- register struct LS_STRUCT_NAME *sp0= sp++;
+ struct LS_STRUCT_NAME *sp0= sp++;
sp->list_len= sp0->list_len >> 1;
sp0->list_len-= sp->list_len;
sp->return_point= 0;
@@ -100,7 +100,7 @@ recursion_point:
return_point0:
sp->list1= sorted_list;
{
- register struct LS_STRUCT_NAME *sp0= sp++;
+ struct LS_STRUCT_NAME *sp0= sp++;
list= list_end;
sp->list_len= sp0->list_len;
sp->return_point= 1;
@@ -108,9 +108,9 @@ return_point0:
goto recursion_point;
return_point1:
{
- register LS_LIST_ITEM **hook= &sorted_list;
- register LS_LIST_ITEM *list1= sp->list1;
- register LS_LIST_ITEM *list2= sorted_list;
+ LS_LIST_ITEM **hook= &sorted_list;
+ LS_LIST_ITEM *list1= sp->list1;
+ LS_LIST_ITEM *list2= sorted_list;
if (LS_COMPARE_FUNC_CALL(list1, list2))
{
diff --git a/sql/records.cc b/sql/records.cc
index ac84ca84ab6..16680c7ecf2 100644
--- a/sql/records.cc
+++ b/sql/records.cc
@@ -631,7 +631,7 @@ static int init_rr_cache(THD *thd, READ_RECORD *info)
static int rr_from_cache(READ_RECORD *info)
{
- reg1 uint i;
+ uint i;
ulong length;
my_off_t rest_of_file;
int16 error;
diff --git a/sql/slave.cc b/sql/slave.cc
index 53902619d26..40f5a4c1744 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -223,7 +223,7 @@ static void set_slave_max_allowed_packet(THD *thd, MYSQL *mysql)
void init_thread_mask(int* mask,Master_info* mi,bool inverse)
{
bool set_io = mi->slave_running, set_sql = mi->rli.slave_running;
- register int tmp_mask=0;
+ int tmp_mask=0;
DBUG_ENTER("init_thread_mask");
if (set_io)
diff --git a/sql/sp.cc b/sql/sp.cc
index cb05108a5bc..f9cfc9ce6c8 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2002, 2016, Oracle and/or its affiliates.
- Copyright (c) 2009, 2017, MariaDB
+ Copyright (c) 2002, 2018, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2018, 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
@@ -423,7 +423,7 @@ private:
bool m_print_once;
public:
- Proc_table_intact() : m_print_once(TRUE) {}
+ Proc_table_intact() : m_print_once(TRUE) { has_keys= TRUE; }
protected:
void report_error(uint code, const char *fmt, ...);
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index ffc109d7d26..de4e20115a4 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
- Copyright (c) 2009, 2016, MariaDB
+ Copyright (c) 2009, 2018, 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
@@ -11379,7 +11379,7 @@ int fill_schema_applicable_roles(THD *thd, TABLE_LIST *tables, COND *cond)
int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr)
{
- reg3 int flag;
+ int flag;
DBUG_ENTER("wild_case_compare");
DBUG_PRINT("enter",("str: '%s' wildstr: '%s'",str,wildstr));
while (*wildstr)
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index 82fc1cbfff7..45c48dd41cc 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2010, 2015, Oracle and/or its affiliates.
- Copyright (c) 2011, 2016, MariaDB
+ Copyright (c) 2011, 2018, 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
@@ -240,7 +240,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
if (thd->locked_tables_list.locked_tables())
{
- if (thd->locked_tables_list.reopen_tables(thd))
+ if (thd->locked_tables_list.reopen_tables(thd, false))
goto end;
/* Restore the table in the table list with the new opened table */
table_list->table= pos_in_locked_tables->table;
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 3de45b0ad66..0081365793b 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -484,7 +484,7 @@ err_with_reopen:
old locks. This should always succeed (unless some external process
has removed the tables)
*/
- if (thd->locked_tables_list.reopen_tables(thd))
+ if (thd->locked_tables_list.reopen_tables(thd, false))
result= true;
/*
Since downgrade_lock() won't do anything with shared
@@ -811,7 +811,10 @@ void close_thread_tables(THD *thd)
we will exit this function a few lines below.
*/
if (! thd->lex->requires_prelocking())
+ {
+ thd->locked_tables_list.reopen_tables(thd, true);
DBUG_VOID_RETURN;
+ }
/*
We are in the top-level statement of a prelocked statement,
@@ -2298,7 +2301,8 @@ void Locked_tables_list::unlink_from_list(THD *thd,
If mode is not LTM_LOCK_TABLES, we needn't do anything. Moreover,
outside this mode pos_in_locked_tables value is not trustworthy.
*/
- if (thd->locked_tables_mode != LTM_LOCK_TABLES)
+ if (thd->locked_tables_mode != LTM_LOCK_TABLES &&
+ thd->locked_tables_mode != LTM_PRELOCKED_UNDER_LOCK_TABLES)
return;
/*
@@ -2402,7 +2406,7 @@ unlink_all_closed_tables(THD *thd, MYSQL_LOCK *lock, size_t reopen_count)
*/
bool
-Locked_tables_list::reopen_tables(THD *thd)
+Locked_tables_list::reopen_tables(THD *thd, bool need_reopen)
{
Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN);
uint reopen_count= 0;
@@ -2413,8 +2417,20 @@ Locked_tables_list::reopen_tables(THD *thd)
for (TABLE_LIST *table_list= m_locked_tables;
table_list; table_list= table_list->next_global)
{
- if (table_list->table) /* The table was not closed */
- continue;
+ if (need_reopen)
+ {
+ if (!table_list->table || !table_list->table->needs_reopen())
+ continue;
+ /* no need to remove the table from the TDC here, thus (TABLE*)1 */
+ close_all_tables_for_name(thd, table_list->table->s,
+ HA_EXTRA_NOT_USED, (TABLE*)1);
+ DBUG_ASSERT(table_list->table == NULL);
+ }
+ else
+ {
+ if (table_list->table) /* The table was not closed */
+ continue;
+ }
/* Links into thd->open_tables upon success */
if (open_table(thd, table_list, &ot_ctx))
@@ -7253,7 +7269,7 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array,
List<Item> *sum_func_list, List<Item> *pre_fix,
bool allow_sum_func)
{
- reg2 Item *item;
+ Item *item;
enum_column_usage saved_column_usage= thd->column_usage;
nesting_map save_allow_sum_func= thd->lex->allow_sum_func;
List_iterator<Item> it(fields);
diff --git a/sql/sql_base.h b/sql/sql_base.h
index a6a85d47dc9..8f6d406cb73 100644
--- a/sql/sql_base.h
+++ b/sql/sql_base.h
@@ -1,4 +1,6 @@
/* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2011, 2018, 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_class.h b/sql/sql_class.h
index a7c33cbc504..10f082e0ee2 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1910,7 +1910,7 @@ public:
void unlink_all_closed_tables(THD *thd,
MYSQL_LOCK *lock,
size_t reopen_count);
- bool reopen_tables(THD *thd);
+ bool reopen_tables(THD *thd, bool need_reopen);
bool restore_lock(THD *thd, TABLE_LIST *dst_table_list, TABLE *table,
MYSQL_LOCK *lock);
void add_back_last_deleted_lock(TABLE_LIST *dst_table_list);
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 67910a3b618..3977393d63b 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -338,7 +338,7 @@ static void del_dbopt(const char *path)
static bool write_db_opt(THD *thd, const char *path,
Schema_specification_st *create)
{
- register File file;
+ File file;
char buf[256]; // Should be enough for one option
bool error=1;
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 392aa52825e..49b2b70e0ff 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -89,7 +89,7 @@ static int write_delayed(THD *thd, TABLE *table, enum_duplicates duplic,
LEX_STRING query, bool ignore, bool log_on);
static void end_delayed_insert(THD *thd);
pthread_handler_t handle_delayed_insert(void *arg);
-static void unlink_blobs(register TABLE *table);
+static void unlink_blobs(TABLE *table);
#endif
static bool check_view_insertability(THD *thd, TABLE_LIST *view);
@@ -3198,7 +3198,7 @@ pthread_handler_t handle_delayed_insert(void *arg)
/* Remove all pointers to data for blob fields so that original table doesn't try to free them */
-static void unlink_blobs(register TABLE *table)
+static void unlink_blobs(TABLE *table)
{
for (Field **ptr=table->field ; *ptr ; ptr++)
{
@@ -3209,7 +3209,7 @@ static void unlink_blobs(register TABLE *table)
/* Free blobs stored in current row */
-static void free_delayed_insert_blobs(register TABLE *table)
+static void free_delayed_insert_blobs(TABLE *table)
{
for (Field **ptr=table->field ; *ptr ; ptr++)
{
@@ -3221,7 +3221,7 @@ static void free_delayed_insert_blobs(register TABLE *table)
/* set value field for blobs to point to data in record */
-static void set_delayed_insert_blobs(register TABLE *table)
+static void set_delayed_insert_blobs(TABLE *table)
{
for (Field **ptr=table->field ; *ptr ; ptr++)
{
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 19e5acfa64c..35e84effd09 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1078,7 +1078,7 @@ Lex_input_stream::unescape(CHARSET_INFO *cs, char *to,
bool Lex_input_stream::get_text(Lex_string_with_metadata_st *dst, uint sep,
int pre_skip, int post_skip)
{
- reg1 uchar c;
+ uchar c;
uint found_escape=0;
CHARSET_INFO *cs= m_thd->charset();
@@ -1261,7 +1261,7 @@ static inline uint int_token(const char *str,uint length)
*/
bool consume_comment(Lex_input_stream *lip, int remaining_recursions_permitted)
{
- reg1 uchar c;
+ uchar c;
while (! lip->eof())
{
c= lip->yyGet();
@@ -1405,7 +1405,7 @@ int ORAlex(YYSTYPE *yylval, THD *thd)
static int lex_one_token(YYSTYPE *yylval, THD *thd)
{
- reg1 uchar UNINIT_VAR(c);
+ uchar UNINIT_VAR(c);
bool comment_closed;
int tokval, result_state;
uint length;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 2593bac7462..6e0d2b0ba0a 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -8145,7 +8145,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
List<String> *partition_names,
LEX_STRING *option)
{
- register TABLE_LIST *ptr;
+ TABLE_LIST *ptr;
TABLE_LIST *UNINIT_VAR(previous_table_ref); /* The table preceding the current one. */
LEX_CSTRING alias_str;
LEX *lex= thd->lex;
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 634c120511a..f9a713f34cb 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2005, 2017, Oracle and/or its affiliates.
- Copyright (c) 2009, 2017, SkySQL Ab.
+ Copyright (c) 2009, 2018, 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
@@ -6785,7 +6785,7 @@ static void alter_partition_lock_handling(ALTER_PARTITION_PARAM_TYPE *lpt)
thd->set_stmt_da(&tmp_stmt_da);
}
- if (thd->locked_tables_list.reopen_tables(thd))
+ if (thd->locked_tables_list.reopen_tables(thd, false))
sql_print_warning("We failed to reacquire LOCKs in ALTER TABLE");
if (stmt_da)
@@ -6991,7 +6991,7 @@ err_exclusive_lock:
thd->set_stmt_da(&tmp_stmt_da);
}
- if (thd->locked_tables_list.reopen_tables(thd))
+ if (thd->locked_tables_list.reopen_tables(thd, false))
sql_print_warning("We failed to reacquire LOCKs in ALTER TABLE");
if (stmt_da)
diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc
index 6e176a40e6c..fa7d8eac80e 100644
--- a/sql/sql_partition_admin.cc
+++ b/sql/sql_partition_admin.cc
@@ -630,7 +630,7 @@ bool Sql_cmd_alter_table_exchange_partition::
better to keep master/slave in consistent state. Alternative would be to
try to revert the exchange operation and issue error.
*/
- (void) thd->locked_tables_list.reopen_tables(thd);
+ (void) thd->locked_tables_list.reopen_tables(thd, false);
if ((error= write_bin_log(thd, TRUE, thd->query(), thd->query_length())))
{
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 605f96293d3..3bc3d132455 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2005, 2013, Oracle and/or its affiliates.
- Copyright (c) 2010, 2017, MariaDB Corporation.
+ Copyright (c) 2005, 2018, Oracle and/or its affiliates.
+ Copyright (c) 2010, 2018, MariaDB Corporation
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
@@ -2330,6 +2330,16 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_CSTRING *name,
if (! (table= open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT)))
DBUG_RETURN(TRUE);
+ if (!table->key_info)
+ {
+ my_printf_error(ER_UNKNOWN_ERROR,
+ "The table %s.%s has no primary key. "
+ "Please check the table definition and "
+ "create the primary key accordingly.", MYF(0),
+ table->s->db.str, table->s->table_name.str);
+ DBUG_RETURN(TRUE);
+ }
+
/*
Pre-acquire audit plugins for events that may potentially occur
during [UN]INSTALL PLUGIN.
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 24f3cc66c6b..1cde0aad0fa 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -427,7 +427,7 @@ static bool send_prep_stmt(Prepared_statement *stmt,
static ulong get_param_length(uchar **packet, ulong len)
{
- reg1 uchar *pos= *packet;
+ uchar *pos= *packet;
if (len < 1)
return 0;
if (*pos < 251)
diff --git a/sql/sql_priv.h b/sql/sql_priv.h
index ba37d933f12..e48b6195bb7 100644
--- a/sql/sql_priv.h
+++ b/sql/sql_priv.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2014, Oracle and/or its affiliates.
- Copyright (c) 2010, 2014, Monty Program Ab.
+/* Copyright (c) 2000, 2018, Oracle and/or its affiliates.
+ Copyright (c) 2010, 2018, Monty Program 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
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 796ea569e64..9a36ef725cc 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -351,7 +351,7 @@ bool handle_select(THD *thd, LEX *lex, select_result *result,
ulong setup_tables_done_option)
{
bool res;
- register SELECT_LEX *select_lex = &lex->select_lex;
+ SELECT_LEX *select_lex = &lex->select_lex;
DBUG_ENTER("handle_select");
MYSQL_SELECT_START(thd->query());
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index e62a49f71ea..ec0f5582ab0 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -2617,7 +2617,7 @@ int collect_statistics_for_index(THD *thd, TABLE *table, uint index)
DBUG_ENTER("collect_statistics_for_index");
/* No statistics for FULLTEXT indexes. */
- if (key_info->flags & HA_FULLTEXT)
+ if (key_info->flags & (HA_FULLTEXT|HA_SPATIAL))
DBUG_RETURN(rc);
Index_prefix_calc index_prefix_calc(thd, table, key_info);
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 390abe36b6c..edf6c776f68 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -667,8 +667,8 @@ int String::strstr(const String &s,uint32 offset)
if (!s.length())
return ((int) offset); // Empty string is always found
- register const char *str = Ptr+offset;
- register const char *search=s.ptr();
+ const char *str = Ptr+offset;
+ const char *search=s.ptr();
const char *end=Ptr+str_length-s.length()+1;
const char *search_end=s.ptr()+s.length();
skip:
@@ -676,7 +676,7 @@ skip:
{
if (*str++ == *search)
{
- register char *i,*j;
+ char *i,*j;
i=(char*) str; j=(char*) search+1;
while (j != search_end)
if (*i++ != *j++) goto skip;
@@ -697,8 +697,8 @@ int String::strrstr(const String &s,uint32 offset)
{
if (!s.length())
return offset; // Empty string is always found
- register const char *str = Ptr+offset-1;
- register const char *search=s.ptr()+s.length()-1;
+ const char *str = Ptr+offset-1;
+ const char *search=s.ptr()+s.length()-1;
const char *end=Ptr+s.length()-2;
const char *search_end=s.ptr()-1;
@@ -707,7 +707,7 @@ skip:
{
if (*str-- == *search)
{
- register char *i,*j;
+ char *i,*j;
i=(char*) str; j=(char*) search-1;
while (j != search_end)
if (*i-- != *j--) goto skip;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 448d095c876..245f59a973a 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2016, Oracle and/or its affiliates.
- Copyright (c) 2010, 2017, MariaDB Corporation.
+ Copyright (c) 2010, 2018, 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
@@ -5173,7 +5173,7 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table,
This should always work as we have a meta lock on the table.
*/
thd->locked_tables_list.add_back_last_deleted_lock(pos_in_locked_tables);
- if (thd->locked_tables_list.reopen_tables(thd))
+ if (thd->locked_tables_list.reopen_tables(thd, false))
{
thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0);
result= 1;
@@ -5625,7 +5625,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
This should always work as we have a meta lock on the table.
*/
thd->locked_tables_list.add_back_last_deleted_lock(pos_in_locked_tables);
- if (thd->locked_tables_list.reopen_tables(thd))
+ if (thd->locked_tables_list.reopen_tables(thd, false))
{
thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0);
res= 1; // We got an error
@@ -7633,7 +7633,7 @@ static bool mysql_inplace_alter_table(THD *thd,
HA_EXTRA_PREPARE_FOR_RENAME :
HA_EXTRA_NOT_USED,
NULL);
- if (thd->locked_tables_list.reopen_tables(thd))
+ if (thd->locked_tables_list.reopen_tables(thd, false))
thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0);
/* QQ; do something about metadata locks ? */
}
@@ -9967,7 +9967,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, const LEX_CSTRING *n
end_inplace:
- if (thd->locked_tables_list.reopen_tables(thd))
+ if (thd->locked_tables_list.reopen_tables(thd, false))
goto err_with_mdl_after_alter;
THD_STAGE_INFO(thd, stage_end);
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index d523779cda7..5b218a1e36a 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -1,5 +1,6 @@
/*
Copyright (c) 2004, 2012, Oracle and/or its affiliates.
+ Copyright (c) 2010, 2018, 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
@@ -588,7 +589,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
Ignore the return value for now. It's better to
keep master/slave in consistent state.
*/
- if (thd->locked_tables_list.reopen_tables(thd))
+ if (thd->locked_tables_list.reopen_tables(thd, false))
thd->clear_error();
/*
diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc
index 2ddb4bc042c..249a6e21ffc 100644
--- a/sql/sql_truncate.cc
+++ b/sql/sql_truncate.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2010, 2015, Oracle and/or its affiliates.
- Copyright (c) 2013, 2015, MariaDB
+ Copyright (c) 2012, 2018, 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
@@ -427,7 +427,7 @@ bool Sql_cmd_truncate_table::truncate_table(THD *thd, TABLE_LIST *table_ref)
*/
error= dd_recreate_table(thd, table_ref->db.str, table_ref->table_name.str);
- if (thd->locked_tables_mode && thd->locked_tables_list.reopen_tables(thd))
+ if (thd->locked_tables_mode && thd->locked_tables_list.reopen_tables(thd, false))
thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0);
/* No need to binlog a failed truncate-by-recreate. */
@@ -500,4 +500,3 @@ bool Sql_cmd_truncate_table::execute(THD *thd)
DBUG_RETURN(res);
}
-
diff --git a/sql/table.cc b/sql/table.cc
index 577ed20a87e..39e38462ac3 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
- Copyright (c) 2008, 2016, MariaDB
+/* Copyright (c) 2000, 2017, Oracle and/or its affiliates.
+ Copyright (c) 2008, 2018, 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
@@ -3539,7 +3539,7 @@ partititon_err:
table TABLE object to free
*/
-int closefrm(register TABLE *table)
+int closefrm(TABLE *table)
{
int error=0;
DBUG_ENTER("closefrm");
@@ -3576,7 +3576,7 @@ int closefrm(register TABLE *table)
/* Deallocate temporary blob storage */
-void free_blobs(register TABLE *table)
+void free_blobs(TABLE *table)
{
uint *ptr, *end;
for (ptr= table->s->blob_field, end=ptr + table->s->blob_fields ;
@@ -4195,7 +4195,7 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def)
/* Whether the table definition has already been validated. */
if (table->s->table_field_def_cache == table_def)
- DBUG_RETURN(FALSE);
+ goto end;
if (table->s->fields != table_def->count)
{
@@ -4228,6 +4228,8 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def)
is backward compatible.
*/
}
+ else
+ {
StringBuffer<1024> sql_type(system_charset_info);
sql_type.extra_allocation(256); // Allocate min 256 characters at once
for (i=0 ; i < table_def->count; i++, field_def++)
@@ -4313,6 +4315,7 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def)
error= TRUE;
}
}
+ }
if (table_def->primary_key_parts)
{
@@ -4357,6 +4360,16 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def)
if (! error)
table->s->table_field_def_cache= table_def;
+end:
+
+ if (has_keys && !error && !table->key_info)
+ {
+ report_error(0, "Incorrect definition of table %s.%s: "
+ "indexes are missing",
+ table->s->db.str, table->alias.c_ptr());
+ error= TRUE;
+ }
+
DBUG_RETURN(error);
}
diff --git a/sql/table.h b/sql/table.h
index ac382e5aa94..30588be762c 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -1,8 +1,7 @@
#ifndef TABLE_INCLUDED
#define TABLE_INCLUDED
-/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
- Copyright (c) 2009, 2014, SkySQL Ab.
- Copyright (c) 2016, 2017, MariaDB Corporation.
+/* Copyright (c) 2000, 2017, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2018, 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
@@ -487,10 +486,11 @@ typedef struct st_table_field_def
class Table_check_intact
{
protected:
+ bool has_keys;
virtual void report_error(uint code, const char *fmt, ...)= 0;
public:
- Table_check_intact() {}
+ Table_check_intact(bool keys= false) : has_keys(keys) {}
virtual ~Table_check_intact() {}
/** Checks whether a table is intact. */
@@ -505,6 +505,8 @@ class Table_check_intact_log_error : public Table_check_intact
{
protected:
void report_error(uint, const char *fmt, ...);
+public:
+ Table_check_intact_log_error() : Table_check_intact(true) {}
};
diff --git a/sql/uniques.cc b/sql/uniques.cc
index 8ed1ceda6a1..86d8d6c7050 100644
--- a/sql/uniques.cc
+++ b/sql/uniques.cc
@@ -209,7 +209,7 @@ static double get_merge_many_buffs_cost(uint *buffer,
uint last_n_elems, int elem_size,
uint compare_factor)
{
- register int i;
+ int i;
double total_cost= 0.0;
uint *buff_elems= buffer; /* #s of elements in each of merged sequences */
diff --git a/sql/uniques.h b/sql/uniques.h
index efc79953bb6..654b3692aaa 100644
--- a/sql/uniques.h
+++ b/sql/uniques.h
@@ -77,7 +77,7 @@ public:
inline static int get_cost_calc_buff_size(size_t nkeys, uint key_size,
size_t max_in_memory_size)
{
- register size_t max_elems_in_tree=
+ size_t max_elems_in_tree=
max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+key_size);
return (int) (sizeof(uint)*(1 + nkeys/max_elems_in_tree));
}