BUG #19904: pg_column_is_updatable(): "negative bitmapset member not allowed" for large attnum (int16 overflow)

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: hackerzheng666(at)gmail(dot)com
Subject: BUG #19904: pg_column_is_updatable(): "negative bitmapset member not allowed" for large attnum (int16 overflow)
Date: 2026-11-15 04:48:38
Message-ID: 19904-57a44a8aa7638ae4@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 19904
Logged by: Zheng Hacker
Email address: hackerzheng666(at)gmail(dot)com
PostgreSQL version: 19rc2
Operating system: Linux x86_64 (Ubuntu 22.04)
Description:

Tested on git master (20devel, commit 70c4a57b64d3; the code in question is
unchanged at master 81b2179 as of 2026-11-14). Not tested on 19rc2 or older
branches; the version selected in the form is only the closest listed one.

create table tt(a int, b text);
select pg_column_is_updatable('tt'::regclass, 32767::smallint, true);
ERROR: negative bitmapset member not allowed

In src/backend/utils/adt/misc.c, pg_column_is_updatable() computes

AttrNumber col = attnum - FirstLowInvalidHeapAttributeNumber;

AttrNumber is int16, FirstLowInvalidHeapAttributeNumber is -7, so for attnum
>= 32761 the result wraps to a negative value and bms_make_singleton(col)
raises the internal error. A valid table with a nonexistent column number
should simply return false, not an internal error. Computing col as int (or
returning false when attnum exceeds the relation's column count before
building the bitmapset) avoids it.

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2026-11-15 04:49:11 BUG #19905: loread() with length near INT_MAX: "invalid memory alloc request size" (int32 overflow)
Previous Message shihao zhong 2026-11-15 03:59:05 Re: BUG #19703: information_schema.usage_privileges omits a sequence owner's implicit USAGE privilege