Re: wrong relkind error messages

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: wrong relkind error messages
Date: 2021-07-02 10:53:08
Message-ID: 84b376ef-573f-47bf-fff9-797078b7146b@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 02.07.21 08:25, Michael Paquier wrote:
> + ereport(ERROR,
> + (errcode(ERRCODE_WRONG_OBJECT_TYPE),
> + errmsg("ALTER action %s cannot be performed on relation \"%s\"",
> + action_str, RelationGetRelationName(rel)),
> + errdetail_relkind_not_supported(rel->rd_rel->relkind)));
> Perhaps the result of alter_table_type_to_string() is worth a note for
> translators?

ok

> + case AT_DetachPartitionFinalize:
> + return "DETACH PARTITION FINALIZE";
> To be exact, I think that this one should be "DETACH PARTITION
> ... FINALIZE".

ok

> + if (relkind == RELKIND_INDEX || relkind == RELKIND_PARTITIONED_INDEX)
> + ereport(ERROR,
> + (errcode(ERRCODE_WRONG_OBJECT_TYPE),
> + errmsg("cannot change schema of index \"%s\"",
> + rv->relname),
> + errhint("Change the schema of the table instead.")));
> + else if (relkind == RELKIND_COMPOSITE_TYPE)
> + ereport(ERROR,
> + (errcode(ERRCODE_WRONG_OBJECT_TYPE),
> + errmsg("cannot change schema of composite type
> \"%s\"",
> + rv->relname),
> + errhint("Use ALTER TYPE instead.")));
> I would simplify this part by removing the errhint(), and use "cannot
> change schema of relation .." as error string, with a dose of
> errdetail_relkind_not_supported().

I aimed for parity with the error reporting in ATExecChangeOwner() here.

> + errmsg("relation \"%s\" cannot have triggers",
> + RelationGetRelationName(rel)),
> Better as "cannot create/rename/remove triggers on relation \"%s\""
> for the three code paths of trigger.c?
>
> + errmsg("relation \"%s\" cannot have rules",
> [...]
> + errmsg("relation \"%s\" cannot have rules",
> For rewriteDefine.c, this could be "cannot create/rename rules on
> relation".

I had it like that, but in previous reviews some people liked it better
this way. ;-) I tend to agree with that, since the error condition
isn't that you can't create a rule/etc. (like, due to incorrect
prerequisite state) but that there cannot be one ever.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2021-07-02 10:55:47 Re: Numeric multiplication overflow errors
Previous Message David Rowley 2021-07-02 10:30:53 Re: Small clean up in nodeAgg.c