--- sql/pgtap.sql +++ sql/pgtap.sql @@ -3689,7 +3689,7 @@ AND n.nspname = $1 AND t.typname = $2 AND t.typtype = 'e' - ORDER BY e.enumsortorder + ORDER BY e.oid ), $3, $4 @@ -3717,7 +3717,7 @@ AND pg_catalog.pg_type_is_visible(t.oid) AND t.typname = $1 AND t.typtype = 'e' - ORDER BY e.enumsortorder + ORDER BY e.oid ), $2, $3 @@ -6161,7 +6161,7 @@ CREATE OR REPLACE FUNCTION findfuncs( NAME, TEXT, TEXT ) RETURNS TEXT[] AS $$ SELECT ARRAY( - SELECT DISTINCT (quote_ident(n.nspname) || '.' || quote_ident(p.proname)) COLLATE "C" AS pname + SELECT DISTINCT (quote_ident(n.nspname) || '.' || quote_ident(p.proname)) AS pname FROM pg_catalog.pg_proc p JOIN pg_catalog.pg_namespace n ON p.pronamespace = n.oid WHERE n.nspname = $1 @@ -6178,7 +6178,7 @@ CREATE OR REPLACE FUNCTION findfuncs( TEXT, TEXT ) RETURNS TEXT[] AS $$ SELECT ARRAY( - SELECT DISTINCT (quote_ident(n.nspname) || '.' || quote_ident(p.proname)) COLLATE "C" AS pname + SELECT DISTINCT (quote_ident(n.nspname) || '.' || quote_ident(p.proname)) AS pname FROM pg_catalog.pg_proc p JOIN pg_catalog.pg_namespace n ON p.pronamespace = n.oid WHERE pg_catalog.pg_function_is_visible(p.oid) @@ -9680,137 +9680,6 @@ GRANT SELECT ON tap_funky TO PUBLIC; GRANT SELECT ON pg_all_foreign_keys TO PUBLIC; --- Get extensions in a given schema -CREATE OR REPLACE FUNCTION _extensions( NAME ) -RETURNS SETOF NAME AS $$ - SELECT e.extname - FROM pg_catalog.pg_namespace n - JOIN pg_catalog.pg_extension e ON n.oid = e.extnamespace - WHERE n.nspname = $1 -$$ LANGUAGE SQL; - -CREATE OR REPLACE FUNCTION _extensions() -RETURNS SETOF NAME AS $$ - SELECT extname FROM pg_catalog.pg_extension -$$ LANGUAGE SQL; - --- extensions_are( schema, extensions, description ) -CREATE OR REPLACE FUNCTION extensions_are( NAME, NAME[], TEXT ) -RETURNS TEXT AS $$ - SELECT _are( - 'extensions', - ARRAY(SELECT _extensions($1) EXCEPT SELECT unnest($2)), - ARRAY(SELECT unnest($2) EXCEPT SELECT _extensions($1)), - $3 - ); -$$ LANGUAGE SQL; - --- extensions_are( schema, extensions) -CREATE OR REPLACE FUNCTION extensions_are( NAME, NAME[] ) -RETURNS TEXT AS $$ - SELECT extensions_are( - $1, $2, - 'Schema ' || quote_ident($1) || ' should have the correct extensions' - ); -$$ LANGUAGE SQL; - --- extensions_are( extensions, description ) -CREATE OR REPLACE FUNCTION extensions_are( NAME[], TEXT ) -RETURNS TEXT AS $$ - SELECT _are( - 'extensions', - ARRAY(SELECT _extensions() EXCEPT SELECT unnest($1)), - ARRAY(SELECT unnest($1) EXCEPT SELECT _extensions()), - $2 - ); -$$ LANGUAGE SQL; - --- extensions_are( schema, extensions) -CREATE OR REPLACE FUNCTION extensions_are( NAME[] ) -RETURNS TEXT AS $$ - SELECT extensions_are($1, 'Should have the correct extensions'); -$$ LANGUAGE SQL; - --- check extension exists function with schema name -CREATE OR REPLACE FUNCTION _ext_exists( NAME, NAME ) -RETURNS BOOLEAN AS $$ - SELECT EXISTS ( - SELECT TRUE - FROM pg_catalog.pg_extension ex - JOIN pg_catalog.pg_namespace n ON ex.extnamespace = n.oid - WHERE n.nspname = $1 - AND ex.extname = $2 - ); -$$ LANGUAGE SQL; - --- check extension exists function without schema name -CREATE OR REPLACE FUNCTION _ext_exists( NAME ) -RETURNS BOOLEAN AS $$ - SELECT EXISTS ( - SELECT TRUE - FROM pg_catalog.pg_extension ex - WHERE ex.extname = $1 - ); -$$ LANGUAGE SQL; - --- has_extension( schema, name, description ) -CREATE OR REPLACE FUNCTION has_extension( NAME, NAME, TEXT ) -RETURNS TEXT AS $$ - SELECT ok( _ext_exists( $1, $2 ), $3 ); -$$ LANGUAGE SQL; - --- has_extension( schema, name ) -CREATE OR REPLACE FUNCTION has_extension( NAME, NAME ) -RETURNS TEXT AS $$ - SELECT ok( - _ext_exists( $1, $2 ), - 'Extension ' || quote_ident($2) - || ' should exist in schema ' || quote_ident($1) ); -$$ LANGUAGE SQL; - --- has_extension( name, description ) -CREATE OR REPLACE FUNCTION has_extension( NAME, TEXT ) -RETURNS TEXT AS $$ - SELECT ok( _ext_exists( $1 ), $2) -$$ LANGUAGE SQL; - --- has_extension( name ) -CREATE OR REPLACE FUNCTION has_extension( NAME ) -RETURNS TEXT AS $$ - SELECT ok( - _ext_exists( $1 ), - 'Extension ' || quote_ident($1) || ' should exist' ); -$$ LANGUAGE SQL; - --- hasnt_extension( schema, name, description ) -CREATE OR REPLACE FUNCTION hasnt_extension( NAME, NAME, TEXT ) -RETURNS TEXT AS $$ - SELECT ok( NOT _ext_exists( $1, $2 ), $3 ); -$$ LANGUAGE SQL; - --- hasnt_extension( schema, name ) -CREATE OR REPLACE FUNCTION hasnt_extension( NAME, NAME ) -RETURNS TEXT AS $$ - SELECT ok( - NOT _ext_exists( $1, $2 ), - 'Extension ' || quote_ident($2) - || ' should not exist in schema ' || quote_ident($1) ); -$$ LANGUAGE SQL; - --- hasnt_extension( name, description ) -CREATE OR REPLACE FUNCTION hasnt_extension( NAME, TEXT ) -RETURNS TEXT AS $$ - SELECT ok( NOT _ext_exists( $1 ), $2) -$$ LANGUAGE SQL; - --- hasnt_extension( name ) -CREATE OR REPLACE FUNCTION hasnt_extension( NAME ) -RETURNS TEXT AS $$ - SELECT ok( - NOT _ext_exists( $1 ), - 'Extension ' || quote_ident($1) || ' should not exist' ); -$$ LANGUAGE SQL; - -- is_partitioned( schema, table, description ) CREATE OR REPLACE FUNCTION is_partitioned ( NAME, NAME, TEXT ) RETURNS TEXT AS $$