diff options
author | Tom Lane | 2007-01-09 02:14:16 +0000 |
---|---|---|
committer | Tom Lane | 2007-01-09 02:14:16 +0000 |
commit | 443175822942ef1f15cd047cda58990a089ef180 (patch) | |
tree | a5e4272719d3323d9aa17312d0d867804b652f10 /src/backend/parser/parser.c | |
parent | 3a32ba2f3f54378e3e06366a5ff06e339984f065 (diff) |
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/backend/parser/parser.c')
-rw-r--r-- | src/backend/parser/parser.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/backend/parser/parser.c b/src/backend/parser/parser.c index c007613cc4e..b9c0b9a9853 100644 --- a/src/backend/parser/parser.c +++ b/src/backend/parser/parser.c @@ -14,7 +14,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parser.c,v 1.70 2007/01/06 19:14:17 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parser.c,v 1.71 2007/01/09 02:14:14 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -97,8 +97,35 @@ filtered_base_yylex(void) /* Do we need to look ahead for a possible multiword token? */ switch (cur_token) { - case WITH: + case NULLS_P: + /* + * NULLS FIRST and NULLS LAST must be reduced to one token + */ + cur_yylval = base_yylval; + cur_yylloc = base_yylloc; + next_token = base_yylex(); + switch (next_token) + { + case FIRST_P: + cur_token = NULLS_FIRST; + break; + case LAST_P: + cur_token = NULLS_LAST; + break; + default: + /* save the lookahead token for next time */ + lookahead_token = next_token; + lookahead_yylval = base_yylval; + lookahead_yylloc = base_yylloc; + have_lookahead = true; + /* and back up the output info to cur_token */ + base_yylval = cur_yylval; + base_yylloc = cur_yylloc; + break; + } + break; + case WITH: /* * WITH CASCADED, LOCAL, or CHECK must be reduced to one token * |