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

Commit68386fc

Browse files
committed
Tab complete "TABLE whatever DROP CONSTRAINT" with a constraint name.
Jeff Janes
1 parentb2a01b9 commit68386fc

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,14 @@ static const SchemaQuery Query_for_list_of_views = {
579579
" and pg_catalog.quote_ident(c1.relname)='%s'"\
580580
" and pg_catalog.pg_table_is_visible(c2.oid)"
581581

582+
/* the silly-looking length condition is just to eat up the current word */
583+
#defineQuery_for_constraint_of_table \
584+
"SELECT pg_catalog.quote_ident(conname) "\
585+
" FROM pg_catalog.pg_class c1, pg_catalog.pg_constraint con "\
586+
" WHERE c1.oid=conrelid and (%d = pg_catalog.length('%s'))"\
587+
" and pg_catalog.quote_ident(c1.relname)='%s'"\
588+
" and pg_catalog.pg_table_is_visible(c1.oid)"
589+
582590
/* the silly-looking length condition is just to eat up the current word */
583591
#defineQuery_for_list_of_tables_for_trigger \
584592
"SELECT pg_catalog.quote_ident(relname) "\
@@ -1337,6 +1345,14 @@ psql_completion(char *text, int start, int end)
13371345
pg_strcasecmp(prev2_wd,"DROP")==0&&
13381346
pg_strcasecmp(prev_wd,"COLUMN")==0)
13391347
COMPLETE_WITH_ATTR(prev3_wd,"");
1348+
/* If we have TABLE <sth> DROP CONSTRAINT, provide list of constraints */
1349+
elseif (pg_strcasecmp(prev4_wd,"TABLE")==0&&
1350+
pg_strcasecmp(prev2_wd,"DROP")==0&&
1351+
pg_strcasecmp(prev_wd,"CONSTRAINT")==0)
1352+
{
1353+
completion_info_charp=prev3_wd;
1354+
COMPLETE_WITH_QUERY(Query_for_constraint_of_table);
1355+
}
13401356
/* ALTER TABLE ALTER [COLUMN] <foo> */
13411357
elseif ((pg_strcasecmp(prev3_wd,"ALTER")==0&&
13421358
pg_strcasecmp(prev2_wd,"COLUMN")==0)||

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp