Re: Patch: add psql tab completion for event triggers

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Ian Barwick <ian(at)2ndquadrant(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Patch: add psql tab completion for event triggers
Date: 2014-04-09 15:23:41
Message-ID: CA+TgmoaQSgRf+YhQRDZzEcWw2d1nKe9qD=uu8hmR=2czgRLuTg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Apr 8, 2014 at 5:27 AM, Ian Barwick <ian(at)2ndquadrant(dot)com> wrote:
> On 08/04/14 18:22, Ian Barwick wrote:
>>
>> As it was kind of annoying not to have this when playing around with
>> event triggers.
>>
>> This also tightens up the existing tab completion for ALTER TRIGGER,
>> which contained redundant code for table name completion, and which was
>> also causing a spurious "RENAME TO" to be inserted in this context:
>>
>> CREATE EVENT TRIGGER foo ON {event} ^I
>
>
> Apologies, previous patch had some unrelated changes in it.
>
> Correct patch attached.

This *still* has some unrelated things in it, like s/Pgsql/Postgres/,
and numerous hunks consisting entirely of whitespace changes and/or
changes to unrelated comments.

Also, what's the point of this hunk:

*************** psql_completion(const char *text, int st
*** 1318,1340 ****
pg_strcasecmp(prev2_wd, "TRIGGER") == 0)
COMPLETE_WITH_CONST("ON");

- else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 &&
- pg_strcasecmp(prev3_wd, "TRIGGER") == 0)
- {
- completion_info_charp = prev2_wd;
- COMPLETE_WITH_QUERY(Query_for_list_of_tables_for_trigger);
- }
-
/*
! * If we have ALTER TRIGGER <sth> ON, then add the correct tablename
*/
else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 &&
pg_strcasecmp(prev3_wd, "TRIGGER") == 0 &&
pg_strcasecmp(prev_wd, "ON") == 0)
! COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);

/* ALTER TRIGGER <name> ON <name> */
! else if (pg_strcasecmp(prev4_wd, "TRIGGER") == 0 &&
pg_strcasecmp(prev2_wd, "ON") == 0)
COMPLETE_WITH_CONST("RENAME TO");

--- 1355,1374 ----
pg_strcasecmp(prev2_wd, "TRIGGER") == 0)
COMPLETE_WITH_CONST("ON");

/*
! * If we have ALTER TRIGGER <name> ON, then add the correct tablename
*/
else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 &&
pg_strcasecmp(prev3_wd, "TRIGGER") == 0 &&
pg_strcasecmp(prev_wd, "ON") == 0)
! {
! completion_info_charp = prev2_wd;
! COMPLETE_WITH_QUERY(Query_for_list_of_tables_for_trigger);
! }

/* ALTER TRIGGER <name> ON <name> */
! else if (pg_strcasecmp(prev5_wd, "ALTER") == 0 &&
! pg_strcasecmp(prev4_wd, "TRIGGER") == 0 &&
pg_strcasecmp(prev2_wd, "ON") == 0)
COMPLETE_WITH_CONST("RENAME TO");

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-04-09 15:24:16 Re: default opclass for jsonb (was Re: Call for GIST/GIN/SP-GIST opclass documentation)
Previous Message Robert Haas 2014-04-09 15:16:13 Re: default opclass for jsonb (was Re: Call for GIST/GIN/SP-GIST opclass documentation)