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
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-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

Attachment Content-Type Size
unknown_filename text/plain 3.0 KB

In response to

Responses

Browse pgsql-bugs by date

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

Browse pgsql-patches by date

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