Re: deparsing utility commands

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: deparsing utility commands
Date: 2015-04-09 16:14:19
Message-ID: 20150409161419.GC4369@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera wrote:
> Executive summary:
>
> There is now a CommandDeparse_hook;
> deparse_utility_command is provided as an extension, intended for 9.6;
> rest of patch would be pushed to 9.5.

Actually here's another approach I like better: use a new pseudotype,
pg_ddl_command, which internally is just a pointer to a CollectedCommand
struct. We cannot give access to the pointer directly in SQL, so much
like type internal or pg_node_tree the in/out functions should just
error out. But the type can be returned as a column in
pg_event_trigger_ddl_command. An extension can create a function that
receives that type as argument, and return a different representation of
the command; the third patch creates a function ddl_deparse_to_json()
which does that.

You can have as many extensions as you want, and your event triggers can
use the column as many times as necessary. This removes the limitation
of the previous approach that you could only have a single extension
providing a CommandDeparse_hook function.

This patch applies cleanly on top of current master. You need to
install the extension with "CREATE EXTENSION ddl_deparse" after building
it in contrib.

Note: the extension is NOT to be committed to core, only the first two
patches; that will give us more room to revisit the JSON representation
more promptly. My intention is that the extension will be published
elsewhere.

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
0001-deparse-infrastructure-needed-for-command-deparsing.patch text/x-diff 68.4 KB
0002-changes-to-core-to-support-the-deparse-extension.patch text/x-diff 30.4 KB
0003-ddl_deparse-extension.patch text/x-diff 231.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sawada Masahiko 2015-04-09 17:52:39 Re: Proposal : REINDEX xxx VERBOSE
Previous Message Stephen Frost 2015-04-09 16:07:39 Re: FPW compression leaks information