Re: Collation versions on Windows (help wanted, apply within) - Mailing list pgsql-hackers

From Juan José Santamaría Flecha
Subject Re: Collation versions on Windows (help wanted, apply within)
Date
Msg-id CAC+AXB0Eat3aLeTrbDoBB9jX863CU_+RSbgiAjcED5DcXoBoFQ@mail.gmail.com
Whole thread Raw
In response to Collation versions on Windows (help wanted, apply within)  (Thomas Munro <thomas.munro@gmail.com>)
List pgsql-hackers

On Fri, Nov 8, 2019 at 12:44 AM Thomas Munro <thomas.munro@gmail.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 


Regards,

Juan José Santamaría Flecha 

pgsql-hackers by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: Monitoring disk space from within the server
Next
From: Mark Dilger
Date:
Subject: Re: TestLib::command_fails_like enhancement