↑↓ select ↵ open ⌫ change scope Open full search

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

Wiki / Hooks / Query planning

planner_hook

planner_hook

Hook for plugins to get control in planner()

Reading PostgreSQL 18.

Description

Hook for plugins to get control in planner()

Interface type
planner_hook_type
Header
src/include/optimizer/planner.h
Subsystem
Query planning
Initial value
NULL (no hook installed)

C interface

typedef PlannedStmt *(*planner_hook_type) (Query *parse, const char *query_string, int cursorOptions, ParamListInfo boundParams);
extern PGDLLIMPORT planner_hook_type planner_hook;

Call sites

src/backend/optimizer/plan/planner.c:316

Core call context: src/backend/optimizer/plan/planner.c:310–324

planner(Query *parse, const char *query_string, int cursorOptions,
		ParamListInfo boundParams)
{
	PlannedStmt *result;

	if (planner_hook)
		result = (*planner_hook) (parse, query_string, cursorOptions, boundParams);
	else
		result = standard_planner(parse, query_string, cursorOptions, boundParams);

	pgstat_report_plan_id(result->planId, false);

	return result;
}

Related entries

Documentation and source

Source build
Version
18
Build
REL_18_STABLE
Source fingerprint
753057e340da8f22e57c9a409ea7a235fd6a46bd

Compare versions

PostgreSQL 12 → 13: changed.

--- PostgreSQL 12
+++ PostgreSQL 13
@@ -17,6 +17,6 @@
       "value": "NULL (no hook installed)"
     }
   ],
-  "signature": "typedef PlannedStmt *(*planner_hook_type) (Query *parse, int cursorOptions, ParamListInfo boundParams);\nextern PGDLLIMPORT planner_hook_type planner_hook;",
+  "signature": "typedef PlannedStmt *(*planner_hook_type) (Query *parse, const char *query_string, int cursorOptions, ParamListInfo boundParams);\nextern PGDLLIMPORT planner_hook_type planner_hook;",
   "tables": null
 }

Compares recorded interfaces and attributes. Source fingerprints and build metadata are excluded; an absent sample is not proof of the introduction or removal release.

Related entries

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