pg_catalog_views.slt 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 VIEW test_view1 AS SELECT 1
  12. statement ok
  13. CREATE VIEW test_view2 AS SELECT 2
  14. query TTT colnames
  15. SELECT schemaname, viewname, definition FROM pg_catalog.pg_views WHERE viewname LIKE 'test_%'
  16. ----
  17. schemaname viewname definition
  18. public test_view1 SELECT␠1;
  19. public test_view2 SELECT␠2;
  20. query I
  21. SELECT COUNT(*) FROM pg_catalog.pg_views WHERE viewname LIKE 'test_%' AND viewowner IS NOT NULL
  22. ----
  23. 2
  24. mode standard
  25. # test SHOW CREATE for pg_views
  26. query TT
  27. SHOW CREATE VIEW pg_views
  28. ----
  29. pg_catalog.pg_views
  30. CREATE VIEW⏎ pg_catalog.pg_views⏎ AS⏎ SELECT⏎ s.name AS schemaname,⏎ v.name AS viewname,⏎ role_owner.oid AS viewowner,⏎ v.definition AS definition⏎ FROM⏎ mz_catalog.mz_views AS v⏎ LEFT JOIN mz_catalog.mz_schemas AS s ON s.id = v.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 = v.owner_id⏎ WHERE s.database_id IS NULL OR d.name = pg_catalog.current_database();
  31. # test that nothing in the pg_catalog or information_schema schemas use unsinged ints
  32. query ITITTITT
  33. SELECT
  34. class_objects.oid as attrelid,
  35. mz_columns.name as attname,
  36. mz_columns.type_oid AS atttypid,
  37. class_objects.type as relation_type,
  38. mz_columns.type as typename,
  39. position as attnum,
  40. mzsc.name as schema_name,
  41. class_objects.name as relation_name
  42. FROM (
  43. SELECT id, oid, schema_id, name, type FROM mz_catalog.mz_relations
  44. UNION ALL
  45. SELECT mz_indexes.id, mz_indexes.oid, mz_relations.schema_id, mz_indexes.name, 'index' AS type
  46. FROM mz_catalog.mz_indexes
  47. JOIN mz_catalog.mz_relations ON mz_indexes.on_id = mz_relations.id
  48. ) AS class_objects
  49. JOIN mz_catalog.mz_columns ON class_objects.id = mz_columns.id
  50. JOIN pg_catalog.pg_type ON pg_type.oid = mz_columns.type_oid
  51. JOIN mz_catalog.mz_databases d ON (d.id IS NULL OR d.name = pg_catalog.current_database())
  52. JOIN mz_catalog.mz_schemas mzsc ON class_objects.schema_id = mzsc.id
  53. WHERE mzsc.name IN ('pg_catalog', 'information_schema')
  54. AND mz_columns.type like '%uint%'
  55. ----