@@ -13410,27 +13410,31 @@ ATPrepAlterColumnType(List **wqueue,
13410
13410
AclResult aclresult;
13411
13411
bool is_expr;
13412
13412
13413
+ pstate->p_sourcetext = context->queryString;
13414
+
13413
13415
if (rel->rd_rel->reloftype && !recursing)
13414
13416
ereport(ERROR,
13415
13417
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
13416
- errmsg("cannot alter column type of typed table")));
13418
+ errmsg("cannot alter column type of typed table"),
13419
+ parser_errposition(pstate, def->location)));
13417
13420
13418
13421
/* lookup the attribute so we can check inheritance status */
13419
13422
tuple = SearchSysCacheAttName(RelationGetRelid(rel), colName);
13420
13423
if (!HeapTupleIsValid(tuple))
13421
13424
ereport(ERROR,
13422
13425
(errcode(ERRCODE_UNDEFINED_COLUMN),
13423
13426
errmsg("column \"%s\" of relation \"%s\" does not exist",
13424
- colName, RelationGetRelationName(rel))));
13427
+ colName, RelationGetRelationName(rel)),
13428
+ parser_errposition(pstate, def->location)));
13425
13429
attTup = (Form_pg_attribute) GETSTRUCT(tuple);
13426
13430
attnum = attTup->attnum;
13427
13431
13428
13432
/* Can't alter a system attribute */
13429
13433
if (attnum <= 0)
13430
13434
ereport(ERROR,
13431
13435
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
13432
- errmsg("cannot alter system column \"%s\"",
13433
- colName )));
13436
+ errmsg("cannot alter system column \"%s\"", colName),
13437
+ parser_errposition(pstate, def->location )));
13434
13438
13435
13439
/*
13436
13440
* Cannot specify USING when altering type of a generated column, because
@@ -13440,7 +13444,8 @@ ATPrepAlterColumnType(List **wqueue,
13440
13444
ereport(ERROR,
13441
13445
(errcode(ERRCODE_INVALID_COLUMN_DEFINITION),
13442
13446
errmsg("cannot specify USING when altering type of generated column"),
13443
- errdetail("Column \"%s\" is a generated column.", colName)));
13447
+ errdetail("Column \"%s\" is a generated column.", colName),
13448
+ parser_errposition(pstate, def->location)));
13444
13449
13445
13450
/*
13446
13451
* Don't alter inherited columns. At outer level, there had better not be
@@ -13450,8 +13455,8 @@ ATPrepAlterColumnType(List **wqueue,
13450
13455
if (attTup->attinhcount > 0 && !recursing)
13451
13456
ereport(ERROR,
13452
13457
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
13453
- errmsg("cannot alter inherited column \"%s\"",
13454
- colName )));
13458
+ errmsg("cannot alter inherited column \"%s\"", colName),
13459
+ parser_errposition(pstate, def->location )));
13455
13460
13456
13461
/* Don't alter columns used in the partition key */
13457
13462
if (has_partition_attrs(rel,
@@ -13460,17 +13465,18 @@ ATPrepAlterColumnType(List **wqueue,
13460
13465
ereport(ERROR,
13461
13466
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
13462
13467
errmsg("cannot alter column \"%s\" because it is part of the partition key of relation \"%s\"",
13463
- colName, RelationGetRelationName(rel))));
13468
+ colName, RelationGetRelationName(rel)),
13469
+ parser_errposition(pstate, def->location)));
13464
13470
13465
13471
/* Look up the target type */
13466
- typenameTypeIdAndMod(NULL , typeName, &targettype, &targettypmod);
13472
+ typenameTypeIdAndMod(pstate , typeName, &targettype, &targettypmod);
13467
13473
13468
13474
aclresult = object_aclcheck(TypeRelationId, targettype, GetUserId(), ACL_USAGE);
13469
13475
if (aclresult != ACLCHECK_OK)
13470
13476
aclcheck_error_type(aclresult, targettype);
13471
13477
13472
13478
/* And the collation */
13473
- targetcollid = GetColumnDefCollation(NULL , def, targettype);
13479
+ targetcollid = GetColumnDefCollation(pstate , def, targettype);
13474
13480
13475
13481
/* make sure datatype is legal for a column */
13476
13482
CheckAttributeType(colName, targettype, targetcollid,
0 commit comments