From: Peter Eisentraut on
On fre, 2010-03-05 at 11:30 +0100, Magnus Hagander wrote:
> > Do you have a use-case where --psqlrc would be more useful than an
> > environment variable, or is it *only* bike-shedding? ;)
>
> Just to be clear, the code difference isn't very large. Attached is a
> patch that does both PSQLRC and --psqlrc.

I can see the environment variable variant as an analogy to BASH_ENV,
but what is the use case for the --psqlrc option? Wouldn't it be easier
and more useful to just be able to process more than one file, say by
specifying -f more than once?



--
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: Tom Lane on
Peter Eisentraut <peter_e(a)gmx.net> writes:
> I can see the environment variable variant as an analogy to BASH_ENV,
> but what is the use case for the --psqlrc option? Wouldn't it be easier
> and more useful to just be able to process more than one file, say by
> specifying -f more than once?

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.

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/6 Tom Lane <tgl(a)sss.pgh.pa.us>:
> Peter Eisentraut <peter_e(a)gmx.net> writes:
>> I can see the environment variable variant as an analogy to BASH_ENV,
>> but what is the use case for the --psqlrc option?  Wouldn't it be easier
>> and more useful to just be able to process more than one file, say by
>> specifying -f more than once?
>
> 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.

That said, it might certainly be useful to be able to process more
than one file with -f, but that's a different usecase, I think.

--
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: Tom Lane on
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 -".

I do think this is potentially cleaner and more general than the
--psqlrc switch. Maybe that should be reverted and the whole topic
reconsidered during 9.1 devel cycle.

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

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

Also, "-f -" and just "psql" behaves different today (for example, in
the showing of startup banners). So we couldn't do that without
changing the behaviour of at least one of those. Which may not be a
problem of course, but I'm sure someone will find a place to complain
:)

With your interleave, you mean things like "psql -f first.sql -f - -f
second.sql"? That does sound like it could be handy - and also really
dangerous :-)


> I do think this is potentially cleaner and more general than the
> --psqlrc switch.  Maybe that should be reverted and the whole topic
> reconsidered during 9.1 devel cycle.

More general, definitely. But cleaner? I'd say rather the opposite.

In the end, I don't see why we can't have both when the implementation
is so trivial.

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