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);
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;
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
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
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,
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,
-- Some error cases.
ALTER TABLE comment_test ALTER COLUMN xmin SET DATA TYPE x;
ERROR: cannot alter system column "xmin"
+LINE 1: ALTER TABLE comment_test ALTER COLUMN xmin SET DATA TYPE x;
+ ^
ALTER TABLE comment_test ALTER COLUMN id SET DATA TYPE x;
ERROR: type "x" does not exist
+LINE 1: ALTER TABLE comment_test ALTER COLUMN id SET DATA TYPE x;
+ ^
ALTER TABLE comment_test ALTER COLUMN id SET DATA TYPE int COLLATE "C";
ERROR: collations are not supported by type integer
+LINE 1: ...LE comment_test ALTER COLUMN id SET DATA TYPE int COLLATE "C...
+ ^
-- Check that the comments are intact.
SELECT col_description('comment_test'::regclass, 1) as comment;
comment
ERROR: cannot drop column "a" because it is part of the partition key of relation "partitioned"
ALTER TABLE partitioned ALTER COLUMN a TYPE char(5);
ERROR: cannot alter column "a" because it is part of the partition key of relation "partitioned"
+LINE 1: ALTER TABLE partitioned ALTER COLUMN a TYPE char(5);
+ ^
ALTER TABLE partitioned DROP COLUMN b;
ERROR: cannot drop column "b" because it is part of the partition key of relation "partitioned"
ALTER TABLE partitioned ALTER COLUMN b TYPE char(5);
ERROR: cannot alter column "b" because it is part of the partition key of relation "partitioned"
+LINE 1: ALTER TABLE partitioned ALTER COLUMN b TYPE char(5);
+ ^
-- specifying storage parameters for partitioned tables is not supported
ALTER TABLE partitioned SET (fillfactor=100);
ERROR: cannot specify storage parameters for a partitioned table
ERROR: cannot rename inherited column "b"
ALTER TABLE part_2 ALTER COLUMN b TYPE text;
ERROR: cannot alter inherited column "b"
+LINE 1: ALTER TABLE part_2 ALTER COLUMN b TYPE text;
+ ^
-- cannot add NOT NULL or check constraints to *only* the parent, when
-- partitions exist
ALTER TABLE ONLY list_parted2 ALTER b SET NOT NULL;
ERROR: cannot drop column "b" because it is part of the partition key of relation "part_5"
ALTER TABLE list_parted2 ALTER COLUMN b TYPE text;
ERROR: cannot alter column "b" because it is part of the partition key of relation "part_5"
+LINE 1: ALTER TABLE list_parted2 ALTER COLUMN b TYPE text;
+ ^
-- dropping non-partition key columns should be allowed on the parent table.
ALTER TABLE list_parted DROP COLUMN b;
SELECT * FROM list_parted;