On Fri, Dec 05, 2025 at 04:41:41PM +0900, Michael Paquier wrote:
> Thanks.  That's a lot to digest.

Digesting a bit more now..

-   char       *ret = palloc(sizeof(buf));
+   char       *ret = palloc_array(char, sizeof(buf))

This one in dumputils.c is right, but I am not sure that it is an
improvement compared to the statu-quo.

Here is a list of the files where I have noticed tha addition of
casts, which are not required anymore:
brin_tuple.c.
gistbuildbuffers.c.
genam.c.
nbtdedup.c.
nbtree.c.
nbtsort.c.
index.c
execGrouping.c
execMain.c
relnode.c
partbounds.c
mcv.c
spell.c
arrayfuncs.c
partcache.c

Perhaps you have used a semi-automatic process and missed these?
Okay, some of these relied on a "Data" structure for the size vs
pointer for the allocation, but the results are the same.

-       IndexOrderByDistance *distances =
-           palloc(sizeof(distances[0]) * so->numberOfOrderBys);

Okay, this one in spgscan.c is not the usual project style.  Correct,
still funky.

            b_checkargnulls =
-               palloc(sizeof(LLVMBasicBlockRef *) * op->d.func.nargs);
+               palloc_array(LLVMBasicBlockRef *, op->d.func.nargs);

This one in llvmjit_expr.c was causing a compilation failure.  I am
not exactly sure why, but discarded for now.  I got a reproduction
locally as well as in the CI.

-   node->tsm_state = palloc0(sizeof(BernoulliSamplerData));
+   node->tsm_state = palloc0_object(BernoulliSamplerData); 

One can argue that this one in bernouilli.c is not really necessary,
tsm_state is actually a void *.

Among the 300-ish files changed in the backend, 48 of them had their
builds slightly change.  The list of them is attached.

So that's everything for the trivial changes, with 4601e7f1c708 for
src/backend/ and 0c3c5c3b06a3 for the rest.
--
Michael
src/backend/replication/syncrep.c
src/backend/replication/logical/reorderbuffer.c
src/backend/replication/logical/snapbuild.c
src/backend/partitioning/partbounds.c
src/backend/access/gist/gistbuildbuffers.c
src/backend/access/spgist/spgtextproc.c
src/backend/access/spgist/spgscan.c
src/backend/access/spgist/spgdoinsert.c
src/backend/access/gin/ginscan.c
src/backend/access/gin/ginbulk.c
src/backend/access/transam/parallel.c
src/backend/access/transam/multixact.c
src/backend/access/nbtree/nbtree.c
src/backend/access/hash/hash.c
src/backend/statistics/dependencies.c
src/backend/statistics/extended_stats.c
src/backend/storage/lmgr/predicate.c
src/backend/storage/lmgr/lock.c
src/backend/storage/ipc/procarray.c
src/backend/optimizer/plan/analyzejoins.c
src/backend/optimizer/plan/planner.c
src/backend/optimizer/plan/initsplan.c
src/backend/optimizer/util/appendinfo.c
src/backend/optimizer/util/extendplan.c
src/backend/optimizer/util/plancat.c
src/backend/optimizer/path/indxpath.c
src/backend/optimizer/path/joinrels.c
src/backend/optimizer/prep/prepjointree.c
src/backend/executor/nodeIndexscan.c
src/backend/executor/nodeAgg.c
src/backend/executor/nodeGatherMerge.c
src/backend/executor/nodeHashjoin.c
src/backend/executor/spi.c
src/backend/executor/execExpr.c
src/backend/executor/nodeIndexonlyscan.c
src/backend/executor/nodeProjectSet.c
src/backend/executor/nodeModifyTable.c
src/backend/catalog/dependency.c
src/backend/parser/analyze.c
src/backend/utils/cache/lsyscache.c
src/backend/utils/cache/plancache.c
src/backend/utils/adt/jsonpath_exec.c
src/backend/utils/adt/array_typanalyze.c
src/backend/utils/adt/jsonb_gin.c
src/backend/utils/adt/rangetypes_gist.c
src/backend/utils/adt/timestamp.c
src/backend/utils/adt/numeric.c
src/backend/postmaster/walsummarizer.c

Attachment: signature.asc
Description: PGP signature

Reply via email to