X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 3B5679DC9A7 for ; Fri, 6 Jan 2006 00:02:05 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 84188-10 for ; Fri, 6 Jan 2006 00:02:03 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by postgresql.org (Postfix) with ESMTP id E66939DC888 for ; Fri, 6 Jan 2006 00:02:02 -0400 (AST) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id k0641x8p000757 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 5 Jan 2006 21:02:01 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.4/8.13.4) with ESMTP id k0641wre081578; Thu, 5 Jan 2006 21:01:58 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.4/8.13.4/Submit) id k0641wDO081577; Thu, 5 Jan 2006 21:01:58 -0700 (MST) (envelope-from mfuhr) Date: Thu, 5 Jan 2006 21:01:58 -0700 From: Michael Fuhr To: JiangWei Cc: pgsql-interfaces@postgresql.org Subject: Re: [C API] Is there a nice way to get table/column name on some error ? Message-ID: <20060106040158.GA81499@winnie.fuhr.org> References: <43BDC8B4.6020801@sduept.com> <20060106021149.GA80657@winnie.fuhr.org> <43BDD2B7.2090609@sduept.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <43BDD2B7.2090609@sduept.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.077 required=5 tests=[AWL=0.077] X-Spam-Score: 0.077 X-Spam-Level: X-Archive-Number: 200601/6 X-Sequence-Number: 5922 [Please post in plain text, not HTML.] On Fri, Jan 06, 2006 at 10:15:19AM +0800, JiangWei wrote: > > With libpq you can call PQerrorMessage(), PQresultErrorMessage(), > > or PQresultErrorField() to get a string that should identify the > > offending column, function, table, etc. Will that work for your > > purpose? > > No. I want to throw a exception with the column name, like this : > if (sqlstate == undefined_column) > throw UnknownProperty(column_name); I'm not aware of a way to get just the column name, so if nobody else posts a way then you might have to parse the error message (admittedly a pain, especially if you have to deal with different languages). -- Michael Fuhr