Fix Semmle errors (#4636)

Co-authored-by: Halil Ozan Akgül <hozanakgul@gmail.com>
pull/4667/head
Hanefi Onaldi 2021-02-08 18:37:44 +03:00 committed by GitHub
parent e96da4886f
commit 353b080474
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 43 additions and 13 deletions

View File

@ -1418,7 +1418,15 @@ CheckAlterDistributedTableConversionParameters(TableConversionState *con)
Var *colocateWithPartKey = DistPartitionKey(colocateWithTableOid);
if (con->distributionColumn &&
if (colocateWithPartKey == NULL)
{
/* this should never happen */
ereport(ERROR, (errmsg("cannot colocate %s with %s because %s doesn't have a "
"distribution column",
con->relationName, con->colocateWith,
con->colocateWith)));
}
else if (con->distributionColumn &&
colocateWithPartKey->vartype != con->distributionKey->vartype)
{
ereport(ERROR, (errmsg("cannot colocate with %s and change distribution "

View File

@ -68,6 +68,13 @@ CascadeOperationForConnectedRelations(Oid relationId, LOCKMODE lockMode,
InvalidateForeignKeyGraph();
List *fKeyConnectedRelationIdList = GetForeignKeyConnectedRelationIdList(relationId);
/* early exit if there are no connected relations */
if (fKeyConnectedRelationIdList == NIL)
{
return;
}
LockRelationsWithLockMode(fKeyConnectedRelationIdList, lockMode);
/*

View File

@ -181,13 +181,13 @@ ChooseIndexColumnNames(List *indexElems)
{
break; /* found nonconflicting name */
}
sprintf(nbuf, "%d", i);
sprintf(nbuf, "%d", i); /* lgtm[cpp/banned-api-usage-required-any] */
/* Ensure generated names are shorter than NAMEDATALEN */
nlen = pg_mbcliplen(origname, strlen(origname),
NAMEDATALEN - 1 - strlen(nbuf));
memcpy(buf, origname, nlen);
strcpy(buf + nlen, nbuf);
memcpy(buf, origname, nlen); /* lgtm[cpp/banned-api-usage-required-any] */
strcpy(buf + nlen, nbuf); /* lgtm[cpp/banned-api-usage-required-any] */
curname = buf;
}

View File

@ -682,7 +682,7 @@ ProcessUtilityInternal(PlannedStmt *pstmt,
* Ensure value is valid, we can't do some checks during CREATE
* EXTENSION. This is important to register some invalidation callbacks.
*/
CitusHasBeenLoaded();
CitusHasBeenLoaded(); /* lgtm[cpp/return-value-ignored] */
}
}

View File

@ -849,7 +849,7 @@ InitializeTableCacheEntry(int64 shardId)
Oid relationId = LookupShardRelationFromCatalog(shardId, missingOk);
/* trigger building the cache for the shard id */
GetCitusTableCacheEntry(relationId);
GetCitusTableCacheEntry(relationId); /* lgtm[cpp/return-value-ignored] */
}

View File

@ -509,7 +509,13 @@ ExecuteRemoteQueryOrCommand(char *nodeName, uint32 nodePort, char *queryString,
return false;
}
SendRemoteCommand(connection, queryString);
if (!SendRemoteCommand(connection, queryString))
{
appendStringInfo(queryResultString, "failed to send query to %s:%d", nodeName,
(int) nodePort);
return false;
}
PGresult *queryResult = GetRemoteCommandResult(connection, raiseInterrupts);
bool success = EvaluateQueryResult(connection, queryResult, queryResultString);

View File

@ -237,7 +237,7 @@ ResultRTEIdentity(Query *query)
int resultRTEIdentity = INVALID_RTE_IDENTITY;
if (IsModifyCommand(query))
{
RangeTblEntry *resultRTE = ExtractResultRelationRTE(query);
RangeTblEntry *resultRTE = ExtractResultRelationRTEOrError(query);
resultRTEIdentity = GetRTEIdentity(resultRTE);
}
return resultRTEIdentity;

View File

@ -200,10 +200,14 @@ GetRemoteProcessId()
appendStringInfo(queryStringInfo, GET_PROCESS_ID);
ExecuteOptionalRemoteCommand(singleConnection, queryStringInfo->data, &result);
int queryResult = ExecuteOptionalRemoteCommand(singleConnection,
queryStringInfo->data, &result);
if (queryResult != RESPONSE_OKAY)
{
PG_RETURN_VOID();
}
int64 rowCount = PQntuples(result);
if (rowCount != 1)
{
PG_RETURN_VOID();

View File

@ -87,8 +87,13 @@ fix_pre_citus10_partitioned_table_constraint_names(PG_FUNCTION_ARGS)
}
List *taskList = CreateFixPartitionConstraintsTaskList(relationId);
/* do not do anything if there are no constraints that should be fixed */
if (taskList != NIL)
{
bool localExecutionSupported = true;
ExecuteUtilityTaskList(taskList, localExecutionSupported);
}
PG_RETURN_VOID();
}