Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Postgres in alpine has collation warning if database was created in another OS.

Đang mở
#1,288 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
docker, postgres
Lĩnh vực
databases, devops

Hướng nghiên cứu

Tái hiện cảnh báo bằng các lệnh Docker được cung cấp postgres:15.8-bookworm và postgres:15.8-alpine3.20. Đọc CheckMyDatabase trong src/backend/utils/init/postinit.c và truy vết get_collation_actual_version, sau đó xác định tại sao actual_versionstr là NULL và liệu hành vi cross-OS có được mong đợi hay không.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Postgres shows warning WARNING: database "postgres" has no actual collation version, but a version was recorded if database was created in another OS.

Steps for reproduce:

  1. Execute postgres in debian image: docker run --rm -e POSTGRES_PASSWORD=password -e POSTGRES_DB=app -v $(pwd)/data:/var/lib/postgresql/data postgres:15.8-bookworm
  2. Stop this
  3. Execute postgres in alpine image: docker run --rm --name postgres -v $(pwd)/data:/var/lib/postgresql/data postgres:15.8-alpine3.20
  4. Run psql:
$ docker exec -ti --user postgres postgres psql
WARNING:  database "postgres" has no actual collation version, but a version was recorded
psql (15.8)
Type "help" for help.

postgres=# \c app
WARNING:  database "app" has no actual collation version, but a version was recorded
You are now connected to database "app" as user "postgres".
app=# 

Research:

I found that a warning occurs in the CheckMyDatabase function when comparing the collate version in the database and the current one in this row.

...
	if (!isnull)
	{
		char	   *actual_versionstr;
		char	   *collversionstr;

		collversionstr = TextDatumGetCString(datum);

		actual_versionstr = get_collation_actual_version(dbform->datlocprovider, dbform->datlocprovider == COLLPROVIDER_ICU ? iculocale : collate);
		if (!actual_versionstr)
			/* should not happen */
			elog(WARNING,
				 "database \"%s\" has no actual collation version, but a version was recorded",
				 name);
		else if (strcmp(actual_versionstr, collversionstr) != 0)
...

After calling get_collation_actual_version, the actual_version_str variable is NULL, because the get_collation_actual_version function after the preprocessor looks like:

char *
get_collation_actual_version(char collprovider, const char *collcollate)
{
	char	   *collversion = NULL;

		if (collprovider == COLLPROVIDER_LIBC &&
			pg_strcasecmp("C", collcollate) != 0 &&
			pg_strncasecmp("C.", collcollate, 2) != 0 &&
			pg_strcasecmp("POSIX", collcollate) != 0)
	{
	}

	return collversion;
}

And it always returns NULL

Ngôn ngữ chính
Shell
Star
2.5k
Fork
1.2k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của docker-library/postgres

Tất cả issue của docker-library/postgres

Issue tương tự

Thêm issue về Shell/Bash

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.