{"Entry":{"collection":"hook","key":"planner_setup_hook","name":"planner_setup_hook","aliases":[],"metadata":{"aliases":[],"category":"Query planning","content_hash":"cab5426487b6dceca93213414e8f43b9544e725224bbc52b6675f9ff9bdd61a3","imported_at":"2026-09-27T17:57:58.882763+08:00","name":"planner_setup_hook","name_zh":"planner_setup_hook","slug":"planner_setup_hook","summary":"Hook for plugins to get control after PlannerGlobal is initialized"}},"Definition":{"Collection":"hook","Key":"planner_setup_hook","SourceDatabase":"center","Version":"20","SourceTable":"hook","SourceKey":"planner_setup_hook","SourceRevision":"2c10c2ce4d7bcd57543a49ab402af02a39724e0a","Facts":{"description":["Hook for plugins to get control after PlannerGlobal is initialized"],"facts":[{"label":"Interface type","value":"planner_setup_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/devel/planner-optimizer.html"}],"release":{"channel":"devel","label":"20 devel","major":"20","ref":"master","revision":"2c10c2ce4d7bcd57543a49ab402af02a39724e0a"},"sections":[{"paragraphs":["Allow plugins to take control after we've initialized \"glob\""],"title":"Core source comments"},{"paragraphs":["src/backend/optimizer/plan/planner.c:538"],"title":"Call sites"},{"code":"\t\tglob-\u003edefault_pgs_mask |= PGS_GATHER_MERGE;\n\tif (enable_partitionwise_join)\n\t\tglob-\u003edefault_pgs_mask |= PGS_CONSIDER_PARTITIONWISE;\n\n\t/* Allow plugins to take control after we've initialized \"glob\" */\n\tif (planner_setup_hook)\n\t\t(*planner_setup_hook) (glob, parse, query_string, cursorOptions,\n\t\t\t\t\t\t\t   \u0026tuple_fraction, es);\n\n\t/* primary planning entry point (may recurse for subqueries) */\n\troot = subquery_planner(glob, parse, NULL, NULL, NULL, false,\n\t\t\t\t\t\t\ttuple_fraction, NULL);\n\n\t/* Select best Path and turn it into a Plan */\n\tfinal_rel = fetch_upper_rel(root, UPPERREL_FINAL, NULL);","paragraphs":[],"title":"Core call context: src/backend/optimizer/plan/planner.c:532–546"}],"signature":"typedef void (*planner_setup_hook_type) (PlannerGlobal *glob, Query *parse, const char *query_string, int cursorOptions, double *tuple_fraction, ExplainState *es);\nextern PGDLLIMPORT planner_setup_hook_type planner_setup_hook;","sources":[{"label":"Interface declaration","path":"src/include/optimizer/planner.h","sha256":"4d38d7e4dd9956ef015711e8bf3262ea52631558a0eea290d4fa14ac517c5407","url":"https://github.com/postgres/postgres/blob/2c10c2ce4d7bcd57543a49ab402af02a39724e0a/src/include/optimizer/planner.h#L36"},{"label":"Core definition","path":"src/backend/optimizer/plan/planner.c","sha256":"fbcf53dca02672e0d1757d98942126dd22a4bcadf5a2323710f76d854fe84395","url":"https://github.com/postgres/postgres/blob/2c10c2ce4d7bcd57543a49ab402af02a39724e0a/src/backend/optimizer/plan/planner.c#L77"},{"label":"Call sites","path":"src/backend/optimizer/plan/planner.c","sha256":"fbcf53dca02672e0d1757d98942126dd22a4bcadf5a2323710f76d854fe84395","url":"https://github.com/postgres/postgres/blob/2c10c2ce4d7bcd57543a49ab402af02a39724e0a/src/backend/optimizer/plan/planner.c#L538"}]},"ManualEvidence":{"release":{"channel":"devel","label":"20 devel","major":"20","ref":"master","revision":"2c10c2ce4d7bcd57543a49ab402af02a39724e0a"},"sources":[{"label":"Interface declaration","path":"src/include/optimizer/planner.h","sha256":"4d38d7e4dd9956ef015711e8bf3262ea52631558a0eea290d4fa14ac517c5407","url":"https://github.com/postgres/postgres/blob/2c10c2ce4d7bcd57543a49ab402af02a39724e0a/src/include/optimizer/planner.h#L36"},{"label":"Core definition","path":"src/backend/optimizer/plan/planner.c","sha256":"fbcf53dca02672e0d1757d98942126dd22a4bcadf5a2323710f76d854fe84395","url":"https://github.com/postgres/postgres/blob/2c10c2ce4d7bcd57543a49ab402af02a39724e0a/src/backend/optimizer/plan/planner.c#L77"},{"label":"Call sites","path":"src/backend/optimizer/plan/planner.c","sha256":"fbcf53dca02672e0d1757d98942126dd22a4bcadf5a2323710f76d854fe84395","url":"https://github.com/postgres/postgres/blob/2c10c2ce4d7bcd57543a49ab402af02a39724e0a/src/backend/optimizer/plan/planner.c#L538"}]},"MeasuredEvidence":{}},"Text":{"Collection":"hook","Key":"planner_setup_hook","SourceDatabase":"center","Version":"20","Locale":"en","Title":"planner_setup_hook","Summary":"Hook for plugins to get control after PlannerGlobal is initialized","BodyHTML":"\u003cp\u003eHook for plugins to get control after PlannerGlobal is initialized\u003c/p\u003e","SourceRevision":"2c10c2ce4d7bcd57543a49ab402af02a39724e0a","ContentHash":"d31b1f5241e8cd7de6e4d4e7ab493e4d343b7f722706561b16f75a33ae23f27b","Payload":{"description":["Hook for plugins to get control after PlannerGlobal is initialized"],"related":[{"label":"The Planner/Optimizer","url":"/docs/devel/planner-optimizer.html"}],"sections":[{"paragraphs":["Allow plugins to take control after we've initialized \"glob\""],"title":"Core source comments"},{"paragraphs":["src/backend/optimizer/plan/planner.c:538"],"title":"Call sites"},{"code":"\t\tglob-\u003edefault_pgs_mask |= PGS_GATHER_MERGE;\n\tif (enable_partitionwise_join)\n\t\tglob-\u003edefault_pgs_mask |= PGS_CONSIDER_PARTITIONWISE;\n\n\t/* Allow plugins to take control after we've initialized \"glob\" */\n\tif (planner_setup_hook)\n\t\t(*planner_setup_hook) (glob, parse, query_string, cursorOptions,\n\t\t\t\t\t\t\t   \u0026tuple_fraction, es);\n\n\t/* primary planning entry point (may recurse for subqueries) */\n\troot = subquery_planner(glob, parse, NULL, NULL, NULL, false,\n\t\t\t\t\t\t\ttuple_fraction, NULL);\n\n\t/* Select best Path and turn it into a Plan */\n\tfinal_rel = fetch_upper_rel(root, UPPERREL_FINAL, NULL);","paragraphs":[],"title":"Core call context: src/backend/optimizer/plan/planner.c:532–546"}]}},"RequestedLocale":"zh-Hans","Fallback":true,"Versions":["19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
