mirror of
https://github.com/postgres/postgres.git
synced 2025-07-14 08:21:07 +03:00
Add support for ALTER RULE ... RENAME TO.
Ali Dar, reviewed by Dean Rasheed.
This commit is contained in:
@ -624,6 +624,15 @@ static const SchemaQuery Query_for_list_of_views = {
|
||||
" (SELECT conrelid FROM pg_catalog.pg_constraint "\
|
||||
" WHERE pg_catalog.quote_ident(conname)='%s')"
|
||||
|
||||
/* the silly-looking length condition is just to eat up the current word */
|
||||
#define Query_for_list_of_tables_for_rule \
|
||||
"SELECT pg_catalog.quote_ident(relname) "\
|
||||
" FROM pg_catalog.pg_class"\
|
||||
" WHERE (%d = pg_catalog.length('%s'))"\
|
||||
" AND oid IN "\
|
||||
" (SELECT ev_class FROM pg_catalog.pg_rewrite "\
|
||||
" WHERE pg_catalog.quote_ident(rulename)='%s')"
|
||||
|
||||
/* the silly-looking length condition is just to eat up the current word */
|
||||
#define Query_for_list_of_tables_for_trigger \
|
||||
"SELECT pg_catalog.quote_ident(relname) "\
|
||||
@ -925,7 +934,7 @@ psql_completion(char *text, int start, int end)
|
||||
{"AGGREGATE", "COLLATION", "CONVERSION", "DATABASE", "DEFAULT PRIVILEGES", "DOMAIN",
|
||||
"EXTENSION", "FOREIGN DATA WRAPPER", "FOREIGN TABLE", "FUNCTION",
|
||||
"GROUP", "INDEX", "LANGUAGE", "LARGE OBJECT", "OPERATOR",
|
||||
"ROLE", "SCHEMA", "SERVER", "SEQUENCE", "TABLE",
|
||||
"ROLE", "RULE", "SCHEMA", "SERVER", "SEQUENCE", "TABLE",
|
||||
"TABLESPACE", "TEXT SEARCH", "TRIGGER", "TYPE",
|
||||
"USER", "USER MAPPING FOR", "VIEW", NULL};
|
||||
|
||||
@ -1259,6 +1268,26 @@ psql_completion(char *text, int start, int end)
|
||||
|
||||
COMPLETE_WITH_LIST(list_ALTERVIEW);
|
||||
}
|
||||
|
||||
/* ALTER RULE <name>, add ON */
|
||||
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
|
||||
pg_strcasecmp(prev2_wd, "RULE") == 0)
|
||||
COMPLETE_WITH_CONST("ON");
|
||||
|
||||
/* If we have ALTER RULE <name> ON, then add the correct tablename */
|
||||
else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 &&
|
||||
pg_strcasecmp(prev3_wd, "RULE") == 0 &&
|
||||
pg_strcasecmp(prev_wd, "ON") == 0)
|
||||
{
|
||||
completion_info_charp = prev2_wd;
|
||||
COMPLETE_WITH_QUERY(Query_for_list_of_tables_for_rule);
|
||||
}
|
||||
|
||||
/* ALTER RULE <name> ON <name> */
|
||||
else if (pg_strcasecmp(prev5_wd, "ALTER") == 0 &&
|
||||
pg_strcasecmp(prev4_wd, "RULE") == 0)
|
||||
COMPLETE_WITH_CONST("RENAME TO");
|
||||
|
||||
/* ALTER TRIGGER <name>, add ON */
|
||||
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
|
||||
pg_strcasecmp(prev2_wd, "TRIGGER") == 0)
|
||||
|
Reference in New Issue
Block a user