From: | Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> |
---|---|
To: | Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com> |
Cc: | Justin Pryzby <pryzby(at)telsasoft(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c) |
Date: | 2022-07-07 17:01:25 |
Message-ID: | CAEudQAp0pLicq-pvyCMLMkWtF2kBqtySgfpiCyov=SziVD8AVw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Em qui., 7 de jul. de 2022 às 09:45, Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
escreveu:
> Em qui., 7 de jul. de 2022 às 08:00, Peter Eisentraut <
> peter(dot)eisentraut(at)enterprisedb(dot)com> escreveu:
> >diff --git a/src/backend/access/transam/twophase.c
> b/src/backend/access/transam/twophase.c
> >index 41b31c5c6f..803d169f57 100644
> >--- a/src/backend/access/transam/twophase.c
> >+++ b/src/backend/access/transam/twophase.c
> >@@ -780,8 +780,8 @@ pg_prepared_xact(PG_FUNCTION_ARGS)
> > {
> > GlobalTransaction gxact = &status->array[status->currIdx++];
> > PGPROC *proc = &ProcGlobal->allProcs[gxact->pgprocno];
> >- Datum values[5];
> >- bool nulls[5];
> >+ Datum values[5] = {0};
> >+ bool nulls[5] = {0};
>
> values variable no initialization or MemSet needed.
>
> diff --git a/src/backend/access/transam/xlogfuncs.c
> b/src/backend/access/transam/xlogfuncs.c
> index 02bd919ff6..61e0f4a29c 100644
> --- a/src/backend/access/transam/xlogfuncs.c
> +++ b/src/backend/access/transam/xlogfuncs.c
> @@ -106,8 +106,8 @@ pg_backup_stop(PG_FUNCTION_ARGS)
> {
> #define PG_STOP_BACKUP_V2_COLS 3
> TupleDesc tupdesc;
> - Datum values[PG_STOP_BACKUP_V2_COLS];
> - bool nulls[PG_STOP_BACKUP_V2_COLS];
> + Datum values[PG_STOP_BACKUP_V2_COLS] = {0};
> + bool nulls[PG_STOP_BACKUP_V2_COLS] = {0};
>
> Same, values variable no initialization or MemSet needed.
>
> diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
> index 5f1726c095..17ff617fba 100644
> --- a/src/backend/catalog/aclchk.c
> +++ b/src/backend/catalog/aclchk.c
> @@ -1188,9 +1188,6 @@ SetDefaultACL(InternalDefaultACL *iacls)
> Acl *old_acl;
> Acl *new_acl;
> HeapTuple newtuple;
> - Datum values[Natts_pg_default_acl];
> - bool nulls[Natts_pg_default_acl];
> - bool replaces[Natts_pg_default_acl];
> int noldmembers;
> int nnewmembers;
> Oid *oldmembers;
> @@ -1341,13 +1338,11 @@ SetDefaultACL(InternalDefaultACL *iacls)
> }
> else
> {
> + Datum values[Natts_pg_default_acl] = {0};
> + bool nulls[Natts_pg_default_acl] = {0};
>
> replaces, can be reduced more one level.
>
> line 1365:
> else
> {
> +bool replaces[Natts_pg_default_acl] = {0};
> defAclOid = ((Form_pg_default_acl) GETSTRUCT(tuple))->oid;
>
> please, wait a minute, I will produce a new version of your patch, with
> some changes for your review.
>
Attached the v1 of your patch.
I think that all is safe to switch MemSet by {0}.
regards,
Ranier Vilela
Attachment | Content-Type | Size |
---|---|---|
v1-0001-WIP-Replace-MemSet-calls-with-struct-initialization.patch | application/octet-stream | 104.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Justin Pryzby | 2022-07-07 17:10:19 | Re: pg15b2: large objects lost on upgrade |
Previous Message | Nathan Bossart | 2022-07-07 16:59:08 | Re: archive modules |