Re: [PATCH] Fix duplicate errmsg in ALTER TABLE SPLIT PARTITION - Mailing list pgsql-hackers

From jian he
Subject Re: [PATCH] Fix duplicate errmsg in ALTER TABLE SPLIT PARTITION
Date
Msg-id CACJufxHWE=898fu2YX_T01yckJcrL5KcEBp0Cwhkvq66snJ0sw@mail.gmail.com
Whole thread
In response to Re: [PATCH] Fix duplicate errmsg in ALTER TABLE SPLIT PARTITION  (John Naylor <johncnaylorls@gmail.com>)
List pgsql-hackers
On Tue, May 5, 2026 at 3:15 PM John Naylor <johncnaylorls@gmail.com> wrote:
>
> Observation:
>
> -        errmsg("can not split non-DEFAULT partition \"%s\"",
> +        errmsg("cannot split non-DEFAULT partition \"%s\"",
>               get_rel_name(splitPartOid)),
> -        errmsg("new partition cannot be DEFAULT because...
> +        errdetail("New partition cannot be DEFAULT because...
>
> -ERROR:  new partition cannot be DEFAULT because DEFAULT partition
> "sales_others" already exists
> +ERROR:  cannot split non-DEFAULT partition "sales_all"
>  LINE 5:    PARTITION sales_others2 DEFAULT);
>                       ^
> +DETAIL:  New partition cannot be DEFAULT because DEFAULT partition
> "sales_others" already exists.
>
> If there are two errmsg's back-to-back, only the second one displays.
> Maybe some automated tooling can detect cases like this going forward?
>

Add an Assert in function errmsg, it will crashes the server when two
errmsg back-to-back:

    Assert(edata->message == NULL);
    EVALUATE_MESSAGE(edata->domain, message, false, true);

Function FreeErrorDataContents change to
```
    if (edata->message)
    {
        pfree(edata->message);
        edata->message = NULL;
    }
```

Most of the tests succeeded on my local machines.
Ok:                 373
Expected Fail:      0
Fail:               0
Unexpected Pass:    0
Skipped:            23
Timeout:            0

I'm not sure if ereport_domain acts differently when
HAVE_PG_INTEGER_CONSTANT_P is true.



--
jian
https://www.enterprisedb.com/



pgsql-hackers by date:

Previous
From: Soumya S Murali
Date:
Subject: Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement
Next
From: John Naylor
Date:
Subject: Re: vectorized CRC on ARM64