On Tue, Nov 19, 2024 at 12:09 AM Peter Eisentraut <pe...@eisentraut.org> wrote:
> The more interesting patch is 495ed0ef2d7, which did
>
> -       collversion = psprintf("%d.%d,%d.%d",
> +       collversion = psprintf("%ld.%ld,%ld.%ld",

This platform has sizeof(int) == sizeof(long), so it doesn't matter.

> whereas my patch just did
>
> -       collversion = psprintf("%ld.%ld,%ld.%ld",
> +       collversion = psprintf("%lu.%lu,%lu.%lu",

I was worried the numbers might have been negative, but those
expressions don't appear to allow that.  Strings observed in real life
are like "1539.5,1539.5" (which bears a passing resemblance to an ICU
version, it has a few fairly low-valued human-originated numbers like
a Unicode version swizzled around in a fairly small number of bits,
but it doesn't matter too match how it works, it's enough to see that
we shift down and mask).

So I think it's OK to back-patch that change.  See attached.

As for why now, I think both fairywren and CI started warning/failing
about 2 months ago[1][2], and that's when fairywren got a uname -r
upgrade, so I guess msys was upgraded; as for CI I guess you'd have to
check for the relevant ming-cross packages moving in Debian.
Unfortunately there were a lot of random CI failures around that time
and I didn't notice this particular circus at the time.

[1] 
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=fairywren&dt=2024-10-02%2003%3A57%3A44
[2] https://github.com/postgres/postgres/runs/30890390821
From dce109fcd0da3c1379cd64389d03fdef18b52b54 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.mu...@gmail.com>
Date: Thu, 28 Nov 2024 16:38:03 +1300
Subject: [PATCH] Fix MinGW %d vs %lu warnings in back branches.

Commit 352f6f2d used %d to format DWORD values (unsigned long) with
psprintf().  It has format-string checking under gcc, and gcc doesn't
like it.  It seems that MinGW has started compiling this code in recent
versions, perhaps due to a _WINNT value change, so now we see the
warnings.

Commits 495ed0ef and a9bc04b2 already changed it to %lu in 16+.  In
13-15, build farm animal fairywren began warning a couple of months ago,
and in 15 (the first branch with CI) the CompilerWarnings
mingw_cross_warning step began failing around the same time.

This fixes the warning without any change in behavior, because
sizeof(int) == sizeof(long) on this platform and the values are computed
with DWORD expressions that cannot exceed INT_MAX or LONG_MAX.

Back-patch the formatting change from those commits into 13-15.

Reported-by: Andres Freund <and...@anarazel.de>
Reviewed-by:
Discussion: https://postgr.es/m/t2vjrcb3bloxf5qqvxjst6r7lvrefqyecxgt2koy5ho5b5glr2%40yuupmm6whgob
---
 src/backend/utils/adt/pg_locale.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c
index 8f841c1d192..3646c979498 100644
--- a/src/backend/utils/adt/pg_locale.c
+++ b/src/backend/utils/adt/pg_locale.c
@@ -1760,7 +1760,7 @@ get_collation_actual_version(char collprovider, const char *collcollate)
 							collcollate,
 							GetLastError())));
 		}
-		collversion = psprintf("%d.%d,%d.%d",
+		collversion = psprintf("%lu.%lu,%lu.%lu",
 							   (version.dwNLSVersion >> 8) & 0xFFFF,
 							   version.dwNLSVersion & 0xFF,
 							   (version.dwDefinedVersion >> 8) & 0xFFFF,
-- 
2.47.0

Reply via email to