Hi hackers.
I'm attaching a patch that add some new test cases for tab completion of psql.
This is my first patch that I'm sending here so let me know if I'm doing
something wrong.
--
Matheus Alcantara
From 6af6b972960f4e9017f1c311ee4b13a96d5f66a1 Mon Sep 17 00:00:00 2001
From: Matheus Alcantara <mths....@pm.me>
Date: Sat, 12 Feb 2022 16:45:55 -0300
Subject: [PATCH] psql: Add tests for tab completion
---
src/bin/psql/t/010_tab_completion.pl | 92 ++++++++++++++++++++++++++++
1 file changed, 92 insertions(+)
diff --git a/src/bin/psql/t/010_tab_completion.pl b/src/bin/psql/t/010_tab_completion.pl
index 005961f34d..f74ff96226 100644
--- a/src/bin/psql/t/010_tab_completion.pl
+++ b/src/bin/psql/t/010_tab_completion.pl
@@ -45,6 +45,7 @@ $node->safe_psql('postgres',
. "CREATE TABLE mytab246 (f1 int, f2 text);\n"
. "CREATE TABLE \"mixedName\" (f1 int, f2 text);\n"
. "CREATE TYPE enum1 AS ENUM ('foo', 'bar', 'baz', 'BLACK');\n"
+ . "CREATE INDEX idx_tab1_c1 ON tab1(c1);\n"
. "CREATE PUBLICATION some_publication;\n");
# Developers would not appreciate this test adding a bunch of junk to
@@ -382,6 +383,97 @@ check_completion(
clear_query();
+check_completion(
+ "CREATE OR REPLACE \t\t",
+ qr/AGGREGATE +LANGUAGE +RULE +TRIGGER +\r\nFUNCTION +PROCEDURE +TRANSFORM +VIEW/,
+ "check create or replace");
+
+clear_query();
+
+check_completion(
+ "ALTER FOREIGN \t\t",
+ qr/DATA WRAPPER +TABLE/ ,
+ "check alter foreign");
+
+clear_query();
+
+check_completion(
+ "ALTER INDEX \t\t",
+ qr/ALL IN TABLESPACE +information_schema. +tab1_pkey\r\nidx_tab1_c1/,
+ "check alter index");
+
+clear_query();
+
+check_completion(
+ "ALTER INDEX idx_tab1_c1 \t\t",
+ qr/ALTER COLUMN +NO DEPENDS ON EXTENSION +RESET\r\nATTACH PARTITION +OWNER TO +SET\r\nDEPENDS ON EXTENSION +RENAME TO/,
+ "check alter index <name>");
+
+clear_query();
+
+check_completion(
+ "ALTER INDEX idx_tab1_c1 ATTACH \t\t",
+ qr/PARTITION/,
+ "check alter index <name> attach");
+
+clear_query();
+
+check_completion(
+ "ALTER INDEX idx_tab1_c1 ATTACH PARTITION \t\t",
+ qr/idx_tab1_c1 +public. +\r\ninformation_schema. +tab1_pkey/,
+ "check alter index <name> ATTACH PARTITION");
+
+clear_query();
+
+check_completion(
+ "ALTER INDEX idx_tab1_c1 ALTER \t\t",
+ qr/COLUMN/,
+ "check alter index <name> alter");
+
+clear_query();
+
+check_completion(
+ "ALTER INDEX idx_tab1_c1 ALTER COLUMN \t\t",
+ qr/1 +SET +STATISTICS/,
+ "check alter index <name> alter column");
+
+clear_query();
+
+check_completion(
+ "ALTER INDEX idx_tab1_c1 ALTER COLUMN 1 SET \t\t",
+ qr/STATISTICS/,
+ "check alter index <name> alter column <column> set");
+
+clear_query();
+
+check_completion(
+ "ALTER INDEX idx_tab1_c1 SET \t\t",
+ qr/\( +TABLESPACE/,
+ "check alter index <name> set");
+
+clear_query();
+
+check_completion(
+ "ALTER INDEX idx_tab1_c1 RESET \t\t",
+ qr/\( +\a/,
+ "check alter index <name> reset");
+
+clear_query();
+
+check_completion(
+ "ALTER INDEX idx_tab1_c1 NO DEPENDS \t\t",
+ qr/ON EXTENSION/,
+ "check alter index <name> no depends");
+
+clear_query();
+
+check_completion(
+ "ALTER INDEX idx_tab1_c1 DEPENDS \t\t",
+ qr/ON EXTENSION/,
+ "check alter index <name> depends");
+
+clear_query();
+
# check VersionedQuery infrastructure
check_completion(
"DROP PUBLIC\t \t\t",
--
2.35.1