summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-01-07 20:21:05 +0100
committerSergei Golubchik <sergii@pisem.net>2013-01-07 20:21:05 +0100
commit78d9fdb134c58ccf792fdec2bb745cb5ff6ec2ec (patch)
tree2689fb85c1810d5561dae251c37f7aa0f5dd3a29 /sql
parentac45f3b38a2098a0a29fd53f023866d6c0dce78d (diff)
downloadmariadb-git-78d9fdb134c58ccf792fdec2bb745cb5ff6ec2ec.tar.gz
non-functional cleanup, clarifying CONVERT_IF_BIGGER_TO_BLOB
Diffstat (limited to 'sql')
-rw-r--r--sql/item.cc6
-rw-r--r--sql/item.h2
-rw-r--r--sql/item_sum.h2
-rw-r--r--sql/opt_subselect.cc4
-rw-r--r--sql/sql_const.h4
-rw-r--r--sql/sql_select.cc2
6 files changed, 11 insertions, 9 deletions
diff --git a/sql/item.cc b/sql/item.cc
index bc98a9a3184..8be339541e1 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -5579,7 +5579,7 @@ bool Item::eq_by_collation(Item *item, bool binary_cmp, CHARSET_INFO *cs)
/**
Create a field to hold a string value from an item.
- If max_length > CONVERT_IF_BIGGER_TO_BLOB create a blob @n
+ If too_big_for_varchar() create a blob @n
If max_length > 0 create a varchar @n
If max_length == 0 create a CHAR(0)
@@ -5594,7 +5594,7 @@ Field *Item::make_string_field(TABLE *table)
Note: the following check is repeated in
subquery_types_allow_materialization():
*/
- if (max_length/collation.collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB)
+ if (too_big_for_varchar())
field= new Field_blob(max_length, maybe_null, name,
collation.collation, TRUE);
/* Item_type_holder holds the exact type, do not change it */
@@ -5699,7 +5699,7 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, bool fixed_length)
DBUG_ASSERT(0);
/* If something goes awfully wrong, it's better to get a string than die */
case MYSQL_TYPE_STRING:
- if (fixed_length && max_length < CONVERT_IF_BIGGER_TO_BLOB)
+ if (fixed_length && !too_big_for_varchar())
{
field= new Field_string(max_length, maybe_null, name,
collation.collation);
diff --git a/sql/item.h b/sql/item.h
index 3136bb00394..42815c34286 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -1424,6 +1424,8 @@ public:
bool eq_by_collation(Item *item, bool binary_cmp, CHARSET_INFO *cs);
uint32 max_char_length() const
{ return max_length / collation.collation->mbmaxlen; }
+ bool too_big_for_varchar() const
+ { return max_char_length() > CONVERT_IF_BIGGER_TO_BLOB; }
void fix_length_and_charset(uint32 max_char_length_arg, CHARSET_INFO *cs)
{
max_length= char_to_byte_length_safe(max_char_length_arg, cs->mbmaxlen);
diff --git a/sql/item_sum.h b/sql/item_sum.h
index c8dce60c7d4..40a28d8beae 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -1439,7 +1439,7 @@ public:
virtual Field *make_string_field(TABLE *table);
enum_field_types field_type() const
{
- if (max_length/collation.collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB )
+ if (too_big_for_varchar())
return MYSQL_TYPE_BLOB;
else
return MYSQL_TYPE_VARCHAR;
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index e70e5a784ba..753722fac08 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -853,8 +853,7 @@ bool subquery_types_allow_materialization(Item_in_subselect *in_subs)
create a blob column because item->max_length is too big.
The following check is copied from Item::make_string_field():
*/
- if (inner->max_length / inner->collation.collation->mbmaxlen >
- CONVERT_IF_BIGGER_TO_BLOB)
+ if (inner->too_big_for_varchar())
{
DBUG_RETURN(FALSE);
}
@@ -3865,6 +3864,7 @@ SJ_TMP_TABLE::create_sj_weedout_tmp_table(THD *thd)
fn_format(path, path, mysql_tmpdir, "", MY_REPLACE_EXT|MY_UNPACK_FILENAME);
/* STEP 2: Figure if we'll be using a key or blob+constraint */
+ /* it always has my_charset_bin, so mbmaxlen==1 */
if (uniq_tuple_length_arg >= CONVERT_IF_BIGGER_TO_BLOB)
using_unique_constraint= TRUE;
diff --git a/sql/sql_const.h b/sql/sql_const.h
index cfbf077bd91..de2704a8553 100644
--- a/sql/sql_const.h
+++ b/sql/sql_const.h
@@ -42,8 +42,8 @@
#define MAX_MBWIDTH 3 /* Max multibyte sequence */
#define MAX_FIELD_CHARLENGTH 255
#define MAX_FIELD_VARCHARLENGTH 65535
-#define MAX_FIELD_BLOBLENGTH UINT_MAX32 /* cf field_blob::get_length() */
-#define CONVERT_IF_BIGGER_TO_BLOB 512 /* Used for CREATE ... SELECT */
+#define MAX_FIELD_BLOBLENGTH UINT_MAX32 /* cf field_blob::get_length() */
+#define CONVERT_IF_BIGGER_TO_BLOB 512 /* Threshold *in characters* */
/* Max column width +1 */
#define MAX_FIELD_WIDTH (MAX_FIELD_CHARLENGTH*MAX_MBWIDTH+1)
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 8914341e0f3..424d2d4a56b 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -14185,7 +14185,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
can't index BIT fields.
*/
(*tmp->item)->marker=4; // Store null in key
- if ((*tmp->item)->max_length >= CONVERT_IF_BIGGER_TO_BLOB)
+ if ((*tmp->item)->too_big_for_varchar())
using_unique_constraint=1;
}
if (param->group_length >= MAX_BLOB_WIDTH)