Re: [GENERAL] pgsql pg_connect

From: "Ross J(dot) Reedstrom" <reedstrm(at)wallace(dot)ece(dot)rice(dot)edu>
To: Jurgen Defurne <defurnj(at)glo(dot)be>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] pgsql pg_connect
Date: 1999-10-28 15:10:37
Message-ID: 19991028101037.B29773@wallace.ece.rice.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jurgen -
In general, libpgtcl questions are best addressed to the 'interfaces' list.
The PgAccess program that comes with postgresql is a tcl program, and it
handles the problem with a catch. Here's the proc that does it (rewrapped
for email):

proc {open_database} {} {
global dbc host pport dbname username password newusername\
newpassword sdbname newdbname newhost newpport pref pgsql
cursor_clock
if {$newusername!=""} {
set connres [catch {set newdbc [pg_connect -conninfo\
"host=$newhost port=$newpport dbname=$newdbname\
user=$newusername password=$newpassword"]} msg]
} {
set connres [catch {set newdbc [pg_connect $newdbname\
-host $newhost -port $newpport]} msg]
}
if {$connres} {
cursor_normal
show_error "Error trying to connect to database \"$newdbname\"\
on host $newhost\n\nPostgreSQL error message: $msg"
return $msg
} {
catch {pg_disconnect $dbc}
set dbc $newdbc
set host $newhost
set pport $newpport
set dbname $newdbname

...other stuff deleted...

}
}

On Thu, Oct 28, 1999 at 01:33:54PM +0200, Jurgen Defurne wrote:
> Hello, people on the mailing list,
>
> load libpgtcl.so
>
> set connection [pg_connect notanexistingdatabase]
>
> it is not at all possible to recover the running program from this
> error. I have tried this using catch, but to no avail. This is the
> result :
>
> Connection to database failed
> FATAL 1: Database notadatabase does not exist in pg_database
> while executing
> "pg_connect notadatabase"
> (file "connect.tcl" line 10)
>
> Or, this is an error in Tcl, or this is not good enough thought out in
> libpgtcl.
>
> Why do I say this about libpgtcl ?

Ross
--
Ross J. Reedstrom, Ph.D., <reedstrm(at)rice(dot)edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St., Houston, TX 77005

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ian Phillips 1999-10-28 15:31:26 Re: [GENERAL] Removing languages
Previous Message Bruce Momjian 1999-10-28 15:10:06 Re: [ANNOUNCE] New PostgreSQL book on web site