CDB_Federated_Table_Register: Handle conflict nicely
This commit is contained in:
@@ -186,7 +186,10 @@ BEGIN
|
|||||||
array_to_string(carto_columns_expression || rest_of_cols, ','),
|
array_to_string(carto_columns_expression || rest_of_cols, ','),
|
||||||
src_table
|
src_table
|
||||||
);
|
);
|
||||||
EXCEPTION WHEN OTHERS THEN
|
EXCEPTION
|
||||||
|
WHEN insufficient_privilege THEN
|
||||||
|
RAISE EXCEPTION 'Could not import table "%" as "%": "%" already exists', remote_table, local_name, local_name;
|
||||||
|
WHEN OTHERS THEN
|
||||||
RAISE EXCEPTION 'Could not import table "%" as "%": %', remote_table, local_name, SQLERRM;
|
RAISE EXCEPTION 'Could not import table "%" as "%": %', remote_table, local_name, SQLERRM;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
|
|||||||
@@ -242,11 +242,29 @@ SELECT cartodb.CDB_Federated_Table_Unregister(
|
|||||||
remote_table => 'remote_geom'
|
remote_table => 'remote_geom'
|
||||||
);
|
);
|
||||||
|
|
||||||
-- Try to register with invalid / NULL id
|
|
||||||
-- Try to register with invalid / NULL geom_column
|
\echo '## Target conflict is handled nicely: Table'
|
||||||
-- Try to register with invalid / NULL webmercator_column
|
CREATE TABLE localtable (a integer);
|
||||||
-- Try to register the same table twice (different name) should fail
|
SELECT cartodb.CDB_Federated_Table_Register(
|
||||||
-- Check that conflict is handled nicely (target view already exists)
|
server => 'loopback',
|
||||||
|
remote_schema => 'remote_schema',
|
||||||
|
remote_table => 'remote_geom',
|
||||||
|
id_column => 'id',
|
||||||
|
geom_column => 'geom',
|
||||||
|
local_name => 'localtable');
|
||||||
|
|
||||||
|
\echo '## Target conflict is handled nicely: View'
|
||||||
|
CREATE VIEW localtable2 AS Select * from localtable;
|
||||||
|
SELECT cartodb.CDB_Federated_Table_Register(
|
||||||
|
server => 'loopback',
|
||||||
|
remote_schema => 'remote_schema',
|
||||||
|
remote_table => 'remote_geom',
|
||||||
|
id_column => 'id',
|
||||||
|
geom_column => 'geom',
|
||||||
|
local_name => 'localtable2');
|
||||||
|
|
||||||
|
DROP VIEW localtable2;
|
||||||
|
DROP TABLE localtable;
|
||||||
|
|
||||||
-- Try permissions tricks
|
-- Try permissions tricks
|
||||||
|
|
||||||
|
|||||||
@@ -53,4 +53,12 @@ ERROR: non geometry column "Does not exists"
|
|||||||
## Registering a table: NULL webmercator_column is OK
|
## Registering a table: NULL webmercator_column is OK
|
||||||
|
|
||||||
|
|
||||||
|
## Target conflict is handled nicely: Table
|
||||||
|
CREATE TABLE
|
||||||
|
ERROR: Could not import table "remote_geom" as "localtable": "localtable" already exists
|
||||||
|
## Target conflict is handled nicely: View
|
||||||
|
CREATE VIEW
|
||||||
|
ERROR: Could not import table "remote_geom" as "localtable2": "localtable2" already exists
|
||||||
|
DROP VIEW
|
||||||
|
DROP TABLE
|
||||||
D1|
|
D1|
|
||||||
|
|||||||
Reference in New Issue
Block a user