01.05.2024 17:08, Tom Lane wrote:
> Hm. We could fix this by introducing another single-purpose error
> report, but I'm starting to think that that's failing to learn from
> experience. Who's to say that other column dependencies aren't
> possible, now or in the future? The only thing stopping us from
> treating the default: case as a normal ERRCODE_FEATURE_NOT_SUPPORTED
> error is that it might be hard to phrase the error message in a nice
> way. We already have a precedent for this being an acceptable
> errdetail:
>
> ereport(ERROR,
> (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
> errmsg("cannot alter type of a column used in a policy definition"),
> errdetail("%s depends on column \"%s\"",
> getObjectDescription(&foundObject, false),
> colName)));
>
> It doesn't seem too awful to me to write the errmsg as
>
> errmsg("cannot alter type of a column used in a %s",
> get_object_class_descr(foundObject.classid)),
I agree, though by doing that we'll loose the ability to detect obviously
wrong dependencies, say, when a role depends on a table column (if
INTERNAL_ERRORs expected to be handled as something abnormal),
but ATExecAlterColumnType() is hardly an appropriate place for such
detection anyway. So I would sacrifice this ability to make this function
simpler now and in the future.
Best regards,
Alexander