pg_catalog_matviews.slt 2.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. mode cockroach
  10. statement ok
  11. CREATE MATERIALIZED VIEW test_view1 AS SELECT 1
  12. statement ok
  13. CREATE MATERIALIZED VIEW test_view2 AS SELECT 2
  14. query TTT colnames
  15. SELECT schemaname, matviewname, definition FROM pg_catalog.pg_matviews WHERE matviewname LIKE 'test_%'
  16. ----
  17. schemaname matviewname definition
  18. public test_view1 SELECT␠1;
  19. public test_view2 SELECT␠2;
  20. query I
  21. SELECT COUNT(*) FROM pg_catalog.pg_matviews WHERE matviewowner IS NOT NULL
  22. ----
  23. 2
  24. mode standard
  25. # test SHOW CREATE for pg_matviews
  26. query TT
  27. SHOW CREATE VIEW pg_matviews
  28. ----
  29. pg_catalog.pg_matviews
  30. CREATE VIEW⏎ pg_catalog.pg_matviews⏎ AS⏎ SELECT⏎ s.name AS schemaname,⏎ m.name AS matviewname,⏎ role_owner.oid AS matviewowner,⏎ m.definition AS definition⏎ FROM⏎ mz_catalog.mz_materialized_views AS m⏎ LEFT JOIN mz_catalog.mz_schemas AS s ON s.id = m.schema_id⏎ LEFT JOIN mz_catalog.mz_databases AS d ON d.id = s.database_id⏎ JOIN mz_catalog.mz_roles AS role_owner ON role_owner.id = m.owner_id⏎ WHERE s.database_id IS NULL OR d.name = pg_catalog.current_database();
  31. simple multiline,conn=mz_catalog_server,user=mz_support
  32. SELECT create_sql FROM (SHOW CREATE VIEW pg_matviews);
  33. ----
  34. CREATE VIEW
  35. pg_catalog.pg_matviews
  36. AS
  37. SELECT
  38. s.name AS schemaname,
  39. m.name AS matviewname,
  40. role_owner.oid AS matviewowner,
  41. m.definition AS definition
  42. FROM
  43. mz_catalog.mz_materialized_views AS m
  44. LEFT JOIN mz_catalog.mz_schemas AS s ON s.id = m.schema_id
  45. LEFT JOIN mz_catalog.mz_databases AS d ON d.id = s.database_id
  46. JOIN mz_catalog.mz_roles AS role_owner ON role_owner.id = m.owner_id
  47. WHERE s.database_id IS NULL OR d.name = pg_catalog.current_database();
  48. EOF
  49. COMPLETE 1