diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-01-07 20:21:05 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-01-07 20:21:05 +0100 |
commit | 78d9fdb134c58ccf792fdec2bb745cb5ff6ec2ec (patch) | |
tree | 2689fb85c1810d5561dae251c37f7aa0f5dd3a29 | |
parent | ac45f3b38a2098a0a29fd53f023866d6c0dce78d (diff) | |
download | mariadb-git-78d9fdb134c58ccf792fdec2bb745cb5ff6ec2ec.tar.gz |
non-functional cleanup, clarifying CONVERT_IF_BIGGER_TO_BLOB
-rw-r--r-- | mysql-test/r/ctype_utf16.result | 8 | ||||
-rw-r--r-- | mysql-test/r/ctype_utf8.result | 8 | ||||
-rw-r--r-- | mysql-test/t/ctype_utf16.test | 4 | ||||
-rw-r--r-- | mysql-test/t/ctype_utf8.test | 5 | ||||
-rw-r--r-- | mysql-test/t/func_gconcat.test | 2 | ||||
-rw-r--r-- | sql/item.cc | 6 | ||||
-rw-r--r-- | sql/item.h | 2 | ||||
-rw-r--r-- | sql/item_sum.h | 2 | ||||
-rw-r--r-- | sql/opt_subselect.cc | 4 | ||||
-rw-r--r-- | sql/sql_const.h | 4 | ||||
-rw-r--r-- | sql/sql_select.cc | 2 |
11 files changed, 37 insertions, 10 deletions
diff --git a/mysql-test/r/ctype_utf16.result b/mysql-test/r/ctype_utf16.result index f0e6ea5f1ad..2eb0f8e9ba6 100644 --- a/mysql-test/r/ctype_utf16.result +++ b/mysql-test/r/ctype_utf16.result @@ -1140,6 +1140,14 @@ id l a 512 Warnings: Warning 1260 Row 1 was cut by GROUP_CONCAT() +SELECT id, CHAR_LENGTH(GROUP_CONCAT(body)) AS l +FROM (SELECT 'a' AS id, REPEAT('foo bar', 100) AS body +UNION ALL +SELECT 'a' AS id, REPEAT('bla bla', 100) AS body) t1; +id l +a 512 +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() # # End of 5.5 tests # diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 69e32977103..d25c454913d 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -5055,6 +5055,14 @@ id l a 1024 Warnings: Warning 1260 Row 2 was cut by GROUP_CONCAT() +SELECT id, CHAR_LENGTH(GROUP_CONCAT(body)) AS l +FROM (SELECT 'a' AS id, REPEAT('foo bar', 100) AS body +UNION ALL +SELECT 'a' AS id, REPEAT('bla bla', 100) AS body) t1; +id l +a 1024 +Warnings: +Warning 1260 Row 2 was cut by GROUP_CONCAT() # # End of 5.5 tests # diff --git a/mysql-test/t/ctype_utf16.test b/mysql-test/t/ctype_utf16.test index 847e302e615..f42d30e1f00 100644 --- a/mysql-test/t/ctype_utf16.test +++ b/mysql-test/t/ctype_utf16.test @@ -777,6 +777,10 @@ SELECT 'a' AS id, REPEAT('bla bla', 100) AS body) t1 GROUP BY id ORDER BY l DESC; +SELECT id, CHAR_LENGTH(GROUP_CONCAT(body)) AS l +FROM (SELECT 'a' AS id, REPEAT('foo bar', 100) AS body +UNION ALL +SELECT 'a' AS id, REPEAT('bla bla', 100) AS body) t1; # ## TODO: add tests for all engines diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 210589adc81..0b90f222593 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -1590,6 +1590,11 @@ SELECT 'a' AS id, REPEAT('bla bla', 100) AS body) t1 GROUP BY id ORDER BY l DESC; +SELECT id, CHAR_LENGTH(GROUP_CONCAT(body)) AS l +FROM (SELECT 'a' AS id, REPEAT('foo bar', 100) AS body +UNION ALL +SELECT 'a' AS id, REPEAT('bla bla', 100) AS body) t1; + --echo # --echo # End of 5.5 tests --echo # diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index e4a1206fa9c..f84c112d303 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -375,7 +375,7 @@ select group_concat('x') UNION ALL select 1; drop table t1; # -# Bug #12863 : missing separators after first empty cancatanated elements +# Bug #12863 : missing separators after first empty concatenated elements # CREATE TABLE t1 (id int, a varchar(9)); 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) |