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.94.2) (envelope-from ) id 1skEVl-008xgd-9m for pgsql-hackers@arkaria.postgresql.org; Sat, 31 Aug 2024 03:10:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1skEVi-00G8UK-S7 for pgsql-hackers@arkaria.postgresql.org; Sat, 31 Aug 2024 03:10:47 +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.94.2) (envelope-from ) id 1skEVi-00G8UC-BJ for pgsql-hackers@lists.postgresql.org; Sat, 31 Aug 2024 03:10:47 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1skEVe-002LPT-V8 for pgsql-hackers@lists.postgresql.org; Sat, 31 Aug 2024 03:10:45 +0000 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-715e3e03831so2426914b3a.2 for ; Fri, 30 Aug 2024 20:10:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1725073842; x=1725678642; darn=lists.postgresql.org; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ox3dqCvlSOGIkLQDEnzOMOD2YRSSW72HB5WuGjAY7RQ=; b=PoabaitbvYbmAcRzAbJV7BwBuWNVLcL8uRka7EXVZ1D7mEYr9C7ObSLm9bLVqor57r u4BpVgqGbt99LVcxwKHCbLUWZESOWZJjCkXJ+XPCoa3FK6NlG6vfgBlx69dKDfTh92qk CvSgQRiYxsQnfwGxMS9dZrCtVJLh4NT4nlTrk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725073842; x=1725678642; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ox3dqCvlSOGIkLQDEnzOMOD2YRSSW72HB5WuGjAY7RQ=; b=Rs24YUPb880Z3svK75mA6TMGhDNoOrPif41+QTSP2wqi007pw5PBtK6qEQGqLG5IeT /75roSLdsId1fX+/crkvybYXPyUJxgeE1L6YSU6Dx9JuMCeYwRzGUqq/TaZhoGXTkZQV Lw6Hu9tcZp9YXLKGbjFDeCw5iLx0mwOdRAQvuGQFFNjwDI5E24r+ozoBtpsQH82FgoaL zAJCXr93n/ZbxdBPQxoFXq36//jTcXAfd/vfqfQJkzneIljy9dRKiwvsJNnQ1OH5yidf eqQXD0TCAHYsxWTNubRnGgVc4o3zIGm0oTrAxBqi/izcvfJD0vKjWsE+6cV0WMlp6cZf 1+7w== X-Forwarded-Encrypted: i=1; AJvYcCU1uGgjbCVvTtjg4WhWeEVeye2Eyfc69DpaDJpB+sEG3MyyfFtxBMp0v1Chff7A9nnwjy271u28jjZt1iP5@lists.postgresql.org X-Gm-Message-State: AOJu0YzQHASh2JGW4G0w1mDzaKXzGLOnoOo/qdV4iL8/IYkDbeoJBnJG FoiKpYc55Ul/W48GCdfvGOHtuUNIecYfRwYh1IsyIk8hnBokRjgxHDV93fUakg== X-Google-Smtp-Source: AGHT+IHwS9o0Qvxua1xIk+b3O0g4IXBqJqALDVlH1ykSt9TXdTpt6oWfqwOp8a67Ga6z50tAonGQIg== X-Received: by 2002:a05:6a20:9c89:b0:1c3:a63a:cef2 with SMTP id adf61e73a8af0-1cce10161e3mr6893148637.28.1725073841866; Fri, 30 Aug 2024 20:10:41 -0700 (PDT) Received: from google.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20515544239sm33112845ad.182.2024.08.30.20.10.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Aug 2024 20:10:41 -0700 (PDT) Date: Fri, 30 Aug 2024 20:10:38 -0700 From: Noah Misch To: Masahiko Sawada Cc: Joe Conway , Peter Eisentraut , Tom Lane , Alexander Korotkov , "Guo, Adam" , "pgsql-hackers@lists.postgresql.org" , Nathan Bossart , Jim Mlodgenski Subject: Re: pg_trgm comparison bug on cross-architecture replication due to different char implementation Message-ID: <20240831031038.31.nmisch@google.com> References: <1685377.1714496091@sss.pgh.pa.us> <1696557.1714498172@sss.pgh.pa.us> <2652929.1714745623@sss.pgh.pa.us> <3846ef0f-5273-41aa-a77e-f92841e0515f@eisentraut.org> <362570f3-1031-4f8e-a077-81c103200b64@joeconway.com> <20240518214546.e8@rfd.leadboat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/2.2.12 (2023-09-09) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Aug 29, 2024 at 03:48:53PM -0500, Masahiko Sawada wrote: > On Sun, May 19, 2024 at 6:46 AM Noah Misch wrote: > > If I were standardizing pg_trgm on one or the other notion of "char", I would > > choose signed char, since I think it's still the majority. More broadly, I > > see these options to fix pg_trgm: > > > > 1. Change to signed char. Every arm64 system needs to scan pg_trgm indexes. > > 2. Change to unsigned char. Every x86 system needs to scan pg_trgm indexes. > > Even though it's true that signed char systems are the majority, it > would not be acceptable to force the need to scan pg_trgm indexes on > unsigned char systems. > > > 3. Offer both, as an upgrade path. For example, pg_trgm could have separate > > operator classes gin_trgm_ops and gin_trgm_ops_unsigned. Running > > pg_upgrade on an unsigned-char system would automatically map v17 > > gin_trgm_ops to v18 gin_trgm_ops_unsigned. This avoids penalizing any > > architecture with upgrade-time scans. > > Very interesting idea. How can new v18 users use the correct operator > class? I don't want to require users to specify the correct signed or > unsigned operator classes when creating a GIN index. Maybe we need to In brief, it wouldn't matter which operator class new v18 indexes use. The documentation would focus on gin_trgm_ops and also say something like: There's an additional operator class, gin_trgm_ops_unsigned. It behaves exactly like gin_trgm_ops, but it uses a deprecated on-disk representation. Use gin_trgm_ops in new indexes, but there's no disadvantage from continuing to use gin_trgm_ops_unsigned. Before PostgreSQL 18, gin_trgm_ops used a platform-dependent representation. pg_upgrade automatically uses gin_trgm_ops_unsigned when upgrading from source data that used the deprecated representation. What concerns might users have, then? (Neither operator class would use plain "char" in a context that affects on-disk state. They'll use "signed char" and "unsigned char".) > dynamically use the correct compare function for the same operator > class depending on the char signedness. But is it possible to do it on > the extension (e.g. pg_trgm) side? No, I don't think the extension can do that cleanly. It would need to store the signedness in the index somehow, and GIN doesn't call the opclass at a time facilitating that. That would need help from the core server.