RE: BUG #18219: libpq does not take into consideration UNICODE define

From: Jeff Laing <Jeff(dot)Laing(at)synchronoss(dot)com>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>, Jan Březina <2janbrezina(at)gmail(dot)com>
Subject: RE: BUG #18219: libpq does not take into consideration UNICODE define
Date: 2023-12-03 22:31:20
Message-ID: CH0PR07MB8889D75C9204CC394BF76F6E8A87A@CH0PR07MB8889.namprd07.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Looks like there is a mix to me…

c:\...mumble…> dumpbin.exe /imports libpq.dll | grep A$
23 InitializeSecurityContextA
1 AcquireCredentialsHandleA
26A GetModuleHandleA
3A8 LoadLibraryA
237 GetFileAttributesA
BA CreateFileA
3A9 LoadLibraryExA
19F FormatMessageA
179 GetUserNameA
CC SHGetFolderPathA

c:\mumble…> dumpbin.exe /imports libpq.dll | grep W$
2C5 GetStartupInfoW
26D GetModuleHandleW

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Sent: Monday, December 4, 2023 9:20 AM
To: Jan Březina <2janbrezina(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>; pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18219: libpq does not take into consideration UNICODE define

On Mon, Dec 4, 2023 at 8: 56 AM Jan Březina <2janbrezina@ gmail. com> wrote: > The project is not misconfigured. Windows applications use MBCS (multi byte character set) or UNICODE defines to specify what Windows API they are using and

On Mon, Dec 4, 2023 at 8:56 AM Jan Březina <2janbrezina(at)gmail(dot)com<mailto:2janbrezina(at)gmail(dot)com>> wrote:

> The project is not misconfigured. Windows applications use MBCS (multi byte character set) or UNICODE defines to specify what Windows API they are using and there are good reasons not to mix the two.

> You should read the following documentation:

> https://urldefense.com/v3/__https://learn.microsoft.com/en-us/windows/win32/intl/unicode-in-the-windows-api__;!!LlG_G4lo9h6Y!NGBMDMpFtxNbtb155g1HCcZB7if4EEXqwlnDws8-7_cM4q7QKLQtHy960vxoB2eM1FGocuofqDDQHEKE9HLunNjlOeY$<https://urldefense.com/v3/__https:/learn.microsoft.com/en-us/windows/win32/intl/unicode-in-the-windows-api__;!!LlG_G4lo9h6Y!NGBMDMpFtxNbtb155g1HCcZB7if4EEXqwlnDws8-7_cM4q7QKLQtHy960vxoB2eM1FGocuofqDDQHEKE9HLunNjlOeY$>

> and mainly

> https://urldefense.com/v3/__https://learn.microsoft.com/en-us/windows/win32/intl/conventions-for-function-prototypes__;!!LlG_G4lo9h6Y!NGBMDMpFtxNbtb155g1HCcZB7if4EEXqwlnDws8-7_cM4q7QKLQtHy960vxoB2eM1FGocuofqDDQHEKE9HLupjSS5eI$<https://urldefense.com/v3/__https:/learn.microsoft.com/en-us/windows/win32/intl/conventions-for-function-prototypes__;!!LlG_G4lo9h6Y!NGBMDMpFtxNbtb155g1HCcZB7if4EEXqwlnDws8-7_cM4q7QKLQtHy960vxoB2eM1FGocuofqDDQHEKE9HLupjSS5eI$>

We know about that stuff at least in general terms, but we are arguing

that *we* should be in control of whether our .c files are compiled

with UNICODE defined, not someone compiling our library. That advice

is about applications. libpq is a shared library.

But let's actually check the cost of this:

> So if you are not planning to support UNICODE define, then you should be concrete in what Windows API you are using and call the **A (ANSI) API directly, as I suggested. It is a correct way, doesn't conflict with any defines and doesn't conflict with any standard API, as UNICODE define affects only the behavior of Windows API.

> I bet there won't be so much work to fix this, as Windows specific implementations are in separate *win32.c files and hence it should not affect any other platforms and it has to work with every compiler, as it is the standard Windows API.

What symbols is libpq.dll referencing? Maybe "dumpbin /imports

libpq.dll" can tell you? I guess that'd show us how many *A /*W

functions are reached, and would be changed to call *A directly. If

it's really just Win32 APIs that are in Windows-only code paths that'd

be one thing. I wasn't sure if it might also include standard C-ish

code that is shared with Unix.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Ba Jinsheng 2023-12-04 01:17:57 Re: Re:BUG #18221: Unexpected Query Result
Previous Message Thomas Munro 2023-12-03 22:20:01 Re: BUG #18219: libpq does not take into consideration UNICODE define