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;
|