Re: [HACKERS] Patch (was: tough locale bug)

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: [HACKERS] Patch (was: tough locale bug)
Дата
Msg-id 199902021920.OAA07046@candle.pha.pa.us
обсуждение исходный текст
Ответ на Patch (was: tough locale bug)  (Goran Thyni <goran@kirra.net>)
Список pgsql-hackers
Do you want this applied?


[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Goran Thyni wrote:
> > 3. text_lt('G','G\0xFF') this is not correct!
> > 
> > Case 3 work not work with strcoll(), in varstr_cmp().
> > If I change it to strcoll() to strncmp() it works as expected,
> > but it probably breaks sorting etc big time.
> 
> Here is a hack which solves the problem without breaking sorting AFAIK.
> I have read a lot of code, but has not found any cleaner way to fix
> this.
> A cleaner solution would be to find the highest char in locale charset
> but I found no portable way to do that, any pointers appriciated.
> 
> It is not a beauty but it works. 
> Please apply to -current since it fixes the bug, 
> unless someone has a better suggestion.
> 
>     best regards,
> -- 
> -----------------
> G_ran Thyni
> This is Penguin Country. On a quiet night you can hear Windows NT
> reboot!

> diff -cr cvs/pgsql/src/backend/utils/adt/varlena.c cvswork/pgsql/src/backend/utils/adt/varlena.c
> *** cvs/pgsql/src/backend/utils/adt/varlena.c    Mon Dec 14 07:01:37 1998
> --- cvswork/pgsql/src/backend/utils/adt/varlena.c    Sun Jan 31 16:32:52 1999
> ***************
> *** 496,528 ****
>   varstr_cmp(char *arg1, int len1, char *arg2, int len2)
>   {
>       int            result;
> !     char       *a1p,
> !                *a2p;
> ! 
>   #ifdef USE_LOCALE
> !     a1p = (unsigned char *) palloc(len1 + 1);
> !     a2p = (unsigned char *) palloc(len2 + 1);
> ! 
> !     memcpy(a1p, arg1, len1);
> !     *(a1p + len1) = '\0';
> !     memcpy(a2p, arg2, len2);
> !     *(a2p + len2) = '\0';
> ! 
> !     result = strcoll(a1p, a2p);
> ! 
> !     pfree(a1p);
> !     pfree(a2p);
> ! 
> ! #else
> ! 
> !     a1p = arg1;
> !     a2p = arg2;
> ! 
> !     result = strncmp(a1p, a2p, Min(len1, len2));
> !     if ((result == 0) && (len1 != len2))
> !         result = (len1 < len2) ? -1 : 1;
>   #endif
> ! 
>       return result;
>   }    /* varstr_cmp() */
>   
> --- 496,524 ----
>   varstr_cmp(char *arg1, int len1, char *arg2, int len2)
>   {
>       int            result;
> !     char       *a1p, *a2p;
>   #ifdef USE_LOCALE
> !     if ((int)arg2[len2 - 1] != -1)
> !       {
> !         a1p = (unsigned char *) palloc(len1 + 1);
> !         a2p = (unsigned char *) palloc(len2 + 1);
> !         memcpy(a1p, arg1, len1);
> !         *(a1p + len1) = '\0';
> !         memcpy(a2p, arg2, len2);
> !         *(a2p + len2) = '\0';
> !         result = strcoll(a1p, a2p);
> !         pfree(a1p);
> !         pfree(a2p);
> !       }
> !     else
>   #endif
> !       {
> !         a1p = arg1;
> !         a2p = arg2;
> !         result = strncmp(a1p, a2p, Min(len1, len2));
> !         if ((result == 0) && (len1 != len2))
> !         result = (len1 < len2) ? -1 : 1;
> !       }
>       return result;
>   }    /* varstr_cmp() */
>   


--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] Something wacko about EXPLAIN cost stats
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] Adding some const keywords to external interfaces