Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c) - Mailing list pgsql-hackers

From Ranier Vilela
Subject Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)
Date
Msg-id CAEudQAoVLjgxMB9+GRKN=EEOpqOJ1O-Z2Npo2wRXAugYLt=_6w@mail.gmail.com
Whole thread Raw
In response to Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)  (Peter Eisentraut <peter.eisentraut@enterprisedb.com>)
Responses Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)
List pgsql-hackers
Em qui., 7 de jul. de 2022 às 08:00, Peter Eisentraut <peter.eisentraut@enterprisedb.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.

regards,
Ranier Vilela

pgsql-hackers by date:

Previous
From: "Zhao Rui"
Date:
Subject: Re:Improving RLS planning
Next
From: Fujii Masao
Date:
Subject: Re: Add checkpoint and redo LSN to LogCheckpointEnd log message