Обсуждение: Seperate command-line histories for seperate databases

Поиск
Список
Период
Сортировка

Seperate command-line histories for seperate databases

От
Peter Eisentraut
Дата:
Someone sent the following request to the Debian bug tracking system:

"""
It'd be nice if the .psql_history file were per-database. This is
because the commands executed on different databases are likely to be
very different, so there is no good reason to lose history for db1 when
working with db2, especially since the new history from db2 is probably
not useful for db1.

I'd suggest giving psql a directory, and naming history like this:
       .psql/history/hostname/dbname
"""

There is undoubtedly some merit to that, but I still have my doubts.  But at 
least we can discuss it.  Comments?

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/


Re: Seperate command-line histories for seperate databases

От
Bruce Momjian
Дата:
Peter Eisentraut wrote:
> Someone sent the following request to the Debian bug tracking system:
> 
> """
> It'd be nice if the .psql_history file were per-database. This is
> because the commands executed on different databases are likely to be
> very different, so there is no good reason to lose history for db1 when
> working with db2, especially since the new history from db2 is probably
> not useful for db1.
> 
> I'd suggest giving psql a directory, and naming history like this:
> 
>         .psql/history/hostname/dbname
> """
> 
> There is undoubtedly some merit to that, but I still have my doubts.  But at 
> least we can discuss it.  Comments?

The psql manual pages for 8.1 now has:
      HISTFILE             The  file  name that will be used to store the his-             tory list. The default
value is  ~/.psql_history.             For example, putting
 
             \set HISTFILE ~/.psql_history- :DBNAME
             in ~/.psqlrc will cause psql to maintain a separate             history for each database.

--  Bruce Momjian   http://candle.pha.pa.us SRA OSS, Inc.   http://www.sraoss.com
 + If your life is a hard drive, Christ can be your backup. +


Re: Seperate command-line histories for seperate databases

От
Peter Eisentraut
Дата:
Bruce Momjian wrote:
> The psql manual pages for 8.1 now has:

>               \set HISTFILE ~/.psql_history- :DBNAME

Excellent!

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/


Re: Seperate command-line histories for seperate databases

От
Bruce Momjian
Дата:
Peter Eisentraut wrote:
> Bruce Momjian wrote:
> > The psql manual pages for 8.1 now has:
> 
> >               \set HISTFILE ~/.psql_history- :DBNAME
> 
> Excellent!

Yea, it is a cool trick someone posted once and I added it to the manual
page for others to use.

--  Bruce Momjian   http://candle.pha.pa.us SRA OSS, Inc.   http://www.sraoss.com
 + If your life is a hard drive, Christ can be your backup. +


Re: Seperate command-line histories for seperate databases

От
"Markus Bertheau"
Дата:
2006/3/17, Bruce Momjian <pgman@candle.pha.pa.us>:
> Peter Eisentraut wrote:
> > Bruce Momjian wrote:
> > > The psql manual pages for 8.1 now has:
> >
> > >               \set HISTFILE ~/.psql_history- :DBNAME

Any reason psql doesn't do this by default? It is clear that the
database name does not unambiguously identify a database, but having a
history for each database name is already an improvement over the
current situation.

Markus Bertheau


Re: Seperate command-line histories for seperate databases

От
Bruce Momjian
Дата:
Markus Bertheau wrote:
> 2006/3/17, Bruce Momjian <pgman@candle.pha.pa.us>:
> > Peter Eisentraut wrote:
> > > Bruce Momjian wrote:
> > > > The psql manual pages for 8.1 now has:
> > >
> > > >               \set HISTFILE ~/.psql_history- :DBNAME
> 
> Any reason psql doesn't do this by default? It is clear that the
> database name does not unambiguously identify a database, but having a
> history for each database name is already an improvement over the
> current situation.

I am not sure everyone would want it.  If they want it, we have given
them the capability.

--  Bruce Momjian   http://candle.pha.pa.us SRA OSS, Inc.   http://www.sraoss.com
 + If your life is a hard drive, Christ can be your backup. +


Re: Seperate command-line histories for seperate databases

От
Chris Browne
Дата:
mbertheau.pg@googlemail.com ("Markus Bertheau") writes:
> 2006/3/17, Bruce Momjian <pgman@candle.pha.pa.us>:
>> Peter Eisentraut wrote:
>> > Bruce Momjian wrote:
>> > > The psql manual pages for 8.1 now has:
>> >
>> > >               \set HISTFILE ~/.psql_history- :DBNAME
>
> Any reason psql doesn't do this by default? It is clear that the
> database name does not unambiguously identify a database, but having a
> history for each database name is already an improvement over the
> current situation.

I fairly frequently find myself accessing different (but similar)
databases, and it's quite valuable to be able to submit the *same*
queries to them.

This change would make it troublesome to do that.  I'd not be all that
keen on the change...
-- 
select 'cbbrowne' || '@' || 'ntlug.org';
http://cbbrowne.com/info/rdbms.html
"On the  other hand, O'Reilly's book  about running W95 has  a toad as
the cover animal.  Makes sense; both have lots of  warts and croak all
the time."  --- Michael Kagalenko,


Re: Seperate command-line histories for seperate databases

От
Andrew Dunstan
Дата:
Chris Browne wrote:

>mbertheau.pg@googlemail.com ("Markus Bertheau") writes:
>  
>
>>2006/3/17, Bruce Momjian <pgman@candle.pha.pa.us>:
>>    
>>
>>>Peter Eisentraut wrote:
>>>      
>>>
>>>>Bruce Momjian wrote:
>>>>        
>>>>
>>>>>The psql manual pages for 8.1 now has:
>>>>>          
>>>>>
>>>>>              \set HISTFILE ~/.psql_history- :DBNAME
>>>>>          
>>>>>
>>Any reason psql doesn't do this by default? It is clear that the
>>database name does not unambiguously identify a database, but having a
>>history for each database name is already an improvement over the
>>current situation.
>>    
>>
>
>I fairly frequently find myself accessing different (but similar)
>databases, and it's quite valuable to be able to submit the *same*
>queries to them.
>
>This change would make it troublesome to do that.  I'd not be all that
>keen on the change...
>  
>

Just what I was thinking.

cheers

andrew


Re: Seperate command-line histories for seperate databases

От
Tom Lane
Дата:
Andrew Dunstan <andrew@dunslane.net> writes:
> Chris Browne wrote:
>> mbertheau.pg@googlemail.com ("Markus Bertheau") writes:
>>> Any reason psql doesn't do this by default?
>> 
>> I fairly frequently find myself accessing different (but similar)
>> databases, and it's quite valuable to be able to submit the *same*
>> queries to them.
>> 
>> This change would make it troublesome to do that.  I'd not be all that
>> keen on the change...

> Just what I was thinking.

+1 on not changing the default behavior.  However, this discussion
makes me wonder just how well the hack recommended by the psql man page
actually works.  What happens if you use \c to change databases during
a psql session?  What *should* happen, if you're trying to keep
per-database histories?
        regards, tom lane


Re: Seperate command-line histories for seperate databases

От
Bruce Momjian
Дата:
Tom Lane wrote:
> Andrew Dunstan <andrew@dunslane.net> writes:
> > Chris Browne wrote:
> >> mbertheau.pg@googlemail.com ("Markus Bertheau") writes:
> >>> Any reason psql doesn't do this by default?
> >> 
> >> I fairly frequently find myself accessing different (but similar)
> >> databases, and it's quite valuable to be able to submit the *same*
> >> queries to them.
> >> 
> >> This change would make it troublesome to do that.  I'd not be all that
> >> keen on the change...
> 
> > Just what I was thinking.
> 
> +1 on not changing the default behavior.  However, this discussion
> makes me wonder just how well the hack recommended by the psql man page
> actually works.  What happens if you use \c to change databases during
> a psql session?  What *should* happen, if you're trying to keep
> per-database histories?

Unless we re-read .psqlrc (which I don't think we do), we will dump into
the original file.

--  Bruce Momjian   http://candle.pha.pa.us SRA OSS, Inc.   http://www.sraoss.com
 + If your life is a hard drive, Christ can be your backup. +


Re: Seperate command-line histories for seperate databases

От
Darcy Buskermolen
Дата:
On Friday 17 March 2006 10:55, Chris Browne wrote:
> mbertheau.pg@googlemail.com ("Markus Bertheau") writes:
> > 2006/3/17, Bruce Momjian <pgman@candle.pha.pa.us>:
> >> Peter Eisentraut wrote:
> >> > Bruce Momjian wrote:
> >> > > The psql manual pages for 8.1 now has:
> >> > >
> >> > >               \set HISTFILE ~/.psql_history- :DBNAME
> >
> > Any reason psql doesn't do this by default? It is clear that the
> > database name does not unambiguously identify a database, but having a
> > history for each database name is already an improvement over the
> > current situation.
>
> I fairly frequently find myself accessing different (but similar)
> databases, and it's quite valuable to be able to submit the *same*
> queries to them.
>
> This change would make it troublesome to do that.  I'd not be all that
> keen on the change...

I'm with Chris on this one, I routinly execute the same command on 6 or 7 of 
our databases, all from the same management consol.   I would find a change 
of this sort soemewhat frustrating, I'd probably be inclined to symlink all 
my history files together.  The presented way looks perfectly acceptable to 
me.


-- 
Darcy Buskermolen
Wavefire Technologies Corp.

http://www.wavefire.com
ph: 250.717.0200
fx: 250.763.1759