Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
4923550c
Commit
4923550c
authored
Apr 03, 2018
by
Simon Riggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tab completion for MERGE
Author: Pavan Deolasee
parent
aa3faa3c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
6 deletions
+81
-6
src/bin/psql/tab-complete.c
src/bin/psql/tab-complete.c
+81
-6
No files found.
src/bin/psql/tab-complete.c
View file @
4923550c
...
...
@@ -659,6 +659,28 @@ static const SchemaQuery Query_for_list_of_updatables = {
NULL
};
/* Relations supporting MERGE */
static
const
SchemaQuery
Query_for_list_of_mergetargets
=
{
/* min_server_version */
110000
,
/* catname */
"pg_catalog.pg_class c"
,
/* selcondition */
"c.relkind IN ("
CppAsString2
(
RELKIND_RELATION
)
", "
CppAsString2
(
RELKIND_PARTITIONED_TABLE
)
") AND "
"c.relhasrules = false AND "
"(c.relhassubclass = false OR "
" c.relkind = "
CppAsString2
(
RELKIND_PARTITIONED_TABLE
)
")"
,
/* viscondition */
"pg_catalog.pg_table_is_visible(c.oid)"
,
/* namespace */
"c.relnamespace"
,
/* result */
"pg_catalog.quote_ident(c.relname)"
,
/* qualresult */
NULL
};
static
const
SchemaQuery
Query_for_list_of_relations
=
{
/* min_server_version */
0
,
...
...
@@ -1605,7 +1627,7 @@ psql_completion(const char *text, int start, int end)
"COMMENT"
,
"COMMIT"
,
"COPY"
,
"CREATE"
,
"DEALLOCATE"
,
"DECLARE"
,
"DELETE FROM"
,
"DISCARD"
,
"DO"
,
"DROP"
,
"END"
,
"EXECUTE"
,
"EXPLAIN"
,
"FETCH"
,
"GRANT"
,
"IMPORT"
,
"INSERT"
,
"LISTEN"
,
"LOAD"
,
"LOCK"
,
"MOVE"
,
"NOTIFY"
,
"PREPARE"
,
"M
ERGE"
,
"M
OVE"
,
"NOTIFY"
,
"PREPARE"
,
"REASSIGN"
,
"REFRESH MATERIALIZED VIEW"
,
"REINDEX"
,
"RELEASE"
,
"RESET"
,
"REVOKE"
,
"ROLLBACK"
,
"SAVEPOINT"
,
"SECURITY LABEL"
,
"SELECT"
,
"SET"
,
"SHOW"
,
"START"
,
...
...
@@ -2999,14 +3021,15 @@ psql_completion(const char *text, int start, int end)
* Complete EXPLAIN [ANALYZE] [VERBOSE] with list of EXPLAIN-able commands
*/
else
if
(
Matches1
(
"EXPLAIN"
))
COMPLETE_WITH_LIST
7
(
"SELECT"
,
"INSERT"
,
"DELETE"
,
"UPDATE"
,
"DECLAR
E"
,
"ANALYZE"
,
"VERBOSE"
);
COMPLETE_WITH_LIST
8
(
"SELECT"
,
"INSERT"
,
"DELETE"
,
"UPDATE"
,
"MERG
E"
,
"
DECLARE"
,
"
ANALYZE"
,
"VERBOSE"
);
else
if
(
Matches2
(
"EXPLAIN"
,
"ANALYZE"
))
COMPLETE_WITH_LIST
6
(
"SELECT"
,
"INSERT"
,
"DELETE"
,
"UPDATE"
,
"DECLAR
E"
,
"VERBOSE"
);
COMPLETE_WITH_LIST
7
(
"SELECT"
,
"INSERT"
,
"DELETE"
,
"UPDATE"
,
"MERG
E"
,
"
DECLARE"
,
"
VERBOSE"
);
else
if
(
Matches2
(
"EXPLAIN"
,
"VERBOSE"
)
||
Matches3
(
"EXPLAIN"
,
"ANALYZE"
,
"VERBOSE"
))
COMPLETE_WITH_LIST5
(
"SELECT"
,
"INSERT"
,
"DELETE"
,
"UPDATE"
,
"DECLARE"
);
COMPLETE_WITH_LIST6
(
"SELECT"
,
"INSERT"
,
"DELETE"
,
"UPDATE"
,
"MERGE"
,
"DECLARE"
);
/* FETCH && MOVE */
/* Complete FETCH with one of FORWARD, BACKWARD, RELATIVE */
...
...
@@ -3229,6 +3252,9 @@ psql_completion(const char *text, int start, int end)
COMPLETE_WITH_CONST
(
"SCHEMA"
);
/* INSERT --- can be inside EXPLAIN, RULE, etc */
/* Complete NOT MATCHED THEN INSERT */
else
if
(
TailMatches4
(
"NOT"
,
"MATCHED"
,
"THEN"
,
"INSERT"
))
COMPLETE_WITH_LIST2
(
"VALUES"
,
"("
);
/* Complete INSERT with "INTO" */
else
if
(
TailMatches1
(
"INSERT"
))
COMPLETE_WITH_CONST
(
"INTO"
);
...
...
@@ -3300,6 +3326,55 @@ psql_completion(const char *text, int start, int end)
Matches5
(
"LOCK"
,
"TABLE"
,
MatchAny
,
"IN"
,
"SHARE"
))
COMPLETE_WITH_LIST3
(
"MODE"
,
"ROW EXCLUSIVE MODE"
,
"UPDATE EXCLUSIVE MODE"
);
/* MERGE --- can be inside EXPLAIN */
else
if
(
TailMatches1
(
"MERGE"
))
COMPLETE_WITH_CONST
(
"INTO"
);
else
if
(
TailMatches2
(
"MERGE"
,
"INTO"
))
COMPLETE_WITH_SCHEMA_QUERY
(
Query_for_list_of_mergetargets
,
NULL
);
else
if
(
TailMatches3
(
"MERGE"
,
"INTO"
,
MatchAny
))
COMPLETE_WITH_LIST2
(
"USING"
,
"AS"
);
else
if
(
TailMatches4
(
"MERGE"
,
"INTO"
,
MatchAny
,
"USING"
))
COMPLETE_WITH_SCHEMA_QUERY
(
Query_for_list_of_tables
,
NULL
);
/* with [AS] alias */
else
if
(
TailMatches5
(
"MERGE"
,
"INTO"
,
MatchAny
,
"AS"
,
MatchAny
))
COMPLETE_WITH_CONST
(
"USING"
);
else
if
(
TailMatches4
(
"MERGE"
,
"INTO"
,
MatchAny
,
MatchAny
))
COMPLETE_WITH_CONST
(
"USING"
);
else
if
(
TailMatches6
(
"MERGE"
,
"INTO"
,
MatchAny
,
"AS"
,
MatchAny
,
"USING"
))
COMPLETE_WITH_SCHEMA_QUERY
(
Query_for_list_of_tables
,
NULL
);
else
if
(
TailMatches5
(
"MERGE"
,
"INTO"
,
MatchAny
,
MatchAny
,
"USING"
))
COMPLETE_WITH_SCHEMA_QUERY
(
Query_for_list_of_tables
,
NULL
);
/* ON */
else
if
(
TailMatches5
(
"MERGE"
,
"INTO"
,
MatchAny
,
"USING"
,
MatchAny
))
COMPLETE_WITH_CONST
(
"ON"
);
else
if
(
TailMatches8
(
"INTO"
,
MatchAny
,
"AS"
,
MatchAny
,
"USING"
,
MatchAny
,
"AS"
,
MatchAny
))
COMPLETE_WITH_CONST
(
"ON"
);
else
if
(
TailMatches6
(
"INTO"
,
MatchAny
,
MatchAny
,
"USING"
,
MatchAny
,
MatchAny
))
COMPLETE_WITH_CONST
(
"ON"
);
/* ON condition */
else
if
(
TailMatches5
(
"INTO"
,
MatchAny
,
"USING"
,
MatchAny
,
"ON"
))
COMPLETE_WITH_ATTR
(
prev4_wd
,
""
);
else
if
(
TailMatches9
(
"INTO"
,
MatchAny
,
"AS"
,
MatchAny
,
"USING"
,
MatchAny
,
"AS"
,
MatchAny
,
"ON"
))
COMPLETE_WITH_ATTR
(
prev8_wd
,
""
);
else
if
(
TailMatches7
(
"INTO"
,
MatchAny
,
MatchAny
,
"USING"
,
MatchAny
,
MatchAny
,
"ON"
))
COMPLETE_WITH_ATTR
(
prev6_wd
,
""
);
/* WHEN [NOT] MATCHED */
else
if
(
TailMatches4
(
"USING"
,
MatchAny
,
"ON"
,
MatchAny
))
COMPLETE_WITH_LIST2
(
"WHEN MATCHED"
,
"WHEN NOT MATCHED"
);
else
if
(
TailMatches6
(
"USING"
,
MatchAny
,
"AS"
,
MatchAny
,
"ON"
,
MatchAny
))
COMPLETE_WITH_LIST2
(
"WHEN MATCHED"
,
"WHEN NOT MATCHED"
);
else
if
(
TailMatches5
(
"USING"
,
MatchAny
,
MatchAny
,
"ON"
,
MatchAny
))
COMPLETE_WITH_LIST2
(
"WHEN MATCHED"
,
"WHEN NOT MATCHED"
);
else
if
(
TailMatches2
(
"WHEN"
,
"MATCHED"
))
COMPLETE_WITH_LIST2
(
"THEN"
,
"AND"
);
else
if
(
TailMatches3
(
"WHEN"
,
"NOT"
,
"MATCHED"
))
COMPLETE_WITH_LIST2
(
"THEN"
,
"AND"
);
else
if
(
TailMatches3
(
"WHEN"
,
"MATCHED"
,
"THEN"
))
COMPLETE_WITH_LIST2
(
"UPDATE"
,
"DELETE"
);
else
if
(
TailMatches4
(
"WHEN"
,
"NOT"
,
"MATCHED"
,
"THEN"
))
COMPLETE_WITH_LIST2
(
"INSERT"
,
"DO"
);
else
if
(
TailMatches5
(
"WHEN"
,
"NOT"
,
"MATCHED"
,
"THEN"
,
"DO"
))
COMPLETE_WITH_CONST
(
"NOTHING"
);
/* NOTIFY --- can be inside EXPLAIN, RULE, etc */
else
if
(
TailMatches1
(
"NOTIFY"
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment