pgsql pg_connect

Поиск
Список
Период
Сортировка
От Jurgen Defurne
Тема pgsql pg_connect
Дата
Msg-id 381834A2.41D45B77@glo.be
обсуждение исходный текст
Ответы Re: [GENERAL] pgsql pg_connect  ("Ross J. Reedstrom" <reedstrm@wallace.ece.rice.edu>)
Список 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

В списке pgsql-general по дате отправления:

Предыдущее
От: "Yury Don"
Дата:
Сообщение: Re: [GENERAL] A simple SQL command
Следующее
От: Ian Phillips
Дата:
Сообщение: Removing languages