↑↓ select ↵ open ⌫ change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Documentation / Extension Hooks / Logging and function calls

fmgr_hook

fmgr_hook

function manager hook

Reading PostgreSQL 18.

Description

function manager hook

Interface type
fmgr_hook_type
Header
src/include/fmgr.h
Subsystem
Logging and function calls
Initial value
NULL (no hook installed)

C interface

typedef void (*fmgr_hook_type) (FmgrHookEventType event, FmgrInfo *flinfo, Datum *arg);
extern PGDLLIMPORT fmgr_hook_type fmgr_hook;

Call sites

src/backend/utils/fmgr/fmgr.c:731

src/backend/utils/fmgr/fmgr.c:762

src/backend/utils/fmgr/fmgr.c:774

Core call context: src/backend/utils/fmgr/fmgr.c:725–739

									  context, source, GetUserId(),
									  action, true, 0, false);
	}

	/* function manager hook */
	if (fmgr_hook)
		(*fmgr_hook) (FHET_START, &fcache->flinfo, &fcache->arg);

	/*
	 * We don't need to restore GUC or userid settings on error, because the
	 * ensuing xact or subxact abort will do that.  The PG_TRY block is only
	 * needed to clean up the flinfo link.
	 */
	save_flinfo = fcinfo->flinfo;

Core call context: src/backend/utils/fmgr/fmgr.c:756–770

								   ((ReturnSetInfo *) fcinfo->resultinfo)->isDone != ExprMultipleResult));
	}
	PG_CATCH();
	{
		fcinfo->flinfo = save_flinfo;
		if (fmgr_hook)
			(*fmgr_hook) (FHET_ABORT, &fcache->flinfo, &fcache->arg);
		PG_RE_THROW();
	}
	PG_END_TRY();

	fcinfo->flinfo = save_flinfo;

	if (fcache->configNames != NIL)
		AtEOXact_GUC(true, save_nestlevel);

Core call context: src/backend/utils/fmgr/fmgr.c:768–782


	if (fcache->configNames != NIL)
		AtEOXact_GUC(true, save_nestlevel);
	if (OidIsValid(fcache->userid))
		SetUserIdAndSecContext(save_userid, save_sec_context);
	if (fmgr_hook)
		(*fmgr_hook) (FHET_END, &fcache->flinfo, &fcache->arg);

	return result;
}


/*-------------------------------------------------------------------------
 *		Support routines for callers of fmgr-compatible functions
 *-------------------------------------------------------------------------

Documentation and source

Source build
Version
18
Build
REL_18_STABLE
Source fingerprint
753057e340da8f22e57c9a409ea7a235fd6a46bd

Related entries

Back to Extension Hooks · Recorded in PostgreSQL 10 through 20; the first sample is not necessarily its introduction.