aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/dbcommands.c35
-rw-r--r--src/backend/commands/event_trigger.c11
-rw-r--r--src/backend/commands/functioncmds.c7
-rw-r--r--src/backend/commands/prepare.c4
-rw-r--r--src/backend/commands/tablecmds.c44
-rw-r--r--src/backend/commands/tablespace.c4
-rw-r--r--src/backend/commands/typecmds.c9
-rw-r--r--src/backend/commands/user.c37
8 files changed, 46 insertions, 105 deletions
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 1901b434c58..099d369b2f4 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -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);
diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c
index f46f86474aa..eef3e5d56e5 100644
--- a/src/backend/commands/event_trigger.c
+++ b/src/backend/commands/event_trigger.c
@@ -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:
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index b016eecb2cd..59e3af626fa 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -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;
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c
index 2333aae4673..579825c1593 100644
--- a/src/backend/commands/prepare.c
+++ b/src/backend/commands/prepare.c
@@ -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);
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index f2947ea9b49..a2f577024a1 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -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;
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index c8bdd9992ac..cb7d46089a3 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -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 */
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index a8757a90bf8..d0d87a1184a 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -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)
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index 984305ba31c..5b24b6dcad8 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -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;