diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-01-09 02:14:16 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-01-09 02:14:16 +0000 |
| commit | 443175822942ef1f15cd047cda58990a089ef180 (patch) | |
| tree | a5e4272719d3323d9aa17312d0d867804b652f10 /src/include/access/nbtree.h | |
| parent | 3a32ba2f3f54378e3e06366a5ff06e339984f065 (diff) | |
| download | postgresql-443175822942ef1f15cd047cda58990a089ef180.tar.gz | |
Support ORDER BY ... NULLS FIRST/LAST, and add ASC/DESC/NULLS FIRST/NULLS LAST
per-column options for btree indexes. The planner's support for this is still
pretty rudimentary; it does not yet know how to plan mergejoins with
nondefault ordering options. The documentation is pretty rudimentary, too.
I'll work on improving that stuff later.
Note incompatible change from prior behavior: ORDER BY ... USING will now be
rejected if the operator is not a less-than or greater-than member of some
btree opclass. This prevents less-than-sane behavior if an operator that
doesn't actually define a proper sort ordering is selected.
Diffstat (limited to 'src/include/access/nbtree.h')
| -rw-r--r-- | src/include/access/nbtree.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h index 991fc14588..435826cf45 100644 --- a/src/include/access/nbtree.h +++ b/src/include/access/nbtree.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/nbtree.h,v 1.107 2007/01/05 22:19:51 momjian Exp $ + * $PostgreSQL: pgsql/src/include/access/nbtree.h,v 1.108 2007/01/09 02:14:15 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -327,7 +327,11 @@ typedef struct xl_btree_newroot /* * Operator strategy numbers for B-tree have been moved to access/skey.h, * because many places need to use them in ScanKeyInit() calls. + * + * The strategy numbers are chosen so that we can commute them by + * subtraction, thus: */ +#define BTCommuteStrategyNumber(strat) (BTMaxStrategyNumber + 1 - (strat)) /* * When a new operator class is declared, we require that the user @@ -458,11 +462,15 @@ typedef struct BTScanOpaqueData typedef BTScanOpaqueData *BTScanOpaque; /* - * We use these private sk_flags bits in preprocessed scan keys + * We use some private sk_flags bits in preprocessed scan keys. We're allowed + * to use bits 16-31 (see skey.h). The uppermost bits are copied from the + * index's indoption[] array entry for the index attribute. */ #define SK_BT_REQFWD 0x00010000 /* required to continue forward scan */ #define SK_BT_REQBKWD 0x00020000 /* required to continue backward scan */ - +#define SK_BT_INDOPTION_SHIFT 24 /* must clear the above bits */ +#define SK_BT_DESC (INDOPTION_DESC << SK_BT_INDOPTION_SHIFT) +#define SK_BT_NULLS_FIRST (INDOPTION_NULLS_FIRST << SK_BT_INDOPTION_SHIFT) /* * prototypes for functions in nbtree.c (external entry points for btree) |
