Skip to content

Obtain the PostgREST version through SQL #2647

@steve-chavez

Description

@steve-chavez

It would be nice to obtain the version like this:

select distinct application_name from pg_stat_activity where application_name like '%postgrest%';

 application_name
------------------
postgrest-10.1.2

The fallback_application_name fits this use case exactly, we can set it and still allow users to override it with application_name.

To implement this, we'd have to add ?fallback_application_name=val to configDbUri here:

SQL.acquire configDbPoolSize timeoutMilliseconds $ toUtf8 configDbUri

Where val would be the current postgREST version.

The ? should be added conditionally. If the uri already contains ?, then add &fallback_application_name=val else add ?fallback_application_name=val.


This function could be used for testing:

CREATE FUNCTION test.get_version() RETURNS pg_stat_activity.application_name%TYPE
AS $$
  select distinct application_name from pg_stat_activity where application_name like '%postgrest%';
$$ LANGUAGE sql;

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions