~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/func_weight_string.test

This patch completes the first step in the splitting of
the XA resource manager API from the storage engine API,
as outlined in the specification here:

http://drizzle.org/wiki/XaStorageEngine

* Splits plugin::StorageEngine into a base StorageEngine
  class and two derived classes, TransactionalStorageEngine
  and XaStorageEngine.  XaStorageEngine derives from
  TransactionalStorageEngine and creates the XA Resource
  Manager API for storage engines.

  - The methods moved from StorageEngine to TransactionalStorageEngine
    include releaseTemporaryLatches(), startConsistentSnapshot(), 
    commit(), rollback(), setSavepoint(), releaseSavepoint(),
    rollbackToSavepoint() and hasTwoPhaseCommit()
  - The methods moved from StorageEngine to XaStorageEngine
    include recover(), commitXid(), rollbackXid(), and prepare()

* Places all static "EngineVector"s into their proper
  namespaces (typedefs belong in header files, not implementation files)
  and places all static methods corresponding
  to either only transactional engines or only XA engines
  into their respective files in /drizzled/plugin/

* Modifies the InnoDB "handler" files to extend plugin::XaStorageEngine
  and not plugin::StorageEngine

The next step, as outlined in the wiki spec page above, is to isolate
the XA Resource Manager API into its own plugin class and modify
plugin::XaStorageEngine to implement plugin::XaResourceManager via
composition.  This is necessary to enable building plugins which can
participate in an XA transaction *without having to have that plugin
implement the entire storage engine API*

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