Below is the list of changes that have just been committed into a local
5.0 repository of bar. When bar does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-06-13 17:18:21+05:00, bar@stripped +14 -0
Bug#28875 Conversion between ASCII and LATIN1 charsets does not function
(Regression, caused by a patch for the bug 22646).
Problem: when result type of date_format() was changed from
binary string to character string, mixing date_format()
with a ascii column in CONCAT() stopped to work.
Fix:
- adding "repertoire" flag into DTCollation class,
to mark items which can return only pure ASCII strings.
- allow character set conversion from pure ASCII to other character sets.
include/m_ctype.h@stripped, 2007-06-13 17:18:19+05:00, bar@stripped +5 -0
Defining new flags.
include/my_sys.h@stripped, 2007-06-13 17:18:19+05:00, bar@stripped +1 -0
Adding new function prototype.
mysql-test/r/ctype_ucs.result@stripped, 2007-06-13 17:18:19+05:00, bar@stripped +26 -0
Adding test cases.
mysql-test/r/func_time.result@stripped, 2007-06-13 17:18:19+05:00, bar@stripped +12 -0
Adding test cases.
mysql-test/t/ctype_ucs.test@stripped, 2007-06-13 17:18:19+05:00, bar@stripped +30 -0
Adding test cases.
mysql-test/t/func_time.test@stripped, 2007-06-13 17:18:19+05:00, bar@stripped +21 -0
Adding test cases.
mysys/charset.c@stripped, 2007-06-13 17:18:20+05:00, bar@stripped +49 -0
- Adding new function, to check if a string consists of pure ASCII.
- Adding pure ASCII detection when loading a dynamic character set.
sql/item.cc@stripped, 2007-06-13 17:18:20+05:00, bar@stripped +30 -12
- Moving detection of a Unicode superset into function.
- Adding detection of a ASCII subset.
- Adding creation of to-ASCII character set convertor when
safe_charset_converter() failed and when the argument.
repertoire is know to be pure ASCII.
sql/item.h@stripped, 2007-06-13 17:18:20+05:00, bar@stripped +31 -5
- Adding "repertoire" member into DTCollation class.
- Detect repertoire when creating Item_string.
sql/item_func.cc@stripped, 2007-06-13 17:18:20+05:00, bar@stripped +1 -1
Adding "repertoire" argument.
sql/item_strfunc.cc@stripped, 2007-06-13 17:18:20+05:00, bar@stripped +2 -1
Adding "repertoire" argument.
sql/item_timefunc.cc@stripped, 2007-06-13 17:18:20+05:00, bar@stripped +5 -1
Initializing the result repertoire taking into account the "is_ascii"
flag of the current locale.
strings/conf_to_src.c@stripped, 2007-06-13 17:18:20+05:00, bar@stripped +44 -4
- Adding detecion of "pure ascii" character sets
- Adding printing of the "MY_CS_PUREASCII" flag
- Adding printing of copyright
strings/ctype-extra.c@stripped, 2007-06-13 17:18:20+05:00, bar@stripped +4 -3
Recreating ctype-extra.c: ascii_general_ci and ascii_bin
are now marked with MY_CS_PUREASCII flag.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: bar
# Host: bar.myoffice.izhnet.ru
# Root: /home/bar/mysql-work/mysql-5.0.b28875
--- 1.128/include/m_ctype.h 2007-06-07 17:55:53 +05:00
+++ 1.129/include/m_ctype.h 2007-06-13 17:18:19 +05:00
@@ -78,7 +78,12 @@ extern MY_UNICASE_INFO *my_unicase_turki
#define MY_CS_READY 256 /* if a charset is initialized */
#define MY_CS_AVAILABLE 512 /* If either compiled-in or loaded*/
#define MY_CS_CSSORT 1024 /* if case sensitive sort order */
+#define MY_CS_PUREASCII 2048 /* if a charset is pure ascii */
#define MY_CHARSET_UNDEFINED 0
+
+/* Character repertoire flags */
+#define MY_REPERTOIRE_ASCII 1 /* Pure ASCII U+0000..U+007F */
+#define MY_REPERTOIRE_EXTENDED 2 /* ASCII + some extended U+0080..U+FFFF */
typedef struct my_uni_idx_st
--- 1.197/include/my_sys.h 2007-05-17 12:48:09 +05:00
+++ 1.198/include/my_sys.h 2007-06-13 17:18:19 +05:00
@@ -882,6 +882,7 @@ extern CHARSET_INFO *get_charset_by_csna
extern void free_charsets(void);
extern char *get_charsets_dir(char *buf);
extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2);
+extern uint my_string_repertoire(CHARSET_INFO *cs, const char *str, ulong len);
extern my_bool init_compiled_charsets(myf flags);
extern void add_compiled_collation(CHARSET_INFO *cs);
extern ulong escape_string_for_mysql(CHARSET_INFO *charset_info,
--- 1.151/mysys/charset.c 2007-06-07 17:55:53 +05:00
+++ 1.152/mysys/charset.c 2007-06-13 17:18:20 +05:00
@@ -37,6 +37,34 @@ my_bool my_charset_same(CHARSET_INFO *cs
}
+/*
+ Check repertoire: detect pure ascii strings
+*/
+uint my_string_repertoire(CHARSET_INFO *cs, const char *str, ulong length)
+{
+ const char *strend= str + length;
+ if (cs->mbminlen == 1)
+ {
+ for ( ; str < strend; str++)
+ {
+ if (((uchar) *str) > 0x7F)
+ return MY_REPERTOIRE_ASCII | MY_REPERTOIRE_EXTENDED;
+ }
+ }
+ else
+ {
+ my_wc_t wc;
+ int chlen;
+ for (; (chlen= cs->cset->mb_wc(cs, &wc, str, strend)) > 0; str+= chlen)
+ {
+ if (wc > 0x7F)
+ return MY_REPERTOIRE_ASCII | MY_REPERTOIRE_EXTENDED;
+ }
+ }
+ return MY_REPERTOIRE_ASCII;
+}
+
+
static uint
get_collation_number_internal(const char *name)
{
@@ -259,6 +287,8 @@ static int add_collation(CHARSET_INFO *c
else
{
uchar *sort_order= all_charsets[cs->number]->sort_order;
+ uint16 *tab_to_uni= all_charsets[cs->number]->tab_to_uni;
+ uint ascii_flag= 0;
simple_cs_init_functions(all_charsets[cs->number]);
newcs->mbminlen= 1;
newcs->mbmaxlen= 1;
@@ -277,6 +307,25 @@ static int add_collation(CHARSET_INFO *c
if (sort_order && sort_order['A'] < sort_order['a'] &&
sort_order['a'] < sort_order['B'])
all_charsets[cs->number]->state|= MY_CS_CSSORT;
+ /*
+ Check if character set is pure ascii,
+ for loose conversion on SQL level,
+ e.g. from ascii to latin1.
+ */
+ if (tab_to_uni)
+ {
+ uint code;
+ ascii_flag= MY_CS_PUREASCII;
+ for (code= 0; code < 256; code++)
+ {
+ if (tab_to_uni[code] > 0x7F)
+ {
+ ascii_flag= 0;
+ break;
+ }
+ }
+ }
+ all_charsets[cs->number]->state|= ascii_flag;
}
}
else
--- 1.269/sql/item.cc 2007-05-21 23:50:02 +05:00
+++ 1.270/sql/item.cc 2007-06-13 17:18:20 +05:00
@@ -1296,6 +1296,25 @@ void Item::split_sum_func2(THD *thd, Ite
}
+static bool
+left_is_superset(DTCollation *left, DTCollation *right)
+{
+ /* Allow convert to Unicode */
+ if (left->collation->state & MY_CS_UNICODE &&
+ (left->derivation < right->derivation ||
+ (left->derivation == right->derivation &&
+ !(right->collation->state & MY_CS_UNICODE))))
+ return TRUE;
+ /* Allow convert from ASCII */
+ if (right->repertoire == MY_REPERTOIRE_ASCII &&
+ (left->derivation < right->derivation ||
+ (left->derivation == right->derivation &&
+ !(left->repertoire == MY_REPERTOIRE_ASCII))))
+ return TRUE;
+ /* Disallow conversion otherwise */
+ return FALSE;
+}
+
/*
Aggregate two collations together taking
into account their coercibility (aka derivation):
@@ -1360,18 +1379,12 @@ bool DTCollation::aggregate(DTCollation
; // Do nothing
}
else if ((flags & MY_COLL_ALLOW_SUPERSET_CONV) &&
- collation->state & MY_CS_UNICODE &&
- (derivation < dt.derivation ||
- (derivation == dt.derivation &&
- !(dt.collation->state & MY_CS_UNICODE))))
+ left_is_superset(this, &dt))
{
// Do nothing
}
else if ((flags & MY_COLL_ALLOW_SUPERSET_CONV) &&
- dt.collation->state & MY_CS_UNICODE &&
- (dt.derivation < derivation ||
- (dt.derivation == derivation &&
- !(collation->state & MY_CS_UNICODE))))
+ left_is_superset(&dt, this))
{
set(dt);
}
@@ -1390,7 +1403,7 @@ bool DTCollation::aggregate(DTCollation
else
{
// Cannot apply conversion
- set(0, DERIVATION_NONE);
+ set(0, DERIVATION_NONE, 0);
return 1;
}
}
@@ -1412,8 +1425,8 @@ bool DTCollation::aggregate(DTCollation
{
if (derivation == DERIVATION_EXPLICIT)
{
- set(0, DERIVATION_NONE);
- return 1;
+ set(0, DERIVATION_NONE, 0);
+ return 1;
}
if (collation->state & MY_CS_BINSORT)
return 0;
@@ -1427,6 +1440,7 @@ bool DTCollation::aggregate(DTCollation
set(bin, DERIVATION_NONE);
}
}
+ repertoire|= dt.repertoire;
return 0;
}
@@ -1571,7 +1585,11 @@ bool agg_item_charsets(DTCollation &coll
&dummy_offset))
continue;
- if (!(conv= (*arg)->safe_charset_converter(coll.collation)))
+ if (!(conv= (*arg)->safe_charset_converter(coll.collation)) &&
+ ((*arg)->collation.repertoire == MY_REPERTOIRE_ASCII))
+ conv= new Item_func_conv_charset(*arg, coll.collation, 1);
+
+ if (!conv)
{
if (nargs >=2 && nargs <= 3)
{
--- 1.230/sql/item.h 2007-05-18 01:17:44 +05:00
+++ 1.231/sql/item.h 2007-06-13 17:18:20 +05:00
@@ -49,29 +49,51 @@ class DTCollation {
public:
CHARSET_INFO *collation;
enum Derivation derivation;
+ uint repertoire;
+ void set_repertoire_from_charset(CHARSET_INFO *cs)
+ {
+ repertoire= cs->state & MY_CS_PUREASCII ?
+ MY_REPERTOIRE_ASCII :
+ MY_REPERTOIRE_ASCII | MY_REPERTOIRE_EXTENDED;
+ }
DTCollation()
{
collation= &my_charset_bin;
derivation= DERIVATION_NONE;
+ repertoire= MY_REPERTOIRE_ASCII | MY_REPERTOIRE_EXTENDED;
}
DTCollation(CHARSET_INFO *collation_arg, Derivation derivation_arg)
{
collation= collation_arg;
derivation= derivation_arg;
+ set_repertoire_from_charset(collation_arg);
}
void set(DTCollation &dt)
{
collation= dt.collation;
derivation= dt.derivation;
+ repertoire= dt.repertoire;
}
void set(CHARSET_INFO *collation_arg, Derivation derivation_arg)
{
collation= collation_arg;
derivation= derivation_arg;
+ set_repertoire_from_charset(collation_arg);
+ }
+ void set(CHARSET_INFO *collation_arg,
+ Derivation derivation_arg,
+ uint repertoire_arg)
+ {
+ collation= collation_arg;
+ derivation= derivation_arg;
+ repertoire= repertoire_arg;
}
void set(CHARSET_INFO *collation_arg)
- { collation= collation_arg; }
+ {
+ collation= collation_arg;
+ set_repertoire_from_charset(collation_arg);
+ }
void set(Derivation derivation_arg)
{ derivation= derivation_arg; }
bool aggregate(DTCollation &dt, uint flags= 0);
@@ -1652,8 +1674,10 @@ public:
Item_string(const char *str,uint length,
CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE)
{
- collation.set(cs, dv);
- str_value.set_or_copy_aligned(str,length,cs);
+ str_value.set_or_copy_aligned(str, length, cs);
+ collation.set(cs, dv, my_string_repertoire(cs,
+ str_value.ptr(),
+ str_value.length()));
/*
We have to have a different max_length than 'length' here to
ensure that we get the right length if we do use the item
@@ -1679,8 +1703,10 @@ public:
Item_string(const char *name_par, const char *str, uint length,
CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE)
{
- collation.set(cs, dv);
- str_value.set_or_copy_aligned(str,length,cs);
+ str_value.set_or_copy_aligned(str, length, cs);
+ collation.set(cs, dv, my_string_repertoire(cs,
+ str_value.ptr(),
+ str_value.length()));
max_length= str_value.numchars()*cs->mbmaxlen;
set_name(name_par, 0, cs);
decimals=NOT_FIXED_DEC;
--- 1.347/sql/item_func.cc 2007-06-03 16:21:53 +05:00
+++ 1.348/sql/item_func.cc 2007-06-13 17:18:20 +05:00
@@ -3751,7 +3751,7 @@ static user_var_entry *get_variable(HASH
entry->value=0;
entry->length=0;
entry->update_query_id=0;
- entry->collation.set(NULL, DERIVATION_IMPLICIT);
+ entry->collation.set(NULL, DERIVATION_IMPLICIT, 0);
entry->unsigned_flag= 0;
/*
If we are here, we were called from a SET or a query which sets a
--- 1.301/sql/item_strfunc.cc 2007-04-28 21:26:10 +05:00
+++ 1.302/sql/item_strfunc.cc 2007-06-13 17:18:20 +05:00
@@ -2672,7 +2672,8 @@ void Item_func_set_collation::fix_length
colname, args[0]->collation.collation->csname);
return;
}
- collation.set(set_collation, DERIVATION_EXPLICIT);
+ collation.set(set_collation, DERIVATION_EXPLICIT,
+ args[0]->collation.repertoire);
max_length= args[0]->max_length;
}
--- 1.144/sql/item_timefunc.cc 2007-05-30 01:32:57 +05:00
+++ 1.145/sql/item_timefunc.cc 2007-06-13 17:18:20 +05:00
@@ -1717,7 +1717,11 @@ void Item_func_date_format::fix_length_a
Item *arg1= args[1]->this_item();
decimals=0;
- collation.set(thd->variables.collation_connection);
+ CHARSET_INFO *cs= thd->variables.collation_connection;
+ uint32 repertoire= arg1->collation.repertoire;
+ if (!thd->variables.lc_time_names->is_ascii)
+ repertoire|= MY_REPERTOIRE_EXTENDED;
+ collation.set(cs, arg1->collation.derivation, repertoire);
if (arg1->type() == STRING_ITEM)
{ // Optimize the normal case
fixed_length=1;
--- 1.20/strings/conf_to_src.c 2006-12-27 09:28:22 +04:00
+++ 1.21/strings/conf_to_src.c 2007-06-13 17:18:20 +05:00
@@ -179,14 +179,31 @@ is_case_sensitive(CHARSET_INFO *cs)
cs->sort_order['a'] < cs->sort_order['B']) ? 1 : 0;
}
+
+static int
+is_pureascii(CHARSET_INFO *cs)
+{
+ size_t code;
+ if (!cs->tab_to_uni)
+ return 0;
+ for (code= 0; code < 256; code++)
+ {
+ if (cs->tab_to_uni[code] > 0x7F)
+ return 0;
+ }
+ return MY_CS_PUREASCII;
+}
+
+
void dispcset(FILE *f,CHARSET_INFO *cs)
{
fprintf(f,"{\n");
fprintf(f," %d,%d,%d,\n",cs->number,0,0);
- fprintf(f," MY_CS_COMPILED%s%s%s,\n",
- cs->state & MY_CS_BINSORT ? "|MY_CS_BINSORT" : "",
- cs->state & MY_CS_PRIMARY ? "|MY_CS_PRIMARY" : "",
- is_case_sensitive(cs) ? "|MY_CS_CSSORT" : "");
+ fprintf(f," MY_CS_COMPILED%s%s%s%s,\n",
+ cs->state & MY_CS_BINSORT ? "|MY_CS_BINSORT" : "",
+ cs->state & MY_CS_PRIMARY ? "|MY_CS_PRIMARY" : "",
+ is_case_sensitive(cs) ? "|MY_CS_CSSORT" : "",
+ is_pureascii(cs) ? "|MY_CS_PUREASCII" : "");
if (cs->name)
{
@@ -243,6 +260,28 @@ void dispcset(FILE *f,CHARSET_INFO *cs)
}
+static void
+fprint_copyright(FILE *file)
+{
+ fprintf(file,
+"/* Copyright (C) 2000-2007 MySQL AB\n"
+"\n"
+" This program is free software; you can redistribute it and/or modify\n"
+" it under the terms of the GNU General Public License as published by\n"
+" the Free Software Foundation; version 2 of the License.\n"
+"\n"
+" This program is distributed in the hope that it will be useful,\n"
+" but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
+" GNU General Public License for more details.\n"
+"\n"
+" You should have received a copy of the GNU General Public License\n"
+" along with this program; if not, write to the Free Software\n"
+" Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */\n"
+"\n");
+}
+
+
int
main(int argc, char **argv __attribute__((unused)))
{
@@ -283,6 +322,7 @@ main(int argc, char **argv __attribute_
"directory:\n");
fprintf(f, " ./conf_to_src ../sql/share/charsets/ > FILE\n");
fprintf(f, "*/\n\n");
+ fprint_copyright(f);
fprintf(f,"#include <my_global.h>\n");
fprintf(f,"#include <m_ctype.h>\n\n");
--- 1.51/mysql-test/r/ctype_ucs.result 2007-03-28 18:57:27 +05:00
+++ 1.52/mysql-test/r/ctype_ucs.result 2007-06-13 17:18:19 +05:00
@@ -865,4 +865,30 @@ blob 65535 65535
text 65535 65535
text 65535 32767
drop table t1;
+create table t1 (a varchar(15) character set ascii not null, b int);
+insert into t1 values ('a',1);
+select concat(a,if(b<10,_ucs2 0x0061,_ucs2 0x0062)) from t1;
+concat(a,if(b<10,_ucs2 0x0061,_ucs2 0x0062))
+aa
+select concat(a,if(b>10,_ucs2 0x0061,_ucs2 0x0062)) from t1;
+concat(a,if(b>10,_ucs2 0x0061,_ucs2 0x0062))
+ab
+select * from t1 where a=if(b<10,_ucs2 0x0061,_ucs2 0x0062);
+a b
+a 1
+select * from t1 where a=if(b>10,_ucs2 0x0061,_ucs2 0x0062);
+a b
+select concat(a,if(b<10,_ucs2 0x00C0,_ucs2 0x0062)) from t1;
+ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (ucs2_general_ci,COERCIBLE) for operation 'concat'
+select concat(a,if(b>10,_ucs2 0x00C0,_ucs2 0x0062)) from t1;
+ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (ucs2_general_ci,COERCIBLE) for operation 'concat'
+select concat(a,if(b<10,_ucs2 0x0062,_ucs2 0x00C0)) from t1;
+ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (ucs2_general_ci,COERCIBLE) for operation 'concat'
+select concat(a,if(b>10,_ucs2 0x0062,_ucs2 0x00C0)) from t1;
+ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (ucs2_general_ci,COERCIBLE) for operation 'concat'
+select * from t1 where a=if(b<10,_ucs2 0x00C0,_ucs2 0x0062);
+ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (ucs2_general_ci,COERCIBLE) for operation '='
+select * from t1 where a=if(b<10,_ucs2 0x0062,_ucs2 0x00C0);
+ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (ucs2_general_ci,COERCIBLE) for operation '='
+drop table t1;
End of 5.0 tests
--- 1.50/mysql-test/t/ctype_ucs.test 2007-03-28 18:57:27 +05:00
+++ 1.51/mysql-test/t/ctype_ucs.test 2007-06-13 17:18:19 +05:00
@@ -594,4 +594,34 @@ select data_type, character_octet_length
from information_schema.columns where table_name='t1';
drop table t1;
+#
+# Conversion from UCS2 to ASCII is possible
+# if the UCS2 string consists of only ASCII characters
+#
+create table t1 (a varchar(15) character set ascii not null, b int);
+insert into t1 values ('a',1);
+select concat(a,if(b<10,_ucs2 0x0061,_ucs2 0x0062)) from t1;
+select concat(a,if(b>10,_ucs2 0x0061,_ucs2 0x0062)) from t1;
+select * from t1 where a=if(b<10,_ucs2 0x0061,_ucs2 0x0062);
+select * from t1 where a=if(b>10,_ucs2 0x0061,_ucs2 0x0062);
+
+#
+# Conversion from UCS2 to ASCII is not possible if
+# the UCS2 string has non-ASCII characters
+#
+--error 1267
+select concat(a,if(b<10,_ucs2 0x00C0,_ucs2 0x0062)) from t1;
+--error 1267
+select concat(a,if(b>10,_ucs2 0x00C0,_ucs2 0x0062)) from t1;
+--error 1267
+select concat(a,if(b<10,_ucs2 0x0062,_ucs2 0x00C0)) from t1;
+--error 1267
+select concat(a,if(b>10,_ucs2 0x0062,_ucs2 0x00C0)) from t1;
+--error 1267
+select * from t1 where a=if(b<10,_ucs2 0x00C0,_ucs2 0x0062);
+--error 1267
+select * from t1 where a=if(b<10,_ucs2 0x0062,_ucs2 0x00C0);
+drop table t1;
+
+
--echo End of 5.0 tests
--- 1.26/strings/ctype-extra.c 2007-01-11 18:43:42 +04:00
+++ 1.27/strings/ctype-extra.c 2007-06-13 17:18:20 +05:00
@@ -5,7 +5,8 @@
To re-generate, run the following in the strings/ directory:
./conf_to_src ../sql/share/charsets/ > FILE
*/
-/* Copyright (C) 2000-2003 MySQL AB
+
+/* Copyright (C) 2000-2007 MySQL 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
@@ -6721,7 +6722,7 @@ CHARSET_INFO compiled_charsets[] = {
#ifdef HAVE_CHARSET_ascii
{
11,0,0,
- MY_CS_COMPILED|MY_CS_PRIMARY,
+ MY_CS_COMPILED|MY_CS_PRIMARY|MY_CS_PUREASCII,
"ascii", /* cset name */
"ascii_general_ci", /* coll name */
"", /* comment */
@@ -7810,7 +7811,7 @@ CHARSET_INFO compiled_charsets[] = {
#ifdef HAVE_CHARSET_ascii
{
65,0,0,
- MY_CS_COMPILED|MY_CS_BINSORT,
+ MY_CS_COMPILED|MY_CS_BINSORT|MY_CS_PUREASCII,
"ascii", /* cset name */
"ascii_bin", /* coll name */
"", /* comment */
--- 1.81/mysql-test/r/func_time.result 2007-03-06 21:50:42 +04:00
+++ 1.82/mysql-test/r/func_time.result 2007-06-13 17:18:19 +05:00
@@ -1246,3 +1246,15 @@ SELECT TIME_FORMAT(SEC_TO_TIME(a),"%H:%i
TIME_FORMAT(SEC_TO_TIME(a),"%H:%i:%s")
838:59:58
838:59:59
+set names latin1;
+create table t1 (a varchar(15) character set ascii not null);
+insert into t1 values ('070514-000000');
+select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1;
+concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull'))
+#
+set lc_time_names=fr_FR;
+select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1;
+ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation 'concat'
+set lc_time_names=en_US;
+drop table t1;
+End of 5.0 tests
--- 1.68/mysql-test/t/func_time.test 2007-03-06 21:50:43 +04:00
+++ 1.69/mysql-test/t/func_time.test 2007-06-13 17:18:19 +05:00
@@ -752,3 +752,24 @@ DROP TABLE t1;
# Check if using GROUP BY with TIME_FORMAT() produces correct results
SELECT TIME_FORMAT(SEC_TO_TIME(a),"%H:%i:%s") FROM (SELECT 3020399 AS a UNION SELECT 3020398 ) x GROUP BY 1;
+
+#
+# Bug#28875 Conversion between ASCII and LATIN1 charsets does not function
+#
+set names latin1;
+create table t1 (a varchar(15) character set ascii not null);
+insert into t1 values ('070514-000000');
+# Conversion of date_format() result to ASCII
+# is safe with the default locale en_US
+--replace_column 1 #
+select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1;
+# Conversion of date_format() result to ASCII
+# is not safe with the non-default locale fr_FR
+# because month and day names can have accented characters
+set lc_time_names=fr_FR;
+--error 1267
+select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1;
+set lc_time_names=en_US;
+drop table t1;
+
+--echo End of 5.0 tests
| Thread |
|---|
| • bk commit into 5.0 tree (bar:1.2518) BUG#28875 | bar | 13 Jun |