From jw.pgsql@sduept.com Fri Jan 6 01:34:28 2006 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 759359DC827 for ; Thu, 5 Jan 2006 21:34:28 -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 56964-06 for ; Thu, 5 Jan 2006 21:34:31 -0400 (AST) X-Greylist: delayed 00:15:57.997159 by SQLgrey- Received: from hp.sduept.com (unknown [60.208.83.220]) by postgresql.org (Postfix) with ESMTP id 85E229DC802 for ; Thu, 5 Jan 2006 21:34:24 -0400 (AST) Received: from [192.168.1.36] (soft36.sduept.com [192.168.1.36]) by hp.sduept.com (8.13.1/8.13.1) with ESMTP id k061WaEJ017510 for ; Fri, 6 Jan 2006 09:32:36 +0800 Message-ID: <43BDC8B4.6020801@sduept.com> Date: Fri, 06 Jan 2006 09:32:36 +0800 From: JiangWei User-Agent: Mozilla Thunderbird 1.0.7-1.1.fc4 (X11/20050929) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-interfaces@postgresql.org Subject: [C API] Is there a nice way to get table/column name on some error ? Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.144 required=5 tests=[AWL=0.016, HTML_MESSAGE=0.001, HTML_TAG_EXIST_TBODY=0.126, MIME_HTML_ONLY=0.001] X-Spam-Score: 0.144 X-Spam-Level: X-Archive-Number: 200601/3 X-Sequence-Number: 5919
42703 UNDEFINED COLUMN undefined_column
42883 UNDEFINED FUNCTION undefined_function
42P01 UNDEFINED TABLE undefined_table

I want to know which column undefined when "undefined_column" Happen at run time.




From mike@fuhr.org Fri Jan 6 02:11:52 2006 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 2EFD09DCA2F for ; Thu, 5 Jan 2006 22:11:52 -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 64090-03 for ; Thu, 5 Jan 2006 22:11:56 -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 C89819DCA0A for ; Thu, 5 Jan 2006 22:11:49 -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 k062Bo6d000664 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 5 Jan 2006 19:11:52 -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 k062BoJ0080756; Thu, 5 Jan 2006 19:11:50 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.4/8.13.4/Submit) id k062BnaF080755; Thu, 5 Jan 2006 19:11:49 -0700 (MST) (envelope-from mfuhr) Date: Thu, 5 Jan 2006 19:11:49 -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: <20060106021149.GA80657@winnie.fuhr.org> References: <43BDC8B4.6020801@sduept.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <43BDC8B4.6020801@sduept.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.074 required=5 tests=[AWL=0.074] X-Spam-Score: 0.074 X-Spam-Level: X-Archive-Number: 200601/4 X-Sequence-Number: 5920 [Please post in plain text, not HTML.] On Fri, Jan 06, 2006 at 09:32:36AM +0800, JiangWei wrote: > 42703 UNDEFINED COLUMN undefined_column > 42883 UNDEFINED FUNCTION undefined_function > 42P01 UNDEFINED TABLE undefined_table > > I want to know which column undefined when "undefined_column" Happen > at run time. 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? -- Michael Fuhr From mike@fuhr.org Fri Jan 6 04:02:05 2006 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