mirror of
https://github.com/postgres/postgres.git
synced 2025-07-26 01:22:12 +03:00
Add a hook to let loadable modules get control at ProcessUtility execution,
and use it to extend contrib/pg_stat_statements to track utility commands. Itagaki Takahiro, reviewed by Euler Taveira de Oliveira.
This commit is contained in:
@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.323 2009/12/11 03:34:55 itagaki Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.324 2009/12/15 20:04:49 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -58,6 +58,10 @@
|
||||
#include "utils/syscache.h"
|
||||
|
||||
|
||||
/* Hook for plugins to get control in ProcessUtility() */
|
||||
ProcessUtility_hook_type ProcessUtility_hook = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* Verify user has ownership of specified relation, else ereport.
|
||||
*
|
||||
@ -274,6 +278,27 @@ ProcessUtility(Node *parsetree,
|
||||
{
|
||||
Assert(queryString != NULL); /* required as of 8.4 */
|
||||
|
||||
/*
|
||||
* We provide a function hook variable that lets loadable plugins
|
||||
* get control when ProcessUtility is called. Such a plugin would
|
||||
* normally call standard_ProcessUtility().
|
||||
*/
|
||||
if (ProcessUtility_hook)
|
||||
(*ProcessUtility_hook) (parsetree, queryString, params,
|
||||
isTopLevel, dest, completionTag);
|
||||
else
|
||||
standard_ProcessUtility(parsetree, queryString, params,
|
||||
isTopLevel, dest, completionTag);
|
||||
}
|
||||
|
||||
void
|
||||
standard_ProcessUtility(Node *parsetree,
|
||||
const char *queryString,
|
||||
ParamListInfo params,
|
||||
bool isTopLevel,
|
||||
DestReceiver *dest,
|
||||
char *completionTag)
|
||||
{
|
||||
check_xact_readonly(parsetree);
|
||||
|
||||
if (completionTag)
|
||||
|
Reference in New Issue
Block a user