mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
ctype_utf8.result, ctype_utf8.test:
New syntax: CHAR(x USING charset) Adding test case. sql_yacc.yy: New syntax: CHAR(x USING charset) Adding new parser rule. item_strfunc.h: New syntax: CHAR(x USING charset) Adding a new constructor.
This commit is contained in:
parent
304d4f580b
commit
7c81d7fc69
4 changed files with 71 additions and 46 deletions
|
@ -1064,46 +1064,56 @@ xxx
|
|||
yyy
|
||||
DROP TABLE t1;
|
||||
set names utf8;
|
||||
select hex(char(1));
|
||||
hex(char(1))
|
||||
select hex(char(1 using utf8));
|
||||
hex(char(1 using utf8))
|
||||
01
|
||||
select char(0xd1,0x8f);
|
||||
char(0xd1,0x8f)
|
||||
select char(0xd1,0x8f using utf8);
|
||||
char(0xd1,0x8f using utf8)
|
||||
Ñ<EFBFBD>
|
||||
select char(0xd18f);
|
||||
char(0xd18f)
|
||||
select char(0xd18f using utf8);
|
||||
char(0xd18f using utf8)
|
||||
Ñ<EFBFBD>
|
||||
select char(53647);
|
||||
char(53647)
|
||||
select char(53647 using utf8);
|
||||
char(53647 using utf8)
|
||||
Ñ<EFBFBD>
|
||||
select char(0xff,0x8f);
|
||||
char(0xff,0x8f)
|
||||
select char(0xff,0x8f using utf8);
|
||||
char(0xff,0x8f using utf8)
|
||||
ÿ<EFBFBD>
|
||||
Warnings:
|
||||
Warning 1300 Invalid utf8 character string: 'FF8F'
|
||||
set sql_mode=traditional;
|
||||
select char(0xff,0x8f);
|
||||
char(0xff,0x8f)
|
||||
ÿ<EFBFBD>
|
||||
select convert(char(0xff,0x8f) using utf8);
|
||||
convert(char(0xff,0x8f) using utf8)
|
||||
ÿ<EFBFBD>
|
||||
select char(195);
|
||||
char(195)
|
||||
Ã
|
||||
select convert(char(195) using utf8);
|
||||
convert(char(195) using utf8)
|
||||
Ã
|
||||
select char(196);
|
||||
char(196)
|
||||
Ä
|
||||
select convert(char(196) using utf8);
|
||||
convert(char(196) using utf8)
|
||||
Ä
|
||||
select char(0xff,0x8f using utf8);
|
||||
char(0xff,0x8f using utf8)
|
||||
NULL
|
||||
Warnings:
|
||||
Error 1300 Invalid utf8 character string: 'FF8F'
|
||||
select char(195 using utf8);
|
||||
char(195 using utf8)
|
||||
NULL
|
||||
Warnings:
|
||||
Error 1300 Invalid utf8 character string: 'C3'
|
||||
select char(196 using utf8);
|
||||
char(196 using utf8)
|
||||
NULL
|
||||
Warnings:
|
||||
Error 1300 Invalid utf8 character string: 'C4'
|
||||
select char(2557 using utf8);
|
||||
char(2557 using utf8)
|
||||
NULL
|
||||
Warnings:
|
||||
Error 1300 Invalid utf8 character string: 'FD'
|
||||
select hex(convert(char(2557 using latin1) using utf8));
|
||||
hex(convert(char(2557 using latin1) using utf8))
|
||||
09C3BD
|
||||
select hex(char(195));
|
||||
hex(char(195))
|
||||
C3
|
||||
select hex(char(196));
|
||||
hex(char(196))
|
||||
C4
|
||||
select hex(char(2557));
|
||||
hex(char(2557))
|
||||
09FD
|
||||
select hex(convert(char(2557) using utf8));
|
||||
hex(convert(char(2557) using utf8))
|
||||
09FD
|
||||
set names utf8;
|
||||
create table t1 (a char(1)) default character set utf8;
|
||||
create table t2 (a char(1)) default character set utf8;
|
||||
|
|
|
@ -871,22 +871,32 @@ DROP TABLE t1;
|
|||
#
|
||||
set names utf8;
|
||||
# correct value
|
||||
select hex(char(1));
|
||||
select char(0xd1,0x8f);
|
||||
select char(0xd18f);
|
||||
select char(53647);
|
||||
select hex(char(1 using utf8));
|
||||
select char(0xd1,0x8f using utf8);
|
||||
select char(0xd18f using utf8);
|
||||
select char(53647 using utf8);
|
||||
# incorrect value: return with warning
|
||||
select char(0xff,0x8f);
|
||||
select char(0xff,0x8f using utf8);
|
||||
# incorrect value in strict mode: return NULL with "Error" level warning
|
||||
set sql_mode=traditional;
|
||||
select char(0xff,0x8f);
|
||||
select convert(char(0xff,0x8f) using utf8);
|
||||
select char(195);
|
||||
select convert(char(195) using utf8);
|
||||
select char(196);
|
||||
select convert(char(196) using utf8);
|
||||
select char(0xff,0x8f using utf8);
|
||||
select char(195 using utf8);
|
||||
select char(196 using utf8);
|
||||
select char(2557 using utf8);
|
||||
|
||||
#
|
||||
# Check convert + char + using
|
||||
#
|
||||
select hex(convert(char(2557 using latin1) using utf8));
|
||||
|
||||
#
|
||||
# char() without USING returns "binary" by default, any argument is ok
|
||||
#
|
||||
select hex(char(195));
|
||||
select hex(char(196));
|
||||
select hex(char(2557));
|
||||
select hex(convert(char(2557) using utf8));
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Bug#12891: UNION doesn't return DISTINCT result for multi-byte characters
|
||||
|
|
|
@ -480,12 +480,15 @@ public:
|
|||
class Item_func_char :public Item_str_func
|
||||
{
|
||||
public:
|
||||
Item_func_char(List<Item> &list) :Item_str_func(list) {}
|
||||
Item_func_char(List<Item> &list) :Item_str_func(list)
|
||||
{ collation.set(&my_charset_bin); }
|
||||
Item_func_char(List<Item> &list, CHARSET_INFO *cs) :Item_str_func(list)
|
||||
{ collation.set(cs); }
|
||||
String *val_str(String *);
|
||||
void fix_length_and_dec()
|
||||
{
|
||||
collation.set(&my_charset_bin);
|
||||
maybe_null=0; max_length=arg_count;
|
||||
maybe_null=0;
|
||||
max_length=arg_count * collation.collation->mbmaxlen;
|
||||
}
|
||||
const char *func_name() const { return "char"; }
|
||||
};
|
||||
|
|
|
@ -4536,6 +4536,8 @@ simple_expr:
|
|||
{ $$= new Item_func_atan($3,$5); }
|
||||
| CHAR_SYM '(' expr_list ')'
|
||||
{ $$= new Item_func_char(*$3); }
|
||||
| CHAR_SYM '(' expr_list USING charset_name ')'
|
||||
{ $$= new Item_func_char(*$3, $5); }
|
||||
| CHARSET '(' expr ')'
|
||||
{ $$= new Item_func_charset($3); }
|
||||
| COALESCE '(' expr_list ')'
|
||||
|
|
Loading…
Reference in a new issue