Thread

  1. Seperate command-line histories for seperate databases

    Peter Eisentraut <peter_e@gmx.net> — 2006-03-17T16:20:43Z

    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/
    
    
  2. Re: Seperate command-line histories for seperate databases

    Bruce Momjian <pgman@candle.pha.pa.us> — 2006-03-17T16:30:09Z

    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. +
    
    
  3. Re: Seperate command-line histories for seperate databases

    Peter Eisentraut <peter_e@gmx.net> — 2006-03-17T17:01:25Z

    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/
    
    
  4. Re: Seperate command-line histories for seperate databases

    Bruce Momjian <pgman@candle.pha.pa.us> — 2006-03-17T17:04:04Z

    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. +
    
    
  5. Re: Seperate command-line histories for seperate databases

    Markus Bertheau <mbertheau.pg@googlemail.com> — 2006-03-17T17:48:47Z

    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
    
    
  6. Re: Seperate command-line histories for seperate databases

    Bruce Momjian <pgman@candle.pha.pa.us> — 2006-03-17T18:51:01Z

    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. +
    
    
  7. Re: Seperate command-line histories for seperate databases

    Chris Browne <cbbrowne@acm.org> — 2006-03-17T18:55:01Z

    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,
    
    
  8. Re: Seperate command-line histories for seperate databases

    Andrew Dunstan <andrew@dunslane.net> — 2006-03-17T19:14:24Z

    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
    
    
  9. Re: Seperate command-line histories for seperate databases

    Tom Lane <tgl@sss.pgh.pa.us> — 2006-03-17T20:27:36Z

    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
    
    
  10. Re: Seperate command-line histories for seperate databases

    Bruce Momjian <pgman@candle.pha.pa.us> — 2006-03-17T21:35:03Z

    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. +
    
    
  11. Re: Seperate command-line histories for seperate databases

    Darcy Buskermolen <darcy@wavefire.com> — 2006-03-17T22:28:31Z

    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