pgsql: Fix StoreCatalogInheritance1 to use 32bit inhseqno

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix StoreCatalogInheritance1 to use 32bit inhseqno
Date: 2018-01-19 13:18:54
Message-ID: E1ecWZK-0005SO-P5@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix StoreCatalogInheritance1 to use 32bit inhseqno

For no apparent reason, this function was using a 16bit-wide inhseqno
value, rather than the correct 32 bit width which is what is stored in
the pg_inherits catalog. This becomes evident if you try to create a
table with more than 65535 parents, because this error appears:

ERROR: duplicate key value violates unique constraint «pg_inherits_relid_seqno_index»
DETAIL: Key (inhrelid, inhseqno)=(329371, 0) already exists.

Needless to say, having so many parents is an uncommon situations, which
explains why this error has never been reported despite being having
been introduced with the Postgres95 1.01 sources in commit d31084e9d111:
https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/commands/creatinh.c;hb=d31084e9d111#l349

Backpatch all the way back.

David Rowley noticed this while reviewing a patch of mine.
Discussion: https://postgr.es/m/CAKJS1f8Dn7swSEhOWwzZzssW7747YB=2Hi+T7uGud40dur69-g@mail.gmail.com

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/8a71ee6288547e20218b08240d8ae867bb16d6c6

Modified Files
--------------
src/backend/commands/tablecmds.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2018-01-19 14:55:08 pgsql: Local partitioned indexes
Previous Message Robert Haas 2018-01-19 12:51:12 pgsql: Transfer state pertaining to pending REINDEX operations to worke