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

Collation is wrong in alpine version #327

Closed
etienned opened this issue Aug 16, 2017 · 9 comments · Fixed by docker-library/docs#1778
Closed

Collation is wrong in alpine version #327

etienned opened this issue Aug 16, 2017 · 9 comments · Fixed by docker-library/docs#1778
Labels

Comments

@etienned
Copy link

etienned commented Aug 16, 2017

If you run this test:

CREATE TEMPORARY TABLE table1 (column1 TEXT); 

INSERT INTO table1 VALUES
('Barn'),
('beef'),
('bémol'),
('Bœuf'),
('boulette'),
('Bubble');

SELECT * FROM table1 ORDER BY column1 COLLATE "en_US"; --Gives the expected order
SELECT * FROM table1 ORDER BY column1 COLLATE "C"; --Gives "wrong" order

First SELECT should gives this order:

  • Barn
  • beef
  • bémol
  • Bœuf
  • boulette
  • Bubble

But instead it gives (same result as COLLATE "C"):

  • Barn
  • Bubble
  • Bœuf
  • beef
  • boulette
  • bémol

Works fine in Jessie version.

It's probably because current musl library version (1.1.16) does not support LC_COLLATE, so despite settings LANG variable, sorting data will be bytewise (C). LC_COLLATE should be added to musl version 1.1.17.

@dannylui
Copy link

dannylui commented Nov 13, 2017

👍

@approxit
Copy link

approxit commented Mar 2, 2018

Any updates on this?

This case popped out in timescale/timescaledb#448.

@tianon

@tianon
Copy link
Member

tianon commented Mar 2, 2018

This sounds similar to #273 / #276 (which both still have an unknown root cause). 😞

The next step for determining the root of the problem would be to install PostgreSQL from Alpine's repos and see if that also exhibits the problem (because if it does, that points more strongly at a musl issue rather than a PostgreSQL issue or even a Docker image specific issue).

@adamhooper
Copy link

adamhooper commented Mar 26, 2018

Collation may be the root cause of #273 and #276, right? Different collation would make different index ordering.

That poses a disaster-scale problem: once musl supports LC_COLLATE, all Postgres VARCHAR indexes will break. One workaround: choose "C" collation.

@jperelli
Copy link

jperelli commented Sep 23, 2019

Maybe relevant: official musl vs glibc Character sets and locale https://wiki.musl-libc.org/functional-differences-from-glibc.html#Character-sets-and-locale

@ManiacDC
Copy link

ManiacDC commented Aug 12, 2020

We just ran into this also, anyone running the alpine image got the default "C" collation.

@raijinsetsu
Copy link

raijinsetsu commented Aug 12, 2020

My entire development team spent the last 6 hours debugging why our unit tests were failing on some local installations and not others. It came down to: the unit tests were written against the Alpine image and expected results is a specific order and the non-Alpine image returned results in a different order.

I ask that the Docker hub page be updated to reflect this as I doubt that we are the only development team that has run into this. A note that "Alpine" will use "C" collation is almost all cases (at least from our testing) would be sufficient.

@tianon
Copy link
Member

tianon commented Aug 12, 2020

Great idea, I've filed docker-library/docs#1778 👍

@jirutka
Copy link

jirutka commented Aug 1, 2022

If you build PostgreSQL with ICU, then you can use ICU Collations instead. Since Alpine v3.16, install icu-data-full to get support for all locales.

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

Successfully merging a pull request may close this issue.

10 participants