{"Entry":{"collection":"hook","key":"fmgr_hook","name":"fmgr_hook","aliases":[],"metadata":{"aliases":[],"category":"Logging and function calls","content_hash":"4a575546e6f51fba9d5c8867a180462172240e1ba692cebdba7656cd970a59bb","derived_content_hash":"0911ed050fd16a1600e6ea8f4d00965163b243f8cf24a168e7a82e41d60b4c77","imported_at":"2026-09-27T17:57:58.842876+08:00","name":"fmgr_hook","name_zh":"fmgr_hook","repair_provenance":{"original_source_revision":"","receipt_sha256":"dc92c78532357277b11ff372fabf4d7892b2754d64fb44d9fb7bc10447821e2d","repair":"wiki-repair-20261023"},"slug":"fmgr_hook","source_rev":"wiki-repair-20261023:8e6226171e049bade4ad0b222a2f8af76505f4116407a6f499fd57d7ef30294b","summary":"function manager hook"}},"Definition":{"Collection":"hook","Key":"fmgr_hook","SourceDatabase":"center","Version":"18","SourceTable":"hook","SourceKey":"fmgr_hook","SourceRevision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","Facts":{"description":["function manager hook"],"description_zh":"函数管理器钩子。","description_zh_html":"\u003cp\u003e函数管理器钩子。\u003c/p\u003e\u003cp\u003e以下中文为本站依据所列 PostgreSQL 源码注释编译的说明。\u003c/p\u003e\u003ch3\u003e接口声明\u003c/h3\u003e\u003cpre\u003etypedef void (*fmgr_hook_type) (FmgrHookEventType event, FmgrInfo *flinfo, Datum *arg);\nextern PGDLLIMPORT fmgr_hook_type fmgr_hook;\u003c/pre\u003e\u003ch3\u003e调用位置\u003c/h3\u003e\u003cul\u003e\u003cli\u003e\u003ccode\u003esrc/backend/utils/fmgr/fmgr.c:731\u003c/code\u003e\u003c/li\u003e\u003cli\u003e\u003ccode\u003esrc/backend/utils/fmgr/fmgr.c:762\u003c/code\u003e\u003c/li\u003e\u003cli\u003e\u003ccode\u003esrc/backend/utils/fmgr/fmgr.c:774\u003c/code\u003e\u003c/li\u003e\u003c/ul\u003e\u003ch3\u003e核心调用上下文：src/backend/utils/fmgr/fmgr.c:725–739\u003c/h3\u003e\u003cpre\u003e\t\t\t\t\t\t\t\t\t  context, source, GetUserId(),\n\t\t\t\t\t\t\t\t\t  action, true, 0, false);\n\t}\n\n\t/* function manager hook */\n\tif (fmgr_hook)\n\t\t(*fmgr_hook) (FHET_START, \u0026amp;fcache-\u0026gt;flinfo, \u0026amp;fcache-\u0026gt;arg);\n\n\t/*\n\t * We don\u0026#x27;t need to restore GUC or userid settings on error, because the\n\t * ensuing xact or subxact abort will do that.  The PG_TRY block is only\n\t * needed to clean up the flinfo link.\n\t */\n\tsave_flinfo = fcinfo-\u0026gt;flinfo;\n\u003c/pre\u003e\u003ch3\u003e核心调用上下文：src/backend/utils/fmgr/fmgr.c:756–770\u003c/h3\u003e\u003cpre\u003e\t\t\t\t\t\t\t\t   ((ReturnSetInfo *) fcinfo-\u0026gt;resultinfo)-\u0026gt;isDone != ExprMultipleResult));\n\t}\n\tPG_CATCH();\n\t{\n\t\tfcinfo-\u0026gt;flinfo = save_flinfo;\n\t\tif (fmgr_hook)\n\t\t\t(*fmgr_hook) (FHET_ABORT, \u0026amp;fcache-\u0026gt;flinfo, \u0026amp;fcache-\u0026gt;arg);\n\t\tPG_RE_THROW();\n\t}\n\tPG_END_TRY();\n\n\tfcinfo-\u0026gt;flinfo = save_flinfo;\n\n\tif (fcache-\u0026gt;configNames != NIL)\n\t\tAtEOXact_GUC(true, save_nestlevel);\u003c/pre\u003e\u003ch3\u003e核心调用上下文：src/backend/utils/fmgr/fmgr.c:768–782\u003c/h3\u003e\u003cpre\u003e\n\tif (fcache-\u0026gt;configNames != NIL)\n\t\tAtEOXact_GUC(true, save_nestlevel);\n\tif (OidIsValid(fcache-\u0026gt;userid))\n\t\tSetUserIdAndSecContext(save_userid, save_sec_context);\n\tif (fmgr_hook)\n\t\t(*fmgr_hook) (FHET_END, \u0026amp;fcache-\u0026gt;flinfo, \u0026amp;fcache-\u0026gt;arg);\n\n\treturn result;\n}\n\n\n/*-------------------------------------------------------------------------\n *\t\tSupport routines for callers of fmgr-compatible functions\n *-------------------------------------------------------------------------\u003c/pre\u003e","facts":[{"label":"Interface type","value":"fmgr_hook_type"},{"label":"Header","value":"src/include/fmgr.h"},{"label":"Subsystem","value":"Logging and function calls"},{"label":"Initial value","value":"NULL (no hook installed)"}],"related":[],"release":{"channel":"stable","label":"18","major":"18","ref":"REL_18_STABLE","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd"},"sections":[{"paragraphs":["src/backend/utils/fmgr/fmgr.c:731","src/backend/utils/fmgr/fmgr.c:762","src/backend/utils/fmgr/fmgr.c:774"],"title":"Call sites"},{"code":"\t\t\t\t\t\t\t\t\t  context, source, GetUserId(),\n\t\t\t\t\t\t\t\t\t  action, true, 0, false);\n\t}\n\n\t/* function manager hook */\n\tif (fmgr_hook)\n\t\t(*fmgr_hook) (FHET_START, \u0026fcache-\u003eflinfo, \u0026fcache-\u003earg);\n\n\t/*\n\t * We don't need to restore GUC or userid settings on error, because the\n\t * ensuing xact or subxact abort will do that.  The PG_TRY block is only\n\t * needed to clean up the flinfo link.\n\t */\n\tsave_flinfo = fcinfo-\u003eflinfo;\n","paragraphs":[],"title":"Core call context: src/backend/utils/fmgr/fmgr.c:725–739"},{"code":"\t\t\t\t\t\t\t\t   ((ReturnSetInfo *) fcinfo-\u003eresultinfo)-\u003eisDone != ExprMultipleResult));\n\t}\n\tPG_CATCH();\n\t{\n\t\tfcinfo-\u003eflinfo = save_flinfo;\n\t\tif (fmgr_hook)\n\t\t\t(*fmgr_hook) (FHET_ABORT, \u0026fcache-\u003eflinfo, \u0026fcache-\u003earg);\n\t\tPG_RE_THROW();\n\t}\n\tPG_END_TRY();\n\n\tfcinfo-\u003eflinfo = save_flinfo;\n\n\tif (fcache-\u003econfigNames != NIL)\n\t\tAtEOXact_GUC(true, save_nestlevel);","paragraphs":[],"title":"Core call context: src/backend/utils/fmgr/fmgr.c:756–770"},{"code":"\n\tif (fcache-\u003econfigNames != NIL)\n\t\tAtEOXact_GUC(true, save_nestlevel);\n\tif (OidIsValid(fcache-\u003euserid))\n\t\tSetUserIdAndSecContext(save_userid, save_sec_context);\n\tif (fmgr_hook)\n\t\t(*fmgr_hook) (FHET_END, \u0026fcache-\u003eflinfo, \u0026fcache-\u003earg);\n\n\treturn result;\n}\n\n\n/*-------------------------------------------------------------------------\n *\t\tSupport routines for callers of fmgr-compatible functions\n *-------------------------------------------------------------------------","paragraphs":[],"title":"Core call context: src/backend/utils/fmgr/fmgr.c:768–782"}],"signature":"typedef void (*fmgr_hook_type) (FmgrHookEventType event, FmgrInfo *flinfo, Datum *arg);\nextern PGDLLIMPORT fmgr_hook_type fmgr_hook;","sources":[{"label":"Interface declaration","path":"src/include/fmgr.h","sha256":"9ae7c92915f702ee93be2b6aed3574edfeb7fb2effae8beb256665f307db961b","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/include/fmgr.h#L842"},{"label":"Core definition","path":"src/backend/utils/fmgr/fmgr.c","sha256":"6cec6e3c08f69e71bfaa67294ac6889c9278a7963e2c676de709782c0c594e75","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/fmgr/fmgr.c#L40"},{"label":"Call sites","path":"src/backend/utils/fmgr/fmgr.c","sha256":"6cec6e3c08f69e71bfaa67294ac6889c9278a7963e2c676de709782c0c594e75","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/fmgr/fmgr.c#L731"}],"translation_provenance":{"inputs":[{"label":"Interface declaration","path":"src/include/fmgr.h","sha256":"9ae7c92915f702ee93be2b6aed3574edfeb7fb2effae8beb256665f307db961b","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/include/fmgr.h#L842"},{"label":"Core definition","path":"src/backend/utils/fmgr/fmgr.c","sha256":"6cec6e3c08f69e71bfaa67294ac6889c9278a7963e2c676de709782c0c594e75","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/fmgr/fmgr.c#L40"},{"label":"Call sites","path":"src/backend/utils/fmgr/fmgr.c","sha256":"6cec6e3c08f69e71bfaa67294ac6889c9278a7963e2c676de709782c0c594e75","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/fmgr/fmgr.c#L731"}],"kind":"authored-source-translation","locale":"zh-Hans","source_revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","translated_source_sha256":"d2b63d6c6383ac9c1397b0f759e14613112fb043bb573d78052a13e4aee027c5","version":"18"},"zh_from":"authored-source-translation"},"ManualEvidence":{"release":{"channel":"stable","label":"18","major":"18","ref":"REL_18_STABLE","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd"},"sources":[{"label":"Interface declaration","path":"src/include/fmgr.h","sha256":"9ae7c92915f702ee93be2b6aed3574edfeb7fb2effae8beb256665f307db961b","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/include/fmgr.h#L842"},{"label":"Core definition","path":"src/backend/utils/fmgr/fmgr.c","sha256":"6cec6e3c08f69e71bfaa67294ac6889c9278a7963e2c676de709782c0c594e75","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/fmgr/fmgr.c#L40"},{"label":"Call sites","path":"src/backend/utils/fmgr/fmgr.c","sha256":"6cec6e3c08f69e71bfaa67294ac6889c9278a7963e2c676de709782c0c594e75","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/fmgr/fmgr.c#L731"}]},"MeasuredEvidence":{}},"Text":{"Collection":"hook","Key":"fmgr_hook","SourceDatabase":"center","Version":"18","Locale":"en","Title":"fmgr_hook","Summary":"function manager hook","BodyHTML":"\u003cp\u003efunction manager hook\u003c/p\u003e","SourceRevision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","ContentHash":"af543dbd6960b9ec9e72ff8a9b50f849c801af9b94d951e439587a850e2ec16d","Payload":{"description":["function manager hook"],"related":[],"sections":[{"paragraphs":["src/backend/utils/fmgr/fmgr.c:731","src/backend/utils/fmgr/fmgr.c:762","src/backend/utils/fmgr/fmgr.c:774"],"title":"Call sites"},{"code":"\t\t\t\t\t\t\t\t\t  context, source, GetUserId(),\n\t\t\t\t\t\t\t\t\t  action, true, 0, false);\n\t}\n\n\t/* function manager hook */\n\tif (fmgr_hook)\n\t\t(*fmgr_hook) (FHET_START, \u0026fcache-\u003eflinfo, \u0026fcache-\u003earg);\n\n\t/*\n\t * We don't need to restore GUC or userid settings on error, because the\n\t * ensuing xact or subxact abort will do that.  The PG_TRY block is only\n\t * needed to clean up the flinfo link.\n\t */\n\tsave_flinfo = fcinfo-\u003eflinfo;\n","paragraphs":[],"title":"Core call context: src/backend/utils/fmgr/fmgr.c:725–739"},{"code":"\t\t\t\t\t\t\t\t   ((ReturnSetInfo *) fcinfo-\u003eresultinfo)-\u003eisDone != ExprMultipleResult));\n\t}\n\tPG_CATCH();\n\t{\n\t\tfcinfo-\u003eflinfo = save_flinfo;\n\t\tif (fmgr_hook)\n\t\t\t(*fmgr_hook) (FHET_ABORT, \u0026fcache-\u003eflinfo, \u0026fcache-\u003earg);\n\t\tPG_RE_THROW();\n\t}\n\tPG_END_TRY();\n\n\tfcinfo-\u003eflinfo = save_flinfo;\n\n\tif (fcache-\u003econfigNames != NIL)\n\t\tAtEOXact_GUC(true, save_nestlevel);","paragraphs":[],"title":"Core call context: src/backend/utils/fmgr/fmgr.c:756–770"},{"code":"\n\tif (fcache-\u003econfigNames != NIL)\n\t\tAtEOXact_GUC(true, save_nestlevel);\n\tif (OidIsValid(fcache-\u003euserid))\n\t\tSetUserIdAndSecContext(save_userid, save_sec_context);\n\tif (fmgr_hook)\n\t\t(*fmgr_hook) (FHET_END, \u0026fcache-\u003eflinfo, \u0026fcache-\u003earg);\n\n\treturn result;\n}\n\n\n/*-------------------------------------------------------------------------\n *\t\tSupport routines for callers of fmgr-compatible functions\n *-------------------------------------------------------------------------","paragraphs":[],"title":"Core call context: src/backend/utils/fmgr/fmgr.c:768–782"}]}},"RequestedLocale":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
