diff --git a/scripts-available/CDB_FederatedServerDiagnostics.sql b/scripts-available/CDB_FederatedServerDiagnostics.sql index 2f727ea..fd00e95 100644 --- a/scripts-available/CDB_FederatedServerDiagnostics.sql +++ b/scripts-available/CDB_FederatedServerDiagnostics.sql @@ -2,11 +2,24 @@ -- Private functions -------------------------------------------------------------------------------- +CREATE OR REPLACE FUNCTION @extschema@.__CDB_FS_Server_Version_PG(server_internal name) +RETURNS text +AS $$ +BEGIN + -- TODO Implement + RETURN '14.0'; +END +$$ +LANGUAGE PLPGSQL VOLATILE PARALLEL UNSAFE; + + CREATE OR REPLACE FUNCTION @extschema@.__CDB_FS_Server_Diagnostics_PG(server_internal name) RETURNS jsonb AS $$ +DECLARE + remote_server_version text := @extschema@.__CDB_FS_Server_Version_PG(server_internal); BEGIN - RETURN '{}'::jsonb; + RETURN jsonb_build_object('server_version', remote_server_version); END $$ LANGUAGE PLPGSQL VOLATILE PARALLEL UNSAFE; diff --git a/test/CDB_FederatedServerDiagnostics.sql b/test/CDB_FederatedServerDiagnostics.sql index 0c1097e..6783118 100644 --- a/test/CDB_FederatedServerDiagnostics.sql +++ b/test/CDB_FederatedServerDiagnostics.sql @@ -34,6 +34,9 @@ SELECT '1.1', cartodb.CDB_Federated_Server_Diagnostics(server => 'doesNotExist') \echo '%% It returns a jsonb object' SELECT '1.2', pg_typeof(cartodb.CDB_Federated_Server_Diagnostics(server => 'loopback')); +\echo '%% It returns the server version' +SELECT '1.3', cartodb.CDB_Federated_Server_Diagnostics(server => 'loopback') @> '{"server_version": "14.0"}'::jsonb; + -- =================================================================== -- Cleanup diff --git a/test/CDB_FederatedServerDiagnostics_expect b/test/CDB_FederatedServerDiagnostics_expect index b8ffd9e..9ec5b49 100644 --- a/test/CDB_FederatedServerDiagnostics_expect +++ b/test/CDB_FederatedServerDiagnostics_expect @@ -3,4 +3,6 @@ C1| ERROR: Server "doesNotExist" does not exist %% It returns a jsonb object 1.2|jsonb +%% It returns the server version +1.3|t D1|