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.