Thread

  1. Re: [HACKERS] PSQL man page patch

    Andrew Martin <martin@biochemistry.ucl.ac.uk> — 1998-01-16T16:30:34Z

    > OK, we never installed this for 6.2 because we were already in Beta. 
    > Can we do this for 6.3?  Vadim suggested we make this part of libpq, so
    > all applications could make use of it.
    > 
    > 
    
    Any more comments about adding support for .psqlrc? The original
    proposal was that psql should read commands from /etc/psqlrc
    and then from $(HOME)/.psqlrc
    
    Nobody seems to have raised any objections. I vote for including this
    for 6.3
    
    
    Andrew
    
    ----------------------------------------------------------------------------
    Dr. Andrew C.R. Martin                             University College London
    EMAIL: (Work) martin@biochem.ucl.ac.uk    (Home) andrew@stagleys.demon.co.uk
    URL:   http://www.biochem.ucl.ac.uk/~martin
    Tel:   (Work) +44(0)171 419 3890                    (Home) +44(0)1372 275775
    
    
  2. Re: [HACKERS] PSQL man page patch

    Thomas Lockhart <lockhart@alumni.caltech.edu> — 1998-01-16T16:52:30Z

    Andrew Martin wrote:
    
    > > OK, we never installed this for 6.2 because we were already in Beta.
    > > Can we do this for 6.3?  Vadim suggested we make this part of libpq, so
    > > all applications could make use of it.
    > >
    > >
    >
    > Any more comments about adding support for .psqlrc? The original
    > proposal was that psql should read commands from /etc/psqlrc
    > and then from $(HOME)/.psqlrc
    >
    > Nobody seems to have raised any objections. I vote for including this
    > for 6.3
    
    I'm in favor of it also, perhaps as a libpq function call which is used in
    psql. That way, other apps or frontends can choose to use it or not.
    
    Would much prefer leaving it out as a _mandatory_ part of connection
    initialization, since there will be side-effects for embedded apps. Combined
    with PGDATESTYLE and PGTZ there will be pretty good control over the frontend
    environment.
    
                                             - Tom
    
    
    
  3. Re: [HACKERS] PSQL man page patch

    Bruce Momjian <maillist@candle.pha.pa.us> — 1998-01-16T17:06:37Z

    > 
    > 
    > > OK, we never installed this for 6.2 because we were already in Beta. 
    > > Can we do this for 6.3?  Vadim suggested we make this part of libpq, so
    > > all applications could make use of it.
    > > 
    > > 
    > 
    > Any more comments about adding support for .psqlrc? The original
    > proposal was that psql should read commands from /etc/psqlrc
    > and then from $(HOME)/.psqlrc
    > 
    > Nobody seems to have raised any objections. I vote for including this
    > for 6.3
    > 
    
    Sure.  Let's do it from psql only, I think.
    
    -- 
    Bruce Momjian
    maillist@candle.pha.pa.us
    
    
  4. Re: [HACKERS] PSQL man page patch

    Marc G. Fournier <scrappy@hub.org> — 1998-01-16T17:12:14Z

    On Fri, 16 Jan 1998, Andrew Martin wrote:
    
    > 
    > > OK, we never installed this for 6.2 because we were already in Beta. 
    > > Can we do this for 6.3?  Vadim suggested we make this part of libpq, so
    > > all applications could make use of it.
    > > 
    > > 
    > 
    > Any more comments about adding support for .psqlrc? The original
    > proposal was that psql should read commands from /etc/psqlrc
    > and then from $(HOME)/.psqlrc
    > 
    > Nobody seems to have raised any objections. I vote for including this
    > for 6.3
    
    	I think its a good thing and should be added...I also agree with
    Bruce(?) who disagreed with Vadim...it shouldn't be inherent in libpq
    itself, only in the "applications" themselves
    
    
    
    
  5. Re: [HACKERS] PSQL man page patch

    Peter T Mount <psqlhack@maidast.demon.co.uk> — 1998-01-17T14:26:31Z

    On Fri, 16 Jan 1998, Thomas G. Lockhart wrote:
    
    > I'm in favor of it also, perhaps as a libpq function call which is used in
    > psql. That way, other apps or frontends can choose to use it or not.
    > 
    > Would much prefer leaving it out as a _mandatory_ part of connection
    > initialization, since there will be side-effects for embedded apps. Combined
    > with PGDATESTYLE and PGTZ there will be pretty good control over the frontend
    > environment.
         
    I agree entirely with you Tom, as this could cause problems if it was a   
    _mandatory_ part of connecting. 
      
    Infact, it would (with the JDBC driver) prevent it from being used with   
    Applets (accessing local files violate applet security).
     
    It's best to make this an optional call for libpq.
    
    For jdbc use, the following is the best way to do this (rather than 
    including it in the driver):
    
    public void readRCfile(Statement stat,File file) throws SQLException
    {
      try {
        FileInputStream fis = new FileInputStream(file);
        BufferedReader r = new BufferedReader(new Reader(fis));
    
        while((String line=r.readLine())!=null) {
          if(!line.startsWith("#"))
    	stat.executeUpdate(line);
        }
        r.close();
      } catch(IOException ioe)
        throw new SQLException(ioe.toString());
    }
    
    public void initConnection(Connection con) throws SQLException
    {
      Statement stat = con.createStatement();
      
      // Process ~/.psqlrc
      try {
        String dir=System.getProperty("user.home");
        if(dir!=null)
          readRCfile(stat,new File(dir,".psqlrc"));
      } catch(SQLException se) {
        // Ignore if it doesn't exist.
      }
    
      // Now /etc/psqlrc
      readRCfile(stat,new File("/etc/psqlrc"));
    
      stat.close();
    }
    
    I'll add this to the examples later.
    
    -- 
    Peter T Mount  petermount@earthling.net or pmount@maidast.demon.co.uk
    Main Homepage: http://www.demon.co.uk/finder
    Work Homepage: http://www.maidstone.gov.uk Work EMail: peter@maidstone.gov.uk
    
    
    
  6. Re: [HACKERS] PSQL man page patch

    Vadim B. Mikheev <vadim@sable.krasnoyarsk.su> — 1998-01-18T09:25:28Z

    Peter T Mount wrote:
    > 
    > On Fri, 16 Jan 1998, Thomas G. Lockhart wrote:
    > 
    > > I'm in favor of it also, perhaps as a libpq function call which is used in
    > > psql. That way, other apps or frontends can choose to use it or not.
    > >
    > > Would much prefer leaving it out as a _mandatory_ part of connection
    > > initialization, since there will be side-effects for embedded apps. Combined
    > > with PGDATESTYLE and PGTZ there will be pretty good control over the frontend
    > > environment.
    > 
    > I agree entirely with you Tom, as this could cause problems if it was a
    > _mandatory_ part of connecting.
    
    Agreed!
    
    BTW, do you like X11 ?
    
    XLock.background:			Black
    Netscape*background:		#B2B2B2
    
    How about following this way ?
    
    psql.pgdatestyle:		euro	# this is for psql
    _some_app_.pgdatestyle:	iso	# this is for some application
    pgaccess.background:	black	# setting pgaccess' specific feature
    *.pggeqo:		on=3	# this is for all applics
    
    We could use 'pg' prefix for standard features (datestyle, tz, etc)
    to give applic developers ability to set applic' specific features
    in the pgsqlrc file(s).
    
    Vadim
    
    
  7. Re: [HACKERS] PSQL man page patch

    Peter T Mount <psqlhack@maidast.demon.co.uk> — 1998-01-18T11:21:48Z

    On Sun, 18 Jan 1998, Vadim B. Mikheev wrote:
    
    > Peter T Mount wrote:
    > > 
    > > On Fri, 16 Jan 1998, Thomas G. Lockhart wrote:
    > > 
    > > > I'm in favor of it also, perhaps as a libpq function call which is used in
    > > > psql. That way, other apps or frontends can choose to use it or not.
    > > >
    > > > Would much prefer leaving it out as a _mandatory_ part of connection
    > > > initialization, since there will be side-effects for embedded apps. Combined
    > > > with PGDATESTYLE and PGTZ there will be pretty good control over the frontend
    > > > environment.
    > > 
    > > I agree entirely with you Tom, as this could cause problems if it was a
    > > _mandatory_ part of connecting.
    > 
    > Agreed!
    > 
    > BTW, do you like X11 ?
    
    Yes, as its much better than a certain other windowing front end I could
    mention ;-)
    
    > XLock.background:			Black
    > Netscape*background:		#B2B2B2
    > 
    > How about following this way ?
    > 
    > psql.pgdatestyle:		euro	# this is for psql
    > _some_app_.pgdatestyle:	iso	# this is for some application
    > pgaccess.background:	black	# setting pgaccess' specific feature
    > *.pggeqo:		on=3	# this is for all applics
    
    I assume you mean using X style configuration in /etc/psqlrc ? If so, then
    yes, it's a good way to go, as it allows a lot of flexibility.
    
    One problem with the earlier .psqlrc idea was that any commands would run
    for any database (as I saw it). This could cause big problems, if the user
    accessed a database that didn't support those commands. With the above
    method, you can get round this, by something like:
    
    psql.database.mydb:	.mydbrc		# sql file run when mydb is opened
    psql.database.*:	.generalrc	# sql file run when any db is
    					# opened
    
    Now, JDBC driver can't use the same config file as that violates security.
    To get round this, we use Java's system properties. For applets, the
    driver simply gets nothing when it asks for the parameter. Applications
    can load their own parameters from a file, or have them set on the command
    line.
    
    The file looks like:
    
    # Default authorisation scheme
    postgresql.auth=password
    
    The command line form looks like:
    
    java -Dpostgresql.auth=password myapp
    
    > We could use 'pg' prefix for standard features (datestyle, tz, etc)
    > to give applic developers ability to set applic' specific features
    > in the pgsqlrc file(s).
    
    Sounds good to me
    
    -- 
    Peter T Mount  petermount@earthling.net or pmount@maidast.demon.co.uk
    Main Homepage: http://www.demon.co.uk/finder
    Work Homepage: http://www.maidstone.gov.uk Work EMail: peter@maidstone.gov.uk
    
    
    
  8. Re: [HACKERS] PSQL man page patch

    Bruce Momjian <maillist@candle.pha.pa.us> — 1998-01-18T19:33:54Z

    > Agreed!
    > 
    > BTW, do you like X11 ?
    > 
    > XLock.background:			Black
    > Netscape*background:		#B2B2B2
    > 
    > How about following this way ?
    > 
    > psql.pgdatestyle:		euro	# this is for psql
    > _some_app_.pgdatestyle:	iso	# this is for some application
    > pgaccess.background:	black	# setting pgaccess' specific feature
    > *.pggeqo:		on=3	# this is for all applics
    > 
    > We could use 'pg' prefix for standard features (datestyle, tz, etc)
    > to give applic developers ability to set applic' specific features
    > in the pgsqlrc file(s).
    > 
    
    Cool idea.
    
    -- 
    Bruce Momjian
    maillist@candle.pha.pa.us