__CDB_FS_List_Foreign_Schemas_PG: Handle order and ignore pg_% schemas automatically
This commit is contained in:
@@ -28,8 +28,12 @@ BEGIN
|
||||
EXECUTE format('IMPORT FOREIGN SCHEMA %I LIMIT TO (%I) FROM SERVER %I INTO %I', inf_schema, remote_table, server_internal, local_schema);
|
||||
END IF;
|
||||
|
||||
-- Return the result we're interested in
|
||||
RETURN QUERY EXECUTE format('SELECT schema_name::name AS remote_schema FROM %I.%I', local_schema, remote_table);
|
||||
-- Return the result we're interested in. Exclude toast and temp schemas
|
||||
RETURN QUERY EXECUTE format('
|
||||
SELECT schema_name::name AS remote_schema FROM %I.%I
|
||||
WHERE schema_name NOT LIKE %s
|
||||
ORDER BY remote_schema
|
||||
', local_schema, remote_table, '''pg_%''');
|
||||
END
|
||||
$$
|
||||
LANGUAGE PLPGSQL VOLATILE PARALLEL UNSAFE;
|
||||
@@ -63,7 +67,9 @@ BEGIN
|
||||
|
||||
-- Return the result we're interested in
|
||||
-- Note: in this context, schema names are not to be quoted
|
||||
RETURN QUERY EXECUTE format($q$SELECT table_name::name AS remote_table FROM %I.%I WHERE table_schema = '%s'$q$, local_schema, remote_table, remote_schema);
|
||||
RETURN QUERY EXECUTE format($q$
|
||||
SELECT table_name::name AS remote_table FROM %I.%I WHERE table_schema = '%s' ORDER BY table_name
|
||||
$q$, local_schema, remote_table, remote_schema);
|
||||
END
|
||||
$func$
|
||||
LANGUAGE PLPGSQL VOLATILE PARALLEL UNSAFE;
|
||||
|
||||
@@ -83,13 +83,10 @@ SET client_min_messages TO notice;
|
||||
-- Test the listing functions
|
||||
-- ===================================================================
|
||||
\echo 'Test listing of remote schemas (sunny day)'
|
||||
SELECT * FROM cartodb.CDB_Federated_Server_List_Remote_Schemas(remote_server => 'loopback')
|
||||
WHERE remote_schema NOT LIKE 'pg_%' -- Exclude toast and temp schemas
|
||||
ORDER BY remote_schema;
|
||||
SELECT * FROM cartodb.CDB_Federated_Server_List_Remote_Schemas(remote_server => 'loopback');
|
||||
|
||||
\echo 'Test listing of remote tables (sunny day)'
|
||||
SELECT * FROM cartodb.CDB_Federated_Server_List_Remote_Tables(remote_server => 'loopback', remote_schema => 'S 1')
|
||||
ORDER BY remote_table;
|
||||
SELECT * FROM cartodb.CDB_Federated_Server_List_Remote_Tables(remote_server => 'loopback', remote_schema => 'S 1');
|
||||
|
||||
-- ===================================================================
|
||||
-- Cleanup
|
||||
|
||||
Reference in New Issue
Block a user