verify-rtr.td 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. $ postgres-execute connection=postgres://mz_system:materialize@${testdrive.materialize-internal-sql-addr}
  10. ALTER SYSTEM SET allow_real_time_recency = true
  11. > SET TRANSACTION_ISOLATION = 'STRICT SERIALIZABLE';
  12. > SET REAL_TIME_RECENCY TO TRUE
  13. $ mysql-connect name=mysql url=mysql://root@mysql password=${arg.mysql-root-password}
  14. $ mysql-execute name=mysql
  15. USE public;
  16. INSERT INTO table_a SELECT 1,2 FROM mysql.time_zone t1, mysql.time_zone t2 LIMIT 100;
  17. INSERT INTO table_b SELECT 1,2 FROM mysql.time_zone t1, mysql.time_zone t2 LIMIT 100;
  18. INSERT INTO table_a SELECT 1,2 FROM mysql.time_zone t1, mysql.time_zone t2 LIMIT 101;
  19. INSERT INTO table_b SELECT 1,2 FROM mysql.time_zone t1, mysql.time_zone t2 LIMIT 102;
  20. # This is a RTR query, so the first result should be correct
  21. $ set-max-tries max-tries=1
  22. > SELECT sum(count)
  23. FROM (
  24. SELECT count(*) FROM table_a
  25. UNION ALL SELECT count(*) FROM table_b
  26. UNION ALL SELECT count(*) FROM t
  27. );
  28. 604
  29. # Do it again
  30. $ mysql-execute name=mysql
  31. INSERT INTO table_a SELECT 1,2 FROM mysql.time_zone t1, mysql.time_zone t2 LIMIT 101;
  32. INSERT INTO table_b SELECT 1,2 FROM mysql.time_zone t1, mysql.time_zone t2 LIMIT 102;
  33. > SELECT sum(count)
  34. FROM (
  35. SELECT count(*) FROM table_a
  36. UNION ALL SELECT count(*) FROM table_b
  37. UNION ALL SELECT count(*) FROM t
  38. );
  39. 807
  40. # Demo materialized views built on sources obey RTR.
  41. > SET REAL_TIME_RECENCY TO FALSE
  42. $ mysql-execute name=mysql
  43. INSERT INTO table_a SELECT 1,2 FROM mysql.time_zone t1, mysql.time_zone t2 LIMIT 100;
  44. INSERT INTO table_b SELECT 1,2 FROM mysql.time_zone t1, mysql.time_zone t2 LIMIT 100;
  45. > SELECT sum < 4000207 FROM sum;
  46. true
  47. > SET REAL_TIME_RECENCY TO TRUE
  48. > SELECT sum FROM sum;
  49. 1007
  50. # Do it again
  51. $ mysql-execute name=mysql
  52. INSERT INTO table_a SELECT 1,2 FROM mysql.time_zone t1, mysql.time_zone t2 LIMIT 100;
  53. INSERT INTO table_b SELECT 1,2 FROM mysql.time_zone t1, mysql.time_zone t2 LIMIT 100;
  54. > SELECT sum FROM sum;
  55. 1207