pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to extract information from pg_ddl_command type
2+ messages / 2 participants
[nested] [flat]

* How to extract information from pg_ddl_command type
@ 2019-07-11 07:27 Thomas Kellerer <spam_eater@gmx.net>
  2019-07-12 22:23 ` Re: How to extract information from pg_ddl_command type Alvaro Herrera <alvherre@2ndquadrant.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Thomas Kellerer @ 2019-07-11 07:27 UTC (permalink / raw)
  To: pgsql-general

The function pg_event_trigger_ddl_commands() returns several columns, one of them being "command" that is of the type "pg_ddl_command". 

The manual[1] describes this column as: 

> A complete representation of the command, in internal format. 
> This cannot be output directly, but it can be passed to other 
> functions to obtain different pieces of information about the 
> command.

However, I can not find any of those "other functions" to extract information from that column. 

My goal is to get the complete SQL text that fired the event trigger - is that even possible through pg_event_trigger_ddl_commands()? 

Thanks
Thomas

[1] https://www.postgresql.org/docs/current/functions-event-triggers.html






^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: How to extract information from pg_ddl_command type
  2019-07-11 07:27 How to extract information from pg_ddl_command type Thomas Kellerer <spam_eater@gmx.net>
@ 2019-07-12 22:23 ` Alvaro Herrera <alvherre@2ndquadrant.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Alvaro Herrera @ 2019-07-12 22:23 UTC (permalink / raw)
  To: Thomas Kellerer <spam_eater@gmx.net>; +Cc: pgsql-general

On 2019-Jul-11, Thomas Kellerer wrote:

> The function pg_event_trigger_ddl_commands() returns several columns, one of them being "command" that is of the type "pg_ddl_command". 
> 
> The manual[1] describes this column as: 
> 
> > A complete representation of the command, in internal format. 
> > This cannot be output directly, but it can be passed to other 
> > functions to obtain different pieces of information about the 
> > command.
> 
> However, I can not find any of those "other functions" to extract information from that column. 
> 
> My goal is to get the complete SQL text that fired the event trigger - is that even possible through pg_event_trigger_ddl_commands()? 

You need a C function.  See the test module in
src/test/modules/test_ddl_deparse -- it contains a very simple
implementation that doesn't really do a lot, but maybe it helps.  The
real meat of the thing is in an outdated module I wrote for 9.5.  I
think the latest version of that was posted by Alexander Shulgin in 2015
here
https://postgr.es/m/CACACo5Q_UXYwF117LBhjZ3xaMPyrgqnqE=mXvRhEfjJ51aCfwQ@mail.gmail.com
or maybe it's here
https://postgr.es/m/CACACo5QQuAV+n4Gi+YA1JF_a+QenR6SJuP8CYdPSrXKa+FHS3A@mail.gmail.com

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





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2019-07-12 22:23 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-07-11 07:27 How to extract information from pg_ddl_command type Thomas Kellerer <spam_eater@gmx.net>
2019-07-12 22:23 ` Alvaro Herrera <alvherre@2ndquadrant.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox