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

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: (view raw, whole thread or download thread mbox)
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
    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} {
	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
> 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 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

pgsql-general by date

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

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