Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit23349b1

Browse files
committed
Add tab completion for ALTER INDEX ALTER COLUMN in psql
The completion here consists of attribute numbers, which is specific tothis grammar.Author: Tatsuro YamadaReviewed-by: Peter EisentrautDiscussion:https://portgr.es/m/b58a78fa-81ce-186f-f0bc-c1aa93c46cbf@lab.ntt.co.jp
1 parenta236765 commit23349b1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎src/bin/psql/tab-complete.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,17 @@ static const SchemaQuery Query_for_list_of_statistics = {
583583
" OR '\"' || relname || '\"'='%s') "\
584584
" AND pg_catalog.pg_table_is_visible(c.oid)"
585585

586+
#defineQuery_for_list_of_attribute_numbers \
587+
"SELECT attnum "\
588+
" FROM pg_catalog.pg_attribute a, pg_catalog.pg_class c "\
589+
" WHERE c.oid = a.attrelid "\
590+
" AND a.attnum > 0 "\
591+
" AND NOT a.attisdropped "\
592+
" AND substring(attnum::pg_catalog.text,1,%d)='%s' "\
593+
" AND (pg_catalog.quote_ident(relname)='%s' "\
594+
" OR '\"' || relname || '\"'='%s') "\
595+
" AND pg_catalog.pg_table_is_visible(c.oid)"
596+
586597
#defineQuery_for_list_of_attributes_with_schema \
587598
"SELECT pg_catalog.quote_ident(attname) "\
588599
" FROM pg_catalog.pg_attribute a, pg_catalog.pg_class c, pg_catalog.pg_namespace n "\
@@ -1604,6 +1615,12 @@ psql_completion(const char *text, int start, int end)
16041615
/* ALTER INDEX <name> ALTER */
16051616
elseif (Matches("ALTER","INDEX",MatchAny,"ALTER"))
16061617
COMPLETE_WITH("COLUMN");
1618+
/* ALTER INDEX <name> ALTER COLUMN */
1619+
elseif (Matches("ALTER","INDEX",MatchAny,"ALTER","COLUMN"))
1620+
{
1621+
completion_info_charp=prev3_wd;
1622+
COMPLETE_WITH_QUERY(Query_for_list_of_attribute_numbers);
1623+
}
16071624
/* ALTER INDEX <name> ALTER COLUMN <colnum> */
16081625
elseif (Matches("ALTER","INDEX",MatchAny,"ALTER","COLUMN",MatchAny))
16091626
COMPLETE_WITH("SET STATISTICS");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp