| From: | Alexander Lakhin <exclusion(at)gmail(dot)com> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | Michael Paquier <michael(at)paquier(dot)xyz>, Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Justin Pryzby <pryzby(at)telsasoft(dot)com> |
| Subject: | Re: Internal error codes triggered by regression tests and user queries, take 2 |
| Date: | 2026-09-12 11:00:00 |
| Message-ID: | 7a9b3652-134c-4565-82ad-839035a3a382@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hello Tom,
07.09.2026 00:00, Alexander Lakhin wrote:
>
> 06.09.2026 22:07, Tom Lane wrote:
>
>> @@ -794,8 +794,10 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column)
>> if (constraint->conname &&
>> notnull_constraint->conname &&
>> strcmp(notnull_constraint->conname, constraint->conname) != 0)
>> - elog(ERROR, "conflicting not-null constraint names \"%s\" and \"%s\"",
>> - notnull_constraint->conname, constraint->conname);
>> + ereport(ERROR,
>> + errcode(ERRCODE_SYNTAX_ERROR),
>> + errmsg("conflicting not-null constraint names \"%s\" and \"%s\"",
>> + notnull_constraint->conname, constraint->conname));
>>
>> This does not seem like a "syntax error". Perhaps
>> ERRCODE_INVALID_OBJECT_DEFINITION would serve?
>
> Yeah, I considered this, but the same errmsg in
> AddRelationNotNullConstraints() uses ERRCODE_SYNTAX_ERROR. I found it
> more consistent to emit the same code. Maybe it would make do the opposite
> -- change the errcode in AddRelationNotNullConstraints() (there are two
> instances there, though)... Moreover, ERRCODE_SYNTAX_ERROR is chosen for
> many other similar messages in transformColumnDefinition(), so I'm not
> sure if it makes sense to change all of those or just report "syntax error"
> for consistency while keeping the patch focused.
I've changed that occurrence to ERRCODE_INVALID_OBJECT_DEFINITION, but as
I mentioned above, transformColumnDefinition() has many other SYNTAX_ERRORs
(originating from a56ff9a0b), besides AddRelationNotNullConstraints().
Please find attached a patch to correct these too, for consistency, if you
find this appropriate. There are other similar errors in parse_utilcmd.c,
but I'd stop here unless we want to start a new campaign not to define,
but correct error codes according to some convention.
>> We'd be well advised to make those two messages more consistent,
>> whether they're worth translating or not. Also I guess a sweep
>> for other "unreachable" errors in typmodout functions might be
>> useful
Changed three occurrences to use the same errmsg and errcode.
Please look at the attached v3-Define-...patch, where I think I addressed
all of your comments.
Thank you for your time!
Best regards,
Alexander
| Attachment | Content-Type | Size |
|---|---|---|
| v3-Define-missing-errcodes.patch | text/x-patch | 5.4 KB |
| v3-Correct-errcodes-in-transformColumnDefinition-AddRelationNotNullConstraints.patch | text/x-patch | 6.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Paul Kim | 2026-09-12 11:52:26 | Re: Be strict when request to flush past end of WAL in WaitXLogInsertionsToFinish |
| Previous Message | Dean Rasheed | 2026-09-12 10:34:21 | Re: SSI: ON CONFLICT DO SELECT takes no predicate lock on the returned row |