agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Enforce pg_class.relchecks limit (32,767 or INT16_MAX)
Date: Sun, 27 Sep 2026 21:55:38 +0000
Message-ID: <E1xAwqQ-00000001WCF-3l6L@gemulon.postgresql.org> (raw)

Enforce pg_class.relchecks limit (32,767 or INT16_MAX)

pg_class.relchecks reports the number of CHECK constraints in a table,
and is stored within a smallint.  It was possible to define a table that
could overflow the counter when specifying more than 32k constraints
(new table or adding a constraint).  This would cause the table to
become undroppable, as this counter should never be negative when
dropping these constraints.

Author: Matthias van de Meent <boekewurm+postgres@gmail.com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Jian He <jian.universality@gmail.com>
Reviewed-by: Sivaprasad <sivaprasad.postgres@gmail.com>
Discussion: https://postgr.es/m/CAEze2WjSW4qaHYnvkTtbknp85eGEirGJTLMZatotdJJKiA+_hA@mail.gmail.com
Backpatch-through: 14

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9ca1d5726c21e3ae182ce461d439e360a0658ad8

Modified Files
--------------
doc/src/sgml/limits.sgml   |  7 +++++++
src/backend/catalog/heap.c | 28 +++++++++++++++++++++++-----
2 files changed, 30 insertions(+), 5 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1xAwqQ-00000001WCF-3l6L@gemulon.postgresql.org>
Permalink:  ../E1xAwqQ-00000001WCF-3l6L@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xAwqQ-00000001WCF-3l6L@gemulon.postgresql.org

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Enforce pg_class.relchecks limit (32,767 or INT16_MAX)
  In-Reply-To: <E1xAwqQ-00000001WCF-3l6L@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox