From 8bab2a943827db536299aaf7af98efdf4308a731 Mon Sep 17 00:00:00 2001
From: Baji Shaik <baji.pgdev@gmail.com>
Date: Sun, 4 Oct 2026 11:07:28 -0500
Subject: [PATCH] psql: Add tab completion for ALTER TABLE ALTER CONSTRAINT

After ALTER TABLE t ALTER CONSTRAINT c, psql now offers DEFERRABLE,
NOT DEFERRABLE, ENFORCED, NOT ENFORCED, INITIALLY DEFERRED, INITIALLY
IMMEDIATE, INHERIT, and NO INHERIT.  Previously, selecting the
constraint name was a dead end with no further suggestions.
---
 src/bin/psql/tab-complete.in.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c
index b3bfe050b18..0bfce35d8d9 100644
--- a/src/bin/psql/tab-complete.in.c
+++ b/src/bin/psql/tab-complete.in.c
@@ -2928,6 +2928,11 @@ match_previous_words(int pattern_id,
 		set_completion_reference(prev3_wd);
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_constraint_of_table);
 	}
+	/* ALTER TABLE <sth> ALTER CONSTRAINT <constraint> options */
+	else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "CONSTRAINT", MatchAny))
+		COMPLETE_WITH("DEFERRABLE", "NOT DEFERRABLE", "ENFORCED", "NOT ENFORCED",
+					  "INITIALLY DEFERRED", "INITIALLY IMMEDIATE",
+					  "INHERIT", "NO INHERIT");
 	/* ALTER TABLE <sth> VALIDATE CONSTRAINT <non-validated constraint> */
 	else if (Matches("ALTER", "TABLE", MatchAny, "VALIDATE", "CONSTRAINT"))
 	{
-- 
2.54.0 (Apple Git-157)

