Server broken down in covering GB18030

Lists: pgsql-bugs
From: 杨邕 <yayooo(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org, laser(at)pgsqldb(dot)com, laser(at)zhengmai(dot)com(dot)cn
Subject: Server broken down in covering GB18030
Date: 2005-07-29 09:36:37
Message-ID: 752022ef05072902361a46d1f9@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Encoding in UTF-8
Bug:
C:\PostgreSQL>ver
Microsoft Windows [版本 5.2.3790]
C:\PostgreSQL>mkdir data
C:\PostgreSQL>bin\initdb -D data
C:\PostgreSQL>bin\postmaster -D data
C:\PostgreSQL\bin>psql -d template1
template1=# select version();
PostgreSQL 8.0.3 on i686-pc-mingw32, compiled by GCC gcc.exe (GCC)
3.4.2 (mingw-special)
template1=# create database test1 encoding 'unicode';
template1=# \l
数据库列表
名字 | 所有者 | 编码
-----------+--------+-----------
template0 | YaYo | SQL_ASCII
template1 | YaYo | SQL_ASCII
test1 | YaYo | UNICODE
template1=# \c test1
你现在已经联接到数据库 "test1".
test1=# \encoding
UNICODE
test1=# select;
错误: 语法错误 在 ";" 或附近的 在字符 7
第 1 行: select;
test1=# \encoding gb18030
test1=# \encoding
GB18030
test1=# select;
服务器意外地关闭了联接
这种现象通常意味着服务器在处理请求之前
或者正在处理请求的时候意外中止
与服务器的联接已丢失. 尝试重置: 失败.
!>
Server Log:
比致命错误还过分的错误: ERRORDATA_STACK_SIZE exceeded
语句: select;
警告: 忽略不能转换的 UTF-8 字符 0xc8d6
警告: 忽略不能转换的 UTF-8 字符 0xe60000
警告: 忽略不能转换的 UTF-8 字符 0xe60000
日志: 服务器进程 (PID 3616) 被信号 125 中断
日志: 中断任何其它已激活的服务器进程
致命错误: 数据库系统在恢复模式中
日志: 所有的服务器进程被中止; 重新初始化
日志: 数据库系统在 2005-07-29 17:08:08 中国标准时间 被中断
日志: checkpoint 记录位置在 0/ABCEC0
日志: redo record is at 0/ABCEC0; undo record is at 0/0; shutdown FALSE
日志: 下一个事物 ID: 558; 下一个 OID: 25422
日志: 数据库系统没有正确的关闭; 自动恢复
日志: 在 0/ABCF00 位置有零长度的记录
日志: 不需要 redo
日志: 数据库系统准备就绪

Debug:
C:\PostgreSQL>ren share\locale\zh_CN zh_CN.disable
C:\PostgreSQL>bin\postmaster -D data
C:\PostgreSQL\bin>psql -d template1
template1=# \l
List of databases
Name | Owner | Encoding
-----------+-------+-----------
template0 | YaYo | SQL_ASCII
template1 | YaYo | SQL_ASCII
test1 | YaYo | UNICODE
template1=# \c test1
You are now connected to database "test1".
test1=# \encoding
UNICODE
test1=# select;
ERROR: syntax error at or near ";" at character 7
LINE 1: select;
test1=# \encoding gb18030
test1=# \encoding
GB18030
test1=# select;
ERROR: syntax error at or near ";" at character 7
LINE 1: select;
test1=# \q


From: "Qingqing Zhou" <zhouqq(at)cs(dot)toronto(dot)edu>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Server broken down in covering GB18030
Date: 2005-08-03 09:09:06
Message-ID: dcq1nv$2h3r$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


My theory is "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 could just print a "Unsupport encoding" message which is
just a plain ascii character string and stop the recursion at step 3.

Regards,
Qingqing

"" <yayooo(at)gmail(dot)com> writes
> template1=# select version();
> PostgreSQL 8.0.3 on i686-pc-mingw32, compiled by GCC gcc.exe (GCC)
> 3.4.2 (mingw-special)
> template1=# create database test1 encoding 'unicode';
> test1=# \encoding
> UNICODE
> test1=# \encoding gb18030
> test1=# \encoding
> GB18030
> test1=# select;
...
> : ERRORDATA_STACK_SIZE exceeded


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Qingqing Zhou <zhouqq(at)cs(dot)toronto(dot)edu>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Server broken down in covering GB18030
Date: 2005-08-13 02:07:10
Message-ID: 200508130207.j7D27AE26736@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


Has this been fixed already?

---------------------------------------------------------------------------

Qingqing Zhou wrote:
>
> My theory is "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 could just print a "Unsupport encoding" message which is
> just a plain ascii character string and stop the recursion at step 3.
>
> Regards,
> Qingqing
>
> "" <yayooo(at)gmail(dot)com> writes
> > template1=# select version();
> > PostgreSQL 8.0.3 on i686-pc-mingw32, compiled by GCC gcc.exe (GCC)
> > 3.4.2 (mingw-special)
> > template1=# create database test1 encoding 'unicode';
> > test1=# \encoding
> > UNICODE
> > test1=# \encoding gb18030
> > test1=# \encoding
> > GB18030
> > test1=# select;
> ...
> > : ERRORDATA_STACK_SIZE exceeded
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Qingqing Zhou <zhouqq(at)cs(dot)toronto(dot)edu>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Server broken down in covering GB18030
Date: 2005-08-13 19:08:13
Message-ID: 20296.1123960093@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> Has this been fixed already?

No. My suggestion of using bind_textdomain_codeset() might fix it,
but I'm not sufficiently familiar with the NLS code to want to try to
install that myself.

regards, tom lane