From 1d30b1ec278a7120fb2957e2af1e51c5ab0a264d Mon Sep 17 00:00:00 2001 From: LXY Date: Thu, 31 Mar 2022 11:15:00 +0800 Subject: [PATCH] Insert newline before `else` (#194) Insert newline before `else` to keep aligned with gpdb repository. --- .clang-format | 1 + diskquota.c | 6 ++++-- diskquota_utility.c | 21 ++++++++++++++------- gp_activetable.c | 21 ++++++++++++++------- quotamodel.c | 18 ++++++++++++------ relation_cache.c | 3 ++- 6 files changed, 47 insertions(+), 23 deletions(-) diff --git a/.clang-format b/.clang-format index f4315b44..63a1d635 100644 --- a/.clang-format +++ b/.clang-format @@ -35,5 +35,6 @@ BraceWrapping: BeforeCatch: true SplitEmptyFunction: false SplitEmptyRecord: false + BeforeElse: true SortIncludes: false diff --git a/diskquota.c b/diskquota.c index 7c5c0c9b..de7b9163 100644 --- a/diskquota.c +++ b/diskquota.c @@ -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))); } @@ -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"); diff --git a/diskquota_utility.c b/diskquota_utility.c index 612850be..dc70c2d1 100644 --- a/diskquota_utility.c +++ b/diskquota_utility.c @@ -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); } @@ -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[]){ @@ -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, @@ -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[]){ @@ -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) @@ -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); @@ -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; } diff --git a/gp_activetable.c b/gp_activetable.c index 06ca5cfa..559f5688 100644 --- a/gp_activetable.c +++ b/gp_activetable.c @@ -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(); @@ -426,7 +427,8 @@ diskquota_fetch_table_stat(PG_FUNCTION_ARGS) hash_seq_init(&(cache->pos), localCacheTable); MemoryContextSwitchTo(oldcontext); - } else + } + else { isFirstCall = false; } @@ -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; } @@ -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; @@ -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))); @@ -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); } @@ -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; diff --git a/quotamodel.c b/quotamodel.c index 4b7c3427..b457e3bb 100644 --- a/quotamodel.c +++ b/quotamodel.c @@ -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); } @@ -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); @@ -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) @@ -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); @@ -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}); } @@ -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. diff --git a/relation_cache.c b/relation_cache.c index 91a1f995..0cf96df8 100644 --- a/relation_cache.c +++ b/relation_cache.c @@ -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)