You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

304 lines
10 KiB

22 years ago
  1. #
  2. # Initialize
  3. --disable_warnings
  4. drop table if exists t1, t2;
  5. --enable_warnings
  6. #
  7. # Test of reading of bigint values
  8. #
  9. select 0,256,00000000000000065536,2147483647,-2147483648,2147483648,+4294967296;
  10. select 9223372036854775807,-009223372036854775808;
  11. select +9999999999999999999,-9999999999999999999;
  12. select cast(9223372036854775808 as unsigned)+1;
  13. select 9223372036854775808+1;
  14. select -(0-3),round(-(0-3)), round(9999999999999999999);
  15. select 1,11,101,1001,10001,100001,1000001,10000001,100000001,1000000001,10000000001,100000000001,1000000000001,10000000000001,100000000000001,1000000000000001,10000000000000001,100000000000000001,1000000000000000001,10000000000000000001;
  16. select -1,-11,-101,-1001,-10001,-100001,-1000001,-10000001,-100000001,-1000000001,-10000000001,-100000000001,-1000000000001,-10000000000001,-100000000000001,-1000000000000001,-10000000000000001,-100000000000000001,-1000000000000000001,-10000000000000000001;
  17. select conv(1,10,16),conv((1<<2)-1,10,16),conv((1<<10)-2,10,16),conv((1<<16)-3,10,16),conv((1<<25)-4,10,16),conv((1<<31)-5,10,16),conv((1<<36)-6,10,16),conv((1<<47)-7,10,16),conv((1<<48)-8,10,16),conv((1<<55)-9,10,16),conv((1<<56)-10,10,16),conv((1<<63)-11,10,16);
  18. #
  19. # In 3.23 we have to disable the test of column to bigint as
  20. # this fails on AIX powerpc (the resolution for double is not good enough)
  21. # This will work on 4.0 as we then have internal handling of bigint variables.
  22. #
  23. create table t1 (a bigint unsigned not null, primary key(a));
  24. insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612);
  25. select * from t1;
  26. select * from t1 where a=18446744073709551615;
  27. # select * from t1 where a='18446744073709551615';
  28. delete from t1 where a=18446744073709551615;
  29. select * from t1;
  30. drop table t1;
  31. create table t1 ( a int not null default 1, big bigint );
  32. insert into t1 (big) values (-1),(12345678901234567),(9223372036854775807),(18446744073709551615);
  33. select * from t1;
  34. select min(big),max(big),max(big)-1 from t1;
  35. select min(big),max(big),max(big)-1 from t1 group by a;
  36. alter table t1 modify big bigint unsigned not null;
  37. select min(big),max(big),max(big)-1 from t1;
  38. select min(big),max(big),max(big)-1 from t1 group by a;
  39. insert into t1 (big) values (18446744073709551615);
  40. select * from t1;
  41. select min(big),max(big),max(big)-1 from t1;
  42. select min(big),max(big),max(big)-1 from t1 group by a;
  43. alter table t1 add key (big);
  44. select min(big),max(big),max(big)-1 from t1;
  45. select min(big),max(big),max(big)-1 from t1 group by a;
  46. alter table t1 modify big bigint not null;
  47. select * from t1;
  48. select min(big),max(big),max(big)-1 from t1;
  49. select min(big),max(big),max(big)-1 from t1 group by a;
  50. drop table t1;
  51. #
  52. # Test problem with big values for auto_increment
  53. #
  54. create table t1 (id bigint auto_increment primary key, a int) auto_increment=9999999999;
  55. insert into t1 values (null,1);
  56. select * from t1;
  57. select * from t1 limit 9999999999;
  58. drop table t1;
  59. #
  60. # Item_uint::save_to_field()
  61. # BUG#1845
  62. # This can't be fixed in MySQL 4.0 without loosing precisions for bigints
  63. #
  64. CREATE TABLE t1 ( quantity decimal(60,0));
  65. insert into t1 values (10000000000000000000);
  66. insert into t1 values (10000000000000000000.0);
  67. insert into t1 values ('10000000000000000000');
  68. select * from t1;
  69. drop table t1;
  70. # atof() behaviour is different of different systems. to be fixed in 4.1
  71. SELECT '0x8000000000000001'+0;
  72. # Test for BUG#8562: joins over BIGINT UNSIGNED value + constant propagation
  73. create table t1 (
  74. value64 bigint unsigned not null,
  75. value32 integer not null,
  76. primary key(value64, value32)
  77. );
  78. create table t2 (
  79. value64 bigint unsigned not null,
  80. value32 integer not null,
  81. primary key(value64, value32)
  82. );
  83. insert into t1 values(17156792991891826145, 1);
  84. insert into t1 values( 9223372036854775807, 2);
  85. insert into t2 values(17156792991891826145, 3);
  86. insert into t2 values( 9223372036854775807, 4);
  87. select * from t1;
  88. select * from t2;
  89. select * from t1, t2 where t1.value64=17156792991891826145 and
  90. t2.value64=17156792991891826145;
  91. select * from t1, t2 where t1.value64=17156792991891826145 and
  92. t2.value64=t1.value64;
  93. select * from t1, t2 where t1.value64= 9223372036854775807 and
  94. t2.value64=9223372036854775807;
  95. select * from t1, t2 where t1.value64= 9223372036854775807 and
  96. t2.value64=t1.value64;
  97. drop table t1, t2;
  98. # End of 4.1 tests
  99. #
  100. # Test of CREATE ... SELECT and unsigned integers
  101. #
  102. create table t1 select 1 as 'a';
  103. show create table t1;
  104. drop table t1;
  105. create table t1 select 9223372036854775809 as 'a';
  106. show create table t1;
  107. select * from t1;
  108. drop table t1;
  109. DROP DATABASE IF EXISTS `scott`;
  110. #
  111. # Check various conversions from/to unsigned bigint.
  112. #
  113. create table t1 (a char(100), b varchar(100), c text, d blob);
  114. insert into t1 values(
  115. 18446744073709551615,18446744073709551615,
  116. 18446744073709551615, 18446744073709551615
  117. );
  118. insert into t1 values (-1 | 0,-1 | 0,-1 | 0 ,-1 | 0);
  119. select * from t1;
  120. drop table t1;
  121. create table t1 ( quantity decimal(2) unsigned);
  122. insert into t1 values (500), (-500), (~0), (-1);
  123. select * from t1;
  124. drop table t1;
  125. #
  126. # Test of storing decimal values in BIGINT range
  127. # (Bug #12750: Incorrect storage of 9999999999999999999 in DECIMAL(19, 0))
  128. #
  129. CREATE TABLE t1 (
  130. `col1` INT(1) NULL,
  131. `col2` INT(2) NULL,
  132. `col3` INT(3) NULL,
  133. `col4` INT(4) NULL,
  134. `col5` INT(5) NULL,
  135. `col6` INT(6) NULL,
  136. `col7` INT(7) NULL,
  137. `col8` INT(8) NULL,
  138. `col9` INT(9) NULL,
  139. `col10` BIGINT(10) NULL,
  140. `col11` BIGINT(11) NULL,
  141. `col12` BIGINT(12) NULL,
  142. `col13` BIGINT(13) NULL,
  143. `col14` BIGINT(14) NULL,
  144. `col15` BIGINT(15) NULL,
  145. `col16` BIGINT(16) NULL,
  146. `col17` BIGINT(17) NULL,
  147. `col18` BIGINT(18) NULL,
  148. `col19` DECIMAL(19, 0) NULL,
  149. `col20` DECIMAL(20, 0) NULL,
  150. `col21` DECIMAL(21, 0) NULL,
  151. `col22` DECIMAL(22, 0) NULL,
  152. `col23` DECIMAL(23, 0) NULL,
  153. `col24` DECIMAL(24, 0) NULL,
  154. `col25` DECIMAL(25, 0) NULL,
  155. `col26` DECIMAL(26, 0) NULL,
  156. `col27` DECIMAL(27, 0) NULL,
  157. `col28` DECIMAL(28, 0) NULL,
  158. `col29` DECIMAL(29, 0) NULL,
  159. `col30` DECIMAL(30, 0) NULL,
  160. `col31` DECIMAL(31, 0) NULL,
  161. `col32` DECIMAL(32, 0) NULL,
  162. `col33` DECIMAL(33, 0) NULL,
  163. `col34` DECIMAL(34, 0) NULL,
  164. `col35` DECIMAL(35, 0) NULL,
  165. `col36` DECIMAL(36, 0) NULL,
  166. `col37` DECIMAL(37, 0) NULL,
  167. `col38` DECIMAL(38, 0) NULL,
  168. `fix1` DECIMAL(38, 1) NULL,
  169. `fix2` DECIMAL(38, 2) NULL,
  170. `fix3` DECIMAL(38, 3) NULL,
  171. `fix4` DECIMAL(38, 4) NULL,
  172. `fix5` DECIMAL(38, 5) NULL,
  173. `fix6` DECIMAL(38, 6) NULL,
  174. `fix7` DECIMAL(38, 7) NULL,
  175. `fix8` DECIMAL(38, 8) NULL,
  176. `fix9` DECIMAL(38, 9) NULL,
  177. `fix10` DECIMAL(38, 10) NULL,
  178. `fix11` DECIMAL(38, 11) NULL,
  179. `fix12` DECIMAL(38, 12) NULL,
  180. `fix13` DECIMAL(38, 13) NULL,
  181. `fix14` DECIMAL(38, 14) NULL,
  182. `fix15` DECIMAL(38, 15) NULL,
  183. `fix16` DECIMAL(38, 16) NULL,
  184. `fix17` DECIMAL(38, 17) NULL,
  185. `fix18` DECIMAL(38, 18) NULL,
  186. `fix19` DECIMAL(38, 19) NULL,
  187. `fix20` DECIMAL(38, 20) NULL,
  188. `fix21` DECIMAL(38, 21) NULL,
  189. `fix22` DECIMAL(38, 22) NULL,
  190. `fix23` DECIMAL(38, 23) NULL,
  191. `fix24` DECIMAL(38, 24) NULL,
  192. `fix25` DECIMAL(38, 25) NULL,
  193. `fix26` DECIMAL(38, 26) NULL,
  194. `fix27` DECIMAL(38, 27) NULL,
  195. `fix28` DECIMAL(38, 28) NULL,
  196. `fix29` DECIMAL(38, 29) NULL,
  197. `fix30` DECIMAL(38, 30) NULL
  198. );
  199. INSERT INTO t1(`col1`, `col2`, `col3`, `col4`, `col5`, `col6`, `col7`, `col8`, `col9`, `col10`, `col11`, `col12`, `col13`, `col14`, `col15`, `col16`, `col17`, `col18`, `col19`, `col20`, `col21`, `col22`, `col23`, `col24`, `col25`, `col26`, `col27`, `col28`, `col29`, `col30`, `col31`, `col32`, `col33`, `col34`, `col35`, `col36`, `col37`, `col38`, `fix1`, `fix2`, `fix3`, `fix4`, `fix5`, `fix6`, `fix7`, `fix8`, `fix9`, `fix10`, `fix11`, `fix12`, `fix13`, `fix14`, `fix15`, `fix16`, `fix17`, `fix18`, `fix19`, `fix20`, `fix21`, `fix22`, `fix23`, `fix24`, `fix25`, `fix26`, `fix27`, `fix28`, `fix29`, `fix30`)
  200. VALUES (9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999,
  201. 9999999999, 99999999999, 999999999999, 9999999999999, 99999999999999,
  202. 999999999999999, 9999999999999999, 99999999999999999, 999999999999999999,
  203. 9999999999999999999, 99999999999999999999, 999999999999999999999,
  204. 9999999999999999999999, 99999999999999999999999, 999999999999999999999999,
  205. 9999999999999999999999999, 99999999999999999999999999,
  206. 999999999999999999999999999, 9999999999999999999999999999,
  207. 99999999999999999999999999999, 999999999999999999999999999999,
  208. 9999999999999999999999999999999, 99999999999999999999999999999999,
  209. 999999999999999999999999999999999, 9999999999999999999999999999999999,
  210. 99999999999999999999999999999999999, 999999999999999999999999999999999999,
  211. 9999999999999999999999999999999999999, 99999999999999999999999999999999999999,
  212. 9999999999999999999999999999999999999.9,
  213. 999999999999999999999999999999999999.99,
  214. 99999999999999999999999999999999999.999,
  215. 9999999999999999999999999999999999.9999,
  216. 999999999999999999999999999999999.99999,
  217. 99999999999999999999999999999999.999999,
  218. 9999999999999999999999999999999.9999999,
  219. 999999999999999999999999999999.99999999,
  220. 99999999999999999999999999999.999999999,
  221. 9999999999999999999999999999.9999999999,
  222. 999999999999999999999999999.99999999999,
  223. 99999999999999999999999999.999999999999,
  224. 9999999999999999999999999.9999999999999,
  225. 999999999999999999999999.99999999999999,
  226. 99999999999999999999999.999999999999999,
  227. 9999999999999999999999.9999999999999999,
  228. 999999999999999999999.99999999999999999,
  229. 99999999999999999999.999999999999999999,
  230. 9999999999999999999.9999999999999999999,
  231. 999999999999999999.99999999999999999999,
  232. 99999999999999999.999999999999999999999,
  233. 9999999999999999.9999999999999999999999,
  234. 999999999999999.99999999999999999999999,
  235. 99999999999999.999999999999999999999999,
  236. 9999999999999.9999999999999999999999999,
  237. 999999999999.99999999999999999999999999,
  238. 99999999999.999999999999999999999999999,
  239. 9999999999.9999999999999999999999999999,
  240. 999999999.99999999999999999999999999999,
  241. 99999999.999999999999999999999999999999);
  242. SELECT * FROM t1;
  243. DROP TABLE t1;
  244. #bug #9088 BIGINT WHERE CLAUSE
  245. create table t1 (bigint_col bigint unsigned);
  246. insert into t1 values (17666000000000000000);
  247. select * from t1 where bigint_col=17666000000000000000;
  248. select * from t1 where bigint_col='17666000000000000000';
  249. drop table t1;
  250. --echo
  251. --echo bug 19955 -- mod is signed with bigint
  252. select cast(10000002383263201056 as unsigned) mod 50 as result;
  253. create table t1 (c1 bigint unsigned);
  254. insert into t1 values (10000002383263201056);
  255. select c1 mod 50 as result from t1;
  256. drop table t1;
  257. #
  258. # Bug #8663 cant use bgint unsigned as input to cast
  259. #
  260. select cast(19999999999999999999 as signed);
  261. select cast(-19999999999999999999 as signed);
  262. # Bug #28005 Partitions: can't use -9223372036854775808
  263. create table t1 select -9223372036854775808 bi;
  264. describe t1;
  265. drop table t1;
  266. create table t1 select -9223372036854775809 bi;
  267. describe t1;
  268. drop table t1;