问题描述
我有两个Postgres 9.1实例:一个是通过OS X上的Postgres.app安装的本地实例,另一个是在Heroku上的远程实例。我确保两台计算机上的 lc_collate
是 en_US.UTF-8
,但仍然看到两者之间的行为不同
I have two Postgres 9.1 instances: one local, installed via Postgres.app on OS X, and one remote, on Heroku. I've ensured that lc_collate
is en_US.UTF-8
on both machines but am still seeing different behavior between the two.
在我的本地实例上, SELECT'i'> N
返回 t
,而远程返回 f
。假设我已经在两个系统上都检查过 lc _ *
,那么什么解释了我看到的差异?
On my local instance, SELECT 'i' > 'N'
returns t
whereas remotely it returns f
. Given that I've already checked lc_*
on both systems, what explains the difference I'm seeing?
推荐答案
从Unicode的角度来看,大小写排序是一种自定义。
摘录自:
From the point of view of Unicode, the case ordering is a customization.Excerpt from http://www.unicode.org/reports/tr10:
Mac OS X的大小写顺序与所使用的OS不同由Heroku。在Mac OS X上:
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
产生:
在Ubuntu 12.04上完全相同的命令和相同的数据产生:
The exact same command and same data on Ubuntu 12.04 produces:
这与PostgreSQL无关,除了它使用操作系统进行校对,因此不幸的是,不同操作系统影响数据库之间存在这些差异。
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.
从版本10开始,PostgreSQL可能会使用 。这些归类可以在操作系统之间进行一致的排序。
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.
这篇关于不同机器(相同语言环境)上Postgres实例之间的排序差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!