Attach metadata to a stored procedure

Posted on

Question :

Is it possible to attach metadata to a stored procedure in Postgres 11?

In particular, I have database migrations with version numbers. So when my migration script runs and might override the current stored proc with CREATE OR REPLACE PROCEDURE, I’d like to be able to attach metadata to the stored proc, with the a newer version number.

Also, how can this be queried afterwards?

Answer :

For this there is a COMMENT SQL command:

COMMENT ON PROCEDURE whatever IS 'some text'

To retrieve it later use the function obj_description().

Leave a Reply

Your email address will not be published. Required fields are marked *