vincentchu-handlersocket 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. data/ext/HandlerSocket-Plugin-for-MySQL/AUTHORS +22 -0
  2. data/ext/HandlerSocket-Plugin-for-MySQL/COPYING +30 -0
  3. data/ext/HandlerSocket-Plugin-for-MySQL/ChangeLog +12 -0
  4. data/ext/HandlerSocket-Plugin-for-MySQL/Makefile.am +87 -0
  5. data/ext/HandlerSocket-Plugin-for-MySQL/README +78 -0
  6. data/ext/HandlerSocket-Plugin-for-MySQL/autogen.sh +117 -0
  7. data/ext/HandlerSocket-Plugin-for-MySQL/client/Makefile.am +24 -0
  8. data/ext/HandlerSocket-Plugin-for-MySQL/client/hsclient.cpp +88 -0
  9. data/ext/HandlerSocket-Plugin-for-MySQL/client/hslongrun.cpp +1041 -0
  10. data/ext/HandlerSocket-Plugin-for-MySQL/client/hspool_test.pl +224 -0
  11. data/ext/HandlerSocket-Plugin-for-MySQL/client/hstest.cpp +1532 -0
  12. data/ext/HandlerSocket-Plugin-for-MySQL/client/hstest.pl +228 -0
  13. data/ext/HandlerSocket-Plugin-for-MySQL/client/hstest_hs.sh +4 -0
  14. data/ext/HandlerSocket-Plugin-for-MySQL/client/hstest_hs_more50.sh +4 -0
  15. data/ext/HandlerSocket-Plugin-for-MySQL/client/hstest_md.sh +7 -0
  16. data/ext/HandlerSocket-Plugin-for-MySQL/client/hstest_my.sh +3 -0
  17. data/ext/HandlerSocket-Plugin-for-MySQL/client/hstest_my_more50.sh +3 -0
  18. data/ext/HandlerSocket-Plugin-for-MySQL/configure.ac +144 -0
  19. data/ext/HandlerSocket-Plugin-for-MySQL/docs-en/about-handlersocket.en.txt +72 -0
  20. data/ext/HandlerSocket-Plugin-for-MySQL/docs-en/configuration-options.en.txt +99 -0
  21. data/ext/HandlerSocket-Plugin-for-MySQL/docs-en/installation.en.txt +92 -0
  22. data/ext/HandlerSocket-Plugin-for-MySQL/docs-en/perl-client.en.txt +135 -0
  23. data/ext/HandlerSocket-Plugin-for-MySQL/docs-en/protocol.en.txt +205 -0
  24. data/ext/HandlerSocket-Plugin-for-MySQL/docs-ja/about-handlersocket.ja.txt +51 -0
  25. data/ext/HandlerSocket-Plugin-for-MySQL/docs-ja/installation.ja.txt +88 -0
  26. data/ext/HandlerSocket-Plugin-for-MySQL/docs-ja/perl-client.ja.txt +127 -0
  27. data/ext/HandlerSocket-Plugin-for-MySQL/docs-ja/protocol.ja.txt +180 -0
  28. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/COPYRIGHT.txt +27 -0
  29. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/Makefile.am +10 -0
  30. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/Makefile.plain.template +31 -0
  31. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/database.cpp +1190 -0
  32. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/database.hpp +142 -0
  33. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/handlersocket.cpp +222 -0
  34. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/handlersocket.spec.template +29 -0
  35. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr.cpp +149 -0
  36. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr.hpp +58 -0
  37. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr_worker.cpp +951 -0
  38. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr_worker.hpp +35 -0
  39. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/mysql_incl.hpp +50 -0
  40. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/COPYRIGHT.txt +27 -0
  41. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/Makefile.am +12 -0
  42. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/Makefile.plain +27 -0
  43. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/allocator.hpp +64 -0
  44. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/auto_addrinfo.hpp +49 -0
  45. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/auto_file.hpp +64 -0
  46. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/auto_ptrcontainer.hpp +67 -0
  47. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/config.cpp +67 -0
  48. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/config.hpp +32 -0
  49. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/escape.cpp +127 -0
  50. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/escape.hpp +66 -0
  51. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/fatal.cpp +36 -0
  52. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/fatal.hpp +22 -0
  53. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/hstcpcli.cpp +441 -0
  54. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/hstcpcli.hpp +62 -0
  55. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/libhsclient.spec.template +39 -0
  56. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/mutex.hpp +51 -0
  57. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/socket.cpp +186 -0
  58. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/socket.hpp +51 -0
  59. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/string_buffer.hpp +118 -0
  60. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/string_ref.hpp +63 -0
  61. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/string_util.cpp +182 -0
  62. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/string_util.hpp +53 -0
  63. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/thread.hpp +84 -0
  64. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/util.hpp +25 -0
  65. data/ext/HandlerSocket-Plugin-for-MySQL/misc/microbench-hs.log +130 -0
  66. data/ext/HandlerSocket-Plugin-for-MySQL/misc/microbench-my.log +125 -0
  67. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/COPYRIGHT.txt +27 -0
  68. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/Changes +6 -0
  69. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/HandlerSocket.xs +632 -0
  70. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/MANIFEST +8 -0
  71. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/Makefile.PL +18 -0
  72. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/Makefile.PL.installed +20 -0
  73. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/README +30 -0
  74. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/lib/Net/HandlerSocket.pm +68 -0
  75. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/lib/Net/HandlerSocket/Pool.pm +362 -0
  76. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/perl-Net-HandlerSocket.spec.template +127 -0
  77. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/ppport.h +6375 -0
  78. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/t/Net-HandlerSocket.t +15 -0
  79. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/Makefile +79 -0
  80. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/common/binary_my.cnf +4 -0
  81. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/common/compat.sh +29 -0
  82. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/common/hstest.pm +66 -0
  83. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/Makefile +4 -0
  84. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/run.sh +27 -0
  85. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test01.expected +100 -0
  86. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test01.pl +38 -0
  87. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test02.expected +100 -0
  88. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test02.pl +49 -0
  89. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test03.expected +771 -0
  90. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test03.pl +61 -0
  91. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test04.expected +0 -0
  92. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test04.pl +63 -0
  93. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test05.expected +771 -0
  94. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test05.pl +59 -0
  95. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test06.expected +644 -0
  96. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test06.pl +90 -0
  97. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test07.expected +304 -0
  98. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test07.pl +98 -0
  99. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test08.expected +2 -0
  100. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test08.pl +48 -0
  101. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test09.expected +12 -0
  102. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test09.pl +67 -0
  103. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test10.expected +771 -0
  104. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test10.pl +93 -0
  105. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test11.expected +37 -0
  106. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test11.pl +112 -0
  107. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test12.expected +273 -0
  108. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test12.pl +134 -0
  109. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test13.expected +92 -0
  110. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test13.pl +92 -0
  111. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test14.expected +144 -0
  112. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test14.pl +80 -0
  113. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test15.expected +764 -0
  114. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test15.pl +114 -0
  115. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test16.expected +66 -0
  116. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test16.pl +88 -0
  117. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test17.expected +0 -0
  118. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test17.pl +125 -0
  119. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test18.expected +22 -0
  120. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test18.pl +63 -0
  121. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test19.expected +14894 -0
  122. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test19.pl +190 -0
  123. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test20.expected +2 -0
  124. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test20.pl +33 -0
  125. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test21.expected +11 -0
  126. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test21.pl +58 -0
  127. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test22.expected +9 -0
  128. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test22.pl +61 -0
  129. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test23.expected +101 -0
  130. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test23.pl +53 -0
  131. data/ext/winebarrel-ruby-handlersocket-c19841e47ea2/README +33 -0
  132. data/ext/winebarrel-ruby-handlersocket-c19841e47ea2/extconf.rb +27 -0
  133. data/ext/winebarrel-ruby-handlersocket-c19841e47ea2/handlersocket.cpp +437 -0
  134. data/ext/winebarrel-ruby-handlersocket-c19841e47ea2/handlersocket.h +32 -0
  135. metadata +200 -0
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/perl
2
+
3
+ # vim:sw=2:ai
4
+
5
+ # test for various numeric types
6
+
7
+ BEGIN {
8
+ push @INC, "../common/";
9
+ };
10
+
11
+ use strict;
12
+ use warnings;
13
+ use bigint;
14
+ use hstest;
15
+
16
+ my $numeric_types = [
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 ],
29
+ ];
30
+
31
+ my $table = 'hstesttbl';
32
+ my $dbh;
33
+ for my $rec (@$numeric_types) {
34
+ my ($typ, $minval, $maxval) = @$rec;
35
+ my @vals = ();
36
+ push(@vals, 0);
37
+ push(@vals, 1);
38
+ push(@vals, $maxval);
39
+ if ($minval != 0) {
40
+ push(@vals, -1);
41
+ push(@vals, $minval);
42
+ }
43
+ my $v1 = $minval;
44
+ my $v2 = $maxval;
45
+ for (my $i = 0; $i < 5; ++$i) {
46
+ $v1 /= 3;
47
+ $v2 /= 3;
48
+ if ($v1 != 0) {
49
+ push(@vals, int($v1));
50
+ }
51
+ push(@vals, int($v2));
52
+ }
53
+ @vals = sort { $a <=> $b } @vals;
54
+ print("TYPE $typ\n");
55
+ test_one($typ, \@vals);
56
+ print("\n");
57
+ }
58
+
59
+ sub test_one {
60
+ my ($typ, $values) = @_;
61
+ $dbh = hstest::init_testdb();
62
+ $dbh->do(
63
+ "create table $table (" .
64
+ "k $typ primary key, " .
65
+ "v1 varchar(512), " .
66
+ "v2 $typ, " .
67
+ "index i1(v1), index i2(v2, v1)) " .
68
+ "engine = myisam default charset = binary");
69
+ my $hs = hstest::get_hs_connection(undef, 9999);
70
+ my $dbname = $hstest::conf{dbname};
71
+ $hs->open_index(1, $dbname, $table, '', 'k,v1,v2');
72
+ $hs->open_index(2, $dbname, $table, 'i1', 'k,v1,v2');
73
+ $hs->open_index(3, $dbname, $table, 'i2', 'k,v1,v2');
74
+ for my $k (@$values) {
75
+ my $kstr = 's' . $k;
76
+ $hs->execute_single(1, '+', [ $k, $kstr, $k ], 0, 0);
77
+ }
78
+ dump_table();
79
+ for my $k (@$values) {
80
+ my $kstr = 's' . $k;
81
+ my ($rk, $rv1, $rv2);
82
+ my $r;
83
+ $r = $hs->execute_single(1, '=', [ $k ], 1, 0);
84
+ shift(@$r);
85
+ ($rk, $rv1, $rv2) = @$r;
86
+ print "PK[$k] $rk $rv1 $rv2\n";
87
+ $r = $hs->execute_single(2, '=', [ $kstr ], 1, 0);
88
+ shift(@$r);
89
+ ($rk, $rv1, $rv2) = @$r;
90
+ print "I1[$kstr] $rk $rv1 $rv2\n";
91
+ $r = $hs->execute_single(3, '=', [ $k, $kstr ], 1, 0);
92
+ shift(@$r);
93
+ ($rk, $rv1, $rv2) = @$r;
94
+ print "I2[$k, $kstr] $rk $rv1 $rv2\n";
95
+ $r = $hs->execute_single(3, '=', [ $k ], 1, 0);
96
+ shift(@$r);
97
+ ($rk, $rv1, $rv2) = @$r;
98
+ print "I2p[$k] $rk $rv1 $rv2\n";
99
+ }
100
+ }
101
+
102
+ sub dump_table {
103
+ print "DUMP_TABLE_BEGIN\n";
104
+ my $aref = $dbh->selectall_arrayref("select k,v1,v2 from $table order by k");
105
+ for my $row (@$aref) {
106
+ my ($k, $v1, $v2) = @$row;
107
+ $v1 = "[null]" if !defined($v1);
108
+ $v2 = "[null]" if !defined($v2);
109
+ print "$k $v1 $v2\n";
110
+ # print "MISMATCH\n" if ($valmap{$k} ne $v);
111
+ }
112
+ print "DUMP_TABLE_END\n";
113
+ }
114
+
@@ -0,0 +1,66 @@
1
+ TYPE DATE
2
+ DUMP_TABLE_BEGIN
3
+ 0000-00-00 s0000-00-00 0000-00-00
4
+ 2011-01-01 s2011-01-01 2011-01-01
5
+ 9999-12-31 s9999-12-31 9999-12-31
6
+ DUMP_TABLE_END
7
+ PK[0000-00-00] 0000-00-00 s0000-00-00 0000-00-00
8
+ I1[s0000-00-00] 0000-00-00 s0000-00-00 0000-00-00
9
+ I2[0000-00-00, s0000-00-00] 0000-00-00 s0000-00-00 0000-00-00
10
+ I2p[0000-00-00] 0000-00-00 s0000-00-00 0000-00-00
11
+ PK[2011-01-01] 2011-01-01 s2011-01-01 2011-01-01
12
+ I1[s2011-01-01] 2011-01-01 s2011-01-01 2011-01-01
13
+ I2[2011-01-01, s2011-01-01] 2011-01-01 s2011-01-01 2011-01-01
14
+ I2p[2011-01-01] 2011-01-01 s2011-01-01 2011-01-01
15
+ PK[9999-12-31] 9999-12-31 s9999-12-31 9999-12-31
16
+ I1[s9999-12-31] 9999-12-31 s9999-12-31 9999-12-31
17
+ I2[9999-12-31, s9999-12-31] 9999-12-31 s9999-12-31 9999-12-31
18
+ I2p[9999-12-31] 9999-12-31 s9999-12-31 9999-12-31
19
+
20
+ TYPE DATETIME
21
+ DUMP_TABLE_BEGIN
22
+ 0000-00-00 00:00:00 s0 0000-00-00 00:00:00
23
+ 2011-01-01 18:30:25 s2011-01-01 18:30:25 2011-01-01 18:30:25
24
+ DUMP_TABLE_END
25
+ PK[0] 0000-00-00 00:00:00 s0 0000-00-00 00:00:00
26
+ I1[s0] 0000-00-00 00:00:00 s0 0000-00-00 00:00:00
27
+ I2[0, s0] 0000-00-00 00:00:00 s0 0000-00-00 00:00:00
28
+ I2p[0] 0000-00-00 00:00:00 s0 0000-00-00 00:00:00
29
+ PK[2011-01-01 18:30:25] 2011-01-01 18:30:25 s2011-01-01 18:30:25 2011-01-01 18:30:25
30
+ I1[s2011-01-01 18:30:25] 2011-01-01 18:30:25 s2011-01-01 18:30:25 2011-01-01 18:30:25
31
+ I2[2011-01-01 18:30:25, s2011-01-01 18:30:25] 2011-01-01 18:30:25 s2011-01-01 18:30:25 2011-01-01 18:30:25
32
+ I2p[2011-01-01 18:30:25] 2011-01-01 18:30:25 s2011-01-01 18:30:25 2011-01-01 18:30:25
33
+
34
+ TYPE TIME
35
+ DUMP_TABLE_BEGIN
36
+ 00:00:00 s0 00:00:00
37
+ 18:30:25 s18:30:25 18:30:25
38
+ DUMP_TABLE_END
39
+ PK[0] 00:00:00 s0 00:00:00
40
+ I1[s0] 00:00:00 s0 00:00:00
41
+ I2[0, s0] 00:00:00 s0 00:00:00
42
+ I2p[0] 00:00:00 s0 00:00:00
43
+ PK[18:30:25] 18:30:25 s18:30:25 18:30:25
44
+ I1[s18:30:25] 18:30:25 s18:30:25 18:30:25
45
+ I2[18:30:25, s18:30:25] 18:30:25 s18:30:25 18:30:25
46
+ I2p[18:30:25] 18:30:25 s18:30:25 18:30:25
47
+
48
+ TYPE YEAR(4)
49
+ DUMP_TABLE_BEGIN
50
+ 1901 s1901 1901
51
+ 2011 s2011 2011
52
+ 2155 s2155 2155
53
+ DUMP_TABLE_END
54
+ PK[1901] 1901 s1901 1901
55
+ I1[s1901] 1901 s1901 1901
56
+ I2[1901, s1901] 1901 s1901 1901
57
+ I2p[1901] 1901 s1901 1901
58
+ PK[2011] 2011 s2011 2011
59
+ I1[s2011] 2011 s2011 2011
60
+ I2[2011, s2011] 2011 s2011 2011
61
+ I2p[2011] 2011 s2011 2011
62
+ PK[2155] 2155 s2155 2155
63
+ I1[s2155] 2155 s2155 2155
64
+ I2[2155, s2155] 2155 s2155 2155
65
+ I2p[2155] 2155 s2155 2155
66
+
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/perl
2
+
3
+ # vim:sw=2:ai
4
+
5
+ # test for date/datetime types
6
+
7
+ BEGIN {
8
+ push @INC, "../common/";
9
+ };
10
+
11
+ use strict;
12
+ use warnings;
13
+ use bigint;
14
+ use hstest;
15
+
16
+ my $datetime_types = [
17
+ [ 'DATE', '0000-00-00', '2011-01-01', '9999-12-31' ],
18
+ [ 'DATETIME', 0, '2011-01-01 18:30:25' ],
19
+ [ 'TIME', 0, '18:30:25' ],
20
+ [ 'YEAR(4)', 1901, 2011, 2155 ],
21
+ # [ 'TIMESTAMP', 0, 999999999 ], # DOES NOT WORK YET
22
+ ];
23
+
24
+ my $table = 'hstesttbl';
25
+ my $dbh;
26
+ for my $rec (@$datetime_types) {
27
+ my ($typ, @vals) = @$rec;
28
+ print("TYPE $typ\n");
29
+ test_one($typ, \@vals);
30
+ print("\n");
31
+ }
32
+
33
+ sub test_one {
34
+ my ($typ, $values) = @_;
35
+ $dbh = hstest::init_testdb();
36
+ $dbh->do(
37
+ "create table $table (" .
38
+ "k $typ primary key, " .
39
+ "v1 varchar(512), " .
40
+ "v2 $typ, " .
41
+ "index i1(v1), index i2(v2, v1)) " .
42
+ "engine = myisam default charset = binary");
43
+ my $hs = hstest::get_hs_connection(undef, 9999);
44
+ my $dbname = $hstest::conf{dbname};
45
+ $hs->open_index(1, $dbname, $table, '', 'k,v1,v2');
46
+ $hs->open_index(2, $dbname, $table, 'i1', 'k,v1,v2');
47
+ $hs->open_index(3, $dbname, $table, 'i2', 'k,v1,v2');
48
+ for my $k (@$values) {
49
+ my $kstr = 's' . $k;
50
+ $hs->execute_single(1, '+', [ $k, $kstr, $k ], 0, 0);
51
+ }
52
+ dump_table();
53
+ for my $k (@$values) {
54
+ my $kstr = 's' . $k;
55
+ my ($rk, $rv1, $rv2);
56
+ my $r;
57
+ $r = $hs->execute_single(1, '=', [ $k ], 1, 0);
58
+ shift(@$r);
59
+ ($rk, $rv1, $rv2) = @$r;
60
+ print "PK[$k] $rk $rv1 $rv2\n";
61
+ $r = $hs->execute_single(2, '=', [ $kstr ], 1, 0);
62
+ shift(@$r);
63
+ ($rk, $rv1, $rv2) = @$r;
64
+ print "I1[$kstr] $rk $rv1 $rv2\n";
65
+ $r = $hs->execute_single(3, '=', [ $k, $kstr ], 1, 0);
66
+ shift(@$r);
67
+ ($rk, $rv1, $rv2) = @$r;
68
+ print "I2[$k, $kstr] $rk $rv1 $rv2\n";
69
+ $r = $hs->execute_single(3, '=', [ $k ], 1, 0);
70
+ shift(@$r);
71
+ ($rk, $rv1, $rv2) = @$r;
72
+ print "I2p[$k] $rk $rv1 $rv2\n";
73
+ }
74
+ }
75
+
76
+ sub dump_table {
77
+ print "DUMP_TABLE_BEGIN\n";
78
+ my $aref = $dbh->selectall_arrayref("select k,v1,v2 from $table order by k");
79
+ for my $row (@$aref) {
80
+ my ($k, $v1, $v2) = @$row;
81
+ $v1 = "[null]" if !defined($v1);
82
+ $v2 = "[null]" if !defined($v2);
83
+ print "$k $v1 $v2\n";
84
+ # print "MISMATCH\n" if ($valmap{$k} ne $v);
85
+ }
86
+ print "DUMP_TABLE_END\n";
87
+ }
88
+
@@ -0,0 +1,125 @@
1
+ #!/usr/bin/perl
2
+
3
+ # vim:sw=2:ai
4
+
5
+ # test for string types
6
+
7
+ BEGIN {
8
+ push @INC, "../common/";
9
+ };
10
+
11
+ use strict;
12
+ use warnings;
13
+ use bigint;
14
+ use hstest;
15
+
16
+ my $string_types = [
17
+ [ 'CHAR(10)', undef, 1, 2, 5, 10 ],
18
+ [ 'VARCHAR(10)', undef, 1, 2, 5, 10 ],
19
+ [ 'BINARY(10)', undef, 1, 2, 5, 10 ],
20
+ [ 'VARBINARY(10)', undef, 1, 2, 5, 10 ],
21
+ [ 'CHAR(255)', undef, 1, 2, 5, 10, 100, 200, 255 ],
22
+ [ 'VARCHAR(255)', undef, 1, 2, 5, 10, 100, 200, 255 ],
23
+ [ 'VARCHAR(511)', undef, 1, 2, 5, 10, 100, 200, 511 ],
24
+ [ 'LONGTEXT', 500, 1, 2, 5, 10, 100, 200, 511 ],
25
+ [ 'LONGBLOB', 500, 1, 2, 5, 10, 100, 200, 511 ],
26
+ # [ 'VARCHAR(4096)', 500, 1, 2, 5, 10, 100, 200, 255, 256, 4095 ],
27
+ # [ 'VARCHAR(16383)', 500, 1, 2, 5, 10, 100, 200, 255, 256, 4095, 4096, 16383 ],
28
+ # [ 'VARBINARY(16383)', 500, 1, 2, 5, 10, 100, 200, 255, 256, 4095, 4096, 16383 ],
29
+ ];
30
+
31
+ my $table = 'hstesttbl';
32
+ my $dbh;
33
+ for my $rec (@$string_types) {
34
+ my ($typ, $keylen, @vs) = @$rec;
35
+ my @vals = ();
36
+ for my $len (@vs) {
37
+ my $s = '';
38
+ my @arr = ();
39
+ srand(999);
40
+ # print "$len 1\n";
41
+ for (my $i = 0; $i < $len; ++$i) {
42
+ my $v = int(rand(10));
43
+ $arr[$i] = chr(65 + $v);
44
+ }
45
+ # print "2\n";
46
+ push(@vals, join('', @arr));
47
+ }
48
+ print("TYPE $typ\n");
49
+ test_one($typ, $keylen, \@vals);
50
+ print("\n");
51
+ }
52
+
53
+ sub test_one {
54
+ my ($typ, $keylen, $values) = @_;
55
+ my $keylen_str = '';
56
+ if (defined($keylen)) {
57
+ $keylen_str = "($keylen)";
58
+ }
59
+ $dbh = hstest::init_testdb();
60
+ $dbh->do(
61
+ "create table $table (" .
62
+ "k $typ, " .
63
+ "v1 varchar(2047), " .
64
+ "v2 $typ, " .
65
+ "primary key(k$keylen_str), " .
66
+ "index i1(v1), index i2(v2$keylen_str, v1(300))) " .
67
+ "engine = myisam default charset = latin1");
68
+ my $hs = hstest::get_hs_connection(undef, 9999);
69
+ my $dbname = $hstest::conf{dbname};
70
+ $hs->open_index(1, $dbname, $table, '', 'k,v1,v2');
71
+ $hs->open_index(2, $dbname, $table, 'i1', 'k,v1,v2');
72
+ $hs->open_index(3, $dbname, $table, 'i2', 'k,v1,v2');
73
+ for my $k (@$values) {
74
+ my $kstr = 's' . $k;
75
+ $hs->execute_single(1, '+', [ $k, $kstr, $k ], 0, 0);
76
+ }
77
+ # dump_table();
78
+ for my $k (@$values) {
79
+ my $kstr = 's' . $k;
80
+ my ($rk, $rv1, $rv2);
81
+ my $r;
82
+ $r = $hs->execute_single(1, '=', [ $k ], 1, 0);
83
+ shift(@$r);
84
+ check_value("$typ:PK", @$r);
85
+ $r = $hs->execute_single(2, '=', [ $kstr ], 1, 0);
86
+ shift(@$r);
87
+ check_value("$typ:I1", @$r);
88
+ $r = $hs->execute_single(3, '=', [ $k, $kstr ], 1, 0);
89
+ shift(@$r);
90
+ check_value("$typ:I2", @$r);
91
+ $r = $hs->execute_single(3, '=', [ $k ], 1, 0);
92
+ shift(@$r);
93
+ check_value("$typ:I2p", @$r);
94
+ }
95
+ }
96
+
97
+ sub check_value {
98
+ my ($mess, $rk, $rv1, $rv2) = @_;
99
+ $rk ||= '';
100
+ $rv1 ||= '';
101
+ $rv2 ||= '';
102
+ if ($rv2 ne $rk) {
103
+ print "$mess: V2 NE\n$rk\n$rv2\n";
104
+ return;
105
+ }
106
+ if ($rv1 ne 's' . $rk) {
107
+ print "$mess: V1 NE\n$rk\n$rv1\n";
108
+ return;
109
+ }
110
+ print "$mess: EQ\n";
111
+ }
112
+
113
+ sub dump_table {
114
+ print "DUMP_TABLE_BEGIN\n";
115
+ my $aref = $dbh->selectall_arrayref("select k,v1,v2 from $table order by k");
116
+ for my $row (@$aref) {
117
+ my ($k, $v1, $v2) = @$row;
118
+ $v1 = "[null]" if !defined($v1);
119
+ $v2 = "[null]" if !defined($v2);
120
+ print "$k $v1 $v2\n";
121
+ # print "MISMATCH\n" if ($valmap{$k} ne $v);
122
+ }
123
+ print "DUMP_TABLE_END\n";
124
+ }
125
+
@@ -0,0 +1,22 @@
1
+ HSINSERT
2
+ 1 v1hs_0
3
+ 2 v1hs_1
4
+ 3 v1hs_2
5
+ 4 v1hs_3
6
+ 5 v1hs_4
7
+ 6 v1hs_5
8
+ 7 v1hs_6
9
+ 8 v1hs_7
10
+ 9 v1hs_8
11
+ 10 v1hs_9
12
+ DUMP_TABLE
13
+ 1 v1hs_0
14
+ 2 v1hs_1
15
+ 3 v1hs_2
16
+ 4 v1hs_3
17
+ 5 v1hs_4
18
+ 6 v1hs_5
19
+ 7 v1hs_6
20
+ 8 v1hs_7
21
+ 9 v1hs_8
22
+ 10 v1hs_9
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/perl
2
+
3
+ # vim:sw=2:ai
4
+
5
+ # tests that columns to be inserted are specified by open_index
6
+
7
+ BEGIN {
8
+ push @INC, "../common/";
9
+ };
10
+
11
+ use strict;
12
+ use warnings;
13
+ use hstest;
14
+
15
+ my $dbh = hstest::init_testdb();
16
+ my $table = 'hstesttbl';
17
+ my $tablesize = 10;
18
+ $dbh->do(
19
+ "create table $table (" .
20
+ "k int primary key auto_increment, " .
21
+ "v1 varchar(30), " .
22
+ "v2 varchar(30)) " .
23
+ "engine = myisam default charset = binary");
24
+ srand(999);
25
+
26
+ my %valmap = ();
27
+
28
+ print "HSINSERT\n";
29
+ my $hs = hstest::get_hs_connection(undef, 9999);
30
+ my $dbname = $hstest::conf{dbname};
31
+ $hs->open_index(1, $dbname, $table, '', 'v1');
32
+ # inserts with auto_increment
33
+ for (my $i = 0; $i < $tablesize; ++$i) {
34
+ my $k = 0;
35
+ my $v1 = "v1hs_" . $i;
36
+ my $v2 = "v2hs_" . $i;
37
+ my $r = $hs->execute_insert(1, [ $v1 ]);
38
+ my $err = $r->[0];
39
+ if ($err != 0) {
40
+ my $err_str = $r->[1];
41
+ print "$err $err_str\n";
42
+ } else {
43
+ my $id = $r->[1];
44
+ print "$id $v1\n";
45
+ }
46
+ }
47
+
48
+ undef $hs;
49
+
50
+ dump_table();
51
+
52
+ sub dump_table {
53
+ print "DUMP_TABLE\n";
54
+ my $aref = $dbh->selectall_arrayref("select k,v1,v2 from $table order by k");
55
+ for my $row (@$aref) {
56
+ my ($k, $v1, $v2) = @$row;
57
+ $v1 = "[null]" if !defined($v1);
58
+ $v2 = "[null]" if !defined($v2);
59
+ print "$k $v1 $v2\n";
60
+ # print "MISMATCH\n" if ($valmap{$k} ne $v);
61
+ }
62
+ }
63
+