diff --git a/src/backend/distributed/deparser/citus_ruleutils.c b/src/backend/distributed/deparser/citus_ruleutils.c index 8a64e5fc8..0389e595c 100644 --- a/src/backend/distributed/deparser/citus_ruleutils.c +++ b/src/backend/distributed/deparser/citus_ruleutils.c @@ -532,8 +532,9 @@ pg_get_tablecolumnoptionsdef_string(Oid tableRelationId) ereport(ERROR, (errmsg("bad number of tuple descriptor attributes"))); } + AttrNumber natts = tupleDescriptor->natts; for (AttrNumber attributeIndex = 0; - attributeIndex < (AttrNumber) tupleDescriptor->natts; + attributeIndex < natts; attributeIndex++) { Form_pg_attribute attributeForm = TupleDescAttr(tupleDescriptor, attributeIndex); diff --git a/src/backend/distributed/planner/recursive_planning.c b/src/backend/distributed/planner/recursive_planning.c index d673b1545..c65a860cd 100644 --- a/src/backend/distributed/planner/recursive_planning.c +++ b/src/backend/distributed/planner/recursive_planning.c @@ -1440,7 +1440,8 @@ TransformFunctionRTE(RangeTblEntry *rangeTblEntry) { ereport(ERROR, (errmsg("bad number of tuple descriptor attributes"))); } - for (targetColumnIndex = 0; targetColumnIndex < (AttrNumber) tupleDesc->natts; + AttrNumber natts = tupleDesc->natts; + for (targetColumnIndex = 0; targetColumnIndex < natts; targetColumnIndex++) { FormData_pg_attribute *attribute = TupleDescAttr(tupleDesc, diff --git a/src/backend/distributed/worker/worker_partition_protocol.c b/src/backend/distributed/worker/worker_partition_protocol.c index 2aa4bcf31..4d1d5aa14 100644 --- a/src/backend/distributed/worker/worker_partition_protocol.c +++ b/src/backend/distributed/worker/worker_partition_protocol.c @@ -780,7 +780,12 @@ CitusRemoveDirectory(const char *filename) /* we now have an empty directory or a regular file, remove it */ if (S_ISDIR(fileStat.st_mode)) { - removed = rmdir(filename); + /* + * We ignore the TOCTUO race condition static analysis warning + * here, since we don't actually read the files or directories. We + * simply want to remove them. + */ + removed = rmdir(filename); /* lgtm[cpp/toctou-race-condition] */ if (errno == ENOTEMPTY || errno == EEXIST) { @@ -789,7 +794,12 @@ CitusRemoveDirectory(const char *filename) } else { - removed = unlink(filename); + /* + * We ignore the TOCTUO race condition static analysis warning + * here, since we don't actually read the files or directories. We + * simply want to remove them. + */ + removed = unlink(filename); /* lgtm[cpp/toctou-race-condition] */ } if (removed != 0 && errno != ENOENT)