pgsql: pg_upgrade: Preserve default char signedness value from old clus

Started by Masahiko Sawada11 months ago6 messages
#1Masahiko Sawada
msawada@postgresql.org

pg_upgrade: Preserve default char signedness value from old cluster.

Commit 44fe30fdab6 introduced the 'default_char_signedness' field in
controlfile. Newly created database clusters always set this field to
'signed'.

This change ensures that pg_upgrade updates the
'default_char_signedness' to 'unsigned' if the source database cluster
has signedness=false. For source clusters from v17 or earlier, which
lack the 'default_char_signedness' information, pg_upgrade assumes the
source cluster was initialized on the same platform where pg_upgrade
is running. It then sets the 'default_char_signedness' value according
to the current platform's default character signedness.

Reviewed-by: Noah Misch <noah@leadboat.com>
Discussion: /messages/by-id/CB11ADBC-0C3F-4FE0-A678-666EE80CBB07@amazon.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a8238f87f980848c2d69c105555c4383e20e7670

Modified Files
--------------
src/bin/pg_upgrade/controldata.c | 44 ++++++++++++++++++-
src/bin/pg_upgrade/pg_upgrade.c | 28 +++++++++++++
src/bin/pg_upgrade/pg_upgrade.h | 6 +++
src/bin/pg_upgrade/t/005_char_signedness.pl | 65 +++++++++++++++++++++++++++++
4 files changed, 142 insertions(+), 1 deletion(-)

#2Robert Haas
robertmhaas@gmail.com
In reply to: Masahiko Sawada (#1)
Re: pgsql: pg_upgrade: Preserve default char signedness value from old clus

On Fri, Feb 21, 2025 at 1:20 PM Masahiko Sawada <msawada@postgresql.org> wrote:

pg_upgrade: Preserve default char signedness value from old cluster.

Hi,

I noticed that after running 'meson test --suite setup --suite
pg_upgrade', the file delete_old_cluster.sh is left behind in the
source directory, which should not happen. Everything created for the
tests should be created in the meson directories. I traced the problem
down to 005_char_signedness.pl. I believe the problem is likely that
other pg_upgrade TAP tests include this locution, whereas
005_char_signedness.pl does not:

# In a VPATH build, we'll be started in the source directory, but we want
# to run pg_upgrade in the build directory so that any files generated finish
# in it, like delete_old_cluster.{sh,bat}.
chdir ${PostgreSQL::Test::Utils::tmp_check};

Regards,

--
Robert Haas
EDB: http://www.enterprisedb.com

#3Masahiko Sawada
sawada.mshk@gmail.com
In reply to: Robert Haas (#2)
1 attachment(s)
Re: pgsql: pg_upgrade: Preserve default char signedness value from old clus

On Mon, Mar 17, 2025 at 10:20 AM Robert Haas <robertmhaas@gmail.com> wrote:

On Fri, Feb 21, 2025 at 1:20 PM Masahiko Sawada <msawada@postgresql.org> wrote:

pg_upgrade: Preserve default char signedness value from old cluster.

Hi,

I noticed that after running 'meson test --suite setup --suite
pg_upgrade', the file delete_old_cluster.sh is left behind in the
source directory, which should not happen. Everything created for the
tests should be created in the meson directories. I traced the problem
down to 005_char_signedness.pl. I believe the problem is likely that
other pg_upgrade TAP tests include this locution, whereas
005_char_signedness.pl does not:

# In a VPATH build, we'll be started in the source directory, but we want
# to run pg_upgrade in the build directory so that any files generated finish
# in it, like delete_old_cluster.{sh,bat}.
chdir ${PostgreSQL::Test::Utils::tmp_check};

Thank you for the report.

I've confirmed the issue and attached a patch to fix it.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

Attachments:

0001-Fix-the-test-005_char_signedness.patchapplication/octet-stream; name=0001-Fix-the-test-005_char_signedness.patchDownload
From 6fe1578bcbf7f579869684a71dd463bb2939d82c Mon Sep 17 00:00:00 2001
From: Masahiko Sawada <sawada.mshk@gmail.com>
Date: Mon, 17 Mar 2025 14:52:13 -0700
Subject: [PATCH] Fix the test 005_char_signedness.

pg_upgrade test 003_char_signedness was leaving files like
delete_old_cluster.sh in the source directory for VPATH and meson
builds. The fix is to change the directory to tmp_check before running
the test.

Reported-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by:
Discussion: http://postgr.es/m/CA+TgmoYg5e4oznn0XGoJ3+mceG1qe_JJt34rF2JLwvGS5T1hgQ@mail.gmail.com
---
 src/bin/pg_upgrade/t/005_char_signedness.pl | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/bin/pg_upgrade/t/005_char_signedness.pl b/src/bin/pg_upgrade/t/005_char_signedness.pl
index 0190747758c..17fa0d48b15 100644
--- a/src/bin/pg_upgrade/t/005_char_signedness.pl
+++ b/src/bin/pg_upgrade/t/005_char_signedness.pl
@@ -45,6 +45,11 @@ command_like(
 	qr/Default char data signedness:\s+unsigned/,
 	'updated default char signedness is unsigned in control file');
 
+# In a VPATH build, we'll be started in the source directory, but we want
+# to run pg_upgrade in the build directory so that any files generated finish
+# in it, like delete_old_cluster.{sh,bat}.
+chdir ${PostgreSQL::Test::Utils::tmp_check};
+
 # Cannot use --set-char-signedness option for upgrading from v18+
 command_checks_all(
 	[
-- 
2.43.5

#4Robert Haas
robertmhaas@gmail.com
In reply to: Masahiko Sawada (#3)
Re: pgsql: pg_upgrade: Preserve default char signedness value from old clus

On Mon, Mar 17, 2025 at 6:02 PM Masahiko Sawada <sawada.mshk@gmail.com> wrote:

I've confirmed the issue and attached a patch to fix it.

Cool. The commit message refers to 003_char_signedness, but the test
name is 005, not 003.

--
Robert Haas
EDB: http://www.enterprisedb.com

#5Masahiko Sawada
sawada.mshk@gmail.com
In reply to: Robert Haas (#4)
Re: pgsql: pg_upgrade: Preserve default char signedness value from old clus

On Mon, Mar 17, 2025 at 8:02 PM Robert Haas <robertmhaas@gmail.com> wrote:

On Mon, Mar 17, 2025 at 6:02 PM Masahiko Sawada <sawada.mshk@gmail.com> wrote:

I've confirmed the issue and attached a patch to fix it.

Cool. The commit message refers to 003_char_signedness, but the test
name is 005, not 003.

Thank you for reviewing the patch. I've pushed the patch after fixing it.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

#6Robert Haas
robertmhaas@gmail.com
In reply to: Masahiko Sawada (#5)
Re: pgsql: pg_upgrade: Preserve default char signedness value from old clus

On Tue, Mar 18, 2025 at 12:36 AM Masahiko Sawada <sawada.mshk@gmail.com> wrote:

Cool. The commit message refers to 003_char_signedness, but the test
name is 005, not 003.

Thank you for reviewing the patch. I've pushed the patch after fixing it.

Thanks for taking care of it (and so quickly!).

--
Robert Haas
EDB: http://www.enterprisedb.com