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 1w15Js-002XoG-0V for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Mar 2026 16:25:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w15Jp-005ElM-12 for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Mar 2026 16:24:57 +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 1w15Jp-005ElD-07 for pgsql-hackers@lists.postgresql.org; Fri, 13 Mar 2026 16:24:57 +0000 Received: from fhigh-b4-smtp.messagingengine.com ([202.12.124.155]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w15Jn-00000001yis-2wXY for pgsql-hackers@postgresql.org; Fri, 13 Mar 2026 16:24:56 +0000 Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfhigh.stl.internal (Postfix) with ESMTP id 1B3177A01B8; Fri, 13 Mar 2026 12:24:55 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Fri, 13 Mar 2026 12:24:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; 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=fm1; t=1773419094; x=1773505494; bh=gdhJpwyzf+ z7+mB8OlCIUCeIhm/f6UhfdLQlHSBtkqU=; b=m48xVghSBj39RdqLycoGpKNNVY 0HOXUowBMyzlCQnYE5oSGgV5YtuSrEgPJ1NsUgZVGIkontAs154Itf/8nv7GH4rA I/F8EYAYKHodeqxEPHH+LNrUYIDQ28EQFlGlCD5WvPyQLPEKby9b0DYJzaJtbrol 66ZPiJUA2exwa3f5/eypf7oP6ED51z1efTNLGHgvjf1jrT1pwl3oDA4ghaT1YesP uDty1C4V3f/zQDH296W2EeNXGcXsg33ERm0dMqaunbdHFiov4OW8Ft5zx4DXDcEV 1FDiNRTwaOr6FboeGJ5YnIOb7QEDTqvlR36g05CFfw/n1OtuTNIstvw3hIlQ== 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=fm1; t= 1773419094; x=1773505494; bh=gdhJpwyzf+z7+mB8OlCIUCeIhm/f6UhfdLQ lHSBtkqU=; b=dyhH4vl96q47s5yNe04cR5+nJDdnrba3ctwYPs2tDYRtwUabDI0 YL38bah3pFbh3vjvmv5iOarLOrDPZslvFHv2q9BEOgAnmWFziV60bx1badSkeDMG dF1xNxvGgnKoIUHieIS0E6R8gbGePUrncvT4omQRgbiVkzNVVm+CxTqbKlaFScRW 73GzBSJdQdsjo1XE6/umoTHoV5JhQPBuz4wMoCTyeyDz9DbsTVSf38NJeSAdDDPr Z/W+GYJKg4KrjFJT122c/clA/u2WNpeSYf69UoAD8C0CbZLROmlSTpvCwPTBebu8 Fb0RUqR1du30ZuN41QUEtajRGUHMrhZZIMg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvledtudefucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtuggjsehttdfstd dttddvnecuhfhrohhmpeetnhgurhgvshcuhfhrvghunhguuceorghnughrvghssegrnhgr rhgriigvlhdruggvqeenucggtffrrghtthgvrhhnpeeffffgledvffegtdevlefgtdeggf fhvdekgfegteeiveejkeetudelveejhfeugeenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvshesrghnrghrrgiivghlrdguvgdpnh gspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheprgihuhhs hhhtihifrghrihdrshhlghdtudesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqh hlqdhhrggtkhgvrhhssehpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 13 Mar 2026 12:24:54 -0400 (EDT) Date: Fri, 13 Mar 2026 12:24:53 -0400 From: Andres Freund To: Ayush Tiwari Cc: pgsql-hackers@postgresql.org Subject: Re: tid_blockno() and tid_offset() accessor functions Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2026-03-08 01:13:13 +0530, Ayush Tiwari wrote: > From 92e3657d85b13355563ba4c447ddf89fcb4c4b3e Mon Sep 17 00:00:00 2001 > From: Ayush Tiwari > Date: Sat, 7 Mar 2026 18:27:36 +0000 > Subject: [PATCH v2] Add tid_block() and tid_offset() accessor functions > > Add two new built-in SQL functions to extract the components of a tid > (tuple identifier) value: > > tid_block(tid) -> bigint -- extract block number > tid_offset(tid) -> integer -- extract offset number > > These provide a clean, efficient alternative to the common workaround > of ctid::text::point for decomposing TID values. The text-based hack > is fragile, inefficient, and unavailable outside of SQL contexts. > > tid_block() returns int8 (bigint) because BlockNumber is uint32, > which exceeds the range of int4. tid_offset() returns int4 (integer) > because OffsetNumber is uint16, which fits safely in int4. > > Both functions use the NoCheck accessor variants from itemptr.h, > are marked leakproof, and include regression tests covering typical > values, boundary conditions, NULL handling, and round-trip identity. > +++ b/doc/src/sgml/func/func-tid.sgml > @@ -0,0 +1,73 @@ > + > + TID Functions > + > + > + TID > + functions > + > + > + > + tid_block > + > + > + > + tid_offset > + > + > + > + For the tid data type (described in + linkend="datatype-oid"/>), Seems odd to reference the datatype-oid, that's barely mentioning the tid type and tid is not an oid like type either (like e.g. regtype is). > + shows the functions available for extracting the block number and > + tuple offset. These functions are commonly used with the > + ctid system column. > + I know some other places do that too, but "shows the functions" sounds odd to me. I'd just say "These are listed in ..." or such. I'd remove the "available for extracting the block number and tuple offset", as that's bound to become inaccurate and just restates the table contents. > --- a/doc/src/sgml/func/func.sgml > +++ b/doc/src/sgml/func/func.sgml > @@ -59,6 +59,7 @@ repeat('Pg', 4) PgPgPgPg > &func-formatting; > &func-datetime; > &func-enum; > +&func-tid; > &func-geometry; > &func-net; > &func-textsearch; I'd add it somewhere more alphabetically fitting. Unfortunately the list isn't fully ordered right now, but no need to make it even worse... Greetings, Andres Freund