Re: Adding date column to system catalog "pg_database" - Mailing list pgsql-admin

From Feike Steenbergen
Subject Re: Adding date column to system catalog "pg_database"
Date
Msg-id CAK_s-G2bEpkEyMXHrmoDFMWWrXSVn4hxhw3p4_BxJAOVKJNS6Q@mail.gmail.com
Whole thread Raw
In response to Adding date column to system catalog "pg_database"  (pavan95 <pavan.postgresdba@gmail.com>)
List pgsql-admin
On 7 June 2018 at 13:05, pavan95 <pavan.postgresdba@gmail.com> wrote:
> Any ideas in accomplishment of this task are of great help!

You could create a (structured, json?) comment on the database with this
kind of information, if you don't use the comment field on the database (yet).


feike=# SELECT json_build_object('created', now(), 'author',
CURRENT_USER)::text AS comment;
-[ RECORD 1 ]-----------------------------------------------------------------
comment | {"created" : "2018-06-09T08:33:30.994298+00:00", "author" : "feike"}

feike=# COMMENT ON DATABASE demo IS '{"created" :
"2018-06-09T08:33:30.994298+00:00", "author" : "feike"}';
COMMENT


Later on, you can read/parse that comment using pg_shdescription:


feike=#
SELECT description,
       (description::jsonb->>'created')::timestamptz
  FROM pg_shdescription
  JOIN pg_database pd ON (objoid=pd.oid and classoid =
'pg_catalog.pg_database'::regclass)
 WHERE datname = 'demo';
-[ RECORD 1 ]---------------------------------------------------------------------
description | {"created" : "2018-06-09T08:33:30.994298+00:00",
"author" : "feike"}
timestamptz | 2018-06-09 08:33:30.994298+00


regards,

Feike


pgsql-admin by date:

Previous
From: Pavan Teja
Date:
Subject: Re: pg_basebackup: could not get write-ahead log end position fromserver: ERROR
Next
From: "Saeed Ahmed (DB)"
Date:
Subject: RE: pg_basebackup: could not get write-ahead log end position fromserver: ERROR