Skip site navigation (1) Skip section navigation (2)

Re: [PATCH] notice handler

From: "Dave Page" <dpage(at)vale-housing(dot)co(dot)uk>
To: "Scot Loach" <sloach(at)sandvine(dot)com>, <pgsql-odbc(at)postgresql(dot)org>
Subject: Re: [PATCH] notice handler
Date: 2005-09-17 22:27:44
Message-ID: E7F85A1B5FF8D44C8A1AF6885BC9A0E4CC2CF8@ratbert.vale-housing.co.uk (view raw or flat)
Thread:
Lists: pgsql-odbc
Thanks Scot, patch applied.

Regards, Dave 

> -----Original Message-----
> From: pgsql-odbc-owner(at)postgresql(dot)org 
> [mailto:pgsql-odbc-owner(at)postgresql(dot)org] On Behalf Of Scot Loach
> Sent: 17 September 2005 18:52
> To: pgsql-odbc(at)postgresql(dot)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(at)postgresql(dot)org 
> so that your
>        message can get through to the mailing list cleanly
> 

pgsql-odbc by date

Next:From: Dave PageDate: 2005-09-17 22:30:16
Subject: Re: [PATCH] notice handler
Previous:From: Tom LaneDate: 2005-09-17 22:19:40
Subject: Re: [PATCH] notice handler

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group