idea - proposal - defining own psql commands

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: idea - proposal - defining own psql commands
Date: 2019-10-31 16:48:22
Message-ID: CAFj8pRBzrf+uZ=e_MNu9oeFqEzA=jv1CC7jYzVWvSkrX_vpUzg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

long time we are think how to allow add some custom commands in psql. I had
a following idea

1. psql can has special buffer for custom queries. This buffer can be
filled by special command \gdefq. This command will have two parameters -
name and number of arguments.

some like

select * from pg_class where relname = :'_first' \gdefcq m1 1
select * from pg_class where relnamespace = :_first::regnamespace and
rename = :'_second' \gdefcq m1 2

the custom queries can be executed via doubled backslash like

\\m1 pg_proc
\\m1 pg_catalog pg_proc

the runtime will count number of parameters and chose variant with selected
name and same number of arguments. Next, it save parameters to variables
like _first, _second. Last step is query execution.

What do you think about this?

Regards

Pavel

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Dilger 2019-10-31 16:48:46 Re: RFC: split OBJS lines to one object per line
Previous Message Pavel Stehule 2019-10-31 16:36:27 Re: Adding percentile metrics to pg_stat_statements module