CDB_Federated_Table_Register works to refresh a table
This commit is contained in:
parent
f20a007160
commit
28376ffecb
@ -66,10 +66,11 @@ $$ LANGUAGE SQL;
|
||||
-- Sets up a Federated Table
|
||||
--
|
||||
-- Precondition: the federated server has to be set up via
|
||||
-- CDB_SetUp_PG_Federated_Server
|
||||
-- CDB_Federated_Server_Register_PG
|
||||
--
|
||||
-- Postcondition: it generates a view in the schema of the user that
|
||||
-- can be used through SQL and Maps API's.
|
||||
-- If the table was already exported, it will be dropped and re-imported
|
||||
--
|
||||
-- E.g:
|
||||
-- SELECT cartodb.CDB_SetUp_PG_Federated_Table(
|
||||
@ -113,6 +114,10 @@ BEGIN
|
||||
END IF;
|
||||
|
||||
-- Import the foreign table
|
||||
-- Drop the old view / table if there was one
|
||||
IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema = local_schema AND table_name = remote_table) THEN
|
||||
EXECUTE @extschema@.CDB_Federated_Table_Unregister(server, remote_schema, remote_table);
|
||||
END IF;
|
||||
EXECUTE FORMAT ('IMPORT FOREIGN SCHEMA %I LIMIT TO (%I) FROM SERVER %I INTO %I;', remote_schema, remote_table, server_internal, local_schema);
|
||||
src_table := format('%I.%I', local_schema, remote_table);
|
||||
|
||||
|
@ -88,6 +88,22 @@ Select 'list_remotes2', CDB_Federated_Server_List_Registered_Tables(
|
||||
remote_schema => 'remote_schema'
|
||||
);
|
||||
|
||||
-- Reregistering R2 with different parameters should work
|
||||
SELECT 'R3', cartodb.CDB_Federated_Table_Register(
|
||||
server => 'loopback',
|
||||
remote_schema => 'remote_schema',
|
||||
remote_table => 'remote_geom2',
|
||||
id_column => 'id',
|
||||
geom_column => 'geom',
|
||||
local_name => 'different_name'
|
||||
);
|
||||
|
||||
-- The old view should dissapear
|
||||
SELECT 'S3_old', cartodb_id, ST_AsText(the_geom_webmercator), another_field FROM "myFullTable";
|
||||
-- And the new appear
|
||||
SELECT 'S3_new', cartodb_id, ST_AsText(the_geom_webmercator), another_field FROM different_name;
|
||||
|
||||
-- Deregistering the first table
|
||||
SELECT 'U1', CDB_Federated_Table_Unregister(
|
||||
server => 'loopback',
|
||||
remote_schema => 'remote_schema',
|
||||
|
@ -17,7 +17,10 @@ V2| SELECT t.id AS cartodb_id,
|
||||
S2|3|POINT(3 3)|patata
|
||||
list_remotes2|(remote_geom2,"public.""myFullTable""")
|
||||
list_remotes2|(remote_geom,public.remote_geom)
|
||||
R3|
|
||||
ERROR: relation "myFullTable" does not exist at character 82
|
||||
S3_new|3|POINT(333958.472379821 334111.17140196)|patata
|
||||
U1|
|
||||
ERROR: relation "remote_geom" does not exist at character 71
|
||||
list_remotes3|(remote_geom2,"public.""myFullTable""")
|
||||
list_remotes3|(remote_geom2,public.different_name)
|
||||
D1|
|
||||
|
Loading…
Reference in New Issue
Block a user