Re: Separate psql commands from arguments

From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: Gregory Stark <stark(at)enterprisedb(dot)com>, 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>
Subject: Re: Separate psql commands from arguments
Date: 2008-04-11 09:38:28
Message-ID: 650AE6E623823FA8E6DA3F4A@imhotep.credativ.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

--On Donnerstag, April 10, 2008 22:48:24 +0100 Gregory Stark
<stark(at)enterprisedb(dot)com> wrote:

> 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.

Als already mentioned in the original thread, excluding backslash commands
from aliasing
isn't a big deal, but this would negate the usefulness of this feature.

>
> 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"?
>

aliases are substituted only once within a call. They are acting exactly
the same way you'll find on your favorite shell. If the current patch
doesn't, it needs to be adressed, of course. Have you tried your examples
on the current patch? Retesting shows it works as expected...

> 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?

Since aliases are simple substitutions nothing different. Multiple commands
are placed directly into the query buffer, so nothing different than the
current behavior should happen. Again, do you have any concrete examples?

>
> 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??

Hmm? What happens if you are going to change your encoding within multiple
backslash commands now?

>
>
> 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.

So i do.

> 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.

Again, it's text _substitution_, replacing the very first token with
another token. Wether this token can be complex or not is another question,
but of course, i'm not so foolish to describe psql as turing complete
language.

--
Thanks

Bernd

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Martijn van Oosterhout 2008-04-11 09:48:46 Re: question on how to correctly communicate with external library functions which return malloc()'ed strings
Previous Message Hans-Juergen Schoenig 2008-04-11 08:57:47 Re: Adding pipelining support to set returning functions