From: Tom Lane Date: Tue, 26 May 2026 15:58:25 +0000 (-0400) Subject: Add stack depth check to QueueFKConstraintValidation(). X-Git-Tag: REL_19_BETA1~48 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=61ea5cc6a61ff9eb8b3d7b055e507a726e5856c7;p=thirdparty%2Fpostgresql.git Add stack depth check to QueueFKConstraintValidation(). QueueFKConstraintValidation() recurses through the partition hierarchy to queue child constraint validations and to mark child rows as validated. With a sufficiently deep partition tree, this can result in a stack-overflow crash. Defend against that as we do elsewhere. Bug: #19482 Reported-by: Alexander Lakhin Author: Ayush Tiwari Reviewed-by: Tom Lane Discussion: https://postgr.es/m/19482-4cc37cbf52d55235@postgresql.org Backpatch-through: 18 --- diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 1e0bacf85fc..a1845240a98 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -13281,6 +13281,9 @@ QueueFKConstraintValidation(List **wqueue, Relation conrel, Relation fkrel, HeapTuple copyTuple; Form_pg_constraint copy_con; + /* since this function recurses, it could be driven to stack overflow */ + check_stack_depth(); + con = (Form_pg_constraint) GETSTRUCT(contuple); Assert(con->contype == CONSTRAINT_FOREIGN); Assert(!con->convalidated);