mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Phase 3 of pgindent updates.
Don't move parenthesized lines to the left, even if that means they flow past the right margin. By default, BSD indent lines up statement continuation lines that are within parentheses so that they start just to the right of the preceding left parenthesis. However, traditionally, if that resulted in the continuation line extending to the right of the desired right margin, then indent would push it left just far enough to not overrun the margin, if it could do so without making the continuation line start to the left of the current statement indent. That makes for a weird mix of indentations unless one has been completely rigid about never violating the 80-column limit. This behavior has been pretty universally panned by Postgres developers. Hence, disable it with indent's new -lpl switch, so that parenthesized lines are always lined up with the preceding left paren. This patch is much less interesting than the first round of indent changes, but also bulkier, so I thought it best to separate the effects. Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
This commit is contained in:
@ -305,7 +305,7 @@ static void StoreCatalogInheritance1(Oid relationId, Oid parentOid,
|
||||
bool child_is_partition);
|
||||
static int findAttrByName(const char *attributeName, List *schema);
|
||||
static void AlterIndexNamespaces(Relation classRel, Relation rel,
|
||||
Oid oldNspOid, Oid newNspOid, ObjectAddresses *objsMoved);
|
||||
Oid oldNspOid, Oid newNspOid, ObjectAddresses *objsMoved);
|
||||
static void AlterSeqNamespaces(Relation classRel, Relation rel,
|
||||
Oid oldNspOid, Oid newNspOid, ObjectAddresses *objsMoved,
|
||||
LOCKMODE lockmode);
|
||||
@ -441,7 +441,7 @@ static void ATExecSetRelOptions(Relation rel, List *defList,
|
||||
AlterTableType operation,
|
||||
LOCKMODE lockmode);
|
||||
static void ATExecEnableDisableTrigger(Relation rel, char *trigname,
|
||||
char fires_when, bool skip_system, LOCKMODE lockmode);
|
||||
char fires_when, bool skip_system, LOCKMODE lockmode);
|
||||
static void ATExecEnableDisableRule(Relation rel, char *rulename,
|
||||
char fires_when, LOCKMODE lockmode);
|
||||
static void ATPrepAddInherit(Relation child_rel);
|
||||
@ -649,7 +649,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
|
||||
*/
|
||||
localHasOids = interpretOidsOption(stmt->options,
|
||||
(relkind == RELKIND_RELATION ||
|
||||
relkind == RELKIND_PARTITIONED_TABLE));
|
||||
relkind == RELKIND_PARTITIONED_TABLE));
|
||||
descriptor->tdhasoid = (localHasOids || parentOidCount > 0);
|
||||
|
||||
/*
|
||||
@ -888,7 +888,7 @@ DropErrorMsgNonExistent(RangeVar *rel, char rightkind, bool missing_ok)
|
||||
{
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_SCHEMA),
|
||||
errmsg("schema \"%s\" does not exist", rel->schemaname)));
|
||||
errmsg("schema \"%s\" does not exist", rel->schemaname)));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -943,7 +943,7 @@ DropErrorMsgWrongType(const char *relname, char wrongkind, char rightkind)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg(rentry->nota_msg, relname),
|
||||
(wentry->kind != '\0') ? errhint("%s", _(wentry->drophint_msg)) : 0));
|
||||
(wentry->kind != '\0') ? errhint("%s", _(wentry->drophint_msg)) : 0));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -973,7 +973,7 @@ RemoveRelations(DropStmt *drop)
|
||||
if (drop->behavior == DROP_CASCADE)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("DROP INDEX CONCURRENTLY does not support CASCADE")));
|
||||
errmsg("DROP INDEX CONCURRENTLY does not support CASCADE")));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1527,7 +1527,7 @@ truncate_check_rel(Relation rel)
|
||||
if (RELATION_IS_OTHER_TEMP(rel))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot truncate temporary tables of other sessions")));
|
||||
errmsg("cannot truncate temporary tables of other sessions")));
|
||||
|
||||
/*
|
||||
* Also check for active uses of the relation in the current transaction,
|
||||
@ -1789,7 +1789,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg(!is_partition
|
||||
? "cannot inherit from temporary relation of another session"
|
||||
? "cannot inherit from temporary relation of another session"
|
||||
: "cannot create as partition of temporary relation of another session")));
|
||||
|
||||
/*
|
||||
@ -1806,8 +1806,8 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
||||
if (list_member_oid(parentOids, RelationGetRelid(relation)))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DUPLICATE_TABLE),
|
||||
errmsg("relation \"%s\" would be inherited from more than once",
|
||||
parent->relname)));
|
||||
errmsg("relation \"%s\" would be inherited from more than once",
|
||||
parent->relname)));
|
||||
|
||||
parentOids = lappend_oid(parentOids, RelationGetRelid(relation));
|
||||
|
||||
@ -1862,22 +1862,22 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
||||
deftypmod != attribute->atttypmod)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("inherited column \"%s\" has a type conflict",
|
||||
attributeName),
|
||||
errmsg("inherited column \"%s\" has a type conflict",
|
||||
attributeName),
|
||||
errdetail("%s versus %s",
|
||||
format_type_with_typemod(defTypeId,
|
||||
deftypmod),
|
||||
format_type_with_typemod(attribute->atttypid,
|
||||
attribute->atttypmod))));
|
||||
format_type_with_typemod(attribute->atttypid,
|
||||
attribute->atttypmod))));
|
||||
defCollId = GetColumnDefCollation(NULL, def, defTypeId);
|
||||
if (defCollId != attribute->attcollation)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_COLLATION_MISMATCH),
|
||||
errmsg("inherited column \"%s\" has a collation conflict",
|
||||
attributeName),
|
||||
errmsg("inherited column \"%s\" has a collation conflict",
|
||||
attributeName),
|
||||
errdetail("\"%s\" versus \"%s\"",
|
||||
get_collation_name(defCollId),
|
||||
get_collation_name(attribute->attcollation))));
|
||||
get_collation_name(attribute->attcollation))));
|
||||
|
||||
/* Copy storage parameter */
|
||||
if (def->storage == 0)
|
||||
@ -1999,7 +1999,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
||||
if (found_whole_row)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot convert whole-row table reference"),
|
||||
errmsg("cannot convert whole-row table reference"),
|
||||
errdetail("Constraint \"%s\" contains a whole-row reference to table \"%s\".",
|
||||
name,
|
||||
RelationGetRelationName(relation))));
|
||||
@ -2079,8 +2079,8 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
||||
*/
|
||||
if (exist_attno == schema_attno)
|
||||
ereport(NOTICE,
|
||||
(errmsg("merging column \"%s\" with inherited definition",
|
||||
attributeName)));
|
||||
(errmsg("merging column \"%s\" with inherited definition",
|
||||
attributeName)));
|
||||
else
|
||||
ereport(NOTICE,
|
||||
(errmsg("moving and merging column \"%s\" with inherited definition", attributeName),
|
||||
@ -2121,8 +2121,8 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
||||
else if (newdef->storage != 0 && def->storage != newdef->storage)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("column \"%s\" has a storage parameter conflict",
|
||||
attributeName),
|
||||
errmsg("column \"%s\" has a storage parameter conflict",
|
||||
attributeName),
|
||||
errdetail("%s versus %s",
|
||||
storage_name(def->storage),
|
||||
storage_name(newdef->storage))));
|
||||
@ -2210,8 +2210,8 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
||||
else
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DUPLICATE_COLUMN),
|
||||
errmsg("column \"%s\" specified more than once",
|
||||
coldef->colname)));
|
||||
errmsg("column \"%s\" specified more than once",
|
||||
coldef->colname)));
|
||||
}
|
||||
prev = rest;
|
||||
rest = next;
|
||||
@ -2232,8 +2232,8 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
||||
if (def->cooked_default == &bogus_marker)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_COLUMN_DEFINITION),
|
||||
errmsg("column \"%s\" inherits conflicting default values",
|
||||
def->colname),
|
||||
errmsg("column \"%s\" inherits conflicting default values",
|
||||
def->colname),
|
||||
errhint("To resolve the conflict, specify a default explicitly.")));
|
||||
}
|
||||
}
|
||||
@ -2597,7 +2597,7 @@ renameatt_internal(Oid myrelid,
|
||||
ListCell *lo;
|
||||
|
||||
child_oids = find_typed_table_dependencies(targetrelation->rd_rel->reltype,
|
||||
RelationGetRelationName(targetrelation),
|
||||
RelationGetRelationName(targetrelation),
|
||||
behavior);
|
||||
|
||||
foreach(lo, child_oids)
|
||||
@ -3462,7 +3462,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
|
||||
{
|
||||
case AT_AddColumn: /* ADD COLUMN */
|
||||
ATSimplePermissions(rel,
|
||||
ATT_TABLE | ATT_COMPOSITE_TYPE | ATT_FOREIGN_TABLE);
|
||||
ATT_TABLE | ATT_COMPOSITE_TYPE | ATT_FOREIGN_TABLE);
|
||||
ATPrepAddColumn(wqueue, rel, recurse, recursing, false, cmd,
|
||||
lockmode);
|
||||
/* Recursion occurs during execution phase */
|
||||
@ -3534,7 +3534,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
|
||||
break;
|
||||
case AT_DropColumn: /* DROP COLUMN */
|
||||
ATSimplePermissions(rel,
|
||||
ATT_TABLE | ATT_COMPOSITE_TYPE | ATT_FOREIGN_TABLE);
|
||||
ATT_TABLE | ATT_COMPOSITE_TYPE | ATT_FOREIGN_TABLE);
|
||||
ATPrepDropColumn(wqueue, rel, recurse, recursing, cmd, lockmode);
|
||||
/* Recursion occurs during execution phase */
|
||||
pass = AT_PASS_DROP;
|
||||
@ -3569,7 +3569,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
|
||||
break;
|
||||
case AT_AlterColumnType: /* ALTER COLUMN TYPE */
|
||||
ATSimplePermissions(rel,
|
||||
ATT_TABLE | ATT_COMPOSITE_TYPE | ATT_FOREIGN_TABLE);
|
||||
ATT_TABLE | ATT_COMPOSITE_TYPE | ATT_FOREIGN_TABLE);
|
||||
/* Performs own recursion */
|
||||
ATPrepAlterColumnType(wqueue, tab, rel, recurse, recursing, cmd, lockmode);
|
||||
pass = AT_PASS_ALTER_TYPE;
|
||||
@ -3971,7 +3971,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
|
||||
break;
|
||||
case AT_EnableTrig: /* ENABLE TRIGGER name */
|
||||
ATExecEnableDisableTrigger(rel, cmd->name,
|
||||
TRIGGER_FIRES_ON_ORIGIN, false, lockmode);
|
||||
TRIGGER_FIRES_ON_ORIGIN, false, lockmode);
|
||||
break;
|
||||
case AT_EnableAlwaysTrig: /* ENABLE ALWAYS TRIGGER name */
|
||||
ATExecEnableDisableTrigger(rel, cmd->name,
|
||||
@ -3979,7 +3979,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
|
||||
break;
|
||||
case AT_EnableReplicaTrig: /* ENABLE REPLICA TRIGGER name */
|
||||
ATExecEnableDisableTrigger(rel, cmd->name,
|
||||
TRIGGER_FIRES_ON_REPLICA, false, lockmode);
|
||||
TRIGGER_FIRES_ON_REPLICA, false, lockmode);
|
||||
break;
|
||||
case AT_DisableTrig: /* DISABLE TRIGGER name */
|
||||
ATExecEnableDisableTrigger(rel, cmd->name,
|
||||
@ -3987,7 +3987,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
|
||||
break;
|
||||
case AT_EnableTrigAll: /* ENABLE TRIGGER ALL */
|
||||
ATExecEnableDisableTrigger(rel, NULL,
|
||||
TRIGGER_FIRES_ON_ORIGIN, false, lockmode);
|
||||
TRIGGER_FIRES_ON_ORIGIN, false, lockmode);
|
||||
break;
|
||||
case AT_DisableTrigAll: /* DISABLE TRIGGER ALL */
|
||||
ATExecEnableDisableTrigger(rel, NULL,
|
||||
@ -3995,7 +3995,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
|
||||
break;
|
||||
case AT_EnableTrigUser: /* ENABLE TRIGGER USER */
|
||||
ATExecEnableDisableTrigger(rel, NULL,
|
||||
TRIGGER_FIRES_ON_ORIGIN, true, lockmode);
|
||||
TRIGGER_FIRES_ON_ORIGIN, true, lockmode);
|
||||
break;
|
||||
case AT_DisableTrigUser: /* DISABLE TRIGGER USER */
|
||||
ATExecEnableDisableTrigger(rel, NULL,
|
||||
@ -4150,8 +4150,8 @@ ATRewriteTables(AlterTableStmt *parsetree, List **wqueue, LOCKMODE lockmode)
|
||||
if (RelationIsUsedAsCatalogTable(OldHeap))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot rewrite table \"%s\" used as a catalog table",
|
||||
RelationGetRelationName(OldHeap))));
|
||||
errmsg("cannot rewrite table \"%s\" used as a catalog table",
|
||||
RelationGetRelationName(OldHeap))));
|
||||
|
||||
/*
|
||||
* Don't allow rewrite on temp tables of other backends ... their
|
||||
@ -4160,7 +4160,7 @@ ATRewriteTables(AlterTableStmt *parsetree, List **wqueue, LOCKMODE lockmode)
|
||||
if (RELATION_IS_OTHER_TEMP(OldHeap))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot rewrite temporary tables of other sessions")));
|
||||
errmsg("cannot rewrite temporary tables of other sessions")));
|
||||
|
||||
/*
|
||||
* Select destination tablespace (same as original unless user
|
||||
@ -4522,7 +4522,7 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
|
||||
|
||||
values[ex->attnum - 1] = ExecEvalExpr(ex->exprstate,
|
||||
econtext,
|
||||
&isnull[ex->attnum - 1]);
|
||||
&isnull[ex->attnum - 1]);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4554,7 +4554,7 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NOT_NULL_VIOLATION),
|
||||
errmsg("column \"%s\" contains null values",
|
||||
NameStr(newTupDesc->attrs[attn]->attname)),
|
||||
NameStr(newTupDesc->attrs[attn]->attname)),
|
||||
errtablecol(oldrel, attn + 1)));
|
||||
}
|
||||
|
||||
@ -4584,7 +4584,7 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
|
||||
if (partqualstate && !ExecCheck(partqualstate, econtext))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_CHECK_VIOLATION),
|
||||
errmsg("partition constraint is violated by some row")));
|
||||
errmsg("partition constraint is violated by some row")));
|
||||
|
||||
/* Write the tuple out to the new relation */
|
||||
if (newrel)
|
||||
@ -4995,7 +4995,7 @@ find_typed_table_dependencies(Oid typeOid, const char *typeName, DropBehavior be
|
||||
(errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),
|
||||
errmsg("cannot alter type \"%s\" because it is the type of a typed table",
|
||||
typeName),
|
||||
errhint("Use ALTER ... CASCADE to alter the typed tables too.")));
|
||||
errhint("Use ALTER ... CASCADE to alter the typed tables too.")));
|
||||
else
|
||||
result = lappend_oid(result, HeapTupleGetOid(tuple));
|
||||
}
|
||||
@ -5139,23 +5139,23 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("child table \"%s\" has different type for column \"%s\"",
|
||||
RelationGetRelationName(rel), colDef->colname)));
|
||||
RelationGetRelationName(rel), colDef->colname)));
|
||||
ccollid = GetColumnDefCollation(NULL, colDef, ctypeId);
|
||||
if (ccollid != childatt->attcollation)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_COLLATION_MISMATCH),
|
||||
errmsg("child table \"%s\" has different collation for column \"%s\"",
|
||||
RelationGetRelationName(rel), colDef->colname),
|
||||
RelationGetRelationName(rel), colDef->colname),
|
||||
errdetail("\"%s\" versus \"%s\"",
|
||||
get_collation_name(ccollid),
|
||||
get_collation_name(childatt->attcollation))));
|
||||
get_collation_name(childatt->attcollation))));
|
||||
|
||||
/* If it's OID, child column must actually be OID */
|
||||
if (isOid && childatt->attnum != ObjectIdAttributeNumber)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("child table \"%s\" has a conflicting \"%s\" column",
|
||||
RelationGetRelationName(rel), colDef->colname)));
|
||||
errmsg("child table \"%s\" has a conflicting \"%s\" column",
|
||||
RelationGetRelationName(rel), colDef->colname)));
|
||||
|
||||
/* Bump the existing child att's inhcount */
|
||||
childatt->attinhcount++;
|
||||
@ -5165,8 +5165,8 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
|
||||
|
||||
/* Inform the user about the merge */
|
||||
ereport(NOTICE,
|
||||
(errmsg("merging definition of column \"%s\" for child \"%s\"",
|
||||
colDef->colname, RelationGetRelationName(rel))));
|
||||
(errmsg("merging definition of column \"%s\" for child \"%s\"",
|
||||
colDef->colname, RelationGetRelationName(rel))));
|
||||
|
||||
heap_close(attrdesc, RowExclusiveLock);
|
||||
return InvalidObjectAddress;
|
||||
@ -5468,8 +5468,8 @@ check_for_column_name_collision(Relation rel, const char *colname,
|
||||
if (attnum <= 0)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DUPLICATE_COLUMN),
|
||||
errmsg("column name \"%s\" conflicts with a system column name",
|
||||
colname)));
|
||||
errmsg("column name \"%s\" conflicts with a system column name",
|
||||
colname)));
|
||||
else
|
||||
{
|
||||
if (if_not_exists)
|
||||
@ -5620,8 +5620,8 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
|
||||
if (get_attidentity(RelationGetRelid(rel), attnum))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("column \"%s\" of relation \"%s\" is an identity column",
|
||||
colName, RelationGetRelationName(rel))));
|
||||
errmsg("column \"%s\" of relation \"%s\" is an identity column",
|
||||
colName, RelationGetRelationName(rel))));
|
||||
|
||||
/*
|
||||
* Check that the attribute is not in a primary key
|
||||
@ -5678,8 +5678,8 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
|
||||
if (tupDesc->attrs[parent_attnum - 1]->attnotnull)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
|
||||
errmsg("column \"%s\" is marked NOT NULL in parent table",
|
||||
colName)));
|
||||
errmsg("column \"%s\" is marked NOT NULL in parent table",
|
||||
colName)));
|
||||
heap_close(parent, AccessShareLock);
|
||||
}
|
||||
|
||||
@ -5822,8 +5822,8 @@ ATExecColumnDefault(Relation rel, const char *colName,
|
||||
if (get_attidentity(RelationGetRelid(rel), attnum))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("column \"%s\" of relation \"%s\" is an identity column",
|
||||
colName, RelationGetRelationName(rel)),
|
||||
errmsg("column \"%s\" of relation \"%s\" is an identity column",
|
||||
colName, RelationGetRelationName(rel)),
|
||||
newDefault ? 0 : errhint("Use ALTER TABLE ... ALTER COLUMN ... DROP IDENTITY instead.")));
|
||||
|
||||
/*
|
||||
@ -5914,8 +5914,8 @@ ATExecAddIdentity(Relation rel, const char *colName,
|
||||
if (attTup->atthasdef)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
errmsg("column \"%s\" of relation \"%s\" already has a default value",
|
||||
colName, RelationGetRelationName(rel))));
|
||||
errmsg("column \"%s\" of relation \"%s\" already has a default value",
|
||||
colName, RelationGetRelationName(rel))));
|
||||
|
||||
attTup->attidentity = cdef->identity;
|
||||
CatalogTupleUpdate(attrelation, &tuple->t_self, tuple);
|
||||
@ -5991,8 +5991,8 @@ ATExecSetIdentity(Relation rel, const char *colName, Node *def, LOCKMODE lockmod
|
||||
if (!attTup->attidentity)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
errmsg("column \"%s\" of relation \"%s\" is not an identity column",
|
||||
colName, RelationGetRelationName(rel))));
|
||||
errmsg("column \"%s\" of relation \"%s\" is not an identity column",
|
||||
colName, RelationGetRelationName(rel))));
|
||||
|
||||
if (generatedEl)
|
||||
{
|
||||
@ -6829,7 +6829,7 @@ ATExecAddConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
|
||||
else
|
||||
newConstraint->conname =
|
||||
ChooseConstraintName(RelationGetRelationName(rel),
|
||||
strVal(linitial(newConstraint->fk_attrs)),
|
||||
strVal(linitial(newConstraint->fk_attrs)),
|
||||
"fkey",
|
||||
RelationGetNamespace(rel),
|
||||
NIL);
|
||||
@ -7867,7 +7867,7 @@ transformFkeyGetPrimaryKey(Relation pkrel, Oid *indexOid,
|
||||
atttypids[i] = attnumTypeId(pkrel, pkattno);
|
||||
opclasses[i] = indclass->values[i];
|
||||
*attnamelist = lappend(*attnamelist,
|
||||
makeString(pstrdup(NameStr(*attnumAttName(pkrel, pkattno)))));
|
||||
makeString(pstrdup(NameStr(*attnumAttName(pkrel, pkattno)))));
|
||||
}
|
||||
|
||||
ReleaseSysCache(indexTuple);
|
||||
@ -8528,8 +8528,8 @@ ATExecDropConstraint(Relation rel, const char *constrName,
|
||||
{
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("constraint \"%s\" of relation \"%s\" does not exist",
|
||||
constrName, RelationGetRelationName(rel))));
|
||||
errmsg("constraint \"%s\" of relation \"%s\" does not exist",
|
||||
constrName, RelationGetRelationName(rel))));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -8596,9 +8596,9 @@ ATExecDropConstraint(Relation rel, const char *constrName,
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("constraint \"%s\" of relation \"%s\" does not exist",
|
||||
constrName,
|
||||
RelationGetRelationName(childrel))));
|
||||
errmsg("constraint \"%s\" of relation \"%s\" does not exist",
|
||||
constrName,
|
||||
RelationGetRelationName(childrel))));
|
||||
|
||||
copy_tuple = heap_copytuple(tuple);
|
||||
|
||||
@ -8716,7 +8716,7 @@ ATPrepAlterColumnType(List **wqueue,
|
||||
if (!is_expr)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
|
||||
errmsg("cannot alter type of column named in partition key")));
|
||||
errmsg("cannot alter type of column named in partition key")));
|
||||
else
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
|
||||
@ -8780,10 +8780,10 @@ ATPrepAlterColumnType(List **wqueue,
|
||||
errmsg("column \"%s\" cannot be cast automatically to type %s",
|
||||
colName, format_type_be(targettype)),
|
||||
/* translator: USING is SQL, don't translate it */
|
||||
errhint("You might need to specify \"USING %s::%s\".",
|
||||
quote_identifier(colName),
|
||||
format_type_with_typemod(targettype,
|
||||
targettypmod))));
|
||||
errhint("You might need to specify \"USING %s::%s\".",
|
||||
quote_identifier(colName),
|
||||
format_type_with_typemod(targettype,
|
||||
targettypmod))));
|
||||
}
|
||||
|
||||
/* Fix collations after all else */
|
||||
@ -8869,7 +8869,7 @@ ATPrepAlterColumnType(List **wqueue,
|
||||
|
||||
attmap = convert_tuples_by_name_map(RelationGetDescr(childrel),
|
||||
RelationGetDescr(rel),
|
||||
gettext_noop("could not convert row type"));
|
||||
gettext_noop("could not convert row type"));
|
||||
((ColumnDef *) cmd->def)->cooked_default =
|
||||
map_variable_attnos(def->cooked_default,
|
||||
1, 0,
|
||||
@ -8878,7 +8878,7 @@ ATPrepAlterColumnType(List **wqueue,
|
||||
if (found_whole_row)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot convert whole-row table reference"),
|
||||
errmsg("cannot convert whole-row table reference"),
|
||||
errdetail("USING expression contains a whole-row table reference.")));
|
||||
pfree(attmap);
|
||||
}
|
||||
@ -9005,7 +9005,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
|
||||
Assert(defaultexpr);
|
||||
defaultexpr = strip_implicit_coercions(defaultexpr);
|
||||
defaultexpr = coerce_to_target_type(NULL, /* no UNKNOWN params */
|
||||
defaultexpr, exprType(defaultexpr),
|
||||
defaultexpr, exprType(defaultexpr),
|
||||
targettype, targettypmod,
|
||||
COERCION_ASSIGNMENT,
|
||||
COERCE_IMPLICIT_CAST,
|
||||
@ -9076,9 +9076,9 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
|
||||
if (!list_member_oid(tab->changedIndexOids, foundObject.objectId))
|
||||
{
|
||||
tab->changedIndexOids = lappend_oid(tab->changedIndexOids,
|
||||
foundObject.objectId);
|
||||
foundObject.objectId);
|
||||
tab->changedIndexDefs = lappend(tab->changedIndexDefs,
|
||||
pg_get_indexdef_string(foundObject.objectId));
|
||||
pg_get_indexdef_string(foundObject.objectId));
|
||||
}
|
||||
}
|
||||
else if (relKind == RELKIND_SEQUENCE)
|
||||
@ -9592,7 +9592,7 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid refRelId, char *cmd,
|
||||
else if (IsA(stmt, AlterTableStmt))
|
||||
querytree_list = list_concat(querytree_list,
|
||||
transformAlterTableStmt(oldRelId,
|
||||
(AlterTableStmt *) stmt,
|
||||
(AlterTableStmt *) stmt,
|
||||
cmd));
|
||||
else
|
||||
querytree_list = lappend(querytree_list, stmt);
|
||||
@ -9719,7 +9719,7 @@ RebuildConstraintComment(AlteredTableInfo *tab, int pass, Oid objid,
|
||||
cmd = makeNode(CommentStmt);
|
||||
cmd->objtype = OBJECT_TABCONSTRAINT;
|
||||
cmd->object = (Node *) list_make3(makeString(get_namespace_name(RelationGetNamespace(rel))),
|
||||
makeString(pstrdup(RelationGetRelationName(rel))),
|
||||
makeString(pstrdup(RelationGetRelationName(rel))),
|
||||
makeString(pstrdup(conname)));
|
||||
cmd->comment = comment_str;
|
||||
|
||||
@ -9872,9 +9872,9 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing, LOCKMODE lock
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot change owner of sequence \"%s\"",
|
||||
NameStr(tuple_class->relname)),
|
||||
errdetail("Sequence \"%s\" is linked to table \"%s\".",
|
||||
NameStr(tuple_class->relname),
|
||||
get_rel_name(tableId))));
|
||||
errdetail("Sequence \"%s\" is linked to table \"%s\".",
|
||||
NameStr(tuple_class->relname),
|
||||
get_rel_name(tableId))));
|
||||
}
|
||||
break;
|
||||
case RELKIND_COMPOSITE_TYPE:
|
||||
@ -9893,8 +9893,8 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing, LOCKMODE lock
|
||||
default:
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("\"%s\" is not a table, view, sequence, or foreign table",
|
||||
NameStr(tuple_class->relname))));
|
||||
errmsg("\"%s\" is not a table, view, sequence, or foreign table",
|
||||
NameStr(tuple_class->relname))));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -10756,7 +10756,7 @@ AlterTableMoveAll(AlterTableMoveAllStmt *stmt)
|
||||
ereport(NOTICE,
|
||||
(errcode(ERRCODE_NO_DATA_FOUND),
|
||||
errmsg("no matching relations in tablespace \"%s\" found",
|
||||
orig_tablespaceoid == InvalidOid ? "(database default)" :
|
||||
orig_tablespaceoid == InvalidOid ? "(database default)" :
|
||||
get_tablespace_name(orig_tablespaceoid))));
|
||||
|
||||
/* Everything is locked, loop through and move all of the relations. */
|
||||
@ -10881,7 +10881,7 @@ copy_relation_data(SMgrRelation src, SMgrRelation dst,
|
||||
*/
|
||||
static void
|
||||
ATExecEnableDisableTrigger(Relation rel, char *trigname,
|
||||
char fires_when, bool skip_system, LOCKMODE lockmode)
|
||||
char fires_when, bool skip_system, LOCKMODE lockmode)
|
||||
{
|
||||
EnableDisableTrigger(rel, trigname, fires_when, skip_system);
|
||||
}
|
||||
@ -10959,14 +10959,14 @@ ATExecAddInherit(Relation child_rel, RangeVar *parent, LOCKMODE lockmode)
|
||||
!parent_rel->rd_islocaltemp)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("cannot inherit from temporary relation of another session")));
|
||||
errmsg("cannot inherit from temporary relation of another session")));
|
||||
|
||||
/* Ditto for the child */
|
||||
if (child_rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP &&
|
||||
!child_rel->rd_islocaltemp)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("cannot inherit to temporary relation of another session")));
|
||||
errmsg("cannot inherit to temporary relation of another session")));
|
||||
|
||||
/* Prevent partitioned tables from becoming inheritance parents */
|
||||
if (parent_rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
|
||||
@ -11070,8 +11070,8 @@ CreateInheritance(Relation child_rel, Relation parent_rel)
|
||||
if (inh->inhparent == RelationGetRelid(parent_rel))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DUPLICATE_TABLE),
|
||||
errmsg("relation \"%s\" would be inherited from more than once",
|
||||
RelationGetRelationName(parent_rel))));
|
||||
errmsg("relation \"%s\" would be inherited from more than once",
|
||||
RelationGetRelationName(parent_rel))));
|
||||
|
||||
if (inh->inhseqno > inhseqno)
|
||||
inhseqno = inh->inhseqno;
|
||||
@ -11214,8 +11214,8 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
|
||||
if (attribute->attnotnull && !childatt->attnotnull)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("column \"%s\" in child table must be marked NOT NULL",
|
||||
attributeName)));
|
||||
errmsg("column \"%s\" in child table must be marked NOT NULL",
|
||||
attributeName)));
|
||||
|
||||
/*
|
||||
* OK, bump the child column's inheritance count. (If we fail
|
||||
@ -11258,7 +11258,7 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
|
||||
* system column, not some random column named "oid".
|
||||
*/
|
||||
tuple = SearchSysCacheCopy2(ATTNUM,
|
||||
ObjectIdGetDatum(RelationGetRelid(child_rel)),
|
||||
ObjectIdGetDatum(RelationGetRelid(child_rel)),
|
||||
Int16GetDatum(ObjectIdAttributeNumber));
|
||||
if (HeapTupleIsValid(tuple))
|
||||
{
|
||||
@ -11538,15 +11538,15 @@ RemoveInheritance(Relation child_rel, Relation parent_rel)
|
||||
if (child_is_partition)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_TABLE),
|
||||
errmsg("relation \"%s\" is not a partition of relation \"%s\"",
|
||||
RelationGetRelationName(child_rel),
|
||||
RelationGetRelationName(parent_rel))));
|
||||
errmsg("relation \"%s\" is not a partition of relation \"%s\"",
|
||||
RelationGetRelationName(child_rel),
|
||||
RelationGetRelationName(parent_rel))));
|
||||
else
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_TABLE),
|
||||
errmsg("relation \"%s\" is not a parent of relation \"%s\"",
|
||||
RelationGetRelationName(parent_rel),
|
||||
RelationGetRelationName(child_rel))));
|
||||
errmsg("relation \"%s\" is not a parent of relation \"%s\"",
|
||||
RelationGetRelationName(parent_rel),
|
||||
RelationGetRelationName(child_rel))));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -11811,8 +11811,8 @@ ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode)
|
||||
if (strncmp(table_attname, type_attname, NAMEDATALEN) != 0)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("table has column \"%s\" where type requires \"%s\"",
|
||||
table_attname, type_attname)));
|
||||
errmsg("table has column \"%s\" where type requires \"%s\"",
|
||||
table_attname, type_attname)));
|
||||
|
||||
/* Compare type. */
|
||||
if (table_attr->atttypid != type_attr->atttypid ||
|
||||
@ -11820,8 +11820,8 @@ ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode)
|
||||
table_attr->attcollation != type_attr->attcollation)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("table \"%s\" has different type for column \"%s\"",
|
||||
RelationGetRelationName(rel), type_attname)));
|
||||
errmsg("table \"%s\" has different type for column \"%s\"",
|
||||
RelationGetRelationName(rel), type_attname)));
|
||||
}
|
||||
DecrTupleDescRefCount(typeTupleDesc);
|
||||
|
||||
@ -11934,7 +11934,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid,
|
||||
*/
|
||||
pg_class = heap_open(RelationRelationId, RowExclusiveLock);
|
||||
pg_class_tuple = SearchSysCacheCopy1(RELOID,
|
||||
ObjectIdGetDatum(RelationGetRelid(rel)));
|
||||
ObjectIdGetDatum(RelationGetRelid(rel)));
|
||||
if (!HeapTupleIsValid(pg_class_tuple))
|
||||
elog(ERROR, "cache lookup failed for relation \"%s\"",
|
||||
RelationGetRelationName(rel));
|
||||
@ -12067,20 +12067,20 @@ ATExecReplicaIdentity(Relation rel, ReplicaIdentityStmt *stmt, LOCKMODE lockmode
|
||||
!indexRel->rd_index->indisunique)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("cannot use non-unique index \"%s\" as replica identity",
|
||||
RelationGetRelationName(indexRel))));
|
||||
errmsg("cannot use non-unique index \"%s\" as replica identity",
|
||||
RelationGetRelationName(indexRel))));
|
||||
/* Deferred indexes are not guaranteed to be always unique. */
|
||||
if (!indexRel->rd_index->indimmediate)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot use non-immediate index \"%s\" as replica identity",
|
||||
RelationGetRelationName(indexRel))));
|
||||
errmsg("cannot use non-immediate index \"%s\" as replica identity",
|
||||
RelationGetRelationName(indexRel))));
|
||||
/* Expression indexes aren't supported. */
|
||||
if (RelationGetIndexExpressions(indexRel) != NIL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot use expression index \"%s\" as replica identity",
|
||||
RelationGetRelationName(indexRel))));
|
||||
errmsg("cannot use expression index \"%s\" as replica identity",
|
||||
RelationGetRelationName(indexRel))));
|
||||
/* Predicate indexes aren't supported. */
|
||||
if (RelationGetIndexPredicate(indexRel) != NIL)
|
||||
ereport(ERROR,
|
||||
@ -12451,7 +12451,7 @@ AlterTableNamespace(AlterObjectSchemaStmt *stmt, Oid *oldschema)
|
||||
sequenceIsOwned(relid, DEPENDENCY_INTERNAL, &tableId, &colId))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot move an owned sequence into another schema"),
|
||||
errmsg("cannot move an owned sequence into another schema"),
|
||||
errdetail("Sequence \"%s\" is linked to table \"%s\".",
|
||||
RelationGetRelationName(rel),
|
||||
get_rel_name(tableId))));
|
||||
@ -13233,15 +13233,15 @@ ComputePartitionAttrs(Relation rel, List *partParams, AttrNumber *partattrs,
|
||||
if (!HeapTupleIsValid(atttuple))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_COLUMN),
|
||||
errmsg("column \"%s\" named in partition key does not exist",
|
||||
pelem->name)));
|
||||
errmsg("column \"%s\" named in partition key does not exist",
|
||||
pelem->name)));
|
||||
attform = (Form_pg_attribute) GETSTRUCT(atttuple);
|
||||
|
||||
if (attform->attnum <= 0)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("cannot use system column \"%s\" in partition key",
|
||||
pelem->name)));
|
||||
errmsg("cannot use system column \"%s\" in partition key",
|
||||
pelem->name)));
|
||||
|
||||
partattrs[attn] = attform->attnum;
|
||||
atttype = attform->atttypid;
|
||||
@ -13383,8 +13383,8 @@ ComputePartitionAttrs(Relation rel, List *partParams, AttrNumber *partattrs,
|
||||
if (!OidIsValid(partopclass[attn]))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("data type %s has no default btree operator class",
|
||||
format_type_be(atttype)),
|
||||
errmsg("data type %s has no default btree operator class",
|
||||
format_type_be(atttype)),
|
||||
errhint("You must specify a btree operator class or define a default btree operator class for the data type.")));
|
||||
}
|
||||
else
|
||||
@ -13511,17 +13511,17 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
|
||||
if (rel->rd_rel->relhasoids && !attachRel->rd_rel->relhasoids)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("cannot attach table \"%s\" without OIDs as partition of"
|
||||
" table \"%s\" with OIDs", RelationGetRelationName(attachRel),
|
||||
RelationGetRelationName(rel))));
|
||||
errmsg("cannot attach table \"%s\" without OIDs as partition of"
|
||||
" table \"%s\" with OIDs", RelationGetRelationName(attachRel),
|
||||
RelationGetRelationName(rel))));
|
||||
|
||||
/* OTOH, if parent doesn't have them, do not allow in attachRel either */
|
||||
if (attachRel->rd_rel->relhasoids && !rel->rd_rel->relhasoids)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("cannot attach table \"%s\" with OIDs as partition of table"
|
||||
" \"%s\" without OIDs", RelationGetRelationName(attachRel),
|
||||
RelationGetRelationName(rel))));
|
||||
errmsg("cannot attach table \"%s\" with OIDs as partition of table"
|
||||
" \"%s\" without OIDs", RelationGetRelationName(attachRel),
|
||||
RelationGetRelationName(rel))));
|
||||
|
||||
/* Check if there are any columns in attachRel that aren't in the parent */
|
||||
tupleDesc = RelationGetDescr(attachRel);
|
||||
|
Reference in New Issue
Block a user