support-multiple-materializations.td 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 that any replication slot can only be materialized once
  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. # Insert data pre-snapshot
  21. $ mysql-execute name=mysql
  22. DROP DATABASE IF EXISTS public;
  23. CREATE DATABASE public;
  24. USE public;
  25. CREATE TABLE t1 (id SERIAL PRIMARY KEY, f1 BOOLEAN);
  26. CREATE TABLE t2 (id SERIAL PRIMARY KEY, t1_id BIGINT UNSIGNED REFERENCES t1(id), name VARCHAR(32));
  27. INSERT INTO t1(f1) VALUES (true),(false);
  28. INSERT INTO t2(t1_id, name) VALUES (1, 'example');
  29. > CREATE SOURCE mz_source
  30. FROM MYSQL CONNECTION mysql_conn
  31. FOR ALL TABLES;
  32. > CREATE MATERIALIZED VIEW t1_mat AS
  33. SELECT * FROM t1
  34. > SELECT id, f1 FROM t1_mat;
  35. 1 1
  36. 2 0
  37. > CREATE MATERIALIZED VIEW t1_mat_dupe AS
  38. SELECT * FROM t1
  39. > DROP MATERIALIZED VIEW t1_mat;
  40. > DROP SOURCE mz_source CASCADE;
  41. # verify that dropping things allows recreation
  42. > CREATE SOURCE mz_source
  43. FROM MYSQL CONNECTION mysql_conn
  44. FOR ALL TABLES;
  45. > CREATE MATERIALIZED VIEW joiner AS
  46. SELECT t2.id, t1.f1, t2.name
  47. FROM t1
  48. JOIN t2
  49. ON t1.id = t2.t1_id
  50. > SELECT * FROM joiner;
  51. 1 1 example