2016-06-23 20:34:04 +08:00
|
|
|
CREATE TYPE cdb_dataservices_server.ds_fdw_metadata as (schemaname text, tabname text, servername text);
|
2016-06-24 17:29:21 +08:00
|
|
|
|
2016-06-23 20:34:04 +08:00
|
|
|
CREATE TYPE cdb_dataservices_server.ds_return_metadata as (colnames text[], coltypes text[]);
|
2016-06-10 17:34:07 +08:00
|
|
|
|
2016-06-24 17:29:21 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server._OBS_ConnectUserTable(username text, orgname text, user_db_role text, input_schema text, dbname text, table_name text)
|
|
|
|
RETURNS cdb_dataservices_server.ds_fdw_metadata AS $$
|
|
|
|
return plpy.execute("SELECT * FROM cdb_dataservices_server.__OBS_ConnectUserTable({username}::text, {orgname}::text, {user_db_role}::text, {schema}::text, {dbname}::text, {table_name}::text)"
|
|
|
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), user_db_role=plpy.quote_literal(user_db_role), schema=plpy.quote_literal(input_schema), dbname=plpy.quote_literal(dbname), table_name=plpy.quote_literal(table_name))
|
|
|
|
)[0]
|
2016-06-10 17:34:07 +08:00
|
|
|
$$ LANGUAGE plpythonu;
|
|
|
|
|
2016-06-24 17:29:21 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server.__OBS_ConnectUserTable(username text, orgname text, user_db_role text, input_schema text, dbname text, table_name text)
|
|
|
|
RETURNS cdb_dataservices_server.ds_fdw_metadata AS $$
|
2016-06-10 17:34:07 +08:00
|
|
|
CONNECT cdb_dataservices_server._obs_server_conn_str(username, orgname);
|
2016-06-24 17:29:21 +08:00
|
|
|
TARGET cdb_observatory._OBS_ConnectUserTable;
|
2016-06-10 17:34:07 +08:00
|
|
|
$$ LANGUAGE plproxy;
|
|
|
|
|
2016-06-24 17:29:21 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server._OBS_GetReturnMetadata(username text, orgname text, function_name text, params json)
|
|
|
|
RETURNS cdb_dataservices_server.ds_return_metadata AS $$
|
2016-06-10 17:34:07 +08:00
|
|
|
CONNECT cdb_dataservices_server._obs_server_conn_str(username, orgname);
|
2016-06-24 17:29:21 +08:00
|
|
|
TARGET cdb_observatory._OBS_GetReturnMetadata;
|
2016-06-10 17:34:07 +08:00
|
|
|
$$ LANGUAGE plproxy;
|
|
|
|
|
2016-06-24 17:29:21 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server._OBS_FetchJoinFdwTableData(username text, orgname text, table_schema text, table_name text, function_name text, params json)
|
2016-06-10 17:34:07 +08:00
|
|
|
RETURNS SETOF record AS $$
|
|
|
|
CONNECT cdb_dataservices_server._obs_server_conn_str(username, orgname);
|
2016-06-24 17:29:21 +08:00
|
|
|
TARGET cdb_observatory._OBS_FetchJoinFdwTableData;
|
2016-06-10 17:34:07 +08:00
|
|
|
$$ LANGUAGE plproxy;
|
|
|
|
|
|
|
|
|
2016-06-24 17:29:21 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server._OBS_DisconnectUserTable(username text, orgname text, table_schema text, table_name text, servername text)
|
2016-06-10 17:34:07 +08:00
|
|
|
RETURNS boolean AS $$
|
|
|
|
CONNECT cdb_dataservices_server._obs_server_conn_str(username, orgname);
|
2016-06-24 17:29:21 +08:00
|
|
|
TARGET cdb_observatory._OBS_DisconnectUserTable;
|
2016-06-10 17:34:07 +08:00
|
|
|
$$ LANGUAGE plproxy;
|