Re: [PATCHES] unknownin/out patch (was PQescapeBytea is

From: Tatsuo Ishii <t-ishii(at)sra(dot)co(dot)jp>
To: mail(at)joeconway(dot)com
Cc: tgl(at)sss(dot)pgh(dot)pa(dot)us, pgsql-patches(at)postgresql(dot)org, lockhart(at)fourpalms(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] unknownin/out patch (was PQescapeBytea is
Date: 2002-04-15 07:50:23
Message-ID: 20020415165023R.t-ishii@sra.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

I'm about to commit your patches with a small fix.
--
Tatsuo Ishii

From: Joe Conway <mail(at)joeconway(dot)com>
Subject: Re: [PATCHES] unknownin/out patch (was [HACKERS] PQescapeBytea is
Date: Mon, 08 Apr 2002 22:57:47 -0700
Message-ID: <3CB282DB(dot)4050708(at)joeconway(dot)com>

> Joe Conway wrote:
> > Tatsuo Ishii wrote:
> > >>> Tatsuo Ishii wrote:
> > >>>
> > >>>>
> > >>>> Try a multibyte encoding database. For example,
> > >>>>
> > >>>> $ createdb -E EUC_JP test $ psql -c 'SELECT
> > >>>> SUBSTRING('1234567890' FROM 3)' test substring ----------- 3456
> > >>>>
> >
> > >>>> (1 row)
> > >>>>
> > >>>> Apparently this is wrong. -- Tatsuo Ishii
> > >>>
> > >>> This problem exists in CVS tip *without* the unknownin/out
> > >>> patch:
> > >>
> > >> Sure. That has been broken for a while.
> > >
> > >
> > > I guess this actually happened in 1.79 of varlena.c:
> > >
> > Yes, I was just looking at that also. It doesn't consider the case of n
> > = -1 for MB. See the lines:
> >
> > #ifdef MULTIBYTE
> > eml = pg_database_encoding_max_length ();
> >
> > if (eml > 1)
> > {
> > sm = 0;
> > sn = (m + n) * eml + 3;
> > }
> > #endif
> >
> > When n = -1 this does the wrong thing. And also a few lines later:
> >
> > #ifdef MULTIBYTE
> > len = pg_mbstrlen_with_len (VARDATA (string), sn - 3);
> >
> > I think both places need to test for n = -1. Do you agree?
> >
> >
> > Joe
> >
>
> The attached patch should fix the bug reported by Tatsuo.
>
> # psql -U postgres testjp
> Welcome to psql, the PostgreSQL interactive terminal.
>
> Type: \copyright for distribution terms
> \h for help with SQL commands
> \? for help on internal slash commands
> \g or terminate with semicolon to execute query
> \q to quit
>
> testjp=# SELECT SUBSTRING('1234567890' FROM 3);
> substring
> ------------
> 34567890
> (1 row)
>
> Joe

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Kings-Lynne 2002-04-15 07:53:51 Re: Importing Large Amounts of Data
Previous Message Curt Sampson 2002-04-15 07:41:19 Re: Importing Large Amounts of Data

Browse pgsql-patches by date

  From Date Subject
Next Message Vince Vielhaber 2002-04-15 09:42:10 Re: [PATCHES] ANSI Compliant Inserts
Previous Message Michael Loftis 2002-04-15 07:35:32 Re: ANSI Compliant Inserts