8
push @INC, "../common/";
17
[ 'TINYINT', -128, 127 ],
18
[ 'TINYINT UNSIGNED', 0, 255 ],
19
[ 'SMALLINT', -32768, 32768 ],
20
[ 'SMALLINT UNSIGNED', 0, 65535 ],
21
[ 'MEDIUMINT', -8388608, 8388607 ],
22
[ 'MEDIUMINT UNSIGNED', 0, 16777215 ],
23
[ 'INT', -2147483648, 2147483647 ],
24
[ 'INT UNSIGNED', 0, 4294967295 ],
25
[ 'BIGINT', -9223372036854775808, 9223372036854775807 ],
26
[ 'BIGINT UNSIGNED', 0, 18446744073709551615 ],
27
[ 'FLOAT', -32768, 32768 ],
28
[ 'DOUBLE', -2147483648, 2147483647 ],
30
my $datetime_types = [
31
[ 'DATE', '0000-00-00', '2011-01-01', '9999-12-31' ],
32
[ 'DATETIME', 0, '2011-01-01 18:30:25' ],
33
[ 'TIME', 0, '18:30:25' ],
34
[ 'YEAR(4)', 1901, 2011, 2155 ],
35
# [ 'TIMESTAMP', 0, 999999999 ], # DOES NOT WORK YET
38
[ 'CHAR(10)', undef, 1, 2, 5, 10 ],
39
[ 'VARCHAR(10)', undef, 1, 2, 5, 10 ],
40
[ 'BINARY(10)', undef, 1, 2, 5, 10 ],
41
[ 'VARBINARY(10)', undef, 1, 2, 5, 10 ],
42
[ 'CHAR(255)', undef, 1, 2, 5, 10, 100, 200, 255 ],
43
[ 'VARCHAR(255)', undef, 1, 2, 5, 10, 100, 200, 255 ],
44
[ 'VARCHAR(511)', undef, 1, 2, 5, 10, 100, 200, 511 ],
45
[ 'LONGTEXT', 500, 1, 2, 5, 10, 100, 200, 511 ], # NOT SUPPORTED YET
46
[ 'LONGBLOB', 500, 1, 2, 5, 10, 100, 200, 511 ], # NOT SUPPORTED YET
47
# [ 'VARCHAR(4096)', 500, 1, 2, 5, 10, 100, 200, 255, 256, 4095 ],
48
# [ 'VARCHAR(16383)', 500, 1, 2, 5, 10, 100, 200, 255, 256, 4095, 4096, 16383 ],
49
# [ 'VARBINARY(16383)', 500, 1, 2, 5, 10, 100, 200, 255, 256, 4095, 4096, 16383 ],
52
for my $rec (@$numeric_types) {
53
my ($typ, $minval, $maxval) = @$rec;
62
for (my $i = 0; $i < 3; ++$i) {
65
push(@vals, int($v1));
66
push(@vals, int($v2));
68
my %vm = map { $_ => 1 } @vals;
69
@vals = sort { $a <=> $b } keys %vm;
71
test_one($typ, undef, \@vals);
74
for my $rec (@$datetime_types) {
75
my ($typ, @vals) = @$rec;
77
test_one($typ, undef, \@vals);
80
for my $rec (@$string_types) {
81
my ($typ, $keylen, @vs) = @$rec;
88
for (my $i = 0; $i < $len; ++$i) {
89
my $v = int(rand(10));
90
$arr[$i] = chr(65 + $v);
93
push(@vals, join('', @arr));
96
test_one($typ, $keylen, \@vals);
102
my ($typ, $keylen, $values) = @_;
103
print "\n$typ -------------------------------------------------\n\n";
105
if (defined($keylen)) {
106
$keylen_str = "($keylen)";
108
my $dbh = hstest::init_testdb();
109
my $table = 'hstesttbl';
112
"create table $table " .
113
"(k1 int not null, k2 int not null, " .
114
"v1 int not null, v2 $typ default null, " .
115
"primary key (k1, k2) ) engine = innodb");
116
my $sth = $dbh->prepare("insert into $table values (?,?,?,?)");
117
for (my $i = 0; $i < $tablesize; ++$i) {
119
for my $v (@$values) {
120
$sth->execute($i, $j, $i, $v);
124
$hs = hstest::get_hs_connection(undef, 9999);
125
my $dbname = $hstest::conf{dbname};
126
$hs->open_index(1, $dbname, $table, '', 'k1,k2,v1,v2', 'v2');
127
my $minval = $values->[0];
128
# select * ... where (k1, k2) >= ('', $minval)
130
4, "FILTER($typ) NO FILTER",
131
[ 1, '>=', [ '', $minval ], 1000, 0 ]
133
for my $v (@$values) {
134
my $vstr = defined($v) ? $v : 'NULL';
135
# select * ... where (k1, k2) >= ('', $minval) and v2 = $v
137
4, "FILTER($typ) v2 = $vstr",
138
[ 1, '>=', [ '', $minval ], 1000, 0, undef, undef, [ [ 'F', '=', 0, $v ] ] ]
140
# select * ... where (k1, k2) >= ('', $minval) and v2 != $v
142
4, "FILTER($typ) v2 != $vstr",
143
[ 1, '>=', [ '', $minval ], 1000, 0, undef, undef, [ [ 'F', '!=', 0, $v ] ] ]
145
# select * ... where (k1, k2) >= ('', $minval) and v2 >= $v
147
4, "FILTER($typ) v2 >= $vstr",
148
[ 1, '>=', [ '', $minval ], 1000, 0, undef, undef, [ [ 'F', '>=', 0, $v ] ] ]
150
# select * ... where (k1, k2) >= ('', $minval) and v2 < $v
152
4, "FILTER($typ) v2 < $vstr",
153
[ 1, '>=', [ '', $minval ], 1000, 0, undef, undef, [ [ 'F', '<', 0, $v ] ] ]
155
# select * ... where (k1, k2) >= ('', $minval) and v2 > $v
157
4, "FILTER($typ) v2 > $vstr",
158
[ 1, '>=', [ '', $minval ], 1000, 0, undef, undef, [ [ 'F', '>', 0, $v ] ] ]
160
# select * ... where (k1, k2) >= ('', $minval) and v2 <= $v
162
4, "FILTER($typ) v2 <= $vstr",
163
[ 1, '>=', [ '', $minval ], 1000, 0, undef, undef, [ [ 'F', '<=', 0, $v ] ] ]
170
my $width = shift(@_);
171
my $mess = shift(@_);
173
my $mres = $hs->execute_multi(\@_);
174
for my $res (@$mres) {
175
my $code = shift(@$res);
176
my $nrows = $code == 0 ? scalar(@$res) / $width : 0;
177
print "code=$code rows=$nrows\n";
179
for my $fld (@$res) {
180
$fld = 'NULL' if !defined($fld);
182
if (++$i >= $width) {