Hi I am sending trivial patch, that enforce more precious tab complete for DROP POLICY statement
Regards Pavel
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c new file mode 100644 index 0683548..9596af6 *** a/src/bin/psql/tab-complete.c --- b/src/bin/psql/tab-complete.c *************** static const SchemaQuery Query_for_list_ *** 742,747 **** --- 742,760 ---- " FROM pg_catalog.pg_tablesample_method "\ " WHERE substring(pg_catalog.quote_ident(tsmname),1,%d)='%s'" + #define Query_for_list_of_policies \ + " SELECT pg_catalog.quote_ident(polname) "\ + " FROM pg_catalog.pg_policy " \ + " WHERE substring(pg_catalog.quote_ident(polname),1,%d)='%s'" + + #define Query_for_list_of_tables_for_policy \ + "SELECT pg_catalog.quote_ident(relname) "\ + " FROM pg_catalog.pg_class"\ + " WHERE (%d = pg_catalog.length('%s'))"\ + " AND oid IN "\ + " (SELECT polrelid FROM pg_catalog.pg_policy "\ + " WHERE pg_catalog.quote_ident(polname)='%s')" + /* * This is a list of all "things" in Pgsql, which can show up after CREATE or * DROP; and there is also a query to get a list of them. *************** psql_completion(const char *text, int st *** 2891,2905 **** COMPLETE_WITH_QUERY(Query_for_list_of_event_triggers); } /* DROP POLICY <name> ON */ else if (pg_strcasecmp(prev3_wd, "DROP") == 0 && pg_strcasecmp(prev2_wd, "POLICY") == 0) COMPLETE_WITH_CONST("ON"); /* DROP POLICY <name> ON <table> */ else if (pg_strcasecmp(prev4_wd, "DROP") == 0 && pg_strcasecmp(prev3_wd, "POLICY") == 0 && pg_strcasecmp(prev_wd, "ON") == 0) ! COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL); /* DROP RULE */ else if (pg_strcasecmp(prev3_wd, "DROP") == 0 && --- 2904,2929 ---- COMPLETE_WITH_QUERY(Query_for_list_of_event_triggers); } + /* DROP POLICY <name> */ + else if (pg_strcasecmp(prev2_wd, "DROP") == 0 && + pg_strcasecmp(prev_wd, "POLICY") == 0) + { + COMPLETE_WITH_QUERY(Query_for_list_of_policies); + } /* DROP POLICY <name> ON */ else if (pg_strcasecmp(prev3_wd, "DROP") == 0 && pg_strcasecmp(prev2_wd, "POLICY") == 0) + { COMPLETE_WITH_CONST("ON"); + } /* DROP POLICY <name> ON <table> */ else if (pg_strcasecmp(prev4_wd, "DROP") == 0 && pg_strcasecmp(prev3_wd, "POLICY") == 0 && pg_strcasecmp(prev_wd, "ON") == 0) ! { ! completion_info_charp = prev2_wd; ! COMPLETE_WITH_QUERY(Query_for_list_of_tables_for_policy); ! } /* DROP RULE */ else if (pg_strcasecmp(prev3_wd, "DROP") == 0 &&
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers