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 1wvz55-001fTO-0N for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Aug 2026 15:16:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wvz51-00BQmz-2l for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Aug 2026 15:16:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wvz51-00BQmp-0T for pgsql-hackers@lists.postgresql.org; Mon, 17 Aug 2026 15:16:52 +0000 Received: from fhigh-b6-smtp.messagingengine.com ([202.12.124.157]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wvz50-000000014bx-1XFj for pgsql-hackers@lists.postgresql.org; Mon, 17 Aug 2026 15:16:51 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.stl.internal (Postfix) with ESMTP id 7355D7A0152; Mon, 17 Aug 2026 11:16:49 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Mon, 17 Aug 2026 11:16:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1786979809; x=1787066209; bh=5 x/3FYL5gg+THZFKTthmqPzAfWOUn6qqkPfg8sCblu0=; b=JNYbKawDSqF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Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 17 Aug 2026 11:16:48 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1786979806; bh=odBYsJXtodPEoGu3lCY+izW7mb+/FLKZkIRiA35gMH8=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=AS6SHj5J3TRq0iaO/e416NZN5dYPMAFO2bYe0O9N/eyWv8F8xBVGG0kpoM+s+ZlNp gZxf4/bMNtX70ZcXoeiLccq9mn/baUUB72yR2iikfismcEKRmefefDUc3O0f+DDnyj Re0c9ePqimSP9xDMSoPzINHZhL2+xT+5n8RpSCZ7hCfJNbYNPiwWgVLf4A4sKjrxUb WBvx7sRQRFXiOkWQ//lHrat1YNIyCYptSklvUZ4mzebmHE9/pfoFNWgIhGpaTSM8z5 DXdT+iVMSQna11vhviA6oOA3jyI8hpx+cn+j285KTB4kClGtjtQJSEOSUk6YuOcPUB UG4aFbY8ybSZQ== Received: by ida.kurilemu.internal (Postfix, from userid 1000) id 06CF2B00048; Mon, 17 Aug 2026 17:16:46 +0200 (CEST) Date: Mon, 17 Aug 2026 17:16:46 +0200 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: Peter Eisentraut Cc: Nikolay Shaplov , PostgreSQL Hackers , Chris Travers , Timur Magomedov , Nathan Bossart Subject: Re: [PATCH] ternary reloption type Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3b230dc4-9495-46b6-8634-e04f9833d45e@eisentraut.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2026-Aug-17, Peter Eisentraut wrote: > There are, depending on how you count, a few to many other ternary types > used throughout the tree, and it's not clear why this one should be the > standard one now. I asked Claude which ternaries we have. The response listed three, and it started with: pg_ternary — src/include/postgres.h The canonical/general-purpose one. Values: PG_TERNARY_FALSE (0), PG_TERNARY_TRUE (1), PG_TERNARY_UNSET (-1). Comment explicitly describes it as a boolean with an extra "unset" value. It's already considered the canonical one! That's a great start. It then said trivalue — src/bin/pg_dump/pg_backup.h Used by pg_dump / client tools for command-line options. Values: TRI_DEFAULT, TRI_NO, TRI_YES. PGTernaryBool — src/interfaces/libpq/libpq-int.h (and an identical copy in src/interfaces/libpq-oauth/oauth-utils.h) A libpq internal "boolean plus not-known" for GUCs it may have to fetch. Values: PG_BOOL_UNKNOWN (0), PG_BOOL_YES, PG_BOOL_NO. That's the complete list it produced. > At least if so that should have involved some discussion > and analysis on the other ones. There are also some tradeoffs about how > this type should be designed. This particular one uses 0 and 1 for false > and true, and -1 for unset. Others use 0 for unset and other values for > false and true. Maybe this choice is useful for this particular use, but we > shouldn't impose it on everyone. I think you're talking about the libpq one (PGTernaryBool), which dates back to commit ee28cacf619f and was defined in libpq-int.h. > Independent of that, I don't understand why this was put into postgres.h > instead of c.h. It's not particular to backend code, as far as I can tell. Right, it's not. It felt a bit out of place in c.h to me, and I didn't see the argument for exposing it wider than postgres.h, but at the same time it seemed to me that a notion this common can perfectly well use a single central definition rather than have each module define the same thing. We have a handful of enums all called "trivalue" in various clients programs, with the same definitions, and that doesn't seem great to me -- quite the opposite in fact. If we move pg_ternary to c.h and add aliases TRI_YES / NO / DEFAULT, then we can remove the repetitive enum typedefs and we'd probably be in a better position. > I think it would be better to rename this to something like relopt_ternary > and move it to access/reloptions.h. I'm not sure what we gain from doing that. If there's generalized opposition to having it in postgres.h, I'm open to renaming it as suggested and moving it there. > If we want to consolidate all ternary types, that might be useful, but it > should be an explicit discussion. The others I found were: /* * Represents whether a header line must match the actual names * (which implies "true"), and whether it should be present. */ #define COPY_HEADER_MATCH -1 #define COPY_HEADER_FALSE 0 #define COPY_HEADER_TRUE 1 and #define GIN_FALSE 0 /* item is not present / does not match */ #define GIN_TRUE 1 /* item is present / matches */ #define GIN_MAYBE 2 /* don't know if item is present / don't know * if matches */ and it didn't seem that they had semantics similar enough to make them use the new enum. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "Sallah, I said NO camels! That's FIVE camels; can't you count?" (Indiana Jones)