mirror of
https://github.com/postgres/postgres.git
synced 2025-07-12 21:01:52 +03:00
Improve run-time partition pruning to handle any stable expression.
The initial coding of the run-time-pruning feature only coped with cases where the partition key(s) are compared to Params. That is a bit silly; we can allow it to work with any non-Var-containing stable expression, as long as we take special care with expressions containing PARAM_EXEC Params. The code is hardly any longer this way, and it's considerably clearer (IMO at least). Per gripe from Pavel Stehule. David Rowley, whacked around a bit by me Discussion: https://postgr.es/m/CAFj8pRBjrufA3ocDm8o4LPGNye9Y+pm1b9kCwode4X04CULG3g@mail.gmail.com
This commit is contained in:
@ -40,23 +40,27 @@ typedef struct PartitionPruneContext
|
||||
PartitionBoundInfo boundinfo;
|
||||
|
||||
/*
|
||||
* Can be set when the context is used from the executor to allow params
|
||||
* found matching the partition key to be evaluated.
|
||||
* This will be set when the context is used from the executor, to allow
|
||||
* Params to be evaluated.
|
||||
*/
|
||||
PlanState *planstate;
|
||||
|
||||
/*
|
||||
* Parameters that are safe to be used for partition pruning. execparams
|
||||
* are not safe to use until the executor is running.
|
||||
*/
|
||||
Bitmapset *safeparams;
|
||||
|
||||
/*
|
||||
* Array of ExprStates, indexed as per PruneCtxStateIdx; one for each
|
||||
* partkey in each pruning step. Allocated if planstate is non-NULL,
|
||||
* otherwise NULL.
|
||||
*/
|
||||
ExprState **exprstates;
|
||||
|
||||
/*
|
||||
* Similar array of flags, each true if corresponding 'exprstate'
|
||||
* expression contains any PARAM_EXEC Params. (Can be NULL if planstate
|
||||
* is NULL.)
|
||||
*/
|
||||
bool *exprhasexecparam;
|
||||
|
||||
/* true if it's safe to evaluate PARAM_EXEC Params */
|
||||
bool evalexecparams;
|
||||
} PartitionPruneContext;
|
||||
|
||||
#define PruneCxtStateIdx(partnatts, step_id, keyno) \
|
||||
|
Reference in New Issue
Block a user