↑↓ select ↵ open ⌫ change scope Open full search

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

Documentation / Extension 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

Related entries

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