X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E3FC8D7FFD for ; Sat, 17 Sep 2005 14:51:48 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85741-02 for ; Sat, 17 Sep 2005 17:51:46 +0000 (GMT) Received: from mailserver.sandvine.com (sandvine.com [199.243.201.138]) by svr1.postgresql.org (Postfix) with ESMTP id 3D289D70C7 for ; Sat, 17 Sep 2005 14:51:45 -0300 (ADT) X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: [PATCH] notice handler Date: Sat, 17 Sep 2005 13:51:45 -0400 Message-ID: <71837C040963F748B9B94E123A289678664FB0@mailserver.sandvine.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH] notice handler Thread-Index: AcW7sHg+9SHQKDz4SE6swGoezN7y8w== From: "Scot Loach" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 required=5 tests=[none] X-Spam-Level: X-Archive-Number: 200509/150 X-Sequence-Number: 6048 This patch fill fix the notice handler so that the odbc driver doesn't = output notices from the backend to stderr. --- connection.c.old 2005-09-17 13:50:26.000000000 -0400 +++ connection.c 2005-09-17 13:40:11.000000000 -0400 @@ -2349,6 +2349,29 @@ } =20 #else + +static void +CC_handle_notice(void *arg, const char *msg) +{ + QResultClass *qres; + + qres =3D (QResultClass*)(arg); + + if (qres =3D=3D NULL) + { + // No query in progress, so just drop the notice + return; + } + + if (QR_command_successful(qres)) + { + QR_set_status(qres, PGRES_NONFATAL_ERROR); + QR_set_notice(qres, msg); /* will dup this string = */ + mylog("~~~ NOTICE: '%s'\n", msg); + qlog("NOTICE from backend during send_query: '%s'\n", = msg); + } +} + /* * Connection class implementation using libpq. * Memory Allocation for PGconn is handled by libpq. @@ -3161,6 +3184,9 @@ } /* free the conninfo structure */ free(conninfo); + + /* setup the notice handler */ + PQsetNoticeProcessor(self->pgconn, CC_handle_notice, NULL); mylog("connection to the database succeeded.\n"); return 1; } @@ -3173,8 +3199,6 @@ PGresult *pgres; char errbuffer[ERROR_MSG_LENGTH + 1]; int pos=3D0; - =20 - pgres =3D PQexec(self->pgconn,query); =20 qres=3DQR_Constructor(); if(!qres) @@ -3183,6 +3207,11 @@ QR_Destructor(qres); return NULL; } + + PQsetNoticeProcessor(self->pgconn, CC_handle_notice, qres); + pgres =3D PQexec(self->pgconn,query); + PQsetNoticeProcessor(self->pgconn, CC_handle_notice, NULL); + qres->status =3D PQresultStatus(pgres); =20 /* Check the connection status */ @@ -3388,7 +3417,6 @@ =20 } =20 - #endif /* USE_LIBPQ */ =20