From: reshke Date: Wed, 7 Jan 2026 19:38:52 +0000 Subject: [PATCH v20260901 1/3] Modernize coding in GIN pageinspect functions. 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 Reviewed-by: Chao Li Reviewed-by: Japin Li Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com --- contrib/pageinspect/ginfuncs.c | 60 +++++++++++++++++----------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c index 058ad52b671..3fe1412fe26 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) @@ -108,8 +108,8 @@ gin_page_opaque_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); @@ -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); -- 2.53.0 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=v20260901-0002-GIN-pageinspect-support-for-entry-tree-and.patch