You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve tab-completion of DROP and ALTER ENABLE/DISABLE on triggers and rules.
At "DROP RULE/TRIGGER triggername ON ...", tab-complete tables that have
a rule/trigger with that name.
At "ALTER TABLE tablename ENABLE/DISABLE TRIGGER/RULE ...", tab-complete to
rules/triggers on that table. Previously, we would tab-complete to all
rules or triggers, not just those that are on that table.
Also, filter out internal RI triggers from the list. You can't DROP them,
and enabling/disabling them is such a rare (and dangerous) operation that
it seems better to hide them.
Andreas Karlsson, reviewed by Ian Barwick.
{"TRIGGER", "SELECT pg_catalog.quote_ident(tgname) FROM pg_catalog.pg_trigger WHERE substring(pg_catalog.quote_ident(tgname),1,%d)='%s'"},
794
+
{"TRIGGER", "SELECT pg_catalog.quote_ident(tgname) FROM pg_catalog.pg_trigger WHERE substring(pg_catalog.quote_ident(tgname),1,%d)='%s' AND NOT tgisinternal"},
778
795
{"TYPE", NULL, &Query_for_list_of_datatypes},
779
796
{"UNIQUE", NULL, NULL, THING_NO_DROP}, /* for CREATE UNIQUE INDEX ... */
780
797
{"UNLOGGED", NULL, NULL, THING_NO_DROP}, /* for CREATE UNLOGGED TABLE
@@ -1409,6 +1426,38 @@ psql_completion(const char *text, int start, int end)
1409
1426
1410
1427
COMPLETE_WITH_LIST(list_ALTERENABLE2);
1411
1428
}
1429
+
elseif (pg_strcasecmp(prev5_wd, "ALTER") ==0&&
1430
+
pg_strcasecmp(prev4_wd, "TABLE") ==0&&
1431
+
pg_strcasecmp(prev2_wd, "ENABLE") ==0&&
1432
+
pg_strcasecmp(prev_wd, "RULE") ==0)
1433
+
{
1434
+
completion_info_charp=prev3_wd;
1435
+
COMPLETE_WITH_QUERY(Query_for_rule_of_table);
1436
+
}
1437
+
elseif (pg_strcasecmp(prev6_wd, "ALTER") ==0&&
1438
+
pg_strcasecmp(prev5_wd, "TABLE") ==0&&
1439
+
pg_strcasecmp(prev3_wd, "ENABLE") ==0&&
1440
+
pg_strcasecmp(prev_wd, "RULE") ==0)
1441
+
{
1442
+
completion_info_charp=prev4_wd;
1443
+
COMPLETE_WITH_QUERY(Query_for_rule_of_table);
1444
+
}
1445
+
elseif (pg_strcasecmp(prev5_wd, "ALTER") ==0&&
1446
+
pg_strcasecmp(prev4_wd, "TABLE") ==0&&
1447
+
pg_strcasecmp(prev2_wd, "ENABLE") ==0&&
1448
+
pg_strcasecmp(prev_wd, "TRIGGER") ==0)
1449
+
{
1450
+
completion_info_charp=prev3_wd;
1451
+
COMPLETE_WITH_QUERY(Query_for_trigger_of_table);
1452
+
}
1453
+
elseif (pg_strcasecmp(prev6_wd, "ALTER") ==0&&
1454
+
pg_strcasecmp(prev5_wd, "TABLE") ==0&&
1455
+
pg_strcasecmp(prev3_wd, "ENABLE") ==0&&
1456
+
pg_strcasecmp(prev_wd, "TRIGGER") ==0)
1457
+
{
1458
+
completion_info_charp=prev4_wd;
1459
+
COMPLETE_WITH_QUERY(Query_for_trigger_of_table);
1460
+
}
1412
1461
/* ALTER TABLE xxx INHERIT */
1413
1462
elseif (pg_strcasecmp(prev4_wd, "ALTER") ==0&&
1414
1463
pg_strcasecmp(prev3_wd, "TABLE") ==0&&
@@ -1424,6 +1473,7 @@ psql_completion(const char *text, int start, int end)
0 commit comments