pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
[PATCH] notice handler
7+ messages / 3 participants
[nested] [flat]

* [PATCH] notice handler
@ 2005-09-17 17:51 Scot Loach <sloach@sandvine.com>
  2005-09-17 22:19 ` Re: [PATCH] notice handler Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 7+ messages in thread

From: Scot Loach @ 2005-09-17 17:51 UTC (permalink / raw)
  To: pgsql-odbc

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 */
^ permalink raw reply [nested|flat] 7+ messages in thread

* Re: [PATCH] notice handler
  2005-09-17 17:51 [PATCH] notice handler Scot Loach <sloach@sandvine.com>
@ 2005-09-17 22:19 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2005-09-17 22:19 UTC (permalink / raw)
  To: Scot Loach <sloach@sandvine.com>; +Cc: pgsql-odbc

"Scot Loach" <sloach@sandvine.com> writes:
> This patch fill fix the notice handler so that the odbc driver doesn't output notices from the backend to stderr.

Why is that a "fix" and not "breaking it"?  It sounds pretty ill-advised
to me.  In particular, notices sent when not inside a query are usually
pretty significant (ie, the backend telling you why it's about to cut
off your connection), and I can't see a justification for arbitrarily
suppressing them.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [PATCH] notice handler
@ 2005-09-17 22:27 Dave Page <dpage@vale-housing.co.uk>
  0 siblings, 0 replies; 7+ messages in thread

From: Dave Page @ 2005-09-17 22:27 UTC (permalink / raw)
  To: Scot Loach <sloach@sandvine.com>; pgsql-odbc

Thanks Scot, patch applied.

Regards, Dave 

> -----Original Message-----
> From: pgsql-odbc-owner@postgresql.org 
> [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Scot Loach
> Sent: 17 September 2005 18:52
> To: pgsql-odbc@postgresql.org
> Subject: [ODBC] [PATCH] notice handler
> 
> 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 @@
>  }
>  
>  #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 */
>  
> 
> ---------------------------(end of 
> broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
>        subscribe-nomail command to majordomo@postgresql.org 
> so that your
>        message can get through to the mailing list cleanly
> 



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [PATCH] notice handler
@ 2005-09-17 22:30 Dave Page <dpage@vale-housing.co.uk>
  2005-09-17 22:33 ` Re: [PATCH] notice handler Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 7+ messages in thread

From: Dave Page @ 2005-09-17 22:30 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; Scot Loach <sloach@sandvine.com>; +Cc: pgsql-odbc

 

> -----Original Message-----
> From: pgsql-odbc-owner@postgresql.org 
> [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Tom Lane
> Sent: 17 September 2005 23:20
> To: Scot Loach
> Cc: pgsql-odbc@postgresql.org
> Subject: Re: [ODBC] [PATCH] notice handler 
> 
> "Scot Loach" <sloach@sandvine.com> writes:
> > This patch fill fix the notice handler so that the odbc 
> driver doesn't output notices from the backend to stderr.
> 
> Why is that a "fix" and not "breaking it"?  It sounds pretty 
> ill-advised
> to me.  In particular, notices sent when not inside a query 
> are usually
> pretty significant (ie, the backend telling you why it's about to cut
> off your connection), and I can't see a justification for arbitrarily
> suppressing them.

It doesn't suppress them, it processes them as a non-fatal message so
the app can deal with them rather than just dumping them to stderr.

Regards, Dave.



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [PATCH] notice handler
  2005-09-17 22:30 Re: [PATCH] notice handler Dave Page <dpage@vale-housing.co.uk>
@ 2005-09-17 22:33 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2005-09-17 22:33 UTC (permalink / raw)
  To: Dave Page <dpage@vale-housing.co.uk>; +Cc: Scot Loach <sloach@sandvine.com>; pgsql-odbc

"Dave Page" <dpage@vale-housing.co.uk> writes:
> It doesn't suppress them, it processes them as a non-fatal message so
> the app can deal with them rather than just dumping them to stderr.

So the comment stating that notices are dumped on the floor when there
is no query in progress is lying?

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [PATCH] notice handler
@ 2005-09-17 22:39 Dave Page <dpage@vale-housing.co.uk>
  0 siblings, 0 replies; 7+ messages in thread

From: Dave Page @ 2005-09-17 22:39 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Scot Loach <sloach@sandvine.com>; pgsql-odbc

 

> -----Original Message-----
> From: Tom Lane [mailto:tgl@sss.pgh.pa.us] 
> Sent: 17 September 2005 23:34
> To: Dave Page
> Cc: Scot Loach; pgsql-odbc@postgresql.org
> Subject: Re: [ODBC] [PATCH] notice handler 
> 
> "Dave Page" <dpage@vale-housing.co.uk> writes:
> > It doesn't suppress them, it processes them as a non-fatal 
> message so
> > the app can deal with them rather than just dumping them to stderr.
> 
> So the comment stating that notices are dumped on the floor when there
> is no query in progress is lying?

<looks again> Ah, sorry. Missed that.

Will sort it...

/D



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [PATCH] notice handler
@ 2005-09-17 23:00 Dave Page <dpage@vale-housing.co.uk>
  0 siblings, 0 replies; 7+ messages in thread

From: Dave Page @ 2005-09-17 23:00 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Scot Loach <sloach@sandvine.com>; pgsql-odbc

 

> -----Original Message-----
> From: pgsql-odbc-owner@postgresql.org 
> [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Dave Page
> Sent: 17 September 2005 23:39
> To: Tom Lane
> Cc: Scot Loach; pgsql-odbc@postgresql.org
> Subject: Re: [ODBC] [PATCH] notice handler 
> 
>  
> 
> > -----Original Message-----
> > From: Tom Lane [mailto:tgl@sss.pgh.pa.us] 
> > Sent: 17 September 2005 23:34
> > To: Dave Page
> > Cc: Scot Loach; pgsql-odbc@postgresql.org
> > Subject: Re: [ODBC] [PATCH] notice handler 
> > 
> > "Dave Page" <dpage@vale-housing.co.uk> writes:
> > > It doesn't suppress them, it processes them as a non-fatal 
> > message so
> > > the app can deal with them rather than just dumping them 
> to stderr.
> > 
> > So the comment stating that notices are dumped on the floor 
> when there
> > is no query in progress is lying?
> 
> <looks again> Ah, sorry. Missed that.
> 
> Will sort it...

Done. Interestingly, the old version of the driver has always done the
same thing.

/D



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2005-09-17 23:00 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-09-17 17:51 [PATCH] notice handler Scot Loach <sloach@sandvine.com>
2005-09-17 22:19 ` Tom Lane <tgl@sss.pgh.pa.us>
2005-09-17 22:27 Re: [PATCH] notice handler Dave Page <dpage@vale-housing.co.uk>
2005-09-17 22:30 Re: [PATCH] notice handler Dave Page <dpage@vale-housing.co.uk>
2005-09-17 22:33 ` Tom Lane <tgl@sss.pgh.pa.us>
2005-09-17 22:39 Re: [PATCH] notice handler Dave Page <dpage@vale-housing.co.uk>
2005-09-17 23:00 Re: [PATCH] notice handler Dave Page <dpage@vale-housing.co.uk>

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