summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2019-06-10 13:59:45 +0400
committerAlexander Barkov <bar@mariadb.com>2019-06-10 13:59:45 +0400
commit163665640afb153c173d272eae98b0b63950cd83 (patch)
treecbcf8a1c573ba7241a719cdc39a9775134d573a8
parentb685109596568beed1635211bf80eef34ce9d146 (diff)
downloadmariadb-git-163665640afb153c173d272eae98b0b63950cd83.tar.gz
MDEV-19724 Add Field::tmp_engine_column_type()
-rw-r--r--sql/field.cc6
-rw-r--r--sql/field.h18
-rw-r--r--sql/opt_subselect.cc10
-rw-r--r--sql/sql_select.cc12
4 files changed, 26 insertions, 20 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 2c35a48e81f..6813943c5f4 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -7529,6 +7529,12 @@ Field *Field_string::make_new_field(MEM_ROOT *root, TABLE *new_table,
}
+en_fieldtype Field_string::tmp_engine_column_type(bool use_packed_rows) const
+{
+ return field_length >= MIN_STRING_LENGTH_TO_PACK_ROWS ? FIELD_SKIP_ENDSPACE :
+ FIELD_NORMAL;
+}
+
/****************************************************************************
VARCHAR type
Data in field->ptr is stored as:
diff --git a/sql/field.h b/sql/field.h
index 38a5b1f7127..cb4f0321c9d 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1125,6 +1125,10 @@ public:
*/
return type();
}
+ virtual en_fieldtype tmp_engine_column_type(bool use_packed_rows) const
+ {
+ return FIELD_NORMAL;
+ }
/*
Conversion type for from the source to the current field.
*/
@@ -3647,6 +3651,7 @@ public:
}
enum ha_base_keytype key_type() const
{ return binary() ? HA_KEYTYPE_BINARY : HA_KEYTYPE_TEXT; }
+ en_fieldtype tmp_engine_column_type(bool use_packed_rows) const;
bool zero_pack() const { return 0; }
Copy_func *get_copy_func(const Field *from) const;
int reset(void)
@@ -3747,6 +3752,10 @@ public:
}
const Type_handler *type_handler() const { return &type_handler_varchar; }
+ en_fieldtype tmp_engine_column_type(bool use_packed_rows) const
+ {
+ return FIELD_VARCHAR;
+ }
enum ha_base_keytype key_type() const;
uint16 key_part_flag() const { return HA_VAR_LENGTH_PART; }
uint16 key_part_length_bytes() const { return HA_KEY_BLOB_LENGTH; }
@@ -3967,6 +3976,10 @@ public:
{ return binary() ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2; }
uint16 key_part_flag() const { return HA_BLOB_PART; }
uint16 key_part_length_bytes() const { return HA_KEY_BLOB_LENGTH; }
+ en_fieldtype tmp_engine_column_type(bool use_packed_rows) const
+ {
+ return FIELD_BLOB;
+ }
Type_std_attributes type_std_attributes() const
{
return Type_std_attributes(Field_blob::max_display_length(), decimals(),
@@ -4632,6 +4645,11 @@ public:
m_table(NULL)
{}
~Field_row();
+ en_fieldtype tmp_engine_column_type(bool use_packed_rows) const
+ {
+ DBUG_ASSERT(0);
+ return Field::tmp_engine_column_type(use_packed_rows);
+ }
enum_conv_type rpl_conv_type_from(const Conv_source &source,
const Relay_log_info *rli,
const Conv_param &param) const
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index 02d221d13b0..f00d0ed019d 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -4483,15 +4483,7 @@ SJ_TMP_TABLE::create_sj_weedout_tmp_table(THD *thd)
/* Make entry for create table */
recinfo->length=length;
- if (field->flags & BLOB_FLAG)
- recinfo->type= FIELD_BLOB;
- else if (use_packed_rows &&
- field->real_type() == MYSQL_TYPE_STRING &&
- length >= MIN_STRING_LENGTH_TO_PACK_ROWS)
- recinfo->type=FIELD_SKIP_ENDSPACE;
- else
- recinfo->type=FIELD_NORMAL;
-
+ recinfo->type= field->tmp_engine_column_type(use_packed_rows);
field->set_table_name(&table->alias);
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 12b522f67e3..7e2e2a1365a 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -18378,17 +18378,7 @@ bool Create_tmp_table::finalize(THD *thd,
/* Make entry for create table */
recinfo->length=length;
- if (field->flags & BLOB_FLAG)
- recinfo->type= FIELD_BLOB;
- else if (use_packed_rows &&
- field->real_type() == MYSQL_TYPE_STRING &&
- length >= MIN_STRING_LENGTH_TO_PACK_ROWS)
- recinfo->type= FIELD_SKIP_ENDSPACE;
- else if (field->real_type() == MYSQL_TYPE_VARCHAR)
- recinfo->type= FIELD_VARCHAR;
- else
- recinfo->type= FIELD_NORMAL;
-
+ recinfo->type= field->tmp_engine_column_type(use_packed_rows);
if (!--m_hidden_field_count)
m_null_count= (m_null_count + 7) & ~7; // move to next byte