Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 17aae41

Browse files
committed
Add tsearch tab completion support:
* adds a few missing words to some commands (like adding GIN as a valid index type or OWNED BY for ALTER SEQUENCE,...) * support for ALTER TABLE foo ENABLE/DISABLE REPLICA TRIGGER/RULE * autocomplete CREATE DATABASE foo TEMPLATE (mostly done to prevent conflicts with the TEMPLATE keyword for text search) * support for ALTER/CREATE/DROP TEXT SEARCH as well as COMMENT ON TEXT SEARCH and the corresponding psql backslash commands. This proved a little more difficult than expected due to the fact that words_after_create[] is used for two purposes - one is to provide a list of words that follow immediatly after CREATE (or DROP) and the other purpose is to use it for autocompleting anywhere in the statement if the word in that struct is found with a query. Since TEXT SEARCH CONFIGURATION|DICTIONARY|TEMPLATE|PARSER results in 3 words instead of one (as all the other words in that list are) I added a flag to the struct to tell create_command_generator() to skip that entry for autocompleting immediatly after CREATE which feels like a dirty hack (but that holds true for a lot of code in tab-complete.c). Stefan Kaltenbrunner
1 parent c0f2b10 commit 17aae41

File tree

1 file changed

+172
-24
lines changed

1 file changed

+172
-24
lines changed

src/bin/psql/tab-complete.c

Lines changed: 172 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2007, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.166 2007/07/03 01:30:37 neilc Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.167 2007/09/14 04:25:24 momjian Exp $
77
*/
88

99
/*----------------------------------------------------------------------
@@ -328,6 +328,10 @@ static const SchemaQuery Query_for_list_of_views = {
328328
" AND pg_catalog.quote_ident(relname)='%s' "\
329329
" AND pg_catalog.pg_table_is_visible(c.oid)"
330330

331+
#define Query_for_list_of_template_databases \
332+
"SELECT pg_catalog.quote_ident(datname) FROM pg_catalog.pg_database "\
333+
" WHERE substring(pg_catalog.quote_ident(datname),1,%d)='%s' and datistemplate IS TRUE"
334+
331335
#define Query_for_list_of_databases \
332336
"SELECT pg_catalog.quote_ident(datname) FROM pg_catalog.pg_database "\
333337
" WHERE substring(pg_catalog.quote_ident(datname),1,%d)='%s'"
@@ -419,6 +423,22 @@ static const SchemaQuery Query_for_list_of_views = {
419423
" (SELECT tgrelid FROM pg_catalog.pg_trigger "\
420424
" WHERE pg_catalog.quote_ident(tgname)='%s')"
421425

426+
#define Query_for_list_of_ts_configurations \
427+
"SELECT pg_catalog.quote_ident(cfgname) FROM pg_catalog.pg_ts_config "\
428+
" WHERE substring(pg_catalog.quote_ident(cfgname),1,%d)='%s'"
429+
430+
#define Query_for_list_of_ts_dictionaries \
431+
"SELECT pg_catalog.quote_ident(dictname) FROM pg_catalog.pg_ts_dict "\
432+
" WHERE substring(pg_catalog.quote_ident(dictname),1,%d)='%s'"
433+
434+
#define Query_for_list_of_ts_parsers \
435+
"SELECT pg_catalog.quote_ident(prsname) FROM pg_catalog.pg_ts_parser "\
436+
" WHERE substring(pg_catalog.quote_ident(prsname),1,%d)='%s'"
437+
438+
#define Query_for_list_of_ts_templates \
439+
"SELECT pg_catalog.quote_ident(tmplname) FROM pg_catalog.pg_ts_template "\
440+
" WHERE substring(pg_catalog.quote_ident(tmplname),1,%d)='%s'"
441+
422442
/*
423443
* This is a list of all "things" in Pgsql, which can show up after CREATE or
424444
* DROP; and there is also a query to get a list of them.
@@ -429,6 +449,7 @@ typedef struct
429449
const char *name;
430450
const char *query; /* simple query, or NULL */
431451
const SchemaQuery *squery; /* schema query, or NULL */
452+
const bool noshow; /* NULL or true if this word should not show up after CREATE or DROP */
432453
} pgsql_thing_t;
433454

434455
static const pgsql_thing_t words_after_create[] = {
@@ -440,28 +461,33 @@ static const pgsql_thing_t words_after_create[] = {
440461
* CREATE CONSTRAINT TRIGGER is not supported here because it is designed
441462
* to be used only by pg_dump.
442463
*/
464+
{"CONFIGURATION", Query_for_list_of_ts_configurations, NULL, true},
443465
{"CONVERSION", "SELECT pg_catalog.quote_ident(conname) FROM pg_catalog.pg_conversion WHERE substring(pg_catalog.quote_ident(conname),1,%d)='%s'"},
444466
{"DATABASE", Query_for_list_of_databases},
467+
{"DICTIONARY", Query_for_list_of_ts_dictionaries, NULL, true},
445468
{"DOMAIN", NULL, &Query_for_list_of_domains},
446469
{"FUNCTION", NULL, &Query_for_list_of_functions},
447470
{"GROUP", Query_for_list_of_roles},
448471
{"LANGUAGE", Query_for_list_of_languages},
449472
{"INDEX", NULL, &Query_for_list_of_indexes},
450473
{"OPERATOR", NULL, NULL}, /* Querying for this is probably not such a
451474
* good idea. */
475+
{"PARSER", Query_for_list_of_ts_parsers, NULL, true},
452476
{"ROLE", Query_for_list_of_roles},
453477
{"RULE", "SELECT pg_catalog.quote_ident(rulename) FROM pg_catalog.pg_rules WHERE substring(pg_catalog.quote_ident(rulename),1,%d)='%s'"},
454478
{"SCHEMA", Query_for_list_of_schemas},
455479
{"SEQUENCE", NULL, &Query_for_list_of_sequences},
456480
{"TABLE", NULL, &Query_for_list_of_tables},
457481
{"TABLESPACE", Query_for_list_of_tablespaces},
458482
{"TEMP", NULL, NULL}, /* for CREATE TEMP TABLE ... */
483+
{"TEMPLATE", Query_for_list_of_ts_templates, NULL, true},
484+
{"TEXT SEARCH", NULL, NULL},
459485
{"TRIGGER", "SELECT pg_catalog.quote_ident(tgname) FROM pg_catalog.pg_trigger WHERE substring(pg_catalog.quote_ident(tgname),1,%d)='%s'"},
460486
{"TYPE", NULL, &Query_for_list_of_datatypes},
461487
{"UNIQUE", NULL, NULL}, /* for CREATE UNIQUE INDEX ... */
462488
{"USER", Query_for_list_of_roles},
463489
{"VIEW", NULL, &Query_for_list_of_views},
464-
{NULL, NULL, NULL} /* end of list */
490+
{NULL, NULL, NULL, false} /* end of list */
465491
};
466492

467493

@@ -531,14 +557,14 @@ psql_completion(char *text, int start, int end)
531557
"GRANT", "INSERT", "LISTEN", "LOAD", "LOCK", "MOVE", "NOTIFY", "PREPARE",
532558
"REASSIGN", "REINDEX", "RELEASE", "RESET", "REVOKE", "ROLLBACK",
533559
"SAVEPOINT", "SELECT", "SET", "SHOW", "START", "TRUNCATE", "UNLISTEN",
534-
"UPDATE", "VACUUM", NULL
560+
"UPDATE", "VACUUM", "VALUES", NULL
535561
};
536562

537563
static const char *const backslash_commands[] = {
538564
"\\a", "\\connect", "\\C", "\\cd", "\\copy", "\\copyright",
539565
"\\d", "\\da", "\\db", "\\dc", "\\dC", "\\dd", "\\dD", "\\df",
540-
"\\dg", "\\di", "\\dl", "\\dn", "\\do", "\\dp", "\\ds", "\\dS",
541-
"\\dt", "\\dT", "\\dv", "\\du",
566+
"\\dF", "\\dFd", "\\dFp", "\\dFt", "\\dg", "\\di", "\\dl",
567+
"\\dn", "\\do", "\\dp", "\\ds", "\\dS", "\\dt", "\\dT", "\\dv", "\\du",
542568
"\\e", "\\echo", "\\encoding",
543569
"\\f", "\\g", "\\h", "\\help", "\\H", "\\i", "\\l",
544570
"\\lo_import", "\\lo_export", "\\lo_list", "\\lo_unlink",
@@ -602,7 +628,7 @@ psql_completion(char *text, int start, int end)
602628
static const char *const list_ALTER[] =
603629
{"AGGREGATE", "CONVERSION", "DATABASE", "DOMAIN", "FUNCTION",
604630
"GROUP", "INDEX", "LANGUAGE", "OPERATOR", "ROLE", "SCHEMA", "SEQUENCE", "TABLE",
605-
"TABLESPACE", "TRIGGER", "TYPE", "USER", "VIEW", NULL};
631+
"TABLESPACE", "TEXT SEARCH", "TRIGGER", "TYPE", "USER", "VIEW", NULL};
606632

607633
COMPLETE_WITH_LIST(list_ALTER);
608634
}
@@ -643,7 +669,7 @@ psql_completion(char *text, int start, int end)
643669
pg_strcasecmp(prev2_wd, "INDEX") == 0)
644670
{
645671
static const char *const list_ALTERINDEX[] =
646-
{"SET TABLESPACE", "OWNER TO", "RENAME TO", NULL};
672+
{"SET TABLESPACE", "OWNER TO", "RENAME TO", "SET", "RESET", NULL};
647673

648674
COMPLETE_WITH_LIST(list_ALTERINDEX);
649675
}
@@ -714,7 +740,7 @@ psql_completion(char *text, int start, int end)
714740
{
715741
static const char *const list_ALTERSEQUENCE[] =
716742
{"INCREMENT", "MINVALUE", "MAXVALUE", "RESTART", "NO", "CACHE", "CYCLE",
717-
"SET SCHEMA", "RENAME TO", NULL};
743+
"SET SCHEMA", "OWNED BY", "RENAME TO", NULL};
718744

719745
COMPLETE_WITH_LIST(list_ALTERSEQUENCE);
720746
}
@@ -769,11 +795,38 @@ psql_completion(char *text, int start, int end)
769795
pg_strcasecmp(prev2_wd, "TABLE") == 0)
770796
{
771797
static const char *const list_ALTER2[] =
772-
{"ADD", "ALTER", "CLUSTER ON", "DROP", "RENAME", "OWNER TO",
773-
"SET", NULL};
798+
{"ADD", "ALTER", "CLUSTER ON", "DISABLE", "DROP", "ENABLE", "INHERIT",
799+
"NO INHERIT", "RENAME", "RESET", "OWNER TO", "SET", NULL};
774800

775801
COMPLETE_WITH_LIST(list_ALTER2);
776802
}
803+
/* ALTER TABLE xxx ENABLE */
804+
else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 &&
805+
pg_strcasecmp(prev3_wd, "TABLE") == 0 &&
806+
pg_strcasecmp(prev_wd, "ENABLE") == 0)
807+
{
808+
static const char *const list_ALTERENABLE[] =
809+
{"ALWAYS","REPLICA","RULE", "TRIGGER", NULL};
810+
COMPLETE_WITH_LIST(list_ALTERENABLE);
811+
}
812+
else if (pg_strcasecmp(prev4_wd, "TABLE") == 0 &&
813+
pg_strcasecmp(prev2_wd, "ENABLE") == 0 &&
814+
(pg_strcasecmp(prev_wd, "REPLICA") == 0 ||
815+
pg_strcasecmp(prev_wd, "ALWAYS") == 0))
816+
{
817+
static const char *const list_ALTERENABLE2[] =
818+
{"RULE", "TRIGGER", NULL};
819+
COMPLETE_WITH_LIST(list_ALTERENABLE2);
820+
}
821+
else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 &&
822+
pg_strcasecmp(prev3_wd, "TABLE") == 0 &&
823+
pg_strcasecmp(prev_wd, "DISABLE") == 0)
824+
{
825+
static const char *const list_ALTERDISABLE[] =
826+
{"RULE", "TRIGGER", NULL};
827+
COMPLETE_WITH_LIST(list_ALTERDISABLE);
828+
}
829+
777830
/* If we have TABLE <sth> ALTER|RENAME, provide list of columns */
778831
else if (pg_strcasecmp(prev3_wd, "TABLE") == 0 &&
779832
(pg_strcasecmp(prev_wd, "ALTER") == 0 ||
@@ -871,6 +924,45 @@ psql_completion(char *text, int start, int end)
871924

872925
COMPLETE_WITH_LIST(list_ALTERTSPC);
873926
}
927+
/* ALTER TEXT SEARCH */
928+
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
929+
pg_strcasecmp(prev2_wd, "TEXT") == 0 &&
930+
pg_strcasecmp(prev_wd, "SEARCH") == 0)
931+
{
932+
static const char *const list_ALTERTEXTSEARCH[] =
933+
{"CONFIGURATION", "DICTIONARY", "PARSER", "TEMPLATE", NULL};
934+
935+
COMPLETE_WITH_LIST(list_ALTERTEXTSEARCH);
936+
}
937+
else if (pg_strcasecmp(prev5_wd, "ALTER") == 0 &&
938+
pg_strcasecmp(prev4_wd, "TEXT") == 0 &&
939+
pg_strcasecmp(prev3_wd, "SEARCH") == 0 &&
940+
(pg_strcasecmp(prev2_wd, "TEMPLATE") == 0 ||
941+
pg_strcasecmp(prev2_wd, "PARSER") == 0))
942+
COMPLETE_WITH_CONST("RENAME TO");
943+
944+
else if (pg_strcasecmp(prev5_wd, "ALTER") == 0 &&
945+
pg_strcasecmp(prev4_wd, "TEXT") == 0 &&
946+
pg_strcasecmp(prev3_wd, "SEARCH") == 0 &&
947+
pg_strcasecmp(prev2_wd, "DICTIONARY") == 0)
948+
{
949+
static const char *const list_ALTERTEXTSEARCH2[] =
950+
{"OWNER TO", "RENAME TO", NULL};
951+
952+
COMPLETE_WITH_LIST(list_ALTERTEXTSEARCH2);
953+
}
954+
955+
else if (pg_strcasecmp(prev5_wd, "ALTER") == 0 &&
956+
pg_strcasecmp(prev4_wd, "TEXT") == 0 &&
957+
pg_strcasecmp(prev3_wd, "SEARCH") == 0 &&
958+
pg_strcasecmp(prev2_wd, "CONFIGURATION") == 0)
959+
{
960+
static const char *const list_ALTERTEXTSEARCH3[] =
961+
{"ADD MAPPING FOR", "ALTER MAPPING", "DROP MAPPING FOR", "OWNER TO", "RENAME TO", NULL};
962+
963+
COMPLETE_WITH_LIST(list_ALTERTEXTSEARCH3);
964+
}
965+
874966
/* complete ALTER TYPE <foo> with OWNER TO, SET SCHEMA */
875967
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
876968
pg_strcasecmp(prev2_wd, "TYPE") == 0)
@@ -947,7 +1039,7 @@ psql_completion(char *text, int start, int end)
9471039
}
9481040

9491041
/*
950-
* If we have CLUSTER <sth> ORDER BY, then add the index as well.
1042+
* If we have CLUSTER <sth> USING, then add the index as well.
9511043
*/
9521044
else if (pg_strcasecmp(prev3_wd, "CLUSTER") == 0 &&
9531045
pg_strcasecmp(prev_wd, "USING") == 0)
@@ -966,12 +1058,25 @@ psql_completion(char *text, int start, int end)
9661058
{"CAST", "CONVERSION", "DATABASE", "INDEX", "LANGUAGE", "RULE", "SCHEMA",
9671059
"SEQUENCE", "TABLE", "TYPE", "VIEW", "COLUMN", "AGGREGATE", "FUNCTION",
9681060
"OPERATOR", "TRIGGER", "CONSTRAINT", "DOMAIN", "LARGE OBJECT",
969-
"TABLESPACE", "ROLE", NULL};
1061+
"TABLESPACE", "TEXT SEARCH", "ROLE", NULL};
9701062

9711063
COMPLETE_WITH_LIST(list_COMMENT);
9721064
}
9731065
else if (pg_strcasecmp(prev4_wd, "COMMENT") == 0 &&
974-
pg_strcasecmp(prev3_wd, "ON") == 0)
1066+
pg_strcasecmp(prev3_wd, "ON") == 0 &&
1067+
pg_strcasecmp(prev2_wd, "TEXT") == 0 &&
1068+
pg_strcasecmp(prev_wd, "SEARCH") == 0)
1069+
{
1070+
static const char *const list_TRANS2[] =
1071+
{"CONFIGURATION", "DICTIONARY", "PARSER", "TEMPLATE", NULL};
1072+
1073+
COMPLETE_WITH_LIST(list_TRANS2);
1074+
}
1075+
else if ((pg_strcasecmp(prev4_wd, "COMMENT") == 0 &&
1076+
pg_strcasecmp(prev3_wd, "ON") == 0) ||
1077+
(pg_strcasecmp(prev5_wd, "ON") == 0 &&
1078+
pg_strcasecmp(prev4_wd, "TEXT") == 0 &&
1079+
pg_strcasecmp(prev3_wd, "SEARCH") == 0))
9751080
COMPLETE_WITH_CONST("IS");
9761081

9771082
/* COPY */
@@ -1038,6 +1143,11 @@ psql_completion(char *text, int start, int end)
10381143
COMPLETE_WITH_LIST(list_DATABASE);
10391144
}
10401145

1146+
else if (pg_strcasecmp(prev4_wd, "CREATE") == 0 &&
1147+
pg_strcasecmp(prev3_wd, "DATABASE") == 0 &&
1148+
pg_strcasecmp(prev_wd, "TEMPLATE") == 0)
1149+
COMPLETE_WITH_QUERY(Query_for_list_of_template_databases);
1150+
10411151
/* CREATE INDEX */
10421152
/* First off we complete CREATE UNIQUE with "INDEX" */
10431153
else if (pg_strcasecmp(prev2_wd, "CREATE") == 0 &&
@@ -1077,7 +1187,7 @@ psql_completion(char *text, int start, int end)
10771187
else if (pg_strcasecmp(prev_wd, "USING") == 0)
10781188
{
10791189
static const char *const index_mth[] =
1080-
{"BTREE", "HASH", "GIST", NULL};
1190+
{"BTREE", "HASH", "GIN", "GIST", NULL};
10811191

10821192
COMPLETE_WITH_LIST(index_mth);
10831193
}
@@ -1143,6 +1253,21 @@ psql_completion(char *text, int start, int end)
11431253
COMPLETE_WITH_CONST("LOCATION");
11441254
}
11451255

1256+
/* CREATE TEXT SEARCH */
1257+
else if (pg_strcasecmp(prev3_wd, "CREATE") == 0 &&
1258+
pg_strcasecmp(prev2_wd, "TEXT") == 0 &&
1259+
pg_strcasecmp(prev_wd, "SEARCH") == 0)
1260+
{
1261+
static const char *const list_CREATETEXTSEARCH[] =
1262+
{"CONFIGURATION", "DICTIONARY", "PARSER", "TEMPLATE", NULL};
1263+
1264+
COMPLETE_WITH_LIST(list_CREATETEXTSEARCH);
1265+
}
1266+
else if (pg_strcasecmp(prev4_wd, "TEXT") == 0 &&
1267+
pg_strcasecmp(prev3_wd, "SEARCH") == 0 &&
1268+
pg_strcasecmp(prev2_wd, "CONFIGURATION") == 0)
1269+
COMPLETE_WITH_CONST("(");
1270+
11461271
/* CREATE TRIGGER */
11471272
/* complete CREATE TRIGGER <name> with BEFORE,AFTER */
11481273
else if (pg_strcasecmp(prev3_wd, "CREATE") == 0 &&
@@ -1287,7 +1412,15 @@ psql_completion(char *text, int start, int end)
12871412
pg_strcasecmp(prev2_wd, "VIEW") == 0)) ||
12881413
(pg_strcasecmp(prev4_wd, "DROP") == 0 &&
12891414
pg_strcasecmp(prev3_wd, "AGGREGATE") == 0 &&
1290-
prev_wd[strlen(prev_wd) - 1] == ')'))
1415+
prev_wd[strlen(prev_wd) - 1] == ')') ||
1416+
(pg_strcasecmp(prev5_wd, "DROP") == 0 &&
1417+
pg_strcasecmp(prev4_wd, "TEXT") == 0 &&
1418+
pg_strcasecmp(prev3_wd, "SEARCH") == 0 &&
1419+
(pg_strcasecmp(prev2_wd, "CONFIGURATION") == 0 ||
1420+
pg_strcasecmp(prev2_wd, "DICTIONARY") == 0 ||
1421+
pg_strcasecmp(prev2_wd, "PARSER") == 0 ||
1422+
pg_strcasecmp(prev2_wd, "TEMPLATE") == 0))
1423+
)
12911424
{
12921425
if ((pg_strcasecmp(prev3_wd, "DROP") == 0) && (pg_strcasecmp(prev2_wd, "FUNCTION") == 0))
12931426
{
@@ -1332,9 +1465,17 @@ psql_completion(char *text, int start, int end)
13321465
pg_strcasecmp(prev2_wd, "OWNED") == 0 &&
13331466
pg_strcasecmp(prev_wd, "BY") == 0)
13341467
COMPLETE_WITH_QUERY(Query_for_list_of_roles);
1468+
else if (pg_strcasecmp(prev3_wd, "DROP") == 0 &&
1469+
pg_strcasecmp(prev2_wd, "TEXT") == 0 &&
1470+
pg_strcasecmp(prev_wd, "SEARCH") == 0)
1471+
{
13351472

1473+
static const char *const list_ALTERTEXTSEARCH[] =
1474+
{"CONFIGURATION", "DICTIONARY", "PARSER", "TEMPLATE", NULL};
13361475

1337-
1476+
COMPLETE_WITH_LIST(list_ALTERTEXTSEARCH);
1477+
}
1478+
13381479
/* EXPLAIN */
13391480

13401481
/*
@@ -1873,6 +2014,14 @@ psql_completion(char *text, int start, int end)
18732014
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_domains, NULL);
18742015
else if (strcmp(prev_wd, "\\df") == 0 || strcmp(prev_wd, "\\df+") == 0)
18752016
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_functions, NULL);
2017+
else if (strcmp(prev_wd, "\\dF") == 0 || strcmp(prev_wd, "\\dF+") == 0)
2018+
COMPLETE_WITH_QUERY(Query_for_list_of_ts_configurations);
2019+
else if (strcmp(prev_wd, "\\dFd") == 0 || strcmp(prev_wd, "\\dFd+") == 0)
2020+
COMPLETE_WITH_QUERY(Query_for_list_of_ts_dictionaries);
2021+
else if (strcmp(prev_wd, "\\dFp") == 0 || strcmp(prev_wd, "\\dFp+") == 0)
2022+
COMPLETE_WITH_QUERY(Query_for_list_of_ts_parsers);
2023+
else if (strcmp(prev_wd, "\\dFt") == 0 || strcmp(prev_wd, "\\dFt+") == 0)
2024+
COMPLETE_WITH_QUERY(Query_for_list_of_ts_templates);
18762025
else if (strcmp(prev_wd, "\\di") == 0 || strcmp(prev_wd, "\\di+") == 0)
18772026
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL);
18782027
else if (strcmp(prev_wd, "\\dn") == 0)
@@ -1985,8 +2134,7 @@ psql_completion(char *text, int start, int end)
19852134
static char *
19862135
create_command_generator(const char *text, int state)
19872136
{
1988-
static int list_index,
1989-
string_length;
2137+
static int list_index, string_length;
19902138
const char *name;
19912139

19922140
/* If this is the first time for this completion, init some values */
@@ -1998,9 +2146,10 @@ create_command_generator(const char *text, int state)
19982146

19992147
/* find something that matches */
20002148
while ((name = words_after_create[list_index++].name))
2001-
if (pg_strncasecmp(name, text, string_length) == 0)
2002-
return pg_strdup(name);
2003-
2149+
{
2150+
if ((pg_strncasecmp(name, text, string_length) == 0) && !words_after_create[list_index - 1].noshow)
2151+
return pg_strdup(name);
2152+
}
20042153
/* if nothing matches, return NULL */
20052154
return NULL;
20062155
}
@@ -2014,8 +2163,7 @@ create_command_generator(const char *text, int state)
20142163
static char *
20152164
drop_command_generator(const char *text, int state)
20162165
{
2017-
static int list_index,
2018-
string_length;
2166+
static int list_index, string_length;
20192167
const char *name;
20202168

20212169
if (state == 0)
@@ -2043,7 +2191,7 @@ drop_command_generator(const char *text, int state)
20432191
*/
20442192
while ((name = words_after_create[list_index++ - 1].name))
20452193
{
2046-
if (pg_strncasecmp(name, text, string_length) == 0)
2194+
if ((pg_strncasecmp(name, text, string_length) == 0) && (!words_after_create[list_index - 2].noshow))
20472195
return pg_strdup(name);
20482196
}
20492197

0 commit comments

Comments
 (0)