Re: \prompt for psql - Mailing list pgsql-patches

From Chad Wagner
Subject Re: \prompt for psql
Date
Msg-id 81961ff50702170905he2dfcf2j95a38df0f09ffd59@mail.gmail.com
Whole thread Raw
In response to Re: \prompt for psql  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: \prompt for psql
Re: \prompt for psql
List pgsql-patches
On 2/17/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Bruce Momjian <bruce@momjian.us> writes:
> stdin makes it impossible to read a script from stdin and still prompt
> the user, but I think that is of limited usefulness.

You can always get around that by reading the script with -f instead.
On balance I can see a lot more uses for read-from-stdin than the other;
however, we do need to define what happens if the command appears when
commands are coming from stdin.

Would it make sense to say:

1. if pset.notty is set and '-f' switch is not set then use simple_prompt
      -- deals with SQL script redirection case and '-f' is not used, and not interactive
2. else then use gets_fromFile(stdin) <or some other alternative?> (read from stdin)
      -- deals with "prompt value" redirection case and '-f' is used, or interactive

It appears that pset.notty will get set to 1 when stdin is not a tty device, which should be the case for redirection.

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: \prompt for psql
Next
From: Peter Eisentraut
Date:
Subject: Re: patch adding new regexp functions