summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2018-12-29 23:44:45 +0100
committerSergei Golubchik <serg@mariadb.org>2018-12-29 23:44:45 +0100
commitaeefd26ecb1089678e343c64998749e9f2e3a1e4 (patch)
treea96f5fdff65a6d0a05d195a74a32bbb4aa0a58c1 /sql
parent50c9469be821e1942a8a9c5f37132e1855c40c86 (diff)
parent802ce9672ff630bbef08235e0e39bf599075f985 (diff)
downloadmariadb-git-aeefd26ecb1089678e343c64998749e9f2e3a1e4.tar.gz
Merge branch '10.0' into 10.1
Diffstat (limited to 'sql')
-rw-r--r--sql/handler.h12
-rw-r--r--sql/opt_range.cc4
-rw-r--r--sql/partition_info.cc4
-rw-r--r--sql/sql_const.h12
-rw-r--r--sql/sql_db.cc9
-rw-r--r--sql/sql_db.h3
-rw-r--r--sql/sql_parse.cc1
-rw-r--r--sql/sql_select.cc4
-rw-r--r--sql/table.cc8
9 files changed, 39 insertions, 18 deletions
diff --git a/sql/handler.h b/sql/handler.h
index 42429e9dcbe..792cce281f6 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -382,6 +382,12 @@ enum enum_alter_inplace_result {
#define HA_KEY_NULL_LENGTH 1
#define HA_KEY_BLOB_LENGTH 2
+/* Maximum length of any index lookup key, in bytes */
+
+#define MAX_KEY_LENGTH (MAX_DATA_LENGTH_FOR_KEY \
+ +(MAX_REF_PARTS \
+ *(HA_KEY_NULL_LENGTH + HA_KEY_BLOB_LENGTH)))
+
#define HA_LEX_CREATE_TMP_TABLE 1
#define HA_CREATE_TMP_ALTER 8
@@ -3371,14 +3377,14 @@ public:
uint max_key_parts() const
{ return MY_MIN(MAX_REF_PARTS, max_supported_key_parts()); }
uint max_key_length() const
- { return MY_MIN(MAX_KEY_LENGTH, max_supported_key_length()); }
+ { return MY_MIN(MAX_DATA_LENGTH_FOR_KEY, max_supported_key_length()); }
uint max_key_part_length() const
- { return MY_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); }
+ { return MY_MIN(MAX_DATA_LENGTH_FOR_KEY, max_supported_key_part_length()); }
virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
virtual uint max_supported_keys() const { return 0; }
virtual uint max_supported_key_parts() const { return MAX_REF_PARTS; }
- virtual uint max_supported_key_length() const { return MAX_KEY_LENGTH; }
+ virtual uint max_supported_key_length() const { return MAX_DATA_LENGTH_FOR_KEY; }
virtual uint max_supported_key_part_length() const { return 255; }
virtual uint min_record_length(uint options) const { return 1; }
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 41d74611abc..072f607fb51 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -2734,10 +2734,6 @@ bool create_key_parts_for_pseudo_indexes(RANGE_OPT_PARAM *param,
{
Field **field_ptr;
TABLE *table= param->table;
- partition_info *part_info= NULL;
- #ifdef WITH_PARTITION_STORAGE_ENGINE
- part_info= table->part_info;
- #endif
uint parts= 0;
for (field_ptr= table->field; *field_ptr; field_ptr++)
diff --git a/sql/partition_info.cc b/sql/partition_info.cc
index 74a1c2a267a..c633ea708d0 100644
--- a/sql/partition_info.cc
+++ b/sql/partition_info.cc
@@ -1987,12 +1987,12 @@ bool partition_info::check_partition_field_length()
for (i= 0; i < num_part_fields; i++)
store_length+= get_partition_field_store_length(part_field_array[i]);
- if (store_length > MAX_KEY_LENGTH)
+ if (store_length > MAX_DATA_LENGTH_FOR_KEY)
DBUG_RETURN(TRUE);
store_length= 0;
for (i= 0; i < num_subpart_fields; i++)
store_length+= get_partition_field_store_length(subpart_field_array[i]);
- if (store_length > MAX_KEY_LENGTH)
+ if (store_length > MAX_DATA_LENGTH_FOR_KEY)
DBUG_RETURN(TRUE);
DBUG_RETURN(FALSE);
}
diff --git a/sql/sql_const.h b/sql/sql_const.h
index 0cd214d8bc7..1d6549f777f 100644
--- a/sql/sql_const.h
+++ b/sql/sql_const.h
@@ -33,7 +33,17 @@
#define MAX_SYS_VAR_LENGTH 32
#define MAX_KEY MAX_INDEXES /* Max used keys */
#define MAX_REF_PARTS 32 /* Max parts used as ref */
-#define MAX_KEY_LENGTH 3072 /* max possible key */
+
+/*
+ Maximum length of the data part of an index lookup key.
+
+ The "data part" is defined as the value itself, not including the
+ NULL-indicator bytes or varchar length bytes ("the Extras"). We need this
+ value because there was a bug where length of the Extras were not counted.
+
+ You probably need MAX_KEY_LENGTH, not this constant.
+*/
+#define MAX_DATA_LENGTH_FOR_KEY 3072
#if SIZEOF_OFF_T > 4
#define MAX_REFLENGTH 8 /* Max length for record ref */
#else
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index f626b4e6112..d7ed82a2ef3 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -771,8 +771,7 @@ exit:
}
-int mysql_create_db(THD *thd, char *db,
- const DDL_options_st &options,
+int mysql_create_db(THD *thd, char *db, DDL_options_st options,
const Schema_specification_st *create_info)
{
/*
@@ -780,6 +779,9 @@ int mysql_create_db(THD *thd, char *db,
to it, we need to use a copy to make execution prepared statement- safe.
*/
Schema_specification_st tmp(*create_info);
+ if (thd->slave_thread &&
+ slave_ddl_exec_mode_options == SLAVE_EXEC_MODE_IDEMPOTENT)
+ options.add(DDL_options::OPT_IF_NOT_EXISTS);
return mysql_create_db_internal(thd, db, options, &tmp, false);
}
@@ -1059,6 +1061,9 @@ exit:
bool mysql_rm_db(THD *thd,char *db, bool if_exists)
{
+ if (thd->slave_thread &&
+ slave_ddl_exec_mode_options == SLAVE_EXEC_MODE_IDEMPOTENT)
+ if_exists= true;
return mysql_rm_db_internal(thd, db, if_exists, false);
}
diff --git a/sql/sql_db.h b/sql/sql_db.h
index b0d99cc1ba4..ed8417a7793 100644
--- a/sql/sql_db.h
+++ b/sql/sql_db.h
@@ -20,8 +20,7 @@
class THD;
-int mysql_create_db(THD *thd, char *db,
- const DDL_options_st &options,
+int mysql_create_db(THD *thd, char *db, DDL_options_st options,
const Schema_specification_st *create);
bool mysql_alter_db(THD *thd, const char *db,
const Schema_specification_st *create);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index a73c3c22ba8..3f6ce8356ce 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1198,6 +1198,7 @@ static bool deny_updates_if_read_only_option(THD *thd, TABLE_LIST *all_tables)
DBUG_RETURN(FALSE);
if (lex->sql_command == SQLCOM_CREATE_DB ||
+ lex->sql_command == SQLCOM_ALTER_DB ||
lex->sql_command == SQLCOM_DROP_DB)
DBUG_RETURN(TRUE);
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 62f40eeb99c..155e261ac34 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -19361,6 +19361,10 @@ test_if_quick_select(JOIN_TAB *tab)
delete tab->select->quick;
tab->select->quick=0;
+
+ if (tab->table->file->inited != handler::NONE)
+ tab->table->file->ha_index_or_rnd_end();
+
int res= tab->select->test_quick_select(tab->join->thd, tab->keys,
(table_map) 0, HA_POS_ERROR, 0,
FALSE, /*remove where parts*/FALSE);
diff --git a/sql/table.cc b/sql/table.cc
index e1edcc0b407..ca06eee077c 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1851,7 +1851,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
uint pk_part_length= key_first_info->key_part[i].store_length;
if (keyinfo->ext_key_part_map & 1<<i)
{
- if (ext_key_length + pk_part_length > MAX_KEY_LENGTH)
+ if (ext_key_length + pk_part_length > MAX_DATA_LENGTH_FOR_KEY)
{
add_keyparts_for_this_key= i;
break;
@@ -1861,9 +1861,9 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
}
}
- if (add_keyparts_for_this_key < (keyinfo->ext_key_parts -
- keyinfo->user_defined_key_parts))
- {
+ if (add_keyparts_for_this_key < keyinfo->ext_key_parts -
+ keyinfo->user_defined_key_parts)
+ {
share->ext_key_parts-= keyinfo->ext_key_parts;
key_part_map ext_key_part_map= keyinfo->ext_key_part_map;
keyinfo->ext_key_parts= keyinfo->user_defined_key_parts;