Skip to content

Commit da9ee02

Browse files
committed
psql: Add some tab completion for TABLESAMPLE.
Petr Jelinek, reviewed by Brendan Jurd
1 parent 4318118 commit da9ee02

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/bin/psql/tab-complete.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,11 @@ static const SchemaQuery Query_for_list_of_matviews = {
737737
" FROM pg_catalog.pg_event_trigger "\
738738
" WHERE substring(pg_catalog.quote_ident(evtname),1,%d)='%s'"
739739

740+
#define Query_for_list_of_tablesample_methods \
741+
" SELECT pg_catalog.quote_ident(tsmname) "\
742+
" FROM pg_catalog.pg_tablesample_method "\
743+
" WHERE substring(pg_catalog.quote_ident(tsmname),1,%d)='%s'"
744+
740745
/*
741746
* This is a list of all "things" in Pgsql, which can show up after CREATE or
742747
* DROP; and there is also a query to get a list of them.
@@ -3580,6 +3585,13 @@ psql_completion(const char *text, int start, int end)
35803585
prev2_wd[0] == '\0')
35813586
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_relations, NULL);
35823587

3588+
/* TABLESAMPLE */
3589+
else if (pg_strcasecmp(prev_wd, "TABLESAMPLE") == 0)
3590+
COMPLETE_WITH_QUERY(Query_for_list_of_tablesample_methods);
3591+
3592+
else if (pg_strcasecmp(prev2_wd, "TABLESAMPLE") == 0)
3593+
COMPLETE_WITH_CONST("(");
3594+
35833595
/* TRUNCATE */
35843596
else if (pg_strcasecmp(prev_wd, "TRUNCATE") == 0)
35853597
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy