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 1vDiH5-00E3ko-Nd for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Oct 2025 11:54:03 +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 1vDiH4-00CS75-3v for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Oct 2025 11:54:01 +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 1vDiH3-00CS6x-A8 for pgsql-hackers@lists.postgresql.org; Tue, 28 Oct 2025 11:54:00 +0000 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vDiGz-004gwS-1v for pgsql-hackers@postgresql.org; Tue, 28 Oct 2025 11:53:59 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id 3342D140048E; Tue, 28 Oct 2025 07:53:54 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Tue, 28 Oct 2025 07:53:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1761652434; x=1761738834; bh=hCAfqJI88f RWSJU5Bl9io4465XgbToUNIkKqg2GUT+o=; b=CKfBqhfPqzRfQGgJmkZz8RiS2u Usa+oRoUb+U6O9ZEuA+pOs5qsu6kGxz6ALrVA3EAAK27Wku7IBQq+4S6piYJuNrY vZztvScY82czkPLhuvuQ2+feVLmHeFKwAKgLLNSCE58YsLofHU9FaDrQA1MLl/Eq e7QOjcGYsnosQgQuUEtvYj4s4Hyt5rDCHZaVT+EdRtqmMgX0bU3HOrT0Kkb4jbNa xgVt/hcGzLeVUKQa0Dwg93prf+logN1gmZr+nbX3nbKXH2+rweNUzCCiGdBIh+Xy xkTG3P64C4kDlxUFHl1xLF/obf7Hpz7NBylvxERkZDhM7j0g+CFICNJkDg9Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1761652434; x=1761738834; bh=hCAfqJI88fRWSJU5Bl9io4465XgbToUNIkK qg2GUT+o=; b=sQNwoFdYk2mwZ/4q+NHEHKhgSDjr1+dGdD/jhvh98BR6K457CXu /TwaTmds+sXEUM69TAsqHHi5I7az/h8UTW1hH9vutSbCHVO42JgD6kCaClconQ89 UtVW92JrzlaI6+gr7BuS6elO3W/70tCtIQEISrZf7hrN3yOf1jEY5F1ueyM8x3rm uGEdvSDlI6PzT9xDxoCPLNxmxlYQirozUL4BQUEAUGNpml/Blbw3CgMF2trVi8VF HPPjL/c+2yManqVhlMqXJoHEqR1bChWXWM4Bh5KyoZyVzfObkvBTQF7cGBQJ6ceV sjq4ruf2yhFGUq2VJje86vRGLd4JlzIEk4A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduiedtjeekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufhffjgfkfgggtgesthdtredttderjeenucfhrhhomhepffgrghhfihhn nhcukfhlmhgrrhhiucforghnnhhsnohkvghruceoihhlmhgrrhhisehilhhmrghrihdroh hrgheqnecuggftrfgrthhtvghrnhepkeeljeeufefhffekhfektdefleeuvdeiiefhheef feefgeegudffudehjeejiefgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepihhlmhgrrhhisehilhhmrghrihdrohhrghdpnhgspghrtghpthht ohephedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvg hrshesphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthhtohepshgrfigruggrrdhmshhh khesghhmrghilhdrtghomhdprhgtphhtthhopeiggehmmhhmseihrghnuggvgidqthgvrg hmrdhruhdprhgtphhtthhopehsvghrghgvhihprhhokhhhohhrvghnkhhoseihrghhohho rdgtohhmrdgruhdprhgtphhtthhopehpohhsthhgrhgvshesjhgvlhhtvghfrdhnlh X-ME-Proxy: Feedback-ID: i1ff147bf:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 28 Oct 2025 07:53:52 -0400 (EDT) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= To: Jelte Fennema-Nio Cc: Sergey Prokhorenko , Andrey Borodin , Masahiko Sawada , pgsql-hackers Subject: Re: Add uuid_to_base32hex() and base32hex_to_uuid() built-in functions References: <1791665551.452444.1761209220211.ref@mail.yahoo.com> <1791665551.452444.1761209220211@mail.yahoo.com> <18022523-0F8F-4C07-AFF5-57DC9086D78E@yandex-team.ru> <1895971769.8343.1761240853939@mail.yahoo.com> <574624399.175025.1761290201491@mail.yahoo.com> <953203149.383019.1761345585325@mail.yahoo.com> <6F76FA61-E2DC-44EF-9504-889D9BDB4EBD@yandex-team.ru> <1154454839.957923.1761604611424@mail.yahoo.com> Date: Tue, 28 Oct 2025 11:53:51 +0000 In-Reply-To: (Jelte Fennema-Nio's message of "Tue, 28 Oct 2025 10:30:04 +0100") Message-ID: <87ldkv8cog.fsf@wibble.ilmari.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Jelte Fennema-Nio writes: > First of all, I'm definitely a proponent of being able to encode UUIDs > using base32hex in Postgres. > > On Mon, 27 Oct 2025 at 23:37, Sergey Prokhorenko > wrote: >> >> Regarding the proposal to couple UUID encoding with the bytea type >> through encode()/decode() functions: I understand the appeal of >> reusing existing infrastructure, but this creates a conceptual >> mismatch. UUID is a distinct semantic type in PostgreSQL, not merely >> binary data. The bytea type has existed for decades without base32hex >> encoding, and that's worked fine, because bytea represents arbitrary >> binary data, not universally unique identifiers with specific >> structural properties and needs. > > I think by far the first step is to make the encoding of UUIDs in > different formats possible in Postgres. The way to do so with the > least API impact (and thus as you noticed, least pushback), would be > to add base32hex to the list of encoding formats in the encode/decode > functions. Then combining that with UUID <-> bytea casting (which also > seems totally reasonable functionality to me), would give you the > functionality (but not the defaults you want). +1 for adding casts. > In a follow up patch I would personally be fine making the API to > encode UUIDs a bit more friendly. In particular, adding an overload to > the encode function that takes a UUID instead of a bytea seems > reasonable to me, i.e. encode(id uuid, format text) -> text Yeah, this works for encode, but not decode, since the argment types are the same (text, text) in both cases. > I'm currently less convinced about a decode_uuid function though. I > think some perf argument (including some benchmarks) would need to be > made to convince me of its usefulness. Because purely from an API > friendliness lens, I feel like decode('...', 'base32hex)::uuid and > decode_uuid('...', 'base32hex') rank basically the same. Agreed. > Once/if an accepted RFC actually defines a default shorter encoding > for UUIDs we could I would definitely be in favor of adding a > decode_uuid function with the default encoding configured as a default > argument. As well as adding the default argument to the uuid encode > overload function. If it's just one new form, do we need a separate decode function? Could we not just make uuid_in() accept both forms (they're easily distinguishable by length), like bytea_in accepts both the old escape format and the new hex format? And if the new format becomes the standard and want to change the default output format, we would need a GUC like bytea_output anyway, to let users control when to make the change. - ilmari