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

pgsql pg_connect

From: Jurgen Defurne <defurnj(at)glo(dot)be>
To: pgsql-general(at)postgresql(dot)org
Subject: pgsql pg_connect
Date: 1999-10-28 11:33:54
Message-ID: 381834A2.41D45B77@glo.be (view raw or flat)
Thread:
Lists: pgsql-general
Hello, people on the mailing list,

This is a rather technical question, but the people of pgsql ask that
certain questions be first posted here.
While busy learning the postgreSQL system and Tcl/Tk, I noticed
something that to me (a fulltime applications programmer) seems a flaw
in libpgtcl.
When using pg_connect to a non-existing database, one doesn't have the
means to control the extent of the error. If you try the following
script :

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 ?

As I mentioned, I am a full-time applications programmer. When writing
software for customers, you do NOT want to let loose parts of the OS
which they don't know. You want to implement a graceful recovery of this
error. In this case, I would like a way that my program keeps running,
so that it is possible to send a notification to the user that the
system isn't available and that he should try another time.
You could of course say, make sure that you have an existing database.
Well, this isn't always possible, and the backend may be down.
The kind of error that you have in this case is a resource allocation
error. It should always be possible for the programmer to recover from
this, or at least provide a meaningful message and a way to get out,
without leaving the user on his own devices.
Once you have a result from the connection, the programmer should be
able to test this result and act accordingly. If he doesn't test it, and
he tries to execute a query, and he gets strange results, then it is his
fault and responsibility. But this is what testing is for.

With regards to everybody,

Jurgen Defurne
Flanders
Belgium

Responses

pgsql-general by date

Next:From: Thomas GoodDate: 1999-10-28 13:52:14
Subject: Re: [ANNOUNCE] New PostgreSQL book on web site
Previous:From: Yury DonDate: 1999-10-28 11:31:03
Subject: Re: [GENERAL] A simple SQL command

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