This patch fill fix the notice handler so that the odbc driver doesn't output notices...
authorDave Page <dpage@pgadmin.org>
Sat, 17 Sep 2005 22:27:24 +0000 (22:27 +0000)
committerDave Page <dpage@pgadmin.org>
Sat, 17 Sep 2005 22:27:24 +0000 (22:27 +0000)
[Scot Loach]

connection.c

index 6b8703d67f2434b989d5e13644f74834586f4547..38a4e289b8a565aa90bbb8111fdbca7d382a8b7b 100644 (file)
@@ -2349,6 +2349,29 @@ CC_send_cancel_request(const ConnectionClass *conn)
 }
 
 #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 @@ LIBPQ_connect(ConnectionClass *self)
    }
    /* 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 @@ LIBPQ_execute_query(ConnectionClass *self,char *query)
    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 @@ LIBPQ_execute_query(ConnectionClass *self,char *query)
        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 */
@@ -3383,7 +3412,6 @@ CC_is_server_alive(ConnectionClass *conn)
 
 }
 
-
 #endif /* USE_LIBPQ */