Re: Thread-unsafe coding in ecpg - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Thread-unsafe coding in ecpg
Date
Msg-id 9460.1548299404@sss.pgh.pa.us
Whole thread Raw
In response to Re: Thread-unsafe coding in ecpg  (Andrew Dunstan <andrew.dunstan@2ndquadrant.com>)
Responses Re: Thread-unsafe coding in ecpg  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Andrew Dunstan <andrew.dunstan@2ndquadrant.com> writes:
> On 1/23/19 6:01 PM, Tom Lane wrote:
>> Perhaps there's some sort of setup that MinGW's version needs that
>> we're not doing?

> This seems to suggest something worse: https://reviews.llvm.org/D40181
> Not sure I fully understand what's happening here, though.

Me either, but I noted a couple of interesting extracts from that page:

    Normal mingw that uses msvcrt.dll doesn't have per-thread locales so
    it won't really work in any case (but I think it does define some sort
    of dummy functions that at least will allow it to build). Nowadays,
    mingw can be built to target ucrtbase.dll as well though, and there it
    should be possible to make it work just like for MSVC although it
    might need some patches.

    ... Looked into MinGW-w64 sources and this is indeed the
    case. _configthreadlocale will return -1 and will not do anything.

This suggests that, rather than throwing up our hands if the initial
_configthreadlocale call returns -1, we should act as though the function
doesn't exist, and just soldier on the same as before.  The code in there
assumes that -1 is a can't-happen case and doesn't try to recover,
but apparently that's over-optimistic.

            regards, tom lane


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: inherited primary key misbehavior
Next
From: Amit Kapila
Date:
Subject: Re: WIP: Avoid creation of the free space map for small tables