Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] PSQL man page patch

From: Peter T Mount <psqlhack(at)maidast(dot)demon(dot)co(dot)uk>
To: "Thomas G(dot) Lockhart" <lockhart(at)alumni(dot)caltech(dot)edu>
Cc: martin(at)biochemistry(dot)ucl(dot)ac(dot)uk, hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] PSQL man page patch
Date: 1998-01-17 14:26:31
Message-ID: Pine.LNX.3.95.980117140924.1911B-100000@maidast (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
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) {
  } 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");
      readRCfile(stat,new File(dir,".psqlrc"));
  } catch(SQLException se) {
    // Ignore if it doesn't exist.

  // Now /etc/psqlrc
  readRCfile(stat,new File("/etc/psqlrc"));


I'll add this to the examples later.

Peter T Mount  petermount(at)earthling(dot)net or pmount(at)maidast(dot)demon(dot)co(dot)uk
Main Homepage:
Work Homepage: Work EMail: peter(at)maidstone(dot)gov(dot)uk

In response to


pgsql-hackers by date

Next:From: Bruce MomjianDate: 1998-01-17 16:00:25
Subject: Re: [HACKERS] subselects coding started
Previous:From: teunisDate: 1998-01-17 06:56:27
Subject: Re: [HACKERS] Re: [QUESTIONS] Arrays (inserting and removing)

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group