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

From: a(dot)pervushina(at)postgrespro(dot)ru
To: pgsql-hackers(at)postgresql(dot)org
Subject: psql: add \si, \sm, \st and \sr functions to show CREATE commands for indexes, matviews, triggers and tables
Date: 2020-07-28 17:46:04
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


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 Content-Type Size
si_st_sm_sr.patch text/x-diff 35.7 KB


Browse pgsql-hackers by date

  From Date Subject
Next Message Josef Šimánek 2020-07-28 18:24:57 Re: [PATCH] Initial progress reporting for COPY command
Previous Message Peter Geoghegan 2020-07-28 17:37:13 Re: 13dev failed assert: comparetup_index_btree(): ItemPointer values should never be equal