summaryrefslogtreecommitdiff
path: root/src/backend/catalog/index.c
diff options
context:
space:
mode:
authorÁlvaro Herrera2024-10-10 15:41:01 +0000
committerÁlvaro Herrera2024-10-10 15:41:01 +0000
commitfd64ed60b62697984bb69a09a3ae19fbe2905eb6 (patch)
tree5ee6945b4ba985633a3aa69cfe77adcf32331d04 /src/backend/catalog/index.c
parent1909835c28a144bf957254eea1f4a4dabafbbaee (diff)
Unbreak overflow test for attinhcount/coninhcount
Commit 90189eefc1e1 narrowed pg_attribute.attinhcount and pg_constraint.coninhcount from 32 to 16 bits, but kept other related structs with 32-bit wide fields: ColumnDef and CookedConstraint contain an int 'inhcount' field which is itself checked for overflow on increments, but there's no check that the values aren't above INT16_MAX before assigning to the catalog columns. This means that a creative user can get a inconsistent table definition and override some protections. Fix it by changing those other structs to also use int16. Also, modernize style by using pg_add_s16_overflow for overflow testing instead of checking for negative values. We also have Constraint.inhcount, which is here removed completely. This was added by commit b0e96f311985 and not removed by its revert at 6f8bb7c1e961. It is not needed by the upcoming not-null constraints patch. This is mostly academic, so we agreed not to backpatch to avoid ABI problems. Bump catversion because of the changes to parse nodes. Co-authored-by: Álvaro Herrera <[email protected]> Co-authored-by: 何建 (jian he) <[email protected]> Reviewed-by: Tom Lane <[email protected]> Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/backend/catalog/index.c')
-rw-r--r--src/backend/catalog/index.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 6084dfa97cb..12822d0b140 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -1900,7 +1900,7 @@ index_constraint_create(Relation heapRelation,
bool islocal;
bool noinherit;
bool is_without_overlaps;
- int inhcount;
+ int16 inhcount;
deferrable = (constr_flags & INDEX_CONSTR_CREATE_DEFERRABLE) != 0;
initdeferred = (constr_flags & INDEX_CONSTR_CREATE_INIT_DEFERRED) != 0;