table-persistence-before-basic.td 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. #
  10. # The simplest smoke test
  11. #
  12. > CREATE TABLE t1 (f1 TIMESTAMP, f2 BYTEA);
  13. > INSERT INTO t1 VALUES (NULL, NULL);
  14. > INSERT INTO t1 VALUES ('2011-11-11 11:11:11', decode('1234', 'hex'));
  15. > CREATE MATERIALIZED VIEW v1 AS SELECT * FROM t1;
  16. #
  17. # Exotic types
  18. #
  19. > CREATE TYPE int4_list AS LIST (ELEMENT TYPE = int4);
  20. > CREATE TYPE int4_list_list AS LIST (ELEMENT TYPE = int4_list);
  21. > CREATE TYPE int4_map AS MAP (KEY TYPE = text, VALUE TYPE = int4);
  22. > CREATE TYPE int4_map_map AS MAP (KEY TYPE = text, VALUE TYPE = int4_map);
  23. > CREATE TABLE exotic_types (int4_list int4_list, int4_list_list int4_list_list, int4_map int4_map, int4_map_map int4_map_map);
  24. > INSERT INTO exotic_types VALUES ('{1,2}'::int4_list, '{{1,2}}'::int4_list_list, '{a=>1}'::int4_map, '{a=>{a=>1}}'::int4_map_map);
  25. > CREATE TABLE char_type_quoted (f1 "char");
  26. > INSERT INTO char_type_quoted VALUES ('a');
  27. #
  28. # Make sure dropping a table does not break persistence of other tables
  29. #
  30. > CREATE TABLE to_be_dropped (f1 INTEGER);
  31. > INSERT INTO to_be_dropped VALUES (1),(2),(3);
  32. > DROP TABLE to_be_dropped;
  33. #
  34. # Make sure persisting the same table in different schema does not cause interference
  35. #
  36. > CREATE SCHEMA schema1;
  37. > CREATE SCHEMA schema2;
  38. > CREATE TABLE schema1.t1 (f1 TEXT);
  39. > INSERT INTO schema1.t1 VALUES ('schema1');
  40. > CREATE TABLE schema2.t1 (f1 TEXT);
  41. > INSERT INTO schema2.t1 VALUES ('schema2');
  42. #
  43. # A table that has been dropped and recreated should not have its old data
  44. #
  45. > CREATE TABLE to_be_recreated (f1 INTEGER);
  46. > INSERT INTO to_be_recreated VALUES (1);
  47. > DROP TABLE to_be_recreated;
  48. > CREATE TABLE to_be_recreated (f1 INTEGER);
  49. > INSERT INTO to_be_recreated VALUES (2);
  50. #
  51. # A table that has been renamed should remain readable
  52. #
  53. > CREATE TABLE to_be_renamed (f1 INTEGER);
  54. > INSERT INTO to_be_renamed VALUES (1);
  55. > ALTER TABLE to_be_renamed RENAME TO already_renamed;
  56. > INSERT INTO already_renamed VALUES (2);