diff --git a/scripts-available/CDB_ForeignTable.sql b/scripts-available/CDB_ForeignTable.sql index b75fd46..5729288 100644 --- a/scripts-available/CDB_ForeignTable.sql +++ b/scripts-available/CDB_ForeignTable.sql @@ -132,6 +132,19 @@ $$ LANGUAGE plpgsql; +CREATE OR REPLACE FUNCTION cartodb._cdb_dbname_of_foreign_table(reloid oid) +RETURNS TEXT AS $$ + SELECT option_value FROM pg_options_to_table(( + + SELECT fs.srvoptions + FROM pg_foreign_table ft + LEFT JOIN pg_foreign_server fs ON ft.ftserver = fs.oid + WHERE ft.ftrelid = reloid + + )) WHERE option_name='dbname'; +$$ LANGUAGE SQL; + + -- Return a set of (dbname, schema_name, table_name, updated_at) -- It is aware of foreign tables -- It assumes the local (schema_name, table_name) map to the remote ones with the same name @@ -165,19 +178,6 @@ AS $$ $$ LANGUAGE SQL; -CREATE OR REPLACE FUNCTION cartodb._cdb_dbname_of_foreign_table(reloid oid) -RETURNS TEXT AS $$ - SELECT option_value FROM pg_options_to_table(( - - SELECT fs.srvoptions - FROM pg_foreign_table ft - LEFT JOIN pg_foreign_server fs ON ft.ftserver = fs.oid - WHERE ft.ftrelid = reloid - - )) WHERE option_name='dbname'; -$$ LANGUAGE SQL; - - -- Return the last updated time of a set of tables -- It is aware of foreign tables -- It assumes the local (schema_name, table_name) map to the remote ones with the same name