postgres.git / summary / log / commit / refs

commit    3a95588fef072ab22aa276d14065ad1bf6bcc976
Author:   David Rowley <drowley@postgresql.org>
Date:     Wed Nov 18 20:01:04 2026 +0000

    Robustify pg_column_is_updatable() against overly large attnums
    
    Passing an attnum sufficiently close to PG_INT16_MAX could wrap
    AttrNumber when offsetting for FirstLowInvalidHeapAttributeNumber,
    leading to an attempt to build a Bitmapset with a negative member value
    resulting in an ERROR, rather than returning the result as it would for
    other nonexistent columns.
    
    Upgrade the type used to 32-bit to avoid this issue.
    
    Bug: #19904
    Reported-by: Zheng Hacker <hackerzheng666@gmail.com>
    Discussion: https://postgr.es/m/19904-57a44a8aa7638ae4@postgresql.org
    Backpatch-through: 15


src/backend/utils/adt/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c index 6fcfd031428..386722afd7b 100644 --- a/src/backend/utils/adt/misc.c +++ b/src/backend/utils/adt/misc.c @@ -666,7 +666,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); int events; [parent: e3b7f6156916]