Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 158e3bc

Browse files
committed
Tab completion for CREATE SEQUENCE.
Vik Fearing, reviewed by Brendan Jurd, Michael Paquier, and myself
1 parent a6a2357 commit 158e3bc

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/bin/psql/tab-complete.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2467,6 +2467,35 @@ psql_completion(const char *text, int start, int end)
24672467
pg_strcasecmp(prev_wd, "TO") == 0)
24682468
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
24692469

2470+
/* CREATE TEMP/TEMPORARY SEQUENCE <name> */
2471+
else if ((pg_strcasecmp(prev3_wd, "CREATE") == 0 &&
2472+
pg_strcasecmp(prev2_wd, "SEQUENCE") == 0) ||
2473+
(pg_strcasecmp(prev4_wd, "CREATE") == 0 &&
2474+
(pg_strcasecmp(prev3_wd, "TEMP") == 0 ||
2475+
pg_strcasecmp(prev3_wd, "TEMPORARY") == 0) &&
2476+
pg_strcasecmp(prev2_wd, "SEQUENCE") == 0))
2477+
{
2478+
static const char *const list_CREATESEQUENCE[] =
2479+
{"INCREMENT BY", "MINVALUE", "MAXVALUE", "NO", "CACHE",
2480+
"CYCLE", "OWNED BY", "START WITH", NULL};
2481+
2482+
COMPLETE_WITH_LIST(list_CREATESEQUENCE);
2483+
}
2484+
/* CREATE TEMP/TEMPORARY SEQUENCE <name> NO */
2485+
else if (((pg_strcasecmp(prev4_wd, "CREATE") == 0 &&
2486+
pg_strcasecmp(prev3_wd, "SEQUENCE") == 0) ||
2487+
(pg_strcasecmp(prev5_wd, "CREATE") == 0 &&
2488+
(pg_strcasecmp(prev4_wd, "TEMP") == 0 ||
2489+
pg_strcasecmp(prev4_wd, "TEMPORARY") == 0) &&
2490+
pg_strcasecmp(prev3_wd, "SEQUENCE") == 0)) &&
2491+
pg_strcasecmp(prev_wd, "NO") == 0)
2492+
{
2493+
static const char *const list_CREATESEQUENCE2[] =
2494+
{"MINVALUE", "MAXVALUE", "CYCLE", NULL};
2495+
2496+
COMPLETE_WITH_LIST(list_CREATESEQUENCE2);
2497+
}
2498+
24702499
/* CREATE SERVER <name> */
24712500
else if (pg_strcasecmp(prev3_wd, "CREATE") == 0 &&
24722501
pg_strcasecmp(prev2_wd, "SERVER") == 0)

0 commit comments

Comments
 (0)