Re: extract psql meta-commands into library?

From: Catherine Devlin <catherine(dot)devlin(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: extract psql meta-commands into library?
Date: 2014-03-07 15:42:13
Message-ID: CAGCtaoM-fW+YfvAWu-ywfLbsoHRctixaZ+ZVtZR=G6xRZkSzRA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Mar 6, 2014 at 12:09 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Hm ... the code in psql's describe.c is not terribly conducive to that.
> Parsing of the backslash command, execution of the query/queries, and
> presentation of the results is all rather tightly bound up; you'd have
> to think about how to decouple those.

I just looked into describe.c, but it was virtually my first look at C
in 15 years and I'm pretty intimidated.

Come to think of it, I really like the idea of moving the query
execution and presentation of results out into plpgsql functions in
template0; then it would be super-easy for applications to utilize
them. Parsing the command could stay with psql, because the
applications would probably want to do that parsing themselves,
anyway.

The trouble is that psql is written to work against older databases,
so if the code were stripped from describe.c in favor of calling
stored functions, those commands would stop working against older
PostgreSQL installations; and if the code were left in describe.c,
then the same function would exist in two different forms in two
different places, with all the maintanability problems that implies.

Is there a way around this I'm not thinking of?

Alternately, I may just give up and write my own, freestanding,
approximate implementation of the meta-commands with no effort to
actually replace the native one. It could still be useful to
application developers if they find out about it.

--
- Catherine
http://catherinedevlin.blogspot.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2014-03-07 15:50:05 Re: extract psql meta-commands into library?
Previous Message David Johnston 2014-03-07 15:12:12 Re: There is bug in PCS 0.9.26: configure pacemaker resource agent for PG stream replication