mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +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)
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/tcop/utility.h,v 1.37 2009/12/01 02:31:13 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/tcop/utility.h,v 1.38 2009/12/15 20:04:49 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -17,9 +17,18 @@
|
||||
#include "tcop/tcopprot.h"
|
||||
|
||||
|
||||
/* Hook for plugins to get control in ProcessUtility() */
|
||||
typedef void (*ProcessUtility_hook_type) (Node *parsetree,
|
||||
const char *queryString, ParamListInfo params, bool isTopLevel,
|
||||
DestReceiver *dest, char *completionTag);
|
||||
extern PGDLLIMPORT ProcessUtility_hook_type ProcessUtility_hook;
|
||||
|
||||
extern void ProcessUtility(Node *parsetree, const char *queryString,
|
||||
ParamListInfo params, bool isTopLevel,
|
||||
DestReceiver *dest, char *completionTag);
|
||||
extern void standard_ProcessUtility(Node *parsetree, const char *queryString,
|
||||
ParamListInfo params, bool isTopLevel,
|
||||
DestReceiver *dest, char *completionTag);
|
||||
|
||||
extern bool UtilityReturnsTuples(Node *parsetree);
|
||||
|
||||
|
Reference in New Issue
Block a user