|
3 | 3 | *
|
4 | 4 | * Copyright (c) 2000-2009, PostgreSQL Global Development Group
|
5 | 5 | *
|
6 |
| - * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.181 2009/03/27 14:58:46 heikki Exp $ |
| 6 | + * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.182 2009/04/06 15:50:59 momjian Exp $ |
7 | 7 | */
|
8 | 8 |
|
9 | 9 | /*----------------------------------------------------------------------
|
@@ -431,18 +431,6 @@ static const SchemaQuery Query_for_list_of_views = {
|
431 | 431 | " UNION ALL SELECT 'all') ss "\
|
432 | 432 | " WHERE substring(name,1,%d)='%s'"
|
433 | 433 |
|
434 |
| -/* |
435 |
| - * Note: As of Pg 8.2, we no longer use relkind 's', but we keep it here |
436 |
| - * for compatibility with older servers |
437 |
| - */ |
438 |
| -#defineQuery_for_list_of_system_relations \ |
439 |
| -"SELECT pg_catalog.quote_ident(relname) "\ |
440 |
| -" FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n "\ |
441 |
| -" WHERE c.relkind IN ('r', 'v', 's', 'S') "\ |
442 |
| -" AND substring(pg_catalog.quote_ident(relname),1,%d)='%s' "\ |
443 |
| -" AND c.relnamespace = n.oid "\ |
444 |
| -" AND n.nspname = 'pg_catalog'" |
445 |
| - |
446 | 434 | #defineQuery_for_list_of_roles \
|
447 | 435 | " SELECT pg_catalog.quote_ident(rolname) "\
|
448 | 436 | " FROM pg_catalog.pg_roles "\
|
@@ -2183,48 +2171,53 @@ psql_completion(char *text, int start, int end)
|
2183 | 2171 | /* TODO: \dc \dd \dl */
|
2184 | 2172 | elseif (strcmp(prev_wd,"\\connect")==0||strcmp(prev_wd,"\\c")==0)
|
2185 | 2173 | COMPLETE_WITH_QUERY(Query_for_list_of_databases);
|
2186 |
| -elseif (strcmp(prev_wd,"\\d")==0||strcmp(prev_wd,"\\d+")==0) |
2187 |
| -COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tisv,NULL); |
2188 |
| -elseif (strcmp(prev_wd,"\\da")==0) |
| 2174 | + |
| 2175 | +elseif (strncmp(prev_wd,"\\da",strlen("\\da"))==0) |
2189 | 2176 | COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_aggregates,NULL);
|
2190 |
| -elseif (strcmp(prev_wd,"\\db")==0) |
| 2177 | +elseif (strncmp(prev_wd,"\\db",strlen("\\db"))==0) |
2191 | 2178 | COMPLETE_WITH_QUERY(Query_for_list_of_tablespaces);
|
2192 |
| -elseif (strcmp(prev_wd,"\\dD")==0) |
| 2179 | +elseif (strncmp(prev_wd,"\\dD",strlen("\\dD"))==0) |
2193 | 2180 | COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_domains,NULL);
|
2194 |
| -elseif (strcmp(prev_wd,"\\des")==0||strcmp(prev_wd,"\\des+")==0) |
| 2181 | +elseif (strncmp(prev_wd,"\\des",strlen("\\des"))==0) |
2195 | 2182 | COMPLETE_WITH_QUERY(Query_for_list_of_servers);
|
2196 |
| -elseif (strcmp(prev_wd,"\\deu")==0||strcmp(prev_wd,"\\deu+")==0) |
| 2183 | +elseif (strncmp(prev_wd,"\\deu",strlen("\\deu"))==0) |
2197 | 2184 | COMPLETE_WITH_QUERY(Query_for_list_of_user_mappings);
|
2198 |
| -elseif (strcmp(prev_wd,"\\dew")==0||strcmp(prev_wd,"\\dew+")==0) |
| 2185 | +elseif (strncmp(prev_wd,"\\dew",strlen("\\dew"))==0) |
2199 | 2186 | COMPLETE_WITH_QUERY(Query_for_list_of_fdws);
|
2200 |
| -elseif (strcmp(prev_wd,"\\df")==0||strcmp(prev_wd,"\\df+")==0) |
| 2187 | + |
| 2188 | +elseif (strncmp(prev_wd,"\\df",strlen("\\df"))==0) |
2201 | 2189 | COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_functions,NULL);
|
2202 |
| -elseif (strcmp(prev_wd,"\\dF")==0||strcmp(prev_wd,"\\dF+")==0) |
2203 |
| -COMPLETE_WITH_QUERY(Query_for_list_of_ts_configurations); |
2204 |
| -elseif (strcmp(prev_wd,"\\dFd")==0||strcmp(prev_wd,"\\dFd+")==0) |
| 2190 | +elseif (strncmp(prev_wd,"\\dFd",strlen("\\dFd"))==0) |
2205 | 2191 | COMPLETE_WITH_QUERY(Query_for_list_of_ts_dictionaries);
|
2206 |
| -elseif (strcmp(prev_wd,"\\dFp")==0||strcmp(prev_wd,"\\dFp+")==0) |
| 2192 | +elseif (strncmp(prev_wd,"\\dFp",strlen("\\dFp"))==0) |
2207 | 2193 | COMPLETE_WITH_QUERY(Query_for_list_of_ts_parsers);
|
2208 |
| -elseif (strcmp(prev_wd,"\\dFt")==0||strcmp(prev_wd,"\\dFt+")==0) |
| 2194 | +elseif (strncmp(prev_wd,"\\dFt",strlen("\\dFt"))==0) |
2209 | 2195 | COMPLETE_WITH_QUERY(Query_for_list_of_ts_templates);
|
2210 |
| -elseif (strcmp(prev_wd,"\\di")==0||strcmp(prev_wd,"\\di+")==0) |
| 2196 | +/* must be at end of \dF */ |
| 2197 | +elseif (strncmp(prev_wd,"\\dF",strlen("\\dF"))==0) |
| 2198 | +COMPLETE_WITH_QUERY(Query_for_list_of_ts_configurations); |
| 2199 | + |
| 2200 | +elseif (strncmp(prev_wd,"\\di",strlen("\\di"))==0) |
2211 | 2201 | COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes,NULL);
|
2212 |
| -elseif (strcmp(prev_wd,"\\dn")==0) |
| 2202 | +elseif (strncmp(prev_wd,"\\dn",strlen("\\dn"))==0) |
2213 | 2203 | COMPLETE_WITH_QUERY(Query_for_list_of_schemas);
|
2214 |
| -elseif (strcmp(prev_wd,"\\dp")==0||strcmp(prev_wd,"\\z")==0) |
| 2204 | +elseif (strncmp(prev_wd,"\\dp",strlen("\\dp"))==0) |
2215 | 2205 | COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tsv,NULL);
|
2216 |
| -elseif (strcmp(prev_wd,"\\ds")==0||strcmp(prev_wd,"\\ds+")==0) |
| 2206 | +elseif (strncmp(prev_wd,"\\ds",strlen("\\ds"))==0) |
2217 | 2207 | COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences,NULL);
|
2218 |
| -elseif (strcmp(prev_wd,"\\dS")==0||strcmp(prev_wd,"\\dS+")==0) |
2219 |
| -COMPLETE_WITH_QUERY(Query_for_list_of_system_relations); |
2220 |
| -elseif (strcmp(prev_wd,"\\dt")==0||strcmp(prev_wd,"\\dt+")==0) |
| 2208 | +elseif (strncmp(prev_wd,"\\dt",strlen("\\dt"))==0) |
2221 | 2209 | COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables,NULL);
|
2222 |
| -elseif (strcmp(prev_wd,"\\dT")==0||strcmp(prev_wd,"\\dT+")==0) |
| 2210 | +elseif (strncmp(prev_wd,"\\dT",strlen("\\dT"))==0) |
2223 | 2211 | COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes,NULL);
|
2224 |
| -elseif (strcmp(prev_wd,"\\du")==0) |
| 2212 | +elseif (strncmp(prev_wd,"\\du",strlen("\\du"))==0) |
2225 | 2213 | COMPLETE_WITH_QUERY(Query_for_list_of_roles);
|
2226 |
| -elseif (strcmp(prev_wd,"\\dv")==0||strcmp(prev_wd,"\\dv+")==0) |
| 2214 | +elseif (strncmp(prev_wd,"\\dv",strlen("\\dv"))==0) |
2227 | 2215 | COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_views,NULL);
|
| 2216 | + |
| 2217 | +/* must be at end of \d list */ |
| 2218 | +elseif (strncmp(prev_wd,"\\d",strlen("\\d"))==0) |
| 2219 | +COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tisv,NULL); |
| 2220 | + |
2228 | 2221 | elseif (strcmp(prev_wd,"\\encoding")==0)
|
2229 | 2222 | COMPLETE_WITH_QUERY(Query_for_list_of_encodings);
|
2230 | 2223 | elseif (strcmp(prev_wd,"\\h")==0||strcmp(prev_wd,"\\help")==0)
|
|