Thread: small bug in to_char and TM prefix, in RC
Hello, I tested TM formating with czech names. Upper case chars in name are not correct. Function upper works perfectly. Sample: postgres=# select to_char(date '2006-02-03', 'TMday'); to_char --------- p�tek (1 ř�dka) correct but postgres=# select to_char(date '2006-02-03', 'TMDAY'); to_char --------- P�TEK (1 ř�dka) correct is P�TEK without spec. chars wrong: PaTEK, have be: PATEK Regards Pavel Stehule _________________________________________________________________ Chcete sdilet sve obrazky a hudbu s prateli? http://messenger.msn.cz/
And this failure is with your translation patch applied? --------------------------------------------------------------------------- Pavel Stehule wrote: > Hello, > > I tested TM formating with czech names. Upper case chars in name are not > correct. Function upper works perfectly. > > Sample: > > postgres=# select to_char(date '2006-02-03', 'TMday'); > to_char > --------- > p�tek > (1 ř�dka) > > correct > > but > > postgres=# select to_char(date '2006-02-03', 'TMDAY'); > to_char > --------- > P�TEK > (1 ř�dka) > > correct is P�TEK > > without spec. chars > wrong: PaTEK, have be: PATEK > > Regards > Pavel Stehule > > _________________________________________________________________ > Chcete sdilet sve obrazky a hudbu s prateli? http://messenger.msn.cz/ > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: In versions below 8.0, the planner will ignore your desire to > choose an index scan if your joining column's datatypes do not > match -- Bruce Momjian bruce@momjian.us EnterpriseDB http://www.enterprisedb.com + If your life is a hard drive, Christ can be your backup. +
Hello, after apply my patch this bug is only visible (for czech env). Propably in others languages isn't used diacritic's chars in mont's and days's names. str_toupper is too simply and don't support UTF8, which isn't for english problem. I prepare patch. Regards Pavel Stehule > >And this failure is with your translation patch applied? > >--------------------------------------------------------------------------- > >Pavel Stehule wrote: > > Hello, > > > > I tested TM formating with czech names. Upper case chars in name are not > > correct. Function upper works perfectly. > > > > Sample: > > > > postgres=# select to_char(date '2006-02-03', 'TMday'); > > to_char > > --------- > > p�tek > > (1 ř�dka) > > > > correct > > > > but > > > > postgres=# select to_char(date '2006-02-03', 'TMDAY'); > > to_char > > --------- > > P�TEK > > (1 ř�dka) > > > > correct is P�TEK > > > > without spec. chars > > wrong: PaTEK, have be: PATEK > > > > Regards > > Pavel Stehule > > > > _________________________________________________________________ > > Chcete sdilet sve obrazky a hudbu s prateli? http://messenger.msn.cz/ > > > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 9: In versions below 8.0, the planner will ignore your desire to > > choose an index scan if your joining column's datatypes do not > > match > >-- > Bruce Momjian bruce@momjian.us > EnterpriseDB http://www.enterprisedb.com > > + If your life is a hard drive, Christ can be your backup. + _________________________________________________________________ Emotikony a pozadi programu MSN Messenger ozivi vasi konverzaci. http://messenger.msn.cz/
On Wed, Nov 29, 2006 at 09:06:07PM +0100, Pavel Stehule wrote: > Hello, > > after apply my patch this bug is only visible (for czech env). Propably in > others languages isn't used diacritic's chars in mont's and days's names. > str_toupper is too simply and don't support UTF8, which isn't for english > problem. > > I prepare patch. What platform is this? Not all platforms are created equal when it comes to handling of toupper/tolower on unicode charaters. Have a nice day, -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > From each according to his ability. To each according to his ability to litigate.
> >On Wed, Nov 29, 2006 at 09:06:07PM +0100, Pavel Stehule wrote: > > Hello, > > > > after apply my patch this bug is only visible (for czech env). Propably >in > > others languages isn't used diacritic's chars in mont's and days's >names. > > str_toupper is too simply and don't support UTF8, which isn't for >english > > problem. > > > > I prepare patch. > >What platform is this? Not all platforms are created equal when it >comes to handling of toupper/tolower on unicode charaters. > postgres=# select version(); version ----------------------------------------------------------------------------------------------------- PostgreSQL 8.2rc1 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.1.1 20061011 (Red Hat 4.1.1-30) to_char use pg_toupper from pgstrcasecmp.c * * Fold a character to upper case. * * Unlike some versions of toupper(), this is safe to apply to characters * that aren't lower case letters. Note however that the whole thing is * a bit bogus for multibyte character sets. */ Pavel _________________________________________________________________ Chcete sdilet sve obrazky a hudbu s prateli? http://messenger.msn.cz/
Martijn van Oosterhout <kleptog@svana.org> writes: > What platform is this? Not all platforms are created equal when it > comes to handling of toupper/tolower on unicode charaters. It's pretty much guaranteed not to work on multibyte characters, regardless of platform :-(. This did not matter for non-localized month/day names, but it does matter now. In the context of the existing code, the simplest solution would be to provide separate translations of "SUNDAY", "Sunday", "sunday" etc but this will not work for the planned strftime() change. regards, tom lane
> >It's pretty much guaranteed not to work on multibyte characters, >regardless of platform :-(. This did not matter for non-localized >month/day names, but it does matter now. > >In the context of the existing code, the simplest solution would be >to provide separate translations of "SUNDAY", "Sunday", "sunday" etc >but this will not work for the planned strftime() change. > and what use modified pg_tolower only for TM fields? Like: if (S_TM(suf)) { strcpy(inout, localize_month(tm->tm_mon - 1)); str_towupper(inout); } else { strcpy(inout, months[tm->tm_mon - 1]); str_toupper(inout); } regards Pavel Stehule _________________________________________________________________ Chcete sdilet sve obrazky a hudbu s prateli? http://messenger.msn.cz/
"Pavel Stehule" <pavel.stehule@hotmail.com> writes: > str_towupper(inout); Since this wouldn't be a length-preserving change, it seems a bit scary to invent a function defined as above. (The whole question of buffer overflow in to_char needs to be looked at anyway, probably.) regards, tom lane