File: charset.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (84 lines) | stat: -rw-r--r-- 2,412 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Check that non-utf8 characters are ok

--source include/have_optimizer_trace.inc
--source include/not_hypergraph.inc  # Does not output the same optimizer trace.

# --ps-protocol gives different trace where view
# has already been materialized
# Test requires: sp-protocol/ps-protocol/view-protocol/cursor-protocol disabled
--source include/no_protocol.inc

set @@session.end_markers_in_json=on;
set @@session.optimizer_trace="enabled=on";
create table t1(a int);
insert into t1 values(1);

# test non-utf8 chars in the SELECT list

set names latin1;
--character_set latin1
# The 5 'A's below are, in this file's bytes, written in latin1
# encoding: xC1C2C4C4C5. We send them as latin1; the server interprets
# them as characters using latin1, then encodes those characters in
# utf8 in the trace; sends back the trace but re-encodes it in latin1
# (as this is how we want it, see "set names latin1".
explain select '', _latin1'' from t1 limit 1;
--disable_warnings
select (@query:=QUERY)+NULL, (@trace:=TRACE)+NULL from information_schema.OPTIMIZER_TRACE;
--enable_warnings
select @query, @trace;
# The trace above is not valid JSON because the client asked to
# receive it encoded in latin1, whereas JSON wants it in utf8.
# Let's get it in utf8.
set names utf8;
select @query, @trace;

# test non-utf8 chars in a view's definition

set names latin1;
create view v1 as select '' as col from t1 limit 1;
select * from v1 where v1.col = '';
--disable_warnings
select (@query:=QUERY)+NULL, (@trace:=TRACE)+NULL from information_schema.OPTIMIZER_TRACE;
--enable_warnings
set names utf8;
select @query, @trace;

drop table t1;
drop view v1;

# test non-ASCII chars in a range

set names latin1;
create table t1(c char(4) primary key) charset latin1;
insert into t1 values ('aaa'), ('');
select * from t1 where c < '';
--disable_warnings
select (@query:=QUERY)+NULL, (@trace:=TRACE)+NULL from information_schema.OPTIMIZER_TRACE;
--enable_warnings
set names utf8;
select @query, @trace;
drop table t1;

# test newline and tabulation chars in an identifier
create table `t
1	a`(`col
1	a` int, index `index
1	a` (`col
1	a`));
insert into `t
1	a` values(2),(3);
create view `v
1	a` as select * from `t
1	a`;
select `col
1	a` from `v
1	a` where `col
1	a` < 6;
select query, trace from information_schema.OPTIMIZER_TRACE;
drop table `t
1	a`;
drop view `v
1	a`;

set optimizer_trace=default;