Ordering differences between Postgres instances on different machines (same locale)

烈酒焚心 提交于 2019-12-05 17:31:30

From the point of view of Unicode, the case ordering is a customization. Excerpt from http://www.unicode.org/reports/tr10:

Case Ordering. Some dictionaries and authors collate uppercase before lowercase while others use the reverse, so that preference needs to be customizable. Sometimes the case ordering is mandated by the government, as in Denmark. Often it is simply a customization or user preference.

Mac OS X simply has a different case ordering than the OS used by Heroku. On Mac OS X:

$ LC_CTYPE=en_US.UTF-8 sort << EOF
> i
> N
> EOF

produces:

N
i

The exact same command and same data on Ubuntu 12.04 produces:

i
N

This has none to do with PostgreSQL, except for the fact that it uses the OS for collation, so these unfortunate discrepancies between different OS impact databases.

PostgreSQL 10 and ICU

Starting with version 10, PostgreSQL may use collations provided by the ICU library, for servers compiled with ICU. These collations can sort consistently across operating systems.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!