psql: add \si, \sm, \st and \sr functions to show CREATE commands for indexes, matviews, triggers and tables - Mailing list pgsql-hackers

From a.pervushina@postgrespro.ru
Subject psql: add \si, \sm, \st and \sr functions to show CREATE commands for indexes, matviews, triggers and tables
Date
Msg-id 191ef0d76e30a36f7d6326a3ce58bd0e@postgrespro.ru
Whole thread Raw
Responses Re: psql: add \si, \sm, \st and \sr functions to show CREATE commands for indexes, matviews, triggers and tables
List pgsql-hackers
Hi,

I've attached a patch that implements \si, \sm, \st and \sr functions 
that show the CREATE command for indexes, matviews, triggers and tables. 
The functions are implemented similarly to the existing sf/sv functions 
with some modifications.

For triggers, I've decided to change input format to "table_name TRIGGER 
trigger_name", as multiple tables are allowed to have a trigger of the 
same name. Because we need to verify not only the name of the trigger, 
but also the name of the table, I've implemented a separate function 
lookup_trigger_oid that takes an additional argument.

Triggers and indexes use pg_catalog.pg_get_triggerdef() and 
pg_indexes.indexdef, while tables and matviews have separate queries for 
reconstruction. Get_create_object_cmd also runs three additional queries 
for tables, to get information on constraints, parents and columns.

There is also the question, if this functionality should be realised on 
the server instead of the client, but some people may think that changes 
to the language are "not the postgres way". However, server realisation 
may have some advantages, such as independence from the client and 
server version.

Best regards,
Alexandra Pervushina.

Attachment

pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: 13dev failed assert: comparetup_index_btree(): ItemPointer values should never be equal
Next
From: Josef Šimánek
Date:
Subject: Re: [PATCH] Initial progress reporting for COPY command