@@ -693,6 +693,17 @@ static const SchemaQuery Query_for_list_of_tables = {
693693 .result = "c.relname" ,
694694};
695695
696+ /* All tables EXCEPT those marked as relispartition = true */
697+ static const SchemaQuery Query_for_list_of_not_relispartition_tables = {
698+ .catname = "pg_catalog.pg_class c" ,
699+ .selcondition = "c.relispartition = false AND "
700+ "c.relkind IN (" CppAsString2 (RELKIND_RELATION ) ", "
701+ CppAsString2 (RELKIND_PARTITIONED_TABLE ) ")" ,
702+ .viscondition = "pg_catalog.pg_table_is_visible(c.oid)" ,
703+ .namespace = "c.relnamespace" ,
704+ .result = "c.relname" ,
705+ };
706+
696707static const SchemaQuery Query_for_list_of_partitioned_tables = {
697708 .catname = "pg_catalog.pg_class c" ,
698709 .selcondition = "c.relkind IN (" CppAsString2 (RELKIND_PARTITIONED_TABLE ) ")" ,
@@ -797,6 +808,17 @@ static const SchemaQuery Query_for_list_of_indexes = {
797808 .result = "c.relname" ,
798809};
799810
811+ /* All indexes EXCEPT those marked as relispartition = true */
812+ static const SchemaQuery Query_for_list_of_not_relispartition_indexes = {
813+ .catname = "pg_catalog.pg_class c" ,
814+ .selcondition = "c.relispartition = false AND "
815+ "c.relkind IN (" CppAsString2 (RELKIND_INDEX ) ", "
816+ CppAsString2 (RELKIND_PARTITIONED_INDEX ) ")" ,
817+ .viscondition = "pg_catalog.pg_table_is_visible(c.oid)" ,
818+ .namespace = "c.relnamespace" ,
819+ .result = "c.relname" ,
820+ };
821+
800822static const SchemaQuery Query_for_list_of_partitioned_indexes = {
801823 .catname = "pg_catalog.pg_class c" ,
802824 .selcondition = "c.relkind = " CppAsString2 (RELKIND_PARTITIONED_INDEX ),
@@ -814,6 +836,19 @@ static const SchemaQuery Query_for_list_of_relations = {
814836 .result = "c.relname" ,
815837};
816838
839+ /* All relations EXCEPT those marked as relispartition = true */
840+ static const SchemaQuery Query_for_list_of_not_relispartition_relations = {
841+ .catname = "pg_catalog.pg_class c" ,
842+ .selcondition = "c.relispartition = false AND "
843+ "c.relkind IN (" CppAsString2 (RELKIND_RELATION ) ", "
844+ CppAsString2 (RELKIND_PARTITIONED_TABLE ) ", "
845+ CppAsString2 (RELKIND_INDEX ) ", "
846+ CppAsString2 (RELKIND_PARTITIONED_INDEX ) ")" ,
847+ .viscondition = "pg_catalog.pg_table_is_visible(c.oid)" ,
848+ .namespace = "c.relnamespace" ,
849+ .result = "c.relname" ,
850+ };
851+
817852/* partitioned relations */
818853static const SchemaQuery Query_for_list_of_partitioned_relations = {
819854 .catname = "pg_catalog.pg_class c" ,
@@ -1916,7 +1951,7 @@ psql_completion(const char *text, int start, int end)
19161951 "\\db" , "\\dc" , "\\dconfig" , "\\dC" , "\\dd" , "\\ddp" , "\\dD" ,
19171952 "\\des" , "\\det" , "\\deu" , "\\dew" , "\\dE" , "\\df" ,
19181953 "\\dF" , "\\dFd" , "\\dFp" , "\\dFt" , "\\dg" , "\\di" , "\\dl" , "\\dL" ,
1919- "\\dm" , "\\dn" , "\\do" , "\\dO" , "\\dp" , "\\dP" , "\\dPi" , "\\dPt" ,
1954+ "\\dm" , "\\dn" , "\\dN" , "\\ do" , "\\dO" , "\\dp" , "\\dP" , "\\dPi" , "\\dPt" ,
19201955 "\\drds" , "\\drg" , "\\dRs" , "\\dRp" , "\\ds" ,
19211956 "\\dt" , "\\dT" , "\\dv" , "\\du" , "\\dx" , "\\dX" , "\\dy" ,
19221957 "\\echo" , "\\edit" , "\\ef" , "\\elif" , "\\else" , "\\encoding" ,
@@ -5376,6 +5411,8 @@ match_previous_words(int pattern_id,
53765411 else if (TailMatchesCS ("\\dF*" ))
53775412 COMPLETE_WITH_SCHEMA_QUERY (Query_for_list_of_ts_configurations );
53785413
5414+ else if (TailMatchesCS ("\\diN*" ) || TailMatchesCS ("\\dNi*" ))
5415+ COMPLETE_WITH_SCHEMA_QUERY (Query_for_list_of_not_relispartition_indexes );
53795416 else if (TailMatchesCS ("\\di*" ))
53805417 COMPLETE_WITH_SCHEMA_QUERY (Query_for_list_of_indexes );
53815418 else if (TailMatchesCS ("\\dL*" ))
@@ -5399,6 +5436,8 @@ match_previous_words(int pattern_id,
53995436 COMPLETE_WITH_VERSIONED_QUERY (Query_for_list_of_subscriptions );
54005437 else if (TailMatchesCS ("\\ds*" ))
54015438 COMPLETE_WITH_SCHEMA_QUERY (Query_for_list_of_sequences );
5439+ else if (TailMatchesCS ("\\dtN*" ) || TailMatchesCS ("\\dNt*" ))
5440+ COMPLETE_WITH_SCHEMA_QUERY (Query_for_list_of_not_relispartition_tables );
54025441 else if (TailMatchesCS ("\\dt*" ))
54035442 COMPLETE_WITH_SCHEMA_QUERY (Query_for_list_of_tables );
54045443 else if (TailMatchesCS ("\\dT*" ))
@@ -5421,6 +5460,8 @@ match_previous_words(int pattern_id,
54215460 COMPLETE_WITH_QUERY (Query_for_list_of_event_triggers );
54225461
54235462 /* must be at end of \d alternatives: */
5463+ else if (TailMatchesCS ("\\dN*" ))
5464+ COMPLETE_WITH_SCHEMA_QUERY (Query_for_list_of_not_relispartition_relations );
54245465 else if (TailMatchesCS ("\\d*" ))
54255466 COMPLETE_WITH_SCHEMA_QUERY (Query_for_list_of_relations );
54265467
0 commit comments