diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-11-25 19:47:50 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-11-25 19:47:50 +0000 |
commit | 290166f93404d8759f4bf60ef1732c8ba9a52785 (patch) | |
tree | b7b9b00e3b3c1defea0e78b4f9b982e21963aa0f /src/include/nodes/execnodes.h | |
parent | dab52ab13d3d3cce26e9bcc3193eb285c195d430 (diff) |
Teach planner and executor to handle ScalarArrayOpExpr as an indexable
qualification when the underlying operator is indexable and useOr is true.
That is, indexkey op ANY (ARRAY[...]) is effectively translated into an
OR combination of one indexscan for each array element. This only works
for bitmap index scans, of course, since regular indexscans no longer
support OR'ing of scans. There are still some loose ends to clean up
before changing 'x IN (list)' to translate as a ScalarArrayOpExpr;
for instance predtest.c ought to be taught about it. But this gets the
basic functionality in place.
Diffstat (limited to 'src/include/nodes/execnodes.h')
-rw-r--r-- | src/include/nodes/execnodes.h | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 63e864e4636..f70847798e6 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.141 2005/11/22 18:17:30 momjian Exp $ + * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.142 2005/11/25 19:47:50 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -871,16 +871,37 @@ typedef struct ScanState */ typedef ScanState SeqScanState; +/* + * These structs store information about index quals that don't have simple + * constant right-hand sides. See comments for ExecIndexBuildScanKeys() + * for discussion. + */ +typedef struct +{ + ScanKey scan_key; /* scankey to put value into */ + ExprState *key_expr; /* expr to evaluate to get value */ +} IndexRuntimeKeyInfo; + +typedef struct +{ + ScanKey scan_key; /* scankey to put value into */ + ExprState *array_expr; /* expr to evaluate to get array value */ + int next_elem; /* next array element to use */ + int num_elems; /* number of elems in current array value */ + Datum *elem_values; /* array of num_elems Datums */ + bool *elem_nulls; /* array of num_elems is-null flags */ +} IndexArrayKeyInfo; + /* ---------------- * IndexScanState information * * indexqualorig execution state for indexqualorig expressions * ScanKeys Skey structures to scan index rel * NumScanKeys number of Skey structs - * RuntimeKeyInfo array of exprstates for Skeys - * that will be evaluated at runtime - * RuntimeContext expr context for evaling runtime Skeys + * RuntimeKeys info about Skeys that must be evaluated at runtime + * NumRuntimeKeys number of RuntimeKeys structs * RuntimeKeysReady true if runtime Skeys have been computed + * RuntimeContext expr context for evaling runtime Skeys * RelationDesc index relation descriptor * ScanDesc index scan descriptor * ---------------- @@ -891,9 +912,10 @@ typedef struct IndexScanState List *indexqualorig; ScanKey iss_ScanKeys; int iss_NumScanKeys; - ExprState **iss_RuntimeKeyInfo; - ExprContext *iss_RuntimeContext; + IndexRuntimeKeyInfo *iss_RuntimeKeys; + int iss_NumRuntimeKeys; bool iss_RuntimeKeysReady; + ExprContext *iss_RuntimeContext; Relation iss_RelationDesc; IndexScanDesc iss_ScanDesc; } IndexScanState; @@ -904,10 +926,12 @@ typedef struct IndexScanState * result bitmap to return output into, or NULL * ScanKeys Skey structures to scan index rel * NumScanKeys number of Skey structs - * RuntimeKeyInfo array of exprstates for Skeys - * that will be evaluated at runtime - * RuntimeContext expr context for evaling runtime Skeys + * RuntimeKeys info about Skeys that must be evaluated at runtime + * NumRuntimeKeys number of RuntimeKeys structs + * ArrayKeys info about Skeys that come from ScalarArrayOpExprs + * NumArrayKeys number of ArrayKeys structs * RuntimeKeysReady true if runtime Skeys have been computed + * RuntimeContext expr context for evaling runtime Skeys * RelationDesc index relation descriptor * ScanDesc index scan descriptor * ---------------- @@ -918,9 +942,12 @@ typedef struct BitmapIndexScanState TIDBitmap *biss_result; ScanKey biss_ScanKeys; int biss_NumScanKeys; - ExprState **biss_RuntimeKeyInfo; - ExprContext *biss_RuntimeContext; + IndexRuntimeKeyInfo *biss_RuntimeKeys; + int biss_NumRuntimeKeys; + IndexArrayKeyInfo *biss_ArrayKeys; + int biss_NumArrayKeys; bool biss_RuntimeKeysReady; + ExprContext *biss_RuntimeContext; Relation biss_RelationDesc; IndexScanDesc biss_ScanDesc; } BitmapIndexScanState; |