From: Michael Paquier <michael@paquier.xyz>
To: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Cc: Matthias van de Meent <boekewurm+postgres@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: BUG: pg_class.relchecks overflow, making table undroppable
Date: Fri, 25 Sep 2026 18:04:40 +0900
Message-ID: <arY5KKfzODnXJ-eG@paquier.xyz> (raw)
In-Reply-To: <arYzwtRf+S9h5UQm@bdtpg>
References: <CAEze2WjSW4qaHYnvkTtbknp85eGEirGJTLMZatotdJJKiA+_hA@mail.gmail.com>
<arWrSl3XON1pTGNp@paquier.xyz>
<arYzwtRf+S9h5UQm@bdtpg>
On Fri, Sep 25, 2026 at 08:41:38AM +0000, Bertrand Drouvot wrote:
> Just a few comments:
>
> === 1
>
> It needs a rebase due to 926627bf902
>
> === 2
>
> + ereport(ERROR,
> + errmsg("too many check constraints on relation \"%s\"",
> + RelationGetQualifiedRelationName(rel)));
>
>
> I think ERRCODE_PROGRAM_LIMIT_EXCEEDED would be appropriate here?
An error record would be appropriate, yes. That's reachable with SQL.
> numchecks++;
> +
> + if (numchecks >= PG_INT16_MAX)
> + ereport(ERROR,
> + errmsg("too many check constraints on relation \"%s\"",
> + RelationGetQualifiedRelationName(rel)));
>
> I wonder if it wouldn't make more sense to check numchecks >= PG_INT16_MAX before
> calling StoreRelCheck()? That would avoid inserting the constraint, recording its
> dependencies and invoking the post create hook for an object that will be rejected.
Yeah, let's do that. That's unlikely but it would just be a waste and
that's just switching the order of things.
If somebody is willing to send an updated patch, feel free, I don't
have the energy for that today.. Jian also mentioned
pg_add_s16_overflow(), which is a good idea for this case. :D
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: michael@paquier.xyz, bertranddrouvot.pg@gmail.com, boekewurm+postgres@gmail.com
Subject: Re: BUG: pg_class.relchecks overflow, making table undroppable
In-Reply-To: <arY5KKfzODnXJ-eG@paquier.xyz>
References: <CAEze2WjSW4qaHYnvkTtbknp85eGEirGJTLMZatotdJJKiA+_hA@mail.gmail.com> <arWrSl3XON1pTGNp@paquier.xyz> <arYzwtRf+S9h5UQm@bdtpg> <arY5KKfzODnXJ-eG@paquier.xyz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox