Re: Separate psql commands from arguments

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Decibel!" <decibel(at)decibel(dot)org>
Cc: "Peter Eisentraut" <peter_e(at)gmx(dot)net>, <pgsql-hackers(at)postgresql(dot)org>, "Brendan Jurd" <direvus(at)gmail(dot)com>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Bernd Helmle" <mailings(at)oopsware(dot)de>
Subject: Re: Separate psql commands from arguments
Date: 2008-04-10 21:48:24
Message-ID: 87lk3l8jpz.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Decibel!" <decibel(at)decibel(dot)org> writes:

> Am Samstag, 5. April 2008 schrieb Gregory Stark:
>> On Apr 10, 2008, at 7:50 AM, Peter Eisentraut wrote:
>>> I also don't see any point in allowing aliases which call other psql
>>> commands.
>
> Why disallow it? I think it could be very useful.

Well I feel like storing a query and resending it later is something
predictable which will work reliably. Storing a psql input line and
reinterpreting it later is surely going to cause weird things to happen.

Just for some examples off the top of my head, what happens if I define an
alias "\foo" which consists of "\foo" and call it? What happens if I have
mutually recursive aliases? What happens if I define "\foo" to run \ followed
by its first argument, and I pass it "foo"? What happens if I pass it "unalias
foo"?

What happens if you press C-c during an alias, does it keep running subsequent
commands? What if the editor returns an error after a \e command? What about
if a \i command doesn't find the file?

What happens to aliases when you change the encoding in the middle of running
one? Actually, come to think of it, what *does* happen to aliases when the
encoding changes??

Basically it sounds like you're treating psql as if it was a well defined
language with well defined syntax and semantics. And I don't think it is. It's
just one big if-else-if block with lots of strcmps. There's no infrastructure
to parse or manage a stack of calls to functions.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Get trained by Bruce Momjian - ask me about EnterpriseDB's PostgreSQL training!

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joshua D. Drake 2008-04-10 21:57:38 Re: Commit fest queue
Previous Message Alvaro Herrera 2008-04-10 21:29:07 Re: Commit fest queue