aboutsummaryrefslogtreecommitdiff
path: root/src/sqliteInt.h
diff options
context:
space:
mode:
authordan <dan@noemail.net>2019-08-27 19:59:21 +0000
committerdan <dan@noemail.net>2019-08-27 19:59:21 +0000
commit8085d53d3c5f853c592cb2ffdb7e49a219c962be (patch)
tree2bfc98a7f04a67845c928791cabeaa27c77e09b3 /src/sqliteInt.h
parente893759cac17443c63fd0bc0bfce198985da7aa5 (diff)
parent512e46a74c20c0e385ee798a6e3238ba1cc621b8 (diff)
downloadsqlite-8085d53d3c5f853c592cb2ffdb7e49a219c962be.tar.gz
sqlite-8085d53d3c5f853c592cb2ffdb7e49a219c962be.zip
Add support for "ORDER BY ... NULLS FIRST" and "ORDER BY ... NULLS LAST". Use this to fix ticket [f8a7060e].
FossilOrigin-Name: 94085fb3e756bc984237b74b6e29c68462ad860870c64dcb5124feaeec387660
Diffstat (limited to 'src/sqliteInt.h')
-rw-r--r--src/sqliteInt.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index 70b2f0ba7..d3f7ffe26 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -2138,10 +2138,13 @@ struct KeyInfo {
u16 nKeyField; /* Number of key columns in the index */
u16 nAllField; /* Total columns, including key plus others */
sqlite3 *db; /* The database connection */
- u8 *aSortOrder; /* Sort order for each column. */
+ u8 *aSortFlags; /* Sort order for each column. */
CollSeq *aColl[1]; /* Collating sequence for each term of the key */
};
+#define KEYINFO_ORDER_DESC 0x01
+#define KEYINFO_ORDER_BIGNULL 0x02
+
/*
** This object holds a record which has been parsed out into individual
** fields, for the purposes of doing a comparison.
@@ -2603,11 +2606,12 @@ struct ExprList {
Expr *pExpr; /* The parse tree for this expression */
char *zName; /* Token associated with this expression */
char *zSpan; /* Original text of the expression */
- u8 sortOrder; /* 1 for DESC or 0 for ASC */
+ u8 sortFlags; /* Mask of KEYINFO_ORDER_* flags */
unsigned done :1; /* A flag to indicate when processing is finished */
unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */
unsigned reusable :1; /* Constant expression is reusable */
unsigned bSorterRef :1; /* Defer evaluation until after sorting */
+ unsigned bNulls: 1; /* True if explicit "NULLS FIRST/LAST" */
union {
struct {
u16 iOrderByCol; /* For ORDER BY, column number in result set */
@@ -3888,7 +3892,7 @@ void sqlite3ExprDelete(sqlite3*, Expr*);
void sqlite3ExprUnmapAndDelete(Parse*, Expr*);
ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*);
-void sqlite3ExprListSetSortOrder(ExprList*,int);
+void sqlite3ExprListSetSortOrder(ExprList*,int,int);
void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*);
void sqlite3ExprListDelete(sqlite3*, ExprList*);
@@ -4365,6 +4369,7 @@ void sqlite3KeyInfoUnref(KeyInfo*);
KeyInfo *sqlite3KeyInfoRef(KeyInfo*);
KeyInfo *sqlite3KeyInfoOfIndex(Parse*, Index*);
KeyInfo *sqlite3KeyInfoFromExprList(Parse*, ExprList*, int, int);
+int sqlite3HasExplicitNulls(Parse*, ExprList*);
#ifdef SQLITE_DEBUG
int sqlite3KeyInfoIsWriteable(KeyInfo*);