pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Scot Loach <sloach@sandvine.com>
To: pgsql-odbc@postgresql.org
Subject: [PATCH] notice handler
Date: Sat, 17 Sep 2005 13:51:45 -0400
Message-ID: <71837C040963F748B9B94E123A289678664FB0@mailserver.sandvine.com> (raw)

This patch fill fix the notice handler so that the odbc driver doesn't output notices from the backend to stderr.

inline patch 1: connection.c (+31/-3 lines) download inline-1.patch--- 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 @@ } #else + +static void +CC_handle_notice(void *arg, const char *msg) +{ + QResultClass *qres; + + qres = (QResultClass*)(arg); + + if (qres == 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=0; - - pgres = PQexec(self->pgconn,query); qres=QR_Constructor(); if(!qres) @@ -3183,6 +3207,11 @@ QR_Destructor(qres); return NULL; } + + PQsetNoticeProcessor(self->pgconn, CC_handle_notice, qres); + pgres = PQexec(self->pgconn,query); + PQsetNoticeProcessor(self->pgconn, CC_handle_notice, NULL); + qres->status = PQresultStatus(pgres); /* Check the connection status */ @@ -3388,7 +3417,6 @@ } - #endif /* USE_LIBPQ */

view thread (7+ messages)  latest in thread

Message-ID: <71837C040963F748B9B94E123A289678664FB0@mailserver.sandvine.com>
Permalink:  ../71837C040963F748B9B94E123A289678664FB0@mailserver.sandvine.com/
Also on:    postgresql.org/message-id/71837C040963F748B9B94E123A289678664FB0@mailserver.sandvine.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: sloach@sandvine.com
  Subject: Re: [PATCH] notice handler
  In-Reply-To: <71837C040963F748B9B94E123A289678664FB0@mailserver.sandvine.com>
  References: <71837C040963F748B9B94E123A289678664FB0@mailserver.sandvine.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox