Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is a difference in string comparison between alpine and normal versions #851

Closed
ryan5500 opened this issue May 28, 2021 · 3 comments
Closed

Comments

@ryan5500
Copy link

When I tried the following query, there was a difference in results between the alpine version and the normal version.

postgres> select 'a' < 'A'
# true in the normal version, false in the alpine version

On the other hand, the comparison with = behaved case-sensitive.

postgres> select 'a' = 'A'
# false for both normal and alpine versions

postgres> select 'A' = 'A'
# true for both normal and alpine versions

I have confirmed that the same behavior is observed in the normal and alpine versions of ver 10, 11, 12, and 13.
The code for verification is placed here.
https://github.com/ryan5500/postgresql-docker-str-comparison-sample

Regarding the select 'a' < 'A' query, is this what you intended?

@wglambert
Copy link

Seems like an issue that upstream might be interested in, we only package Postgres into the container and maintain the respective entrypoint file so I don't think there's anything actionable we could do at the Dockerfile level to alleviate this

https://github.com/docker-library/docs/tree/master/postgres#postgresversion-alpine

The main caveat to note is that it does use musl libc instead of glibc and friends, so software will often run into issues depending on the depth of their libc requirements/assumptions.

@ryan5500
Copy link
Author

Thank you for your response.
I understood the situation.
I'll check postgres issue tracker.

@ryan5500
Copy link
Author

ryan5500 commented May 31, 2021

I found the problem is related to this issue.
#327

select 'a' < 'A' query returns false for alpine docker, because postgres compiled using musl library ignores LANG=en_US.utf8 in Dockerfile, and sets default collation as "C".

This is duplicated issue, so I close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants