3
3
*
4
4
* Copyright (c) 2000-2007, PostgreSQL Global Development Group
5
5
*
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 $
7
7
*/
8
8
9
9
/*----------------------------------------------------------------------
@@ -328,6 +328,10 @@ static const SchemaQuery Query_for_list_of_views = {
328
328
" AND pg_catalog.quote_ident(relname)='%s' "\
329
329
" AND pg_catalog.pg_table_is_visible(c.oid)"
330
330
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
+
331
335
#define Query_for_list_of_databases \
332
336
"SELECT pg_catalog.quote_ident(datname) FROM pg_catalog.pg_database "\
333
337
" WHERE substring(pg_catalog.quote_ident(datname),1,%d)='%s'"
@@ -419,6 +423,22 @@ static const SchemaQuery Query_for_list_of_views = {
419
423
" (SELECT tgrelid FROM pg_catalog.pg_trigger "\
420
424
" WHERE pg_catalog.quote_ident(tgname)='%s')"
421
425
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
+
422
442
/*
423
443
* This is a list of all "things" in Pgsql, which can show up after CREATE or
424
444
* DROP; and there is also a query to get a list of them.
@@ -429,6 +449,7 @@ typedef struct
429
449
const char * name ;
430
450
const char * query ; /* simple query, or NULL */
431
451
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 */
432
453
} pgsql_thing_t ;
433
454
434
455
static const pgsql_thing_t words_after_create [] = {
@@ -440,28 +461,33 @@ static const pgsql_thing_t words_after_create[] = {
440
461
* CREATE CONSTRAINT TRIGGER is not supported here because it is designed
441
462
* to be used only by pg_dump.
442
463
*/
464
+ {"CONFIGURATION" , Query_for_list_of_ts_configurations , NULL , true},
443
465
{"CONVERSION" , "SELECT pg_catalog.quote_ident(conname) FROM pg_catalog.pg_conversion WHERE substring(pg_catalog.quote_ident(conname),1,%d)='%s'" },
444
466
{"DATABASE" , Query_for_list_of_databases },
467
+ {"DICTIONARY" , Query_for_list_of_ts_dictionaries , NULL , true},
445
468
{"DOMAIN" , NULL , & Query_for_list_of_domains },
446
469
{"FUNCTION" , NULL , & Query_for_list_of_functions },
447
470
{"GROUP" , Query_for_list_of_roles },
448
471
{"LANGUAGE" , Query_for_list_of_languages },
449
472
{"INDEX" , NULL , & Query_for_list_of_indexes },
450
473
{"OPERATOR" , NULL , NULL }, /* Querying for this is probably not such a
451
474
* good idea. */
475
+ {"PARSER" , Query_for_list_of_ts_parsers , NULL , true},
452
476
{"ROLE" , Query_for_list_of_roles },
453
477
{"RULE" , "SELECT pg_catalog.quote_ident(rulename) FROM pg_catalog.pg_rules WHERE substring(pg_catalog.quote_ident(rulename),1,%d)='%s'" },
454
478
{"SCHEMA" , Query_for_list_of_schemas },
455
479
{"SEQUENCE" , NULL , & Query_for_list_of_sequences },
456
480
{"TABLE" , NULL , & Query_for_list_of_tables },
457
481
{"TABLESPACE" , Query_for_list_of_tablespaces },
458
482
{"TEMP" , NULL , NULL }, /* for CREATE TEMP TABLE ... */
483
+ {"TEMPLATE" , Query_for_list_of_ts_templates , NULL , true},
484
+ {"TEXT SEARCH" , NULL , NULL },
459
485
{"TRIGGER" , "SELECT pg_catalog.quote_ident(tgname) FROM pg_catalog.pg_trigger WHERE substring(pg_catalog.quote_ident(tgname),1,%d)='%s'" },
460
486
{"TYPE" , NULL , & Query_for_list_of_datatypes },
461
487
{"UNIQUE" , NULL , NULL }, /* for CREATE UNIQUE INDEX ... */
462
488
{"USER" , Query_for_list_of_roles },
463
489
{"VIEW" , NULL , & Query_for_list_of_views },
464
- {NULL , NULL , NULL } /* end of list */
490
+ {NULL , NULL , NULL , false } /* end of list */
465
491
};
466
492
467
493
@@ -531,14 +557,14 @@ psql_completion(char *text, int start, int end)
531
557
"GRANT" , "INSERT" , "LISTEN" , "LOAD" , "LOCK" , "MOVE" , "NOTIFY" , "PREPARE" ,
532
558
"REASSIGN" , "REINDEX" , "RELEASE" , "RESET" , "REVOKE" , "ROLLBACK" ,
533
559
"SAVEPOINT" , "SELECT" , "SET" , "SHOW" , "START" , "TRUNCATE" , "UNLISTEN" ,
534
- "UPDATE" , "VACUUM" , NULL
560
+ "UPDATE" , "VACUUM" , "VALUES" , NULL
535
561
};
536
562
537
563
static const char * const backslash_commands [] = {
538
564
"\\a" , "\\connect" , "\\C" , "\\cd" , "\\copy" , "\\copyright" ,
539
565
"\\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" ,
542
568
"\\e" , "\\echo" , "\\encoding" ,
543
569
"\\f" , "\\g" , "\\h" , "\\help" , "\\H" , "\\i" , "\\l" ,
544
570
"\\lo_import" , "\\lo_export" , "\\lo_list" , "\\lo_unlink" ,
@@ -602,7 +628,7 @@ psql_completion(char *text, int start, int end)
602
628
static const char * const list_ALTER [] =
603
629
{"AGGREGATE" , "CONVERSION" , "DATABASE" , "DOMAIN" , "FUNCTION" ,
604
630
"GROUP" , "INDEX" , "LANGUAGE" , "OPERATOR" , "ROLE" , "SCHEMA" , "SEQUENCE" , "TABLE" ,
605
- "TABLESPACE" , "TRIGGER" , "TYPE" , "USER" , "VIEW" , NULL };
631
+ "TABLESPACE" , "TEXT SEARCH" , " TRIGGER" , "TYPE" , "USER" , "VIEW" , NULL };
606
632
607
633
COMPLETE_WITH_LIST (list_ALTER );
608
634
}
@@ -643,7 +669,7 @@ psql_completion(char *text, int start, int end)
643
669
pg_strcasecmp (prev2_wd , "INDEX" ) == 0 )
644
670
{
645
671
static const char * const list_ALTERINDEX [] =
646
- {"SET TABLESPACE" , "OWNER TO" , "RENAME TO" , NULL };
672
+ {"SET TABLESPACE" , "OWNER TO" , "RENAME TO" , "SET" , "RESET" , NULL };
647
673
648
674
COMPLETE_WITH_LIST (list_ALTERINDEX );
649
675
}
@@ -714,7 +740,7 @@ psql_completion(char *text, int start, int end)
714
740
{
715
741
static const char * const list_ALTERSEQUENCE [] =
716
742
{"INCREMENT" , "MINVALUE" , "MAXVALUE" , "RESTART" , "NO" , "CACHE" , "CYCLE" ,
717
- "SET SCHEMA" , "RENAME TO" , NULL };
743
+ "SET SCHEMA" , "OWNED BY" , " RENAME TO" , NULL };
718
744
719
745
COMPLETE_WITH_LIST (list_ALTERSEQUENCE );
720
746
}
@@ -769,11 +795,38 @@ psql_completion(char *text, int start, int end)
769
795
pg_strcasecmp (prev2_wd , "TABLE" ) == 0 )
770
796
{
771
797
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 };
774
800
775
801
COMPLETE_WITH_LIST (list_ALTER2 );
776
802
}
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
+
777
830
/* If we have TABLE <sth> ALTER|RENAME, provide list of columns */
778
831
else if (pg_strcasecmp (prev3_wd , "TABLE" ) == 0 &&
779
832
(pg_strcasecmp (prev_wd , "ALTER" ) == 0 ||
@@ -871,6 +924,45 @@ psql_completion(char *text, int start, int end)
871
924
872
925
COMPLETE_WITH_LIST (list_ALTERTSPC );
873
926
}
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
+
874
966
/* complete ALTER TYPE <foo> with OWNER TO, SET SCHEMA */
875
967
else if (pg_strcasecmp (prev3_wd , "ALTER" ) == 0 &&
876
968
pg_strcasecmp (prev2_wd , "TYPE" ) == 0 )
@@ -947,7 +1039,7 @@ psql_completion(char *text, int start, int end)
947
1039
}
948
1040
949
1041
/*
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.
951
1043
*/
952
1044
else if (pg_strcasecmp (prev3_wd , "CLUSTER" ) == 0 &&
953
1045
pg_strcasecmp (prev_wd , "USING" ) == 0 )
@@ -966,12 +1058,25 @@ psql_completion(char *text, int start, int end)
966
1058
{"CAST" , "CONVERSION" , "DATABASE" , "INDEX" , "LANGUAGE" , "RULE" , "SCHEMA" ,
967
1059
"SEQUENCE" , "TABLE" , "TYPE" , "VIEW" , "COLUMN" , "AGGREGATE" , "FUNCTION" ,
968
1060
"OPERATOR" , "TRIGGER" , "CONSTRAINT" , "DOMAIN" , "LARGE OBJECT" ,
969
- "TABLESPACE" , "ROLE" , NULL };
1061
+ "TABLESPACE" , "TEXT SEARCH" , " ROLE" , NULL };
970
1062
971
1063
COMPLETE_WITH_LIST (list_COMMENT );
972
1064
}
973
1065
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 ))
975
1080
COMPLETE_WITH_CONST ("IS" );
976
1081
977
1082
/* COPY */
@@ -1038,6 +1143,11 @@ psql_completion(char *text, int start, int end)
1038
1143
COMPLETE_WITH_LIST (list_DATABASE );
1039
1144
}
1040
1145
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
+
1041
1151
/* CREATE INDEX */
1042
1152
/* First off we complete CREATE UNIQUE with "INDEX" */
1043
1153
else if (pg_strcasecmp (prev2_wd , "CREATE" ) == 0 &&
@@ -1077,7 +1187,7 @@ psql_completion(char *text, int start, int end)
1077
1187
else if (pg_strcasecmp (prev_wd , "USING" ) == 0 )
1078
1188
{
1079
1189
static const char * const index_mth [] =
1080
- {"BTREE" , "HASH" , "GIST" , NULL };
1190
+ {"BTREE" , "HASH" , "GIN" , " GIST" , NULL };
1081
1191
1082
1192
COMPLETE_WITH_LIST (index_mth );
1083
1193
}
@@ -1143,6 +1253,21 @@ psql_completion(char *text, int start, int end)
1143
1253
COMPLETE_WITH_CONST ("LOCATION" );
1144
1254
}
1145
1255
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
+
1146
1271
/* CREATE TRIGGER */
1147
1272
/* complete CREATE TRIGGER <name> with BEFORE,AFTER */
1148
1273
else if (pg_strcasecmp (prev3_wd , "CREATE" ) == 0 &&
@@ -1287,7 +1412,15 @@ psql_completion(char *text, int start, int end)
1287
1412
pg_strcasecmp (prev2_wd , "VIEW" ) == 0 )) ||
1288
1413
(pg_strcasecmp (prev4_wd , "DROP" ) == 0 &&
1289
1414
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
+ )
1291
1424
{
1292
1425
if ((pg_strcasecmp (prev3_wd , "DROP" ) == 0 ) && (pg_strcasecmp (prev2_wd , "FUNCTION" ) == 0 ))
1293
1426
{
@@ -1332,9 +1465,17 @@ psql_completion(char *text, int start, int end)
1332
1465
pg_strcasecmp (prev2_wd , "OWNED" ) == 0 &&
1333
1466
pg_strcasecmp (prev_wd , "BY" ) == 0 )
1334
1467
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
+ {
1335
1472
1473
+ static const char * const list_ALTERTEXTSEARCH [] =
1474
+ {"CONFIGURATION" , "DICTIONARY" , "PARSER" , "TEMPLATE" , NULL };
1336
1475
1337
-
1476
+ COMPLETE_WITH_LIST (list_ALTERTEXTSEARCH );
1477
+ }
1478
+
1338
1479
/* EXPLAIN */
1339
1480
1340
1481
/*
@@ -1873,6 +2014,14 @@ psql_completion(char *text, int start, int end)
1873
2014
COMPLETE_WITH_SCHEMA_QUERY (Query_for_list_of_domains , NULL );
1874
2015
else if (strcmp (prev_wd , "\\df" ) == 0 || strcmp (prev_wd , "\\df+" ) == 0 )
1875
2016
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 );
1876
2025
else if (strcmp (prev_wd , "\\di" ) == 0 || strcmp (prev_wd , "\\di+" ) == 0 )
1877
2026
COMPLETE_WITH_SCHEMA_QUERY (Query_for_list_of_indexes , NULL );
1878
2027
else if (strcmp (prev_wd , "\\dn" ) == 0 )
@@ -1985,8 +2134,7 @@ psql_completion(char *text, int start, int end)
1985
2134
static char *
1986
2135
create_command_generator (const char * text , int state )
1987
2136
{
1988
- static int list_index ,
1989
- string_length ;
2137
+ static int list_index , string_length ;
1990
2138
const char * name ;
1991
2139
1992
2140
/* If this is the first time for this completion, init some values */
@@ -1998,9 +2146,10 @@ create_command_generator(const char *text, int state)
1998
2146
1999
2147
/* find something that matches */
2000
2148
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
+ }
2004
2153
/* if nothing matches, return NULL */
2005
2154
return NULL ;
2006
2155
}
@@ -2014,8 +2163,7 @@ create_command_generator(const char *text, int state)
2014
2163
static char *
2015
2164
drop_command_generator (const char * text , int state )
2016
2165
{
2017
- static int list_index ,
2018
- string_length ;
2166
+ static int list_index , string_length ;
2019
2167
const char * name ;
2020
2168
2021
2169
if (state == 0 )
@@ -2043,7 +2191,7 @@ drop_command_generator(const char *text, int state)
2043
2191
*/
2044
2192
while ((name = words_after_create [list_index ++ - 1 ].name ))
2045
2193
{
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 ) )
2047
2195
return pg_strdup (name );
2048
2196
}
2049
2197
0 commit comments