Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wp8mO-001Srv-01 for pgsql-bugs@arkaria.postgresql.org; Wed, 29 Jul 2026 18:13:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wp8mM-007ZfW-2L for pgsql-bugs@arkaria.postgresql.org; Wed, 29 Jul 2026 18:13:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wp8Vj-007VCU-37 for pgsql-bugs@lists.postgresql.org; Wed, 29 Jul 2026 17:56:07 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wp8Vh-00000000y3X-3t3L for pgsql-bugs@lists.postgresql.org; Wed, 29 Jul 2026 17:56:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=BBj0AVb9ULaztDMi91FBbGlIEb3cTbgLQMPsnhgS76U=; b=Ya3Rg64NjRc2/r0CsiZC+8zs1z 838FeIIL7mHgQh8J9RqU4u4atl8fdlVsB9ZhlMxwb3qqpx9VqBEW54FjgYfaYSXnF/JIS7Omt/cB4 2rzufIK5vN5SmV8FeL9M30CbCFR1OFK7rplfSovTRAiosvPG2+7PpGELtYA6aNE1oj+paD6H7n8Pi Na1zHbUC9eXdCYhxDi4SunJxaC+0x6C3bDdn8ESJRjS0CHiSTXTo+XsUDqBfDAvTAgjhzDDyAyT4R AflStcGQFwMNYqfh3DkDMFyRe5CjXhkQ4LkY3OSKxBnel63EW52in1k4XSfng+NrtUY/8tHwazrFU Z90wl7pA==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wp8Vg-002y8e-2H for pgsql-bugs@lists.postgresql.org; Wed, 29 Jul 2026 17:56:04 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1wp8Vf-00000006xa3-1fda for pgsql-bugs@lists.postgresql.org; Wed, 29 Jul 2026 17:56:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19587: hashchar (internal "char" type) depends on platform char signedness To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: malis@pgrust.com Reply-To: malis@pgrust.com, pgsql-bugs@lists.postgresql.org Date: Wed, 29 Jul 2026 17:55:45 +0000 Message-ID: <19587-4416a590531c9c73@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following bug has been logged on the website: Bug reference: 19587 Logged by: Michael Malis Email address: malis@pgrust.com PostgreSQL version: 18.4 Operating system: Linux x86_64 and Linux aarch64, same package build Description: =20 This is about the internal single-byte "char" type (pg_type oid 18, the one needing double quotes), not SQL CHAR(n), which is bpchar and is unaffected. hashchar() and hashcharextended() cast through a bare char, whose signedness is implementation-defined: hashchar(PG_FUNCTION_ARGS) { return hash_uint32((int32) PG_GETARG_CHAR(0)); } DatumGetChar() returns char, so a high-bit byte sign-extends where char is signed (x86-64, macOS) and does not where it is unsigned (Linux aarch64). Other integer hash functions cast from explicitly-signed types and are unaffected. Reproduce (SQL_ASCII database, on each platform): SELECT hashchar(chr(128)::"char"); x86-64: 1361043915 (=3D hashint4(-128)) aarch64: 1807103465 (=3D hashint4( 128)) Impact. Hash aggregation and hash joins are unaffected, since a query hashes both sides with the same binary. The problem is where the hash is persisted: hash partitioning on a "char" column routes rows differently per platform, so a pg_dump taken on one architecture fails to restore on the other (violates partition constraint; --load-via-partition-root avoids it), and a hash index on such a column returns false negatives if the data directory is read by a build with the opposite signedness.