X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 68715329E7C for ; Mon, 13 Sep 2004 22:16:18 +0100 (BST) 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 46193-09 for ; Mon, 13 Sep 2004 21:16:10 +0000 (GMT) Received: from mail.broadpark.no (mail.broadpark.no [217.13.4.2]) by svr1.postgresql.org (Postfix) with ESMTP id D4BE7329E79 for ; Mon, 13 Sep 2004 22:16:10 +0100 (BST) Received: from dwp.des.no (37.80-203-228.nextgentel.com [80.203.228.37]) by mail.broadpark.no (Postfix) with ESMTP id 5B5F91266 for ; Mon, 13 Sep 2004 23:16:48 +0200 (MEST) Received: by dwp.des.no (Postfix, from userid 2602) id 01FEEB85E; Mon, 13 Sep 2004 23:16:08 +0200 (CEST) To: pgsql-interfaces@postgresql.org Subject: [PATCH] add notice processor to DBD::Pg From: des@des.no (=?iso-8859-1?q?Dag-Erling_Sm=F8rgrav?=) Date: Mon, 13 Sep 2004 23:16:08 +0200 Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/11 X-Sequence-Number: 5086 --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable The attached patch adds a notice processor to DBD::Pg. While it doesn't do much (just pass the mesage on to warn()), it allows Perl scripts to intercept notices with the usual $SIG{__WARN__} mechanism. DES --=20 Dag-Erling Sm=F8rgrav - des@des.no --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=patch-dbdimp.c --- dbdimp.c.orig Sun Sep 12 13:26:17 2004 +++ dbdimp.c Sun Sep 12 13:29:12 2004 @@ -97,6 +97,12 @@ free(err); } +static void +pg_notice(void *arg, const char *message) +{ + warn("%s", message); +} + static int pgtype_bind_ok (dbtype) int dbtype; @@ -182,6 +188,9 @@ /* make a connection to the database */ imp_dbh->conn = PQconnectdb(conn_str); free(conn_str); + + /* install notice processor */ + PQsetNoticeProcessor(imp_dbh->conn, pg_notice, imp_dbh->conn); /* check to see that the backend connection was successfully made */ if (PQstatus(imp_dbh->conn) != CONNECTION_OK) { --=-=-=--