Replace many MemSet calls with struct initialization

This replaces all MemSet() calls with struct initialization where that
is easily and obviously possible.  (For example, some cases have to
worry about padding bits, so I left those.)

(The same could be done with appropriate memset() calls, but this
patch is part of an effort to phase out MemSet(), so it doesn't touch
memset() calls.)

Reviewed-by: Ranier Vilela <ranier.vf@gmail.com>
Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://www.postgresql.org/message-id/9847b13c-b785-f4e2-75c3-12ec77a3b05c@enterprisedb.com
This commit is contained in:
Peter Eisentraut 2022-07-16 08:42:15 +02:00
parent c94ae9d827
commit 9fd45870c1
51 changed files with 200 additions and 468 deletions

View File

@ -554,12 +554,10 @@ report_corruption_internal(Tuplestorestate *tupstore, TupleDesc tupdesc,
BlockNumber blkno, OffsetNumber offnum,
AttrNumber attnum, char *msg)
{
Datum values[HEAPCHECK_RELATION_COLS];
bool nulls[HEAPCHECK_RELATION_COLS];
Datum values[HEAPCHECK_RELATION_COLS] = {0};
bool nulls[HEAPCHECK_RELATION_COLS] = {0};
HeapTuple tuple;
MemSet(values, 0, sizeof(values));
MemSet(nulls, 0, sizeof(nulls));
values[0] = Int64GetDatum(blkno);
values[1] = Int32GetDatum(offnum);
values[2] = Int32GetDatum(attnum);

View File

@ -26,9 +26,7 @@ blcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
double *indexPages)
{
IndexOptInfo *index = path->indexinfo;
GenericCosts costs;
MemSet(&costs, 0, sizeof(costs));
GenericCosts costs = {0};
/* We have to visit all index tuples anyway */
costs.numIndexTuples = index->tuples;

View File

@ -202,7 +202,7 @@ brin_page_items(PG_FUNCTION_ARGS)
for (;;)
{
Datum values[7];
bool nulls[7];
bool nulls[7] = {0};
/*
* This loop is called once for every attribute of every tuple in the
@ -230,8 +230,6 @@ brin_page_items(PG_FUNCTION_ARGS)
else
attno++;
MemSet(nulls, 0, sizeof(nulls));
if (unusedItem)
{
values[0] = UInt16GetDatum(offset);
@ -334,7 +332,7 @@ brin_metapage_info(PG_FUNCTION_ARGS)
BrinMetaPageData *meta;
TupleDesc tupdesc;
Datum values[4];
bool nulls[4];
bool nulls[4] = {0};
HeapTuple htup;
if (!superuser())
@ -354,7 +352,6 @@ brin_metapage_info(PG_FUNCTION_ARGS)
/* Extract values from the metapage */
meta = (BrinMetaPageData *) PageGetContents(page);
MemSet(nulls, 0, sizeof(nulls));
values[0] = CStringGetTextDatum(psprintf("0x%08X", meta->brinMagic));
values[1] = Int32GetDatum(meta->brinVersion);
values[2] = Int32GetDatum(meta->pagesPerRange);

View File

@ -238,7 +238,7 @@ hash_page_stats(PG_FUNCTION_ARGS)
Page page;
int j;
Datum values[9];
bool nulls[9];
bool nulls[9] = {0};
HashPageStat stat;
HeapTuple tuple;
TupleDesc tupleDesc;
@ -261,8 +261,6 @@ hash_page_stats(PG_FUNCTION_ARGS)
elog(ERROR, "return type must be a row type");
tupleDesc = BlessTupleDesc(tupleDesc);
MemSet(nulls, 0, sizeof(nulls));
j = 0;
values[j++] = Int32GetDatum(stat.live_items);
values[j++] = Int32GetDatum(stat.dead_items);
@ -303,7 +301,7 @@ hash_page_items(PG_FUNCTION_ARGS)
Page page;
Datum result;
Datum values[3];
bool nulls[3];
bool nulls[3] = {0};
uint32 hashkey;
HeapTuple tuple;
FuncCallContext *fctx;
@ -361,8 +359,6 @@ hash_page_items(PG_FUNCTION_ARGS)
itup = (IndexTuple) PageGetItem(uargs->page, id);
MemSet(nulls, 0, sizeof(nulls));
j = 0;
values[j++] = Int32GetDatum((int32) uargs->offset);
values[j++] = PointerGetDatum(&itup->t_tid);
@ -409,7 +405,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
int i,
j;
Datum values[3];
bool nulls[3];
bool nulls[3] = {0};
uint32 *freep;
if (!superuser())
@ -495,8 +491,6 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
elog(ERROR, "return type must be a row type");
tupleDesc = BlessTupleDesc(tupleDesc);
MemSet(nulls, 0, sizeof(nulls));
j = 0;
values[j++] = Int64GetDatum((int64) bitmapblkno);
values[j++] = Int32GetDatum(bitmapbit);
@ -526,7 +520,7 @@ hash_metapage_info(PG_FUNCTION_ARGS)
int i,
j;
Datum values[16];
bool nulls[16];
bool nulls[16] = {0};
Datum spares[HASH_MAX_SPLITPOINTS];
Datum mapp[HASH_MAX_BITMAPS];
@ -544,8 +538,6 @@ hash_metapage_info(PG_FUNCTION_ARGS)
metad = HashPageGetMeta(page);
MemSet(nulls, 0, sizeof(nulls));
j = 0;
values[j++] = Int64GetDatum((int64) metad->hashm_magic);
values[j++] = Int64GetDatum((int64) metad->hashm_version);

View File

@ -507,8 +507,8 @@ Datum
heap_tuple_infomask_flags(PG_FUNCTION_ARGS)
{
#define HEAP_TUPLE_INFOMASK_COLS 2
Datum values[HEAP_TUPLE_INFOMASK_COLS];
bool nulls[HEAP_TUPLE_INFOMASK_COLS];
Datum values[HEAP_TUPLE_INFOMASK_COLS] = {0};
bool nulls[HEAP_TUPLE_INFOMASK_COLS] = {0};
uint16 t_infomask = PG_GETARG_INT16(0);
uint16 t_infomask2 = PG_GETARG_INT16(1);
int cnt = 0;
@ -530,10 +530,6 @@ heap_tuple_infomask_flags(PG_FUNCTION_ARGS)
bitcnt = pg_popcount((const char *) &t_infomask, sizeof(uint16)) +
pg_popcount((const char *) &t_infomask2, sizeof(uint16));
/* Initialize values and NULL flags arrays */
MemSet(values, 0, sizeof(values));
MemSet(nulls, 0, sizeof(nulls));
/* If no flags, return a set of empty arrays */
if (bitcnt <= 0)
{

View File

@ -814,12 +814,11 @@ apw_detach_shmem(int code, Datum arg)
static void
apw_start_leader_worker(void)
{
BackgroundWorker worker;
BackgroundWorker worker = {0};
BackgroundWorkerHandle *handle;
BgwHandleStatus status;
pid_t pid;
MemSet(&worker, 0, sizeof(BackgroundWorker));
worker.bgw_flags = BGWORKER_SHMEM_ACCESS;
worker.bgw_start_time = BgWorkerStart_ConsistentState;
strcpy(worker.bgw_library_name, "pg_prewarm");
@ -856,10 +855,9 @@ apw_start_leader_worker(void)
static void
apw_start_database_worker(void)
{
BackgroundWorker worker;
BackgroundWorker worker = {0};
BackgroundWorkerHandle *handle;
MemSet(&worker, 0, sizeof(BackgroundWorker));
worker.bgw_flags =
BGWORKER_SHMEM_ACCESS | BGWORKER_BACKEND_DATABASE_CONNECTION;
worker.bgw_start_time = BgWorkerStart_ConsistentState;

View File

@ -1854,8 +1854,8 @@ pg_stat_statements_info(PG_FUNCTION_ARGS)
{
pgssGlobalStats stats;
TupleDesc tupdesc;
Datum values[PG_STAT_STATEMENTS_INFO_COLS];
bool nulls[PG_STAT_STATEMENTS_INFO_COLS];
Datum values[PG_STAT_STATEMENTS_INFO_COLS] = {0};
bool nulls[PG_STAT_STATEMENTS_INFO_COLS] = {0};
if (!pgss || !pgss_hash)
ereport(ERROR,
@ -1866,9 +1866,6 @@ pg_stat_statements_info(PG_FUNCTION_ARGS)
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
elog(ERROR, "return type must be a row type");
MemSet(values, 0, sizeof(values));
MemSet(nulls, 0, sizeof(nulls));
/* Read global statistics for pg_stat_statements */
{
volatile pgssSharedState *s = (volatile pgssSharedState *) pgss;

View File

@ -75,7 +75,7 @@ pg_visibility_map(PG_FUNCTION_ARGS)
Buffer vmbuffer = InvalidBuffer;
TupleDesc tupdesc;
Datum values[2];
bool nulls[2];
bool nulls[2] = {0};
rel = relation_open(relid, AccessShareLock);
@ -88,7 +88,6 @@ pg_visibility_map(PG_FUNCTION_ARGS)
errmsg("invalid block number")));
tupdesc = pg_visibility_tupdesc(false, false);
MemSet(nulls, 0, sizeof(nulls));
mapbits = (int32) visibilitymap_get_status(rel, blkno, &vmbuffer);
if (vmbuffer != InvalidBuffer)
@ -117,7 +116,7 @@ pg_visibility(PG_FUNCTION_ARGS)
Page page;
TupleDesc tupdesc;
Datum values[3];
bool nulls[3];
bool nulls[3] = {0};
rel = relation_open(relid, AccessShareLock);
@ -130,7 +129,6 @@ pg_visibility(PG_FUNCTION_ARGS)
errmsg("invalid block number")));
tupdesc = pg_visibility_tupdesc(false, true);
MemSet(nulls, 0, sizeof(nulls));
mapbits = (int32) visibilitymap_get_status(rel, blkno, &vmbuffer);
if (vmbuffer != InvalidBuffer)
@ -188,10 +186,9 @@ pg_visibility_map_rel(PG_FUNCTION_ARGS)
if (info->next < info->count)
{
Datum values[3];
bool nulls[3];
bool nulls[3] = {0};
HeapTuple tuple;
MemSet(nulls, 0, sizeof(nulls));
values[0] = Int64GetDatum(info->next);
values[1] = BoolGetDatum((info->bits[info->next] & (1 << 0)) != 0);
values[2] = BoolGetDatum((info->bits[info->next] & (1 << 1)) != 0);
@ -233,10 +230,9 @@ pg_visibility_rel(PG_FUNCTION_ARGS)
if (info->next < info->count)
{
Datum values[4];
bool nulls[4];
bool nulls[4] = {0};
HeapTuple tuple;
MemSet(nulls, 0, sizeof(nulls));
values[0] = Int64GetDatum(info->next);
values[1] = BoolGetDatum((info->bits[info->next] & (1 << 0)) != 0);
values[2] = BoolGetDatum((info->bits[info->next] & (1 << 1)) != 0);
@ -266,7 +262,7 @@ pg_visibility_map_summary(PG_FUNCTION_ARGS)
int64 all_frozen = 0;
TupleDesc tupdesc;
Datum values[2];
bool nulls[2];
bool nulls[2] = {0};
rel = relation_open(relid, AccessShareLock);
@ -300,7 +296,6 @@ pg_visibility_map_summary(PG_FUNCTION_ARGS)
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "all_frozen", INT8OID, -1, 0);
tupdesc = BlessTupleDesc(tupdesc);
MemSet(nulls, 0, sizeof(nulls));
values[0] = Int64GetDatum(all_visible);
values[1] = Int64GetDatum(all_frozen);

View File

@ -229,8 +229,8 @@ pg_get_wal_record_info(PG_FUNCTION_ARGS)
{
#define PG_GET_WAL_RECORD_INFO_COLS 11
Datum result;
Datum values[PG_GET_WAL_RECORD_INFO_COLS];
bool nulls[PG_GET_WAL_RECORD_INFO_COLS];
Datum values[PG_GET_WAL_RECORD_INFO_COLS] = {0};
bool nulls[PG_GET_WAL_RECORD_INFO_COLS] = {0};
XLogRecPtr lsn;
XLogRecPtr curr_lsn;
XLogRecPtr first_record;
@ -266,9 +266,6 @@ pg_get_wal_record_info(PG_FUNCTION_ARGS)
errmsg("could not read WAL at %X/%X",
LSN_FORMAT_ARGS(first_record))));
MemSet(values, 0, sizeof(values));
MemSet(nulls, 0, sizeof(nulls));
GetWALRecordInfo(xlogreader, first_record, values, nulls,
PG_GET_WAL_RECORD_INFO_COLS);
@ -334,8 +331,8 @@ GetWALRecordsInfo(FunctionCallInfo fcinfo, XLogRecPtr start_lsn,
XLogRecPtr first_record;
XLogReaderState *xlogreader;
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
Datum values[PG_GET_WAL_RECORDS_INFO_COLS];
bool nulls[PG_GET_WAL_RECORDS_INFO_COLS];
Datum values[PG_GET_WAL_RECORDS_INFO_COLS] = {0};
bool nulls[PG_GET_WAL_RECORDS_INFO_COLS] = {0};
SetSingleFuncCall(fcinfo, 0);
@ -343,9 +340,6 @@ GetWALRecordsInfo(FunctionCallInfo fcinfo, XLogRecPtr start_lsn,
Assert(xlogreader);
MemSet(values, 0, sizeof(values));
MemSet(nulls, 0, sizeof(nulls));
while (ReadNextXLogRecord(xlogreader, first_record) &&
xlogreader->EndRecPtr <= end_lsn)
{
@ -556,17 +550,15 @@ GetWalStats(FunctionCallInfo fcinfo, XLogRecPtr start_lsn,
#define PG_GET_WAL_STATS_COLS 9
XLogRecPtr first_record;
XLogReaderState *xlogreader;
XLogStats stats;
XLogStats stats = {0};
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
Datum values[PG_GET_WAL_STATS_COLS];
bool nulls[PG_GET_WAL_STATS_COLS];
Datum values[PG_GET_WAL_STATS_COLS] = {0};
bool nulls[PG_GET_WAL_STATS_COLS] = {0};
SetSingleFuncCall(fcinfo, 0);
xlogreader = InitXLogReaderState(start_lsn, &first_record);
MemSet(&stats, 0, sizeof(stats));
while (ReadNextXLogRecord(xlogreader, first_record) &&
xlogreader->EndRecPtr <= end_lsn)
{
@ -578,9 +570,6 @@ GetWalStats(FunctionCallInfo fcinfo, XLogRecPtr start_lsn,
pfree(xlogreader->private_data);
XLogReaderFree(xlogreader);
MemSet(values, 0, sizeof(values));
MemSet(nulls, 0, sizeof(nulls));
GetXLogSummaryStats(&stats, rsinfo, values, nulls,
PG_GET_WAL_STATS_COLS,
stats_per_record);

View File

@ -575,7 +575,7 @@ pgstathashindex(PG_FUNCTION_ARGS)
HeapTuple tuple;
TupleDesc tupleDesc;
Datum values[8];
bool nulls[8];
bool nulls[8] = {0};
Buffer metabuf;
HashMetaPage metap;
float8 free_percent;
@ -697,7 +697,6 @@ pgstathashindex(PG_FUNCTION_ARGS)
/*
* Build and return the tuple
*/
MemSet(nulls, 0, sizeof(nulls));
values[0] = Int32GetDatum(stats.version);
values[1] = Int64GetDatum((int64) stats.bucket_pages);
values[2] = Int64GetDatum((int64) stats.overflow_pages);

View File

@ -1678,8 +1678,8 @@ postgres_fdw_get_connections(PG_FUNCTION_ARGS)
while ((entry = (ConnCacheEntry *) hash_seq_search(&scan)))
{
ForeignServer *server;
Datum values[POSTGRES_FDW_GET_CONNECTIONS_COLS];
bool nulls[POSTGRES_FDW_GET_CONNECTIONS_COLS];
Datum values[POSTGRES_FDW_GET_CONNECTIONS_COLS] = {0};
bool nulls[POSTGRES_FDW_GET_CONNECTIONS_COLS] = {0};
/* We only look for open remote connections */
if (!entry->conn)
@ -1687,9 +1687,6 @@ postgres_fdw_get_connections(PG_FUNCTION_ARGS)
server = GetForeignServerExtended(entry->serverid, FSV_MISSING_OK);
MemSet(values, 0, sizeof(values));
MemSet(nulls, 0, sizeof(nulls));
/*
* The foreign server may have been dropped in current explicit
* transaction. It is not possible to drop the server from another

View File

@ -3307,7 +3307,7 @@ estimate_path_cost_size(PlannerInfo *root,
{
RelOptInfo *outerrel = fpinfo->outerrel;
PgFdwRelationInfo *ofpinfo;
AggClauseCosts aggcosts;
AggClauseCosts aggcosts = {0};
double input_rows;
int numGroupCols;
double numGroups = 1;
@ -3331,7 +3331,6 @@ estimate_path_cost_size(PlannerInfo *root,
input_rows = ofpinfo->rows;
/* Collect statistics about aggregates for estimating costs. */
MemSet(&aggcosts, 0, sizeof(AggClauseCosts));
if (root->parse->hasAggs)
{
get_agg_clause_costs(root, AGGSPLIT_SIMPLE, &aggcosts);

View File

@ -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};
HeapTuple tuple;
Datum result;
@ -791,8 +791,6 @@ pg_prepared_xact(PG_FUNCTION_ARGS)
/*
* Form tuple with appropriate data.
*/
MemSet(values, 0, sizeof(values));
MemSet(nulls, 0, sizeof(nulls));
values[0] = TransactionIdGetDatum(proc->xid);
values[1] = CStringGetTextDatum(gxact->gid);

View File

@ -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};
bool waitforarchive = PG_GETARG_BOOL(0);
XLogRecPtr stoppoint;
@ -117,9 +117,6 @@ pg_backup_stop(PG_FUNCTION_ARGS)
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
elog(ERROR, "return type must be a row type");
MemSet(values, 0, sizeof(values));
MemSet(nulls, 0, sizeof(nulls));
if (status != SESSION_BACKUP_RUNNING)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

View File

@ -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};
bool replaces[Natts_pg_default_acl] = {0};
Oid defAclOid;
/* Prepare to insert or update pg_default_acl entry */
MemSet(values, 0, sizeof(values));
MemSet(nulls, false, sizeof(nulls));
MemSet(replaces, false, sizeof(replaces));
if (isNew)
{
/* insert new entry */
@ -1662,9 +1657,9 @@ ExecGrant_Attribute(InternalGrant *istmt, Oid relOid, const char *relname,
AclMode avail_goptions;
bool need_update;
HeapTuple newtuple;
Datum values[Natts_pg_attribute];
bool nulls[Natts_pg_attribute];
bool replaces[Natts_pg_attribute];
Datum values[Natts_pg_attribute] = {0};
bool nulls[Natts_pg_attribute] = {0};
bool replaces[Natts_pg_attribute] = {0};
int noldmembers;
int nnewmembers;
Oid *oldmembers;
@ -1745,9 +1740,6 @@ ExecGrant_Attribute(InternalGrant *istmt, Oid relOid, const char *relname,
nnewmembers = aclmembers(new_acl, &newmembers);
/* finished building new ACL value, now insert it */
MemSet(values, 0, sizeof(values));
MemSet(nulls, false, sizeof(nulls));
MemSet(replaces, false, sizeof(replaces));
/*
* If the updated ACL is empty, we can set attacl to null, and maybe even
@ -1975,9 +1967,9 @@ ExecGrant_Relation(InternalGrant *istmt)
Acl *new_acl;
Oid grantorId;
HeapTuple newtuple;
Datum values[Natts_pg_class];
bool nulls[Natts_pg_class];
bool replaces[Natts_pg_class];
Datum values[Natts_pg_class] = {0};
bool nulls[Natts_pg_class] = {0};
bool replaces[Natts_pg_class] = {0};
int nnewmembers;
Oid *newmembers;
ObjectType objtype;
@ -2027,10 +2019,6 @@ ExecGrant_Relation(InternalGrant *istmt)
nnewmembers = aclmembers(new_acl, &newmembers);
/* finished building new ACL value, now insert it */
MemSet(values, 0, sizeof(values));
MemSet(nulls, false, sizeof(nulls));
MemSet(replaces, false, sizeof(replaces));
replaces[Anum_pg_class_relacl - 1] = true;
values[Anum_pg_class_relacl - 1] = PointerGetDatum(new_acl);
@ -2150,9 +2138,9 @@ ExecGrant_Database(InternalGrant *istmt)
Oid grantorId;
Oid ownerId;
HeapTuple newtuple;
Datum values[Natts_pg_database];
bool nulls[Natts_pg_database];
bool replaces[Natts_pg_database];
Datum values[Natts_pg_database] = {0};
bool nulls[Natts_pg_database] = {0};
bool replaces[Natts_pg_database] = {0};
int noldmembers;
int nnewmembers;
Oid *oldmembers;
@ -2217,10 +2205,6 @@ ExecGrant_Database(InternalGrant *istmt)
nnewmembers = aclmembers(new_acl, &newmembers);
/* finished building new ACL value, now insert it */
MemSet(values, 0, sizeof(values));
MemSet(nulls, false, sizeof(nulls));
MemSet(replaces, false, sizeof(replaces));
replaces[Anum_pg_database_datacl - 1] = true;
values[Anum_pg_database_datacl - 1] = PointerGetDatum(new_acl);
@ -2271,9 +2255,9 @@ ExecGrant_Fdw(InternalGrant *istmt)
Oid ownerId;
HeapTuple tuple;
HeapTuple newtuple;
Datum values[Natts_pg_foreign_data_wrapper];
bool nulls[Natts_pg_foreign_data_wrapper];
bool replaces[Natts_pg_foreign_data_wrapper];
Datum values[Natts_pg_foreign_data_wrapper] = {0};
bool nulls[Natts_pg_foreign_data_wrapper] = {0};
bool replaces[Natts_pg_foreign_data_wrapper] = {0};
int noldmembers;
int nnewmembers;
Oid *oldmembers;
@ -2339,10 +2323,6 @@ ExecGrant_Fdw(InternalGrant *istmt)
nnewmembers = aclmembers(new_acl, &newmembers);
/* finished building new ACL value, now insert it */
MemSet(values, 0, sizeof(values));
MemSet(nulls, false, sizeof(nulls));
MemSet(replaces, false, sizeof(replaces));
replaces[Anum_pg_foreign_data_wrapper_fdwacl - 1] = true;
values[Anum_pg_foreign_data_wrapper_fdwacl - 1] = PointerGetDatum(new_acl);
@ -2398,9 +2378,9 @@ ExecGrant_ForeignServer(InternalGrant *istmt)
Oid ownerId;
HeapTuple tuple;
HeapTuple newtuple;
Datum values[Natts_pg_foreign_server];
bool nulls[Natts_pg_foreign_server];
bool replaces[Natts_pg_foreign_server];
Datum values[Natts_pg_foreign_server] = {0};
bool nulls[Natts_pg_foreign_server] = {0};
bool replaces[Natts_pg_foreign_server] = {0};
int noldmembers;
int nnewmembers;
Oid *oldmembers;
@ -2465,10 +2445,6 @@ ExecGrant_ForeignServer(InternalGrant *istmt)
nnewmembers = aclmembers(new_acl, &newmembers);
/* finished building new ACL value, now insert it */
MemSet(values, 0, sizeof(values));
MemSet(nulls, false, sizeof(nulls));
MemSet(replaces, false, sizeof(replaces));
replaces[Anum_pg_foreign_server_srvacl - 1] = true;
values[Anum_pg_foreign_server_srvacl - 1] = PointerGetDatum(new_acl);
@ -2523,9 +2499,9 @@ ExecGrant_Function(InternalGrant *istmt)
Oid ownerId;
HeapTuple tuple;
HeapTuple newtuple;
Datum values[Natts_pg_proc];
bool nulls[Natts_pg_proc];
bool replaces[Natts_pg_proc];
Datum values[Natts_pg_proc] = {0};
bool nulls[Natts_pg_proc] = {0};
bool replaces[Natts_pg_proc] = {0};
int noldmembers;
int nnewmembers;
Oid *oldmembers;
@ -2589,10 +2565,6 @@ ExecGrant_Function(InternalGrant *istmt)
nnewmembers = aclmembers(new_acl, &newmembers);
/* finished building new ACL value, now insert it */
MemSet(values, 0, sizeof(values));
MemSet(nulls, false, sizeof(nulls));
MemSet(replaces, false, sizeof(replaces));
replaces[Anum_pg_proc_proacl - 1] = true;
values[Anum_pg_proc_proacl - 1] = PointerGetDatum(new_acl);
@ -2646,9 +2618,9 @@ ExecGrant_Language(InternalGrant *istmt)
Oid ownerId;
HeapTuple tuple;
HeapTuple newtuple;
Datum values[Natts_pg_language];
bool nulls[Natts_pg_language];
bool replaces[Natts_pg_language];
Datum values[Natts_pg_language] = {0};
bool nulls[Natts_pg_language] = {0};
bool replaces[Natts_pg_language] = {0};
int noldmembers;
int nnewmembers;
Oid *oldmembers;
@ -2720,10 +2692,6 @@ ExecGrant_Language(InternalGrant *istmt)
nnewmembers = aclmembers(new_acl, &newmembers);
/* finished building new ACL value, now insert it */
MemSet(values, 0, sizeof(values));
MemSet(nulls, false, sizeof(nulls));
MemSet(replaces, false, sizeof(replaces));
replaces[Anum_pg_language_lanacl - 1] = true;
values[Anum_pg_language_lanacl - 1] = PointerGetDatum(new_acl);
@ -2778,9 +2746,9 @@ ExecGrant_Largeobject(InternalGrant *istmt)
Oid grantorId;
Oid ownerId;
HeapTuple newtuple;
Datum values[Natts_pg_largeobject_metadata];
bool nulls[Natts_pg_largeobject_metadata];
bool replaces[Natts_pg_largeobject_metadata];
Datum values[Natts_pg_largeobject_metadata] = {0};
bool nulls[Natts_pg_largeobject_metadata] = {0};
bool replaces[Natts_pg_largeobject_metadata] = {0};
int noldmembers;
int nnewmembers;
Oid *oldmembers;
@ -2858,10 +2826,6 @@ ExecGrant_Largeobject(InternalGrant *istmt)
nnewmembers = aclmembers(new_acl, &newmembers);
/* finished building new ACL value, now insert it */
MemSet(values, 0, sizeof(values));
MemSet(nulls, false, sizeof(nulls));
MemSet(replaces, false, sizeof(replaces));
replaces[Anum_pg_largeobject_metadata_lomacl - 1] = true;
values[Anum_pg_largeobject_metadata_lomacl - 1]
= PointerGetDatum(new_acl);
@ -2917,9 +2881,9 @@ ExecGrant_Namespace(InternalGrant *istmt)
Oid ownerId;
HeapTuple tuple;
HeapTuple newtuple;
Datum values[Natts_pg_namespace];
bool nulls[Natts_pg_namespace];
bool replaces[Natts_pg_namespace];
Datum values[Natts_pg_namespace] = {0};
bool nulls[Natts_pg_namespace] = {0};
bool replaces[Natts_pg_namespace] = {0};
int noldmembers;
int nnewmembers;
Oid *oldmembers;
@ -2984,10 +2948,6 @@ ExecGrant_Namespace(InternalGrant *istmt)
nnewmembers = aclmembers(new_acl, &newmembers);
/* finished building new ACL value, now insert it */
MemSet(values, 0, sizeof(values));
MemSet(nulls, false, sizeof(nulls));
MemSet(replaces, false, sizeof(replaces));
replaces[Anum_pg_namespace_nspacl - 1] = true;
values[Anum_pg_namespace_nspacl - 1] = PointerGetDatum(new_acl);
@ -3040,9 +3000,9 @@ ExecGrant_Tablespace(InternalGrant *istmt)
Oid grantorId;
Oid ownerId;
HeapTuple newtuple;
Datum values[Natts_pg_tablespace];
bool nulls[Natts_pg_tablespace];
bool replaces[Natts_pg_tablespace];
Datum values[Natts_pg_tablespace] = {0};
bool nulls[Natts_pg_tablespace] = {0};
bool replaces[Natts_pg_tablespace] = {0};
int noldmembers;
int nnewmembers;
Oid *oldmembers;
@ -3108,10 +3068,6 @@ ExecGrant_Tablespace(InternalGrant *istmt)
nnewmembers = aclmembers(new_acl, &newmembers);
/* finished building new ACL value, now insert it */
MemSet(values, 0, sizeof(values));
MemSet(nulls, false, sizeof(nulls));
MemSet(replaces, false, sizeof(replaces));
replaces[Anum_pg_tablespace_spcacl - 1] = true;
values[Anum_pg_tablespace_spcacl - 1] = PointerGetDatum(new_acl);
@ -3160,9 +3116,9 @@ ExecGrant_Type(InternalGrant *istmt)
Oid grantorId;
Oid ownerId;
HeapTuple newtuple;
Datum values[Natts_pg_type];
bool nulls[Natts_pg_type];
bool replaces[Natts_pg_type];
Datum values[Natts_pg_type] = {0};
bool nulls[Natts_pg_type] = {0};
bool replaces[Natts_pg_type] = {0};
int noldmembers;
int nnewmembers;
Oid *oldmembers;
@ -3242,10 +3198,6 @@ ExecGrant_Type(InternalGrant *istmt)
nnewmembers = aclmembers(new_acl, &newmembers);
/* finished building new ACL value, now insert it */
MemSet(values, 0, sizeof(values));
MemSet(nulls, false, sizeof(nulls));
MemSet(replaces, false, sizeof(replaces));
replaces[Anum_pg_type_typacl - 1] = true;
values[Anum_pg_type_typacl - 1] = PointerGetDatum(new_acl);
@ -3384,13 +3336,9 @@ ExecGrant_Parameter(InternalGrant *istmt)
{
/* finished building new ACL value, now insert it */
HeapTuple newtuple;
Datum values[Natts_pg_parameter_acl];
bool nulls[Natts_pg_parameter_acl];
bool replaces[Natts_pg_parameter_acl];
MemSet(values, 0, sizeof(values));
MemSet(nulls, false, sizeof(nulls));
MemSet(replaces, false, sizeof(replaces));
Datum values[Natts_pg_parameter_acl] = {0};
bool nulls[Natts_pg_parameter_acl] = {0};
bool replaces[Natts_pg_parameter_acl] = {0};
replaces[Anum_pg_parameter_acl_paracl - 1] = true;
values[Anum_pg_parameter_acl_paracl - 1] = PointerGetDatum(new_acl);
@ -6419,17 +6367,13 @@ recordExtensionInitPrivWorker(Oid objoid, Oid classoid, int objsubid, Acl *new_a
/* If we find an entry, update it with the latest ACL. */
if (HeapTupleIsValid(oldtuple))
{
Datum values[Natts_pg_init_privs];
bool nulls[Natts_pg_init_privs];
bool replace[Natts_pg_init_privs];
Datum values[Natts_pg_init_privs] = {0};
bool nulls[Natts_pg_init_privs] = {0};
bool replace[Natts_pg_init_privs] = {0};
/* If we have a new ACL to set, then update the row with it. */
if (new_acl)
{
MemSet(values, 0, sizeof(values));
MemSet(nulls, false, sizeof(nulls));
MemSet(replace, false, sizeof(replace));
values[Anum_pg_init_privs_initprivs - 1] = PointerGetDatum(new_acl);
replace[Anum_pg_init_privs_initprivs - 1] = true;
@ -6446,8 +6390,8 @@ recordExtensionInitPrivWorker(Oid objoid, Oid classoid, int objsubid, Acl *new_a
}
else
{
Datum values[Natts_pg_init_privs];
bool nulls[Natts_pg_init_privs];
Datum values[Natts_pg_init_privs] = {0};
bool nulls[Natts_pg_init_privs] = {0};
/*
* Only add a new entry if the new ACL is non-NULL.
@ -6458,8 +6402,6 @@ recordExtensionInitPrivWorker(Oid objoid, Oid classoid, int objsubid, Acl *new_a
if (new_acl)
{
/* No entry found, so add it. */
MemSet(nulls, false, sizeof(nulls));
values[Anum_pg_init_privs_objoid - 1] = ObjectIdGetDatum(objoid);
values[Anum_pg_init_privs_classoid - 1] = ObjectIdGetDatum(classoid);
values[Anum_pg_init_privs_objsubid - 1] = Int32GetDatum(objsubid);

View File

@ -1635,12 +1635,11 @@ recordDependencyOnSingleRelExpr(const ObjectAddress *depender,
bool reverse_self)
{
find_expr_references_context context;
RangeTblEntry rte;
RangeTblEntry rte = {0};
context.addrs = new_object_addresses();
/* We gin up a rather bogus rangetable list to handle Vars */
MemSet(&rte, 0, sizeof(rte));
rte.type = T_RangeTblEntry;
rte.rtekind = RTE_RELATION;
rte.relid = relId;

View File

@ -1709,15 +1709,11 @@ RemoveAttributeById(Oid relid, AttrNumber attnum)
/* clear the missing value if any */
if (attStruct->atthasmissing)
{
Datum valuesAtt[Natts_pg_attribute];
bool nullsAtt[Natts_pg_attribute];
bool replacesAtt[Natts_pg_attribute];
Datum valuesAtt[Natts_pg_attribute] = {0};
bool nullsAtt[Natts_pg_attribute] = {0};
bool replacesAtt[Natts_pg_attribute] = {0};
/* update the tuple - set atthasmissing and attmissingval */
MemSet(valuesAtt, 0, sizeof(valuesAtt));
MemSet(nullsAtt, false, sizeof(nullsAtt));
MemSet(replacesAtt, false, sizeof(replacesAtt));
valuesAtt[Anum_pg_attribute_atthasmissing - 1] =
BoolGetDatum(false);
replacesAtt[Anum_pg_attribute_atthasmissing - 1] = true;
@ -2006,9 +2002,9 @@ RelationClearMissing(Relation rel)
void
SetAttrMissing(Oid relid, char *attname, char *value)
{
Datum valuesAtt[Natts_pg_attribute];
bool nullsAtt[Natts_pg_attribute];
bool replacesAtt[Natts_pg_attribute];
Datum valuesAtt[Natts_pg_attribute] = {0};
bool nullsAtt[Natts_pg_attribute] = {0};
bool replacesAtt[Natts_pg_attribute] = {0};
Datum missingval;
Form_pg_attribute attStruct;
Relation attrrel,
@ -2041,10 +2037,6 @@ SetAttrMissing(Oid relid, char *attname, char *value)
Int32GetDatum(attStruct->atttypmod));
/* update the tuple - set atthasmissing and attmissingval */
MemSet(valuesAtt, 0, sizeof(valuesAtt));
MemSet(nullsAtt, false, sizeof(nullsAtt));
MemSet(replacesAtt, false, sizeof(replacesAtt));
valuesAtt[Anum_pg_attribute_atthasmissing - 1] = BoolGetDatum(true);
replacesAtt[Anum_pg_attribute_atthasmissing - 1] = true;
valuesAtt[Anum_pg_attribute_attmissingval - 1] = missingval;
@ -3321,7 +3313,7 @@ StorePartitionKey(Relation rel,
Relation pg_partitioned_table;
HeapTuple tuple;
Datum values[Natts_pg_partitioned_table];
bool nulls[Natts_pg_partitioned_table];
bool nulls[Natts_pg_partitioned_table] = {0};
ObjectAddress myself;
ObjectAddress referenced;
ObjectAddresses *addrs;
@ -3347,8 +3339,6 @@ StorePartitionKey(Relation rel,
pg_partitioned_table = table_open(PartitionedRelationId, RowExclusiveLock);
MemSet(nulls, false, sizeof(nulls));
/* Only this can ever be NULL */
if (!partexprDatum)
nulls[Anum_pg_partitioned_table_partexprs - 1] = true;

View File

@ -554,7 +554,7 @@ UpdateIndexRelation(Oid indexoid,
Datum exprsDatum;
Datum predDatum;
Datum values[Natts_pg_index];
bool nulls[Natts_pg_index];
bool nulls[Natts_pg_index] = {0};
Relation pg_index;
HeapTuple tuple;
int i;
@ -608,8 +608,6 @@ UpdateIndexRelation(Oid indexoid,
/*
* Build a pg_index tuple
*/
MemSet(nulls, false, sizeof(nulls));
values[Anum_pg_index_indexrelid - 1] = ObjectIdGetDatum(indexoid);
values[Anum_pg_index_indrelid - 1] = ObjectIdGetDatum(heapoid);
values[Anum_pg_index_indnatts - 1] = Int16GetDatum(indexInfo->ii_NumIndexAttrs);

View File

@ -111,15 +111,12 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
Expr *expr2 = (Expr *) expr;
EState *estate = NULL;
ExprContext *econtext;
Datum valuesAtt[Natts_pg_attribute];
bool nullsAtt[Natts_pg_attribute];
bool replacesAtt[Natts_pg_attribute];
Datum valuesAtt[Natts_pg_attribute] = {0};
bool nullsAtt[Natts_pg_attribute] = {0};
bool replacesAtt[Natts_pg_attribute] = {0};
Datum missingval = (Datum) 0;
bool missingIsNull = true;
MemSet(valuesAtt, 0, sizeof(valuesAtt));
MemSet(nullsAtt, false, sizeof(nullsAtt));
MemSet(replacesAtt, false, sizeof(replacesAtt));
valuesAtt[Anum_pg_attribute_atthasdef - 1] = true;
replacesAtt[Anum_pg_attribute_atthasdef - 1] = true;

View File

@ -47,7 +47,7 @@ CastCreate(Oid sourcetypeid, Oid targettypeid, Oid funcid, char castcontext,
HeapTuple tuple;
Oid castid;
Datum values[Natts_pg_cast];
bool nulls[Natts_pg_cast];
bool nulls[Natts_pg_cast] = {0};
ObjectAddress myself,
referenced;
ObjectAddresses *addrs;
@ -78,8 +78,6 @@ CastCreate(Oid sourcetypeid, Oid targettypeid, Oid funcid, char castcontext,
values[Anum_pg_cast_castcontext - 1] = CharGetDatum(castcontext);
values[Anum_pg_cast_castmethod - 1] = CharGetDatum(castmethod);
MemSet(nulls, false, sizeof(nulls));
tuple = heap_form_tuple(RelationGetDescr(relation), values, nulls);
CatalogTupleInsert(relation, tuple);

View File

@ -74,8 +74,8 @@ ParameterAclCreate(const char *parameter)
Relation rel;
TupleDesc tupDesc;
HeapTuple tuple;
Datum values[Natts_pg_parameter_acl];
bool nulls[Natts_pg_parameter_acl];
Datum values[Natts_pg_parameter_acl] = {0};
bool nulls[Natts_pg_parameter_acl] = {0};
/*
* To prevent cluttering pg_parameter_acl with useless entries, insist
@ -98,8 +98,6 @@ ParameterAclCreate(const char *parameter)
*/
rel = table_open(ParameterAclRelationId, RowExclusiveLock);
tupDesc = RelationGetDescr(rel);
MemSet(values, 0, sizeof(values));
MemSet(nulls, false, sizeof(nulls));
parameterId = GetNewOidWithIndex(rel,
ParameterAclOidIndexId,
Anum_pg_parameter_acl_oid);

View File

@ -1162,14 +1162,12 @@ pg_get_publication_tables(PG_FUNCTION_ARGS)
HeapTuple pubtuple = NULL;
HeapTuple rettuple;
Oid relid = list_nth_oid(tables, funcctx->call_cntr);
Datum values[NUM_PUBLICATION_TABLES_ELEM];
bool nulls[NUM_PUBLICATION_TABLES_ELEM];
Datum values[NUM_PUBLICATION_TABLES_ELEM] = {0};
bool nulls[NUM_PUBLICATION_TABLES_ELEM] = {0};
/*
* Form tuple with appropriate data.
*/
MemSet(nulls, 0, sizeof(nulls));
MemSet(values, 0, sizeof(values));
publication = GetPublicationByName(pubname, false);

View File

@ -689,8 +689,8 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
volatile Oid dst_deftablespace;
Relation pg_database_rel;
HeapTuple tuple;
Datum new_record[Natts_pg_database];
bool new_record_nulls[Natts_pg_database];
Datum new_record[Natts_pg_database] = {0};
bool new_record_nulls[Natts_pg_database] = {0};
Oid dboid = InvalidOid;
Oid datdba;
ListCell *option;
@ -1296,9 +1296,6 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
(dblocprovider != COLLPROVIDER_ICU && !dbiculocale));
/* Form tuple */
MemSet(new_record, 0, sizeof(new_record));
MemSet(new_record_nulls, false, sizeof(new_record_nulls));
new_record[Anum_pg_database_oid - 1] = ObjectIdGetDatum(dboid);
new_record[Anum_pg_database_datname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(dbname));
@ -1822,9 +1819,6 @@ movedb(const char *dbname, const char *tblspcname)
newtuple;
Oid src_tblspcoid,
dst_tblspcoid;
Datum new_record[Natts_pg_database];
bool new_record_nulls[Natts_pg_database];
bool new_record_repl[Natts_pg_database];
ScanKeyData scankey;
SysScanDesc sysscan;
AclResult aclresult;
@ -2003,6 +1997,10 @@ movedb(const char *dbname, const char *tblspcname)
PG_ENSURE_ERROR_CLEANUP(movedb_failure_callback,
PointerGetDatum(&fparms));
{
Datum new_record[Natts_pg_database] = {0};
bool new_record_nulls[Natts_pg_database] = {0};
bool new_record_repl[Natts_pg_database] = {0};
/*
* Copy files from the old tablespace to the new one
*/
@ -2042,10 +2040,6 @@ movedb(const char *dbname, const char *tblspcname)
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist", dbname)));
MemSet(new_record, 0, sizeof(new_record));
MemSet(new_record_nulls, false, sizeof(new_record_nulls));
MemSet(new_record_repl, false, sizeof(new_record_repl));
new_record[Anum_pg_database_dattablespace - 1] = ObjectIdGetDatum(dst_tblspcoid);
new_record_repl[Anum_pg_database_dattablespace - 1] = true;
@ -2194,9 +2188,9 @@ AlterDatabase(ParseState *pstate, AlterDatabaseStmt *stmt, bool isTopLevel)
DefElem *dallowconnections = NULL;
DefElem *dconnlimit = NULL;
DefElem *dtablespace = NULL;
Datum new_record[Natts_pg_database];
bool new_record_nulls[Natts_pg_database];
bool new_record_repl[Natts_pg_database];
Datum new_record[Natts_pg_database] = {0};
bool new_record_nulls[Natts_pg_database] = {0};
bool new_record_repl[Natts_pg_database] = {0};
/* Extract options from the statement node tree */
foreach(option, stmt->options)
@ -2305,10 +2299,6 @@ AlterDatabase(ParseState *pstate, AlterDatabaseStmt *stmt, bool isTopLevel)
/*
* Build an updated tuple, perusing the information just obtained
*/
MemSet(new_record, 0, sizeof(new_record));
MemSet(new_record_nulls, false, sizeof(new_record_nulls));
MemSet(new_record_repl, false, sizeof(new_record_repl));
if (distemplate)
{
new_record[Anum_pg_database_datistemplate - 1] = BoolGetDatum(dbistemplate);
@ -2492,8 +2482,8 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
if (datForm->datdba != newOwnerId)
{
Datum repl_val[Natts_pg_database];
bool repl_null[Natts_pg_database];
bool repl_repl[Natts_pg_database];
bool repl_null[Natts_pg_database] = {0};
bool repl_repl[Natts_pg_database] = {0};
Acl *newAcl;
Datum aclDatum;
bool isNull;
@ -2521,9 +2511,6 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("permission denied to change owner of database")));
memset(repl_null, false, sizeof(repl_null));
memset(repl_repl, false, sizeof(repl_repl));
repl_repl[Anum_pg_database_datdba - 1] = true;
repl_val[Anum_pg_database_datdba - 1] = ObjectIdGetDatum(newOwnerId);

View File

@ -1310,14 +1310,11 @@ pg_event_trigger_dropped_objects(PG_FUNCTION_ARGS)
{
SQLDropObject *obj;
int i = 0;
Datum values[12];
bool nulls[12];
Datum values[12] = {0};
bool nulls[12] = {0};
obj = slist_container(SQLDropObject, next, iter.cur);
MemSet(values, 0, sizeof(values));
MemSet(nulls, 0, sizeof(nulls));
/* classid */
values[i++] = ObjectIdGetDatum(obj->address.classId);
@ -1840,7 +1837,7 @@ pg_event_trigger_ddl_commands(PG_FUNCTION_ARGS)
{
CollectedCommand *cmd = lfirst(lc);
Datum values[9];
bool nulls[9];
bool nulls[9] = {0};
ObjectAddress addr;
int i = 0;
@ -1858,8 +1855,6 @@ pg_event_trigger_ddl_commands(PG_FUNCTION_ARGS)
!OidIsValid(cmd->d.simple.address.objectId))
continue;
MemSet(nulls, 0, sizeof(nulls));
switch (cmd->type)
{
case SCT_Simple:

View File

@ -1806,8 +1806,8 @@ CreateTransform(CreateTransformStmt *stmt)
AclResult aclresult;
Form_pg_proc procstruct;
Datum values[Natts_pg_transform];
bool nulls[Natts_pg_transform];
bool replaces[Natts_pg_transform];
bool nulls[Natts_pg_transform] = {0};
bool replaces[Natts_pg_transform] = {0};
Oid transformid;
HeapTuple tuple;
HeapTuple newtuple;
@ -1913,8 +1913,6 @@ CreateTransform(CreateTransformStmt *stmt)
values[Anum_pg_transform_trffromsql - 1] = ObjectIdGetDatum(fromsqlfuncid);
values[Anum_pg_transform_trftosql - 1] = ObjectIdGetDatum(tosqlfuncid);
MemSet(nulls, false, sizeof(nulls));
relation = table_open(TransformRelationId, RowExclusiveLock);
tuple = SearchSysCache2(TRFTYPELANG,
@ -1931,7 +1929,6 @@ CreateTransform(CreateTransformStmt *stmt)
format_type_be(typeid),
stmt->lang)));
MemSet(replaces, false, sizeof(replaces));
replaces[Anum_pg_transform_trffromsql - 1] = true;
replaces[Anum_pg_transform_trftosql - 1] = true;

View File

@ -685,12 +685,10 @@ pg_prepared_statement(PG_FUNCTION_ARGS)
{
TupleDesc result_desc;
Datum values[8];
bool nulls[8];
bool nulls[8] = {0};
result_desc = prep_stmt->plansource->resultDesc;
MemSet(nulls, 0, sizeof(nulls));
values[0] = CStringGetTextDatum(prep_stmt->stmt_name);
values[1] = CStringGetTextDatum(prep_stmt->plansource->query_string);
values[2] = TimestampTzGetDatum(prep_stmt->prepare_time);

View File

@ -8988,15 +8988,15 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
bool recurse, bool recursing, LOCKMODE lockmode)
{
Relation pkrel;
int16 pkattnum[INDEX_MAX_KEYS];
int16 fkattnum[INDEX_MAX_KEYS];
Oid pktypoid[INDEX_MAX_KEYS];
Oid fktypoid[INDEX_MAX_KEYS];
Oid opclasses[INDEX_MAX_KEYS];
Oid pfeqoperators[INDEX_MAX_KEYS];
Oid ppeqoperators[INDEX_MAX_KEYS];
Oid ffeqoperators[INDEX_MAX_KEYS];
int16 fkdelsetcols[INDEX_MAX_KEYS];
int16 pkattnum[INDEX_MAX_KEYS] = {0};
int16 fkattnum[INDEX_MAX_KEYS] = {0};
Oid pktypoid[INDEX_MAX_KEYS] = {0};
Oid fktypoid[INDEX_MAX_KEYS] = {0};
Oid opclasses[INDEX_MAX_KEYS] = {0};
Oid pfeqoperators[INDEX_MAX_KEYS] = {0};
Oid ppeqoperators[INDEX_MAX_KEYS] = {0};
Oid ffeqoperators[INDEX_MAX_KEYS] = {0};
int16 fkdelsetcols[INDEX_MAX_KEYS] = {0};
int i;
int numfks,
numpks,
@ -9088,16 +9088,6 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
* Look up the referencing attributes to make sure they exist, and record
* their attnums and type OIDs.
*/
MemSet(pkattnum, 0, sizeof(pkattnum));
MemSet(fkattnum, 0, sizeof(fkattnum));
MemSet(pktypoid, 0, sizeof(pktypoid));
MemSet(fktypoid, 0, sizeof(fktypoid));
MemSet(opclasses, 0, sizeof(opclasses));
MemSet(pfeqoperators, 0, sizeof(pfeqoperators));
MemSet(ppeqoperators, 0, sizeof(ppeqoperators));
MemSet(ffeqoperators, 0, sizeof(ffeqoperators));
MemSet(fkdelsetcols, 0, sizeof(fkdelsetcols));
numfks = transformColumnNameList(RelationGetRelid(rel),
fkconstraint->fk_attrs,
fkattnum, fktypoid);
@ -11473,7 +11463,7 @@ validateForeignKeyConstraint(char *conname,
{
TupleTableSlot *slot;
TableScanDesc scan;
Trigger trig;
Trigger trig = {0};
Snapshot snapshot;
MemoryContext oldcxt;
MemoryContext perTupCxt;
@ -11484,7 +11474,6 @@ validateForeignKeyConstraint(char *conname,
/*
* Build a trigger call structure; we'll need it either way.
*/
MemSet(&trig, 0, sizeof(trig));
trig.tgoid = InvalidOid;
trig.tgname = conname;
trig.tgenabled = TRIGGER_FIRES_ON_ORIGIN;
@ -12758,15 +12747,11 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
int one = 1;
bool isNull;
Datum valuesAtt[Natts_pg_attribute];
bool nullsAtt[Natts_pg_attribute];
bool replacesAtt[Natts_pg_attribute];
Datum valuesAtt[Natts_pg_attribute] = {0};
bool nullsAtt[Natts_pg_attribute] = {0};
bool replacesAtt[Natts_pg_attribute] = {0};
HeapTuple newTup;
MemSet(valuesAtt, 0, sizeof(valuesAtt));
MemSet(nullsAtt, false, sizeof(nullsAtt));
MemSet(replacesAtt, false, sizeof(replacesAtt));
missingval = array_get_element(missingval,
1,
&one,
@ -19192,7 +19177,7 @@ ATDetachCheckNoForeignKeyRefs(Relation partition)
HeapTuple tuple;
Form_pg_constraint constrForm;
Relation rel;
Trigger trig;
Trigger trig = {0};
tuple = SearchSysCache1(CONSTROID, ObjectIdGetDatum(constrOid));
if (!HeapTupleIsValid(tuple))
@ -19205,7 +19190,6 @@ ATDetachCheckNoForeignKeyRefs(Relation partition)
/* prevent data changes into the referencing table until commit */
rel = table_open(constrForm->conrelid, ShareLock);
MemSet(&trig, 0, sizeof(trig));
trig.tgoid = InvalidOid;
trig.tgname = NameStr(constrForm->conname);
trig.tgenabled = TRIGGER_FIRES_ON_ORIGIN;

View File

@ -238,7 +238,7 @@ CreateTableSpace(CreateTableSpaceStmt *stmt)
#ifdef HAVE_SYMLINK
Relation rel;
Datum values[Natts_pg_tablespace];
bool nulls[Natts_pg_tablespace];
bool nulls[Natts_pg_tablespace] = {0};
HeapTuple tuple;
Oid tablespaceoid;
char *location;
@ -340,8 +340,6 @@ CreateTableSpace(CreateTableSpaceStmt *stmt)
*/
rel = table_open(TableSpaceRelationId, RowExclusiveLock);
MemSet(nulls, false, sizeof(nulls));
if (IsBinaryUpgrade)
{
/* Use binary-upgrade override for tablespace oid */

View File

@ -2570,9 +2570,9 @@ AlterDomainDefault(List *names, Node *defaultRaw)
Relation rel;
char *defaultValue;
Node *defaultExpr = NULL; /* NULL if no default specified */
Datum new_record[Natts_pg_type];
bool new_record_nulls[Natts_pg_type];
bool new_record_repl[Natts_pg_type];
Datum new_record[Natts_pg_type] = {0};
bool new_record_nulls[Natts_pg_type] = {0};
bool new_record_repl[Natts_pg_type] = {0};
HeapTuple newtuple;
Form_pg_type typTup;
ObjectAddress address;
@ -2593,9 +2593,6 @@ AlterDomainDefault(List *names, Node *defaultRaw)
checkDomainOwner(tup);
/* Setup new tuple */
MemSet(new_record, (Datum) 0, sizeof(new_record));
MemSet(new_record_nulls, false, sizeof(new_record_nulls));
MemSet(new_record_repl, false, sizeof(new_record_repl));
/* Store the new default into the tuple */
if (defaultRaw)

View File

@ -74,8 +74,8 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt)
Relation pg_authid_rel;
TupleDesc pg_authid_dsc;
HeapTuple tuple;
Datum new_record[Natts_pg_authid];
bool new_record_nulls[Natts_pg_authid];
Datum new_record[Natts_pg_authid] = {0};
bool new_record_nulls[Natts_pg_authid] = {0};
Oid roleid;
ListCell *item;
ListCell *option;
@ -338,12 +338,8 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt)
/*
* Build a tuple to insert
*/
MemSet(new_record, 0, sizeof(new_record));
MemSet(new_record_nulls, false, sizeof(new_record_nulls));
new_record[Anum_pg_authid_rolname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(stmt->role));
new_record[Anum_pg_authid_rolsuper - 1] = BoolGetDatum(issuper);
new_record[Anum_pg_authid_rolinherit - 1] = BoolGetDatum(inherit);
new_record[Anum_pg_authid_rolcreaterole - 1] = BoolGetDatum(createrole);
@ -492,9 +488,9 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt)
Oid
AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
{
Datum new_record[Natts_pg_authid];
bool new_record_nulls[Natts_pg_authid];
bool new_record_repl[Natts_pg_authid];
Datum new_record[Natts_pg_authid] = {0};
bool new_record_nulls[Natts_pg_authid] = {0};
bool new_record_repl[Natts_pg_authid] = {0};
Relation pg_authid_rel;
TupleDesc pg_authid_dsc;
HeapTuple tuple,
@ -691,9 +687,6 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
/*
* Build an updated tuple, perusing the information just obtained
*/
MemSet(new_record, 0, sizeof(new_record));
MemSet(new_record_nulls, false, sizeof(new_record_nulls));
MemSet(new_record_repl, false, sizeof(new_record_repl));
/*
* issuper/createrole/etc
@ -1440,9 +1433,9 @@ AddRoleMems(const char *rolename, Oid roleid,
Oid memberid = lfirst_oid(iditem);
HeapTuple authmem_tuple;
HeapTuple tuple;
Datum new_record[Natts_pg_auth_members];
bool new_record_nulls[Natts_pg_auth_members];
bool new_record_repl[Natts_pg_auth_members];
Datum new_record[Natts_pg_auth_members] = {0};
bool new_record_nulls[Natts_pg_auth_members] = {0};
bool new_record_repl[Natts_pg_auth_members] = {0};
/*
* pg_database_owner is never a role member. Lifting this restriction
@ -1500,10 +1493,6 @@ AddRoleMems(const char *rolename, Oid roleid,
}
/* Build a tuple to insert or update */
MemSet(new_record, 0, sizeof(new_record));
MemSet(new_record_nulls, false, sizeof(new_record_nulls));
MemSet(new_record_repl, false, sizeof(new_record_repl));
new_record[Anum_pg_auth_members_roleid - 1] = ObjectIdGetDatum(roleid);
new_record[Anum_pg_auth_members_member - 1] = ObjectIdGetDatum(memberid);
new_record[Anum_pg_auth_members_grantor - 1] = ObjectIdGetDatum(grantorId);
@ -1614,15 +1603,11 @@ DelRoleMems(const char *rolename, Oid roleid,
{
/* Just turn off the admin option */
HeapTuple tuple;
Datum new_record[Natts_pg_auth_members];
bool new_record_nulls[Natts_pg_auth_members];
bool new_record_repl[Natts_pg_auth_members];
Datum new_record[Natts_pg_auth_members] = {0};
bool new_record_nulls[Natts_pg_auth_members] = {0};
bool new_record_repl[Natts_pg_auth_members] = {0};
/* Build a tuple to update with */
MemSet(new_record, 0, sizeof(new_record));
MemSet(new_record_nulls, false, sizeof(new_record_nulls));
MemSet(new_record_repl, false, sizeof(new_record_repl));
new_record[Anum_pg_auth_members_admin_option - 1] = BoolGetDatum(false);
new_record_repl[Anum_pg_auth_members_admin_option - 1] = true;

View File

@ -2926,13 +2926,12 @@ cost_agg(Path *path, PlannerInfo *root,
double output_tuples;
Cost startup_cost;
Cost total_cost;
AggClauseCosts dummy_aggcosts;
const AggClauseCosts dummy_aggcosts = {0};
/* Use all-zero per-aggregate costs if NULL is passed */
if (aggcosts == NULL)
{
Assert(aggstrategy == AGG_HASHED);
MemSet(&dummy_aggcosts, 0, sizeof(AggClauseCosts));
aggcosts = &dummy_aggcosts;
}

View File

@ -1594,9 +1594,8 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
* to. We have to build an additional level of ParseState
* to keep in step with varlevelsup in the subselect.
*/
ParseState mypstate;
ParseState mypstate = {0};
MemSet(&mypstate, 0, sizeof(mypstate));
mypstate.parentParseState = pstate;
mypstate.p_rtable = rte->subquery->rtable;
/* don't bother filling the rest of the fake pstate */

View File

@ -938,8 +938,8 @@ pg_stat_get_subscription(PG_FUNCTION_ARGS)
for (i = 0; i < max_logical_replication_workers; i++)
{
/* for each row */
Datum values[PG_STAT_GET_SUBSCRIPTION_COLS];
bool nulls[PG_STAT_GET_SUBSCRIPTION_COLS];
Datum values[PG_STAT_GET_SUBSCRIPTION_COLS] = {0};
bool nulls[PG_STAT_GET_SUBSCRIPTION_COLS] = {0};
int worker_pid;
LogicalRepWorker worker;
@ -953,9 +953,6 @@ pg_stat_get_subscription(PG_FUNCTION_ARGS)
worker_pid = worker.proc->pid;
MemSet(values, 0, sizeof(values));
MemSet(nulls, 0, sizeof(nulls));
values[0] = ObjectIdGetDatum(worker.subid);
if (OidIsValid(worker.relid))
values[1] = ObjectIdGetDatum(worker.relid);

View File

@ -402,7 +402,7 @@ IdentifySystem(void)
TupOutputState *tstate;
TupleDesc tupdesc;
Datum values[4];
bool nulls[4];
bool nulls[4] = {0};
TimeLineID currTLI;
/*
@ -437,7 +437,6 @@ IdentifySystem(void)
}
dest = CreateDestReceiver(DestRemoteSimple);
MemSet(nulls, false, sizeof(nulls));
/* need a tuple descriptor representing four columns */
tupdesc = CreateTemplateTupleDesc(4);
@ -483,7 +482,7 @@ ReadReplicationSlot(ReadReplicationSlotCmd *cmd)
DestReceiver *dest;
TupOutputState *tstate;
TupleDesc tupdesc;
Datum values[READ_REPLICATION_SLOT_COLS];
Datum values[READ_REPLICATION_SLOT_COLS] = {0};
bool nulls[READ_REPLICATION_SLOT_COLS];
tupdesc = CreateTemplateTupleDesc(READ_REPLICATION_SLOT_COLS);
@ -495,8 +494,7 @@ ReadReplicationSlot(ReadReplicationSlotCmd *cmd)
TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 3, "restart_tli",
INT8OID, -1, 0);
MemSet(values, 0, READ_REPLICATION_SLOT_COLS * sizeof(Datum));
MemSet(nulls, true, READ_REPLICATION_SLOT_COLS * sizeof(bool));
memset(nulls, true, READ_REPLICATION_SLOT_COLS * sizeof(bool));
LWLockAcquire(ReplicationSlotControlLock, LW_SHARED);
slot = SearchNamedReplicationSlot(cmd->slotname, false);
@ -859,13 +857,12 @@ StartReplication(StartReplicationCmd *cmd)
TupOutputState *tstate;
TupleDesc tupdesc;
Datum values[2];
bool nulls[2];
bool nulls[2] = {0};
snprintf(startpos_str, sizeof(startpos_str), "%X/%X",
LSN_FORMAT_ARGS(sendTimeLineValidUpto));
dest = CreateDestReceiver(DestRemoteSimple);
MemSet(nulls, false, sizeof(nulls));
/*
* Need a tuple descriptor representing two columns. int8 may seem
@ -1043,7 +1040,7 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
TupOutputState *tstate;
TupleDesc tupdesc;
Datum values[4];
bool nulls[4];
bool nulls[4] = {0};
Assert(!MyReplicationSlot);
@ -1178,7 +1175,6 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
LSN_FORMAT_ARGS(MyReplicationSlot->data.confirmed_flush));
dest = CreateDestReceiver(DestRemoteSimple);
MemSet(nulls, false, sizeof(nulls));
/*----------
* Need a tuple descriptor representing four columns:
@ -3488,7 +3484,7 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
TimestampTz replyTime;
bool is_sync_standby;
Datum values[PG_STAT_GET_WAL_SENDERS_COLS];
bool nulls[PG_STAT_GET_WAL_SENDERS_COLS];
bool nulls[PG_STAT_GET_WAL_SENDERS_COLS] = {0};
int j;
/* Collect data from shared memory */
@ -3527,7 +3523,6 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
}
}
memset(nulls, 0, sizeof(nulls));
values[0] = Int32GetDatum(pid);
if (!has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_STATS))

View File

@ -67,8 +67,7 @@ InsertRule(const char *rulname,
char *evqual = nodeToString(event_qual);
char *actiontree = nodeToString((Node *) action);
Datum values[Natts_pg_rewrite];
bool nulls[Natts_pg_rewrite];
bool replaces[Natts_pg_rewrite];
bool nulls[Natts_pg_rewrite] = {0};
NameData rname;
Relation pg_rewrite_desc;
HeapTuple tup,
@ -81,8 +80,6 @@ InsertRule(const char *rulname,
/*
* Set up *nulls and *values arrays
*/
MemSet(nulls, false, sizeof(nulls));
namestrcpy(&rname, rulname);
values[Anum_pg_rewrite_rulename - 1] = NameGetDatum(&rname);
values[Anum_pg_rewrite_ev_class - 1] = ObjectIdGetDatum(eventrel_oid);
@ -106,6 +103,8 @@ InsertRule(const char *rulname,
if (HeapTupleIsValid(oldtup))
{
bool replaces[Natts_pg_rewrite] = {0};
if (!replace)
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
@ -115,7 +114,6 @@ InsertRule(const char *rulname,
/*
* When replacing, we don't need to replace every attribute
*/
MemSet(replaces, false, sizeof(replaces));
replaces[Anum_pg_rewrite_ev_type - 1] = true;
replaces[Anum_pg_rewrite_is_instead - 1] = true;
replaces[Anum_pg_rewrite_ev_qual - 1] = true;

View File

@ -1785,7 +1785,7 @@ aclexplode(PG_FUNCTION_ARGS)
{
Datum result;
Datum values[4];
bool nulls[4];
bool nulls[4] = {0};
HeapTuple tuple;
values[0] = ObjectIdGetDatum(aidata->ai_grantor);
@ -1793,8 +1793,6 @@ aclexplode(PG_FUNCTION_ARGS)
values[2] = CStringGetTextDatum(convert_aclright_to_string(priv_bit));
values[3] = BoolGetDatum((ACLITEM_GET_GOPTIONS(*aidata) & priv_bit) != 0);
MemSet(nulls, 0, sizeof(nulls));
tuple = heap_form_tuple(funcctx->tuple_desc, values, nulls);
result = HeapTupleGetDatum(tuple);

View File

@ -742,11 +742,10 @@ ReadArrayStr(char *arrayStr,
bool eoArray = false;
bool hasnull;
int32 totbytes;
int indx[MAXDIM],
int indx[MAXDIM] = {0},
prod[MAXDIM];
mda_get_prod(ndim, dim, prod);
MemSet(indx, 0, sizeof(indx));
/* Initialize is-null markers to true */
memset(nulls, true, nitems * sizeof(bool));

View File

@ -4924,7 +4924,7 @@ pg_timezone_abbrevs(PG_FUNCTION_ARGS)
Datum result;
HeapTuple tuple;
Datum values[3];
bool nulls[3];
bool nulls[3] = {0};
const datetkn *tp;
char buffer[TOKMAXLEN + 1];
int gmtoffset;
@ -5011,8 +5011,6 @@ pg_timezone_abbrevs(PG_FUNCTION_ARGS)
break;
}
MemSet(nulls, 0, sizeof(nulls));
/*
* Convert name to text, using upcasing conversion that is the inverse of
* what ParseDateTime() uses.
@ -5051,7 +5049,7 @@ pg_timezone_names(PG_FUNCTION_ARGS)
pg_tzenum *tzenum;
pg_tz *tz;
Datum values[4];
bool nulls[4];
bool nulls[4] = {0};
int tzoff;
struct pg_tm tm;
fsec_t fsec;
@ -5088,8 +5086,6 @@ pg_timezone_names(PG_FUNCTION_ARGS)
if (tzn && strlen(tzn) > 31)
continue;
MemSet(nulls, 0, sizeof(nulls));
values[0] = CStringGetTextDatum(pg_get_timezone_name(tz));
values[1] = CStringGetTextDatum(tzn ? tzn : "");

View File

@ -172,8 +172,8 @@ pg_lock_status(PG_FUNCTION_ARGS)
LOCKMODE mode = 0;
const char *locktypename;
char tnbuf[32];
Datum values[NUM_LOCK_STATUS_COLUMNS];
bool nulls[NUM_LOCK_STATUS_COLUMNS];
Datum values[NUM_LOCK_STATUS_COLUMNS] = {0};
bool nulls[NUM_LOCK_STATUS_COLUMNS] = {0};
HeapTuple tuple;
Datum result;
LockInstanceData *instance;
@ -230,8 +230,6 @@ pg_lock_status(PG_FUNCTION_ARGS)
/*
* Form tuple with appropriate data.
*/
MemSet(values, 0, sizeof(values));
MemSet(nulls, false, sizeof(nulls));
if (instance->locktag.locktag_type <= LOCKTAG_LAST_TYPE)
locktypename = LockTagTypeNames[instance->locktag.locktag_type];
@ -359,8 +357,8 @@ pg_lock_status(PG_FUNCTION_ARGS)
PREDICATELOCKTARGETTAG *predTag = &(predLockData->locktags[mystatus->predLockIdx]);
SERIALIZABLEXACT *xact = &(predLockData->xacts[mystatus->predLockIdx]);
Datum values[NUM_LOCK_STATUS_COLUMNS];
bool nulls[NUM_LOCK_STATUS_COLUMNS];
Datum values[NUM_LOCK_STATUS_COLUMNS] = {0};
bool nulls[NUM_LOCK_STATUS_COLUMNS] = {0};
HeapTuple tuple;
Datum result;
@ -369,8 +367,6 @@ pg_lock_status(PG_FUNCTION_ARGS)
/*
* Form tuple with appropriate data.
*/
MemSet(values, 0, sizeof(values));
MemSet(nulls, false, sizeof(nulls));
/* lock type */
lockType = GET_PREDICATELOCKTARGETTAG_TYPE(*predTag);

View File

@ -113,8 +113,8 @@ pg_partition_tree(PG_FUNCTION_ARGS)
if (funcctx->call_cntr < list_length(partitions))
{
Datum result;
Datum values[PG_PARTITION_TREE_COLS];
bool nulls[PG_PARTITION_TREE_COLS];
Datum values[PG_PARTITION_TREE_COLS] = {0};
bool nulls[PG_PARTITION_TREE_COLS] = {0};
HeapTuple tuple;
Oid parentid = InvalidOid;
Oid relid = list_nth_oid(partitions, funcctx->call_cntr);
@ -126,8 +126,6 @@ pg_partition_tree(PG_FUNCTION_ARGS)
/*
* Form tuple with appropriate data.
*/
MemSet(nulls, 0, sizeof(nulls));
MemSet(values, 0, sizeof(values));
/* relid */
values[0] = ObjectIdGetDatum(relid);

View File

@ -488,13 +488,10 @@ pg_stat_get_progress_info(PG_FUNCTION_ARGS)
{
LocalPgBackendStatus *local_beentry;
PgBackendStatus *beentry;
Datum values[PG_STAT_GET_PROGRESS_COLS];
bool nulls[PG_STAT_GET_PROGRESS_COLS];
Datum values[PG_STAT_GET_PROGRESS_COLS] = {0};
bool nulls[PG_STAT_GET_PROGRESS_COLS] = {0};
int i;
MemSet(values, 0, sizeof(values));
MemSet(nulls, 0, sizeof(nulls));
local_beentry = pgstat_fetch_stat_local_beentry(curr_backend);
if (!local_beentry)
@ -551,17 +548,14 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
for (curr_backend = 1; curr_backend <= num_backends; curr_backend++)
{
/* for each row */
Datum values[PG_STAT_GET_ACTIVITY_COLS];
bool nulls[PG_STAT_GET_ACTIVITY_COLS];
Datum values[PG_STAT_GET_ACTIVITY_COLS] = {0};
bool nulls[PG_STAT_GET_ACTIVITY_COLS] = {0};
LocalPgBackendStatus *local_beentry;
PgBackendStatus *beentry;
PGPROC *proc;
const char *wait_event_type = NULL;
const char *wait_event = NULL;
MemSet(values, 0, sizeof(values));
MemSet(nulls, 0, sizeof(nulls));
/* Get the next one in the list */
local_beentry = pgstat_fetch_stat_local_beentry(curr_backend);
if (!local_beentry)
@ -1747,15 +1741,11 @@ pg_stat_get_wal(PG_FUNCTION_ARGS)
{
#define PG_STAT_GET_WAL_COLS 9
TupleDesc tupdesc;
Datum values[PG_STAT_GET_WAL_COLS];
bool nulls[PG_STAT_GET_WAL_COLS];
Datum values[PG_STAT_GET_WAL_COLS] = {0};
bool nulls[PG_STAT_GET_WAL_COLS] = {0};
char buf[256];
PgStat_WalStats *wal_stats;
/* Initialise values and NULL flags arrays */
MemSet(values, 0, sizeof(values));
MemSet(nulls, 0, sizeof(nulls));
/* Initialise attributes information in the tuple descriptor */
tupdesc = CreateTemplateTupleDesc(PG_STAT_GET_WAL_COLS);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "wal_records",
@ -1826,8 +1816,8 @@ pg_stat_get_slru(PG_FUNCTION_ARGS)
for (i = 0;; i++)
{
/* for each row */
Datum values[PG_STAT_GET_SLRU_COLS];
bool nulls[PG_STAT_GET_SLRU_COLS];
Datum values[PG_STAT_GET_SLRU_COLS] = {0};
bool nulls[PG_STAT_GET_SLRU_COLS] = {0};
PgStat_SLRUStats stat;
const char *name;
@ -1837,8 +1827,6 @@ pg_stat_get_slru(PG_FUNCTION_ARGS)
break;
stat = stats[i];
MemSet(values, 0, sizeof(values));
MemSet(nulls, 0, sizeof(nulls));
values[0] = PointerGetDatum(cstring_to_text(name));
values[1] = Int64GetDatum(stat.blocks_zeroed);
@ -2201,14 +2189,10 @@ Datum
pg_stat_get_archiver(PG_FUNCTION_ARGS)
{
TupleDesc tupdesc;
Datum values[7];
bool nulls[7];
Datum values[7] = {0};
bool nulls[7] = {0};
PgStat_ArchiverStats *archiver_stats;
/* Initialise values and NULL flags arrays */
MemSet(values, 0, sizeof(values));
MemSet(nulls, 0, sizeof(nulls));
/* Initialise attributes information in the tuple descriptor */
tupdesc = CreateTemplateTupleDesc(7);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "archived_count",
@ -2274,15 +2258,11 @@ pg_stat_get_replication_slot(PG_FUNCTION_ARGS)
text *slotname_text = PG_GETARG_TEXT_P(0);
NameData slotname;
TupleDesc tupdesc;
Datum values[PG_STAT_GET_REPLICATION_SLOT_COLS];
bool nulls[PG_STAT_GET_REPLICATION_SLOT_COLS];
Datum values[PG_STAT_GET_REPLICATION_SLOT_COLS] = {0};
bool nulls[PG_STAT_GET_REPLICATION_SLOT_COLS] = {0};
PgStat_StatReplSlotEntry *slotent;
PgStat_StatReplSlotEntry allzero;
/* Initialise values and NULL flags arrays */
MemSet(values, 0, sizeof(values));
MemSet(nulls, 0, sizeof(nulls));
/* Initialise attributes information in the tuple descriptor */
tupdesc = CreateTemplateTupleDesc(PG_STAT_GET_REPLICATION_SLOT_COLS);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "slot_name",
@ -2348,8 +2328,8 @@ pg_stat_get_subscription_stats(PG_FUNCTION_ARGS)
#define PG_STAT_GET_SUBSCRIPTION_STATS_COLS 4
Oid subid = PG_GETARG_OID(0);
TupleDesc tupdesc;
Datum values[PG_STAT_GET_SUBSCRIPTION_STATS_COLS];
bool nulls[PG_STAT_GET_SUBSCRIPTION_STATS_COLS];
Datum values[PG_STAT_GET_SUBSCRIPTION_STATS_COLS] = {0};
bool nulls[PG_STAT_GET_SUBSCRIPTION_STATS_COLS] = {0};
PgStat_StatSubEntry *subentry;
PgStat_StatSubEntry allzero;
@ -2368,10 +2348,6 @@ pg_stat_get_subscription_stats(PG_FUNCTION_ARGS)
TIMESTAMPTZOID, -1, 0);
BlessTupleDesc(tupdesc);
/* Initialise values and NULL flags arrays */
MemSet(values, 0, sizeof(values));
MemSet(nulls, 0, sizeof(nulls));
if (!subentry)
{
/* If the subscription is not found, initialise its stats */

View File

@ -6642,10 +6642,10 @@ btcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
double *indexPages)
{
IndexOptInfo *index = path->indexinfo;
GenericCosts costs;
GenericCosts costs = {0};
Oid relid;
AttrNumber colnum;
VariableStatData vardata;
VariableStatData vardata = {0};
double numIndexTuples;
Cost descentCost;
List *indexBoundQuals;
@ -6797,7 +6797,6 @@ btcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
/*
* Now do generic index cost estimation.
*/
MemSet(&costs, 0, sizeof(costs));
costs.numIndexTuples = numIndexTuples;
genericcostestimate(root, path, loop_count, &costs);
@ -6842,8 +6841,6 @@ btcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
* ordering, but don't negate it entirely. Before 8.0 we divided the
* correlation by the number of columns, but that seems too strong.)
*/
MemSet(&vardata, 0, sizeof(vardata));
if (index->indexkeys[0] != 0)
{
/* Simple variable --- look to stats for the underlying table */
@ -6947,9 +6944,7 @@ hashcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
Selectivity *indexSelectivity, double *indexCorrelation,
double *indexPages)
{
GenericCosts costs;
MemSet(&costs, 0, sizeof(costs));
GenericCosts costs = {0};
genericcostestimate(root, path, loop_count, &costs);
@ -6992,11 +6987,9 @@ gistcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
double *indexPages)
{
IndexOptInfo *index = path->indexinfo;
GenericCosts costs;
GenericCosts costs = {0};
Cost descentCost;
MemSet(&costs, 0, sizeof(costs));
genericcostestimate(root, path, loop_count, &costs);
/*
@ -7049,11 +7042,9 @@ spgcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
double *indexPages)
{
IndexOptInfo *index = path->indexinfo;
GenericCosts costs;
GenericCosts costs = {0};
Cost descentCost;
MemSet(&costs, 0, sizeof(costs));
genericcostestimate(root, path, loop_count, &costs);
/*

View File

@ -2403,7 +2403,7 @@ interval_cmp_value(const Interval *interval)
}
static int
interval_cmp_internal(Interval *interval1, Interval *interval2)
interval_cmp_internal(const Interval *interval1, const Interval *interval2)
{
INT128 span1 = interval_cmp_value(interval1);
INT128 span2 = interval_cmp_value(interval2);
@ -5777,7 +5777,7 @@ generate_series_timestamp(PG_FUNCTION_ARGS)
Timestamp finish = PG_GETARG_TIMESTAMP(1);
Interval *step = PG_GETARG_INTERVAL_P(2);
MemoryContext oldcontext;
Interval interval_zero;
const Interval interval_zero = {0};
/* create a function context for cross-call persistence */
funcctx = SRF_FIRSTCALL_INIT();
@ -5800,7 +5800,6 @@ generate_series_timestamp(PG_FUNCTION_ARGS)
fctx->step = *step;
/* Determine sign of the interval */
MemSet(&interval_zero, 0, sizeof(Interval));
fctx->step_sign = interval_cmp_internal(&fctx->step, &interval_zero);
if (fctx->step_sign == 0)
@ -5857,7 +5856,7 @@ generate_series_timestamptz(PG_FUNCTION_ARGS)
TimestampTz finish = PG_GETARG_TIMESTAMPTZ(1);
Interval *step = PG_GETARG_INTERVAL_P(2);
MemoryContext oldcontext;
Interval interval_zero;
const Interval interval_zero = {0};
/* create a function context for cross-call persistence */
funcctx = SRF_FIRSTCALL_INIT();
@ -5880,7 +5879,6 @@ generate_series_timestamptz(PG_FUNCTION_ARGS)
fctx->step = *step;
/* Determine sign of the interval */
MemSet(&interval_zero, 0, sizeof(Interval));
fctx->step_sign = interval_cmp_internal(&fctx->step, &interval_zero);
if (fctx->step_sign == 0)

View File

@ -1146,14 +1146,12 @@ pg_cursor(PG_FUNCTION_ARGS)
{
Portal portal = hentry->portal;
Datum values[6];
bool nulls[6];
bool nulls[6] = {0};
/* report only "visible" entries */
if (!portal->visible)
continue;
MemSet(nulls, 0, sizeof(nulls));
values[0] = CStringGetTextDatum(portal->name);
values[1] = CStringGetTextDatum(portal->sourceText);
values[2] = BoolGetDatum(portal->cursorOptions & CURSOR_OPT_HOLD);

View File

@ -447,7 +447,7 @@ reached_end_position(XLogRecPtr segendpos, uint32 timeline,
{
#ifndef WIN32
fd_set fds;
struct timeval tv;
struct timeval tv = {0};
int r;
/*
@ -457,16 +457,13 @@ reached_end_position(XLogRecPtr segendpos, uint32 timeline,
FD_ZERO(&fds);
FD_SET(bgpipe[0], &fds);
MemSet(&tv, 0, sizeof(tv));
r = select(bgpipe[0] + 1, &fds, NULL, NULL, &tv);
if (r == 1)
{
char xlogend[64];
char xlogend[64] = {0};
uint32 hi,
lo;
MemSet(xlogend, 0, sizeof(xlogend));
r = read(bgpipe[0], xlogend, sizeof(xlogend) - 1);
if (r < 0)
pg_fatal("could not read from ready pipe: %m");
@ -528,11 +525,10 @@ typedef struct
static int
LogStreamerMain(logstreamer_param *param)
{
StreamCtl stream;
StreamCtl stream = {0};
in_log_streamer = true;
MemSet(&stream, 0, sizeof(stream));
stream.startpos = param->startptr;
stream.timeline = param->timeline;
stream.sysidentifier = param->sysidentifier;
@ -1758,7 +1754,7 @@ BaseBackup(char *compression_algorithm, char *compression_detail,
char *basebkp;
int i;
char xlogstart[64];
char xlogend[64];
char xlogend[64] = {0};
int minServerMajor,
maxServerMajor;
int serverVersion,
@ -1952,7 +1948,6 @@ BaseBackup(char *compression_algorithm, char *compression_detail,
else
starttli = latesttli;
PQclear(res);
MemSet(xlogend, 0, sizeof(xlogend));
if (verbose && includewal != NO_WAL)
pg_log_info("write-ahead log start point: %s on timeline %u",

View File

@ -564,11 +564,9 @@ StreamLog(void)
{
XLogRecPtr serverpos;
TimeLineID servertli;
StreamCtl stream;
StreamCtl stream = {0};
char *sysidentifier;
MemSet(&stream, 0, sizeof(stream));
/*
* Connect in replication mode to the server
*/

View File

@ -1111,9 +1111,8 @@ tar_close(Walfile f, WalCloseMethod method)
padding = tarPaddingBytesRequired(filesize);
if (padding)
{
char zerobuf[TAR_BLOCK_SIZE];
char zerobuf[TAR_BLOCK_SIZE] = {0};
MemSet(zerobuf, 0, padding);
if (tar_write(f, zerobuf, padding) != padding)
return -1;
}
@ -1222,7 +1221,7 @@ tar_existsfile(const char *pathname)
static bool
tar_finish(void)
{
char zerobuf[1024];
char zerobuf[1024] = {0};
tar_clear_error();
@ -1233,7 +1232,6 @@ tar_finish(void)
}
/* A tarfile always ends with two empty blocks */
MemSet(zerobuf, 0, sizeof(zerobuf));
if (tar_data->compression_algorithm == PG_COMPRESSION_NONE)
{
errno = 0;

View File

@ -165,14 +165,12 @@ static int
getaddrinfo_unix(const char *path, const struct addrinfo *hintsp,
struct addrinfo **result)
{
struct addrinfo hints;
struct addrinfo hints = {0};
struct addrinfo *aip;
struct sockaddr_un *unp;
*result = NULL;
MemSet(&hints, 0, sizeof(hints));
if (strlen(path) >= sizeof(unp->sun_path))
return EAI_FAIL;

View File

@ -756,12 +756,8 @@ find_arguments(const char *format, va_list args,
int longflag;
int fmtpos;
int i;
int last_dollar;
PrintfArgType argtypes[PG_NL_ARGMAX + 1];
/* Initialize to "no dollar arguments known" */
last_dollar = 0;
MemSet(argtypes, 0, sizeof(argtypes));
int last_dollar = 0; /* Init to "no dollar arguments known" */
PrintfArgType argtypes[PG_NL_ARGMAX + 1] = {0};
/*
* This loop must accept the same format strings as the one in dopr().

View File

@ -50,7 +50,7 @@ test_predtest(PG_FUNCTION_ARGS)
strong_refuted_by,
weak_refuted_by;
Datum values[8];
bool nulls[8];
bool nulls[8] = {0};
int i;
/* We use SPI to parse, plan, and execute the test query */
@ -204,7 +204,6 @@ test_predtest(PG_FUNCTION_ARGS)
"w_r_holds", BOOLOID, -1, 0);
tupdesc = BlessTupleDesc(tupdesc);
MemSet(nulls, 0, sizeof(nulls));
values[0] = BoolGetDatum(strong_implied_by);
values[1] = BoolGetDatum(weak_implied_by);
values[2] = BoolGetDatum(strong_refuted_by);

View File

@ -1110,7 +1110,7 @@ test_enc_conversion(PG_FUNCTION_ARGS)
int convertedbytes;
int dstlen;
Datum values[2];
bool nulls[2];
bool nulls[2] = {0};
HeapTuple tuple;
if (src_encoding < 0)
@ -1199,7 +1199,6 @@ test_enc_conversion(PG_FUNCTION_ARGS)
pfree(dst);
}
MemSet(nulls, 0, sizeof(nulls));
values[0] = Int32GetDatum(convertedbytes);
values[1] = PointerGetDatum(retval);
tuple = heap_form_tuple(tupdesc, values, nulls);