two-destination-schemas.td 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 identically-named tables in two destination schemas can be
  12. # successfully disambiguated and replicated
  13. #
  14. > CREATE SECRET mysqlpass AS '${arg.mysql-root-password}'
  15. > CREATE CONNECTION mysql_conn TO MYSQL (
  16. HOST mysql,
  17. USER root,
  18. PASSWORD SECRET mysqlpass
  19. )
  20. $ mysql-connect name=mysql url=mysql://root@mysql password=${arg.mysql-root-password}
  21. $ mysql-execute name=mysql
  22. DROP DATABASE IF EXISTS public;
  23. CREATE DATABASE public;
  24. USE public;
  25. DROP TABLE IF EXISTS t1;
  26. DROP TABLE IF EXISTS t2;
  27. CREATE TABLE t1 (f1 INTEGER);
  28. INSERT INTO t1 VALUES (1);
  29. CREATE TABLE t2 (f1 INTEGER);
  30. INSERT INTO t2 VALUES (2);
  31. > DROP SCHEMA IF EXISTS schema1 CASCADE;
  32. > DROP SCHEMA IF EXISTS schema2 CASCADE;
  33. > CREATE SCHEMA schema1;
  34. > CREATE SCHEMA schema2;
  35. # TODO: database-issues#7397 (schema must be specified even when no collisions exist): remove public prefix
  36. > CREATE SOURCE mz_source
  37. FROM MYSQL CONNECTION mysql_conn
  38. FOR TABLES (public.t1 AS schema1.t1, public.t2 AS schema2.t1);
  39. > SELECT * FROM schema1.t1;
  40. 1
  41. > SELECT * FROM schema2.t1;
  42. 2
  43. $ mysql-execute name=mysql
  44. INSERT INTO t1 SELECT * FROM t1;
  45. INSERT INTO t2 SELECT * FROM t2;
  46. > SELECT * FROM schema1.t1;
  47. 1
  48. 1
  49. > SELECT * FROM schema2.t1;
  50. 2
  51. 2
  52. $ mysql-execute name=mysql
  53. DROP TABLE t1;
  54. DROP TABLE t2;
  55. > DROP SOURCE mz_source CASCADE;
  56. > DROP SCHEMA schema1 CASCADE;
  57. > DROP SCHEMA schema2 CASCADE;