. "CREATE TABLE mytab123 (f1 int, f2 text);\n"
. "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 TYPE enum1 AS ENUM ('foo', 'bar', 'baz', 'BLACK');\n"
+ . "CREATE PUBLICATION some_publication;\n");
# Developers would not appreciate this test adding a bunch of junk to
# their ~/.psql_history, so be sure to redirect history into a temp file.
{
local $Test::Builder::Level = $Test::Builder::Level + 1;
- check_completion("\\r\n", qr/postgres=# /, "\\r works");
+ check_completion("\\r\n", qr/Query buffer reset.*postgres=# /s,
+ "\\r works");
return;
}
qr/"mytab123" +"mytab246"/,
"offer multiple quoted table choices");
-check_completion("2\t", qr/246" /,
+# note: broken versions of libedit want to backslash the closing quote;
+# not much we can do about that
+check_completion("2\t", qr/246\\?" /,
"finish completion of one of multiple quoted table choices");
-clear_query();
+# note: broken versions of libedit may leave us in a state where psql
+# thinks there's an unclosed double quote, so that we have to use
+# clear_line not clear_query here
+clear_line();
# check handling of mixed-case names
+# note: broken versions of libedit want to backslash the closing quote;
+# not much we can do about that
check_completion(
"select * from \"mi\t",
- qr/"mixedName"/,
+ qr/"mixedName\\?" /,
"complete a mixed-case name");
-clear_query();
+# as above, must use clear_line not clear_query here
+clear_line();
# check case folding
check_completion(
# differently, so just check that the replacement comes out correctly
check_completion("\\DRD\t", qr/drds /, "complete \\DRD<tab> to \\drds");
-clear_query();
+# broken versions of libedit require clear_line not clear_query here
+clear_line();
# check completion of a schema-qualified name
check_completion(
clear_query();
+# check variant where we're completing a qualified name from a refname
+# (this one also checks successful completion in a multiline command)
+check_completion(
+ "comment on constraint tab1_pkey \n on public.\t",
+ qr/public\.tab1/,
+ "complete qualified name from object reference");
+
+clear_query();
+
# check filename completion
check_completion(
"\\lo_import tmp_check/some\t",
qr|tmp_check/af\a?ile|,
"filename completion with multiple possibilities");
-clear_query();
+# broken versions of libedit require clear_line not clear_query here
+clear_line();
# COPY requires quoting
# note: broken versions of libedit want to backslash the closing quote;
clear_query();
}
+# alternate path where keyword comes from SchemaQuery
+check_completion(
+ "DROP TYPE big\t",
+ qr/DROP TYPE bigint /,
+ "offer keyword from SchemaQuery");
+
+clear_query();
+
+# check create_command_generator
+check_completion(
+ "CREATE TY\t",
+ qr/CREATE TYPE /,
+ "check create_command_generator");
+
+clear_query();
+
+# check words_after_create infrastructure
+check_completion(
+ "CREATE TABLE mytab\t\t",
+ qr/mytab123 +mytab246/,
+ "check words_after_create");
+
+clear_query();
+
+# check VersionedQuery infrastructure
+check_completion(
+ "DROP PUBLIC\t \t\t",
+ qr/DROP PUBLICATION\s+some_publication /,
+ "check VersionedQuery");
+
+clear_query();
+
+# hits ends_with() and logic for completing in multi-line queries
+check_completion("analyze (\n\t\t", qr/VERBOSE/,
+ "check ANALYZE (VERBOSE ...");
+
+clear_query();
+
+# check completions for GUCs
+check_completion(
+ "set interval\t\t",
+ qr/intervalstyle TO/,
+ "complete a GUC name");
+check_completion(" iso\t", qr/iso_8601 /, "complete a GUC enum value");
+
+clear_query();
+
+# check completions for psql variables
+check_completion("\\set VERB\t", qr/VERBOSITY /,
+ "complete a psql variable name");
+check_completion("def\t", qr/default /, "complete a psql variable value");
+
+clear_query();
+
+check_completion(
+ "\\echo :VERB\t",
+ qr/:VERBOSITY /,
+ "complete an interpolated psql variable name");
+
+clear_query();
+
+# check no-completions code path
+check_completion("blarg \t\t", qr//, "check completion failure path");
+
+clear_query();
+
# send psql an explicit \q to shut it down, else pty won't close properly
$timer->start(5);
$in .= "\\q\n";