From 512a61cc8d83b990e46f20be2bc60100ce43155e Mon Sep 17 00:00:00 2001
From: Sho Ito <i.sho.0628@gmail.com>
Date: Sun, 8 Nov 2026 16:10:40 -0500
Subject: [PATCH] psql: Test completion after REPACK USING

Extend the existing psql completion TAP suite, reusing its setup and helpers. Keep the regression cases in a separate patch so they can be applied independently of the implementation fix.
---
 src/bin/psql/t/010_tab_completion.pl | 36 ++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/src/bin/psql/t/010_tab_completion.pl b/src/bin/psql/t/010_tab_completion.pl
index 1d2e5f5b..f5310c63 100644
--- a/src/bin/psql/t/010_tab_completion.pl
+++ b/src/bin/psql/t/010_tab_completion.pl
@@ -422,6 +422,42 @@ check_completion(
 
 clear_line();
 
+# REPACK must recognise USING as a keyword, including after a column list.
+check_completion(
+	"REPACK USING \t",
+	qr/REPACK USING INDEX /,
+	"complete INDEX after REPACK USING");
+
+clear_query();
+
+check_completion(
+	"REPACK (VERBOSE) USING \t",
+	qr/REPACK \(VERBOSE\) USING INDEX /,
+	"complete INDEX after REPACK (VERBOSE) USING");
+
+clear_query();
+
+check_completion(
+	"REPACK tab1 USING \t",
+	qr/REPACK tab1 USING INDEX /,
+	"complete INDEX after REPACK tab1 USING");
+
+clear_query();
+
+check_completion(
+	"REPACK (ANALYZE) tab1 USING \t",
+	qr/REPACK \(ANALYZE\) tab1 USING INDEX /,
+	"complete INDEX after REPACK (ANALYZE) tab1 USING");
+
+clear_query();
+
+check_completion(
+	"REPACK (ANALYZE) tab1 (c1) USING \t",
+	qr/REPACK \(ANALYZE\) tab1 \(c1\) USING INDEX /,
+	"complete INDEX after REPACK (ANALYZE) tab1 (c1) USING");
+
+clear_query();
+
 # send psql an explicit \q to shut it down, else pty won't close properly
 $h->quit or die "psql returned $?";
 
