Re: overflow bug for inhcounts

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, jian he <jian(dot)universality(at)gmail(dot)com>
Subject: Re: overflow bug for inhcounts
Date: 2024-10-09 10:59:20
Message-ID: 202410091059.oyl22p2w5kie@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2024-Oct-08, Tom Lane wrote:

> Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> > ... This is because ColumnDef->inhcount is a 32-bit int, but
> > Form_pg_attribute->attinhcount is int16, so we didn't break the overflow
> > test for ColumnDef inhcount, but attinhcount has overflowed during
> > assignment.
>
> Ugh ... somebody's ancient oversight there. Or maybe attinhcount
> was once int32, and we narrowed it for space reasons?

Yeah, both attinhcount and coninhcount were narrowed in 90189eefc1e1
during REL_16_STABLE development, so it's a relatively new problem.

> > From branch master, I propose we change those two members to int16
> > (ColumnDef->inhcount and CookedConstraint->inhcount) to make those
> > counters consistently use the same type; and then use
> > pg_add_s16_overflow() instead of ++ for the increments, as in the
> > attached patch. With this patch, the child table creation fails as
> > expected ("too many inheritance parents").
>
> +1. I didn't check if there were any other places to touch, but
> this looks like a good solution for master.

Thanks for looking.

--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"La conclusión que podemos sacar de esos estudios es que
no podemos sacar ninguna conclusión de ellos" (Tanenbaum)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nishant Sharma 2024-10-09 11:11:33 Re: [PROPOSAL] : Disallow use of empty column name in (column_name '') in ALTER or CREATE of foreign table.
Previous Message Tomas Vondra 2024-10-09 10:41:02 Re: Changing the state of data checksums in a running cluster