prevent encoding conversion recursive error - Mailing list pgsql-patches

From Qingqing Zhou
Subject prevent encoding conversion recursive error
Date
Msg-id dcsl7c$284i$1@news.hub.org
Whole thread Raw
Responses Re: prevent encoding conversion recursive error  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
As this thread reports (some sever messages are in Chinese):

    http://archives.postgresql.org/pgsql-bugs/2005-07/msg00247.php

a SQL grammar error could crash the error stack.

My explaination is that "select;" incurs a parse error and this error
message is
supposed to be translated into your encoding, but unfortunately not every
UTF8 character is necessarily be encoded as GB18030, which will cause an
infinite recursive elogs just like this:

1:elog(parse_error)        // contain unencodable characters
2:    elog(report_not_translatable)    // contain unencodable characters
again
3:        elog(report_report_not_translatable)
4:            elog(report_report_report_not_translatable)
5:                ...

and corrupt the elog stack.

To fix this, we just change errmsg() to errmsg_internal() to avoid
tranlation which could stop the recursion at step 2.

Regards,
Qingqing


---

Index: backend/utils/mb/conv.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/mb/conv.c,v
retrieving revision 1.53
diff -c -r1.53 conv.c
*** backend/utils/mb/conv.c     15 Jun 2005 00:15:08 -0000      1.53
--- backend/utils/mb/conv.c     4 Aug 2005 08:33:57 -0000
***************
*** 380,386 ****
                {
                        ereport(WARNING,

(errcode(ERRCODE_UNTRANSLATABLE_CHARACTER),
!                                 errmsg("ignoring unconvertible UTF8
character 0x%04x",
                                                 iutf)));
                        continue;
                }
--- 380,386 ----
                {
                        ereport(WARNING,

(errcode(ERRCODE_UNTRANSLATABLE_CHARACTER),
!                                 errmsg_internal("ignoring unconvertible
UTF8 character 0x%04x",
                                                 iutf)));
                        continue;
                }
***************
*** 449,455 ****
                {
                        ereport(WARNING,

(errcode(ERRCODE_UNTRANSLATABLE_CHARACTER),
!                                        errmsg("ignoring unconvertible %s
character 0x%04x",

(&pg_enc2name_tbl[encoding])->name, iiso)));
                        continue;
                }
--- 449,455 ----
                {
                        ereport(WARNING,

(errcode(ERRCODE_UNTRANSLATABLE_CHARACTER),
!                                        errmsg_internal("ignoring
unconvertible %s character 0x%04x",

(&pg_enc2name_tbl[encoding])->name, iiso)));
                        continue;
                }





pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: PL/pgSQL: EXCEPTION NOSAVEPOINT
Next
From: Tom Lane
Date:
Subject: Re: prevent encoding conversion recursive error