模板数据库“template1”具有排序规则版本,但无法确定实际的排序规则版本

bud*_*891 11 database postgresql collation postgresql-12 postgresql-15

我刚刚将 Postgres 从 12 升级到 15,但不断收到此错误: template database "template1" has a collation version, but no actual collation version could be determined

这是 Postgres 15 中的 template1 排序规则信息: 在此输入图像描述

有想法该怎么解决这个吗?如果需要更多信息,请告诉我。

谢谢!

更新:

以下是操作系统信息:
发行商 ID:Debian。
描述:Debian GNU/Linux 10(破坏者)。
发布:10。
代号:buster。

我有一个 Postgres docker 容器,所以我用它来升级:https ://github.com/tianon/docker-postgres-upgrade/tree/master/12-to-15

我没有更换机器或升级操作系统。以下是 PG 12 上的 template1 整理信息:

在此输入图像描述

更新2:

所以我做了一些挖掘,结果发现 en_US.utf8 排序规则在 Postgres 12 上的 pg_collat​​ion 表中不存在。但是在 Postgres 15 上,它确实存在于该表中,并且版本为 2.31:

在此输入图像描述

有没有什么办法解决这一问题?

Jac*_*bec 6

最简单的解决方案是更新 template1 数据库的排序规则版本。

登录 postgres:

sudo -u postgres psql
Run Code Online (Sandbox Code Playgroud)

查看数据库列表:

\l
Run Code Online (Sandbox Code Playgroud)

如果您看到您的 template1 数据库。升级整理版本:

ALTER DATABASE template1 REFRESH COLLATION VERSION;
Run Code Online (Sandbox Code Playgroud)

相当 postgres cli:

\q
Run Code Online (Sandbox Code Playgroud)

重新加载 postgres 服务(对于 Ubuntu Linux 等):

sudo service postgresql restart
Run Code Online (Sandbox Code Playgroud)

检查postgres服务状态:

sudo service postgresql status
Run Code Online (Sandbox Code Playgroud)

也许您需要更新 postgres 数据库的排序规则版本。使用与命令相同的步骤:

ALTER DATABASE postgres REFRESH COLLATION VERSION; 
Run Code Online (Sandbox Code Playgroud)


Har*_* P. 4

  1. 删除索引

  2. alter database template1 refresh collation version;

  3. 添加/重建索引