Re: pg_trgm comparison bug on cross-architecture replication due to different char implementation

Noah Misch <noah@leadboat.com>

From: Noah Misch <noah@leadboat.com>
To: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Joe Conway <mail@joeconway.com>, Peter Eisentraut <peter@eisentraut.org>, Alexander Korotkov <aekorotkov@gmail.com>, "Guo, Adam" <adamguo@amazon.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>, Nathan Bossart <nathandbossart@gmail.com>, Jim Mlodgenski <jimmy76@gmail.com>
Date: 2025-02-18T23:23:09Z
Lists: pgsql-hackers
Apart from two doc issues, this is ready:

On Tue, Feb 18, 2025 at 01:23:20PM -0800, Masahiko Sawada wrote:
> On Mon, Feb 17, 2025 at 2:57 PM Noah Misch <noah@leadboat.com> wrote:
> > On Fri, Jan 17, 2025 at 05:11:41PM -0800, Masahiko Sawada wrote:

> +        However, when upgrading from <productname>PostgreSQL</productname> 17 or,
> +        earlier <application>pg_upgrade</application> adopts the char signedness

s/or, earlier/or earlier,/

> --- a/doc/src/sgml/ref/pg_resetwal.sgml
> +++ b/doc/src/sgml/ref/pg_resetwal.sgml
> @@ -171,6 +171,22 @@ PostgreSQL documentation
>    </para>
>  
>    <variablelist>
> +   <varlistentry>
> +    <term><option>--char-signedness=<replaceable class="parameter">option</replaceable></option></term>
> +    <listitem>
> +     <para>
> +      Manually set the default char signedness. Possible values are
> +      <literal>signed</literal> and <literal>unsigned</literal>.
> +     </para>
> +     <para>
> +      A safe value for this option is, if known, the default char signedness
> +      of the platform where the database cluster was initialized. However,

Only if initialized on v17 or earlier.  I recommend this edit:

diff --git a/doc/src/sgml/ref/pg_resetwal.sgml b/doc/src/sgml/ref/pg_resetwal.sgml
index a72678d..dd011d2 100644
--- a/doc/src/sgml/ref/pg_resetwal.sgml
+++ b/doc/src/sgml/ref/pg_resetwal.sgml
@@ -179,8 +179,11 @@ PostgreSQL documentation
       <literal>signed</literal> and <literal>unsigned</literal>.
      </para>
      <para>
-      A safe value for this option is, if known, the default char signedness
-      of the platform where the database cluster was initialized. However,
+      For a database cluster that <command>pg_upgrade</command> upgraded from
+      a <productname>PostgreSQL</productname> version before 18, the safe
+      value would be the default <type>char</type> signedness of the platform
+      that ran the cluster before that upgrade. For all other
+      clusters, <literal>signed</literal> would be the safe value. However,
       this option is exclusively for use with <command>pg_upgrade</command>
       and should not normally be used manually.
      </para>



Commits

  1. pg_upgrade: Check for the expected error message in TAP tests.

  2. Fix a typo in 005_char_signedness.pl test.

  3. Add test 005_char_signedness.pl to meson.build.

  4. Fix an issue with index scan using pg_trgm due to char signedness on different architectures.

  5. pg_upgrade: Add --set-char-signedness to set the default char signedness of new cluster.

  6. pg_upgrade: Preserve default char signedness value from old cluster.

  7. pg_resetwal: Add --char-signedness option to change the default char signedness.

  8. Add default_char_signedness field to ControlFileData.

  9. Remove unneeded nbtree array preprocessing assert.