pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: hackerzheng666@gmail.com
Subject: BUG #19904: pg_column_is_updatable(): "negative bitmapset member not allowed" for large attnum (int16 overflow)
Date: Sun, 15 Nov 2026 04:48:38 +0000
Message-ID: <19904-57a44a8aa7638ae4@postgresql.org> (raw)

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.








view thread (3+ messages)  latest in thread

Message-ID: <19904-57a44a8aa7638ae4@postgresql.org>
Permalink:  ../19904-57a44a8aa7638ae4@postgresql.org/
Also on:    postgresql.org/message-id/19904-57a44a8aa7638ae4@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, hackerzheng666@gmail.com
  Subject: Re: BUG #19904: pg_column_is_updatable(): "negative bitmapset member not allowed" for large attnum (int16 overflow)
  In-Reply-To: <19904-57a44a8aa7638ae4@postgresql.org>
  References: <19904-57a44a8aa7638ae4@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox