|
66 | 66 | #include "commands/typecmds.h" |
67 | 67 | #include "commands/user.h" |
68 | 68 | #include "commands/vacuum.h" |
| 69 | +#include "common/int.h" |
69 | 70 | #include "executor/executor.h" |
70 | 71 | #include "foreign/fdwapi.h" |
71 | 72 | #include "foreign/foreign.h" |
@@ -3044,8 +3045,8 @@ MergeCheckConstraint(List *constraints, const char *name, Node *expr) |
3044 | 3045 | if (equal(expr, ccon->expr)) |
3045 | 3046 | { |
3046 | 3047 | /* OK to merge constraint with existing */ |
3047 | | - ccon->inhcount++; |
3048 | | - if (ccon->inhcount < 0) |
| 3048 | + if (pg_add_s16_overflow(ccon->inhcount, 1, |
| 3049 | + &ccon->inhcount)) |
3049 | 3050 | ereport(ERROR, |
3050 | 3051 | errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), |
3051 | 3052 | errmsg("too many inheritance parents")); |
@@ -3347,8 +3348,8 @@ MergeInheritedAttribute(List *inh_columns, |
3347 | 3348 | * Default and other constraints are handled by the caller. |
3348 | 3349 | */ |
3349 | 3350 |
|
3350 | | - prevdef->inhcount++; |
3351 | | - if (prevdef->inhcount < 0) |
| 3351 | + if (pg_add_s16_overflow(prevdef->inhcount, 1, |
| 3352 | + &prevdef->inhcount)) |
3352 | 3353 | ereport(ERROR, |
3353 | 3354 | errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), |
3354 | 3355 | errmsg("too many inheritance parents")); |
@@ -7089,8 +7090,8 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel, |
7089 | 7090 | get_collation_name(childatt->attcollation)))); |
7090 | 7091 |
|
7091 | 7092 | /* Bump the existing child att's inhcount */ |
7092 | | - childatt->attinhcount++; |
7093 | | - if (childatt->attinhcount < 0) |
| 7093 | + if (pg_add_s16_overflow(childatt->attinhcount, 1, |
| 7094 | + &childatt->attinhcount)) |
7094 | 7095 | ereport(ERROR, |
7095 | 7096 | errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), |
7096 | 7097 | errmsg("too many inheritance parents")); |
@@ -10170,7 +10171,7 @@ addFkRecurseReferenced(List **wqueue, Constraint *fkconstraint, Relation rel, |
10170 | 10171 | Oid constrOid; |
10171 | 10172 | char *conname; |
10172 | 10173 | bool conislocal; |
10173 | | - int coninhcount; |
| 10174 | + int16 coninhcount; |
10174 | 10175 | bool connoinherit; |
10175 | 10176 | Oid deleteTriggerOid, |
10176 | 10177 | updateTriggerOid; |
@@ -10549,9 +10550,9 @@ addFkRecurseReferencing(List **wqueue, Constraint *fkconstraint, Relation rel, |
10549 | 10550 | NULL, |
10550 | 10551 | NULL, |
10551 | 10552 | NULL, |
10552 | | - false, |
10553 | | - 1, |
10554 | | - false, |
| 10553 | + false, /* conIsLocal */ |
| 10554 | + 1, /* conInhCount */ |
| 10555 | + false, /* conNoInherit */ |
10555 | 10556 | with_period, /* conPeriod */ |
10556 | 10557 | false); |
10557 | 10558 |
|
@@ -11076,8 +11077,8 @@ CloneFkReferencing(List **wqueue, Relation parentRel, Relation partRel) |
11076 | 11077 | NULL, |
11077 | 11078 | NULL, |
11078 | 11079 | NULL, |
11079 | | - false, /* islocal */ |
11080 | | - 1, /* inhcount */ |
| 11080 | + false, /* conIsLocal */ |
| 11081 | + 1, /* conInhCount */ |
11081 | 11082 | false, /* conNoInherit */ |
11082 | 11083 | with_period, /* conPeriod */ |
11083 | 11084 | true); |
@@ -15944,8 +15945,8 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel, bool ispart |
15944 | 15945 | * OK, bump the child column's inheritance count. (If we fail |
15945 | 15946 | * later on, this change will just roll back.) |
15946 | 15947 | */ |
15947 | | - child_att->attinhcount++; |
15948 | | - if (child_att->attinhcount < 0) |
| 15948 | + if (pg_add_s16_overflow(child_att->attinhcount, 1, |
| 15949 | + &child_att->attinhcount)) |
15949 | 15950 | ereport(ERROR, |
15950 | 15951 | errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), |
15951 | 15952 | errmsg("too many inheritance parents")); |
@@ -16075,8 +16076,9 @@ MergeConstraintsIntoExisting(Relation child_rel, Relation parent_rel) |
16075 | 16076 | */ |
16076 | 16077 | child_copy = heap_copytuple(child_tuple); |
16077 | 16078 | child_con = (Form_pg_constraint) GETSTRUCT(child_copy); |
16078 | | - child_con->coninhcount++; |
16079 | | - if (child_con->coninhcount < 0) |
| 16079 | + |
| 16080 | + if (pg_add_s16_overflow(child_con->coninhcount, 1, |
| 16081 | + &child_con->coninhcount)) |
16080 | 16082 | ereport(ERROR, |
16081 | 16083 | errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), |
16082 | 16084 | errmsg("too many inheritance parents")); |
|
0 commit comments