pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #19904: pg_column_is_updatable(): "negative bitmapset member not allowed" for large attnum (int16 overflow)
3+ messages / 2 participants
[nested] [flat]

Commits from this thread:
  2026-11-18 8d7914fa68 4892c9447e 5f4f6e412f 3a95588fef 94280519a0 79a9240c6f  Robustify pg_column_is_updatable() against overly large attnums
* BUG #19904: pg_column_is_updatable(): "negative bitmapset member not allowed" for large attnum (int16 overflow)
@ 2026-11-15 04:48 PG Bug reporting form <noreply@postgresql.org>
  2026-11-17 03:55 ` Re: BUG #19904: pg_column_is_updatable(): "negative bitmapset member not allowed" for large attnum (int16 overflow) David Rowley <dgrowleyml@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: PG Bug reporting form @ 2026-11-15 04:48 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: hackerzheng666@gmail.com

The following bug has been logged on the website:

Bug reference:      19904
Logged by:          Zheng Hacker
Email address:      hackerzheng666@gmail.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.








^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #19904: pg_column_is_updatable(): "negative bitmapset member not allowed" for large attnum (int16 overflow)
  2026-11-15 04:48 BUG #19904: pg_column_is_updatable(): "negative bitmapset member not allowed" for large attnum (int16 overflow) PG Bug reporting form <noreply@postgresql.org>
@ 2026-11-17 03:55 ` David Rowley <dgrowleyml@gmail.com>
  2026-11-18 20:10   ` Re: BUG #19904: pg_column_is_updatable(): "negative bitmapset member not allowed" for large attnum (int16 overflow) David Rowley <dgrowleyml@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: David Rowley @ 2026-11-17 03:55 UTC (permalink / raw)
  To: hackerzheng666@gmail.com; pgsql-bugs@lists.postgresql.org

On Tue, 17 Nov 2026 at 00:45, PG Bug reporting form
<noreply@postgresql.org> wrote:
> create table tt(a int, b text);
> select pg_column_is_updatable('tt'::regclass, 32767::smallint, true);
> ERROR:  negative bitmapset member not allowed

So don't do that?

We could fix by just promoting the AttrNumber to int with:

inline patch 1: src/backend/utils/adt/misc.c (+1/-1 lines) download inline-1.patch--- a/src/backend/utils/adt/misc.c +++ b/src/backend/utils/adt/misc.c @@ -639,7 +639,7 @@ pg_column_is_updatable(PG_FUNCTION_ARGS) { Oid reloid = PG_GETARG_OID(0); AttrNumber attnum = PG_GETARG_INT16(1); - AttrNumber col = attnum - FirstLowInvalidHeapAttributeNumber; + int col = attnum -
FirstLowInvalidHeapAttributeNumber; bool include_triggers = PG_GETARG_BOOL(2); That avoids overflowing the int16 when subtracting the -7 David ^ permalink raw reply [nested|flat] 3+ messages in thread

* Re: BUG #19904: pg_column_is_updatable(): "negative bitmapset member not allowed" for large attnum (int16 overflow)
  2026-11-15 04:48 BUG #19904: pg_column_is_updatable(): "negative bitmapset member not allowed" for large attnum (int16 overflow) PG Bug reporting form <noreply@postgresql.org>
  2026-11-17 03:55 ` Re: BUG #19904: pg_column_is_updatable(): "negative bitmapset member not allowed" for large attnum (int16 overflow) David Rowley <dgrowleyml@gmail.com>
@ 2026-11-18 20:10   ` David Rowley <dgrowleyml@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: David Rowley @ 2026-11-18 20:10 UTC (permalink / raw)
  To: hackerzheng666@gmail.com; pgsql-bugs@lists.postgresql.org

On Tue, 17 Nov 2026 at 16:55, David Rowley <dgrowleyml@gmail.com> wrote:
>
> On Tue, 17 Nov 2026 at 00:45, PG Bug reporting form
> <noreply@postgresql.org> wrote:
> > create table tt(a int, b text);
> > select pg_column_is_updatable('tt'::regclass, 32767::smallint, true);
> > ERROR:  negative bitmapset member not allowed
>
> We could fix by just promoting the AttrNumber to int with:

Pushed. Thanks.

David






^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2026-11-18 20:10 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-15 04:48 BUG #19904: pg_column_is_updatable(): "negative bitmapset member not allowed" for large attnum (int16 overflow) PG Bug reporting form <noreply@postgresql.org>
2026-11-17 03:55 ` David Rowley <dgrowleyml@gmail.com>
2026-11-18 20:10   ` David Rowley <dgrowleyml@gmail.com>

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