Refactor VacuumStmt checker to be single-return

Decided this would be safer for the future (defaults to unsupported).
pull/1836/head
Jason Petersen 2017-11-27 11:49:46 -07:00
parent b12e77ab0e
commit 0eacf6bd95
No known key found for this signature in database
GPG Key ID: 9F1D3510D110ABA9
1 changed files with 12 additions and 16 deletions

View File

@ -1534,43 +1534,39 @@ static bool
IsSupportedDistributedVacuumStmt(Oid relationId, VacuumStmt *vacuumStmt) IsSupportedDistributedVacuumStmt(Oid relationId, VacuumStmt *vacuumStmt)
{ {
const char *stmtName = (vacuumStmt->options & VACOPT_VACUUM) ? "VACUUM" : "ANALYZE"; const char *stmtName = (vacuumStmt->options & VACOPT_VACUUM) ? "VACUUM" : "ANALYZE";
bool distributeStmt = false;
if (vacuumStmt->relation == NULL) if (vacuumStmt->relation == NULL)
{ {
/* WARN and exit early for unqualified VACUUM commands */ /* WARN for unqualified VACUUM commands */
ereport(WARNING, (errmsg("not propagating %s command to worker nodes", stmtName), ereport(WARNING, (errmsg("not propagating %s command to worker nodes", stmtName),
errhint("Provide a specific table in order to %s " errhint("Provide a specific table in order to %s "
"distributed tables.", stmtName))); "distributed tables.", stmtName)));
return false;
} }
else if (!OidIsValid(relationId) || !IsDistributedTable(relationId))
if (!OidIsValid(relationId) || !IsDistributedTable(relationId))
{ {
return false; /* Nothing to do here; relation no longer exists or is not distributed */
} }
else if (!EnableDDLPropagation)
if (!EnableDDLPropagation)
{ {
/* WARN and exit early if DDL propagation is not enabled */ /* WARN if DDL propagation is not enabled */
ereport(WARNING, (errmsg("not propagating %s command to worker nodes", stmtName), ereport(WARNING, (errmsg("not propagating %s command to worker nodes", stmtName),
errhint("Set citus.enable_ddl_propagation to true in order to " errhint("Set citus.enable_ddl_propagation to true in order to "
"send targeted %s commands to worker nodes.", "send targeted %s commands to worker nodes.",
stmtName))); stmtName)));
return false;
} }
else if (vacuumStmt->options & VACOPT_VERBOSE)
if (vacuumStmt->options & VACOPT_VERBOSE)
{ {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("the VERBOSE option is currently unsupported in " errmsg("the VERBOSE option is currently unsupported in "
"distributed %s commands", stmtName))); "distributed %s commands", stmtName)));
}
return false; else
{
distributeStmt = true;
} }
return true; return distributeStmt;
} }