~stewart/drizzle/embedded-innodb-create-select-transaction-arrgh

« back to all changes in this revision

Viewing changes to mysql-test/t/func_weight_string.test

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--disable_warnings
 
2
drop table if exists t1;
 
3
--enable_warnings
 
4
 
 
5
set names latin1;
 
6
 
 
7
#
 
8
# If it's BLOB or BINARY or VARBINARY, then output = input.
 
9
#
 
10
select hex(weight_string(0x010203));
 
11
 
 
12
#
 
13
# "AS CHAR ( int )" causes padding on the right. The pad
 
14
# character is always space, that is, 0x20 or 0x0020.
 
15
# The padding occurs before the conversion to a weight.
 
16
# The value of "int" is the number of characters, not the number of bytes.
 
17
#
 
18
select hex(weight_string('aa' as char(3)));
 
19
 
 
20
#
 
21
# The minimum value of 'int' is 1.
 
22
#
 
23
--error 1064
 
24
select hex(weight_string('a' as char(-1)));
 
25
--error 1064
 
26
select hex(weight_string('a' as char(0)));
 
27
select hex(weight_string('a' as char(1)));
 
28
 
 
29
#
 
30
# If 'int' is smaller than the length of 'string',
 
31
# truncation will occur with no warning.
 
32
#
 
33
select hex(weight_string('ab' as char(1)));
 
34
 
 
35
#
 
36
# If "AS CHAR ( int )" is omitted, there is no padding and no truncation.
 
37
#
 
38
select hex(weight_string('ab'));
 
39
 
 
40
#
 
41
# "AS BINARY ( int )" is like CHAR(int) but causes padding of 0x00
 
42
# so one doesn't have to use "CAST(string AS BINARY(int))".
 
43
#
 
44
select hex(weight_string('aa' as binary(3)));
 
45
select hex(weight_string(cast('aa' as binary(3))));
 
46
 
 
47
#
 
48
# If and only if one specifies "LEVEL numeric-list" (not "range"),
 
49
# one may follow any "number" with [ASC|DESC][REVERSE]
 
50
#
 
51
--error 1064
 
52
select hex(weight_string('ab' level 1-1 ASC));
 
53
--error 1064
 
54
select hex(weight_string('ab' level 1-1 DESC));
 
55
--error 1064
 
56
select hex(weight_string('ab' level 1-1 REVERSE));
 
57
 
 
58
#
 
59
# If one says "DESC", then the weights come out NOTed
 
60
# or negated for that level. 
 
61
# If one says "REVERSE", then the weights come out in
 
62
# reverse order for that level, that is, starting with
 
63
# the last character and ending with the first character.
 
64
#
 
65
select hex(weight_string('ab' level 1 ASC));
 
66
select hex(weight_string('ab' level 1 DESC));
 
67
select hex(weight_string('ab' level 1 REVERSE));
 
68
select hex(weight_string('ab' level 1 DESC REVERSE));
 
69
 
 
70
#
 
71
# If the result length is less than or equal to the
 
72
# maximum possible length for the VARBINARY data type,
 
73
# then the result data type is VARBINARY. Otherwise
 
74
# the result data type is BLOB.
 
75
#
 
76
create table t1 select weight_string('test') as w;
 
77
show create table t1;
 
78
drop table t1;
 
79
create table t1 select weight_string(repeat('t',66000)) as w;
 
80
show create table t1;
 
81
drop table t1;
 
82
 
 
83
#
 
84
# If input is NULL, then output is NULL.
 
85
#
 
86
select weight_string(NULL);
 
87
 
 
88
#    
 
89
# WEIGHT_STRING and REVERSE will not be a new reserved word.
 
90
#
 
91
select 1 as weight_string, 2 as reverse;
 
92
 
 
93
#
 
94
# Check that collation derivation is copied from the argument
 
95
#
 
96
select coercibility(weight_string('test'));
 
97
select coercibility(weight_string('test' collate latin1_swedish_ci));
 
98
 
 
99
#
 
100
# Bug#33663 Character sets: weight_string function,
 
101
# varchar column, wrong result
 
102
#
 
103
create table t1 (s1 varchar(5));
 
104
insert into t1 values ('a'),(null);
 
105
select hex(weight_string(s1)) from t1 order by s1;
 
106
drop table t1;