Skip to content

Commit

Permalink
Insert newline before else (#194)
Browse files Browse the repository at this point in the history
Insert newline before `else` to keep aligned with gpdb repository.
  • Loading branch information
liuxueyang authored Mar 31, 2022
1 parent 423269b commit 1d30b1e
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 23 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ BraceWrapping:
BeforeCatch: true
SplitEmptyFunction: false
SplitEmptyRecord: false
BeforeElse: true

SortIncludes: false
6 changes: 4 additions & 2 deletions diskquota.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ _PG_init(void)
{
ereport(ERROR, (errmsg("[diskquota] booting " DISKQUOTA_VERSION ", but " DISKQUOTA_BINARY_NAME
" not in shared_preload_libraries. abort.")));
} else
}
else
{
ereport(INFO, (errmsg("booting diskquota-" DISKQUOTA_VERSION)));
}
Expand Down Expand Up @@ -298,7 +299,8 @@ disk_quota_worker_main(Datum main_arg)
snprintf(_errmsg, sizeof(_errmsg), _errfmt, times * diskquota_naptime);

init_ps_display("bgworker:", "[diskquota]", dbname, _errmsg);
} else
}
else
{
init_ps_display("bgworker:", "[diskquota]", dbname,
"v" DISKQUOTA_VERSION " is not matching with current SQL. stop working");
Expand Down
21 changes: 14 additions & 7 deletions diskquota_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ dispatch_pause_or_resume_command(Oid dbid, bool pause_extension)
if (dbid == InvalidOid)
{
appendStringInfo(&sql, "()");
} else
}
else
{
appendStringInfo(&sql, "(%d)", dbid);
}
Expand Down Expand Up @@ -854,7 +855,8 @@ set_quota_config_internal(Oid targetoid, int64 quota_limit_mb, QuotaType type)
},
NULL, false, 0);
if (ret != SPI_OK_INSERT) elog(ERROR, "cannot insert into quota setting table, error code %d", ret);
} else if (SPI_processed > 0 && quota_limit_mb < 0)
}
else if (SPI_processed > 0 && quota_limit_mb < 0)
{
ret = SPI_execute_with_args("delete from diskquota.quota_config where targetoid = $1 and quotatype = $2", 2,
(Oid[]){
Expand All @@ -867,7 +869,8 @@ set_quota_config_internal(Oid targetoid, int64 quota_limit_mb, QuotaType type)
},
NULL, false, 0);
if (ret != SPI_OK_DELETE) elog(ERROR, "cannot delete item from quota setting table, error code %d", ret);
} else if (SPI_processed > 0 && quota_limit_mb > 0)
}
else if (SPI_processed > 0 && quota_limit_mb > 0)
{
ret = SPI_execute_with_args(
"update diskquota.quota_config set quotalimitMB = $1 where targetoid= $2 and quotatype = $3", 3,
Expand Down Expand Up @@ -940,7 +943,8 @@ set_target_internal(Oid primaryoid, Oid spcoid, int64 quota_limit_mb, QuotaType
},
NULL, false, 0);
if (ret != SPI_OK_INSERT) elog(ERROR, "cannot insert into quota setting table, error code %d", ret);
} else if (SPI_processed > 0 && quota_limit_mb < 0)
}
else if (SPI_processed > 0 && quota_limit_mb < 0)
{
ret = SPI_execute_with_args("delete from diskquota.target where primaryOid = $1 and tablespaceOid = $2", 2,
(Oid[]){
Expand Down Expand Up @@ -1104,7 +1108,8 @@ update_diskquota_db_list(Oid dbid, HASHACTION action)
{
ereport(WARNING, (errmsg("can't alloc memory on dbid cache, there ary too many databases to monitor")));
}
} else if (action == HASH_REMOVE)
}
else if (action == HASH_REMOVE)
{
hash_search(monitoring_dbid_cache, &dbid, HASH_REMOVE, &found);
if (!found)
Expand Down Expand Up @@ -1360,7 +1365,8 @@ calculate_relation_size_all_forks(RelFileNodeBackend *rnode, char relstorage)
totalsize += ctx.size;
}
return totalsize;
} else if (relstorage == RELSTORAGE_AOROWS || relstorage == RELSTORAGE_AOCOLS)
}
else if (relstorage == RELSTORAGE_AOROWS || relstorage == RELSTORAGE_AOCOLS)
{
RelationFileStatCtx ctx = {0};
ctx.relation_path = relpathbackend(rnode->node, rnode->backend, MAIN_FORKNUM);
Expand All @@ -1373,7 +1379,8 @@ calculate_relation_size_all_forks(RelFileNodeBackend *rnode, char relstorage)
relation_file_stat(0, &ctx);
ao_foreach_extent_file(relation_file_stat, &ctx);
return ctx.size;
} else
}
else
{
return 0;
}
Expand Down
21 changes: 14 additions & 7 deletions gp_activetable.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ gp_fetch_active_tables(bool is_init)
if (is_init)
{
load_table_size(local_table_stats_map);
} else
}
else
{
/* step 1: fetch active oids from all the segments */
local_active_table_oid_maps = pull_active_list_from_seg();
Expand Down Expand Up @@ -426,7 +427,8 @@ diskquota_fetch_table_stat(PG_FUNCTION_ARGS)
hash_seq_init(&(cache->pos), localCacheTable);

MemoryContextSwitchTo(oldcontext);
} else
}
else
{
isFirstCall = false;
}
Expand All @@ -436,7 +438,8 @@ diskquota_fetch_table_stat(PG_FUNCTION_ARGS)
if (isFirstCall)
{
funcctx->user_fctx = (void *)cache;
} else
}
else
{
cache = (DiskQuotaSetOFCache *)funcctx->user_fctx;
}
Expand Down Expand Up @@ -521,7 +524,8 @@ get_active_tables_stats(ArrayType *array)
if (bitmap && (*bitmap & bitmask) == 0)
{
continue;
} else
}
else
{
relOid = DatumGetObjectId(fetch_att(ptr, typbyval, typlen));
segId = GpIdentity.segindex;
Expand Down Expand Up @@ -795,7 +799,8 @@ load_table_size(HTAB *local_table_stats_map)
if (tupdesc->natts != 3)
{
ereport(WARNING, (errmsg("[diskquota] tupdesc->natts: %d", tupdesc->natts)));
} else
}
else
{
ereport(WARNING, (errmsg("[diskquota] attrs: %d, %d, %d", tupdesc->attrs[0]->atttypid,
tupdesc->attrs[1]->atttypid, tupdesc->attrs[2]->atttypid)));
Expand Down Expand Up @@ -861,7 +866,8 @@ convert_map_to_string(HTAB *local_active_table_oid_maps)
if (count != nitems)
{
appendStringInfo(&buffer, "%d,", entry->reloid);
} else
}
else
{
appendStringInfo(&buffer, "%d", entry->reloid);
}
Expand Down Expand Up @@ -1016,7 +1022,8 @@ pull_active_table_size_from_seg(HTAB *local_table_stats_map, char *active_oid_ar
entry->reloid = reloid;
entry->tablesize = tableSize;
entry->segid = -1;
} else
}
else
{
/* sum table size from all the segments */
entry->tablesize = entry->tablesize + tableSize;
Expand Down
18 changes: 12 additions & 6 deletions quotamodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ update_limit_for_quota(int64 limit, float segratio, QuotaType type, Oid *keys)
if (key.segid == -1)
{
entry->limit = limit;
} else
}
else
{
entry->limit = round((limit / SEGCOUNT) * segratio);
}
Expand Down Expand Up @@ -817,7 +818,8 @@ calculate_table_disk_usage(bool is_init, HTAB *local_active_table_stat_map)
{
reltablespace = MyDatabaseTableSpace;
}
} else
}
else
{
LWLockAcquire(diskquota_locks.relation_cache_lock, LW_SHARED);
DiskQuotaRelationCacheEntry *relation_entry = hash_search(relation_cache, &relOid, HASH_FIND, NULL);
Expand Down Expand Up @@ -1065,7 +1067,8 @@ flush_local_black_map(void)
ereport(WARNING, (errmsg("[diskquota] Shared disk quota black map size limit reached."
"Some out-of-limit schemas or roles will be lost"
"in blacklist.")));
} else
}
else
{
/* new db objects which exceed quota limit */
if (!found)
Expand All @@ -1080,7 +1083,8 @@ flush_local_black_map(void)
blackentry->segexceeded = localblackentry->segexceeded;
localblackentry->isexceeded = false;
localblackentry->segexceeded = false;
} else
}
else
{
/* db objects are removed or under quota limit in the new loop */
(void)hash_search(disk_quota_black_map, (void *)&localblackentry->keyitem, HASH_REMOVE, NULL);
Expand Down Expand Up @@ -1281,7 +1285,8 @@ do_load_quotas(void)
quotaType, quota_info[quotaType].num_keys)));
}
update_limit_for_quota(quota_limit_mb * (1 << 20), segratio, quotaType, (Oid[]){targetOid});
} else
}
else
{
update_limit_for_quota(quota_limit_mb * (1 << 20), segratio, quotaType, (Oid[]){targetOid, spcOid});
}
Expand Down Expand Up @@ -1767,7 +1772,8 @@ refresh_blackmap(PG_FUNCTION_ARGS)
break;
}
}
} else
}
else
{
/*
* We cannot fetch the relation from syscache. It may be an uncommitted relation.
Expand Down
3 changes: 2 additions & 1 deletion relation_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ parse_primary_table_oid(Oid relid, bool on_bgworker)
{
return InvalidOid;
}
} else
}
else
{
rel = diskquota_relation_open(relid, NoLock);
if (rel == NULL)
Expand Down

0 comments on commit 1d30b1e

Please sign in to comment.