Re: Enhancement to psql command, feedback.

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Christopher Browne <cbbrowne(at)gmail(dot)com>
Cc: John McKown <john(dot)archie(dot)mckown(at)gmail(dot)com>, PostgreSQL Mailing Lists <pgsql-general(at)postgresql(dot)org>
Subject: Re: Enhancement to psql command, feedback.
Date: 2018-05-09 17:41:46
Message-ID: CAKFQuwYqQAn5MVgXtCqbj0gBo2jZoWhAzf6-bt9amd3YCYFkPg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, May 9, 2018 at 9:04 AM, Christopher Browne <cbbrowne(at)gmail(dot)com>
wrote:

> On Wed, 9 May 2018 at 04:00, John McKown <john(dot)archie(dot)mckown(at)gmail(dot)com>
> wrote:
> > To me this looks similar to a UNIX shell script. Now, going sideways for
> a second, if someone wanted to create a "self contained" awk script. It
> would look something like:
>
> > #!/bin/awk -f
> > ... awk code ...
>
> I have found it convenient when Lisp implementations (that use ; as the
> comment indicator, and where # tends to mean something quite different)
> have provided something like this.
>
> I'd quite like it if I could start a script with
> #!psql
> or similar and have it be, yes, indeed, directly executable via psql.
>
> There are several complications that leap out at me...
>

​Frankly, none of those are complications. For all the areas of concern
you described the decision for desired behavior has already been made.
They seem to limit the extent to which a shebang would be useful...

1. O/S PATH determines what a bare "psql" invocation finds
2. arguments override environment variables
3. \i means include, no transaction semantics

And trying harder for #1 doesn't seem worthwhile - or maybe is a feature in
its own right. Something like:

--@ client-version >= 9.6
--@ server-version >= 9.4

If those comments are found in a file psql is evaluating it should error
out if the condition doesn't match. That should apply regardless of
invocation method.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message nikhil raj 2018-05-09 18:31:37 Why is my Postgre server went in recovery mode all in sudden
Previous Message Bruce Harold 2018-05-09 17:38:57 RE: Error creating plpython3u extension