{"Entry":{"collection":"hook","key":"get_index_stats_hook","name":"get_index_stats_hook","aliases":[],"metadata":{"aliases":[],"category":"Statistics and estimation","content_hash":"75ec4070d6d5bac73b854afef4a4ff4904e32538dfce309120c0361d4caad41f","derived_content_hash":"105fae08ec2387e616340a52f505ad9460edb3e516802a25be26ee7198902a75","imported_at":"2026-09-27T17:57:58.89592+08:00","name":"get_index_stats_hook","name_zh":"get_index_stats_hook","repair_provenance":{"original_source_revision":"","receipt_sha256":"20a0a65e8fc782c606968e2a63e868b1b8bc52d09744dbaaa4d4afde8494be67","repair":"wiki-repair-20261023"},"slug":"get_index_stats_hook","source_rev":"wiki-repair-20261023:d81344f75461ffa99da2c695d4c6fbf70f155c011719e72ab393e1ead90f33d8","summary":"get_index_stats_hook: core extension hook declared in src/include/utils/selfuncs.h. The exact interface and call sites are recorded below."}},"Definition":{"Collection":"hook","Key":"get_index_stats_hook","SourceDatabase":"center","Version":"18","SourceTable":"hook","SourceKey":"get_index_stats_hook","SourceRevision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","Facts":{"description":["get_index_stats_hook: core extension hook declared in src/include/utils/selfuncs.h. The exact interface and call sites are recorded below."],"description_zh":"get_index_stats_hook 是在 src/include/utils/selfuncs.h 中声明的核心扩展钩子。下方保留精确接口与调用位置。","description_zh_html":"\u003cp\u003eget_index_stats_hook 是在 src/include/utils/selfuncs.h 中声明的核心扩展钩子。下方保留精确接口与调用位置。\u003c/p\u003e\u003cp\u003e以下中文为本站依据所列 PostgreSQL 源码注释编译的说明。\u003c/p\u003e\u003ch3\u003e接口声明\u003c/h3\u003e\u003cpre\u003etypedef bool (*get_index_stats_hook_type) (PlannerInfo *root, Oid indexOid, AttrNumber indexattnum, VariableStatData *vardata);\nextern PGDLLIMPORT get_index_stats_hook_type get_index_stats_hook;\u003c/pre\u003e\u003ch3\u003e调用位置\u003c/h3\u003e\u003cul\u003e\u003cli\u003e\u003ccode\u003esrc/backend/utils/adt/selfuncs.c:5488\u003c/code\u003e\u003c/li\u003e\u003cli\u003e\u003ccode\u003esrc/backend/utils/adt/selfuncs.c:6224\u003c/code\u003e\u003c/li\u003e\u003cli\u003e\u003ccode\u003esrc/backend/utils/adt/selfuncs.c:8783\u003c/code\u003e\u003c/li\u003e\u003c/ul\u003e\u003ch3\u003e核心调用上下文：src/backend/utils/adt/selfuncs.c:5482–5496\u003c/h3\u003e\u003cpre\u003e\t\t\t\t\t\t * a partial index.\n\t\t\t\t\t\t *\n\t\t\t\t\t\t * An index stats hook, however, must make its own\n\t\t\t\t\t\t * decisions about what to do with partial indexes.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tif (get_index_stats_hook \u0026amp;\u0026amp;\n\t\t\t\t\t\t\t(*get_index_stats_hook) (root, index-\u0026gt;indexoid,\n\t\t\t\t\t\t\t\t\t\t\t\t\t pos + 1, vardata))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t/*\n\t\t\t\t\t\t\t * The hook took control of acquiring a stats\n\t\t\t\t\t\t\t * tuple.  If it did supply a tuple, it\u0026#x27;d better\n\t\t\t\t\t\t\t * have supplied a freefunc.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tif (HeapTupleIsValid(vardata-\u0026gt;statsTuple) \u0026amp;\u0026amp;\u003c/pre\u003e\u003ch3\u003e核心调用上下文：src/backend/utils/adt/selfuncs.c:6218–6232\u003c/h3\u003e\u003cpre\u003e\t{\n\t\t/* Expression --- maybe there are stats for the index itself */\n\t\trelid = index-\u0026gt;indexoid;\n\t\tcolnum = indexcol + 1;\n\n\t\tif (get_index_stats_hook \u0026amp;\u0026amp;\n\t\t\t(*get_index_stats_hook) (root, relid, colnum, vardata))\n\t\t{\n\t\t\t/*\n\t\t\t * The hook took control of acquiring a stats tuple.  If it did\n\t\t\t * supply a tuple, it\u0026#x27;d better have supplied a freefunc.\n\t\t\t */\n\t\t\tif (HeapTupleIsValid(vardata-\u0026gt;statsTuple) \u0026amp;\u0026amp;\n\t\t\t\t!vardata-\u0026gt;freefunc)\n\t\t\t\telog(ERROR, \u0026quot;no function provided to release variable stats with\u0026quot;);\u003c/pre\u003e\u003ch3\u003e核心调用上下文：src/backend/utils/adt/selfuncs.c:8777–8791\u003c/h3\u003e\u003cpre\u003e\t\t\t */\n\n\t\t\t/* get the attnum from the 0-based index. */\n\t\t\tattnum = iclause-\u0026gt;indexcol + 1;\n\n\t\t\tif (get_index_stats_hook \u0026amp;\u0026amp;\n\t\t\t\t(*get_index_stats_hook) (root, index-\u0026gt;indexoid, attnum, \u0026amp;vardata))\n\t\t\t{\n\t\t\t\t/*\n\t\t\t\t * The hook took control of acquiring a stats tuple.  If it\n\t\t\t\t * did supply a tuple, it\u0026#x27;d better have supplied a freefunc.\n\t\t\t\t */\n\t\t\t\tif (HeapTupleIsValid(vardata.statsTuple) \u0026amp;\u0026amp;\n\t\t\t\t\t!vardata.freefunc)\n\t\t\t\t\telog(ERROR, \u0026quot;no function provided to release variable stats with\u0026quot;);\u003c/pre\u003e","facts":[{"label":"Interface type","value":"get_index_stats_hook_type"},{"label":"Header","value":"src/include/utils/selfuncs.h"},{"label":"Subsystem","value":"Statistics and estimation"},{"label":"Initial value","value":"NULL (no hook installed)"}],"related":[{"label":"The Planner/Optimizer","url":"/docs/18/planner-optimizer.html"}],"release":{"channel":"stable","label":"18","major":"18","ref":"REL_18_STABLE","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd"},"sections":[{"paragraphs":["src/backend/utils/adt/selfuncs.c:5488","src/backend/utils/adt/selfuncs.c:6224","src/backend/utils/adt/selfuncs.c:8783"],"title":"Call sites"},{"code":"\t\t\t\t\t\t * a partial index.\n\t\t\t\t\t\t *\n\t\t\t\t\t\t * An index stats hook, however, must make its own\n\t\t\t\t\t\t * decisions about what to do with partial indexes.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tif (get_index_stats_hook \u0026\u0026\n\t\t\t\t\t\t\t(*get_index_stats_hook) (root, index-\u003eindexoid,\n\t\t\t\t\t\t\t\t\t\t\t\t\t pos + 1, vardata))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t/*\n\t\t\t\t\t\t\t * The hook took control of acquiring a stats\n\t\t\t\t\t\t\t * tuple.  If it did supply a tuple, it'd better\n\t\t\t\t\t\t\t * have supplied a freefunc.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tif (HeapTupleIsValid(vardata-\u003estatsTuple) \u0026\u0026","paragraphs":[],"title":"Core call context: src/backend/utils/adt/selfuncs.c:5482–5496"},{"code":"\t{\n\t\t/* Expression --- maybe there are stats for the index itself */\n\t\trelid = index-\u003eindexoid;\n\t\tcolnum = indexcol + 1;\n\n\t\tif (get_index_stats_hook \u0026\u0026\n\t\t\t(*get_index_stats_hook) (root, relid, colnum, vardata))\n\t\t{\n\t\t\t/*\n\t\t\t * The hook took control of acquiring a stats tuple.  If it did\n\t\t\t * supply a tuple, it'd better have supplied a freefunc.\n\t\t\t */\n\t\t\tif (HeapTupleIsValid(vardata-\u003estatsTuple) \u0026\u0026\n\t\t\t\t!vardata-\u003efreefunc)\n\t\t\t\telog(ERROR, \"no function provided to release variable stats with\");","paragraphs":[],"title":"Core call context: src/backend/utils/adt/selfuncs.c:6218–6232"},{"code":"\t\t\t */\n\n\t\t\t/* get the attnum from the 0-based index. */\n\t\t\tattnum = iclause-\u003eindexcol + 1;\n\n\t\t\tif (get_index_stats_hook \u0026\u0026\n\t\t\t\t(*get_index_stats_hook) (root, index-\u003eindexoid, attnum, \u0026vardata))\n\t\t\t{\n\t\t\t\t/*\n\t\t\t\t * The hook took control of acquiring a stats tuple.  If it\n\t\t\t\t * did supply a tuple, it'd better have supplied a freefunc.\n\t\t\t\t */\n\t\t\t\tif (HeapTupleIsValid(vardata.statsTuple) \u0026\u0026\n\t\t\t\t\t!vardata.freefunc)\n\t\t\t\t\telog(ERROR, \"no function provided to release variable stats with\");","paragraphs":[],"title":"Core call context: src/backend/utils/adt/selfuncs.c:8777–8791"}],"signature":"typedef bool (*get_index_stats_hook_type) (PlannerInfo *root, Oid indexOid, AttrNumber indexattnum, VariableStatData *vardata);\nextern PGDLLIMPORT get_index_stats_hook_type get_index_stats_hook;","sources":[{"label":"Interface declaration","path":"src/include/utils/selfuncs.h","sha256":"a3b64e2dd2d41eab2c162a2571bfbe98fac83ae9fab514b73d637220157a501a","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/include/utils/selfuncs.h#L147"},{"label":"Core definition","path":"src/backend/utils/adt/selfuncs.c","sha256":"c51b0d3f9c9015e98278241c8efc28c39739a56337ffec1163427b3876170f19","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/adt/selfuncs.c#L149"},{"label":"Call sites","path":"src/backend/utils/adt/selfuncs.c","sha256":"c51b0d3f9c9015e98278241c8efc28c39739a56337ffec1163427b3876170f19","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/adt/selfuncs.c#L5488"}],"translation_provenance":{"inputs":[{"label":"Interface declaration","path":"src/include/utils/selfuncs.h","sha256":"a3b64e2dd2d41eab2c162a2571bfbe98fac83ae9fab514b73d637220157a501a","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/include/utils/selfuncs.h#L147"},{"label":"Core definition","path":"src/backend/utils/adt/selfuncs.c","sha256":"c51b0d3f9c9015e98278241c8efc28c39739a56337ffec1163427b3876170f19","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/adt/selfuncs.c#L149"},{"label":"Call sites","path":"src/backend/utils/adt/selfuncs.c","sha256":"c51b0d3f9c9015e98278241c8efc28c39739a56337ffec1163427b3876170f19","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/adt/selfuncs.c#L5488"}],"kind":"authored-source-translation","locale":"zh-Hans","source_revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","translated_source_sha256":"b5407db9f99e77f5a99d4fb571d60dc9bdaff42168c7a9125f4b30796109b6e8","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/utils/selfuncs.h","sha256":"a3b64e2dd2d41eab2c162a2571bfbe98fac83ae9fab514b73d637220157a501a","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/include/utils/selfuncs.h#L147"},{"label":"Core definition","path":"src/backend/utils/adt/selfuncs.c","sha256":"c51b0d3f9c9015e98278241c8efc28c39739a56337ffec1163427b3876170f19","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/adt/selfuncs.c#L149"},{"label":"Call sites","path":"src/backend/utils/adt/selfuncs.c","sha256":"c51b0d3f9c9015e98278241c8efc28c39739a56337ffec1163427b3876170f19","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/adt/selfuncs.c#L5488"}]},"MeasuredEvidence":{}},"Text":{"Collection":"hook","Key":"get_index_stats_hook","SourceDatabase":"center","Version":"18","Locale":"en","Title":"get_index_stats_hook","Summary":"get_index_stats_hook: core extension hook declared in src/include/utils/selfuncs.h. The exact interface and call sites are recorded below.","BodyHTML":"\u003cp\u003eget_index_stats_hook: core extension hook declared in src/include/utils/selfuncs.h. The exact interface and call sites are recorded below.\u003c/p\u003e","SourceRevision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","ContentHash":"1ce7920410c8b91d7f3fc228ad110a53186628beacffbe909d81f95db0ea95c2","Payload":{"description":["get_index_stats_hook: core extension hook declared in src/include/utils/selfuncs.h. The exact interface and call sites are recorded below."],"related":[{"label":"The Planner/Optimizer","url":"/docs/18/planner-optimizer.html"}],"sections":[{"paragraphs":["src/backend/utils/adt/selfuncs.c:5488","src/backend/utils/adt/selfuncs.c:6224","src/backend/utils/adt/selfuncs.c:8783"],"title":"Call sites"},{"code":"\t\t\t\t\t\t * a partial index.\n\t\t\t\t\t\t *\n\t\t\t\t\t\t * An index stats hook, however, must make its own\n\t\t\t\t\t\t * decisions about what to do with partial indexes.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tif (get_index_stats_hook \u0026\u0026\n\t\t\t\t\t\t\t(*get_index_stats_hook) (root, index-\u003eindexoid,\n\t\t\t\t\t\t\t\t\t\t\t\t\t pos + 1, vardata))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t/*\n\t\t\t\t\t\t\t * The hook took control of acquiring a stats\n\t\t\t\t\t\t\t * tuple.  If it did supply a tuple, it'd better\n\t\t\t\t\t\t\t * have supplied a freefunc.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tif (HeapTupleIsValid(vardata-\u003estatsTuple) \u0026\u0026","paragraphs":[],"title":"Core call context: src/backend/utils/adt/selfuncs.c:5482–5496"},{"code":"\t{\n\t\t/* Expression --- maybe there are stats for the index itself */\n\t\trelid = index-\u003eindexoid;\n\t\tcolnum = indexcol + 1;\n\n\t\tif (get_index_stats_hook \u0026\u0026\n\t\t\t(*get_index_stats_hook) (root, relid, colnum, vardata))\n\t\t{\n\t\t\t/*\n\t\t\t * The hook took control of acquiring a stats tuple.  If it did\n\t\t\t * supply a tuple, it'd better have supplied a freefunc.\n\t\t\t */\n\t\t\tif (HeapTupleIsValid(vardata-\u003estatsTuple) \u0026\u0026\n\t\t\t\t!vardata-\u003efreefunc)\n\t\t\t\telog(ERROR, \"no function provided to release variable stats with\");","paragraphs":[],"title":"Core call context: src/backend/utils/adt/selfuncs.c:6218–6232"},{"code":"\t\t\t */\n\n\t\t\t/* get the attnum from the 0-based index. */\n\t\t\tattnum = iclause-\u003eindexcol + 1;\n\n\t\t\tif (get_index_stats_hook \u0026\u0026\n\t\t\t\t(*get_index_stats_hook) (root, index-\u003eindexoid, attnum, \u0026vardata))\n\t\t\t{\n\t\t\t\t/*\n\t\t\t\t * The hook took control of acquiring a stats tuple.  If it\n\t\t\t\t * did supply a tuple, it'd better have supplied a freefunc.\n\t\t\t\t */\n\t\t\t\tif (HeapTupleIsValid(vardata.statsTuple) \u0026\u0026\n\t\t\t\t\t!vardata.freefunc)\n\t\t\t\t\telog(ERROR, \"no function provided to release variable stats with\");","paragraphs":[],"title":"Core call context: src/backend/utils/adt/selfuncs.c:8777–8791"}]}},"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}
