Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-11-2008, 03:13 AM
John Hansen
 
Posts: n/a
Default Re: Patch for collation using ICU

Ok,.. tested on debian sarge with ICU 3.2
UNICODE Database, C locale.

upper() and lower() returns an empty string for any input, including
7bit ascii, regardless of client_encoding, so something is obviously
broken.

Have you tested this patch on a UNICODE DB with locale C/POSIX ?

.... John

> -----Original Message-----
> From: John Hansen
> Sent: Friday, March 25, 2005 10:27 PM
> To: 'Palle Girgensohn'; 'pgsql-hackers@postgresql.org'
> Subject: RE: [HACKERS] Patch for collation using ICU
>
> > --On fredag, mars 25, 2005 16.34.41 +1100 John Hansen
> > <john@geeknet.com.au>
> > wrote:
> >
> > > Useful if it's going to support earlier releases of ICU....
> > >
> > > Not all os's come with ICU3.2, debian for example,

> > currently has 2.1
> > > in testing, and 2.6 in unstable.

> >
> > Oh, OK. FreeBSD has only the 3.2 as port. I can check the older
> > version, I doubt it would too much difference. Some

> autoconf sorcery
> > needed, perhaps.

>
> Naww, it's no biggie, we'll just need to include ICU with pg I think.
> I tried that, there are several functions from ICU that you
> use, that are not in ICU2.1
>
> Dono about 2.6.
>
> However, ICU3.2 compiles on debian with a small change to the
> debian/rules file.
> debian/tmp/etc is missing, so add mkdir debian/tmp/etc
>
> ... John
>
> >
> > /Palle
> >
> > >
> > > ... John
> > >
> > >> -----Original Message-----
> > >> From: pgsql-hackers-owner@postgresql.org
> > >> [mailtogsql-hackers-owner@postgresql.org] On Behalf Of Palle
> > >> Girgensohn
> > >> Sent: Friday, March 25, 2005 10:40 AM
> > >> To: pgsql-hackers@postgresql.org
> > >> Subject: [HACKERS] Patch for collation using ICU
> > >>
> > >> Hi!
> > >>
> > >> I've put together a patch for using IBM's ICU package for

> > collation.
> > >>
> > >> If your OS does not have full support for collation ur
> > >> uppercase/lowercase in multibyte locales, this might be

> useful. If
> > >> you are using a multibyte character encoding in your

> database and
> > >> want collation, i.e. order by, and also lower(), upper() and
> > >> initcap() to work properly, this patch will do just that.
> > >>
> > >> This patch is needed for FreeBSD, since this OS has no

> support for
> > >> collation of for example unicode locales (that is,

> wcscoll(3) does
> > >> not do what you expect if you set LC_ALL=sv_SE.UTF-8, for

> > example).
> > >> AFAIK the patch is *not* necessary for Linux, although IBM

> > claims ICU
> > >> collation to be about twice as fast as glibc for simple western
> > >> locales.
> > >>
> > >> It adds a configure switch, `--with-icu', which will set

> > up the code
> > >> to use ICU instead of wchar_t and wcscoll.
> > >>
> > >> This has been tested only on FreeBSD-4.11 &

> > FreeBSD-5-stable, where
> > >> it seems to run well. I've not had the time to do any

> comparative
> > >> performance tests yet, but it seems it is at least not

> slower than
> > >> using LATIN1 with
> > >> sv_SE.ISO8859-1 locale, perhaps even faster.
> > >>
> > >> I'd be delighted if some more experienced postgresql

> hackers would
> > >> review this stuff. The patch is pretty compact, so it's

> > fast reading
> > >> I'm planning to add this patch as an option (tagged
> > >> "experimental") to FreeBSD's postgresql port. Any ideas

> > about whether
> > >> this is a good idea or not?
> > >>
> > >> Any thoughts or ideas are welcome!
> > >>
> > >> Cheers,
> > >> Palle
> > >>
> > >> Patch at:
> > >> <http://people.freebsd.org/~girgen/po...u/pg-801-icu-2
> > > 005-03-14.diff>
> > >>
> > >> ICU at sourceforge: <http://icu.sf.net/>
> > >>
> > >>
> > >> ---------------------------(end of
> > >> broadcast)---------------------------
> > >> TIP 7: don't forget to increase your free space map settings
> > >>
> > >>

> >
> >
> >
> >
> >
> >


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-11-2008, 03:13 AM
Palle Girgensohn
 
Posts: n/a
Default Re: Patch for collation using ICU


--On fredag, mars 25, 2005 23.39.33 +1100 John Hansen <john@geeknet.com.au>
wrote:

> Ok,.. tested on debian sarge with ICU 3.2
> UNICODE Database, C locale.
>
> upper() and lower() returns an empty string for any input, including
> 7bit ascii, regardless of client_encoding, so something is obviously
> broken.
>
> Have you tested this patch on a UNICODE DB with locale C/POSIX ?


No, honestly not. Mostly tested it with my needs, sv_SE.UTF-8 and UNICODE,
and also de_DE.UTF-8.

How will PostgreSQL react to this combo? A database cluster initdb:ed with
locale=C/POSIX, and then a database in UNICODE (really utf-8)
representation... hmm... I think I might have made a false assumption that
the locale string would contain the character encoding. I do something like
encoding = strchr(locale, '.') + 1... That code will be confused by a 'C'
locale, indeed. I'll check it out!

/Palle



>
> ... John
>
>> -----Original Message-----
>> From: John Hansen
>> Sent: Friday, March 25, 2005 10:27 PM
>> To: 'Palle Girgensohn'; 'pgsql-hackers@postgresql.org'
>> Subject: RE: [HACKERS] Patch for collation using ICU
>>
>> > --On fredag, mars 25, 2005 16.34.41 +1100 John Hansen
>> > <john@geeknet.com.au>
>> > wrote:
>> >
>> > > Useful if it's going to support earlier releases of ICU....
>> > >
>> > > Not all os's come with ICU3.2, debian for example,
>> > currently has 2.1
>> > > in testing, and 2.6 in unstable.
>> >
>> > Oh, OK. FreeBSD has only the 3.2 as port. I can check the older
>> > version, I doubt it would too much difference. Some

>> autoconf sorcery
>> > needed, perhaps.

>>
>> Naww, it's no biggie, we'll just need to include ICU with pg I think.
>> I tried that, there are several functions from ICU that you
>> use, that are not in ICU2.1
>>
>> Dono about 2.6.
>>
>> However, ICU3.2 compiles on debian with a small change to the
>> debian/rules file.
>> debian/tmp/etc is missing, so add mkdir debian/tmp/etc
>>
>> ... John
>>
>> >
>> > /Palle
>> >
>> > >
>> > > ... John
>> > >
>> > >> -----Original Message-----
>> > >> From: pgsql-hackers-owner@postgresql.org
>> > >> [mailtogsql-hackers-owner@postgresql.org] On Behalf Of Palle
>> > >> Girgensohn
>> > >> Sent: Friday, March 25, 2005 10:40 AM
>> > >> To: pgsql-hackers@postgresql.org
>> > >> Subject: [HACKERS] Patch for collation using ICU
>> > >>
>> > >> Hi!
>> > >>
>> > >> I've put together a patch for using IBM's ICU package for
>> > collation.
>> > >>
>> > >> If your OS does not have full support for collation ur
>> > >> uppercase/lowercase in multibyte locales, this might be

>> useful. If
>> > >> you are using a multibyte character encoding in your

>> database and
>> > >> want collation, i.e. order by, and also lower(), upper() and
>> > >> initcap() to work properly, this patch will do just that.
>> > >>
>> > >> This patch is needed for FreeBSD, since this OS has no

>> support for
>> > >> collation of for example unicode locales (that is,

>> wcscoll(3) does
>> > >> not do what you expect if you set LC_ALL=sv_SE.UTF-8, for
>> > example).
>> > >> AFAIK the patch is *not* necessary for Linux, although IBM
>> > claims ICU
>> > >> collation to be about twice as fast as glibc for simple western
>> > >> locales.
>> > >>
>> > >> It adds a configure switch, `--with-icu', which will set
>> > up the code
>> > >> to use ICU instead of wchar_t and wcscoll.
>> > >>
>> > >> This has been tested only on FreeBSD-4.11 &
>> > FreeBSD-5-stable, where
>> > >> it seems to run well. I've not had the time to do any

>> comparative
>> > >> performance tests yet, but it seems it is at least not

>> slower than
>> > >> using LATIN1 with
>> > >> sv_SE.ISO8859-1 locale, perhaps even faster.
>> > >>
>> > >> I'd be delighted if some more experienced postgresql

>> hackers would
>> > >> review this stuff. The patch is pretty compact, so it's
>> > fast reading
>> > >> I'm planning to add this patch as an option (tagged
>> > >> "experimental") to FreeBSD's postgresql port. Any ideas
>> > about whether
>> > >> this is a good idea or not?
>> > >>
>> > >> Any thoughts or ideas are welcome!
>> > >>
>> > >> Cheers,
>> > >> Palle
>> > >>
>> > >> Patch at:
>> > >> <http://people.freebsd.org/~girgen/po...u/pg-801-icu-2
>> > > 005-03-14.diff>
>> > >>
>> > >> ICU at sourceforge: <http://icu.sf.net/>
>> > >>
>> > >>
>> > >> ---------------------------(end of
>> > >> broadcast)---------------------------
>> > >> TIP 7: don't forget to increase your free space map settings
>> > >>
>> > >>
>> >
>> >
>> >
>> >
>> >
>> >






---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-11-2008, 03:13 AM
Tom Lane
 
Posts: n/a
Default Re: Patch for collation using ICU

Palle Girgensohn <girgen@pingpong.net> writes:
> hmm... I think I might have made a false assumption that
> the locale string would contain the character encoding.


You certainly cannot assume that. Would that it were so easy to find
out the character set for a locale :-(.

There's some code in initdb that you might emulate, though I can't say
that I trust it a whole lot.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-11-2008, 03:13 AM
Andrew Dunstan
 
Posts: n/a
Default Re: Patch for collation using ICU



Tom Lane wrote:

>Palle Girgensohn <girgen@pingpong.net> writes:
>
>
>>hmm... I think I might have made a false assumption that
>>the locale string would contain the character encoding.
>>
>>

>
>You certainly cannot assume that. Would that it were so easy to find
>out the character set for a locale :-(.
>
>There's some code in initdb that you might emulate, though I can't say
>that I trust it a whole lot.
>
>
>
>


Me either. On FC3 I saw this the other day, haven't had time to dig into
what's going on:

[andrew inst]$ echo $LANG
en_US.UTF-8
[andrew inst]$ bin/initdb floobl
The files belonging to this database system will be owned by user "andrew".
This user must also own the server process.

The database cluster will be initialized with locale en_US.UTF-8.
initdb: could not find suitable encoding for locale "en_US.UTF-8"
Rerun initdb with the -E option.
Try "initdb --help" for more information.



cheers

andrew

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-11-2008, 03:13 AM
Palle Girgensohn
 
Posts: n/a
Default Re: Patch for collation using ICU


--On fredag, mars 25, 2005 09.53.38 -0500 Tom Lane <tgl@sss.pgh.pa.us>
wrote:

> Palle Girgensohn <girgen@pingpong.net> writes:
>> hmm... I think I might have made a false assumption that
>> the locale string would contain the character encoding.

>
> You certainly cannot assume that. Would that it were so easy to find
> out the character set for a locale :-(.
>
> There's some code in initdb that you might emulate, though I can't say
> that I trust it a whole lot.


Best thing would of course be to check the encoding of the database. I
realized I've made a bad assumption that the initdb locale has anything to
do with the character encoding of the database - it doesn't. There must be
some already existsing trusted way to get the character encoding of a
database?

/Palle


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-11-2008, 03:15 AM
Peter Eisentraut
 
Posts: n/a
Default Re: Patch for collation using ICU

Andrew Dunstan wrote:
> The database cluster will be initialized with locale en_US.UTF-8.
> initdb: could not find suitable encoding for locale "en_US.UTF-8"


What does

$ LC_ALL=en_US.UTF-8 locale charmap

show?

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-11-2008, 03:16 AM
Andrew Dunstan
 
Posts: n/a
Default Re: Patch for collation using ICU



Peter Eisentraut wrote:

>Andrew Dunstan wrote:
>
>
>>The database cluster will be initialized with locale en_US.UTF-8.
>>initdb: could not find suitable encoding for locale "en_US.UTF-8"
>>
>>

>
>What does
>
>$ LC_ALL=en_US.UTF-8 locale charmap
>
>show?
>
>
>


[andrew pgsql]$ LC_ALL=en_US.UTF-8 locale charmap
UTF-8
[andrew pgsql]$

cheers

andrew

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-11-2008, 03:16 AM
Peter Eisentraut
 
Posts: n/a
Default Re: Patch for collation using ICU

Andrew Dunstan wrote:
> [andrew pgsql]$ LC_ALL=en_US.UTF-8 locale charmap
> UTF-8


That seems normal. Time to get out the debugger, I suppose.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:15 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652