-- -- Regression tests for schemas (namespaces) --
-- set the whitespace-only search_path to test that the -- GUC list syntax is preserved during a schema creation SELECT pg_catalog.set_config('search_path', ' ', false);
CREATESCHEMA test_ns_schema_1 CREATEUNIQUEINDEX abc_a_idx ON abc (a)
CREATE VIEW abc_view AS SELECT a+1AS a, b+1AS b FROM abc
CREATETABLE abc (
a serial,
b intUNIQUE
);
-- verify that the correct search_path restored on abort SET search_path to public;
BEGIN; SET search_path to public, test_ns_schema_1; CREATESCHEMA test_ns_schema_2 CREATE VIEW abc_view ASSELECT c FROM abc; COMMIT; SHOW search_path;
-- verify that the correct search_path preserved -- after creating the schema and on commit
BEGIN; SET search_path to public, test_ns_schema_1; CREATESCHEMA test_ns_schema_2 CREATE VIEW abc_view ASSELECT a FROM abc; SHOW search_path; COMMIT; SHOW search_path; DROPSCHEMA test_ns_schema_2 CASCADE;
-- verify that the objects were created SELECT COUNT(*) FROM pg_class WHERE relnamespace =
(SELECT oid FROM pg_namespace WHERE nspname = 'test_ns_schema_1');
SELECT * FROM test_ns_schema_1.abc; SELECT * FROM test_ns_schema_1.abc_view;
ALTERSCHEMA test_ns_schema_1 RENAMETO test_ns_schema_renamed; SELECT COUNT(*) FROM pg_class WHERE relnamespace =
(SELECT oid FROM pg_namespace WHERE nspname = 'test_ns_schema_1');
-- test IF NOT EXISTS cases CREATESCHEMA test_ns_schema_renamed; -- fail, already exists CREATESCHEMAIFNOTEXISTS test_ns_schema_renamed; -- ok with notice CREATESCHEMAIFNOTEXISTS test_ns_schema_renamed -- fail, disallowed CREATETABLE abc (
a serial,
b intUNIQUE
);
DROPSCHEMA test_ns_schema_renamed CASCADE;
-- verify that the objects were dropped SELECT COUNT(*) FROM pg_class WHERE relnamespace =
(SELECT oid FROM pg_namespace WHERE nspname = 'test_ns_schema_renamed');
-- -- Verify that search_path is set to a safe value during maintenance -- commands. --
CREATESCHEMA test_maint_search_path; SET search_path = test_maint_search_path;
CREATE FUNCTION fn(INT) RETURNS INT IMMUTABLE LANGUAGE plpgsql AS $$
BEGIN
RAISE NOTICE 'current search_path: %', current_setting('search_path'); RETURN $1;
END;
$$;
-- the following commands should see search_path as pg_catalog, pg_temp
CREATEINDEX test_maint_idx ON test_maint_search_path.test_maint (fn(i));
REINDEX TABLE test_maint_search_path.test_maint; ANALYZE test_maint_search_path.test_maint;
VACUUM FULL test_maint_search_path.test_maint;
CLUSTER test_maint_search_path.test_maint USING test_maint_idx;
REFRESH MATERIALIZED VIEW test_maint_search_path.test_maint_mv;
RESET search_path;
DROPSCHEMA test_maint_search_path CASCADE;
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.1Bemerkung:
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.