Re: psqlodbc libpq version: quiet error on connect failure - Mailing list pgsql-odbc

From Dave Page
Subject Re: psqlodbc libpq version: quiet error on connect failure
Date
Msg-id E7F85A1B5FF8D44C8A1AF6885BC9A0E4AC93B4@ratbert.vale-housing.co.uk
Whole thread Raw
In response to psqlodbc libpq version: quiet error on connect failure  (Marko Ristola <Marko.Ristola@kolumbus.fi>)
Responses Re: psqlodbc libpq version: quiet error on connect failure
List pgsql-odbc
Thanks, I've applied a patch to fix this. Iirc, exit_nicely() is used in
the libpq examples in the PostgreSQL manual :-)

/D

> -----Original Message-----
> From: pgsql-odbc-owner@postgresql.org
> [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Marko Ristola
> Sent: 20 July 2005 12:23
> To: pgsql-odbc@postgresql.org
> Subject: [ODBC] psqlodbc libpq version: quiet error on connect failure
>
>
> Problem
>
> psqlodbc, with libpq enabled, will do exit(1), if connecting into the
> database fails.
> A good fix seems to be to remove the exit_nicely() function call.
>
> ----------------------
> static void
> exit_nicely(PGconn *conn)
> {
>         PQfinish(conn);
>         exit(1);
> }
> ----------------------
>
> Connect code:
>
>     self->pgconn = PQconnectdb(conninfo);
>     if (PQstatus(self->pgconn) != CONNECTION_OK)
>     {
>
> CC_set_error(self,CONNECTION_COULD_NOT_ESTABLISH,PQerrorMessag
> e(self->pgconn));
>         mylog("could not establish connection to the database %s
> \n",PQerrorMessage(self->pgconn));
>         exit_nicely(self->pgconn);
>         free(conninfo);
>         return 0;
>     }
>
> ------------------------
>
> Marko Ristola
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>

pgsql-odbc by date:

Previous
From: Marko Ristola
Date:
Subject: A correction into the connect exit(1) problem
Next
From: Marko Ristola
Date:
Subject: Re: psqlodbc libpq version: quiet error on connect failure