invisible-columns.td 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. $ skip-if
  10. SELECT mz_version_num() < 13300;
  11. $ set-sql-timeout duration=1s
  12. #
  13. # Invisible columns
  14. #
  15. > CREATE SECRET mysqlpass AS '${arg.mysql-root-password}'
  16. > CREATE CONNECTION mysql_conn TO MYSQL (
  17. HOST mysql,
  18. USER root,
  19. PASSWORD SECRET mysqlpass
  20. )
  21. $ mysql-connect name=mysql url=mysql://root@mysql password=${arg.mysql-root-password}
  22. $ mysql-execute name=mysql
  23. DROP DATABASE IF EXISTS public;
  24. CREATE DATABASE public;
  25. USE public;
  26. CREATE TABLE t1 (f1 INT, f2 INT INVISIBLE, f3 INT INVISIBLE);
  27. INSERT INTO t1 (f1, f2, f3) VALUES (10, 20, 30);
  28. INSERT INTO t1 VALUES (11);
  29. > CREATE SOURCE mz_source
  30. FROM MYSQL CONNECTION mysql_conn
  31. FOR ALL TABLES;
  32. > SELECT * FROM t1;
  33. 10 20 30
  34. 11 <null> <null>
  35. $ mysql-execute name=mysql
  36. ALTER TABLE t1 ALTER COLUMN f2 SET VISIBLE;
  37. > SELECT * FROM t1;
  38. 10 20 30
  39. 11 <null> <null>
  40. $ mysql-execute name=mysql
  41. ALTER TABLE t1 DROP COLUMN f2;
  42. ! SELECT * FROM t1;
  43. contains:incompatible schema change