Skip site navigation (1) Skip section navigation (2)

Re: [BUGS] BUG #2120: Crash when doing UTF8<->ISO_8859_8 encoding

From: Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp>
To: pgman(at)candle(dot)pha(dot)pa(dot)us
Cc: tgl(at)sss(dot)pgh(dot)pa(dot)us, ishii(at)sraoss(dot)co(dot)jp, sagi(at)adamnet(dot)co(dot)il,pgsql-patches(at)postgresql(dot)org
Subject: Re: [BUGS] BUG #2120: Crash when doing UTF8<->ISO_8859_8 encoding
Date: 2005-12-23 01:42:07
Message-ID: 20051223.104207.129789350.t-ishii@sraoss.co.jp (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-patches
> Tom Lane wrote:
> > Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp> writes:
> > >> It looks like somebody rearranged the pg_enc enum without bothering to
> > >> fix the tables that are affected by this.
> > 
> > > I will look into this.
> > 
> > Thank you.  It might be worth adding a comment to pg_wchar.h listing all
> > the places that need to be fixed when enum pg_enc changes.
> > 
> 
> I have developed the following patch against CVS.  Tatsuo, you can use
> it as a starting point.  It adds a comment to encnames.c and reorders
> utf8_and_iso8859.c to match the existing order.  I also added the
> missing entries at the bottom.  I checked for pg_conv_map in the source
> code and only utf8_and_iso8859.c has that structure, so I assume it is
> the only one that also depends on the encnames.c ordering.

I think the current implementaion in utf8_and_iso8859.c is fast but
too fragile against rearranging of encoding id. I modify those functions
in utf8_and_iso8859.c to do a linear search with encoding id. With
this change developers feel free to rearrange encoding id, and this
kind of problems will be gone forever. The only penalty is the time of
searching 13 entries in the encoding map. We can do a quick sort but
it will need sorted entry by encoding id and may cause similar problem
in the future. So I'm not sure it's worth doing the quick sort.

Propsed patch attached.

> Looking at 8.0.X, it has the matching order, so we are OK there, but it
> doesn't have the trailing entries.  Tatsuo, are those needed?

I think it's OK, since the last missing entry will never be visited.
--
Tatsuo Ishii
SRA OSS, Inc. Japan

In response to

Responses

pgsql-bugs by date

Next:From: Bruce MomjianDate: 2005-12-23 01:53:09
Subject: Re: [BUGS] BUG #2120: Crash when doing UTF8<->ISO_8859_8 encoding conversion
Previous:From: Bruce MomjianDate: 2005-12-22 23:09:49
Subject: Re: [PATCHES] [BUGS] Solaris cc compiler on amd: PostgreSQL does not

pgsql-patches by date

Next:From: Bruce MomjianDate: 2005-12-23 01:53:09
Subject: Re: [BUGS] BUG #2120: Crash when doing UTF8<->ISO_8859_8 encoding conversion
Previous:From: Bruce MomjianDate: 2005-12-23 00:38:28
Subject: Re: Disparity in search_path SHOW and SET

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group