diff options
author | Robert Haas <rhaas@postgresql.org> | 2012-07-18 10:16:16 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2012-07-18 10:16:16 -0400 |
commit | 3855968f328918b6cd1401dd11d109d471a54d40 (patch) | |
tree | 37cf34023851c0c3d14f30b4833937cfaeb2fa34 /src/bin/psql | |
parent | faf26bf1175530cc97ce3e804ff10dc2be7026d3 (diff) | |
download | postgresql-3855968f328918b6cd1401dd11d109d471a54d40.tar.gz postgresql-3855968f328918b6cd1401dd11d109d471a54d40.zip |
Syntax support and documentation for event triggers.
They don't actually do anything yet; that will get fixed in a
follow-on commit. But this gets the basic infrastructure in place,
including CREATE/ALTER/DROP EVENT TRIGGER; support for COMMENT,
SECURITY LABEL, and ALTER EXTENSION .. ADD/DROP EVENT TRIGGER;
pg_dump and psql support; and documentation for the anticipated
initial feature set.
Dimitri Fontaine, with review and a bunch of additional hacking by me.
Thom Brown extensively reviewed earlier versions of this patch set,
but there's not a whole lot of that code left in this commit, as it
turns out.
Diffstat (limited to 'src/bin/psql')
-rw-r--r-- | src/bin/psql/command.c | 3 | ||||
-rw-r--r-- | src/bin/psql/describe.c | 61 | ||||
-rw-r--r-- | src/bin/psql/describe.h | 3 | ||||
-rw-r--r-- | src/bin/psql/help.c | 1 |
4 files changed, 68 insertions, 0 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index c5ec9819ea1..8abadb26c49 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -490,6 +490,9 @@ exec_command(const char *cmd, else success = listExtensions(pattern); break; + case 'y': /* Event Triggers */ + success = listEventTriggers(pattern, show_verbose); + break; default: status = PSQL_CMD_UNKNOWN; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 9170dc6982a..14985ba0b10 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -2953,6 +2953,67 @@ listConversions(const char *pattern, bool verbose, bool showSystem) } /* + * \dy + * + * Describes Event Triggers. + */ +bool +listEventTriggers(const char *pattern, bool verbose) +{ + PQExpBufferData buf; + PGresult *res; + printQueryOpt myopt = pset.popt; + static const bool translate_columns[] = + {false, false, false, true, false, false, false}; + + initPQExpBuffer(&buf); + + printfPQExpBuffer(&buf, + "select evtname as \"%s\", " + "evtevent as \"%s\", " + "pg_catalog.pg_get_userbyid(e.evtowner) AS \"%s\", " + "case evtenabled when 'O' then 'enabled' " + " when 'R' then 'replica' " + " when 'A' then 'always' " + " when 'D' then 'disabled' end as \"%s\", " + "e.evtfoid::regproc as \"%s\", " + "array_to_string(array(select x " + " from unnest(evttags) as t(x)), ', ') as \"%s\" ", + gettext_noop("Name"), + gettext_noop("Event"), + gettext_noop("Owner"), + gettext_noop("Enabled"), + gettext_noop("Procedure"), + gettext_noop("Tags")); + if (verbose) + appendPQExpBuffer(&buf, + ",\npg_catalog.obj_description(e.oid, 'pg_event_trigger') as \"%s\"", + gettext_noop("Description")); + appendPQExpBuffer(&buf, + "\nFROM pg_event_trigger e "); + + processSQLNamePattern(pset.db, &buf, pattern, false, false, + NULL, "evtname", NULL, NULL); + + appendPQExpBuffer(&buf, "ORDER BY 1"); + + res = PSQLexec(buf.data, false); + termPQExpBuffer(&buf); + if (!res) + return false; + + myopt.nullPrint = NULL; + myopt.title = _("List of event triggers"); + myopt.translate_header = true; + myopt.translate_columns = translate_columns; + + printQuery(res, &myopt, pset.queryFout, pset.logfile); + + PQclear(res); + return true; +} + +/* * \dC * * Describes casts. diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h index 2b2ef21686a..eef7733833b 100644 --- a/src/bin/psql/describe.h +++ b/src/bin/psql/describe.h @@ -96,4 +96,7 @@ extern bool listExtensions(const char *pattern); /* \dx+ */ extern bool listExtensionContents(const char *pattern); +/* \dy */ +extern bool listEventTriggers(const char *pattern, bool verbose); + #endif /* DESCRIBE_H */ diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index 717d4cd10cf..3ebf7cc5262 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -229,6 +229,7 @@ slashUsage(unsigned short int pager) fprintf(output, _(" \\dv[S+] [PATTERN] list views\n")); fprintf(output, _(" \\dE[S+] [PATTERN] list foreign tables\n")); fprintf(output, _(" \\dx[+] [PATTERN] list extensions\n")); + fprintf(output, _(" \\dy [PATTERN] list event triggers\n")); fprintf(output, _(" \\l[+] list all databases\n")); fprintf(output, _(" \\sf[+] FUNCNAME show a function's definition\n")); fprintf(output, _(" \\z [PATTERN] same as \\dp\n")); |