From 9d97e5aebf07826236cf3ae184ab838ecf529697 Mon Sep 17 00:00:00 2001 From: jsc0218 Date: Sat, 26 Sep 2020 14:44:35 -0400 Subject: [PATCH] remove parenthesis inside ereport --- src/client/kv_client.cc | 4 +-- src/ipc/kv_mq.cc | 4 +-- src/ipc/kv_posix.cc | 24 ++++++++-------- src/kv_fdw.c | 56 ++++++++++++++++++------------------- src/kv_utility.c | 60 ++++++++++++++++++++-------------------- src/server/kv_manager.cc | 2 +- src/server/kv_storage.cc | 4 +-- src/server/kv_worker.cc | 10 +++---- 8 files changed, 82 insertions(+), 82 deletions(-) diff --git a/src/client/kv_client.cc b/src/client/kv_client.cc index bd8c392..a7cda89 100644 --- a/src/client/kv_client.cc +++ b/src/client/kv_client.cc @@ -56,12 +56,12 @@ static KVWorkerClient* GetKVWorkerClient(KVWorkerId workerId) { return worker; } - ereport(ERROR, (errcode(ERRCODE_CONFIGURATION_LIMIT_EXCEEDED), + ereport(ERROR, errcode(ERRCODE_CONFIGURATION_LIMIT_EXCEEDED), errmsg("too many background workers"), errhint("Up to %d background workers can be registered with" " the current settings.", max_worker_processes), errhint("Consider increasing the configuration parameter " - "\"max_worker_processes\"."))); + "\"max_worker_processes\".")); return nullptr; } diff --git a/src/ipc/kv_mq.cc b/src/ipc/kv_mq.cc index 787b830..d64901f 100644 --- a/src/ipc/kv_mq.cc +++ b/src/ipc/kv_mq.cc @@ -55,7 +55,7 @@ void KVMessageQueue::Send(const KVMessage& msg) { if (isServer_) { if (msg.hdr.rpsId == 0) { - ereport(WARNING, (errmsg("invalid response channel"))); + ereport(WARNING, errmsg("invalid response channel")); return; } @@ -74,7 +74,7 @@ void KVMessageQueue::Recv(KVMessage& msg, int flag) { channel = request_; } else { if (msg.hdr.rpsId == 0) { - ereport(WARNING, (errmsg("invalid response channel"))); + ereport(WARNING, errmsg("invalid response channel")); return; } diff --git a/src/ipc/kv_posix.cc b/src/ipc/kv_posix.cc index 3801fa0..f4838b9 100644 --- a/src/ipc/kv_posix.cc +++ b/src/ipc/kv_posix.cc @@ -23,15 +23,15 @@ extern "C" { int ShmOpen(const char* name, int flag, mode_t mode, const char* func) { int fd = shm_open(name, flag, mode); if (fd == -1) { - ereport(ERROR, (errmsg("%s %s failed", func, __func__))); + ereport(ERROR, errmsg("%s %s failed", func, __func__)); } return fd; } void ShmUnlink(const char* name, const char* func) { if (shm_unlink(name) == -1) { - ereport(WARNING, (errmsg("%s %s failed", func, __func__), - errhint("maybe no shared memory to unlink"))); + ereport(WARNING, errmsg("%s %s failed", func, __func__), + errhint("maybe no shared memory to unlink")); } } @@ -39,45 +39,45 @@ void* Mmap(void* addr, size_t len, int prot, int flag, int fd, off_t offset, const char* func) { void* ptr = mmap(addr, len, prot, flag, fd, offset); if (ptr == MAP_FAILED) { - ereport(ERROR, (errmsg("%s %s failed", func, __func__))); + ereport(ERROR, errmsg("%s %s failed", func, __func__)); } return ptr; } void Munmap(void* addr, size_t len, const char* func) { if (munmap(addr, len) == -1) { - ereport(ERROR, (errmsg("%s %s failed", func, __func__))); + ereport(ERROR, errmsg("%s %s failed", func, __func__)); } } void Ftruncate(int fd, off_t length, const char* func) { if (ftruncate(fd, length) == -1) { - ereport(ERROR, (errmsg("%s %s failed", func, __func__))); + ereport(ERROR, errmsg("%s %s failed", func, __func__)); } } void Fclose(int fd, const char* func) { if (close(fd) == -1) { - ereport(ERROR, (errmsg("%s %s failed", func, __func__))); + ereport(ERROR, errmsg("%s %s failed", func, __func__)); } } void SemInit(volatile sem_t* sem, int pshared, unsigned int value, const char* func) { if (sem_init((sem_t*) sem, pshared, value) == -1) { - ereport(ERROR, (errmsg("%s %s failed", func, __func__))); + ereport(ERROR, errmsg("%s %s failed", func, __func__)); } } void SemDestroy(volatile sem_t* sem, const char* func) { if (sem_destroy((sem_t*) sem) == -1) { - ereport(ERROR, (errmsg("%s %s failed", func, __func__))); + ereport(ERROR, errmsg("%s %s failed", func, __func__)); } } void SemPost(volatile sem_t* sem, const char* func) { if (sem_post((sem_t*) sem) == -1) { - ereport(ERROR, (errmsg("%s %s failed", func, __func__))); + ereport(ERROR, errmsg("%s %s failed", func, __func__)); } } @@ -86,7 +86,7 @@ int SemWait(volatile sem_t* sem, const char* func) { if (errno == EINTR) { return -1; } - ereport(ERROR, (errmsg("%s %s failed", func, __func__))); + ereport(ERROR, errmsg("%s %s failed", func, __func__)); } return 0; } @@ -94,7 +94,7 @@ int SemWait(volatile sem_t* sem, const char* func) { int SemTryWait(volatile sem_t* sem, const char* func) { int ret = sem_trywait((sem_t*) sem); if (ret == -1 && errno != EAGAIN) { - ereport(ERROR, (errmsg("%s %s failed", func, __func__))); + ereport(ERROR, errmsg("%s %s failed", func, __func__)); } return ret; } diff --git a/src/kv_fdw.c b/src/kv_fdw.c index 5452bfd..1d84044 100755 --- a/src/kv_fdw.c +++ b/src/kv_fdw.c @@ -114,7 +114,7 @@ static void GetForeignRelSize(PlannerInfo* root, RelOptInfo* baserel, * can compute a better estimate of the average result row width. */ - ereport(DEBUG1, (errmsg("entering function %s", __func__))); + ereport(DEBUG1, errmsg("entering function %s", __func__)); /* * min & max will call GetForeignRelSize & GetForeignPaths multiple times, @@ -162,7 +162,7 @@ static void GetForeignRelSize(PlannerInfo* root, RelOptInfo* baserel, /* bit numbers are offset by FirstLowInvalidHeapAttributeNumber */ AttrNumber attr = col + FirstLowInvalidHeapAttributeNumber; if (attr <= InvalidAttrNumber) { /* shouldn't happen */ - ereport(ERROR, (errmsg("InvalidAttrNumber in %s", __func__))); + ereport(ERROR, errmsg("InvalidAttrNumber in %s", __func__)); } planState->targetAttrs = lappend_int(planState->targetAttrs, attr); printf(" %d ", attr); @@ -204,7 +204,7 @@ static void GetForeignPaths(PlannerInfo* root, RelOptInfo* baserel, * that is needed to identify the specific scan method intended. */ - ereport(DEBUG1, (errmsg("entering function %s", __func__))); + ereport(DEBUG1, errmsg("entering function %s", __func__)); Cost startupCost = 0; Cost totalCost = startupCost + baserel->rows; @@ -238,7 +238,7 @@ static ForeignScan* GetForeignPlan(PlannerInfo* root, RelOptInfo* baserel, * */ - ereport(DEBUG1, (errmsg("entering function %s", __func__))); + ereport(DEBUG1, errmsg("entering function %s", __func__)); /* * We have no native ability to evaluate restriction clauses, so we just @@ -309,7 +309,7 @@ static void GetKeyBasedQual(Node* node, ForeignScanState* scanState, /* get the name of the operator according to PG_OPERATOR OID */ HeapTuple opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(op->opno)); if (!HeapTupleIsValid(opertup)) { - ereport(ERROR, (errmsg("cache lookup failed for operator %u", op->opno))); + ereport(ERROR, errmsg("cache lookup failed for operator %u", op->opno)); } Form_pg_operator operform = (Form_pg_operator) GETSTRUCT(opertup); char* oprname = NameStr(operform->oprname); @@ -367,7 +367,7 @@ static void BeginForeignScan(ForeignScanState* scanState, int executorFlags) { * */ - ereport(DEBUG1, (errmsg("entering function %s", __func__))); + ereport(DEBUG1, errmsg("entering function %s", __func__)); TableReadState* readState = palloc0(sizeof(TableReadState)); readState->execExplainOnly = false; @@ -611,7 +611,7 @@ static TupleTableSlot* IterateForeignScan(ForeignScanState* scanState) { * (just as you would need to do in the case of a data type mismatch). */ - ereport(DEBUG1, (errmsg("entering function %s", __func__))); + ereport(DEBUG1, errmsg("entering function %s", __func__)); TupleTableSlot* tupleSlot = scanState->ss.ss_ScanTupleSlot; ExecClearTuple(tupleSlot); @@ -666,7 +666,7 @@ static void ReScanForeignScan(ForeignScanState* scanState) { * return exactly the same rows. */ - ereport(DEBUG1, (errmsg("entering function %s", __func__))); + ereport(DEBUG1, errmsg("entering function %s", __func__)); } static void EndForeignScan(ForeignScanState* scanState) { @@ -677,7 +677,7 @@ static void EndForeignScan(ForeignScanState* scanState) { * remote servers should be cleaned up. */ - ereport(DEBUG1, (errmsg("entering function %s", __func__))); + ereport(DEBUG1, errmsg("entering function %s", __func__)); TableReadState* readState = (TableReadState*) scanState->fdw_state; Assert(readState); @@ -748,7 +748,7 @@ static void AddForeignUpdateTargets(Query* parsetree, RangeTblEntry* tableEntry, * relies on an unchanging primary key to identify rows.) */ - ereport(DEBUG1, (errmsg("entering function %s", __func__))); + ereport(DEBUG1, errmsg("entering function %s", __func__)); /* * We are using first column as row identification column, so we are adding @@ -792,7 +792,7 @@ static List* PlanForeignModify(PlannerInfo* root, ModifyTable* plan, * BeginForeignModify will be NIL. */ - ereport(DEBUG1, (errmsg("entering function %s", __func__))); + ereport(DEBUG1, errmsg("entering function %s", __func__)); #ifdef VIDARDB if (plan->operation == CMD_INSERT) { @@ -829,11 +829,11 @@ static List* PlanForeignModify(PlannerInfo* root, ModifyTable* plan, while ((col = bms_first_member(attrs)) >= 0) { col += FirstLowInvalidHeapAttributeNumber; if (col <= InvalidAttrNumber) { /* shouldn't happen */ - ereport(ERROR, (errmsg("InvalidAttrNumber in %s", __func__))); + ereport(ERROR, errmsg("InvalidAttrNumber in %s", __func__)); } if (col == 1) { - ereport(ERROR, (errmsg("row identifier column update is " - "not supported."))); + ereport(ERROR, errmsg("row identifier column update is " + "not supported.")); } if (col > 1) { break; @@ -878,7 +878,7 @@ static void BeginForeignModify(ModifyTableState* modifyTableState, * during executor startup. */ - ereport(DEBUG1, (errmsg("entering function %s", __func__))); + ereport(DEBUG1, errmsg("entering function %s", __func__)); if (executorFlags & EXEC_FLAG_EXPLAIN_ONLY) { return; @@ -929,7 +929,7 @@ static void SerializeTuple(StringInfo key, StringInfo val, Datum datum = tupleSlot->tts_values[index]; if (tupleSlot->tts_isnull[index]) { if (index == 0) { - ereport(ERROR, (errmsg("first column cannot be null!"))); + ereport(ERROR, errmsg("first column cannot be null!")); } SerializeNullAttribute(tupleDescriptor, index, val); @@ -971,7 +971,7 @@ static TupleTableSlot* ExecForeignInsert(EState* executorState, * the foreign table will fail with an error message. */ - ereport(DEBUG1, (errmsg("entering function %s", __func__))); + ereport(DEBUG1, errmsg("entering function %s", __func__)); TupleDesc tupleDescriptor = slot->tts_tupleDescriptor; @@ -1040,7 +1040,7 @@ static TupleTableSlot* ExecForeignUpdate(EState* executorState, * */ - ereport(DEBUG1, (errmsg("entering function %s", __func__))); + ereport(DEBUG1, errmsg("entering function %s", __func__)); TupleDesc tupleDescriptor = slot->tts_tupleDescriptor; bool shouldFree; @@ -1105,7 +1105,7 @@ static TupleTableSlot* ExecForeignDelete(EState* executorState, * from the foreign table will fail with an error message. */ - ereport(DEBUG1, (errmsg("entering function %s", __func__))); + ereport(DEBUG1, errmsg("entering function %s", __func__)); slot_getallattrs(planSlot); @@ -1167,7 +1167,7 @@ static void EndForeignModify(EState* executorState, ResultRelInfo* resultRelInfo * executor shutdown. */ - ereport(DEBUG1, (errmsg("entering function %s", __func__))); + ereport(DEBUG1, errmsg("entering function %s", __func__)); TableWriteState* writeState = (TableWriteState*) resultRelInfo->ri_FdwState; @@ -1201,7 +1201,7 @@ static void ExplainForeignScan(ForeignScanState* scanState, * information is printed during EXPLAIN. */ - ereport(DEBUG1, (errmsg("entering function %s", __func__))); + ereport(DEBUG1, errmsg("entering function %s", __func__)); } static void ExplainForeignModify(ModifyTableState* modifyTableState, @@ -1221,7 +1221,7 @@ static void ExplainForeignModify(ModifyTableState* modifyTableState, * information is printed during EXPLAIN. */ - ereport(DEBUG1, (errmsg("entering function %s", __func__))); + ereport(DEBUG1, errmsg("entering function %s", __func__)); } static bool AnalyzeForeignTable(Relation relation, @@ -1255,7 +1255,7 @@ static bool AnalyzeForeignTable(Relation relation, * ---- */ - ereport(DEBUG1, (errmsg("entering function %s", __func__))); + ereport(DEBUG1, errmsg("entering function %s", __func__)); return false; } @@ -1264,7 +1264,7 @@ Datum kv_fdw_handler(PG_FUNCTION_ARGS) { printf("\n-----------------%s----------------------\n", __func__); FdwRoutine* routine = makeNode(FdwRoutine); - ereport(DEBUG1, (errmsg("entering function %s", __func__))); + ereport(DEBUG1, errmsg("entering function %s", __func__)); /* * assign the handlers for the FDW @@ -1308,16 +1308,16 @@ Datum kv_fdw_validator(PG_FUNCTION_ARGS) { printf("\n-----------------%s----------------------\n", __func__); //List *options_list = untransformRelOptions(PG_GETARG_DATUM(0)); - ereport(DEBUG1, (errmsg("entering function %s", __func__))); + ereport(DEBUG1, errmsg("entering function %s", __func__)); /* make sure the options are valid */ /* no options are supported */ /*if (list_length(options_list) > 0) { - ereport(ERROR, (errcode(ERRCODE_FDW_INVALID_OPTION_NAME), - errmsg("invalid options"), - errhint("FDW does not support any options"))); + ereport(ERROR, errcode(ERRCODE_FDW_INVALID_OPTION_NAME), + errmsg("invalid options"), + errhint("FDW does not support any options")); }*/ PG_RETURN_VOID(); diff --git a/src/kv_utility.c b/src/kv_utility.c index 99defb8..b89e574 100644 --- a/src/kv_utility.c +++ b/src/kv_utility.c @@ -114,18 +114,18 @@ static bool KVDirectoryExists(StringInfo directoryName) { /* file already exists; check that it is a directory */ if (!S_ISDIR(directoryStat.st_mode)) { ereport(ERROR, - (errmsg("\"%s\" is not a directory", directoryName->data), - errhint("You need to remove or rename the file \"%s\".", - directoryName->data))); + errmsg("\"%s\" is not a directory", directoryName->data), + errhint("You need to remove or rename the file \"%s\".", + directoryName->data)); } } else { if (errno == ENOENT) { directoryExists = false; } else { ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not stat directory \"%s\": %m", - directoryName->data))); + errcode_for_file_access(), + errmsg("could not stat directory \"%s\": %m", + directoryName->data)); } } @@ -142,9 +142,9 @@ static void KVCreateDatabaseDirectory(Oid databaseOid) { appendStringInfo(directoryPath, "%s/%s", DataDir, KVFDWNAME); if (!KVDirectoryExists(directoryPath)) { if (mkdir(directoryPath->data, S_IRWXU) != 0) { - ereport(ERROR, (errcode_for_file_access(), - errmsg("could not create directory \"%s\": %m", - directoryPath->data))); + ereport(ERROR, errcode_for_file_access(), + errmsg("could not create directory \"%s\": %m", + directoryPath->data)); } } @@ -153,9 +153,9 @@ static void KVCreateDatabaseDirectory(Oid databaseOid) { databaseOid); if (!KVDirectoryExists(databaseDirectoryPath)) { if (mkdir(databaseDirectoryPath->data, S_IRWXU) != 0) { - ereport(ERROR, (errcode_for_file_access(), - errmsg("could not create directory \"%s\": %m", - databaseDirectoryPath->data))); + ereport(ERROR, errcode_for_file_access(), + errmsg("could not create directory \"%s\": %m", + databaseDirectoryPath->data)); } } } @@ -263,7 +263,7 @@ KVFdwOptions* KVGetOptions(Oid foreignTableId) { Datum kv_ddl_event_end_trigger(PG_FUNCTION_ARGS) { /* error if event trigger manager did not call this function */ if (!CALLED_AS_EVENT_TRIGGER(fcinfo)) { - ereport(ERROR, (errmsg("trigger not fired by event trigger manager"))); + ereport(ERROR, errmsg("trigger not fired by event trigger manager")); } EventTriggerData* triggerData = (EventTriggerData*) fcinfo->context; @@ -385,15 +385,15 @@ static void KVCheckSuperuserPrivilegesForCopy(const CopyStmt* copyStmt) { */ if (copyStmt->filename != NULL && !superuser()) { if (copyStmt->is_program) { - ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("must be superuser to COPY to or from a program"), - errhint("Anyone can COPY to stdout or from stdin. " - "psql's \\copy command also works for anyone."))); + ereport(ERROR, errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), + errmsg("must be superuser to COPY to or from a program"), + errhint("Anyone can COPY to stdout or from stdin. " + "psql's \\copy command also works for anyone.")); } else { - ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("must be superuser to COPY to or from a file"), - errhint("Anyone can COPY to stdout or from stdin. " - "psql's \\copy command also works for anyone."))); + ereport(ERROR, errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), + errmsg("must be superuser to COPY to or from a file"), + errhint("Anyone can COPY to stdout or from stdin. " + "psql's \\copy command also works for anyone.")); } } } @@ -631,7 +631,7 @@ static uint64 KVCopyIntoTable(const CopyStmt* copyStmt, const char* queryString) Datum datum = values[index]; if (nulls[index]) { if (index == 0) { - ereport(ERROR, (errmsg("first column cannot be null!"))); + ereport(ERROR, errmsg("first column cannot be null!")); } SerializeNullAttribute(tupleDescriptor, index, val); } else { @@ -674,10 +674,10 @@ static uint64 KVCopyIntoTable(const CopyStmt* copyStmt, const char* queryString) */ static uint64 KVCopyOutTable(CopyStmt* copyStmt, const char* queryString) { if (copyStmt->attlist != NIL) { - ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("copy column list is not supported"), - errhint("use 'copy (select from ) to " - "...' instead"))); + ereport(ERROR, errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("copy column list is not supported"), + errhint("use 'copy (select from
) to " + "...' instead")); } RangeVar* relation = copyStmt->relation; @@ -758,14 +758,14 @@ static void KVCheckAlterTable(AlterTableStmt* alterStmt) { if (!can_coerce_type(1, ¤tTypeId, &targetTypeId, COERCION_IMPLICIT)) { char* typeName = TypeNameToString(columnDef->typeName); - ereport(ERROR, (errmsg("Column %s cannot be cast automatically " - "to type %s", columnName, typeName))); + ereport(ERROR, errmsg("Column %s cannot be cast automatically " + "to type %s", columnName, typeName)); } } if (alterCmd->subtype == AT_AddColumn) { - ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("No support for adding column currently"))); + ereport(ERROR, errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("No support for adding column currently")); } } } diff --git a/src/server/kv_manager.cc b/src/server/kv_manager.cc index ae32404..994e67b 100644 --- a/src/server/kv_manager.cc +++ b/src/server/kv_manager.cc @@ -149,7 +149,7 @@ void KVManager::Run() { Terminate(msg.hdr.relId, msg); break; default: - ereport(WARNING, (errmsg("invalid operation: %d", msg.hdr.op))); + ereport(WARNING, errmsg("invalid operation: %d", msg.hdr.op)); } } } diff --git a/src/server/kv_storage.cc b/src/server/kv_storage.cc index 0d90c24..597b03c 100644 --- a/src/server/kv_storage.cc +++ b/src/server/kv_storage.cc @@ -70,7 +70,7 @@ void* OpenConn(char* path, bool useColumn, int attrCount, ComparatorOpts* opts) Status s = DB::Open(options, string(path), &conn); if (!s.ok()) { - ereport(ERROR, (errmsg("DB open status: %s", s.ToString().c_str()))); + ereport(ERROR, errmsg("DB open status: %s", s.ToString().c_str())); } return conn; } @@ -83,7 +83,7 @@ void* OpenConn(char* path, ComparatorOpts* opts) { Status s = DB::Open(options, string(path), &conn); if (!s.ok()) { - ereport(ERROR, (errmsg("DB open status: %s", s.ToString().c_str()))); + ereport(ERROR, errmsg("DB open status: %s", s.ToString().c_str())); } return conn; } diff --git a/src/server/kv_worker.cc b/src/server/kv_worker.cc index 6806d60..87cb826 100644 --- a/src/server/kv_worker.cc +++ b/src/server/kv_worker.cc @@ -103,7 +103,7 @@ void KVWorker::Run() { Terminate(msg); break; default: - ereport(WARNING, (errmsg("invalid operation: %d", msg.hdr.op))); + ereport(WARNING, errmsg("invalid operation: %d", msg.hdr.op)); } } } @@ -810,14 +810,14 @@ void* LaunchKVWorker(KVWorkerId workerId, KVDatabaseId dbId) { pid_t pid; BgwHandleStatus status = WaitForBackgroundWorkerStartup(handle, &pid); if (status == BGWH_POSTMASTER_DIED) { - ereport(WARNING, (errcode(ERRCODE_INSUFFICIENT_RESOURCES), + ereport(WARNING, errcode(ERRCODE_INSUFFICIENT_RESOURCES), errmsg("cannot start background processes without postmaster"), errhint("Kill all remaining database processes and restart " - "the database."))); + "the database.")); } else if (status != BGWH_STARTED) { - ereport(WARNING, (errcode(ERRCODE_INSUFFICIENT_RESOURCES), + ereport(WARNING, errcode(ERRCODE_INSUFFICIENT_RESOURCES), errmsg("could not start background process"), - errhint("More details may be available in the server log."))); + errhint("More details may be available in the server log.")); } return handle;