Re: Fix errcontext() function

Lists: pgsql-hackers
From: Chen Huajun <chenhj(at)cn(dot)fujitsu(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Fix errcontext() function
Date: 2012-11-08 05:59:58
Message-ID: 509B4A5E.7010307@cn.fujitsu.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello,

I am sending patch for errcontext() function.

I use procedural languages to do some operation, but when error occurs
,the CONTEXT error messages from procedural languages doesn't display in
local language.

for example:
--------------------------------------------------------
postgres=# CREATE OR REPLACE FUNCTION logfunc3 (logtxt text) RETURNS
timestamp AS $$
postgres$# BEGIN
postgres$# select * from db;
postgres$# RETURN 'now';
postgres$# END;
postgres$# $$ LANGUAGE plpgsql;
CREATE FUNCTION
postgres=# select logfunc3('test');
ERROR: リレーション"db"は存在しません
行 1: select * from db
QUERY: select * from db
CONTEXT: PL/pgSQL function "logfunc3" line 3 at SQL ステートメント
--------------------------------------------------------
but,“CONTEXT: PL/pgSQL 関数 "logfunc3" の 3 行目の型 SQL ステートメント” is my expected.

There is the same problem in pl/perl and pl/python .

After checking and debuging the source code ,I found the reason.

The reason is that domian setted is wrong. For PL/pgSQL, domain "pgsql" should be setted, but domain setted is "postgres" .

So I considered to fix the bug by updating errcontext() funtion.

The patched portion is at src/include/utils/elog.h and
src/backend/utils/error/elog.c

I invite any ideas how to improve this patch.

Best Regards

Huajun Chen

Attachment Content-Type Size
elog_c.diff text/plain 2.7 KB
elog_h.diff text/plain 1.1 KB

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: Chen Huajun <chenhj(at)cn(dot)fujitsu(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fix errcontext() function
Date: 2012-11-08 08:07:14
Message-ID: 509B6832.80303@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 08.11.2012 07:59, Chen Huajun wrote:
> I am sending patch for errcontext() function.
>
> I use procedural languages to do some operation, but when error occurs
> ,the CONTEXT error messages from procedural languages doesn't display in
> local language.
>
> for example:
> --------------------------------------------------------
> postgres=# CREATE OR REPLACE FUNCTION logfunc3 (logtxt text) RETURNS
> timestamp AS $$
> postgres$# BEGIN
> postgres$# select * from db;
> postgres$# RETURN 'now';
> postgres$# END;
> postgres$# $$ LANGUAGE plpgsql;
> CREATE FUNCTION
> postgres=# select logfunc3('test');
> ERROR: リレーション"db"は存在しません
> 行 1: select * from db
> QUERY: select * from db
> CONTEXT: PL/pgSQL function "logfunc3" line 3 at SQL ステートメント
> --------------------------------------------------------
> but,“CONTEXT: PL/pgSQL 関数 "logfunc3" の 3 行目の型 SQL ステートメント” is my expected.
>
> There is the same problem in pl/perl and pl/python .
>
> After checking and debuging the source code ,I found the reason.
>
> The reason is that domian setted is wrong. For PL/pgSQL, domain "pgsql" should be setted, but domain setted is "postgres" .
>
> So I considered to fix the bug by updating errcontext() funtion.

Unfortunately not all compilers support varargs macros. I bumped into
this in February, see
http://archives.postgresql.org/message-id/4F3B72E0.8040801@enterprisedb.com.
My last attempt to fix this was at
http://archives.postgresql.org/pgsql-hackers/2012-04/msg00812.php. That
patch is probably good to go, I just got busy with other things and
forgot about it back then. Can you take a look at that patch and see if
I missed anything, please?

- Heikki


From: Chen Huajun <chenhj(at)cn(dot)fujitsu(dot)com>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fix errcontext() function
Date: 2012-11-10 09:46:24
Message-ID: 509E2270.5090307@cn.fujitsu.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Heikki

> Unfortunately not all compilers support varargs macros. I bumped into this in February, see http://archives.postgresql.org/message-id/4F3B72E0.8040801@enterprisedb.com. My last attempt to fix this was
> at http://archives.postgresql.org/pgsql-hackers/2012-04/msg00812.php. That patch is probably good to go, I just got busy with other things and forgot about it back then. Can you take a look at that
> patch and see if I missed anything, please?
>
> - Heikki
>
>

I think you are right,although the number of changed place is a a little bit large.
Thanks for your answer!

Chen Huajun


From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: Chen Huajun <chenhj(at)cn(dot)fujitsu(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fix errcontext() function
Date: 2012-11-12 15:21:12
Message-ID: 50A113E8.1070600@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 10.11.2012 11:46, Chen Huajun wrote:
>> Unfortunately not all compilers support varargs macros. I bumped into
>> this in February, see
>> http://archives.postgresql.org/message-id/4F3B72E0.8040801@enterprisedb.com.
>> My last attempt to fix this was
>> at http://archives.postgresql.org/pgsql-hackers/2012-04/msg00812.php.
>> That patch is probably good to go, I just got busy with other things
>> and forgot about it back then. Can you take a look at that
>> patch and see if I missed anything, please?
>
> I think you are right,although the number of changed place is a a little
> bit large.
> Thanks for your answer!

Ok, I've committed this patch now, it will be fixed in 9.3. Thanks for
reminding me about this.

- Heikki


From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix errcontext() function
Date: 2012-11-12 15:52:59
Message-ID: 20121112155259.GC4506@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Heikki Linnakangas wrote:
> On 10.11.2012 11:46, Chen Huajun wrote:
> >>Unfortunately not all compilers support varargs macros. I bumped into
> >>this in February, see
> >>http://archives.postgresql.org/message-id/4F3B72E0.8040801@enterprisedb.com.
> >>My last attempt to fix this was
> >>at http://archives.postgresql.org/pgsql-hackers/2012-04/msg00812.php.
> >>That patch is probably good to go, I just got busy with other things
> >>and forgot about it back then. Can you take a look at that
> >>patch and see if I missed anything, please?
> >
> >I think you are right,although the number of changed place is a a little
> >bit large.
> >Thanks for your answer!
>
> Ok, I've committed this patch now, it will be fixed in 9.3. Thanks
> for reminding me about this.

Hopefully you noticed that contrib is broken.

--


From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix errcontext() function
Date: 2012-11-12 16:33:13
Message-ID: 50A124C9.3060709@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 12.11.2012 17:52, Alvaro Herrera wrote:
> Hopefully you noticed that contrib is broken.

Oops.. fixed.

- Heikki