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 1wHalV-007Kg7-0V for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Apr 2026 05:13:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wHalU-00G7Qo-1F for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Apr 2026 05:13:44 +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 1wHalT-00G7Qf-1L for pgsql-hackers@lists.postgresql.org; Tue, 28 Apr 2026 05:13:44 +0000 Received: from fout-a3-smtp.messagingengine.com ([103.168.172.146]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wHalP-000000038cr-2z7q for pgsql-hackers@postgresql.org; Tue, 28 Apr 2026 05:13:42 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id A526DEC00A0; Tue, 28 Apr 2026 01:13:38 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Tue, 28 Apr 2026 01:13:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; 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=1777353218; x=1777439618; bh=4qrL5OjmSi yjMbKb4xvEEtqb2CelP11iwNxBXFFQWU8=; b=Odox0SE3iCyzokHNSDZNbGAs+Z tXJiZ58nRbGs50lGIABR11PqULLRCZcBHOWeHuJ2trlvlfKc0652U1S/6TFIEVuh 1U4Fxv2vGLxMWkcSV7rVQMn3pyRHaw7h+2otKdCf9sWO03raXCuQuqHJAUlDy+iA 36WnImX7WybRPg7x7TLUmx9XNPgvvv+I/XEkYp1j6/nB8fDwdzMBZwBff9wVPbMO EMuxZWRQ/veBnFDh/ZYeceByRaxYUBXP15Bd0lTRo3pXdaGukD1EytYPXgvU/Ccl i1G6wJIfjVoMFB5mYhiQJIwf3pG/MQb7vcGx3CNkysT+Z1ALmaw9VfL9TXwQ== 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=fm2; t= 1777353218; x=1777439618; bh=4qrL5OjmSiyjMbKb4xvEEtqb2CelP11iwNx BXFFQWU8=; b=JH4LrgvoPZgdFIaYqQjmFmMgNWXTzw7J/OJt8biSI7n/yl0y65f nD5wN1WJ0s0T7KM8hsZ07hyIXxWc26iqWzsiRBigTJsRqv+ePepgiY9W7pJ/2ZSU SF3IGoGNQ0pyOv2F0KZ8oOX8RXJOzO/BnesbyRgL84hNNNZnaM+ip2hnTWEjcK9W rAUqPSFfjZZHMqq5K/yjjRXwV2+LN6KFoLwAVKsjIPmz7LkTO4udYTEZkvW3ZYaD 8whhpllB0ddZbKaoWRREvgPQbPGnq1LTxNqrA0feE5QbnOGnV/BW2+6M/QJFTKgb 6tGDO4pVeXvYKp4Jpb96QZ1OfmGDRas5uEw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdektdejtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdefhedmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvden ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeegffejvefgveduvdejtddvtdeijeeh udeuledvudeftdfgfeejvdekveekiedvvdenucffohhmrghinhepphhoshhtghhrvghsqh hlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhho mhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidpnhgspghrtghpthhtohepledpmh houggvpehsmhhtphhouhhtpdhrtghpthhtohepphgvthgvrhesvghishgvnhhtrhgruhht rdhorhhgpdhrtghpthhtoheprghlvghkshgrnhguvghrsehtihhgvghruggrthgrrdgtoh hmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrshesphhoshhtghhrvghsqhhlrdho rhhgpdhrtghpthhtoheprhgvshhhkhgvkhhirhhilhhlsehgmhgrihhlrdgtohhmpdhrtg hpthhtohepughgrhhofihlvgihmhhlsehgmhgrihhlrdgtohhmpdhrtghpthhtohepthhg lhesshhsshdrphhghhdrphgrrdhushdprhgtphhtthhopehhlhhinhhnrghkrgesihhkih drfhhipdhrtghpthhtohepnhgrthhhrghnuggsohhsshgrrhhtsehgmhgrihhlrdgtohhm pdhrtghpthhtohepmhgvlhgrnhhivghplhgrghgvmhgrnhesghhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 28 Apr 2026 01:13:35 -0400 (EDT) Date: Tue, 28 Apr 2026 14:13:31 +0900 From: Michael Paquier To: Peter Eisentraut Cc: Aleksander Alekseev , pgsql-hackers , Kirill Reshke , David Rowley , Tom Lane , Heikki Linnakangas , Nathan Bossart , melanieplageman@gmail.com Subject: Re: Define DatumGetInt8 function. Message-ID: References: <2869012.1767023578@sss.pgh.pa.us> <7f39480a-4b7a-4a51-a9ec-d1189b44432d@eisentraut.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="BUvVvcythNfp1i9o" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --BUvVvcythNfp1i9o Content-Type: multipart/mixed; boundary="D742/kIVTjGERCcK" Content-Disposition: inline --D742/kIVTjGERCcK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Mar 27, 2026 at 01:17:15PM +0100, Peter Eisentraut wrote: > I'm moving this patch to the next commitfest. It's worth continuing to work > on making this more correct, but AFAICT no bug has been claimed here, so > it's not worth rushing this now. Well, as you have pointed out at [1], this is undoing a portion of 6dcfac9696cb that has changed a set of *GetDatum() functions to match with the C type of the variables they work on, and not the output of the function, which is incorrect. This means an open item standing on top of my head for this release, that needs to be acted on. The patch proposed at [2] handles the problem partially, unfortunately. I have spotted a lot more places where we use a *GetDatum() that does not match with the data type of the SQL function related to. In terms of locations spotted, some notes: - Of course, the.. cough.. places that 6dcfac9696cb has touched, reverted now to their original form to match the SQL data type (BRIN, pageinspect, GiST, lockfuncs.c, one in pg_buffercache). - The IndexTupleSize() business in pageinspect is a good catch. All these related to smallint, used a int32 GetDatum(). - Not completely sure about the ones in nbtcompare.c, TBH. - lockfuncs.c is much more inconsistent than I thought, even after reverting the bits of 6dcfac9696cb. pg_lock_status() was a mixed bag of incorrectness (field3 for LOCKTAG_PAGE, field3 and field4 for LOCKTAG_TUPLE, two more for PREDLOCKTAG_TUPLE). - ginlogic.c, for triConsistentFn and consistentFmgrInfo. nuserentries is a uint32, but the functions require Int32GetDatum() as use int4 for the data type. - xlogfuncs.c, pg_walfile_name_offset() should use Int32GetDatum() for xrecoff. - pg_proc.c, for pronargs and pronargdefaults. Quite an old one. - pg_logicalinspect, 4 spots for the snapshot functions. - pg_walinspect, for various record data. - pgstatindex, pending pages. In short, it took me some time to put some order into all that, finishing with the attached patch set. 0001 is the minimum for v19, that reverts 6dcfac9696cb so as we have more *GetDatum() matching with the types in the SQL functions. That would take care of the open item on top of my head. 0002 is a set of fixes that I have spotted while investigating this set of issues in depth. These spots are actually wrong, some of them for a long time. I would be slightly tempted to do something about these in v19 rather than wait for v20, as these are somewhat latent bugs, to have more consistency across the board. Has anybody from the RMT an opinion to offer? There is not much urgency in it, still.. Added the RMT in CC for opinions. [1]: https://www.postgresql.org/message-id/97f9375a-be61-4272-a44d-408337fe8fa6%40eisentraut.org [2]: https://www.postgresql.org/message-id/CAJ7c6TMcGu8qmRe1gZfJ-gOzVnZq-t%3Dfwn-UuyStx1w6ZyydMw%40mail.gmail.com -- Michael --D742/kIVTjGERCcK Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=0001-Revert-Use-more-consistent-GetDatum-macros-for-some-.patch Content-Transfer-Encoding: quoted-printable =46rom d777110a8e705eb69e506f56a6f33297869b7599 Mon Sep 17 00:00:00 2001 =46rom: Michael Paquier Date: Tue, 28 Apr 2026 13:54:59 +0900 Subject: [PATCH 1/2] Revert "Use more consistent *GetDatum() macros for some unsigned numbers" This reverts commit 6dcfac9696cb, which is wrong in trying to match the *GetDatum() functions to match with the C types. These should match with the SQL functions these fields relate to. More areas in the tree are still wrong, using Datum conversion routines that do not match with the types of the SQL functions. These will be adjusted in an upcoming commit. Reported-by: Peter Eisentraut Discussion: https://postgr.es/m/97f9375a-be61-4272-a44d-408337fe8fa6@eisent= raut.org Discussion: https://postgr.es/m/CAJ7c6TMcGu8qmRe1gZfJ-gOzVnZq-t=3Dfwn-UuySt= x1w6ZyydMw@mail.gmail.com --- src/backend/access/brin/brin_inclusion.c | 2 +- src/backend/access/brin/brin_minmax.c | 2 +- src/backend/access/brin/brin_minmax_multi.c | 2 +- src/backend/access/gist/gistget.c | 4 ++-- src/backend/utils/adt/lockfuncs.c | 4 ++-- contrib/pageinspect/btreefuncs.c | 2 +- contrib/pageinspect/ginfuncs.c | 2 +- contrib/pageinspect/gistfuncs.c | 4 ++-- contrib/pg_buffercache/pg_buffercache_pages.c | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/backend/access/brin/brin_inclusion.c b/src/backend/access/= brin/brin_inclusion.c index 5a2058d9aad7..08890a3d0095 100644 --- a/src/backend/access/brin/brin_inclusion.c +++ b/src/backend/access/brin/brin_inclusion.c @@ -641,7 +641,7 @@ inclusion_get_strategy_procinfo(BrinDesc *bdesc, uint16= attno, Oid subtype, tuple =3D SearchSysCache4(AMOPSTRATEGY, ObjectIdGetDatum(opfamily), ObjectIdGetDatum(attr->atttypid), ObjectIdGetDatum(subtype), - UInt16GetDatum(strategynum)); + Int16GetDatum(strategynum)); =20 if (!HeapTupleIsValid(tuple)) elog(ERROR, "missing operator %d(%u,%u) in opfamily %u", diff --git a/src/backend/access/brin/brin_minmax.c b/src/backend/access/bri= n/brin_minmax.c index 732010293718..9d4e47b4dc08 100644 --- a/src/backend/access/brin/brin_minmax.c +++ b/src/backend/access/brin/brin_minmax.c @@ -294,7 +294,7 @@ minmax_get_strategy_procinfo(BrinDesc *bdesc, uint16 at= tno, Oid subtype, tuple =3D SearchSysCache4(AMOPSTRATEGY, ObjectIdGetDatum(opfamily), ObjectIdGetDatum(attr->atttypid), ObjectIdGetDatum(subtype), - UInt16GetDatum(strategynum)); + Int16GetDatum(strategynum)); =20 if (!HeapTupleIsValid(tuple)) elog(ERROR, "missing operator %d(%u,%u) in opfamily %u", diff --git a/src/backend/access/brin/brin_minmax_multi.c b/src/backend/acce= ss/brin/brin_minmax_multi.c index 207ae336091b..daa97164e413 100644 --- a/src/backend/access/brin/brin_minmax_multi.c +++ b/src/backend/access/brin/brin_minmax_multi.c @@ -2930,7 +2930,7 @@ minmax_multi_get_strategy_procinfo(BrinDesc *bdesc, u= int16 attno, Oid subtype, tuple =3D SearchSysCache4(AMOPSTRATEGY, ObjectIdGetDatum(opfamily), ObjectIdGetDatum(attr->atttypid), ObjectIdGetDatum(subtype), - UInt16GetDatum(strategynum)); + Int16GetDatum(strategynum)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "missing operator %d(%u,%u) in opfamily %u", strategynum, attr->atttypid, subtype, opfamily); diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gi= stget.c index 4d7c100d7378..d509cc38d5db 100644 --- a/src/backend/access/gist/gistget.c +++ b/src/backend/access/gist/gistget.c @@ -231,7 +231,7 @@ gistindex_keytest(IndexScanDesc scan, key->sk_collation, PointerGetDatum(&de), key->sk_argument, - UInt16GetDatum(key->sk_strategy), + Int16GetDatum(key->sk_strategy), ObjectIdGetDatum(key->sk_subtype), PointerGetDatum(&recheck)); =20 @@ -295,7 +295,7 @@ gistindex_keytest(IndexScanDesc scan, key->sk_collation, PointerGetDatum(&de), key->sk_argument, - UInt16GetDatum(key->sk_strategy), + Int16GetDatum(key->sk_strategy), ObjectIdGetDatum(key->sk_subtype), PointerGetDatum(&recheck)); *recheck_distances_p |=3D recheck; diff --git a/src/backend/utils/adt/lockfuncs.c b/src/backend/utils/adt/lock= funcs.c index 4481c354fd61..dc58e9cb0a6d 100644 --- a/src/backend/utils/adt/lockfuncs.c +++ b/src/backend/utils/adt/lockfuncs.c @@ -330,7 +330,7 @@ pg_lock_status(PG_FUNCTION_ARGS) values[1] =3D ObjectIdGetDatum(instance->locktag.locktag_field1); values[8] =3D ObjectIdGetDatum(instance->locktag.locktag_field2); values[6] =3D ObjectIdGetDatum(instance->locktag.locktag_field3); - values[9] =3D UInt16GetDatum(instance->locktag.locktag_field4); + values[9] =3D Int16GetDatum(instance->locktag.locktag_field4); nulls[2] =3D true; nulls[3] =3D true; nulls[4] =3D true; @@ -344,7 +344,7 @@ pg_lock_status(PG_FUNCTION_ARGS) values[1] =3D ObjectIdGetDatum(instance->locktag.locktag_field1); values[7] =3D ObjectIdGetDatum(instance->locktag.locktag_field2); values[8] =3D ObjectIdGetDatum(instance->locktag.locktag_field3); - values[9] =3D UInt16GetDatum(instance->locktag.locktag_field4); + values[9] =3D Int16GetDatum(instance->locktag.locktag_field4); nulls[2] =3D true; nulls[3] =3D true; nulls[4] =3D true; diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefu= ncs.c index 0585b7cee402..62c905c6e7c2 100644 --- a/contrib/pageinspect/btreefuncs.c +++ b/contrib/pageinspect/btreefuncs.c @@ -507,7 +507,7 @@ bt_page_print_tuples(ua_page_items *uargs) =20 j =3D 0; memset(nulls, 0, sizeof(nulls)); - values[j++] =3D UInt16GetDatum(offset); + values[j++] =3D Int16GetDatum(offset); values[j++] =3D ItemPointerGetDatum(&itup->t_tid); values[j++] =3D Int32GetDatum((int) IndexTupleSize(itup)); values[j++] =3D BoolGetDatum(IndexTupleHasNulls(itup)); diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c index b6574083b0a1..ebcc2b3db5c7 100644 --- a/contrib/pageinspect/ginfuncs.c +++ b/contrib/pageinspect/ginfuncs.c @@ -73,7 +73,7 @@ gin_metapage_info(PG_FUNCTION_ARGS) =20 values[0] =3D Int64GetDatum(metadata->head); values[1] =3D Int64GetDatum(metadata->tail); - values[2] =3D UInt32GetDatum(metadata->tailFreeSize); + values[2] =3D Int32GetDatum(metadata->tailFreeSize); values[3] =3D Int64GetDatum(metadata->nPendingPages); values[4] =3D Int64GetDatum(metadata->nPendingHeapTuples); =20 diff --git a/contrib/pageinspect/gistfuncs.c b/contrib/pageinspect/gistfunc= s.c index 89678d377c7b..23a4b49771d4 100644 --- a/contrib/pageinspect/gistfuncs.c +++ b/contrib/pageinspect/gistfuncs.c @@ -177,7 +177,7 @@ gist_page_items_bytea(PG_FUNCTION_ARGS) =20 memset(nulls, 0, sizeof(nulls)); =20 - values[0] =3D UInt16GetDatum(offset); + values[0] =3D Int16GetDatum(offset); values[1] =3D ItemPointerGetDatum(&itup->t_tid); values[2] =3D Int32GetDatum((int) IndexTupleSize(itup)); =20 @@ -284,7 +284,7 @@ gist_page_items(PG_FUNCTION_ARGS) =20 memset(nulls, 0, sizeof(nulls)); =20 - values[0] =3D UInt16GetDatum(offset); + values[0] =3D Int16GetDatum(offset); values[1] =3D ItemPointerGetDatum(&itup->t_tid); values[2] =3D Int32GetDatum((int) IndexTupleSize(itup)); values[3] =3D BoolGetDatum(ItemIdIsDead(id)); diff --git a/contrib/pg_buffercache/pg_buffercache_pages.c b/contrib/pg_buf= fercache/pg_buffercache_pages.c index 1ec2cf0e6f46..bf2e6c972202 100644 --- a/contrib/pg_buffercache/pg_buffercache_pages.c +++ b/contrib/pg_buffercache/pg_buffercache_pages.c @@ -192,7 +192,7 @@ pg_buffercache_pages(PG_FUNCTION_ARGS) nulls[5] =3D false; values[6] =3D BoolGetDatum(isdirty); nulls[6] =3D false; - values[7] =3D UInt16GetDatum(usagecount); + values[7] =3D Int16GetDatum(usagecount); nulls[7] =3D false; /* unused for v1.0 callers, but the array is always long enough */ values[8] =3D Int32GetDatum(pinning_backends); --=20 2.53.0 --D742/kIVTjGERCcK Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=0002-Fix-more-Datum-conversion-inconsistencies.patch Content-Transfer-Encoding: quoted-printable =46rom 508b5dffde0f81255bbf9133492bfb5071bfb5dc Mon Sep 17 00:00:00 2001 =46rom: Michael Paquier Date: Tue, 28 Apr 2026 14:02:24 +0900 Subject: [PATCH 2/2] Fix more Datum conversion inconsistencies This is a continuation of the work done in the previous commit, that has undone the work of 6dcfac9696cb. The *GetDatum() macros for output should match with what the SQL functions use as DatumGet*() in input. Aleksander has spotted some of the areas patched here, for pageinspect. I have spotted the rest while digging into the state of the tree. There is no actual behavior change after this commit, since all the affected values are small enough that the signed bit is never used. Author: Aleksander Alekseev Author: Michael Paquier Discussion: https://postgr.es/m/CAJ7c6TMcGu8qmRe1gZfJ-gOzVnZq-t=3Dfwn-UuySt= x1w6ZyydMw@mail.gmail.com --- src/backend/access/gin/ginlogic.c | 6 +++--- src/backend/access/transam/xlogfuncs.c | 2 +- src/backend/catalog/pg_proc.c | 4 ++-- src/backend/utils/adt/lockfuncs.c | 10 +++++----- contrib/pageinspect/brinfuncs.c | 8 ++++---- contrib/pageinspect/btreefuncs.c | 2 +- contrib/pageinspect/ginfuncs.c | 2 +- contrib/pageinspect/gistfuncs.c | 4 ++-- contrib/pageinspect/heapfuncs.c | 18 +++++++++--------- contrib/pageinspect/rawpage.c | 14 +++++++------- contrib/pg_logicalinspect/pg_logicalinspect.c | 8 ++++---- contrib/pg_walinspect/pg_walinspect.c | 14 +++++++------- contrib/pgstattuple/pgstatindex.c | 2 +- 13 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/backend/access/gin/ginlogic.c b/src/backend/access/gin/gin= logic.c index e851d49f74de..e59d655da623 100644 --- a/src/backend/access/gin/ginlogic.c +++ b/src/backend/access/gin/ginlogic.c @@ -75,7 +75,7 @@ directBoolConsistentFn(GinScanKey key) PointerGetDatum(key->entryRes), UInt16GetDatum(key->strategy), key->query, - UInt32GetDatum(key->nuserentries), + Int32GetDatum(key->nuserentries), PointerGetDatum(key->extra_data), PointerGetDatum(&key->recheckCurItem), PointerGetDatum(key->queryValues), @@ -93,7 +93,7 @@ directTriConsistentFn(GinScanKey key) PointerGetDatum(key->entryRes), UInt16GetDatum(key->strategy), key->query, - UInt32GetDatum(key->nuserentries), + Int32GetDatum(key->nuserentries), PointerGetDatum(key->extra_data), PointerGetDatum(key->queryValues), PointerGetDatum(key->queryCategories))); @@ -114,7 +114,7 @@ shimBoolConsistentFn(GinScanKey key) PointerGetDatum(key->entryRes), UInt16GetDatum(key->strategy), key->query, - UInt32GetDatum(key->nuserentries), + Int32GetDatum(key->nuserentries), PointerGetDatum(key->extra_data), PointerGetDatum(key->queryValues), PointerGetDatum(key->queryCategories))); diff --git a/src/backend/access/transam/xlogfuncs.c b/src/backend/access/tr= ansam/xlogfuncs.c index 0f5979691e6b..207da27d0347 100644 --- a/src/backend/access/transam/xlogfuncs.c +++ b/src/backend/access/transam/xlogfuncs.c @@ -448,7 +448,7 @@ pg_walfile_name_offset(PG_FUNCTION_ARGS) */ xrecoff =3D XLogSegmentOffset(locationpoint, wal_segment_size); =20 - values[1] =3D UInt32GetDatum(xrecoff); + values[1] =3D Int32GetDatum(xrecoff); isnull[1] =3D false; =20 /* diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c index 5df4b3f7a91e..4c6dfb5ca908 100644 --- a/src/backend/catalog/pg_proc.c +++ b/src/backend/catalog/pg_proc.c @@ -342,8 +342,8 @@ ProcedureCreate(const char *procedureName, values[Anum_pg_proc_proretset - 1] =3D BoolGetDatum(returnsSet); values[Anum_pg_proc_provolatile - 1] =3D CharGetDatum(volatility); values[Anum_pg_proc_proparallel - 1] =3D CharGetDatum(parallel); - values[Anum_pg_proc_pronargs - 1] =3D UInt16GetDatum(parameterCount); - values[Anum_pg_proc_pronargdefaults - 1] =3D UInt16GetDatum(list_length(p= arameterDefaults)); + values[Anum_pg_proc_pronargs - 1] =3D Int16GetDatum(parameterCount); + values[Anum_pg_proc_pronargdefaults - 1] =3D Int16GetDatum(list_length(pa= rameterDefaults)); values[Anum_pg_proc_prorettype - 1] =3D ObjectIdGetDatum(returnType); values[Anum_pg_proc_proargtypes - 1] =3D PointerGetDatum(parameterTypes); if (allParameterTypes !=3D PointerGetDatum(NULL)) diff --git a/src/backend/utils/adt/lockfuncs.c b/src/backend/utils/adt/lock= funcs.c index dc58e9cb0a6d..949b242322cb 100644 --- a/src/backend/utils/adt/lockfuncs.c +++ b/src/backend/utils/adt/lockfuncs.c @@ -271,7 +271,7 @@ pg_lock_status(PG_FUNCTION_ARGS) case LOCKTAG_PAGE: values[1] =3D ObjectIdGetDatum(instance->locktag.locktag_field1); values[2] =3D ObjectIdGetDatum(instance->locktag.locktag_field2); - values[3] =3D UInt32GetDatum(instance->locktag.locktag_field3); + values[3] =3D Int32GetDatum(instance->locktag.locktag_field3); nulls[4] =3D true; nulls[5] =3D true; nulls[6] =3D true; @@ -282,8 +282,8 @@ pg_lock_status(PG_FUNCTION_ARGS) case LOCKTAG_TUPLE: values[1] =3D ObjectIdGetDatum(instance->locktag.locktag_field1); values[2] =3D ObjectIdGetDatum(instance->locktag.locktag_field2); - values[3] =3D UInt32GetDatum(instance->locktag.locktag_field3); - values[4] =3D UInt16GetDatum(instance->locktag.locktag_field4); + values[3] =3D Int32GetDatum(instance->locktag.locktag_field3); + values[4] =3D Int16GetDatum(instance->locktag.locktag_field4); nulls[5] =3D true; nulls[6] =3D true; nulls[7] =3D true; @@ -402,12 +402,12 @@ pg_lock_status(PG_FUNCTION_ARGS) values[1] =3D ObjectIdGetDatum(GET_PREDICATELOCKTARGETTAG_DB(*predTag)); values[2] =3D ObjectIdGetDatum(GET_PREDICATELOCKTARGETTAG_RELATION(*pred= Tag)); if (lockType =3D=3D PREDLOCKTAG_TUPLE) - values[4] =3D UInt16GetDatum(GET_PREDICATELOCKTARGETTAG_OFFSET(*predTag= )); + values[4] =3D Int16GetDatum(GET_PREDICATELOCKTARGETTAG_OFFSET(*predTag)= ); else nulls[4] =3D true; if ((lockType =3D=3D PREDLOCKTAG_TUPLE) || (lockType =3D=3D PREDLOCKTAG_PAGE)) - values[3] =3D UInt32GetDatum(GET_PREDICATELOCKTARGETTAG_PAGE(*predTag)); + values[3] =3D Int32GetDatum(GET_PREDICATELOCKTARGETTAG_PAGE(*predTag)); else nulls[3] =3D true; =20 diff --git a/contrib/pageinspect/brinfuncs.c b/contrib/pageinspect/brinfunc= s.c index 309b9522f902..c64124b5b020 100644 --- a/contrib/pageinspect/brinfuncs.c +++ b/contrib/pageinspect/brinfuncs.c @@ -246,7 +246,7 @@ brin_page_items(PG_FUNCTION_ARGS) =20 if (unusedItem) { - values[0] =3D UInt16GetDatum(offset); + values[0] =3D Int32GetDatum(offset); nulls[1] =3D true; nulls[2] =3D true; nulls[3] =3D true; @@ -259,7 +259,7 @@ brin_page_items(PG_FUNCTION_ARGS) { int att =3D attno - 1; =20 - values[0] =3D UInt16GetDatum(offset); + values[0] =3D Int32GetDatum(offset); switch (TupleDescAttr(rsinfo->setDesc, 1)->atttypid) { case INT8OID: @@ -267,12 +267,12 @@ brin_page_items(PG_FUNCTION_ARGS) break; case INT4OID: /* support for old extension version */ - values[1] =3D UInt32GetDatum(dtup->bt_blkno); + values[1] =3D Int32GetDatum(dtup->bt_blkno); break; default: elog(ERROR, "incorrect output types"); } - values[2] =3D UInt16GetDatum(attno); + values[2] =3D Int32GetDatum(attno); values[3] =3D BoolGetDatum(dtup->bt_columns[att].bv_allnulls); values[4] =3D BoolGetDatum(dtup->bt_columns[att].bv_hasnulls); values[5] =3D BoolGetDatum(dtup->bt_placeholder); diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefu= ncs.c index 62c905c6e7c2..3381e7cc2a74 100644 --- a/contrib/pageinspect/btreefuncs.c +++ b/contrib/pageinspect/btreefuncs.c @@ -509,7 +509,7 @@ bt_page_print_tuples(ua_page_items *uargs) memset(nulls, 0, sizeof(nulls)); values[j++] =3D Int16GetDatum(offset); values[j++] =3D ItemPointerGetDatum(&itup->t_tid); - values[j++] =3D Int32GetDatum((int) IndexTupleSize(itup)); + values[j++] =3D Int16GetDatum(IndexTupleSize(itup)); values[j++] =3D BoolGetDatum(IndexTupleHasNulls(itup)); values[j++] =3D BoolGetDatum(IndexTupleHasVarwidths(itup)); =20 diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c index ebcc2b3db5c7..e4461db7f0a2 100644 --- a/contrib/pageinspect/ginfuncs.c +++ b/contrib/pageinspect/ginfuncs.c @@ -258,7 +258,7 @@ gin_leafpage_items(PG_FUNCTION_ARGS) memset(nulls, 0, sizeof(nulls)); =20 values[0] =3D ItemPointerGetDatum(&cur->first); - values[1] =3D UInt16GetDatum(cur->nbytes); + values[1] =3D Int16GetDatum(cur->nbytes); =20 /* build an array of decoded item pointers */ tids =3D ginPostingListDecode(cur, &ndecoded); diff --git a/contrib/pageinspect/gistfuncs.c b/contrib/pageinspect/gistfunc= s.c index 23a4b49771d4..8f127d41ec49 100644 --- a/contrib/pageinspect/gistfuncs.c +++ b/contrib/pageinspect/gistfuncs.c @@ -179,7 +179,7 @@ gist_page_items_bytea(PG_FUNCTION_ARGS) =20 values[0] =3D Int16GetDatum(offset); values[1] =3D ItemPointerGetDatum(&itup->t_tid); - values[2] =3D Int32GetDatum((int) IndexTupleSize(itup)); + values[2] =3D Int16GetDatum(IndexTupleSize(itup)); =20 tuple_bytea =3D (bytea *) palloc(tuple_len + VARHDRSZ); SET_VARSIZE(tuple_bytea, tuple_len + VARHDRSZ); @@ -286,7 +286,7 @@ gist_page_items(PG_FUNCTION_ARGS) =20 values[0] =3D Int16GetDatum(offset); values[1] =3D ItemPointerGetDatum(&itup->t_tid); - values[2] =3D Int32GetDatum((int) IndexTupleSize(itup)); + values[2] =3D Int16GetDatum(IndexTupleSize(itup)); values[3] =3D BoolGetDatum(ItemIdIsDead(id)); =20 if (index_columns) diff --git a/contrib/pageinspect/heapfuncs.c b/contrib/pageinspect/heapfunc= s.c index 4f0f3bd53e74..7be4770dc84b 100644 --- a/contrib/pageinspect/heapfuncs.c +++ b/contrib/pageinspect/heapfuncs.c @@ -189,10 +189,10 @@ heap_page_items(PG_FUNCTION_ARGS) lp_flags =3D ItemIdGetFlags(id); lp_len =3D ItemIdGetLength(id); =20 - values[0] =3D UInt16GetDatum(inter_call_data->offset); - values[1] =3D UInt16GetDatum(lp_offset); - values[2] =3D UInt16GetDatum(lp_flags); - values[3] =3D UInt16GetDatum(lp_len); + values[0] =3D Int16GetDatum(inter_call_data->offset); + values[1] =3D Int16GetDatum(lp_offset); + values[2] =3D Int16GetDatum(lp_flags); + values[3] =3D Int16GetDatum(lp_len); =20 /* * We do just enough validity checking to make sure we don't reference @@ -209,13 +209,13 @@ heap_page_items(PG_FUNCTION_ARGS) /* Extract information from the tuple header */ tuphdr =3D (HeapTupleHeader) PageGetItem(page, id); =20 - values[4] =3D UInt32GetDatum(HeapTupleHeaderGetRawXmin(tuphdr)); - values[5] =3D UInt32GetDatum(HeapTupleHeaderGetRawXmax(tuphdr)); + values[4] =3D TransactionIdGetDatum(HeapTupleHeaderGetRawXmin(tuphdr)); + values[5] =3D TransactionIdGetDatum(HeapTupleHeaderGetRawXmax(tuphdr)); /* shared with xvac */ - values[6] =3D UInt32GetDatum(HeapTupleHeaderGetRawCommandId(tuphdr)); + values[6] =3D Int32GetDatum(HeapTupleHeaderGetRawCommandId(tuphdr)); values[7] =3D PointerGetDatum(&tuphdr->t_ctid); - values[8] =3D UInt32GetDatum(tuphdr->t_infomask2); - values[9] =3D UInt32GetDatum(tuphdr->t_infomask); + values[8] =3D Int32GetDatum(tuphdr->t_infomask2); + values[9] =3D Int32GetDatum(tuphdr->t_infomask); values[10] =3D UInt8GetDatum(tuphdr->t_hoff); =20 /* diff --git a/contrib/pageinspect/rawpage.c b/contrib/pageinspect/rawpage.c index f3996dc39fcd..d136593edb26 100644 --- a/contrib/pageinspect/rawpage.c +++ b/contrib/pageinspect/rawpage.c @@ -284,8 +284,8 @@ page_header(PG_FUNCTION_ARGS) } else values[0] =3D LSNGetDatum(lsn); - values[1] =3D UInt16GetDatum(pageheader->pd_checksum); - values[2] =3D UInt16GetDatum(pageheader->pd_flags); + values[1] =3D Int16GetDatum(pageheader->pd_checksum); + values[2] =3D Int16GetDatum(pageheader->pd_flags); =20 /* pageinspect >=3D 1.10 uses int4 instead of int2 for those fields */ switch (TupleDescAttr(tupdesc, 3)->atttypid) @@ -294,10 +294,10 @@ page_header(PG_FUNCTION_ARGS) Assert(TupleDescAttr(tupdesc, 4)->atttypid =3D=3D INT2OID && TupleDescAttr(tupdesc, 5)->atttypid =3D=3D INT2OID && TupleDescAttr(tupdesc, 6)->atttypid =3D=3D INT2OID); - values[3] =3D UInt16GetDatum(pageheader->pd_lower); - values[4] =3D UInt16GetDatum(pageheader->pd_upper); - values[5] =3D UInt16GetDatum(pageheader->pd_special); - values[6] =3D UInt16GetDatum(PageGetPageSize(page)); + values[3] =3D Int16GetDatum(pageheader->pd_lower); + values[4] =3D Int16GetDatum(pageheader->pd_upper); + values[5] =3D Int16GetDatum(pageheader->pd_special); + values[6] =3D Int16GetDatum(PageGetPageSize(page)); break; case INT4OID: Assert(TupleDescAttr(tupdesc, 4)->atttypid =3D=3D INT4OID && @@ -313,7 +313,7 @@ page_header(PG_FUNCTION_ARGS) break; } =20 - values[7] =3D UInt16GetDatum(PageGetPageLayoutVersion(page)); + values[7] =3D Int16GetDatum(PageGetPageLayoutVersion(page)); values[8] =3D TransactionIdGetDatum(pageheader->pd_prune_xid); =20 /* Build and return the tuple. */ diff --git a/contrib/pg_logicalinspect/pg_logicalinspect.c b/contrib/pg_log= icalinspect/pg_logicalinspect.c index 9420fa5e0c7c..389394de66b3 100644 --- a/contrib/pg_logicalinspect/pg_logicalinspect.c +++ b/contrib/pg_logicalinspect/pg_logicalinspect.c @@ -117,9 +117,9 @@ pg_get_logical_snapshot_meta(PG_FUNCTION_ARGS) /* Validate and restore the snapshot to 'ondisk' */ SnapBuildRestoreSnapshot(&ondisk, lsn, CurrentMemoryContext, false); =20 - values[i++] =3D UInt32GetDatum(ondisk.magic); + values[i++] =3D Int32GetDatum(ondisk.magic); values[i++] =3D Int64GetDatum((int64) ondisk.checksum); - values[i++] =3D UInt32GetDatum(ondisk.version); + values[i++] =3D Int32GetDatum(ondisk.version); =20 Assert(i =3D=3D PG_GET_LOGICAL_SNAPSHOT_META_COLS); =20 @@ -163,7 +163,7 @@ pg_get_logical_snapshot_info(PG_FUNCTION_ARGS) values[i++] =3D LSNGetDatum(ondisk.builder.last_serialized_snapshot); values[i++] =3D TransactionIdGetDatum(ondisk.builder.next_phase_at); =20 - values[i++] =3D UInt32GetDatum(ondisk.builder.committed.xcnt); + values[i++] =3D Int32GetDatum(ondisk.builder.committed.xcnt); if (ondisk.builder.committed.xcnt > 0) { Datum *arrayelems; @@ -180,7 +180,7 @@ pg_get_logical_snapshot_info(PG_FUNCTION_ARGS) else nulls[i++] =3D true; =20 - values[i++] =3D UInt32GetDatum(ondisk.builder.catchange.xcnt); + values[i++] =3D Int32GetDatum(ondisk.builder.catchange.xcnt); if (ondisk.builder.catchange.xcnt > 0) { Datum *arrayelems; diff --git a/contrib/pg_walinspect/pg_walinspect.c b/contrib/pg_walinspect/= pg_walinspect.c index 4cf6e41e2f5c..a172f9e2b407 100644 --- a/contrib/pg_walinspect/pg_walinspect.c +++ b/contrib/pg_walinspect/pg_walinspect.c @@ -230,9 +230,9 @@ GetWALRecordInfo(XLogReaderState *record, Datum *values, values[i++] =3D TransactionIdGetDatum(XLogRecGetXid(record)); values[i++] =3D CStringGetTextDatum(desc.rm_name); values[i++] =3D CStringGetTextDatum(record_type); - values[i++] =3D UInt32GetDatum(XLogRecGetTotalLen(record)); - values[i++] =3D UInt32GetDatum(XLogRecGetDataLen(record)); - values[i++] =3D UInt32GetDatum(fpi_len); + values[i++] =3D Int32GetDatum(XLogRecGetTotalLen(record)); + values[i++] =3D Int32GetDatum(XLogRecGetDataLen(record)); + values[i++] =3D Int32GetDatum(fpi_len); =20 if (rec_desc.len > 0) values[i++] =3D CStringGetTextDatum(rec_desc.data); @@ -357,10 +357,10 @@ GetWALBlockInfo(FunctionCallInfo fcinfo, XLogReaderSt= ate *record, * record_length, main_data_length, block_data_len, and * block_fpi_length outputs */ - values[i++] =3D UInt32GetDatum(XLogRecGetTotalLen(record)); - values[i++] =3D UInt32GetDatum(XLogRecGetDataLen(record)); - values[i++] =3D UInt32GetDatum(block_data_len); - values[i++] =3D UInt32GetDatum(block_fpi_len); + values[i++] =3D Int32GetDatum(XLogRecGetTotalLen(record)); + values[i++] =3D Int32GetDatum(XLogRecGetDataLen(record)); + values[i++] =3D Int32GetDatum(block_data_len); + values[i++] =3D Int32GetDatum(block_fpi_len); =20 /* block_fpi_info (text array) output */ if (block_fpi_info) diff --git a/contrib/pgstattuple/pgstatindex.c b/contrib/pgstattuple/pgstat= index.c index 3a3f2637bd95..8951ad0aac47 100644 --- a/contrib/pgstattuple/pgstatindex.c +++ b/contrib/pgstattuple/pgstatindex.c @@ -586,7 +586,7 @@ pgstatginindex_internal(Oid relid, FunctionCallInfo fci= nfo) elog(ERROR, "return type must be a row type"); =20 values[0] =3D Int32GetDatum(stats.version); - values[1] =3D UInt32GetDatum(stats.pending_pages); + values[1] =3D Int32GetDatum(stats.pending_pages); values[2] =3D Int64GetDatum(stats.pending_tuples); =20 /* --=20 2.53.0 --D742/kIVTjGERCcK-- --BUvVvcythNfp1i9o Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmnwQfsACgkQnvQgOdby QH1WFQ/5AZCmyNAmbAetJoaheVBVWPAz/MXMd4pirzYzRkwkKjas6X2WHSbn3oV1 MoufHkabKHdLw58gI/+oQTwm1j4Zo4p/UgurG6dRVvLkIk+m4GS4b2IqUg31GmPP N5AccZ3uUG00mvJBK2oAkeqoBTvO5n2KCzOeq2akPHtt6E7B3360QX807KMrZFO9 5P7wb6dqhIZ8c4pZd1XSgLqtv1bsbbXuLZBhvr6HUabP0o6kAgTx+cKV0hHMQnLn RtIAF/7w/Gm8TztD3CIsMKw3Vh7P0dcAxmCNZbuCNCnxrglAcw3Ht/d+NZ2pUAkR 4Nm4/vyK04UrGHxUamRQMwBKfIkabL/PxLLp3mmCqM6OKMd64gPNlskTBwhJVB+u UtKqVpis9D9RwmDFiXnD9STcA+3j/E8YdCqZPksbXLFxhkNAqWuDbJ4cjtBNCk4o IwSLdpM/nFfGff/5481bxRlgd7un9HFycHotFhlWjP+iTX1rkMa/ws+WXk49dvmC pBpQzassl/Qm1oLVag29D+VDYycXA5pRIFXCHo6y7AeypYRep6bALpqphT7o+7+w n2oEOhMiXjY08+hNDLayjaUd6EnHPlKhYjGwAKWohVASNqZRwWzDwHyhQESIGxJp KWwHh+3IEh+ZTjEKlcTMyLJXGddAXuauo8ChxDKuIPCvYDM2o0A= =HJCo -----END PGP SIGNATURE----- --BUvVvcythNfp1i9o--