Re: Explicit psqlrc

From: David Christensen <david(at)endpoint(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, gabrielle <gorthx(at)gmail(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Mark Wong <markwkm(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Explicit psqlrc
Date: 2010-07-22 03:06:33
Message-ID: 4304B649-BBCE-4FEE-804E-4A4971C81F33@endpoint.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On Jul 21, 2010, at 12:31 PM, Alvaro Herrera wrote:

> Excerpts from Peter Eisentraut's message of mié jul 21 10:24:26 -0400 2010:
>> On tis, 2010-07-20 at 11:48 -0400, Robert Haas wrote:
>>> It's tempting to propose making .psqlrc apply only in interactive
>>> mode, period. But that would be an incompatibility with previous
>>> releases, and I'm not sure it's the behavior we want, either.
>>
>> What is a use case for having .psqlrc be read in noninteractive use?
>
> Even if there weren't one, why does it get applied to -f but not -c?
> They're both noninteractive.

So not to let the thread drop, it appears that we're faced with the following situation:

1) The current behavior is inconsistent with the psqlrc handling of -c and -f.
2) The current behavior is still historical and we presumably want to maintain it.

I'm not sure of the cases where we're willing to break backwards compatibility, but I do know that it's not done lightly. So perhaps for this specific patch, we'd need/want to punt supporting both -c's in conjunction with -f's, at least until we can resolve some of the ambiguities in what the actual behavior should be in each of these cases. This could still be a followup patch for 9.1, if we get these issues resolved.

And as long as we're redesigning the bike shed, I think a better use case for supporting multiple sql files would be to support them in such a way that you wouldn't need to provide explicit -f flags for each. Many programs utilize the '--' token for an "end of options" flag, with the rest of the arguments then becoming something special, such as filenames. So what about adding the interpretation that anything after '--' is interpreted as a filename? That will allow the use of shell wildcards to specify multiple files, and thus allow something like:

$ psql -U myuser mydatabase -- *.sql
$ psql -- {pre-,,post-}migration.sql

while still being unambiguous with the current convention of having an unspecified argument be interpreted as a database name. This would make it possible to actually specify/use multiple files in a fashion that people are used to doing, as opposed to having to explicitly type things out or do contortions will shell substitutions, etc.

Regards,

David
--
David Christensen
End Point Corporation
david(at)endpoint(dot)com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2010-07-22 03:13:48 Re: psql \conninfo command (was: Patch: psql \whoami option)
Previous Message Robert Haas 2010-07-22 03:01:08 Re: review: psql: edit function, show function commands patch