From 3d13bc29a263faf10fa56ec9761c912f008439a8 Mon Sep 17 00:00:00 2001 From: jian he Date: Thu, 9 Jan 2025 20:31:05 +0800 Subject: [PATCH v11 1/1] remove ereport(ERROR, (errcode(...))) unnecessary parentheses. --- src/backend/catalog/heap.c | 12 ++--- src/backend/commands/indexcmds.c | 16 +++--- src/backend/commands/statscmds.c | 12 ++--- src/backend/commands/tablecmds.c | 81 +++++++++++++++--------------- src/backend/parser/parse_utilcmd.c | 7 ++- 5 files changed, 64 insertions(+), 64 deletions(-) diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index 2e0fd67e92..8e77570e6e 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -589,8 +589,8 @@ CheckAttributeType(const char *attname, */ if (flags & CHKATYPE_IS_VIRTUAL) ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("virtual generated column \"%s\" cannot have a domain type", attname))); + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("virtual generated column \"%s\" cannot have a domain type", attname)); /* * If it's a domain, recurse to check its base type. @@ -2559,8 +2559,8 @@ AddRelationNewConstraints(Relation rel, /* TODO: see transformColumnDefinition() */ if (get_attgenerated(RelationGetRelid(rel), colnum) == ATTRIBUTE_GENERATED_VIRTUAL) ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("not-null constraints are not supported on virtual generated columns"))); + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("not-null constraints are not supported on virtual generated columns")); /* * If the column already has a not-null constraint, we don't want @@ -2852,8 +2852,8 @@ AddRelationNotNullConstraints(Relation rel, List *constraints, /* TODO: see transformColumnDefinition() */ if (get_attgenerated(RelationGetRelid(rel), attnum) == ATTRIBUTE_GENERATED_VIRTUAL) ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("not-null constraints are not supported on virtual generated columns"))); + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("not-null constraints are not supported on virtual generated columns")); /* * A column can only have one not-null constraint, so discard any diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 174541f6af..fe7952a32f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1127,10 +1127,10 @@ DefineIndex(Oid tableId, if (TupleDescAttr(RelationGetDescr(rel), attno - 1)->attgenerated == ATTRIBUTE_GENERATED_VIRTUAL) ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - stmt->isconstraint ? - errmsg("unique constraints on virtual generated columns are not supported") : - errmsg("indexes on virtual generated columns are not supported"))); + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + stmt->isconstraint ? + errmsg("unique constraints on virtual generated columns are not supported") : + errmsg("indexes on virtual generated columns are not supported")); } /* @@ -1166,10 +1166,10 @@ DefineIndex(Oid tableId, if (TupleDescAttr(RelationGetDescr(rel), attno - 1)->attgenerated == ATTRIBUTE_GENERATED_VIRTUAL) ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - stmt->isconstraint ? - errmsg("unique constraints on virtual generated columns are not supported") : - errmsg("indexes on virtual generated columns are not supported"))); + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + stmt->isconstraint ? + errmsg("unique constraints on virtual generated columns are not supported") : + errmsg("indexes on virtual generated columns are not supported")); } } diff --git a/src/backend/commands/statscmds.c b/src/backend/commands/statscmds.c index e24d540cd4..a223e0c008 100644 --- a/src/backend/commands/statscmds.c +++ b/src/backend/commands/statscmds.c @@ -249,8 +249,8 @@ CreateStatistics(CreateStatsStmt *stmt) /* Disallow use of virtual generated columns in extended stats */ if (attForm->attgenerated == ATTRIBUTE_GENERATED_VIRTUAL) ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("statistics creation on virtual generated columns is not supported"))); + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("statistics creation on virtual generated columns is not supported")); /* Disallow data types without a less-than operator */ type = lookup_type_cache(attForm->atttypid, TYPECACHE_LT_OPR); @@ -278,8 +278,8 @@ CreateStatistics(CreateStatsStmt *stmt) /* Disallow use of virtual generated columns in extended stats */ if (get_attgenerated(relid, var->varattno) == ATTRIBUTE_GENERATED_VIRTUAL) ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("statistics creation on virtual generated columns is not supported"))); + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("statistics creation on virtual generated columns is not supported")); /* Disallow data types without a less-than operator */ type = lookup_type_cache(var->vartype, TYPECACHE_LT_OPR); @@ -318,8 +318,8 @@ CreateStatistics(CreateStatsStmt *stmt) /* Disallow use of virtual generated columns in extended stats */ if (get_attgenerated(relid, attnum) == ATTRIBUTE_GENERATED_VIRTUAL) ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("statistics creation on virtual generated columns is not supported"))); + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("statistics creation on virtual generated columns is not supported")); } /* diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index e65cde9c9a..58388ac512 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -3027,12 +3027,12 @@ MergeAttributes(List *columns, const List *supers, char relpersistence, if (coldef->generated && restdef->generated && coldef->generated != restdef->generated) ereport(ERROR, - (errcode(ERRCODE_INVALID_COLUMN_DEFINITION), - errmsg("column \"%s\" inherits from generated column of different kind", + errcode(ERRCODE_INVALID_COLUMN_DEFINITION), + errmsg("column \"%s\" inherits from generated column of different kind", restdef->colname), - errdetail("Parent column is %s, child column is %s.", + errdetail("Parent column is %s, child column is %s.", coldef->generated == ATTRIBUTE_GENERATED_STORED ? "STORED" : "VIRTUAL", - restdef->generated == ATTRIBUTE_GENERATED_STORED ? "STORED" : "VIRTUAL"))); + restdef->generated == ATTRIBUTE_GENERATED_STORED ? "STORED" : "VIRTUAL")); /* * Override the parent's default value for this column @@ -3308,12 +3308,12 @@ MergeChildAttribute(List *inh_columns, int exist_attno, int newcol_attno, const if (inhdef->generated && newdef->generated && newdef->generated != inhdef->generated) ereport(ERROR, - (errcode(ERRCODE_INVALID_COLUMN_DEFINITION), - errmsg("column \"%s\" inherits from generated column of different kind", + errcode(ERRCODE_INVALID_COLUMN_DEFINITION), + errmsg("column \"%s\" inherits from generated column of different kind", inhdef->colname), - errdetail("Parent column is %s, child column is %s.", + errdetail("Parent column is %s, child column is %s.", inhdef->generated == ATTRIBUTE_GENERATED_STORED ? "STORED" : "VIRTUAL", - newdef->generated == ATTRIBUTE_GENERATED_STORED ? "STORED" : "VIRTUAL"))); + newdef->generated == ATTRIBUTE_GENERATED_STORED ? "STORED" : "VIRTUAL")); /* * If new def has a default, override previous default @@ -7774,10 +7774,10 @@ ATExecSetNotNull(List **wqueue, Relation rel, char *conName, char *colName, /* TODO: see transformColumnDefinition() */ if (TupleDescAttr(RelationGetDescr(rel), attnum - 1)->attgenerated == ATTRIBUTE_GENERATED_VIRTUAL) ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("not-null constraints are not supported on virtual generated columns"), - errdetail("Column \"%s\" of relation \"%s\" is a virtual generated column.", - colName, RelationGetRelationName(rel)))); + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("not-null constraints are not supported on virtual generated columns"), + errdetail("Column \"%s\" of relation \"%s\" is a virtual generated column.", + colName, RelationGetRelationName(rel))); /* See if there's already a constraint */ tuple = findNotNullConstraintAttnum(RelationGetRelid(rel), attnum); @@ -8432,9 +8432,9 @@ ATExecSetExpression(AlteredTableInfo *tab, Relation rel, const char *colName, attgenerated = attTup->attgenerated; if (!attgenerated) ereport(ERROR, - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("column \"%s\" of relation \"%s\" is not a generated column", - colName, RelationGetRelationName(rel)))); + errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("column \"%s\" of relation \"%s\" is not a generated column", + colName, RelationGetRelationName(rel))); /* * TODO: This could be done, just need to recheck any constraints @@ -8443,10 +8443,10 @@ ATExecSetExpression(AlteredTableInfo *tab, Relation rel, const char *colName, if (attgenerated == ATTRIBUTE_GENERATED_VIRTUAL && rel->rd_att->constr && rel->rd_att->constr->num_check > 0) ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("ALTER TABLE / SET EXPRESSION is not supported for virtual generated columns on tables with check constraints"), - errdetail("Column \"%s\" of relation \"%s\" is a virtual generated column.", - colName, RelationGetRelationName(rel)))); + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("ALTER TABLE / SET EXPRESSION is not supported for virtual generated columns on tables with check constraints"), + errdetail("Column \"%s\" of relation \"%s\" is a virtual generated column.", + colName, RelationGetRelationName(rel))); /* * We need to prevent this because a change of expression could affect a @@ -8458,10 +8458,10 @@ ATExecSetExpression(AlteredTableInfo *tab, Relation rel, const char *colName, if (attgenerated == ATTRIBUTE_GENERATED_VIRTUAL && GetRelationPublications(RelationGetRelid(rel)) != NIL) ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("ALTER TABLE / SET EXPRESSION is not supported for virtual generated columns on tables that are part of a publication"), - errdetail("Column \"%s\" of relation \"%s\" is a virtual generated column.", - colName, RelationGetRelationName(rel)))); + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("ALTER TABLE / SET EXPRESSION is not supported for virtual generated columns on tables that are part of a publication"), + errdetail("Column \"%s\" of relation \"%s\" is a virtual generated column.", + colName, RelationGetRelationName(rel))); rewrite = (attgenerated == ATTRIBUTE_GENERATED_STORED); @@ -8631,18 +8631,18 @@ ATExecDropExpression(Relation rel, const char *colName, bool missing_ok, LOCKMOD */ if (attTup->attgenerated == ATTRIBUTE_GENERATED_VIRTUAL) ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("ALTER TABLE / DROP EXPRESSION is not supported for virtual generated columns"), - errdetail("Column \"%s\" of relation \"%s\" is a virtual generated column.", - colName, RelationGetRelationName(rel)))); + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("ALTER TABLE / DROP EXPRESSION is not supported for virtual generated columns"), + errdetail("Column \"%s\" of relation \"%s\" is a virtual generated column.", + colName, RelationGetRelationName(rel))); if (!attTup->attgenerated) { if (!missing_ok) ereport(ERROR, - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("column \"%s\" of relation \"%s\" is not a generated column", - colName, RelationGetRelationName(rel)))); + errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("column \"%s\" of relation \"%s\" is not a generated column", + colName, RelationGetRelationName(rel))); else { ereport(NOTICE, @@ -8795,9 +8795,9 @@ ATExecSetStatistics(Relation rel, const char *colName, int16 colNum, Node *newVa */ if (attrtuple->attgenerated == ATTRIBUTE_GENERATED_VIRTUAL) ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot alter statistics on virtual generated column \"%s\"", - colName))); + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("cannot alter statistics on virtual generated column \"%s\"", + colName)); if (rel->rd_rel->relkind == RELKIND_INDEX || rel->rd_rel->relkind == RELKIND_PARTITIONED_INDEX) @@ -10002,8 +10002,8 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel, */ if (attgenerated == ATTRIBUTE_GENERATED_VIRTUAL) ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("foreign key constraints on virtual generated columns are not supported"))); + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("foreign key constraints on virtual generated columns are not supported")); } /* @@ -16456,17 +16456,18 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel, bool ispart (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("column \"%s\" in child table must be a generated column", parent_attname))); if (child_att->attgenerated && !parent_att->attgenerated) - ereport(ERROR, + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("column \"%s\" in child table must not be a generated column", parent_attname))); if (parent_att->attgenerated && child_att->attgenerated && child_att->attgenerated != parent_att->attgenerated) ereport(ERROR, - (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("column \"%s\" inherits from generated column of different kind", parent_attname), - errdetail("Parent column is %s, child column is %s.", + errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("column \"%s\" inherits from generated column of different kind", parent_attname), + errdetail("Parent column is %s, child column is %s.", parent_att->attgenerated == ATTRIBUTE_GENERATED_STORED ? "STORED" : "VIRTUAL", - child_att->attgenerated == ATTRIBUTE_GENERATED_STORED ? "STORED" : "VIRTUAL"))); + child_att->attgenerated == ATTRIBUTE_GENERATED_STORED ? "STORED" : "VIRTUAL")); /* * Regular inheritance children are independent enough not to diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 609cd6d716..0328c8784e 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -996,10 +996,9 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column) */ if (column->is_not_null && column->generated == ATTRIBUTE_GENERATED_VIRTUAL) ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("not-null constraints are not supported on virtual generated columns"), - parser_errposition(cxt->pstate, - constraint->location))); + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("not-null constraints are not supported on virtual generated columns"), + parser_errposition(cxt->pstate, constraint->location)); } /* -- 2.34.1