From: Tom Lane on
Magnus Hagander <magnus(a)hagander.net> writes:
> 2010/3/7 Tom Lane <tgl(a)sss.pgh.pa.us>:
>> If we were going to support multiple -f options, it would be sensible
>> to interpret "-f -" as "read from stdin until EOF".

> Right, that would work. Though it would be a lot more user-unfriendly
> for such a simple thing, IMHO.

If the issue had come up even once before in psql's existence, I might
think that user-friendliness would be a good argument. As things stand,
I don't believe the average user will care about it in the least. I'd
be willing to lay long odds that the average user doesn't even have a
..psqlrc file, much less feel the need to override it. I'd rather see
"use a substitute psqlrc" be a behavior you can build out of existing
general-purpose switches than still another option that has to be
documented and remembered.

> Also, "-f -" and just "psql" behaves different today (for example, in
> the showing of startup banners).

Yes, there would be some things to think about there, which is why it's
a topic for a new devel cycle rather than something to shoehorn in
after the close of the last CF.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

From: Magnus Hagander on
2010/3/7 Tom Lane <tgl(a)sss.pgh.pa.us>:
> Magnus Hagander <magnus(a)hagander.net> writes:
>> 2010/3/7 Tom Lane <tgl(a)sss.pgh.pa.us>:
>>> If we were going to support multiple -f options, it would be sensible
>>> to interpret "-f -" as "read from stdin until EOF".
>
>> Right, that would work. Though it would be a lot more user-unfriendly
>> for such a simple thing, IMHO.
>
> If the issue had come up even once before in psql's existence, I might
> think that user-friendliness would be a good argument.  As things stand,
> I don't believe the average user will care about it in the least.  I'd
> be willing to lay long odds that the average user doesn't even have a
> .psqlrc file, much less feel the need to override it.  I'd rather see
> "use a substitute psqlrc" be a behavior you can build out of existing
> general-purpose switches than still another option that has to be
> documented and remembered.

I've heard if a couple of times before, but I agree it's certainly not
a much asked-for one. Most if it has been in off-list scenarios and
people have probabliy just thought it's not a big enough feature to
bother emailing about.


>> Also, "-f -" and just "psql" behaves different today (for example, in
>> the showing of startup banners).
>
> Yes, there would be some things to think about there, which is why it's
> a topic for a new devel cycle rather than something to shoehorn in
> after the close of the last CF.

Fair enough. I expected it to be a small and noncontroversial thing,
but since there are objections, I'll go revert it.

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/

--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

From: Bruce Momjian on
Magnus Hagander wrote:
> >> Also, "-f -" and just "psql" behaves different today (for example, in
> >> the showing of startup banners).
> >
> > Yes, there would be some things to think about there, which is why it's
> > a topic for a new devel cycle rather than something to shoehorn in
> > after the close of the last CF.
>
> Fair enough. I expected it to be a small and noncontroversial thing,
> but since there are objections, I'll go revert it.

Do you want to create a TODO entry for this?

--
Bruce Momjian <bruce(a)momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

PG East: http://www.enterprisedb.com/community/nav-pg-east-2010.do

--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

From: David Christensen on

On Mar 7, 2010, at 9:22 AM, Tom Lane wrote:

> Magnus Hagander <magnus(a)hagander.net> writes:
>> 2010/3/6 Tom Lane <tgl(a)sss.pgh.pa.us>:
>>> The analogy I was thinking about was psql -X, but I agree that it's
>>> not obvious why this shouldn't be thought of as an additional -f
>>> file.
>
>> Uh, I don't follow. When we use -f, we'll run the script and then
>> exit. The whole point is to run it and *not* exit, since you are
>> normally using it to set up the environment in psql.
>
> If we were going to support multiple -f options, it would be sensible
> to interpret "-f -" as "read from stdin until EOF". Then you could
> interleave prepared scripts and stdin, which could be pretty handy.
> The default behavior would be equivalent to a single instance of "-f
> -",
> and what you are looking for would be "-X -f substitute-psqlrc -f -".

Here's an initial stab at supporting multiple -f's (not counting the
interpretation of "-f -" as STDIN). There are also a few pieces that
are up for interpretation, such as the propagation of the return value
of the MainLoop(). Also, while this patch supports the single-
transaction mode, it does so in a way that will break if one of the
scripts include explicit BEGIN/COMMIT statements (although it is no
different than the existing code in this regard).

Regards,

David
--
David Christensen
End Point Corporation
david(a)endpoint.com



From: Robert Haas on
On Mon, Mar 8, 2010 at 1:39 AM, David Christensen <david(a)endpoint.com> wrote:
>
> On Mar 7, 2010, at 9:22 AM, Tom Lane wrote:
>
>> Magnus Hagander <magnus(a)hagander.net> writes:
>>>
>>> 2010/3/6 Tom Lane <tgl(a)sss.pgh.pa.us>:
>>>>
>>>> The analogy I was thinking about was psql -X, but I agree that it's
>>>> not obvious why this shouldn't be thought of as an additional -f file.
>>
>>> Uh, I don't follow. When we use -f, we'll run the script and then
>>> exit. The whole point is to run it and *not* exit, since you are
>>> normally using it to set up the environment in psql.
>>
>> If we were going to support multiple -f options, it would be sensible
>> to interpret "-f -" as "read from stdin until EOF".  Then you could
>> interleave prepared scripts and stdin, which could be pretty handy.
>> The default behavior would be equivalent to a single instance of "-f -",
>> and what you are looking for would be "-X -f substitute-psqlrc -f -".
>
> Here's an initial stab at supporting multiple -f's (not counting the
> interpretation of "-f -" as STDIN).  There are also a few pieces that are up
> for interpretation, such as the propagation of the return value of the
> MainLoop().  Also, while this patch supports the single-transaction mode, it
> does so in a way that will break if one of the scripts include explicit
> BEGIN/COMMIT statements (although it is no different than the existing code
> in this regard).

I have added to this to the next CommitFest.

....Robert

--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers