types-bit.td 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. $ set-sql-timeout duration=1s
  10. #
  11. # Test the BIT data type
  12. #
  13. > CREATE SECRET mysqlpass AS '${arg.mysql-root-password}'
  14. > CREATE CONNECTION mysql_conn TO MYSQL (
  15. HOST mysql,
  16. USER root,
  17. PASSWORD SECRET mysqlpass
  18. )
  19. $ mysql-connect name=mysql url=mysql://root@mysql password=${arg.mysql-root-password}
  20. $ mysql-execute name=mysql
  21. DROP DATABASE IF EXISTS public;
  22. CREATE DATABASE public;
  23. USE public;
  24. # Insert data pre-snapshot
  25. CREATE TABLE t1 (f1 BIT(11), f2 BIT(1));
  26. INSERT INTO t1 VALUES (8, 0);
  27. INSERT INTO t1 VALUES (13, 1);
  28. INSERT INTO t1 VALUES (b'11100000100', b'1');
  29. INSERT INTO t1 VALUES (b'0000', b'0');
  30. INSERT INTO t1 VALUES (b'11111111111', b'0');
  31. CREATE TABLE t2 (f1 BIT(64));
  32. INSERT INTO t2 VALUES (0);
  33. INSERT INTO t2 VALUES (1);
  34. INSERT INTO t2 VALUES (2032);
  35. INSERT INTO t2 VALUES (b'11111111');
  36. INSERT INTO t2 VALUES (b'1111111111111111111111111111111111111111111111111111111111111111');
  37. > CREATE SOURCE mz_source FROM MYSQL CONNECTION mysql_conn;
  38. > CREATE TABLE t1 FROM SOURCE mz_source (REFERENCE public.t1);
  39. > CREATE TABLE t2 FROM SOURCE mz_source (REFERENCE public.t2);
  40. > SELECT COUNT(*) > 0 FROM t1;
  41. true
  42. > SELECT COUNT(*) > 0 FROM t2;
  43. true
  44. # Insert the same data post-snapshot
  45. $ mysql-execute name=mysql
  46. INSERT INTO t1 SELECT * FROM t1;
  47. # MySQL does not have a proper boolean type
  48. > SELECT pg_typeof(f1), pg_typeof(f2) FROM t1 LIMIT 1;
  49. uint8 uint8
  50. > SELECT * FROM t1 ORDER BY f1 DESC;
  51. 0 0
  52. 0 0
  53. 8 0
  54. 8 0
  55. 13 1
  56. 13 1
  57. 1796 1
  58. 1796 1
  59. 2047 0
  60. 2047 0
  61. > SELECT * FROM t2 ORDER BY f1 DESC;
  62. 0
  63. 1
  64. 255
  65. 2032
  66. 18446744073709551615