summaryrefslogtreecommitdiff
path: root/src/backend/commands/tablecmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r--src/backend/commands/tablecmds.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 96a48ba82c1..d617c4bc63d 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -13410,10 +13410,13 @@ ATPrepAlterColumnType(List **wqueue,
AclResult aclresult;
bool is_expr;
+ pstate->p_sourcetext = context->queryString;
+
if (rel->rd_rel->reloftype && !recursing)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("cannot alter column type of typed table")));
+ errmsg("cannot alter column type of typed table"),
+ parser_errposition(pstate, def->location)));
/* lookup the attribute so we can check inheritance status */
tuple = SearchSysCacheAttName(RelationGetRelid(rel), colName);
@@ -13421,7 +13424,8 @@ ATPrepAlterColumnType(List **wqueue,
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
- colName, RelationGetRelationName(rel))));
+ colName, RelationGetRelationName(rel)),
+ parser_errposition(pstate, def->location)));
attTup = (Form_pg_attribute) GETSTRUCT(tuple);
attnum = attTup->attnum;
@@ -13429,8 +13433,8 @@ ATPrepAlterColumnType(List **wqueue,
if (attnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot alter system column \"%s\"",
- colName)));
+ errmsg("cannot alter system column \"%s\"", colName),
+ parser_errposition(pstate, def->location)));
/*
* Cannot specify USING when altering type of a generated column, because
@@ -13440,7 +13444,8 @@ ATPrepAlterColumnType(List **wqueue,
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_DEFINITION),
errmsg("cannot specify USING when altering type of generated column"),
- errdetail("Column \"%s\" is a generated column.", colName)));
+ errdetail("Column \"%s\" is a generated column.", colName),
+ parser_errposition(pstate, def->location)));
/*
* Don't alter inherited columns. At outer level, there had better not be
@@ -13450,8 +13455,8 @@ ATPrepAlterColumnType(List **wqueue,
if (attTup->attinhcount > 0 && !recursing)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
- errmsg("cannot alter inherited column \"%s\"",
- colName)));
+ errmsg("cannot alter inherited column \"%s\"", colName),
+ parser_errposition(pstate, def->location)));
/* Don't alter columns used in the partition key */
if (has_partition_attrs(rel,
@@ -13460,17 +13465,18 @@ ATPrepAlterColumnType(List **wqueue,
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("cannot alter column \"%s\" because it is part of the partition key of relation \"%s\"",
- colName, RelationGetRelationName(rel))));
+ colName, RelationGetRelationName(rel)),
+ parser_errposition(pstate, def->location)));
/* Look up the target type */
- typenameTypeIdAndMod(NULL, typeName, &targettype, &targettypmod);
+ typenameTypeIdAndMod(pstate, typeName, &targettype, &targettypmod);
aclresult = object_aclcheck(TypeRelationId, targettype, GetUserId(), ACL_USAGE);
if (aclresult != ACLCHECK_OK)
aclcheck_error_type(aclresult, targettype);
/* And the collation */
- targetcollid = GetColumnDefCollation(NULL, def, targettype);
+ targetcollid = GetColumnDefCollation(pstate, def, targettype);
/* make sure datatype is legal for a column */
CheckAttributeType(colName, targettype, targetcollid,