2011-06-28 44 views
2

我創建使用fr_CA.UTF-8我的數據庫是這樣的:問題PostgreSQL中訂購重音字符8.4

createdb --encoding=utf-8 --locale=fr_CA.UTF-8 --template=template0 someapp_development 

然後我加載樣本數據,其中包含重音字符,其中包括「練習曲德我安德烈·卡倫」和「Zellers inc。」。在法國,E應該排序/ Z之前整理,因此我期待下面的語句:

SELECT fullname FROM addressees ORDER BY LOWER(fullname) 

到Z之前返回E,但可悲的是,這種情況並非如此:

# select fullname from addressees where party_id in (36, 618, 1264, 2481, 4473) order by lower(fullname); 
       fullname     
------------------------------------------- 
VRV Express inc. [4473] 
Vêtements S.P. Apparels inc. (Les) [2481] 
Zellers inc. (Galeries Orford) [1264] 
Étude de Me André Caron [618] 
Étude de Me Richard Drapeau [36] 

公告另外VRV在Vêtements之前。我一定在某個地方誤解了某些東西。一些更多的信息:

$ psql someapp_development 
psql (8.4.4, server 8.4.3) 

$ psql --list 
              List of databases 
      Name   | Owner | Encoding | Collation | Ctype | Access privileges 
---------------------------+-----------+----------+-------------+-------------+----------------------- 
meetphil_development  | francois | UTF8  | fr_CA.UTF-8 | fr_CA.UTF-8 | 
+1

我已閱讀HTTP:/ /stackoverflow.com/questions/1659158/converting-accented-characters-in-postgresql。這基本上是同一個問題嗎? –

+0

是的,但是您可能想要在測試服務器上使用Postgres 9.0或9.1測試版進行測試,因爲從8.4開始,很多工作都進入了排序規則。事實上,我是99%,這將在9.1上工作,因爲他們在該版本中爲這個主題添加了整頁文檔。 –

+0

我目前無法獲得9.1,但9.0.4無法解決問題。 –

回答

2

一些測試(8.4.7 Postgres的科學的Linux 6.0)後,我的結論是這是最有可能在系統中fr_CA語言環境中的錯誤:

-bash-4.1$ psql 
psql (8.4.7) 
Saisissez « help » pour l'aide. 

postgres=# show lc_collate ; 
lc_collate 
------------ 
fr_CA.utf8 
(1 ligne) 

postgres=# create table addressees (party_id serial primary key, fullname text); 
NOTICE: CREATE TABLE créera des séquences implicites « addressees_party_id_seq » pour la colonne serial « addressees.party_id » 
NOTICE: CREATE TABLE/PRIMARY KEY créera un index implicite « addressees_pkey » pour la table « addressees » 
CREATE TABLE 
postgres=# insert into addressees (fullname) values ('VRV Express inc. [4473]'),('Vêtements S.P. Apparels inc. (Les) [2481]'),('Zellers inc. (Galeries Orford) [1264]'), ('Étude de Me André Caron [618]'),('Étude de Me Richard Drapeau [36]'); 
INSERT 0 5 
postgres=# select * from addressees order by lower(fullname); 
party_id |     fullname 
----------+------------------------------------------- 
     4 | Étude de Me André Caron [618] 
     5 | Étude de Me Richard Drapeau [36] 
     2 | Vêtements S.P. Apparels inc. (Les) [2481] 
     1 | VRV Express inc. [4473] 
     3 | Zellers inc. (Galeries Orford) [1264] 
(5 lignes) 

postgres=# 
+0

我在Mac OS X上。我將在Linux上運行一些測試,看看它是否解決了這個問題。 –

+0

我在Ubuntu 11.04 Natty上引導了一個PostgreSQL 8.4的EC2實例,事情和我預期的一樣,即使我使用en_US.UTF-8歸類創建了數據庫。我使用fr_CA.UTF-8語言環境重新測試了我的測試,結果仍然很好。感謝指針! –