mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-20 21:53:23 +02:00
This feature lets user code inspect and take action on DDL events. Whenever a ddl_command_end event trigger is installed, DDL actions executed are saved to a list which can be inspected during execution of a function attached to ddl_command_end. The set-returning function pg_event_trigger_ddl_commands can be used to list actions so captured; it returns data about the type of command executed, as well as the affected object. This is sufficient for many uses of this feature. For the cases where it is not, we also provide a "command" column of a new pseudo-type pg_ddl_command, which is a pointer to a C structure that can be accessed by C code. The struct contains all the info necessary to completely inspect and even reconstruct the executed command. There is no actual deparse code here; that's expected to come later. What we have is enough infrastructure that the deparsing can be done in an external extension. The intention is that we will add some deparsing code in a later release, as an in-core extension. A new test module is included. It's probably insufficient as is, but it should be sufficient as a starting point for a more complete and future-proof approach. Authors: Álvaro Herrera, with some help from Andres Freund, Ian Barwick, Abhijit Menon-Sen. Reviews by Andres Freund, Robert Haas, Amit Kapila, Michael Paquier, Craig Ringer, David Steele. Additional input from Chris Browne, Dimitri Fontaine, Stephen Frost, Petr Jelínek, Tom Lane, Jim Nasby, Steven Singer, Pavel Stěhule. Based on original work by Dimitri Fontaine, though I didn't use his code. Discussion: https://www.postgresql.org/message-id/m2txrsdzxa.fsf@2ndQuadrant.fr https://www.postgresql.org/message-id/20131108153322.GU5809@eldon.alvh.no-ip.org https://www.postgresql.org/message-id/20150215044814.GL3391@alvh.no-ip.org
46 lines
1.4 KiB
C
46 lines
1.4 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* aclchk_internal.h
|
|
*
|
|
* Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/utils/aclchk_internal.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef ACLCHK_INTERNAL_H
|
|
#define ACLCHK_INTERNAL_H
|
|
|
|
#include "nodes/parsenodes.h"
|
|
#include "nodes/pg_list.h"
|
|
|
|
/*
|
|
* The information about one Grant/Revoke statement, in internal format: object
|
|
* and grantees names have been turned into Oids, the privilege list is an
|
|
* AclMode bitmask. If 'privileges' is ACL_NO_RIGHTS (the 0 value) and
|
|
* all_privs is true, 'privileges' will be internally set to the right kind of
|
|
* ACL_ALL_RIGHTS_*, depending on the object type (NB - this will modify the
|
|
* InternalGrant struct!)
|
|
*
|
|
* Note: 'all_privs' and 'privileges' represent object-level privileges only.
|
|
* There might also be column-level privilege specifications, which are
|
|
* represented in col_privs (this is a list of untransformed AccessPriv nodes).
|
|
* Column privileges are only valid for objtype ACL_OBJECT_RELATION.
|
|
*/
|
|
typedef struct
|
|
{
|
|
bool is_grant;
|
|
GrantObjectType objtype;
|
|
List *objects;
|
|
bool all_privs;
|
|
AclMode privileges;
|
|
List *col_privs;
|
|
List *grantees;
|
|
bool grant_option;
|
|
DropBehavior behavior;
|
|
} InternalGrant;
|
|
|
|
|
|
#endif /* ACLCHK_INTERNAL_H */
|