agora inbox for pgsql-hackers@postgresql.org
help / color / mirror / Atom feedFrom: reshke <reshke@double.cloud>
Subject: [PATCH v15 1/3] Modernize coding in GIN pageinspect functions.
Date: Wed, 7 Jan 2026 19:38:52 +0000
This patch switches palloc to our newly preferred palloc_array and modernizes
ereport calls, switching from list-style to polymorphic ereport
calls. This patch also fixes whitespace/tab issues, enforcing a single style.
across existing ginfuncs.c code.
Inspired by Peter Eisentraut's patch in the thread.
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Japin Li <japinli@hotmail.com>
Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
contrib/pageinspect/ginfuncs.c | 58 +++++++++++++++++-----------------
1 file changed, 29 insertions(+), 29 deletions(-)
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index ebcc2b3db5c..b7bd7a3f4cd 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -38,8 +38,8 @@ gin_metapage_info(PG_FUNCTION_ARGS)
if (!superuser())
ereport(ERROR,
- (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("must be superuser to use raw page functions")));
+ errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+ errmsg("must be superuser to use raw page functions"));
page = get_page_from_raw(raw_page);
@@ -48,20 +48,20 @@ gin_metapage_info(PG_FUNCTION_ARGS)
if (PageGetSpecialSize(page) != MAXALIGN(sizeof(GinPageOpaqueData)))
ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("input page is not a valid GIN metapage"),
- errdetail("Expected special size %d, got %d.",
- (int) MAXALIGN(sizeof(GinPageOpaqueData)),
- (int) PageGetSpecialSize(page))));
+ errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("input page is not a valid GIN metapage"),
+ errdetail("Expected special size %d, got %d.",
+ (int) MAXALIGN(sizeof(GinPageOpaqueData)),
+ (int) PageGetSpecialSize(page)));
opaq = GinPageGetOpaque(page);
if (opaq->flags != GIN_META)
ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("input page is not a GIN metapage"),
- errdetail("Flags %04X, expected %04X",
- opaq->flags, GIN_META)));
+ errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("input page is not a GIN metapage"),
+ errdetail("Flags %04X, expected %04X",
+ opaq->flags, GIN_META));
/* Build a tuple descriptor for our result type */
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
@@ -118,11 +118,11 @@ gin_page_opaque_info(PG_FUNCTION_ARGS)
if (PageGetSpecialSize(page) != MAXALIGN(sizeof(GinPageOpaqueData)))
ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("input page is not a valid GIN data leaf page"),
- errdetail("Expected special size %d, got %d.",
- (int) MAXALIGN(sizeof(GinPageOpaqueData)),
- (int) PageGetSpecialSize(page))));
+ errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("input page is not a valid GIN data leaf page"),
+ errdetail("Expected special size %d, got %d.",
+ (int) MAXALIGN(sizeof(GinPageOpaqueData)),
+ (int) PageGetSpecialSize(page)));
opaq = GinPageGetOpaque(page);
@@ -184,8 +184,8 @@ gin_leafpage_items(PG_FUNCTION_ARGS)
if (!superuser())
ereport(ERROR,
- (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("must be superuser to use raw page functions")));
+ errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+ errmsg("must be superuser to use raw page functions"));
if (SRF_IS_FIRSTCALL())
{
@@ -207,20 +207,20 @@ gin_leafpage_items(PG_FUNCTION_ARGS)
if (PageGetSpecialSize(page) != MAXALIGN(sizeof(GinPageOpaqueData)))
ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("input page is not a valid GIN data leaf page"),
- errdetail("Expected special size %d, got %d.",
- (int) MAXALIGN(sizeof(GinPageOpaqueData)),
- (int) PageGetSpecialSize(page))));
+ errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("input page is not a valid GIN data leaf page"),
+ errdetail("Expected special size %d, got %d.",
+ (int) MAXALIGN(sizeof(GinPageOpaqueData)),
+ (int) PageGetSpecialSize(page)));
opaq = GinPageGetOpaque(page);
if (opaq->flags != (GIN_DATA | GIN_LEAF | GIN_COMPRESSED))
ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("input page is not a compressed GIN data leaf page"),
- errdetail("Flags %04X, expected %04X",
- opaq->flags,
- (GIN_DATA | GIN_LEAF | GIN_COMPRESSED))));
+ errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("input page is not a compressed GIN data leaf page"),
+ errdetail("Flags %04X, expected %04X",
+ opaq->flags,
+ (GIN_DATA | GIN_LEAF | GIN_COMPRESSED)));
inter_call_data = palloc_object(gin_leafpage_items_state);
@@ -262,7 +262,7 @@ gin_leafpage_items(PG_FUNCTION_ARGS)
/* build an array of decoded item pointers */
tids = ginPostingListDecode(cur, &ndecoded);
- tids_datum = (Datum *) palloc(ndecoded * sizeof(Datum));
+ tids_datum = palloc_array(Datum, ndecoded);
for (i = 0; i < ndecoded; i++)
tids_datum[i] = ItemPointerGetDatum(&tids[i]);
values[2] = PointerGetDatum(construct_array_builtin(tids_datum, ndecoded, TIDOID));
--
2.43.0
--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
filename=v15-0002-GIN-pageinspect-support-for-entry-tree-and-posti.patch
view thread (343+ messages) latest in thread
Message-ID: <no-message-id-1157287@localhost>
Permalink: ../../no-message-id-1157287@localhost/
Also on: postgresql.org/message-id/no-message-id-1157287@localhost
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: reshke@double.cloud
Subject: Re: [PATCH v15 1/3] Modernize coding in GIN pageinspect functions.
In-Reply-To: <no-message-id-1157287@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox