Re: Collation versions on Windows (help wanted, apply within)

From: Juan José Santamaría Flecha <juanjo(dot)santamaria(at)gmail(dot)com>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Collation versions on Windows (help wanted, apply within)
Date: 2019-11-08 21:20:42
Message-ID: CAC+AXB0Eat3aLeTrbDoBB9jX863CU_+RSbgiAjcED5DcXoBoFQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Nov 8, 2019 at 12:44 AM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:

>
> Do any Windows hackers want to help get it into shape? Some things to
> do: test it, verify that the _WIN32_WINNT >= 0x0600 stuff makes sense
> (why do we target such ancient Windows releases anyway?)

You have to keep in mind that _WIN32_WINNT also applies to MinGW, so any
build with those tools will use a value of 0x0501 and this code will be
ifdef'd out.

As from where this value comes, my take is that it has not been revised in
a long time [1]. Windows 7 , Server 2008 and 2008 R2 support will end next
year [2] [3], maybe you can make a case for updating this value.

> see if there is way we could use GetNLSVersion() (no "Ex") to make this
> work on
> older Windows system

Older systems is just Windows Server 2003, not sure if it is worth any
effort.

> check if it makes sense to assume that
> collcollate is encoded with CP_ACP ("the system default Windows ANSI
> code page", used elsewhere in the PG source tree for a similar
> purpose, but this seems likely to go wrong for locale names that have
> non-ASCII characters, and indeed we see complaints on the lists
> involving the word "Bokmål"), and recommend a better way to display
> the collation version as text.

The GetNLSVersionEx() function uses a "Language tag" value, check Language
Code Identifier (LCID) [4], and these tags are plain ascii.

> To test that it works, you'd need to look at the contents of
> pg_collation to confirm that you see the new version strings, create
> an index on a column that explicitly uses a collation that has a
> version, update the pg_collation table by hand to have a to a
> different value, and then open a new session and to access the index
> to check that you get a warning about the version changing. The
> warning can be cleared by using ALTER COLLATION ... REFRESH VERSION.
>

The code works as expected with this collation:

postgres=# CREATE COLLATION en_US (LC_COLLATE = 'en-US', LC_CTYPE =
'en-US');
CREATE COLLATION
postgres=# select * from pg_collation;
oid | collname | collnamespace | collowner | collprovider |
collisdeterministic | collencoding | collcollate | collctype | collversion
-------+-----------+---------------+-----------+--------------+---------------------+--------------+-------------+-----------+-------------
100 | default | 11 | 10 | d | t
| -1 | | |
950 | C | 11 | 10 | c | t
| -1 | C | C |
951 | POSIX | 11 | 10 | c | t
| -1 | POSIX | POSIX |
12326 | ucs_basic | 11 | 10 | c | t
| 6 | C | C |
16387 | en_us | 2200 | 10 | c | t
| 24 | en-US | en-US | 6020f,6020f
(5 rows)

The error code 87 is an ERROR_INVALID_PARAMETER that is raised when the
collate input does not match a valid tag, I would suggest not returning it
directly.

Regards,

Juan José Santamaría Flecha

[1]
https://www.postgresql.org/message-id/flat/20090907112633.C851.52131E4D%40oss.ntt.co.jp
[2]
https://support.microsoft.com/en-us/help/4456235/end-of-support-for-windows-server-2008-and-windows-server-2008-r2
[3]
https://support.microsoft.com/en-us/help/4057281/windows-7-support-will-end-on-january-14-2020
[4]
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/70feba9f-294e-491e-b6eb-56532684c37f

Regards,

Juan José Santamaría Flecha

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Dilger 2019-11-08 21:40:06 Re: TestLib::command_fails_like enhancement
Previous Message Tomas Vondra 2019-11-08 21:11:16 Re: Monitoring disk space from within the server