diff options
| author | Tom Lane | 2006-01-25 20:29:24 +0000 |
|---|---|---|
| committer | Tom Lane | 2006-01-25 20:29:24 +0000 |
| commit | 3a0a16cb7e2aba8d9864d117d1199181432b42b8 (patch) | |
| tree | 84965bad887c54100ebb9615257be6df2b18cee4 /src/include | |
| parent | 06d45e485dcb65e948b747ccc3e995fadd183887 (diff) | |
Allow row comparisons to be used as indexscan qualifications.
This completes the project to upgrade our handling of row comparisons.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/access/skey.h | 35 | ||||
| -rw-r--r-- | src/include/executor/nodeIndexscan.h | 6 | ||||
| -rw-r--r-- | src/include/optimizer/clauses.h | 6 |
3 files changed, 41 insertions, 6 deletions
diff --git a/src/include/access/skey.h b/src/include/access/skey.h index f3845e55184..ecca1b84cff 100644 --- a/src/include/access/skey.h +++ b/src/include/access/skey.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/access/skey.h,v 1.30 2006/01/14 22:03:35 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/skey.h,v 1.31 2006/01/25 20:29:24 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -70,6 +70,36 @@ typedef struct ScanKeyData typedef ScanKeyData *ScanKey; /* + * About row comparisons: + * + * The ScanKey data structure also supports row comparisons, that is ordered + * tuple comparisons like (x, y) > (c1, c2), having the SQL-spec semantics + * "x > c1 OR (x = c1 AND y > c2)". Note that this is currently only + * implemented for btree index searches, not for heapscans or any other index + * type. A row comparison is represented by a "header" ScanKey entry plus + * a separate array of ScanKeys, one for each column of the row comparison. + * The header entry has these properties: + * sk_flags = SK_ROW_HEADER + * sk_attno = index column number for leading column of row comparison + * sk_strategy = btree strategy code for semantics of row comparison + * (ie, < <= > or >=) + * sk_subtype, sk_func: not used + * sk_argument: pointer to subsidiary ScanKey array + * If the header is part of a ScanKey array that's sorted by attno, it + * must be sorted according to the leading column number. + * + * The subsidiary ScanKey array appears in logical column order of the row + * comparison, which may be different from index column order. The array + * elements are like a normal ScanKey array except that: + * sk_flags must include SK_ROW_MEMBER, plus SK_ROW_END in the last + * element (needed since row header does not include a count) + * sk_func points to the btree comparison support function for the + * opclass, NOT the operator's implementation function. + * sk_strategy must be the same in all elements of the subsidiary array, + * that is, the same as in the header entry. + */ + +/* * ScanKeyData sk_flags * * sk_flags bits 0-15 are reserved for system-wide use (symbols for those @@ -78,6 +108,9 @@ typedef ScanKeyData *ScanKey; */ #define SK_ISNULL 0x0001 /* sk_argument is NULL */ #define SK_UNARY 0x0002 /* unary operator (currently unsupported) */ +#define SK_ROW_HEADER 0x0004 /* row comparison header (see above) */ +#define SK_ROW_MEMBER 0x0008 /* row comparison member (see above) */ +#define SK_ROW_END 0x0010 /* last row comparison member (see above) */ /* diff --git a/src/include/executor/nodeIndexscan.h b/src/include/executor/nodeIndexscan.h index 21bb254f63e..d36defaa016 100644 --- a/src/include/executor/nodeIndexscan.h +++ b/src/include/executor/nodeIndexscan.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/executor/nodeIndexscan.h,v 1.25 2005/11/25 19:47:50 tgl Exp $ + * $PostgreSQL: pgsql/src/include/executor/nodeIndexscan.h,v 1.26 2006/01/25 20:29:24 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -25,8 +25,8 @@ extern void ExecIndexRestrPos(IndexScanState *node); extern void ExecIndexReScan(IndexScanState *node, ExprContext *exprCtxt); /* routines exported to share code with nodeBitmapIndexscan.c */ -extern void ExecIndexBuildScanKeys(PlanState *planstate, List *quals, - List *strategies, List *subtypes, +extern void ExecIndexBuildScanKeys(PlanState *planstate, Relation index, + List *quals, List *strategies, List *subtypes, ScanKey *scanKeys, int *numScanKeys, IndexRuntimeKeyInfo **runtimeKeys, int *numRuntimeKeys, IndexArrayKeyInfo **arrayKeys, int *numArrayKeys); diff --git a/src/include/optimizer/clauses.h b/src/include/optimizer/clauses.h index 0d3770dc5c4..11eb6417fa7 100644 --- a/src/include/optimizer/clauses.h +++ b/src/include/optimizer/clauses.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/optimizer/clauses.h,v 1.81 2005/12/20 02:30:36 tgl Exp $ + * $PostgreSQL: pgsql/src/include/optimizer/clauses.h,v 1.82 2006/01/25 20:29:24 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -67,7 +67,9 @@ extern bool has_distinct_clause(Query *query); extern bool has_distinct_on_clause(Query *query); extern int NumRelids(Node *clause); -extern void CommuteClause(OpExpr *clause); + +extern void CommuteOpExpr(OpExpr *clause); +extern void CommuteRowCompareExpr(RowCompareExpr *clause); extern Node *strip_implicit_coercions(Node *node); |
