From edc578a46e6b2face388e40d9edbc9c8dabac3d1 Mon Sep 17 00:00:00 2001 From: Sho Ito Date: Sun, 8 Nov 2026 16:10:36 -0500 Subject: [PATCH] psql: Test REPACK index completion after a column list 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 | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/bin/psql/t/010_tab_completion.pl b/src/bin/psql/t/010_tab_completion.pl index 1d2e5f5b..09f5bb00 100644 --- a/src/bin/psql/t/010_tab_completion.pl +++ b/src/bin/psql/t/010_tab_completion.pl @@ -422,6 +422,38 @@ check_completion( clear_line(); +# The table reference must skip the optional column list. repack_other is an +# unrelated table with a primary key too, so falling back to all indexes +# cannot uniquely complete the index name to tab1_pkey. +$node->safe_psql('postgres', 'CREATE TABLE repack_other (id int PRIMARY KEY)'); +check_completion( + "REPACK tab1 USING INDEX \t", + qr/REPACK tab1 USING INDEX tab1_pkey /, + "complete only the target table index after REPACK tab1"); + +clear_query(); + +check_completion( + "REPACK (ANALYZE) tab1 USING INDEX \t", + qr/REPACK \(ANALYZE\) tab1 USING INDEX tab1_pkey /, + "complete only the target table index after REPACK (ANALYZE) tab1"); + +clear_query(); + +check_completion( + "REPACK (ANALYZE) tab1 (c1) USING INDEX \t", + qr/REPACK \(ANALYZE\) tab1 \(c1\) USING INDEX tab1_pkey /, + "complete only the target table index after REPACK (ANALYZE) tab1 (c1)"); + +clear_query(); + +check_completion( + "REPACK (ANALYZE) tab1 (c1, c2) USING INDEX \t", + qr/REPACK \(ANALYZE\) tab1 \(c1, c2\) USING INDEX tab1_pkey /, + "complete only the target table index after REPACK (ANALYZE) tab1 (c1, c2)"); + +clear_query(); + # send psql an explicit \q to shut it down, else pty won't close properly $h->quit or die "psql returned $?";