{"Entry":{"collection":"hook","key":"planner_hook","name":"planner_hook","aliases":[],"metadata":{"aliases":[],"category":"Query planning","content_hash":"8074b5fa8dfb063fe3df9e4e704a6ff0cd13951bef893e0284bda3063fd4b9eb","imported_at":"2026-09-27T17:57:58.88085+08:00","name":"planner_hook","name_zh":"planner_hook","slug":"planner_hook","summary":"Hook for plugins to get control in planner()"}},"Definition":{"Collection":"hook","Key":"planner_hook","SourceDatabase":"center","Version":"18","SourceTable":"hook","SourceKey":"planner_hook","SourceRevision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","Facts":{"description":["Hook for plugins to get control in planner()"],"facts":[{"label":"Interface type","value":"planner_hook_type"},{"label":"Header","value":"src/include/optimizer/planner.h"},{"label":"Subsystem","value":"Query planning"},{"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/optimizer/plan/planner.c:316"],"title":"Call sites"},{"code":"planner(Query *parse, const char *query_string, int cursorOptions,\n\t\tParamListInfo boundParams)\n{\n\tPlannedStmt *result;\n\n\tif (planner_hook)\n\t\tresult = (*planner_hook) (parse, query_string, cursorOptions, boundParams);\n\telse\n\t\tresult = standard_planner(parse, query_string, cursorOptions, boundParams);\n\n\tpgstat_report_plan_id(result-\u003eplanId, false);\n\n\treturn result;\n}\n","paragraphs":[],"title":"Core call context: src/backend/optimizer/plan/planner.c:310–324"}],"signature":"typedef PlannedStmt *(*planner_hook_type) (Query *parse, const char *query_string, int cursorOptions, ParamListInfo boundParams);\nextern PGDLLIMPORT planner_hook_type planner_hook;","sources":[{"label":"Interface declaration","path":"src/include/optimizer/planner.h","sha256":"2b48e2afeff0e27570bc5bf536f3d5cdaab6111beb0b98bef9e5ce069598d08b","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/include/optimizer/planner.h#L26"},{"label":"Core definition","path":"src/backend/optimizer/plan/planner.c","sha256":"70faebbc45551e477e5d75000911b029ea648e8cc616725f3b0032480cf16878","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/optimizer/plan/planner.c#L74"},{"label":"Call sites","path":"src/backend/optimizer/plan/planner.c","sha256":"70faebbc45551e477e5d75000911b029ea648e8cc616725f3b0032480cf16878","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/optimizer/plan/planner.c#L316"}]},"ManualEvidence":{"release":{"channel":"stable","label":"18","major":"18","ref":"REL_18_STABLE","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd"},"sources":[{"label":"Interface declaration","path":"src/include/optimizer/planner.h","sha256":"2b48e2afeff0e27570bc5bf536f3d5cdaab6111beb0b98bef9e5ce069598d08b","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/include/optimizer/planner.h#L26"},{"label":"Core definition","path":"src/backend/optimizer/plan/planner.c","sha256":"70faebbc45551e477e5d75000911b029ea648e8cc616725f3b0032480cf16878","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/optimizer/plan/planner.c#L74"},{"label":"Call sites","path":"src/backend/optimizer/plan/planner.c","sha256":"70faebbc45551e477e5d75000911b029ea648e8cc616725f3b0032480cf16878","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/optimizer/plan/planner.c#L316"}]},"MeasuredEvidence":{}},"Text":{"Collection":"hook","Key":"planner_hook","SourceDatabase":"center","Version":"18","Locale":"en","Title":"planner_hook","Summary":"Hook for plugins to get control in planner()","BodyHTML":"\u003cp\u003eHook for plugins to get control in planner()\u003c/p\u003e","SourceRevision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","ContentHash":"4187ffe7078670475828001f297708566afa710095909e63d80aa3abc71e8850","Payload":{"description":["Hook for plugins to get control in planner()"],"related":[{"label":"The Planner/Optimizer","url":"/docs/18/planner-optimizer.html"}],"sections":[{"paragraphs":["src/backend/optimizer/plan/planner.c:316"],"title":"Call sites"},{"code":"planner(Query *parse, const char *query_string, int cursorOptions,\n\t\tParamListInfo boundParams)\n{\n\tPlannedStmt *result;\n\n\tif (planner_hook)\n\t\tresult = (*planner_hook) (parse, query_string, cursorOptions, boundParams);\n\telse\n\t\tresult = standard_planner(parse, query_string, cursorOptions, boundParams);\n\n\tpgstat_report_plan_id(result-\u003eplanId, false);\n\n\treturn result;\n}\n","paragraphs":[],"title":"Core call context: src/backend/optimizer/plan/planner.c:310–324"}]}},"RequestedLocale":"zh-Hans","Fallback":true,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
