From 2bb8398a344872b02c7df27f61c41027f874068e Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@enterprisedb.com>
Date: Fri, 21 Sep 2018 20:16:19 +1200
Subject: [PATCH 2/2] Variadic COMPLETE_WITH(...) macros.

---
 src/bin/psql/tab-complete.c | 749 ++++++++++++++++--------------------
 1 file changed, 337 insertions(+), 412 deletions(-)

diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 21a4a807d9..b64928355d 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -173,7 +173,7 @@ static bool completion_case_sensitive;	/* completion is case sensitive */
  * 2) The results from a schema query you pass it.
  *	  We support both simple and versioned schema queries.
  * 3) The items from a null-pointer-terminated list (with or without
- *	  case-sensitive comparison; see also COMPLETE_WITH_LISTn, below).
+ *	  case-sensitive comparison; see also COMPLETE_WITH, below).
  * 4) A string constant.
  * 5) The list of attributes of the given table (possibly schema-qualified).
  * 6/ The list of arguments to the given function (possibly schema-qualified).
@@ -204,27 +204,37 @@ do { \
 	matches = completion_matches(text, complete_from_versioned_schema_query); \
 } while (0)
 
-#define COMPLETE_WITH_LIST_CS(list) \
+#define COMPLETE_WITH_LIST_X(cs, list) \
 do { \
-	completion_charpp = list; \
-	completion_case_sensitive = true; \
-	matches = completion_matches(text, complete_from_list); \
+	completion_case_sensitive = (cs); \
+	if (!(list)[1]) \
+	{ \
+		completion_charp = (list)[0]; \
+		matches = completion_matches(text, complete_from_const); \
+	} \
+	else \
+	{ \
+		completion_charpp = (list); \
+		matches = completion_matches(text, complete_from_list); \
+	} \
 } while (0)
 
-#define COMPLETE_WITH_LIST(list) \
+#define COMPLETE_WITH_LIST(list) COMPLETE_WITH_LIST_X(false, (list))
+#define COMPLETE_WITH_LIST_CS(list) COMPLETE_WITH_LIST_X(true, (list))
+
+#define COMPLETE_WITH(...) \
 do { \
-	completion_charpp = list; \
-	completion_case_sensitive = false; \
-	matches = completion_matches(text, complete_from_list); \
+	static const char *const list[] = { __VA_ARGS__, NULL }; \
+	COMPLETE_WITH_LIST(list); \
 } while (0)
 
-#define COMPLETE_WITH_CONST(string) \
+#define COMPLETE_WITH_CS(...) \
 do { \
-	completion_charp = string; \
-	completion_case_sensitive = false; \
-	matches = completion_matches(text, complete_from_const); \
+	static const char *const list[] = { __VA_ARGS__, NULL }; \
+	COMPLETE_WITH_LIST_CS(list); \
 } while (0)
 
+
 #define COMPLETE_WITH_ATTR(relation, addon) \
 do { \
 	char   *_completion_schema; \
@@ -300,91 +310,6 @@ do { \
 	matches = completion_matches(text, complete_from_query); \
 } while (0)
 
-/*
- * These macros simplify use of COMPLETE_WITH_LIST for short, fixed lists.
- * There is no COMPLETE_WITH_LIST1; use COMPLETE_WITH_CONST for that case.
- */
-#define COMPLETE_WITH_LIST2(s1, s2) \
-do { \
-	static const char *const list[] = { s1, s2, NULL }; \
-	COMPLETE_WITH_LIST(list); \
-} while (0)
-
-#define COMPLETE_WITH_LIST3(s1, s2, s3) \
-do { \
-	static const char *const list[] = { s1, s2, s3, NULL }; \
-	COMPLETE_WITH_LIST(list); \
-} while (0)
-
-#define COMPLETE_WITH_LIST4(s1, s2, s3, s4) \
-do { \
-	static const char *const list[] = { s1, s2, s3, s4, NULL }; \
-	COMPLETE_WITH_LIST(list); \
-} while (0)
-
-#define COMPLETE_WITH_LIST5(s1, s2, s3, s4, s5) \
-do { \
-	static const char *const list[] = { s1, s2, s3, s4, s5, NULL }; \
-	COMPLETE_WITH_LIST(list); \
-} while (0)
-
-#define COMPLETE_WITH_LIST6(s1, s2, s3, s4, s5, s6) \
-do { \
-	static const char *const list[] = { s1, s2, s3, s4, s5, s6, NULL }; \
-	COMPLETE_WITH_LIST(list); \
-} while (0)
-
-#define COMPLETE_WITH_LIST7(s1, s2, s3, s4, s5, s6, s7) \
-do { \
-	static const char *const list[] = { s1, s2, s3, s4, s5, s6, s7, NULL }; \
-	COMPLETE_WITH_LIST(list); \
-} while (0)
-
-#define COMPLETE_WITH_LIST8(s1, s2, s3, s4, s5, s6, s7, s8) \
-do { \
-	static const char *const list[] = { s1, s2, s3, s4, s5, s6, s7, s8, NULL }; \
-	COMPLETE_WITH_LIST(list); \
-} while (0)
-
-#define COMPLETE_WITH_LIST9(s1, s2, s3, s4, s5, s6, s7, s8, s9) \
-do { \
-	static const char *const list[] = { s1, s2, s3, s4, s5, s6, s7, s8, s9, NULL }; \
-	COMPLETE_WITH_LIST(list); \
-} while (0)
-
-#define COMPLETE_WITH_LIST10(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10) \
-do { \
-	static const char *const list[] = { s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, NULL }; \
-	COMPLETE_WITH_LIST(list); \
-} while (0)
-
-/*
- * Likewise for COMPLETE_WITH_LIST_CS.
- */
-#define COMPLETE_WITH_LIST_CS2(s1, s2) \
-do { \
-	static const char *const list[] = { s1, s2, NULL }; \
-	COMPLETE_WITH_LIST_CS(list); \
-} while (0)
-
-#define COMPLETE_WITH_LIST_CS3(s1, s2, s3) \
-do { \
-	static const char *const list[] = { s1, s2, s3, NULL }; \
-	COMPLETE_WITH_LIST_CS(list); \
-} while (0)
-
-#define COMPLETE_WITH_LIST_CS4(s1, s2, s3, s4) \
-do { \
-	static const char *const list[] = { s1, s2, s3, s4, NULL }; \
-	COMPLETE_WITH_LIST_CS(list); \
-} while (0)
-
-#define COMPLETE_WITH_LIST_CS5(s1, s2, s3, s4, s5) \
-do { \
-	static const char *const list[] = { s1, s2, s3, s4, s5, NULL }; \
-	COMPLETE_WITH_LIST_CS(list); \
-} while (0)
-
 /*
  * Assembly instructions for schema queries
  */
@@ -1490,51 +1415,51 @@ psql_completion(const char *text, int start, int end)
 		matches = completion_matches(text, alter_command_generator);
 	/* ALTER TABLE,INDEX,MATERIALIZED VIEW ALL IN TABLESPACE xxx */
 	else if (TailMatches("ALL", "IN", "TABLESPACE", MatchAny))
-		COMPLETE_WITH_LIST2("SET TABLESPACE", "OWNED BY");
+		COMPLETE_WITH("SET TABLESPACE", "OWNED BY");
 	/* ALTER TABLE,INDEX,MATERIALIZED VIEW ALL IN TABLESPACE xxx OWNED BY */
 	else if (TailMatches("ALL", "IN", "TABLESPACE", MatchAny, "OWNED", "BY"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_roles);
 	/* ALTER TABLE,INDEX,MATERIALIZED VIEW ALL IN TABLESPACE xxx OWNED BY xxx */
 	else if (TailMatches("ALL", "IN", "TABLESPACE", MatchAny, "OWNED", "BY", MatchAny))
-		COMPLETE_WITH_CONST("SET TABLESPACE");
+		COMPLETE_WITH("SET TABLESPACE");
 	/* ALTER AGGREGATE,FUNCTION,PROCEDURE,ROUTINE <name> */
 	else if (Matches("ALTER", "AGGREGATE|FUNCTION|PROCEDURE|ROUTINE", MatchAny))
-		COMPLETE_WITH_CONST("(");
+		COMPLETE_WITH("(");
 	/* ALTER AGGREGATE,FUNCTION,PROCEDURE,ROUTINE <name> (...) */
 	else if (Matches("ALTER", "AGGREGATE|FUNCTION|PROCEDURE|ROUTINE", MatchAny, MatchAny))
 	{
 		if (ends_with(prev_wd, ')'))
-			COMPLETE_WITH_LIST3("OWNER TO", "RENAME TO", "SET SCHEMA");
+			COMPLETE_WITH("OWNER TO", "RENAME TO", "SET SCHEMA");
 		else
 			COMPLETE_WITH_FUNCTION_ARG(prev2_wd);
 	}
 	/* ALTER PUBLICATION <name> */
 	else if (Matches("ALTER", "PUBLICATION", MatchAny))
-		COMPLETE_WITH_LIST5("ADD TABLE", "DROP TABLE", "OWNER TO", "RENAME TO", "SET");
+		COMPLETE_WITH("ADD TABLE", "DROP TABLE", "OWNER TO", "RENAME TO", "SET");
 	/* ALTER PUBLICATION <name> SET */
 	else if (Matches("ALTER", "PUBLICATION", MatchAny, "SET"))
-		COMPLETE_WITH_LIST2("(", "TABLE");
+		COMPLETE_WITH("(", "TABLE");
 	/* ALTER PUBLICATION <name> SET ( */
 	else if (HeadMatches("ALTER", "PUBLICATION", MatchAny) && TailMatches("SET", "("))
-		COMPLETE_WITH_CONST("publish");
+		COMPLETE_WITH("publish");
 	/* ALTER SUBSCRIPTION <name> */
 	else if (Matches("ALTER", "SUBSCRIPTION", MatchAny))
-		COMPLETE_WITH_LIST7("CONNECTION", "ENABLE", "DISABLE", "OWNER TO",
+		COMPLETE_WITH("CONNECTION", "ENABLE", "DISABLE", "OWNER TO",
 							"RENAME TO", "REFRESH PUBLICATION", "SET");
 	/* ALTER SUBSCRIPTION <name> REFRESH PUBLICATION */
 	else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) &&
 			 TailMatches("REFRESH", "PUBLICATION"))
-		COMPLETE_WITH_CONST("WITH (");
+		COMPLETE_WITH("WITH (");
 	/* ALTER SUBSCRIPTION <name> REFRESH PUBLICATION WITH ( */
 	else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) &&
 			 TailMatches("REFRESH", "PUBLICATION", "WITH", "("))
-		COMPLETE_WITH_CONST("copy_data");
+		COMPLETE_WITH("copy_data");
 	/* ALTER SUBSCRIPTION <name> SET */
 	else if (Matches("ALTER", "SUBSCRIPTION", MatchAny, "SET"))
-		COMPLETE_WITH_LIST2("(", "PUBLICATION");
+		COMPLETE_WITH("(", "PUBLICATION");
 	/* ALTER SUBSCRIPTION <name> SET ( */
 	else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches("SET", "("))
-		COMPLETE_WITH_LIST2("slot_name", "synchronous_commit");
+		COMPLETE_WITH("slot_name", "synchronous_commit");
 	/* ALTER SUBSCRIPTION <name> SET PUBLICATION */
 	else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches("SET", "PUBLICATION"))
 	{
@@ -1543,26 +1468,26 @@ psql_completion(const char *text, int start, int end)
 	/* ALTER SUBSCRIPTION <name> SET PUBLICATION <name> */
 	else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) &&
 			 TailMatches("SET", "PUBLICATION", MatchAny))
-		COMPLETE_WITH_CONST("WITH (");
+		COMPLETE_WITH("WITH (");
 	/* ALTER SUBSCRIPTION <name> SET PUBLICATION <name> WITH ( */
 	else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) &&
 			 TailMatches("SET", "PUBLICATION", MatchAny, "WITH", "("))
-		COMPLETE_WITH_LIST2("copy_data", "refresh");
+		COMPLETE_WITH("copy_data", "refresh");
 	/* ALTER SCHEMA <name> */
 	else if (Matches("ALTER", "SCHEMA", MatchAny))
-		COMPLETE_WITH_LIST2("OWNER TO", "RENAME TO");
+		COMPLETE_WITH("OWNER TO", "RENAME TO");
 
 	/* ALTER COLLATION <name> */
 	else if (Matches("ALTER", "COLLATION", MatchAny))
-		COMPLETE_WITH_LIST3("OWNER TO", "RENAME TO", "SET SCHEMA");
+		COMPLETE_WITH("OWNER TO", "RENAME TO", "SET SCHEMA");
 
 	/* ALTER CONVERSION <name> */
 	else if (Matches("ALTER", "CONVERSION", MatchAny))
-		COMPLETE_WITH_LIST3("OWNER TO", "RENAME TO", "SET SCHEMA");
+		COMPLETE_WITH("OWNER TO", "RENAME TO", "SET SCHEMA");
 
 	/* ALTER DATABASE <name> */
 	else if (Matches("ALTER", "DATABASE", MatchAny))
-		COMPLETE_WITH_LIST7("RESET", "SET", "OWNER TO", "RENAME TO",
+		COMPLETE_WITH("RESET", "SET", "OWNER TO", "RENAME TO",
 							"IS_TEMPLATE", "ALLOW_CONNECTIONS",
 							"CONNECTION LIMIT");
 
@@ -1576,15 +1501,15 @@ psql_completion(const char *text, int start, int end)
 
 	/* ALTER EVENT TRIGGER <name> */
 	else if (Matches("ALTER", "EVENT", "TRIGGER", MatchAny))
-		COMPLETE_WITH_LIST4("DISABLE", "ENABLE", "OWNER TO", "RENAME TO");
+		COMPLETE_WITH("DISABLE", "ENABLE", "OWNER TO", "RENAME TO");
 
 	/* ALTER EVENT TRIGGER <name> ENABLE */
 	else if (Matches("ALTER", "EVENT", "TRIGGER", MatchAny, "ENABLE"))
-		COMPLETE_WITH_LIST2("REPLICA", "ALWAYS");
+		COMPLETE_WITH("REPLICA", "ALWAYS");
 
 	/* ALTER EXTENSION <name> */
 	else if (Matches("ALTER", "EXTENSION", MatchAny))
-		COMPLETE_WITH_LIST4("ADD", "DROP", "UPDATE", "SET SCHEMA");
+		COMPLETE_WITH("ADD", "DROP", "UPDATE", "SET SCHEMA");
 
 	/* ALTER EXTENSION <name> UPDATE */
 	else if (Matches("ALTER", "EXTENSION", MatchAny, "UPDATE"))
@@ -1602,11 +1527,11 @@ psql_completion(const char *text, int start, int end)
 
 	/* ALTER FOREIGN */
 	else if (Matches("ALTER", "FOREIGN"))
-		COMPLETE_WITH_LIST2("DATA WRAPPER", "TABLE");
+		COMPLETE_WITH("DATA WRAPPER", "TABLE");
 
 	/* ALTER FOREIGN DATA WRAPPER <name> */
 	else if (Matches("ALTER", "FOREIGN", "DATA", "WRAPPER", MatchAny))
-		COMPLETE_WITH_LIST5("HANDLER", "VALIDATOR", "OPTIONS", "OWNER TO", "RENAME TO");
+		COMPLETE_WITH("HANDLER", "VALIDATOR", "OPTIONS", "OWNER TO", "RENAME TO");
 
 	/* ALTER FOREIGN TABLE <name> */
 	else if (Matches("ALTER", "FOREIGN", "TABLE", MatchAny))
@@ -1625,31 +1550,31 @@ psql_completion(const char *text, int start, int end)
 								   "UNION SELECT 'ALL IN TABLESPACE'");
 	/* ALTER INDEX <name> */
 	else if (Matches("ALTER", "INDEX", MatchAny))
-		COMPLETE_WITH_LIST6("ALTER COLUMN", "OWNER TO", "RENAME TO", "SET",
+		COMPLETE_WITH("ALTER COLUMN", "OWNER TO", "RENAME TO", "SET",
 							"RESET", "ATTACH PARTITION");
 	else if (Matches("ALTER", "INDEX", MatchAny, "ATTACH"))
-		COMPLETE_WITH_CONST("PARTITION");
+		COMPLETE_WITH("PARTITION");
 	else if (Matches("ALTER", "INDEX", MatchAny, "ATTACH", "PARTITION"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL);
 	/* ALTER INDEX <name> ALTER COLUMN <colnum> */
 	else if (Matches("ALTER", "INDEX", MatchAny, "ALTER", "COLUMN", MatchAny))
-		COMPLETE_WITH_CONST("SET STATISTICS");
+		COMPLETE_WITH("SET STATISTICS");
 	/* ALTER INDEX <name> SET */
 	else if (Matches("ALTER", "INDEX", MatchAny, "SET"))
-		COMPLETE_WITH_LIST2("(", "TABLESPACE");
+		COMPLETE_WITH("(", "TABLESPACE");
 	/* ALTER INDEX <name> RESET */
 	else if (Matches("ALTER", "INDEX", MatchAny, "RESET"))
-		COMPLETE_WITH_CONST("(");
+		COMPLETE_WITH("(");
 	/* ALTER INDEX <foo> SET|RESET ( */
 	else if (Matches("ALTER", "INDEX", MatchAny, "RESET", "("))
-		COMPLETE_WITH_LIST8("fillfactor", "recheck_on_update",
+		COMPLETE_WITH("fillfactor", "recheck_on_update",
 							"vacuum_cleanup_index_scale_factor",	/* BTREE */
 							"fastupdate", "gin_pending_list_limit", /* GIN */
 							"buffering",	/* GiST */
 							"pages_per_range", "autosummarize"	/* BRIN */
 			);
 	else if (Matches("ALTER", "INDEX", MatchAny, "SET", "("))
-		COMPLETE_WITH_LIST8("fillfactor =", "recheck_on_update =",
+		COMPLETE_WITH("fillfactor =", "recheck_on_update =",
 							"vacuum_cleanup_index_scale_factor =",	/* BTREE */
 							"fastupdate =", "gin_pending_list_limit =", /* GIN */
 							"buffering =",	/* GiST */
@@ -1658,11 +1583,11 @@ psql_completion(const char *text, int start, int end)
 
 	/* ALTER LANGUAGE <name> */
 	else if (Matches("ALTER", "LANGUAGE", MatchAny))
-		COMPLETE_WITH_LIST2("OWNER_TO", "RENAME TO");
+		COMPLETE_WITH("OWNER_TO", "RENAME TO");
 
 	/* ALTER LARGE OBJECT <oid> */
 	else if (Matches("ALTER", "LARGE", "OBJECT", MatchAny))
-		COMPLETE_WITH_CONST("OWNER TO");
+		COMPLETE_WITH("OWNER TO");
 
 	/* ALTER MATERIALIZED VIEW */
 	else if (Matches("ALTER", "MATERIALIZED", "VIEW"))
@@ -1701,39 +1626,39 @@ psql_completion(const char *text, int start, int end)
 
 	/* ALTER DEFAULT PRIVILEGES */
 	else if (Matches("ALTER", "DEFAULT", "PRIVILEGES"))
-		COMPLETE_WITH_LIST2("FOR ROLE", "IN SCHEMA");
+		COMPLETE_WITH("FOR ROLE", "IN SCHEMA");
 	/* ALTER DEFAULT PRIVILEGES FOR */
 	else if (Matches("ALTER", "DEFAULT", "PRIVILEGES", "FOR"))
-		COMPLETE_WITH_CONST("ROLE");
+		COMPLETE_WITH("ROLE");
 	/* ALTER DEFAULT PRIVILEGES IN */
 	else if (Matches("ALTER", "DEFAULT", "PRIVILEGES", "IN"))
-		COMPLETE_WITH_CONST("SCHEMA");
+		COMPLETE_WITH("SCHEMA");
 	/* ALTER DEFAULT PRIVILEGES FOR ROLE|USER ... */
 	else if (Matches("ALTER", "DEFAULT", "PRIVILEGES", "FOR", "ROLE|USER",
 					  MatchAny))
-		COMPLETE_WITH_LIST3("GRANT", "REVOKE", "IN SCHEMA");
+		COMPLETE_WITH("GRANT", "REVOKE", "IN SCHEMA");
 	/* ALTER DEFAULT PRIVILEGES IN SCHEMA ... */
 	else if (Matches("ALTER", "DEFAULT", "PRIVILEGES", "IN", "SCHEMA",
 					  MatchAny))
-		COMPLETE_WITH_LIST3("GRANT", "REVOKE", "FOR ROLE");
+		COMPLETE_WITH("GRANT", "REVOKE", "FOR ROLE");
 	/* ALTER DEFAULT PRIVILEGES IN SCHEMA ... FOR */
 	else if (Matches("ALTER", "DEFAULT", "PRIVILEGES", "IN", "SCHEMA",
 					  MatchAny, "FOR"))
-		COMPLETE_WITH_CONST("ROLE");
+		COMPLETE_WITH("ROLE");
 	/* ALTER DEFAULT PRIVILEGES FOR ROLE|USER ... IN SCHEMA ... */
 	/* ALTER DEFAULT PRIVILEGES IN SCHEMA ... FOR ROLE|USER ... */
 	else if (Matches("ALTER", "DEFAULT", "PRIVILEGES", "FOR", "ROLE|USER",
 					  MatchAny, "IN", "SCHEMA", MatchAny) ||
 			 Matches("ALTER", "DEFAULT", "PRIVILEGES", "IN", "SCHEMA",
 					  MatchAny, "FOR", "ROLE|USER", MatchAny))
-		COMPLETE_WITH_LIST2("GRANT", "REVOKE");
+		COMPLETE_WITH("GRANT", "REVOKE");
 	/* ALTER DOMAIN <name> */
 	else if (Matches("ALTER", "DOMAIN", MatchAny))
-		COMPLETE_WITH_LIST6("ADD", "DROP", "OWNER TO", "RENAME", "SET",
+		COMPLETE_WITH("ADD", "DROP", "OWNER TO", "RENAME", "SET",
 							"VALIDATE CONSTRAINT");
 	/* ALTER DOMAIN <sth> DROP */
 	else if (Matches("ALTER", "DOMAIN", MatchAny, "DROP"))
-		COMPLETE_WITH_LIST3("CONSTRAINT", "DEFAULT", "NOT NULL");
+		COMPLETE_WITH("CONSTRAINT", "DEFAULT", "NOT NULL");
 	/* ALTER DOMAIN <sth> DROP|RENAME|VALIDATE CONSTRAINT */
 	else if (Matches("ALTER", "DOMAIN", MatchAny, "DROP|RENAME|VALIDATE", "CONSTRAINT"))
 	{
@@ -1742,14 +1667,14 @@ psql_completion(const char *text, int start, int end)
 	}
 	/* ALTER DOMAIN <sth> RENAME */
 	else if (Matches("ALTER", "DOMAIN", MatchAny, "RENAME"))
-		COMPLETE_WITH_LIST2("CONSTRAINT", "TO");
+		COMPLETE_WITH("CONSTRAINT", "TO");
 	/* ALTER DOMAIN <sth> RENAME CONSTRAINT <sth> */
 	else if (Matches("ALTER", "DOMAIN", MatchAny, "RENAME", "CONSTRAINT", MatchAny))
-		COMPLETE_WITH_CONST("TO");
+		COMPLETE_WITH("TO");
 
 	/* ALTER DOMAIN <sth> SET */
 	else if (Matches("ALTER", "DOMAIN", MatchAny, "SET"))
-		COMPLETE_WITH_LIST3("DEFAULT", "NOT NULL", "SCHEMA");
+		COMPLETE_WITH("DEFAULT", "NOT NULL", "SCHEMA");
 	/* ALTER SEQUENCE <name> */
 	else if (Matches("ALTER", "SEQUENCE", MatchAny))
 	{
@@ -1761,27 +1686,27 @@ psql_completion(const char *text, int start, int end)
 	}
 	/* ALTER SEQUENCE <name> NO */
 	else if (Matches("ALTER", "SEQUENCE", MatchAny, "NO"))
-		COMPLETE_WITH_LIST3("MINVALUE", "MAXVALUE", "CYCLE");
+		COMPLETE_WITH("MINVALUE", "MAXVALUE", "CYCLE");
 	/* ALTER SERVER <name> */
 	else if (Matches("ALTER", "SERVER", MatchAny))
-		COMPLETE_WITH_LIST4("VERSION", "OPTIONS", "OWNER TO", "RENAME TO");
+		COMPLETE_WITH("VERSION", "OPTIONS", "OWNER TO", "RENAME TO");
 	/* ALTER SERVER <name> VERSION <version> */
 	else if (Matches("ALTER", "SERVER", MatchAny, "VERSION", MatchAny))
-		COMPLETE_WITH_CONST("OPTIONS");
+		COMPLETE_WITH("OPTIONS");
 	/* ALTER SYSTEM SET, RESET, RESET ALL */
 	else if (Matches("ALTER", "SYSTEM"))
-		COMPLETE_WITH_LIST2("SET", "RESET");
+		COMPLETE_WITH("SET", "RESET");
 	else if (Matches("ALTER", "SYSTEM", "SET|RESET"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_alter_system_set_vars);
 	else if (Matches("ALTER", "SYSTEM", "SET", MatchAny))
-		COMPLETE_WITH_CONST("TO");
+		COMPLETE_WITH("TO");
 	/* ALTER VIEW <name> */
 	else if (Matches("ALTER", "VIEW", MatchAny))
-		COMPLETE_WITH_LIST4("ALTER COLUMN", "OWNER TO", "RENAME TO",
+		COMPLETE_WITH("ALTER COLUMN", "OWNER TO", "RENAME TO",
 							"SET SCHEMA");
 	/* ALTER MATERIALIZED VIEW <name> */
 	else if (Matches("ALTER", "MATERIALIZED", "VIEW", MatchAny))
-		COMPLETE_WITH_LIST4("ALTER COLUMN", "OWNER TO", "RENAME TO",
+		COMPLETE_WITH("ALTER COLUMN", "OWNER TO", "RENAME TO",
 							"SET SCHEMA");
 
 	/* ALTER POLICY <name> */
@@ -1789,7 +1714,7 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_QUERY(Query_for_list_of_policies);
 	/* ALTER POLICY <name> ON */
 	else if (Matches("ALTER", "POLICY", MatchAny))
-		COMPLETE_WITH_CONST("ON");
+		COMPLETE_WITH("ON");
 	/* ALTER POLICY <name> ON <table> */
 	else if (Matches("ALTER", "POLICY", MatchAny, "ON"))
 	{
@@ -1798,20 +1723,20 @@ psql_completion(const char *text, int start, int end)
 	}
 	/* ALTER POLICY <name> ON <table> - show options */
 	else if (Matches("ALTER", "POLICY", MatchAny, "ON", MatchAny))
-		COMPLETE_WITH_LIST4("RENAME TO", "TO", "USING (", "WITH CHECK (");
+		COMPLETE_WITH("RENAME TO", "TO", "USING (", "WITH CHECK (");
 	/* ALTER POLICY <name> ON <table> TO <role> */
 	else if (Matches("ALTER", "POLICY", MatchAny, "ON", MatchAny, "TO"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_grant_roles);
 	/* ALTER POLICY <name> ON <table> USING ( */
 	else if (Matches("ALTER", "POLICY", MatchAny, "ON", MatchAny, "USING"))
-		COMPLETE_WITH_CONST("(");
+		COMPLETE_WITH("(");
 	/* ALTER POLICY <name> ON <table> WITH CHECK ( */
 	else if (Matches("ALTER", "POLICY", MatchAny, "ON", MatchAny, "WITH", "CHECK"))
-		COMPLETE_WITH_CONST("(");
+		COMPLETE_WITH("(");
 
 	/* ALTER RULE <name>, add ON */
 	else if (Matches("ALTER", "RULE", MatchAny))
-		COMPLETE_WITH_CONST("ON");
+		COMPLETE_WITH("ON");
 
 	/* If we have ALTER RULE <name> ON, then add the correct tablename */
 	else if (Matches("ALTER", "RULE", MatchAny, "ON"))
@@ -1822,15 +1747,15 @@ psql_completion(const char *text, int start, int end)
 
 	/* ALTER RULE <name> ON <name> */
 	else if (Matches("ALTER", "RULE", MatchAny, "ON", MatchAny))
-		COMPLETE_WITH_CONST("RENAME TO");
+		COMPLETE_WITH("RENAME TO");
 
 	/* ALTER STATISTICS <name> */
 	else if (Matches("ALTER", "STATISTICS", MatchAny))
-		COMPLETE_WITH_LIST3("OWNER TO", "RENAME TO", "SET SCHEMA");
+		COMPLETE_WITH("OWNER TO", "RENAME TO", "SET SCHEMA");
 
 	/* ALTER TRIGGER <name>, add ON */
 	else if (Matches("ALTER", "TRIGGER", MatchAny))
-		COMPLETE_WITH_CONST("ON");
+		COMPLETE_WITH("ON");
 
 	else if (Matches("ALTER", "TRIGGER", MatchAny, MatchAny))
 	{
@@ -1846,7 +1771,7 @@ psql_completion(const char *text, int start, int end)
 
 	/* ALTER TRIGGER <name> ON <name> */
 	else if (Matches("ALTER", "TRIGGER", MatchAny, "ON", MatchAny))
-		COMPLETE_WITH_CONST("RENAME TO");
+		COMPLETE_WITH("RENAME TO");
 
 	/*
 	 * If we detect ALTER TABLE <name>, suggest sub commands
@@ -1863,10 +1788,10 @@ psql_completion(const char *text, int start, int end)
 	}
 	/* ALTER TABLE xxx ENABLE */
 	else if (Matches("ALTER", "TABLE", MatchAny, "ENABLE"))
-		COMPLETE_WITH_LIST5("ALWAYS", "REPLICA", "ROW LEVEL SECURITY", "RULE",
+		COMPLETE_WITH("ALWAYS", "REPLICA", "ROW LEVEL SECURITY", "RULE",
 							"TRIGGER");
 	else if (Matches("ALTER", "TABLE", MatchAny, "ENABLE", "REPLICA|ALWAYS"))
-		COMPLETE_WITH_LIST2("RULE", "TRIGGER");
+		COMPLETE_WITH("RULE", "TRIGGER");
 	else if (Matches("ALTER", "TABLE", MatchAny, "ENABLE", "RULE"))
 	{
 		completion_info_charp = prev3_wd;
@@ -1895,7 +1820,7 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, "");
 	/* ALTER TABLE xxx DISABLE */
 	else if (Matches("ALTER", "TABLE", MatchAny, "DISABLE"))
-		COMPLETE_WITH_LIST3("ROW LEVEL SECURITY", "RULE", "TRIGGER");
+		COMPLETE_WITH("ROW LEVEL SECURITY", "RULE", "TRIGGER");
 	else if (Matches("ALTER", "TABLE", MatchAny, "DISABLE", "RULE"))
 	{
 		completion_info_charp = prev3_wd;
@@ -1919,15 +1844,15 @@ psql_completion(const char *text, int start, int end)
 
 	/* ALTER TABLE xxx RENAME yyy */
 	else if (Matches("ALTER", "TABLE", MatchAny, "RENAME", MatchAnyExcept("CONSTRAINT|TO")))
-		COMPLETE_WITH_CONST("TO");
+		COMPLETE_WITH("TO");
 
 	/* ALTER TABLE xxx RENAME COLUMN/CONSTRAINT yyy */
 	else if (Matches("ALTER", "TABLE", MatchAny, "RENAME", "COLUMN|CONSTRAINT", MatchAnyExcept("TO")))
-		COMPLETE_WITH_CONST("TO");
+		COMPLETE_WITH("TO");
 
 	/* If we have ALTER TABLE <sth> DROP, provide COLUMN or CONSTRAINT */
 	else if (Matches("ALTER", "TABLE", MatchAny, "DROP"))
-		COMPLETE_WITH_LIST2("COLUMN", "CONSTRAINT");
+		COMPLETE_WITH("COLUMN", "CONSTRAINT");
 	/* If we have ALTER TABLE <sth> DROP COLUMN, provide list of columns */
 	else if (Matches("ALTER", "TABLE", MatchAny, "DROP", "COLUMN"))
 		COMPLETE_WITH_ATTR(prev3_wd, "");
@@ -1944,25 +1869,25 @@ psql_completion(const char *text, int start, int end)
 	/* ALTER TABLE ALTER [COLUMN] <foo> */
 	else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny) ||
 			 Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny))
-		COMPLETE_WITH_LIST6("TYPE", "SET", "RESET", "RESTART", "ADD", "DROP");
+		COMPLETE_WITH("TYPE", "SET", "RESET", "RESTART", "ADD", "DROP");
 	/* ALTER TABLE ALTER [COLUMN] <foo> SET */
 	else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET") ||
 			 Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET"))
-		COMPLETE_WITH_LIST5("(", "DEFAULT", "NOT NULL", "STATISTICS", "STORAGE");
+		COMPLETE_WITH("(", "DEFAULT", "NOT NULL", "STATISTICS", "STORAGE");
 	/* ALTER TABLE ALTER [COLUMN] <foo> SET ( */
 	else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET", "(") ||
 			 Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET", "("))
-		COMPLETE_WITH_LIST2("n_distinct", "n_distinct_inherited");
+		COMPLETE_WITH("n_distinct", "n_distinct_inherited");
 	/* ALTER TABLE ALTER [COLUMN] <foo> SET STORAGE */
 	else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET", "STORAGE") ||
 			 Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET", "STORAGE"))
-		COMPLETE_WITH_LIST4("PLAIN", "EXTERNAL", "EXTENDED", "MAIN");
+		COMPLETE_WITH("PLAIN", "EXTERNAL", "EXTENDED", "MAIN");
 	/* ALTER TABLE ALTER [COLUMN] <foo> DROP */
 	else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "DROP") ||
 			 Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "DROP"))
-		COMPLETE_WITH_LIST3("DEFAULT", "IDENTITY", "NOT NULL");
+		COMPLETE_WITH("DEFAULT", "IDENTITY", "NOT NULL");
 	else if (Matches("ALTER", "TABLE", MatchAny, "CLUSTER"))
-		COMPLETE_WITH_CONST("ON");
+		COMPLETE_WITH("ON");
 	else if (Matches("ALTER", "TABLE", MatchAny, "CLUSTER", "ON"))
 	{
 		completion_info_charp = prev3_wd;
@@ -1970,7 +1895,7 @@ psql_completion(const char *text, int start, int end)
 	}
 	/* If we have ALTER TABLE <sth> SET, provide list of attributes and '(' */
 	else if (Matches("ALTER", "TABLE", MatchAny, "SET"))
-		COMPLETE_WITH_LIST7("(", "LOGGED", "SCHEMA", "TABLESPACE", "UNLOGGED",
+		COMPLETE_WITH("(", "LOGGED", "SCHEMA", "TABLESPACE", "UNLOGGED",
 							"WITH", "WITHOUT");
 
 	/*
@@ -1981,13 +1906,13 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_QUERY(Query_for_list_of_tablespaces);
 	/* If we have ALTER TABLE <sth> SET WITH provide OIDS */
 	else if (Matches("ALTER", "TABLE", MatchAny, "SET", "WITH"))
-		COMPLETE_WITH_CONST("OIDS");
+		COMPLETE_WITH("OIDS");
 	/* If we have ALTER TABLE <sth> SET WITHOUT provide CLUSTER or OIDS */
 	else if (Matches("ALTER", "TABLE", MatchAny, "SET", "WITHOUT"))
-		COMPLETE_WITH_LIST2("CLUSTER", "OIDS");
+		COMPLETE_WITH("CLUSTER", "OIDS");
 	/* ALTER TABLE <foo> RESET */
 	else if (Matches("ALTER", "TABLE", MatchAny, "RESET"))
-		COMPLETE_WITH_CONST("(");
+		COMPLETE_WITH("(");
 	/* ALTER TABLE <foo> SET|RESET ( */
 	else if (Matches("ALTER", "TABLE", MatchAny, "SET|RESET", "("))
 	{
@@ -2034,11 +1959,11 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_QUERY(Query_for_index_of_table);
 	}
 	else if (Matches("ALTER", "TABLE", MatchAny, "REPLICA", "IDENTITY", "USING"))
-		COMPLETE_WITH_CONST("INDEX");
+		COMPLETE_WITH("INDEX");
 	else if (Matches("ALTER", "TABLE", MatchAny, "REPLICA", "IDENTITY"))
-		COMPLETE_WITH_LIST4("FULL", "NOTHING", "DEFAULT", "USING");
+		COMPLETE_WITH("FULL", "NOTHING", "DEFAULT", "USING");
 	else if (Matches("ALTER", "TABLE", MatchAny, "REPLICA"))
-		COMPLETE_WITH_CONST("IDENTITY");
+		COMPLETE_WITH("IDENTITY");
 
 	/*
 	 * If we have ALTER TABLE <foo> ATTACH PARTITION, provide a list of
@@ -2048,9 +1973,9 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, "");
 	/* Limited completion support for partition bound specification */
 	else if (TailMatches("ATTACH", "PARTITION", MatchAny))
-		COMPLETE_WITH_LIST2("FOR VALUES", "DEFAULT");
+		COMPLETE_WITH("FOR VALUES", "DEFAULT");
 	else if (TailMatches("FOR", "VALUES"))
-		COMPLETE_WITH_LIST3("FROM (", "IN (", "WITH (");
+		COMPLETE_WITH("FROM (", "IN (", "WITH (");
 
 	/*
 	 * If we have ALTER TABLE <foo> DETACH PARTITION, provide a list of
@@ -2064,41 +1989,41 @@ psql_completion(const char *text, int start, int end)
 
 	/* ALTER TABLESPACE <foo> with RENAME TO, OWNER TO, SET, RESET */
 	else if (Matches("ALTER", "TABLESPACE", MatchAny))
-		COMPLETE_WITH_LIST4("RENAME TO", "OWNER TO", "SET", "RESET");
+		COMPLETE_WITH("RENAME TO", "OWNER TO", "SET", "RESET");
 	/* ALTER TABLESPACE <foo> SET|RESET */
 	else if (Matches("ALTER", "TABLESPACE", MatchAny, "SET|RESET"))
-		COMPLETE_WITH_CONST("(");
+		COMPLETE_WITH("(");
 	/* ALTER TABLESPACE <foo> SET|RESET ( */
 	else if (Matches("ALTER", "TABLESPACE", MatchAny, "SET|RESET", "("))
-		COMPLETE_WITH_LIST3("seq_page_cost", "random_page_cost",
+		COMPLETE_WITH("seq_page_cost", "random_page_cost",
 							"effective_io_concurrency");
 
 	/* ALTER TEXT SEARCH */
 	else if (Matches("ALTER", "TEXT", "SEARCH"))
-		COMPLETE_WITH_LIST4("CONFIGURATION", "DICTIONARY", "PARSER", "TEMPLATE");
+		COMPLETE_WITH("CONFIGURATION", "DICTIONARY", "PARSER", "TEMPLATE");
 	else if (Matches("ALTER", "TEXT", "SEARCH", "TEMPLATE|PARSER", MatchAny))
-		COMPLETE_WITH_LIST2("RENAME TO", "SET SCHEMA");
+		COMPLETE_WITH("RENAME TO", "SET SCHEMA");
 	else if (Matches("ALTER", "TEXT", "SEARCH", "DICTIONARY", MatchAny))
-		COMPLETE_WITH_LIST3("OWNER TO", "RENAME TO", "SET SCHEMA");
+		COMPLETE_WITH("OWNER TO", "RENAME TO", "SET SCHEMA");
 	else if (Matches("ALTER", "TEXT", "SEARCH", "CONFIGURATION", MatchAny))
-		COMPLETE_WITH_LIST6("ADD MAPPING FOR", "ALTER MAPPING",
+		COMPLETE_WITH("ADD MAPPING FOR", "ALTER MAPPING",
 							"DROP MAPPING FOR",
 							"OWNER TO", "RENAME TO", "SET SCHEMA");
 
 	/* complete ALTER TYPE <foo> with actions */
 	else if (Matches("ALTER", "TYPE", MatchAny))
-		COMPLETE_WITH_LIST7("ADD ATTRIBUTE", "ADD VALUE", "ALTER ATTRIBUTE",
+		COMPLETE_WITH("ADD ATTRIBUTE", "ADD VALUE", "ALTER ATTRIBUTE",
 							"DROP ATTRIBUTE",
 							"OWNER TO", "RENAME", "SET SCHEMA");
 	/* complete ALTER TYPE <foo> ADD with actions */
 	else if (Matches("ALTER", "TYPE", MatchAny, "ADD"))
-		COMPLETE_WITH_LIST2("ATTRIBUTE", "VALUE");
+		COMPLETE_WITH("ATTRIBUTE", "VALUE");
 	/* ALTER TYPE <foo> RENAME	*/
 	else if (Matches("ALTER", "TYPE", MatchAny, "RENAME"))
-		COMPLETE_WITH_LIST3("ATTRIBUTE", "TO", "VALUE");
+		COMPLETE_WITH("ATTRIBUTE", "TO", "VALUE");
 	/* ALTER TYPE xxx RENAME (ATTRIBUTE|VALUE) yyy */
 	else if (Matches("ALTER", "TYPE", MatchAny, "RENAME", "ATTRIBUTE|VALUE", MatchAny))
-		COMPLETE_WITH_CONST("TO");
+		COMPLETE_WITH("TO");
 
 	/*
 	 * If we have ALTER TYPE <sth> ALTER/DROP/RENAME ATTRIBUTE, provide list
@@ -2108,13 +2033,13 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_ATTR(prev3_wd, "");
 	/* ALTER TYPE ALTER ATTRIBUTE <foo> */
 	else if (Matches("ALTER", "TYPE", MatchAny, "ALTER", "ATTRIBUTE", MatchAny))
-		COMPLETE_WITH_CONST("TYPE");
+		COMPLETE_WITH("TYPE");
 	/* complete ALTER GROUP <foo> */
 	else if (Matches("ALTER", "GROUP", MatchAny))
-		COMPLETE_WITH_LIST3("ADD USER", "DROP USER", "RENAME TO");
+		COMPLETE_WITH("ADD USER", "DROP USER", "RENAME TO");
 	/* complete ALTER GROUP <foo> ADD|DROP with USER */
 	else if (Matches("ALTER", "GROUP", MatchAny, "ADD|DROP"))
-		COMPLETE_WITH_CONST("USER");
+		COMPLETE_WITH("USER");
 	/* complete ALTER GROUP <foo> ADD|DROP USER with a user name */
 	else if (Matches("ALTER", "GROUP", MatchAny, "ADD|DROP", "USER"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_roles);
@@ -2127,24 +2052,24 @@ psql_completion(const char *text, int start, int end)
 
 /* BEGIN */
 	else if (Matches("BEGIN"))
-		COMPLETE_WITH_LIST6("WORK", "TRANSACTION", "ISOLATION LEVEL", "READ", "DEFERRABLE", "NOT DEFERRABLE");
+		COMPLETE_WITH("WORK", "TRANSACTION", "ISOLATION LEVEL", "READ", "DEFERRABLE", "NOT DEFERRABLE");
 /* END, ABORT */
 	else if (Matches("END|ABORT"))
-		COMPLETE_WITH_LIST2("WORK", "TRANSACTION");
+		COMPLETE_WITH("WORK", "TRANSACTION");
 /* COMMIT */
 	else if (Matches("COMMIT"))
-		COMPLETE_WITH_LIST3("WORK", "TRANSACTION", "PREPARED");
+		COMPLETE_WITH("WORK", "TRANSACTION", "PREPARED");
 /* RELEASE SAVEPOINT */
 	else if (Matches("RELEASE"))
-		COMPLETE_WITH_CONST("SAVEPOINT");
+		COMPLETE_WITH("SAVEPOINT");
 /* ROLLBACK */
 	else if (Matches("ROLLBACK"))
-		COMPLETE_WITH_LIST4("WORK", "TRANSACTION", "TO SAVEPOINT", "PREPARED");
+		COMPLETE_WITH("WORK", "TRANSACTION", "TO SAVEPOINT", "PREPARED");
 /* CALL */
 	else if (Matches("CALL"))
 		COMPLETE_WITH_VERSIONED_SCHEMA_QUERY(Query_for_list_of_procedures, NULL);
 	else if (Matches("CALL", MatchAny))
-		COMPLETE_WITH_CONST("(");
+		COMPLETE_WITH("(");
 /* CLUSTER */
 	else if (Matches("CLUSTER"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tm, "UNION SELECT 'VERBOSE'");
@@ -2152,10 +2077,10 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tm, NULL);
 	/* If we have CLUSTER <sth>, then add "USING" */
 	else if (Matches("CLUSTER", MatchAnyExcept("VERBOSE|ON")))
-		COMPLETE_WITH_CONST("USING");
+		COMPLETE_WITH("USING");
 	/* If we have CLUSTER VERBOSE <sth>, then add "USING" */
 	else if (Matches("CLUSTER", "VERBOSE", MatchAny))
-		COMPLETE_WITH_CONST("USING");
+		COMPLETE_WITH("USING");
 	/* If we have CLUSTER <sth> USING, then add the index as well */
 	else if (Matches("CLUSTER", MatchAny, "USING") ||
 			 Matches("CLUSTER", "VERBOSE", MatchAny, "USING"))
@@ -2166,7 +2091,7 @@ psql_completion(const char *text, int start, int end)
 
 /* COMMENT */
 	else if (Matches("COMMENT"))
-		COMPLETE_WITH_CONST("ON");
+		COMPLETE_WITH("ON");
 	else if (Matches("COMMENT", "ON"))
 	{
 		static const char *const list_COMMENT[] =
@@ -2185,13 +2110,13 @@ psql_completion(const char *text, int start, int end)
 	else if (Matches("COMMENT", "ON", "ACCESS", "METHOD"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_access_methods);
 	else if (Matches("COMMENT", "ON", "FOREIGN"))
-		COMPLETE_WITH_LIST2("DATA WRAPPER", "TABLE");
+		COMPLETE_WITH("DATA WRAPPER", "TABLE");
 	else if (Matches("COMMENT", "ON", "TEXT", "SEARCH"))
-		COMPLETE_WITH_LIST4("CONFIGURATION", "DICTIONARY", "PARSER", "TEMPLATE");
+		COMPLETE_WITH("CONFIGURATION", "DICTIONARY", "PARSER", "TEMPLATE");
 	else if (Matches("COMMENT", "ON", "CONSTRAINT"))
 		COMPLETE_WITH_QUERY(Query_for_all_table_constraints);
 	else if (Matches("COMMENT", "ON", "CONSTRAINT", MatchAny))
-		COMPLETE_WITH_CONST("ON");
+		COMPLETE_WITH("ON");
 	else if (Matches("COMMENT", "ON", "CONSTRAINT", MatchAny, "ON"))
 	{
 		completion_info_charp = prev2_wd;
@@ -2204,7 +2129,7 @@ psql_completion(const char *text, int start, int end)
 	else if (Matches("COMMENT", "ON", MatchAny, MatchAnyExcept("IS")) ||
 			 Matches("COMMENT", "ON", MatchAny, MatchAny, MatchAnyExcept("IS")) ||
 			 Matches("COMMENT", "ON", MatchAny, MatchAny, MatchAny, MatchAnyExcept("IS")))
-		COMPLETE_WITH_CONST("IS");
+		COMPLETE_WITH("IS");
 
 /* COPY */
 
@@ -2220,11 +2145,11 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
 	/* If we have COPY (, complete it with legal commands */
 	else if (Matches("COPY|\\copy", "("))
-		COMPLETE_WITH_LIST7("SELECT", "TABLE", "VALUES", "INSERT", "UPDATE", "DELETE", "WITH");
+		COMPLETE_WITH("SELECT", "TABLE", "VALUES", "INSERT", "UPDATE", "DELETE", "WITH");
 	/* If we have COPY [BINARY] <sth>, complete it with "TO" or "FROM" */
 	else if (Matches("COPY|\\copy", MatchAny) ||
 			 Matches("COPY", "BINARY", MatchAny))
-		COMPLETE_WITH_LIST2("FROM", "TO");
+		COMPLETE_WITH("FROM", "TO");
 	/* If we have COPY [BINARY] <sth> FROM|TO, complete with filename */
 	else if (Matches("COPY|\\copy", MatchAny, "FROM|TO") ||
 			 Matches("COPY", "BINARY", MatchAny, "FROM|TO"))
@@ -2236,29 +2161,29 @@ psql_completion(const char *text, int start, int end)
 	/* Handle COPY [BINARY] <sth> FROM|TO filename */
 	else if (Matches("COPY|\\copy", MatchAny, "FROM|TO", MatchAny) ||
 			 Matches("COPY", "BINARY", MatchAny, "FROM|TO", MatchAny))
-		COMPLETE_WITH_LIST6("BINARY", "OIDS", "DELIMITER", "NULL", "CSV",
+		COMPLETE_WITH("BINARY", "OIDS", "DELIMITER", "NULL", "CSV",
 							"ENCODING");
 
 	/* Handle COPY [BINARY] <sth> FROM|TO filename CSV */
 	else if (Matches("COPY|\\copy", MatchAny, "FROM|TO", MatchAny, "CSV") ||
 			 Matches("COPY", "BINARY", MatchAny, "FROM|TO", MatchAny, "CSV"))
-		COMPLETE_WITH_LIST5("HEADER", "QUOTE", "ESCAPE", "FORCE QUOTE",
+		COMPLETE_WITH("HEADER", "QUOTE", "ESCAPE", "FORCE QUOTE",
 							"FORCE NOT NULL");
 
 	/* CREATE ACCESS METHOD */
 	/* Complete "CREATE ACCESS METHOD <name>" */
 	else if (Matches("CREATE", "ACCESS", "METHOD", MatchAny))
-		COMPLETE_WITH_CONST("TYPE");
+		COMPLETE_WITH("TYPE");
 	/* Complete "CREATE ACCESS METHOD <name> TYPE" */
 	else if (Matches("CREATE", "ACCESS", "METHOD", MatchAny, "TYPE"))
-		COMPLETE_WITH_CONST("INDEX");
+		COMPLETE_WITH("INDEX");
 	/* Complete "CREATE ACCESS METHOD <name> TYPE <type>" */
 	else if (Matches("CREATE", "ACCESS", "METHOD", MatchAny, "TYPE", MatchAny))
-		COMPLETE_WITH_CONST("HANDLER");
+		COMPLETE_WITH("HANDLER");
 
 	/* CREATE DATABASE */
 	else if (Matches("CREATE", "DATABASE", MatchAny))
-		COMPLETE_WITH_LIST9("OWNER", "TEMPLATE", "ENCODING", "TABLESPACE",
+		COMPLETE_WITH("OWNER", "TEMPLATE", "ENCODING", "TABLESPACE",
 							"IS_TEMPLATE",
 							"ALLOW_CONNECTIONS", "CONNECTION LIMIT",
 							"LC_COLLATE", "LC_CTYPE");
@@ -2272,7 +2197,7 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_QUERY(Query_for_list_of_available_extensions);
 	/* CREATE EXTENSION <name> */
 	else if (Matches("CREATE", "EXTENSION", MatchAny))
-		COMPLETE_WITH_LIST3("WITH SCHEMA", "CASCADE", "VERSION");
+		COMPLETE_WITH("WITH SCHEMA", "CASCADE", "VERSION");
 	/* CREATE EXTENSION <name> VERSION */
 	else if (Matches("CREATE", "EXTENSION", MatchAny, "VERSION"))
 	{
@@ -2282,16 +2207,16 @@ psql_completion(const char *text, int start, int end)
 
 	/* CREATE FOREIGN */
 	else if (Matches("CREATE", "FOREIGN"))
-		COMPLETE_WITH_LIST2("DATA WRAPPER", "TABLE");
+		COMPLETE_WITH("DATA WRAPPER", "TABLE");
 
 	/* CREATE FOREIGN DATA WRAPPER */
 	else if (Matches("CREATE", "FOREIGN", "DATA", "WRAPPER", MatchAny))
-		COMPLETE_WITH_LIST3("HANDLER", "VALIDATOR", "OPTIONS");
+		COMPLETE_WITH("HANDLER", "VALIDATOR", "OPTIONS");
 
 	/* CREATE INDEX --- is allowed inside CREATE SCHEMA, so use TailMatches */
 	/* First off we complete CREATE UNIQUE with "INDEX" */
 	else if (TailMatches("CREATE", "UNIQUE"))
-		COMPLETE_WITH_CONST("INDEX");
+		COMPLETE_WITH("INDEX");
 
 	/*
 	 * If we have CREATE|UNIQUE INDEX, then add "ON", "CONCURRENTLY", and
@@ -2320,7 +2245,7 @@ psql_completion(const char *text, int start, int end)
 	/* Complete CREATE|UNIQUE INDEX [CONCURRENTLY] <sth> with "ON" */
 	else if (TailMatches("CREATE|UNIQUE", "INDEX", MatchAny) ||
 			 TailMatches("CREATE|UNIQUE", "INDEX", "CONCURRENTLY", MatchAny))
-		COMPLETE_WITH_CONST("ON");
+		COMPLETE_WITH("ON");
 
 	/*
 	 * Complete INDEX <name> ON <table> with a list of table columns (which
@@ -2328,7 +2253,7 @@ psql_completion(const char *text, int start, int end)
 	 */
 	else if (TailMatches("INDEX", MatchAny, "ON", MatchAny) ||
 			 TailMatches("INDEX|CONCURRENTLY", "ON", MatchAny))
-		COMPLETE_WITH_LIST2("(", "USING");
+		COMPLETE_WITH("(", "USING");
 	else if (TailMatches("INDEX", MatchAny, "ON", MatchAny, "(") ||
 			 TailMatches("INDEX|CONCURRENTLY", "ON", MatchAny, "("))
 		COMPLETE_WITH_ATTR(prev2_wd, "");
@@ -2343,74 +2268,74 @@ psql_completion(const char *text, int start, int end)
 	else if (TailMatches("ON", MatchAny, "USING", MatchAny) &&
 			 !TailMatches("POLICY", MatchAny, MatchAny, MatchAny, MatchAny, MatchAny) &&
 			 !TailMatches("FOR", MatchAny, MatchAny, MatchAny))
-		COMPLETE_WITH_CONST("(");
+		COMPLETE_WITH("(");
 
 	/* CREATE POLICY */
 	/* Complete "CREATE POLICY <name> ON" */
 	else if (Matches("CREATE", "POLICY", MatchAny))
-		COMPLETE_WITH_CONST("ON");
+		COMPLETE_WITH("ON");
 	/* Complete "CREATE POLICY <name> ON <table>" */
 	else if (Matches("CREATE", "POLICY", MatchAny, "ON"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
 	/* Complete "CREATE POLICY <name> ON <table> AS|FOR|TO|USING|WITH CHECK" */
 	else if (Matches("CREATE", "POLICY", MatchAny, "ON", MatchAny))
-		COMPLETE_WITH_LIST5("AS", "FOR", "TO", "USING (", "WITH CHECK (");
+		COMPLETE_WITH("AS", "FOR", "TO", "USING (", "WITH CHECK (");
 	/* CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE */
 	else if (Matches("CREATE", "POLICY", MatchAny, "ON", MatchAny, "AS"))
-		COMPLETE_WITH_LIST2("PERMISSIVE", "RESTRICTIVE");
+		COMPLETE_WITH("PERMISSIVE", "RESTRICTIVE");
 
 	/*
 	 * CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE
 	 * FOR|TO|USING|WITH CHECK
 	 */
 	else if (Matches("CREATE", "POLICY", MatchAny, "ON", MatchAny, "AS", MatchAny))
-		COMPLETE_WITH_LIST4("FOR", "TO", "USING", "WITH CHECK");
+		COMPLETE_WITH("FOR", "TO", "USING", "WITH CHECK");
 	/* CREATE POLICY <name> ON <table> FOR ALL|SELECT|INSERT|UPDATE|DELETE */
 	else if (Matches("CREATE", "POLICY", MatchAny, "ON", MatchAny, "FOR"))
-		COMPLETE_WITH_LIST5("ALL", "SELECT", "INSERT", "UPDATE", "DELETE");
+		COMPLETE_WITH("ALL", "SELECT", "INSERT", "UPDATE", "DELETE");
 	/* Complete "CREATE POLICY <name> ON <table> FOR INSERT TO|WITH CHECK" */
 	else if (Matches("CREATE", "POLICY", MatchAny, "ON", MatchAny, "FOR", "INSERT"))
-		COMPLETE_WITH_LIST2("TO", "WITH CHECK (");
+		COMPLETE_WITH("TO", "WITH CHECK (");
 	/* Complete "CREATE POLICY <name> ON <table> FOR SELECT|DELETE TO|USING" */
 	else if (Matches("CREATE", "POLICY", MatchAny, "ON", MatchAny, "FOR", "SELECT|DELETE"))
-		COMPLETE_WITH_LIST2("TO", "USING (");
+		COMPLETE_WITH("TO", "USING (");
 	/* CREATE POLICY <name> ON <table> FOR ALL|UPDATE TO|USING|WITH CHECK */
 	else if (Matches("CREATE", "POLICY", MatchAny, "ON", MatchAny, "FOR", "ALL|UPDATE"))
-		COMPLETE_WITH_LIST3("TO", "USING (", "WITH CHECK (");
+		COMPLETE_WITH("TO", "USING (", "WITH CHECK (");
 	/* Complete "CREATE POLICY <name> ON <table> TO <role>" */
 	else if (Matches("CREATE", "POLICY", MatchAny, "ON", MatchAny, "TO"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_grant_roles);
 	/* Complete "CREATE POLICY <name> ON <table> USING (" */
 	else if (Matches("CREATE", "POLICY", MatchAny, "ON", MatchAny, "USING"))
-		COMPLETE_WITH_CONST("(");
+		COMPLETE_WITH("(");
 
 	/*
 	 * CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE FOR
 	 * ALL|SELECT|INSERT|UPDATE|DELETE
 	 */
 	else if (Matches("CREATE", "POLICY", MatchAny, "ON", MatchAny, "AS", MatchAny, "FOR"))
-		COMPLETE_WITH_LIST5("ALL", "SELECT", "INSERT", "UPDATE", "DELETE");
+		COMPLETE_WITH("ALL", "SELECT", "INSERT", "UPDATE", "DELETE");
 
 	/*
 	 * Complete "CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE FOR
 	 * INSERT TO|WITH CHECK"
 	 */
 	else if (Matches("CREATE", "POLICY", MatchAny, "ON", MatchAny, "AS", MatchAny, "FOR", "INSERT"))
-		COMPLETE_WITH_LIST2("TO", "WITH CHECK (");
+		COMPLETE_WITH("TO", "WITH CHECK (");
 
 	/*
 	 * Complete "CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE FOR
 	 * SELECT|DELETE TO|USING"
 	 */
 	else if (Matches("CREATE", "POLICY", MatchAny, "ON", MatchAny, "AS", MatchAny, "FOR", "SELECT|DELETE"))
-		COMPLETE_WITH_LIST2("TO", "USING (");
+		COMPLETE_WITH("TO", "USING (");
 
 	/*
 	 * CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE FOR
 	 * ALL|UPDATE TO|USING|WITH CHECK
 	 */
 	else if (Matches("CREATE", "POLICY", MatchAny, "ON", MatchAny, "AS", MatchAny, "FOR", "ALL|UPDATE"))
-		COMPLETE_WITH_LIST3("TO", "USING (", "WITH CHECK (");
+		COMPLETE_WITH("TO", "USING (", "WITH CHECK (");
 
 	/*
 	 * Complete "CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE TO
@@ -2424,34 +2349,34 @@ psql_completion(const char *text, int start, int end)
 	 * USING ("
 	 */
 	else if (Matches("CREATE", "POLICY", MatchAny, "ON", MatchAny, "AS", MatchAny, "USING"))
-		COMPLETE_WITH_CONST("(");
+		COMPLETE_WITH("(");
 
 
 /* CREATE PUBLICATION */
 	else if (Matches("CREATE", "PUBLICATION", MatchAny))
-		COMPLETE_WITH_LIST3("FOR TABLE", "FOR ALL TABLES", "WITH (");
+		COMPLETE_WITH("FOR TABLE", "FOR ALL TABLES", "WITH (");
 	else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR"))
-		COMPLETE_WITH_LIST2("TABLE", "ALL TABLES");
+		COMPLETE_WITH("TABLE", "ALL TABLES");
 	/* Complete "CREATE PUBLICATION <name> FOR TABLE <table>" */
 	else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR TABLE"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
 	/* Complete "CREATE PUBLICATION <name> [...] WITH" */
 	else if (HeadMatches("CREATE", "PUBLICATION") && TailMatches("WITH", "("))
-		COMPLETE_WITH_CONST("publish");
+		COMPLETE_WITH("publish");
 
 /* CREATE RULE */
 	/* Complete "CREATE RULE <sth>" with "AS ON" */
 	else if (Matches("CREATE", "RULE", MatchAny))
-		COMPLETE_WITH_CONST("AS ON");
+		COMPLETE_WITH("AS ON");
 	/* Complete "CREATE RULE <sth> AS" with "ON" */
 	else if (Matches("CREATE", "RULE", MatchAny, "AS"))
-		COMPLETE_WITH_CONST("ON");
+		COMPLETE_WITH("ON");
 	/* Complete "CREATE RULE <sth> AS ON" with SELECT|UPDATE|INSERT|DELETE */
 	else if (Matches("CREATE", "RULE", MatchAny, "AS", "ON"))
-		COMPLETE_WITH_LIST4("SELECT", "UPDATE", "INSERT", "DELETE");
+		COMPLETE_WITH("SELECT", "UPDATE", "INSERT", "DELETE");
 	/* Complete "AS ON SELECT|UPDATE|INSERT|DELETE" with a "TO" */
 	else if (TailMatches("AS", "ON", "SELECT|UPDATE|INSERT|DELETE"))
-		COMPLETE_WITH_CONST("TO");
+		COMPLETE_WITH("TO");
 	/* Complete "AS ON <sth> TO" with a table name */
 	else if (TailMatches("AS", "ON", "SELECT|UPDATE|INSERT|DELETE", "TO"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
@@ -2459,25 +2384,25 @@ psql_completion(const char *text, int start, int end)
 /* CREATE SEQUENCE --- is allowed inside CREATE SCHEMA, so use TailMatches */
 	else if (TailMatches("CREATE", "SEQUENCE", MatchAny) ||
 			 TailMatches("CREATE", "TEMP|TEMPORARY", "SEQUENCE", MatchAny))
-		COMPLETE_WITH_LIST8("INCREMENT BY", "MINVALUE", "MAXVALUE", "NO", "CACHE",
+		COMPLETE_WITH("INCREMENT BY", "MINVALUE", "MAXVALUE", "NO", "CACHE",
 							"CYCLE", "OWNED BY", "START WITH");
 	else if (TailMatches("CREATE", "SEQUENCE", MatchAny, "NO") ||
 			 TailMatches("CREATE", "TEMP|TEMPORARY", "SEQUENCE", MatchAny, "NO"))
-		COMPLETE_WITH_LIST3("MINVALUE", "MAXVALUE", "CYCLE");
+		COMPLETE_WITH("MINVALUE", "MAXVALUE", "CYCLE");
 
 /* CREATE SERVER <name> */
 	else if (Matches("CREATE", "SERVER", MatchAny))
-		COMPLETE_WITH_LIST3("TYPE", "VERSION", "FOREIGN DATA WRAPPER");
+		COMPLETE_WITH("TYPE", "VERSION", "FOREIGN DATA WRAPPER");
 
 /* CREATE STATISTICS <name> */
 	else if (Matches("CREATE", "STATISTICS", MatchAny))
-		COMPLETE_WITH_LIST2("(", "ON");
+		COMPLETE_WITH("(", "ON");
 	else if (Matches("CREATE", "STATISTICS", MatchAny, "("))
-		COMPLETE_WITH_LIST2("ndistinct", "dependencies");
+		COMPLETE_WITH("ndistinct", "dependencies");
 	else if (HeadMatches("CREATE", "STATISTICS", MatchAny) &&
 			 previous_words[0][0] == '(' &&
 			 previous_words[0][strlen(previous_words[0]) - 1] == ')')
-		COMPLETE_WITH_CONST("ON");
+		COMPLETE_WITH("ON");
 	else if (HeadMatches("CREATE", "STATISTICS", MatchAny) &&
 			 TailMatches("FROM"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
@@ -2485,64 +2410,64 @@ psql_completion(const char *text, int start, int end)
 /* CREATE TABLE --- is allowed inside CREATE SCHEMA, so use TailMatches */
 	/* Complete "CREATE TEMP/TEMPORARY" with the possible temp objects */
 	else if (TailMatches("CREATE", "TEMP|TEMPORARY"))
-		COMPLETE_WITH_LIST3("SEQUENCE", "TABLE", "VIEW");
+		COMPLETE_WITH("SEQUENCE", "TABLE", "VIEW");
 	/* Complete "CREATE UNLOGGED" with TABLE or MATVIEW */
 	else if (TailMatches("CREATE", "UNLOGGED"))
-		COMPLETE_WITH_LIST2("TABLE", "MATERIALIZED VIEW");
+		COMPLETE_WITH("TABLE", "MATERIALIZED VIEW");
 	/* Complete PARTITION BY with RANGE ( or LIST ( or ... */
 	else if (TailMatches("PARTITION", "BY"))
-		COMPLETE_WITH_LIST3("RANGE (", "LIST (", "HASH (");
+		COMPLETE_WITH("RANGE (", "LIST (", "HASH (");
 	/* If we have xxx PARTITION OF, provide a list of partitioned tables */
 	else if (TailMatches("PARTITION", "OF"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_tables, "");
 	/* Limited completion support for partition bound specification */
 	else if (TailMatches("PARTITION", "OF", MatchAny))
-		COMPLETE_WITH_LIST2("FOR VALUES", "DEFAULT");
+		COMPLETE_WITH("FOR VALUES", "DEFAULT");
 
 /* CREATE TABLESPACE */
 	else if (Matches("CREATE", "TABLESPACE", MatchAny))
-		COMPLETE_WITH_LIST2("OWNER", "LOCATION");
+		COMPLETE_WITH("OWNER", "LOCATION");
 	/* Complete CREATE TABLESPACE name OWNER name with "LOCATION" */
 	else if (Matches("CREATE", "TABLESPACE", MatchAny, "OWNER", MatchAny))
-		COMPLETE_WITH_CONST("LOCATION");
+		COMPLETE_WITH("LOCATION");
 
 /* CREATE TEXT SEARCH */
 	else if (Matches("CREATE", "TEXT", "SEARCH"))
-		COMPLETE_WITH_LIST4("CONFIGURATION", "DICTIONARY", "PARSER", "TEMPLATE");
+		COMPLETE_WITH("CONFIGURATION", "DICTIONARY", "PARSER", "TEMPLATE");
 	else if (Matches("CREATE", "TEXT", "SEARCH", "CONFIGURATION", MatchAny))
-		COMPLETE_WITH_CONST("(");
+		COMPLETE_WITH("(");
 
 /* CREATE SUBSCRIPTION */
 	else if (Matches("CREATE", "SUBSCRIPTION", MatchAny))
-		COMPLETE_WITH_CONST("CONNECTION");
+		COMPLETE_WITH("CONNECTION");
 	else if (Matches("CREATE", "SUBSCRIPTION", MatchAny, "CONNECTION", MatchAny))
-		COMPLETE_WITH_CONST("PUBLICATION");
+		COMPLETE_WITH("PUBLICATION");
 	else if (Matches("CREATE", "SUBSCRIPTION", MatchAny, "CONNECTION",
 					  MatchAny, "PUBLICATION"))
 	{
 		/* complete with nothing here as this refers to remote publications */
 	}
 	else if (HeadMatches("CREATE", "SUBSCRIPTION") && TailMatches("PUBLICATION", MatchAny))
-		COMPLETE_WITH_CONST("WITH (");
+		COMPLETE_WITH("WITH (");
 	/* Complete "CREATE SUBSCRIPTION <name> ...  WITH ( <opt>" */
 	else if (HeadMatches("CREATE", "SUBSCRIPTION") && TailMatches("WITH", "("))
-		COMPLETE_WITH_LIST6("copy_data", "connect", "create_slot", "enabled",
+		COMPLETE_WITH("copy_data", "connect", "create_slot", "enabled",
 							"slot_name", "synchronous_commit");
 
 /* CREATE TRIGGER --- is allowed inside CREATE SCHEMA, so use TailMatches */
 	/* complete CREATE TRIGGER <name> with BEFORE,AFTER,INSTEAD OF */
 	else if (TailMatches("CREATE", "TRIGGER", MatchAny))
-		COMPLETE_WITH_LIST3("BEFORE", "AFTER", "INSTEAD OF");
+		COMPLETE_WITH("BEFORE", "AFTER", "INSTEAD OF");
 	/* complete CREATE TRIGGER <name> BEFORE,AFTER with an event */
 	else if (TailMatches("CREATE", "TRIGGER", MatchAny, "BEFORE|AFTER"))
-		COMPLETE_WITH_LIST4("INSERT", "DELETE", "UPDATE", "TRUNCATE");
+		COMPLETE_WITH("INSERT", "DELETE", "UPDATE", "TRUNCATE");
 	/* complete CREATE TRIGGER <name> INSTEAD OF with an event */
 	else if (TailMatches("CREATE", "TRIGGER", MatchAny, "INSTEAD", "OF"))
-		COMPLETE_WITH_LIST3("INSERT", "DELETE", "UPDATE");
+		COMPLETE_WITH("INSERT", "DELETE", "UPDATE");
 	/* complete CREATE TRIGGER <name> BEFORE,AFTER sth with OR,ON */
 	else if (TailMatches("CREATE", "TRIGGER", MatchAny, "BEFORE|AFTER", MatchAny) ||
 			 TailMatches("CREATE", "TRIGGER", MatchAny, "INSTEAD", "OF", MatchAny))
-		COMPLETE_WITH_LIST2("ON", "OR");
+		COMPLETE_WITH("ON", "OR");
 
 	/*
 	 * complete CREATE TRIGGER <name> BEFORE,AFTER event ON with a list of
@@ -2554,40 +2479,40 @@ psql_completion(const char *text, int start, int end)
 	else if (TailMatches("CREATE", "TRIGGER", MatchAny, "INSTEAD", "OF", MatchAny, "ON"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_views, NULL);
 	else if (HeadMatches("CREATE", "TRIGGER") && TailMatches("ON", MatchAny))
-		COMPLETE_WITH_LIST7("NOT DEFERRABLE", "DEFERRABLE", "INITIALLY",
+		COMPLETE_WITH("NOT DEFERRABLE", "DEFERRABLE", "INITIALLY",
 							"REFERENCING", "FOR", "WHEN (", "EXECUTE PROCEDURE");
 	else if (HeadMatches("CREATE", "TRIGGER") &&
 			 (TailMatches("DEFERRABLE") || TailMatches("INITIALLY", "IMMEDIATE|DEFERRED")))
-		COMPLETE_WITH_LIST4("REFERENCING", "FOR", "WHEN (", "EXECUTE PROCEDURE");
+		COMPLETE_WITH("REFERENCING", "FOR", "WHEN (", "EXECUTE PROCEDURE");
 	else if (HeadMatches("CREATE", "TRIGGER") && TailMatches("REFERENCING"))
-		COMPLETE_WITH_LIST2("OLD TABLE", "NEW TABLE");
+		COMPLETE_WITH("OLD TABLE", "NEW TABLE");
 	else if (HeadMatches("CREATE", "TRIGGER") && TailMatches("OLD|NEW", "TABLE"))
-		COMPLETE_WITH_CONST("AS");
+		COMPLETE_WITH("AS");
 	else if (HeadMatches("CREATE", "TRIGGER") &&
 			 (TailMatches("REFERENCING", "OLD", "TABLE", "AS", MatchAny) ||
 			  TailMatches("REFERENCING", "OLD", "TABLE", MatchAny)))
-		COMPLETE_WITH_LIST4("NEW TABLE", "FOR", "WHEN (", "EXECUTE PROCEDURE");
+		COMPLETE_WITH("NEW TABLE", "FOR", "WHEN (", "EXECUTE PROCEDURE");
 	else if (HeadMatches("CREATE", "TRIGGER") &&
 			 (TailMatches("REFERENCING", "NEW", "TABLE", "AS", MatchAny) ||
 			  TailMatches("REFERENCING", "NEW", "TABLE", MatchAny)))
-		COMPLETE_WITH_LIST4("OLD TABLE", "FOR", "WHEN (", "EXECUTE PROCEDURE");
+		COMPLETE_WITH("OLD TABLE", "FOR", "WHEN (", "EXECUTE PROCEDURE");
 	else if (HeadMatches("CREATE", "TRIGGER") &&
 			 (TailMatches("REFERENCING", "OLD|NEW", "TABLE", "AS", MatchAny, "OLD|NEW", "TABLE", "AS", MatchAny) ||
 			  TailMatches("REFERENCING", "OLD|NEW", "TABLE", MatchAny, "OLD|NEW", "TABLE", "AS", MatchAny) ||
 			  TailMatches("REFERENCING", "OLD|NEW", "TABLE", "AS", MatchAny, "OLD|NEW", "TABLE", MatchAny) ||
 			  TailMatches("REFERENCING", "OLD|NEW", "TABLE", MatchAny, "OLD|NEW", "TABLE", MatchAny)))
-		COMPLETE_WITH_LIST3("FOR", "WHEN (", "EXECUTE PROCEDURE");
+		COMPLETE_WITH("FOR", "WHEN (", "EXECUTE PROCEDURE");
 	else if (HeadMatches("CREATE", "TRIGGER") && TailMatches("FOR"))
-		COMPLETE_WITH_LIST3("EACH", "ROW", "STATEMENT");
+		COMPLETE_WITH("EACH", "ROW", "STATEMENT");
 	else if (HeadMatches("CREATE", "TRIGGER") && TailMatches("FOR", "EACH"))
-		COMPLETE_WITH_LIST2("ROW", "STATEMENT");
+		COMPLETE_WITH("ROW", "STATEMENT");
 	else if (HeadMatches("CREATE", "TRIGGER") &&
 			 (TailMatches("FOR", "EACH", "ROW|STATEMENT") ||
 			  TailMatches("FOR", "ROW|STATEMENT")))
-		COMPLETE_WITH_LIST2("WHEN (", "EXECUTE PROCEDURE");
+		COMPLETE_WITH("WHEN (", "EXECUTE PROCEDURE");
 	/* complete CREATE TRIGGER ... EXECUTE with PROCEDURE */
 	else if (HeadMatches("CREATE", "TRIGGER") && TailMatches("EXECUTE"))
-		COMPLETE_WITH_CONST("PROCEDURE");
+		COMPLETE_WITH("PROCEDURE");
 	else if (HeadMatches("CREATE", "TRIGGER") && TailMatches("EXECUTE", "PROCEDURE"))
 		COMPLETE_WITH_VERSIONED_SCHEMA_QUERY(Query_for_list_of_functions, NULL);
 
@@ -2623,35 +2548,35 @@ psql_completion(const char *text, int start, int end)
 
 	/* complete CREATE ROLE,USER,GROUP <name> IN with ROLE,GROUP */
 	else if (Matches("CREATE", "ROLE|USER|GROUP", MatchAny, "IN"))
-		COMPLETE_WITH_LIST2("GROUP", "ROLE");
+		COMPLETE_WITH("GROUP", "ROLE");
 
 /* CREATE VIEW --- is allowed inside CREATE SCHEMA, so use TailMatches */
 	/* Complete CREATE VIEW <name> with AS */
 	else if (TailMatches("CREATE", "VIEW", MatchAny))
-		COMPLETE_WITH_CONST("AS");
+		COMPLETE_WITH("AS");
 	/* Complete "CREATE VIEW <sth> AS with "SELECT" */
 	else if (TailMatches("CREATE", "VIEW", MatchAny, "AS"))
-		COMPLETE_WITH_CONST("SELECT");
+		COMPLETE_WITH("SELECT");
 
 /* CREATE MATERIALIZED VIEW */
 	else if (Matches("CREATE", "MATERIALIZED"))
-		COMPLETE_WITH_CONST("VIEW");
+		COMPLETE_WITH("VIEW");
 	/* Complete CREATE MATERIALIZED VIEW <name> with AS */
 	else if (Matches("CREATE", "MATERIALIZED", "VIEW", MatchAny))
-		COMPLETE_WITH_CONST("AS");
+		COMPLETE_WITH("AS");
 	/* Complete "CREATE MATERIALIZED VIEW <sth> AS with "SELECT" */
 	else if (Matches("CREATE", "MATERIALIZED", "VIEW", MatchAny, "AS"))
-		COMPLETE_WITH_CONST("SELECT");
+		COMPLETE_WITH("SELECT");
 
 /* CREATE EVENT TRIGGER */
 	else if (Matches("CREATE", "EVENT"))
-		COMPLETE_WITH_CONST("TRIGGER");
+		COMPLETE_WITH("TRIGGER");
 	/* Complete CREATE EVENT TRIGGER <name> with ON */
 	else if (Matches("CREATE", "EVENT", "TRIGGER", MatchAny))
-		COMPLETE_WITH_CONST("ON");
+		COMPLETE_WITH("ON");
 	/* Complete CREATE EVENT TRIGGER <name> ON with event_type */
 	else if (Matches("CREATE", "EVENT", "TRIGGER", MatchAny, "ON"))
-		COMPLETE_WITH_LIST3("ddl_command_start", "ddl_command_end", "sql_drop");
+		COMPLETE_WITH("ddl_command_start", "ddl_command_end", "sql_drop");
 
 /* DEALLOCATE */
 	else if (Matches("DEALLOCATE"))
@@ -2659,30 +2584,30 @@ psql_completion(const char *text, int start, int end)
 
 /* DECLARE */
 	else if (Matches("DECLARE", MatchAny))
-		COMPLETE_WITH_LIST5("BINARY", "INSENSITIVE", "SCROLL", "NO SCROLL",
+		COMPLETE_WITH("BINARY", "INSENSITIVE", "SCROLL", "NO SCROLL",
 							"CURSOR");
 	else if (HeadMatches("DECLARE") && TailMatches("CURSOR"))
-		COMPLETE_WITH_LIST3("WITH HOLD", "WITHOUT HOLD", "FOR");
+		COMPLETE_WITH("WITH HOLD", "WITHOUT HOLD", "FOR");
 
 /* DELETE --- can be inside EXPLAIN, RULE, etc */
 	/* ... despite which, only complete DELETE with FROM at start of line */
 	else if (Matches("DELETE"))
-		COMPLETE_WITH_CONST("FROM");
+		COMPLETE_WITH("FROM");
 	/* Complete DELETE FROM with a list of tables */
 	else if (TailMatches("DELETE", "FROM"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_updatables, NULL);
 	/* Complete DELETE FROM <table> */
 	else if (TailMatches("DELETE", "FROM", MatchAny))
-		COMPLETE_WITH_LIST2("USING", "WHERE");
+		COMPLETE_WITH("USING", "WHERE");
 	/* XXX: implement tab completion for DELETE ... USING */
 
 /* DISCARD */
 	else if (Matches("DISCARD"))
-		COMPLETE_WITH_LIST4("ALL", "PLANS", "SEQUENCES", "TEMP");
+		COMPLETE_WITH("ALL", "PLANS", "SEQUENCES", "TEMP");
 
 /* DO */
 	else if (Matches("DO"))
-		COMPLETE_WITH_CONST("LANGUAGE");
+		COMPLETE_WITH("LANGUAGE");
 
 /* DROP */
 	/* Complete DROP object with CASCADE / RESTRICT */
@@ -2696,15 +2621,15 @@ psql_completion(const char *text, int start, int end)
 			 Matches("DROP", "FOREIGN", "DATA", "WRAPPER", MatchAny) ||
 			 Matches("DROP", "FOREIGN", "TABLE", MatchAny) ||
 			 Matches("DROP", "TEXT", "SEARCH", "CONFIGURATION|DICTIONARY|PARSER|TEMPLATE", MatchAny))
-		COMPLETE_WITH_LIST2("CASCADE", "RESTRICT");
+		COMPLETE_WITH("CASCADE", "RESTRICT");
 
 	/* help completing some of the variants */
 	else if (Matches("DROP", "AGGREGATE|FUNCTION|PROCEDURE|ROUTINE", MatchAny))
-		COMPLETE_WITH_CONST("(");
+		COMPLETE_WITH("(");
 	else if (Matches("DROP", "AGGREGATE|FUNCTION|PROCEDURE|ROUTINE", MatchAny, "("))
 		COMPLETE_WITH_FUNCTION_ARG(prev2_wd);
 	else if (Matches("DROP", "FOREIGN"))
-		COMPLETE_WITH_LIST2("DATA WRAPPER", "TABLE");
+		COMPLETE_WITH("DATA WRAPPER", "TABLE");
 
 	/* DROP INDEX */
 	else if (Matches("DROP", "INDEX"))
@@ -2713,46 +2638,46 @@ psql_completion(const char *text, int start, int end)
 	else if (Matches("DROP", "INDEX", "CONCURRENTLY"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL);
 	else if (Matches("DROP", "INDEX", MatchAny))
-		COMPLETE_WITH_LIST2("CASCADE", "RESTRICT");
+		COMPLETE_WITH("CASCADE", "RESTRICT");
 	else if (Matches("DROP", "INDEX", "CONCURRENTLY", MatchAny))
-		COMPLETE_WITH_LIST2("CASCADE", "RESTRICT");
+		COMPLETE_WITH("CASCADE", "RESTRICT");
 
 	/* DROP MATERIALIZED VIEW */
 	else if (Matches("DROP", "MATERIALIZED"))
-		COMPLETE_WITH_CONST("VIEW");
+		COMPLETE_WITH("VIEW");
 	else if (Matches("DROP", "MATERIALIZED", "VIEW"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_matviews, NULL);
 
 	/* DROP OWNED BY */
 	else if (Matches("DROP", "OWNED"))
-		COMPLETE_WITH_CONST("BY");
+		COMPLETE_WITH("BY");
 	else if (Matches("DROP", "OWNED", "BY"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_roles);
 
 	/* DROP TEXT SEARCH */
 	else if (Matches("DROP", "TEXT", "SEARCH"))
-		COMPLETE_WITH_LIST4("CONFIGURATION", "DICTIONARY", "PARSER", "TEMPLATE");
+		COMPLETE_WITH("CONFIGURATION", "DICTIONARY", "PARSER", "TEMPLATE");
 
 	/* DROP TRIGGER */
 	else if (Matches("DROP", "TRIGGER", MatchAny))
-		COMPLETE_WITH_CONST("ON");
+		COMPLETE_WITH("ON");
 	else if (Matches("DROP", "TRIGGER", MatchAny, "ON"))
 	{
 		completion_info_charp = prev2_wd;
 		COMPLETE_WITH_QUERY(Query_for_list_of_tables_for_trigger);
 	}
 	else if (Matches("DROP", "TRIGGER", MatchAny, "ON", MatchAny))
-		COMPLETE_WITH_LIST2("CASCADE", "RESTRICT");
+		COMPLETE_WITH("CASCADE", "RESTRICT");
 
 	/* DROP ACCESS METHOD */
 	else if (Matches("DROP", "ACCESS"))
-		COMPLETE_WITH_CONST("METHOD");
+		COMPLETE_WITH("METHOD");
 	else if (Matches("DROP", "ACCESS", "METHOD"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_access_methods);
 
 	/* DROP EVENT TRIGGER */
 	else if (Matches("DROP", "EVENT"))
-		COMPLETE_WITH_CONST("TRIGGER");
+		COMPLETE_WITH("TRIGGER");
 	else if (Matches("DROP", "EVENT", "TRIGGER"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_event_triggers);
 
@@ -2761,7 +2686,7 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_QUERY(Query_for_list_of_policies);
 	/* DROP POLICY <name> ON */
 	else if (Matches("DROP", "POLICY", MatchAny))
-		COMPLETE_WITH_CONST("ON");
+		COMPLETE_WITH("ON");
 	/* DROP POLICY <name> ON <table> */
 	else if (Matches("DROP", "POLICY", MatchAny, "ON"))
 	{
@@ -2771,14 +2696,14 @@ psql_completion(const char *text, int start, int end)
 
 	/* DROP RULE */
 	else if (Matches("DROP", "RULE", MatchAny))
-		COMPLETE_WITH_CONST("ON");
+		COMPLETE_WITH("ON");
 	else if (Matches("DROP", "RULE", MatchAny, "ON"))
 	{
 		completion_info_charp = prev2_wd;
 		COMPLETE_WITH_QUERY(Query_for_list_of_tables_for_rule);
 	}
 	else if (Matches("DROP", "RULE", MatchAny, "ON", MatchAny))
-		COMPLETE_WITH_LIST2("CASCADE", "RESTRICT");
+		COMPLETE_WITH("CASCADE", "RESTRICT");
 
 /* EXECUTE */
 	else if (Matches("EXECUTE"))
@@ -2790,22 +2715,22 @@ psql_completion(const char *text, int start, int end)
 	 * Complete EXPLAIN [ANALYZE] [VERBOSE] with list of EXPLAIN-able commands
 	 */
 	else if (Matches("EXPLAIN"))
-		COMPLETE_WITH_LIST7("SELECT", "INSERT", "DELETE", "UPDATE", "DECLARE",
+		COMPLETE_WITH("SELECT", "INSERT", "DELETE", "UPDATE", "DECLARE",
 							"ANALYZE", "VERBOSE");
 	else if (Matches("EXPLAIN", "ANALYZE"))
-		COMPLETE_WITH_LIST6("SELECT", "INSERT", "DELETE", "UPDATE", "DECLARE",
+		COMPLETE_WITH("SELECT", "INSERT", "DELETE", "UPDATE", "DECLARE",
 							"VERBOSE");
 	else if (Matches("EXPLAIN", "VERBOSE") ||
 			 Matches("EXPLAIN", "ANALYZE", "VERBOSE"))
-		COMPLETE_WITH_LIST5("SELECT", "INSERT", "DELETE", "UPDATE", "DECLARE");
+		COMPLETE_WITH("SELECT", "INSERT", "DELETE", "UPDATE", "DECLARE");
 
 /* FETCH && MOVE */
 	/* Complete FETCH with one of FORWARD, BACKWARD, RELATIVE */
 	else if (Matches("FETCH|MOVE"))
-		COMPLETE_WITH_LIST4("ABSOLUTE", "BACKWARD", "FORWARD", "RELATIVE");
+		COMPLETE_WITH("ABSOLUTE", "BACKWARD", "FORWARD", "RELATIVE");
 	/* Complete FETCH <sth> with one of ALL, NEXT, PRIOR */
 	else if (Matches("FETCH|MOVE", MatchAny))
-		COMPLETE_WITH_LIST3("ALL", "NEXT", "PRIOR");
+		COMPLETE_WITH("ALL", "NEXT", "PRIOR");
 
 	/*
 	 * Complete FETCH <sth1> <sth2> with "FROM" or "IN". These are equivalent,
@@ -2813,7 +2738,7 @@ psql_completion(const char *text, int start, int end)
 	 * variant or the other.
 	 */
 	else if (Matches("FETCH|MOVE", MatchAny, MatchAny))
-		COMPLETE_WITH_LIST2("FROM", "IN");
+		COMPLETE_WITH("FROM", "IN");
 
 /* FOREIGN DATA WRAPPER */
 	/* applies in ALTER/DROP FDW and in CREATE SERVER */
@@ -2823,7 +2748,7 @@ psql_completion(const char *text, int start, int end)
 	/* applies in CREATE SERVER */
 	else if (TailMatches("FOREIGN", "DATA", "WRAPPER", MatchAny) &&
 			 HeadMatches("CREATE", "SERVER"))
-		COMPLETE_WITH_CONST("OPTIONS");
+		COMPLETE_WITH("OPTIONS");
 
 /* FOREIGN TABLE */
 	else if (TailMatches("FOREIGN", "TABLE") &&
@@ -2846,9 +2771,9 @@ psql_completion(const char *text, int start, int end)
 		 * privileges (can't grant roles)
 		 */
 		if (HeadMatches("ALTER", "DEFAULT", "PRIVILEGES"))
-			COMPLETE_WITH_LIST10("SELECT", "INSERT", "UPDATE",
-								 "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER",
-								 "EXECUTE", "USAGE", "ALL");
+			COMPLETE_WITH("SELECT", "INSERT", "UPDATE",
+						  "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER",
+						  "EXECUTE", "USAGE", "ALL");
 		else
 			COMPLETE_WITH_QUERY(Query_for_list_of_roles
 								" UNION SELECT 'SELECT'"
@@ -2873,11 +2798,11 @@ psql_completion(const char *text, int start, int end)
 	else if (TailMatches("GRANT|REVOKE", MatchAny))
 	{
 		if (TailMatches("SELECT|INSERT|UPDATE|DELETE|TRUNCATE|REFERENCES|TRIGGER|CREATE|CONNECT|TEMPORARY|TEMP|EXECUTE|USAGE|ALL"))
-			COMPLETE_WITH_CONST("ON");
+			COMPLETE_WITH("ON");
 		else if (TailMatches("GRANT", MatchAny))
-			COMPLETE_WITH_CONST("TO");
+			COMPLETE_WITH("TO");
 		else
-			COMPLETE_WITH_CONST("FROM");
+			COMPLETE_WITH("FROM");
 	}
 
 	/*
@@ -2898,7 +2823,7 @@ psql_completion(const char *text, int start, int end)
 		 * objects supported.
 		 */
 		if (HeadMatches("ALTER", "DEFAULT", "PRIVILEGES"))
-			COMPLETE_WITH_LIST7("TABLES", "SEQUENCES", "FUNCTIONS", "PROCEDURES", "ROUTINES", "TYPES", "SCHEMAS");
+			COMPLETE_WITH("TABLES", "SEQUENCES", "FUNCTIONS", "PROCEDURES", "ROUTINES", "TYPES", "SCHEMAS");
 		else
 			COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tsvmf,
 									   " UNION SELECT 'ALL FUNCTIONS IN SCHEMA'"
@@ -2922,13 +2847,13 @@ psql_completion(const char *text, int start, int end)
 									   " UNION SELECT 'TYPE'");
 	}
 	else if (TailMatches("GRANT|REVOKE", MatchAny, "ON", "ALL"))
-		COMPLETE_WITH_LIST5("FUNCTIONS IN SCHEMA",
+		COMPLETE_WITH("FUNCTIONS IN SCHEMA",
 							"PROCEDURES IN SCHEMA",
 							"ROUTINES IN SCHEMA",
 							"SEQUENCES IN SCHEMA",
 							"TABLES IN SCHEMA");
 	else if (TailMatches("GRANT|REVOKE", MatchAny, "ON", "FOREIGN"))
-		COMPLETE_WITH_LIST2("DATA WRAPPER", "SERVER");
+		COMPLETE_WITH("DATA WRAPPER", "SERVER");
 
 	/*
 	 * Complete "GRANT/REVOKE * ON DATABASE/DOMAIN/..." with a list of
@@ -2961,9 +2886,9 @@ psql_completion(const char *text, int start, int end)
 		else if (TailMatches("TYPE"))
 			COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes, NULL);
 		else if (TailMatches("GRANT", MatchAny, MatchAny, MatchAny))
-			COMPLETE_WITH_CONST("TO");
+			COMPLETE_WITH("TO");
 		else
-			COMPLETE_WITH_CONST("FROM");
+			COMPLETE_WITH("FROM");
 	}
 
 	/*
@@ -2978,51 +2903,51 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_QUERY(Query_for_list_of_grant_roles);
 	/* Complete "GRANT/REVOKE ... ON * *" with TO/FROM */
 	else if (HeadMatches("GRANT") && TailMatches("ON", MatchAny, MatchAny))
-		COMPLETE_WITH_CONST("TO");
+		COMPLETE_WITH("TO");
 	else if (HeadMatches("REVOKE") && TailMatches("ON", MatchAny, MatchAny))
-		COMPLETE_WITH_CONST("FROM");
+		COMPLETE_WITH("FROM");
 
 	/* Complete "GRANT/REVOKE * ON ALL * IN SCHEMA *" with TO/FROM */
 	else if (TailMatches("GRANT|REVOKE", MatchAny, "ON", "ALL", MatchAny, "IN", "SCHEMA", MatchAny))
 	{
 		if (TailMatches("GRANT", MatchAny, MatchAny, MatchAny, MatchAny, MatchAny, MatchAny, MatchAny))
-			COMPLETE_WITH_CONST("TO");
+			COMPLETE_WITH("TO");
 		else
-			COMPLETE_WITH_CONST("FROM");
+			COMPLETE_WITH("FROM");
 	}
 
 	/* Complete "GRANT/REVOKE * ON FOREIGN DATA WRAPPER *" with TO/FROM */
 	else if (TailMatches("GRANT|REVOKE", MatchAny, "ON", "FOREIGN", "DATA", "WRAPPER", MatchAny))
 	{
 		if (TailMatches("GRANT", MatchAny, MatchAny, MatchAny, MatchAny, MatchAny, MatchAny))
-			COMPLETE_WITH_CONST("TO");
+			COMPLETE_WITH("TO");
 		else
-			COMPLETE_WITH_CONST("FROM");
+			COMPLETE_WITH("FROM");
 	}
 
 	/* Complete "GRANT/REVOKE * ON FOREIGN SERVER *" with TO/FROM */
 	else if (TailMatches("GRANT|REVOKE", MatchAny, "ON", "FOREIGN", "SERVER", MatchAny))
 	{
 		if (TailMatches("GRANT", MatchAny, MatchAny, MatchAny, MatchAny, MatchAny))
-			COMPLETE_WITH_CONST("TO");
+			COMPLETE_WITH("TO");
 		else
-			COMPLETE_WITH_CONST("FROM");
+			COMPLETE_WITH("FROM");
 	}
 
 /* GROUP BY */
 	else if (TailMatches("FROM", MatchAny, "GROUP"))
-		COMPLETE_WITH_CONST("BY");
+		COMPLETE_WITH("BY");
 
 /* IMPORT FOREIGN SCHEMA */
 	else if (Matches("IMPORT"))
-		COMPLETE_WITH_CONST("FOREIGN SCHEMA");
+		COMPLETE_WITH("FOREIGN SCHEMA");
 	else if (Matches("IMPORT", "FOREIGN"))
-		COMPLETE_WITH_CONST("SCHEMA");
+		COMPLETE_WITH("SCHEMA");
 
 /* INSERT --- can be inside EXPLAIN, RULE, etc */
 	/* Complete INSERT with "INTO" */
 	else if (TailMatches("INSERT"))
-		COMPLETE_WITH_CONST("INTO");
+		COMPLETE_WITH("INTO");
 	/* Complete INSERT INTO with table names */
 	else if (TailMatches("INSERT", "INTO"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_updatables, NULL);
@@ -3035,7 +2960,7 @@ psql_completion(const char *text, int start, int end)
 	 * "TABLE" or "DEFAULT VALUES" or "OVERRIDING"
 	 */
 	else if (TailMatches("INSERT", "INTO", MatchAny))
-		COMPLETE_WITH_LIST6("(", "DEFAULT VALUES", "SELECT", "TABLE", "VALUES", "OVERRIDING");
+		COMPLETE_WITH("(", "DEFAULT VALUES", "SELECT", "TABLE", "VALUES", "OVERRIDING");
 
 	/*
 	 * Complete INSERT INTO <table> (attribs) with "VALUES" or "SELECT" or
@@ -3043,19 +2968,19 @@ psql_completion(const char *text, int start, int end)
 	 */
 	else if (TailMatches("INSERT", "INTO", MatchAny, MatchAny) &&
 			 ends_with(prev_wd, ')'))
-		COMPLETE_WITH_LIST4("SELECT", "TABLE", "VALUES", "OVERRIDING");
+		COMPLETE_WITH("SELECT", "TABLE", "VALUES", "OVERRIDING");
 
 	/* Complete OVERRIDING */
 	else if (TailMatches("OVERRIDING"))
-		COMPLETE_WITH_LIST2("SYSTEM VALUE", "USER VALUE");
+		COMPLETE_WITH("SYSTEM VALUE", "USER VALUE");
 
 	/* Complete after OVERRIDING clause */
 	else if (TailMatches("OVERRIDING", MatchAny, "VALUE"))
-		COMPLETE_WITH_LIST3("SELECT", "TABLE", "VALUES");
+		COMPLETE_WITH("SELECT", "TABLE", "VALUES");
 
 	/* Insert an open parenthesis after "VALUES" */
 	else if (TailMatches("VALUES") && !TailMatches("DEFAULT", "VALUES"))
-		COMPLETE_WITH_CONST("(");
+		COMPLETE_WITH("(");
 
 /* LOCK */
 	/* Complete LOCK [TABLE] with a list of tables */
@@ -3070,12 +2995,12 @@ psql_completion(const char *text, int start, int end)
 	/* Complete LOCK [TABLE] <table> with "IN" */
 	else if (Matches("LOCK", MatchAnyExcept("TABLE")) ||
 			 Matches("LOCK", "TABLE", MatchAny))
-		COMPLETE_WITH_CONST("IN");
+		COMPLETE_WITH("IN");
 
 	/* Complete LOCK [TABLE] <table> IN with a lock mode */
 	else if (Matches("LOCK", MatchAny, "IN") ||
 			 Matches("LOCK", "TABLE", MatchAny, "IN"))
-		COMPLETE_WITH_LIST8("ACCESS SHARE MODE",
+		COMPLETE_WITH("ACCESS SHARE MODE",
 							"ROW SHARE MODE", "ROW EXCLUSIVE MODE",
 							"SHARE UPDATE EXCLUSIVE MODE", "SHARE MODE",
 							"SHARE ROW EXCLUSIVE MODE",
@@ -3084,12 +3009,12 @@ psql_completion(const char *text, int start, int end)
 	/* Complete LOCK [TABLE] <table> IN ACCESS|ROW with rest of lock mode */
 	else if (Matches("LOCK", MatchAny, "IN", "ACCESS|ROW") ||
 			 Matches("LOCK", "TABLE", MatchAny, "IN", "ACCESS|ROW"))
-		COMPLETE_WITH_LIST2("EXCLUSIVE MODE", "SHARE MODE");
+		COMPLETE_WITH("EXCLUSIVE MODE", "SHARE MODE");
 
 	/* Complete LOCK [TABLE] <table> IN SHARE with rest of lock mode */
 	else if (Matches("LOCK", MatchAny, "IN", "SHARE") ||
 			 Matches("LOCK", "TABLE", MatchAny, "IN", "SHARE"))
-		COMPLETE_WITH_LIST3("MODE", "ROW EXCLUSIVE MODE",
+		COMPLETE_WITH("MODE", "ROW EXCLUSIVE MODE",
 							"UPDATE EXCLUSIVE MODE");
 
 /* NOTIFY --- can be inside EXPLAIN, RULE, etc */
@@ -3098,7 +3023,7 @@ psql_completion(const char *text, int start, int end)
 
 /* OPTIONS */
 	else if (TailMatches("OPTIONS"))
-		COMPLETE_WITH_CONST("(");
+		COMPLETE_WITH("(");
 
 /* OWNER TO  - complete with available roles */
 	else if (TailMatches("OWNER", "TO"))
@@ -3106,13 +3031,13 @@ psql_completion(const char *text, int start, int end)
 
 /* ORDER BY */
 	else if (TailMatches("FROM", MatchAny, "ORDER"))
-		COMPLETE_WITH_CONST("BY");
+		COMPLETE_WITH("BY");
 	else if (TailMatches("FROM", MatchAny, "ORDER", "BY"))
 		COMPLETE_WITH_ATTR(prev3_wd, "");
 
 /* PREPARE xx AS */
 	else if (Matches("PREPARE", MatchAny, "AS"))
-		COMPLETE_WITH_LIST4("SELECT", "UPDATE", "INSERT", "DELETE FROM");
+		COMPLETE_WITH("SELECT", "UPDATE", "INSERT", "DELETE FROM");
 
 /*
  * PREPARE TRANSACTION is missing on purpose. It's intended for transaction
@@ -3121,42 +3046,42 @@ psql_completion(const char *text, int start, int end)
 
 /* REASSIGN OWNED BY xxx TO yyy */
 	else if (Matches("REASSIGN"))
-		COMPLETE_WITH_CONST("OWNED BY");
+		COMPLETE_WITH("OWNED BY");
 	else if (Matches("REASSIGN", "OWNED"))
-		COMPLETE_WITH_CONST("BY");
+		COMPLETE_WITH("BY");
 	else if (Matches("REASSIGN", "OWNED", "BY"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_roles);
 	else if (Matches("REASSIGN", "OWNED", "BY", MatchAny))
-		COMPLETE_WITH_CONST("TO");
+		COMPLETE_WITH("TO");
 	else if (Matches("REASSIGN", "OWNED", "BY", MatchAny, "TO"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_roles);
 
 /* REFRESH MATERIALIZED VIEW */
 	else if (Matches("REFRESH"))
-		COMPLETE_WITH_CONST("MATERIALIZED VIEW");
+		COMPLETE_WITH("MATERIALIZED VIEW");
 	else if (Matches("REFRESH", "MATERIALIZED"))
-		COMPLETE_WITH_CONST("VIEW");
+		COMPLETE_WITH("VIEW");
 	else if (Matches("REFRESH", "MATERIALIZED", "VIEW"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_matviews,
 								   " UNION SELECT 'CONCURRENTLY'");
 	else if (Matches("REFRESH", "MATERIALIZED", "VIEW", "CONCURRENTLY"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_matviews, NULL);
 	else if (Matches("REFRESH", "MATERIALIZED", "VIEW", MatchAny))
-		COMPLETE_WITH_CONST("WITH");
+		COMPLETE_WITH("WITH");
 	else if (Matches("REFRESH", "MATERIALIZED", "VIEW", "CONCURRENTLY", MatchAny))
-		COMPLETE_WITH_CONST("WITH");
+		COMPLETE_WITH("WITH");
 	else if (Matches("REFRESH", "MATERIALIZED", "VIEW", MatchAny, "WITH"))
-		COMPLETE_WITH_LIST2("NO DATA", "DATA");
+		COMPLETE_WITH("NO DATA", "DATA");
 	else if (Matches("REFRESH", "MATERIALIZED", "VIEW", "CONCURRENTLY", MatchAny, "WITH"))
-		COMPLETE_WITH_LIST2("NO DATA", "DATA");
+		COMPLETE_WITH("NO DATA", "DATA");
 	else if (Matches("REFRESH", "MATERIALIZED", "VIEW", MatchAny, "WITH", "NO"))
-		COMPLETE_WITH_CONST("DATA");
+		COMPLETE_WITH("DATA");
 	else if (Matches("REFRESH", "MATERIALIZED", "VIEW", "CONCURRENTLY", MatchAny, "WITH", "NO"))
-		COMPLETE_WITH_CONST("DATA");
+		COMPLETE_WITH("DATA");
 
 /* REINDEX */
 	else if (Matches("REINDEX"))
-		COMPLETE_WITH_LIST5("TABLE", "INDEX", "SYSTEM", "SCHEMA", "DATABASE");
+		COMPLETE_WITH("TABLE", "INDEX", "SYSTEM", "SCHEMA", "DATABASE");
 	else if (Matches("REINDEX", "TABLE"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tm, NULL);
 	else if (Matches("REINDEX", "INDEX"))
@@ -3168,11 +3093,11 @@ psql_completion(const char *text, int start, int end)
 
 /* SECURITY LABEL */
 	else if (Matches("SECURITY"))
-		COMPLETE_WITH_CONST("LABEL");
+		COMPLETE_WITH("LABEL");
 	else if (Matches("SECURITY", "LABEL"))
-		COMPLETE_WITH_LIST2("ON", "FOR");
+		COMPLETE_WITH("ON", "FOR");
 	else if (Matches("SECURITY", "LABEL", "FOR", MatchAny))
-		COMPLETE_WITH_CONST("ON");
+		COMPLETE_WITH("ON");
 	else if (Matches("SECURITY", "LABEL", "ON") ||
 			 Matches("SECURITY", "LABEL", "FOR", MatchAny, "ON"))
 	{
@@ -3185,7 +3110,7 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_LIST(list_SECURITY_LABEL);
 	}
 	else if (Matches("SECURITY", "LABEL", "ON", MatchAny, MatchAny))
-		COMPLETE_WITH_CONST("IS");
+		COMPLETE_WITH("IS");
 
 /* SELECT */
 	/* naah . . . */
@@ -3198,57 +3123,57 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_QUERY(Query_for_list_of_show_vars);
 	/* Complete "SET TRANSACTION" */
 	else if (Matches("SET", "TRANSACTION"))
-		COMPLETE_WITH_LIST5("SNAPSHOT", "ISOLATION LEVEL", "READ", "DEFERRABLE", "NOT DEFERRABLE");
+		COMPLETE_WITH("SNAPSHOT", "ISOLATION LEVEL", "READ", "DEFERRABLE", "NOT DEFERRABLE");
 	else if (Matches("BEGIN|START", "TRANSACTION") ||
 			 Matches("BEGIN", "WORK") ||
 			 Matches("BEGIN") ||
 			 Matches("SET", "SESSION", "CHARACTERISTICS", "AS", "TRANSACTION"))
-		COMPLETE_WITH_LIST4("ISOLATION LEVEL", "READ", "DEFERRABLE", "NOT DEFERRABLE");
+		COMPLETE_WITH("ISOLATION LEVEL", "READ", "DEFERRABLE", "NOT DEFERRABLE");
 	else if (Matches("SET|BEGIN|START", "TRANSACTION|WORK", "NOT") ||
 			 Matches("BEGIN", "NOT") ||
 			 Matches("SET", "SESSION", "CHARACTERISTICS", "AS", "TRANSACTION", "NOT"))
-		COMPLETE_WITH_CONST("DEFERRABLE");
+		COMPLETE_WITH("DEFERRABLE");
 	else if (Matches("SET|BEGIN|START", "TRANSACTION|WORK", "ISOLATION") ||
 			 Matches("BEGIN", "ISOLATION") ||
 			 Matches("SET", "SESSION", "CHARACTERISTICS", "AS", "TRANSACTION", "ISOLATION"))
-		COMPLETE_WITH_CONST("LEVEL");
+		COMPLETE_WITH("LEVEL");
 	else if (Matches("SET|BEGIN|START", "TRANSACTION|WORK", "ISOLATION", "LEVEL") ||
 			 Matches("BEGIN", "ISOLATION", "LEVEL") ||
 			 Matches("SET", "SESSION", "CHARACTERISTICS", "AS", "TRANSACTION", "ISOLATION", "LEVEL"))
-		COMPLETE_WITH_LIST3("READ", "REPEATABLE READ", "SERIALIZABLE");
+		COMPLETE_WITH("READ", "REPEATABLE READ", "SERIALIZABLE");
 	else if (Matches("SET|BEGIN|START", "TRANSACTION|WORK", "ISOLATION", "LEVEL", "READ") ||
 			 Matches("BEGIN", "ISOLATION", "LEVEL", "READ") ||
 			 Matches("SET", "SESSION", "CHARACTERISTICS", "AS", "TRANSACTION", "ISOLATION", "LEVEL", "READ"))
-		COMPLETE_WITH_LIST2("UNCOMMITTED", "COMMITTED");
+		COMPLETE_WITH("UNCOMMITTED", "COMMITTED");
 	else if (Matches("SET|BEGIN|START", "TRANSACTION|WORK", "ISOLATION", "LEVEL", "REPEATABLE") ||
 			 Matches("BEGIN", "ISOLATION", "LEVEL", "REPEATABLE") ||
 			 Matches("SET", "SESSION", "CHARACTERISTICS", "AS", "TRANSACTION", "ISOLATION", "LEVEL", "REPEATABLE"))
-		COMPLETE_WITH_CONST("READ");
+		COMPLETE_WITH("READ");
 	else if (Matches("SET|BEGIN|START", "TRANSACTION|WORK", "READ") ||
 			 Matches("BEGIN", "READ") ||
 			 Matches("SET", "SESSION", "CHARACTERISTICS", "AS", "TRANSACTION", "READ"))
-		COMPLETE_WITH_LIST2("ONLY", "WRITE");
+		COMPLETE_WITH("ONLY", "WRITE");
 	/* SET CONSTRAINTS */
 	else if (Matches("SET", "CONSTRAINTS"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_constraints_with_schema, "UNION SELECT 'ALL'");
 	/* Complete SET CONSTRAINTS <foo> with DEFERRED|IMMEDIATE */
 	else if (Matches("SET", "CONSTRAINTS", MatchAny))
-		COMPLETE_WITH_LIST2("DEFERRED", "IMMEDIATE");
+		COMPLETE_WITH("DEFERRED", "IMMEDIATE");
 	/* Complete SET ROLE */
 	else if (Matches("SET", "ROLE"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_roles);
 	/* Complete SET SESSION with AUTHORIZATION or CHARACTERISTICS... */
 	else if (Matches("SET", "SESSION"))
-		COMPLETE_WITH_LIST2("AUTHORIZATION", "CHARACTERISTICS AS TRANSACTION");
+		COMPLETE_WITH("AUTHORIZATION", "CHARACTERISTICS AS TRANSACTION");
 	/* Complete SET SESSION AUTHORIZATION with username */
 	else if (Matches("SET", "SESSION", "AUTHORIZATION"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_roles " UNION SELECT 'DEFAULT'");
 	/* Complete RESET SESSION with AUTHORIZATION */
 	else if (Matches("RESET", "SESSION"))
-		COMPLETE_WITH_CONST("AUTHORIZATION");
+		COMPLETE_WITH("AUTHORIZATION");
 	/* Complete SET <var> with "TO" */
 	else if (Matches("SET", MatchAny))
-		COMPLETE_WITH_CONST("TO");
+		COMPLETE_WITH("TO");
 
 	/*
 	 * Complete ALTER DATABASE|FUNCTION||PROCEDURE|ROLE|ROUTINE|USER ... SET
@@ -3256,7 +3181,7 @@ psql_completion(const char *text, int start, int end)
 	 */
 	else if (HeadMatches("ALTER", "DATABASE|FUNCTION|PROCEDURE|ROLE|ROUTINE|USER") &&
 			 TailMatches("SET", MatchAny))
-		COMPLETE_WITH_LIST2("FROM CURRENT", "TO");
+		COMPLETE_WITH("FROM CURRENT", "TO");
 	/* Suggest possible variable values */
 	else if (TailMatches("SET", MatchAny, "TO|="))
 	{
@@ -3289,10 +3214,10 @@ psql_completion(const char *text, int start, int end)
 				COMPLETE_WITH_QUERY(querybuf);
 			}
 			else if (guctype && strcmp(guctype, "bool") == 0)
-				COMPLETE_WITH_LIST9("on", "off", "true", "false", "yes", "no",
+				COMPLETE_WITH("on", "off", "true", "false", "yes", "no",
 									"1", "0", "DEFAULT");
 			else
-				COMPLETE_WITH_CONST("DEFAULT");
+				COMPLETE_WITH("DEFAULT");
 
 			if (guctype)
 				free(guctype);
@@ -3301,7 +3226,7 @@ psql_completion(const char *text, int start, int end)
 
 /* START TRANSACTION */
 	else if (Matches("START"))
-		COMPLETE_WITH_CONST("TRANSACTION");
+		COMPLETE_WITH("TRANSACTION");
 
 /* TABLE, but not TABLE embedded in other commands */
 	else if (Matches("TABLE"))
@@ -3311,7 +3236,7 @@ psql_completion(const char *text, int start, int end)
 	else if (TailMatches("TABLESAMPLE"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_tablesample_methods);
 	else if (TailMatches("TABLESAMPLE", MatchAny))
-		COMPLETE_WITH_CONST("(");
+		COMPLETE_WITH("(");
 
 /* TRUNCATE */
 	else if (Matches("TRUNCATE"))
@@ -3327,17 +3252,17 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_updatables, NULL);
 	/* Complete UPDATE <table> with "SET" */
 	else if (TailMatches("UPDATE", MatchAny))
-		COMPLETE_WITH_CONST("SET");
+		COMPLETE_WITH("SET");
 	/* Complete UPDATE <table> SET with list of attributes */
 	else if (TailMatches("UPDATE", MatchAny, "SET"))
 		COMPLETE_WITH_ATTR(prev2_wd, "");
 	/* UPDATE <table> SET <attr> = */
 	else if (TailMatches("UPDATE", MatchAny, "SET", MatchAny))
-		COMPLETE_WITH_CONST("=");
+		COMPLETE_WITH("=");
 
 /* USER MAPPING */
 	else if (Matches("ALTER|CREATE|DROP", "USER", "MAPPING"))
-		COMPLETE_WITH_CONST("FOR");
+		COMPLETE_WITH("FOR");
 	else if (Matches("CREATE", "USER", "MAPPING", "FOR"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_roles
 							" UNION SELECT 'CURRENT_USER'"
@@ -3346,9 +3271,9 @@ psql_completion(const char *text, int start, int end)
 	else if (Matches("ALTER|DROP", "USER", "MAPPING", "FOR"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_user_mappings);
 	else if (Matches("CREATE|ALTER|DROP", "USER", "MAPPING", "FOR", MatchAny))
-		COMPLETE_WITH_CONST("SERVER");
+		COMPLETE_WITH("SERVER");
 	else if (Matches("CREATE|ALTER", "USER", "MAPPING", "FOR", MatchAny, "SERVER", MatchAny))
-		COMPLETE_WITH_CONST("OPTIONS");
+		COMPLETE_WITH("OPTIONS");
 
 /*
  * VACUUM [ FULL | FREEZE ] [ VERBOSE ] [ table ]
@@ -3386,7 +3311,7 @@ psql_completion(const char *text, int start, int end)
 	 * other contexts.
 	 */
 	else if (Matches("WITH"))
-		COMPLETE_WITH_CONST("RECURSIVE");
+		COMPLETE_WITH("RECURSIVE");
 
 /* ANALYZE */
 	/* Complete with list of tables */
@@ -3410,7 +3335,7 @@ psql_completion(const char *text, int start, int end)
 /* Backslash commands */
 /* TODO:  \dc \dd \dl */
 	else if (TailMatchesCS("\\?"))
-		COMPLETE_WITH_LIST_CS3("commands", "options", "variables");
+		COMPLETE_WITH_CS("commands", "options", "variables");
 	else if (TailMatchesCS("\\connect|\\c"))
 	{
 		if (!recognized_connection_string(text))
@@ -3503,30 +3428,30 @@ psql_completion(const char *text, int start, int end)
 	else if (TailMatchesCS("\\h|\\help", MatchAny, MatchAny))
 	{
 		if (TailMatches("CREATE|DROP", "ACCESS"))
-			COMPLETE_WITH_CONST("METHOD");
+			COMPLETE_WITH("METHOD");
 		else if (TailMatches("ALTER", "DEFAULT"))
-			COMPLETE_WITH_CONST("PRIVILEGES");
+			COMPLETE_WITH("PRIVILEGES");
 		else if (TailMatches("CREATE|ALTER|DROP", "EVENT"))
-			COMPLETE_WITH_CONST("TRIGGER");
+			COMPLETE_WITH("TRIGGER");
 		else if (TailMatches("CREATE|ALTER|DROP", "FOREIGN"))
-			COMPLETE_WITH_LIST2("DATA WRAPPER", "TABLE");
+			COMPLETE_WITH("DATA WRAPPER", "TABLE");
 		else if (TailMatches("ALTER", "LARGE"))
-			COMPLETE_WITH_CONST("OBJECT");
+			COMPLETE_WITH("OBJECT");
 		else if (TailMatches("CREATE|ALTER|DROP", "MATERIALIZED"))
-			COMPLETE_WITH_CONST("VIEW");
+			COMPLETE_WITH("VIEW");
 		else if (TailMatches("CREATE|ALTER|DROP", "TEXT"))
-			COMPLETE_WITH_CONST("SEARCH");
+			COMPLETE_WITH("SEARCH");
 		else if (TailMatches("CREATE|ALTER|DROP", "USER"))
-			COMPLETE_WITH_CONST("MAPPING FOR");
+			COMPLETE_WITH("MAPPING FOR");
 	}
 	else if (TailMatchesCS("\\h|\\help", MatchAny, MatchAny, MatchAny))
 	{
 		if (TailMatches("CREATE|ALTER|DROP", "FOREIGN", "DATA"))
-			COMPLETE_WITH_CONST("WRAPPER");
+			COMPLETE_WITH("WRAPPER");
 		else if (TailMatches("CREATE|ALTER|DROP", "TEXT", "SEARCH"))
-			COMPLETE_WITH_LIST4("CONFIGURATION", "DICTIONARY", "PARSER", "TEMPLATE");
+			COMPLETE_WITH("CONFIGURATION", "DICTIONARY", "PARSER", "TEMPLATE");
 		else if (TailMatches("CREATE|ALTER|DROP", "USER", "MAPPING"))
-			COMPLETE_WITH_CONST("FOR");
+			COMPLETE_WITH("FOR");
 	}
 	else if (TailMatchesCS("\\l*") && !TailMatchesCS("\\lo*"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_databases);
@@ -3554,13 +3479,13 @@ psql_completion(const char *text, int start, int end)
 			COMPLETE_WITH_LIST_CS(my_list);
 		}
 		else if (TailMatchesCS("linestyle"))
-			COMPLETE_WITH_LIST_CS3("ascii", "old-ascii", "unicode");
+			COMPLETE_WITH_CS("ascii", "old-ascii", "unicode");
 		else if (TailMatchesCS("pager"))
-			COMPLETE_WITH_LIST_CS3("on", "off", "always");
+			COMPLETE_WITH_CS("on", "off", "always");
 		else if (TailMatchesCS("unicode_border_linestyle|"
 								"unicode_column_linestyle|"
 								"unicode_header_linestyle"))
-			COMPLETE_WITH_LIST_CS2("single", "double");
+			COMPLETE_WITH_CS("single", "double");
 	}
 	else if (TailMatchesCS("\\unset"))
 		matches = complete_from_variables(text, "", "", true);
@@ -3570,23 +3495,23 @@ psql_completion(const char *text, int start, int end)
 	{
 		if (TailMatchesCS("AUTOCOMMIT|ON_ERROR_STOP|QUIET|"
 						   "SINGLELINE|SINGLESTEP"))
-			COMPLETE_WITH_LIST_CS2("on", "off");
+			COMPLETE_WITH_CS("on", "off");
 		else if (TailMatchesCS("COMP_KEYWORD_CASE"))
-			COMPLETE_WITH_LIST_CS4("lower", "upper",
-								   "preserve-lower", "preserve-upper");
+			COMPLETE_WITH_CS("lower", "upper",
+							 "preserve-lower", "preserve-upper");
 		else if (TailMatchesCS("ECHO"))
-			COMPLETE_WITH_LIST_CS4("errors", "queries", "all", "none");
+			COMPLETE_WITH_CS("errors", "queries", "all", "none");
 		else if (TailMatchesCS("ECHO_HIDDEN"))
-			COMPLETE_WITH_LIST_CS3("noexec", "off", "on");
+			COMPLETE_WITH_CS("noexec", "off", "on");
 		else if (TailMatchesCS("HISTCONTROL"))
-			COMPLETE_WITH_LIST_CS4("ignorespace", "ignoredups",
-								   "ignoreboth", "none");
+			COMPLETE_WITH_CS("ignorespace", "ignoredups",
+							 "ignoreboth", "none");
 		else if (TailMatchesCS("ON_ERROR_ROLLBACK"))
-			COMPLETE_WITH_LIST_CS3("on", "off", "interactive");
+			COMPLETE_WITH_CS("on", "off", "interactive");
 		else if (TailMatchesCS("SHOW_CONTEXT"))
-			COMPLETE_WITH_LIST_CS3("never", "errors", "always");
+			COMPLETE_WITH_CS("never", "errors", "always");
 		else if (TailMatchesCS("VERBOSITY"))
-			COMPLETE_WITH_LIST_CS3("default", "verbose", "terse");
+			COMPLETE_WITH_CS("default", "verbose", "terse");
 	}
 	else if (TailMatchesCS("\\sf*"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_routines, NULL);
@@ -3632,7 +3557,7 @@ psql_completion(const char *text, int start, int end)
 	 */
 	if (matches == NULL)
 	{
-		COMPLETE_WITH_CONST("");
+		COMPLETE_WITH("");
 #ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
 		rl_completion_append_character = '\0';
 #endif
-- 
2.17.0

