diff options
| author | Michael Paquier <michael@paquier.xyz> | 2021-08-31 12:07:20 +0900 | 
|---|---|---|
| committer | Michael Paquier <michael@paquier.xyz> | 2021-08-31 12:07:47 +0900 | 
| commit | f2bbadce6b5052337a11a33ea6bd8d8aebe2610a (patch) | |
| tree | 1e0698f6738db719c719d7681a60c02cb2a983f0 /src/bin/psql/tab-complete.c | |
| parent | 99709c9b908eba99ecd787c4dc757f71edd98d87 (diff) | |
Add tab completion for data types after ALTER TABLE ADD [COLUMN] in psql
This allows finding data types that can be used for the creation of a
new column, completing d3fa876.
Author: Dagfinn Ilmari Mannsåker
Discussion: https://postgr.es/m/87h7f7uk6s.fsf@wibble.ilmari.org
Diffstat (limited to 'src/bin/psql/tab-complete.c')
| -rw-r--r-- | src/bin/psql/tab-complete.c | 8 | 
1 files changed, 8 insertions, 0 deletions
| diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 7c6af435a95..76462412db5 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -2025,8 +2025,16 @@ psql_completion(const char *text, int start, int end)  					  "DETACH PARTITION", "FORCE ROW LEVEL SECURITY");  	/* ALTER TABLE xxx ADD */  	else if (Matches("ALTER", "TABLE", MatchAny, "ADD")) +	{ +		/* make sure to keep this list and the !Matches() below in sync */  		COMPLETE_WITH("COLUMN", "CONSTRAINT", "CHECK", "UNIQUE", "PRIMARY KEY",  					  "EXCLUDE", "FOREIGN KEY"); +	} +	/* ATER TABLE xxx ADD [COLUMN] yyy */ +	else if (Matches("ALTER", "TABLE", MatchAny, "ADD", "COLUMN", MatchAny) || +			 (Matches("ALTER", "TABLE", MatchAny, "ADD", MatchAny) && +			  !Matches("ALTER", "TABLE", MatchAny, "ADD", "COLUMN|CONSTRAINT|CHECK|UNIQUE|PRIMARY|EXCLUDE|FOREIGN"))) +		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes, NULL);  	/* ALTER TABLE xxx ADD CONSTRAINT yyy */  	else if (Matches("ALTER", "TABLE", MatchAny, "ADD", "CONSTRAINT", MatchAny))  		COMPLETE_WITH("CHECK", "UNIQUE", "PRIMARY KEY", "EXCLUDE", "FOREIGN KEY"); | 
