Browse Source

complete SQLite-3.8.1 porting, and auto generate porting code

geniusgogo 11 years ago
parent
commit
7d88b753d6

+ 3 - 2
components/external/SQLite-3.8.1/src/mem1.c

@@ -76,13 +76,14 @@ static malloc_zone_t* _sqliteZone_;
         (_sqliteZone_ ? _sqliteZone_->size(_sqliteZone_,x) : malloc_size(x))
         (_sqliteZone_ ? _sqliteZone_->size(_sqliteZone_,x) : malloc_size(x))
 
 
 #elif defined(SQLITE_OS_RTT)
 #elif defined(SQLITE_OS_RTT)
+#include <rtthread.h>
 /*
 /*
 ** Use standard C library malloc and free on non-Apple systems.
 ** Use standard C library malloc and free on non-Apple systems.
 ** Also used by rt-thread systems if SQLITE_WITHOUT_ZONEMALLOC is defined.
 ** Also used by rt-thread systems if SQLITE_WITHOUT_ZONEMALLOC is defined.
 */
 */
-#define SQLITE_MALLOC(x)    rt_malloc(x)
+#define SQLITE_MALLOC(x)    rt_malloc((rt_size_t)x)
 #define SQLITE_FREE(x)      rt_free(x)
 #define SQLITE_FREE(x)      rt_free(x)
-#define SQLITE_REALLOC(x,y) rt_realloc((x),(y))
+#define SQLITE_REALLOC(x,y) rt_realloc((x),(rt_size_t)(y))
 
 
 #if (!defined(SQLITE_WITHOUT_MSIZE)) \
 #if (!defined(SQLITE_WITHOUT_MSIZE)) \
       && (defined(HAVE_MALLOC_H) && defined(HAVE_MALLOC_USABLE_SIZE))
       && (defined(HAVE_MALLOC_H) && defined(HAVE_MALLOC_USABLE_SIZE))

+ 86 - 84
components/external/SQLite-3.8.1/src/sqliteInt.h

@@ -87,7 +87,7 @@
 ** to the next, so we have developed the following set of #if statements
 ** to the next, so we have developed the following set of #if statements
 ** to generate appropriate macros for a wide range of compilers.
 ** to generate appropriate macros for a wide range of compilers.
 **
 **
-** The correct "ANSI" way to do this is to use the intptr_t type. 
+** The correct "ANSI" way to do this is to use the intptr_t type.
 ** Unfortunately, that typedef is not available on all compilers, or
 ** Unfortunately, that typedef is not available on all compilers, or
 ** if it is available, it requires an #include of specific headers
 ** if it is available, it requires an #include of specific headers
 ** that vary from one machine to the next.
 ** that vary from one machine to the next.
@@ -140,7 +140,7 @@
 
 
 /*
 /*
 ** The SQLITE_DEFAULT_MEMSTATUS macro must be defined as either 0 or 1.
 ** The SQLITE_DEFAULT_MEMSTATUS macro must be defined as either 0 or 1.
-** It determines whether or not the features related to 
+** It determines whether or not the features related to
 ** SQLITE_CONFIG_MEMSTATUS are available by default or not. This value can
 ** SQLITE_CONFIG_MEMSTATUS are available by default or not. This value can
 ** be overridden at runtime using the sqlite3_config() API.
 ** be overridden at runtime using the sqlite3_config() API.
 */
 */
@@ -210,7 +210,7 @@
 ** is set.  Thus NDEBUG becomes an opt-in rather than an opt-out
 ** is set.  Thus NDEBUG becomes an opt-in rather than an opt-out
 ** feature.
 ** feature.
 */
 */
-#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) 
+#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
 # define NDEBUG 1
 # define NDEBUG 1
 #endif
 #endif
 #if defined(NDEBUG) && defined(SQLITE_DEBUG)
 #if defined(NDEBUG) && defined(SQLITE_DEBUG)
@@ -218,7 +218,7 @@
 #endif
 #endif
 
 
 /*
 /*
-** The testcase() macro is used to aid in coverage testing.  When 
+** The testcase() macro is used to aid in coverage testing.  When
 ** doing coverage testing, the condition inside the argument to
 ** doing coverage testing, the condition inside the argument to
 ** testcase() must be evaluated both true and false in order to
 ** testcase() must be evaluated both true and false in order to
 ** get full branch coverage.  The testcase() macro is inserted
 ** get full branch coverage.  The testcase() macro is inserted
@@ -264,7 +264,7 @@
 #endif
 #endif
 
 
 /*
 /*
-** The ALWAYS and NEVER macros surround boolean expressions which 
+** The ALWAYS and NEVER macros surround boolean expressions which
 ** are intended to always be true or false, respectively.  Such
 ** are intended to always be true or false, respectively.  Such
 ** expressions could be omitted from the code completely.  But they
 ** expressions could be omitted from the code completely.  But they
 ** are included in a few cases in order to enhance the resilience
 ** are included in a few cases in order to enhance the resilience
@@ -336,7 +336,7 @@
 
 
 /*
 /*
 ** OMIT_TEMPDB is set to 1 if SQLITE_OMIT_TEMPDB is defined, or 0
 ** OMIT_TEMPDB is set to 1 if SQLITE_OMIT_TEMPDB is defined, or 0
-** afterward. Having this macro allows us to cause the C compiler 
+** afterward. Having this macro allows us to cause the C compiler
 ** to omit code used by TEMP tables without messy #ifndef statements.
 ** to omit code used by TEMP tables without messy #ifndef statements.
 */
 */
 #ifdef SQLITE_OMIT_TEMPDB
 #ifdef SQLITE_OMIT_TEMPDB
@@ -488,7 +488,7 @@ typedef INT8_TYPE i8;              /* 1-byte signed integer */
 **      4 -> 20           1000 -> 99        1048576 -> 200
 **      4 -> 20           1000 -> 99        1048576 -> 200
 **     10 -> 33           1024 -> 100    4294967296 -> 320
 **     10 -> 33           1024 -> 100    4294967296 -> 320
 **
 **
-** The LogEst can be negative to indicate fractional values. 
+** The LogEst can be negative to indicate fractional values.
 ** Examples:
 ** Examples:
 **
 **
 **    0.5 -> -10           0.1 -> -33        0.0625 -> -40
 **    0.5 -> -10           0.1 -> -33        0.0625 -> -40
@@ -523,7 +523,7 @@ extern const int sqlite3one;
 #define LARGEST_INT64  (0xffffffff|(((i64)0x7fffffff)<<32))
 #define LARGEST_INT64  (0xffffffff|(((i64)0x7fffffff)<<32))
 #define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)
 #define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)
 
 
-/* 
+/*
 ** Round up a number to the next larger multiple of 8.  This is used
 ** Round up a number to the next larger multiple of 8.  This is used
 ** to force 8-byte alignment on 64-bit architectures.
 ** to force 8-byte alignment on 64-bit architectures.
 */
 */
@@ -568,7 +568,9 @@ extern const int sqlite3one;
 # endif
 # endif
 #endif
 #endif
 #ifndef SQLITE_MAX_MMAP_SIZE
 #ifndef SQLITE_MAX_MMAP_SIZE
-# if defined(__linux__) \
+# if defined(SQLITE_OS_RTT)
+#   define SQLITE_MAX_MMAP_SIZE 0
+# elif defined(__linux__) \
   || defined(_WIN32) \
   || defined(_WIN32) \
   || (defined(__APPLE__) && defined(__MACH__)) \
   || (defined(__APPLE__) && defined(__MACH__)) \
   || defined(__sun)
   || defined(__sun)
@@ -609,7 +611,7 @@ extern const int sqlite3one;
 
 
 /*
 /*
 ** An instance of the following structure is used to store the busy-handler
 ** An instance of the following structure is used to store the busy-handler
-** callback for a given sqlite handle. 
+** callback for a given sqlite handle.
 **
 **
 ** The sqlite.busyHandler member of the sqlite struct contains the busy
 ** The sqlite.busyHandler member of the sqlite struct contains the busy
 ** callback for the database handle. Each pager opened via the sqlite
 ** callback for the database handle. Each pager opened via the sqlite
@@ -654,9 +656,9 @@ struct BusyHandler {
 
 
 /*
 /*
 ** The following value as a destructor means to use sqlite3DbFree().
 ** The following value as a destructor means to use sqlite3DbFree().
-** The sqlite3DbFree() routine requires two parameters instead of the 
-** one parameter that destructors normally want.  So we have to introduce 
-** this magic value that the code knows to handle differently.  Any 
+** The sqlite3DbFree() routine requires two parameters instead of the
+** one parameter that destructors normally want.  So we have to introduce
+** this magic value that the code knows to handle differently.  Any
 ** pointer will work here as long as it is distinct from SQLITE_STATIC
 ** pointer will work here as long as it is distinct from SQLITE_STATIC
 ** and SQLITE_TRANSIENT.
 ** and SQLITE_TRANSIENT.
 */
 */
@@ -683,16 +685,16 @@ struct BusyHandler {
   int sqlite3_wsd_init(int N, int J);
   int sqlite3_wsd_init(int N, int J);
   void *sqlite3_wsd_find(void *K, int L);
   void *sqlite3_wsd_find(void *K, int L);
 #else
 #else
-  #define SQLITE_WSD 
+  #define SQLITE_WSD
   #define GLOBAL(t,v) v
   #define GLOBAL(t,v) v
   #define sqlite3GlobalConfig sqlite3Config
   #define sqlite3GlobalConfig sqlite3Config
 #endif
 #endif
 
 
 /*
 /*
 ** The following macros are used to suppress compiler warnings and to
 ** The following macros are used to suppress compiler warnings and to
-** make it clear to human readers when a function parameter is deliberately 
+** make it clear to human readers when a function parameter is deliberately
 ** left unused within the body of a function. This usually happens when
 ** left unused within the body of a function. This usually happens when
-** a function is called via a function pointer. For example the 
+** a function is called via a function pointer. For example the
 ** implementation of an SQL aggregate step callback may not use the
 ** implementation of an SQL aggregate step callback may not use the
 ** parameter indicating the number of arguments passed to the aggregate,
 ** parameter indicating the number of arguments passed to the aggregate,
 ** if it knows that this is enforced elsewhere.
 ** if it knows that this is enforced elsewhere.
@@ -754,7 +756,7 @@ typedef struct Walker Walker;
 typedef struct WhereInfo WhereInfo;
 typedef struct WhereInfo WhereInfo;
 
 
 /*
 /*
-** Defer sourcing vdbe.h and btree.h until after the "u8" and 
+** Defer sourcing vdbe.h and btree.h until after the "u8" and
 ** "BusyHandler" typedefs. vdbe.h also requires a few of the opaque
 ** "BusyHandler" typedefs. vdbe.h also requires a few of the opaque
 ** pointer types (i.e. FuncDef) defined above.
 ** pointer types (i.e. FuncDef) defined above.
 */
 */
@@ -788,7 +790,7 @@ struct Db {
 ** the Schema for the TEMP databaes (sqlite3.aDb[1]) which is free-standing.
 ** the Schema for the TEMP databaes (sqlite3.aDb[1]) which is free-standing.
 ** In shared cache mode, a single Schema object can be shared by multiple
 ** In shared cache mode, a single Schema object can be shared by multiple
 ** Btrees that refer to the same underlying BtShared object.
 ** Btrees that refer to the same underlying BtShared object.
-** 
+**
 ** Schema objects are automatically deallocated when the last Btree that
 ** Schema objects are automatically deallocated when the last Btree that
 ** references them is destroyed.   The TEMP Schema is manually freed by
 ** references them is destroyed.   The TEMP Schema is manually freed by
 ** sqlite3_close().
 ** sqlite3_close().
@@ -813,7 +815,7 @@ struct Schema {
 };
 };
 
 
 /*
 /*
-** These macros can be used to test, set, or clear bits in the 
+** These macros can be used to test, set, or clear bits in the
 ** Db.pSchema->flags field.
 ** Db.pSchema->flags field.
 */
 */
 #define DbHasProperty(D,I,P)     (((D)->aDb[I].pSchema->flags&(P))==(P))
 #define DbHasProperty(D,I,P)     (((D)->aDb[I].pSchema->flags&(P))==(P))
@@ -932,9 +934,9 @@ struct sqlite3 {
   void *pTraceArg;                          /* Argument to the trace function */
   void *pTraceArg;                          /* Argument to the trace function */
   void (*xProfile)(void*,const char*,u64);  /* Profiling function */
   void (*xProfile)(void*,const char*,u64);  /* Profiling function */
   void *pProfileArg;                        /* Argument to profile function */
   void *pProfileArg;                        /* Argument to profile function */
-  void *pCommitArg;                 /* Argument to xCommitCallback() */   
+  void *pCommitArg;                 /* Argument to xCommitCallback() */
   int (*xCommitCallback)(void*);    /* Invoked at every commit. */
   int (*xCommitCallback)(void*);    /* Invoked at every commit. */
-  void *pRollbackArg;               /* Argument to xRollbackCallback() */   
+  void *pRollbackArg;               /* Argument to xRollbackCallback() */
   void (*xRollbackCallback)(void*); /* Invoked at every commit. */
   void (*xRollbackCallback)(void*); /* Invoked at every commit. */
   void *pUpdateArg;
   void *pUpdateArg;
   void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64);
   void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64);
@@ -981,8 +983,8 @@ struct sqlite3 {
   int *pnBytesFreed;            /* If not NULL, increment this in DbFree() */
   int *pnBytesFreed;            /* If not NULL, increment this in DbFree() */
 
 
 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
-  /* The following variables are all protected by the STATIC_MASTER 
-  ** mutex, not by sqlite3.mutex. They are used by code in notify.c. 
+  /* The following variables are all protected by the STATIC_MASTER
+  ** mutex, not by sqlite3.mutex. They are used by code in notify.c.
   **
   **
   ** When X.pUnlockConnection==Y, that means that X is waiting for Y to
   ** When X.pUnlockConnection==Y, that means that X is waiting for Y to
   ** unlock so that it can proceed.
   ** unlock so that it can proceed.
@@ -1104,7 +1106,7 @@ struct FuncDef {
 ** This structure encapsulates a user-function destructor callback (as
 ** This structure encapsulates a user-function destructor callback (as
 ** configured using create_function_v2()) and a reference counter. When
 ** configured using create_function_v2()) and a reference counter. When
 ** create_function_v2() is called to create a function with a destructor,
 ** create_function_v2() is called to create a function with a destructor,
-** a single object of this type is allocated. FuncDestructor.nRef is set to 
+** a single object of this type is allocated. FuncDestructor.nRef is set to
 ** the number of FuncDef objects created (either 1 or 3, depending on whether
 ** the number of FuncDef objects created (either 1 or 3, depending on whether
 ** or not the specified encoding is SQLITE_ANY). The FuncDef.pDestructor
 ** or not the specified encoding is SQLITE_ANY). The FuncDef.pDestructor
 ** member of each of the new FuncDef objects is set to point to the allocated
 ** member of each of the new FuncDef objects is set to point to the allocated
@@ -1141,10 +1143,10 @@ struct FuncDestructor {
 ** used to create the initializers for the FuncDef structures.
 ** used to create the initializers for the FuncDef structures.
 **
 **
 **   FUNCTION(zName, nArg, iArg, bNC, xFunc)
 **   FUNCTION(zName, nArg, iArg, bNC, xFunc)
-**     Used to create a scalar function definition of a function zName 
+**     Used to create a scalar function definition of a function zName
 **     implemented by C function xFunc that accepts nArg arguments. The
 **     implemented by C function xFunc that accepts nArg arguments. The
 **     value passed as iArg is cast to a (void*) and made available
 **     value passed as iArg is cast to a (void*) and made available
-**     as the user-data (sqlite3_user_data()) for the function. If 
+**     as the user-data (sqlite3_user_data()) for the function. If
 **     argument bNC is true, then the SQLITE_FUNC_NEEDCOLL flag is set.
 **     argument bNC is true, then the SQLITE_FUNC_NEEDCOLL flag is set.
 **
 **
 **   AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal)
 **   AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal)
@@ -1154,8 +1156,8 @@ struct FuncDestructor {
 **     FUNCTION().
 **     FUNCTION().
 **
 **
 **   LIKEFUNC(zName, nArg, pArg, flags)
 **   LIKEFUNC(zName, nArg, pArg, flags)
-**     Used to create a scalar function definition of a function zName 
-**     that accepts nArg arguments and is implemented by a call to C 
+**     Used to create a scalar function definition of a function zName
+**     that accepts nArg arguments and is implemented by a call to C
 **     function likeFunc. Argument pArg is cast to a (void *) and made
 **     function likeFunc. Argument pArg is cast to a (void *) and made
 **     available as the function user-data (sqlite3_user_data()). The
 **     available as the function user-data (sqlite3_user_data()). The
 **     FuncDef.flags variable is set to the value passed as the flags
 **     FuncDef.flags variable is set to the value passed as the flags
@@ -1259,7 +1261,7 @@ struct CollSeq {
 **
 **
 ** These used to have mnemonic name like 'i' for SQLITE_AFF_INTEGER and
 ** These used to have mnemonic name like 'i' for SQLITE_AFF_INTEGER and
 ** 't' for SQLITE_AFF_TEXT.  But we can save a little space and improve
 ** 't' for SQLITE_AFF_TEXT.  But we can save a little space and improve
-** the speed a little by numbering the values consecutively.  
+** the speed a little by numbering the values consecutively.
 **
 **
 ** But rather than start with 0 or 1, we begin with 'a'.  That way,
 ** But rather than start with 0 or 1, we begin with 'a'.  That way,
 ** when multiple affinity types are concatenated into a string and
 ** when multiple affinity types are concatenated into a string and
@@ -1278,7 +1280,7 @@ struct CollSeq {
 
 
 /*
 /*
 ** The SQLITE_AFF_MASK values masks off the significant bits of an
 ** The SQLITE_AFF_MASK values masks off the significant bits of an
-** affinity value. 
+** affinity value.
 */
 */
 #define SQLITE_AFF_MASK     0x67
 #define SQLITE_AFF_MASK     0x67
 
 
@@ -1292,20 +1294,20 @@ struct CollSeq {
 
 
 /*
 /*
 ** An object of this type is created for each virtual table present in
 ** An object of this type is created for each virtual table present in
-** the database schema. 
+** the database schema.
 **
 **
 ** If the database schema is shared, then there is one instance of this
 ** If the database schema is shared, then there is one instance of this
 ** structure for each database connection (sqlite3*) that uses the shared
 ** structure for each database connection (sqlite3*) that uses the shared
 ** schema. This is because each database connection requires its own unique
 ** schema. This is because each database connection requires its own unique
-** instance of the sqlite3_vtab* handle used to access the virtual table 
-** implementation. sqlite3_vtab* handles can not be shared between 
-** database connections, even when the rest of the in-memory database 
+** instance of the sqlite3_vtab* handle used to access the virtual table
+** implementation. sqlite3_vtab* handles can not be shared between
+** database connections, even when the rest of the in-memory database
 ** schema is shared, as the implementation often stores the database
 ** schema is shared, as the implementation often stores the database
 ** connection handle passed to it via the xConnect() or xCreate() method
 ** connection handle passed to it via the xConnect() or xCreate() method
 ** during initialization internally. This database connection handle may
 ** during initialization internally. This database connection handle may
-** then be used by the virtual table implementation to access real tables 
-** within the database. So that they appear as part of the callers 
-** transaction, these accesses need to be made via the same database 
+** then be used by the virtual table implementation to access real tables
+** within the database. So that they appear as part of the callers
+** transaction, these accesses need to be made via the same database
 ** connection as that used to execute SQL operations on the virtual table.
 ** connection as that used to execute SQL operations on the virtual table.
 **
 **
 ** All VTable objects that correspond to a single table in a shared
 ** All VTable objects that correspond to a single table in a shared
@@ -1317,19 +1319,19 @@ struct CollSeq {
 ** sqlite3_vtab* handle in the compiled query.
 ** sqlite3_vtab* handle in the compiled query.
 **
 **
 ** When an in-memory Table object is deleted (for example when the
 ** When an in-memory Table object is deleted (for example when the
-** schema is being reloaded for some reason), the VTable objects are not 
-** deleted and the sqlite3_vtab* handles are not xDisconnect()ed 
+** schema is being reloaded for some reason), the VTable objects are not
+** deleted and the sqlite3_vtab* handles are not xDisconnect()ed
 ** immediately. Instead, they are moved from the Table.pVTable list to
 ** immediately. Instead, they are moved from the Table.pVTable list to
 ** another linked list headed by the sqlite3.pDisconnect member of the
 ** another linked list headed by the sqlite3.pDisconnect member of the
-** corresponding sqlite3 structure. They are then deleted/xDisconnected 
+** corresponding sqlite3 structure. They are then deleted/xDisconnected
 ** next time a statement is prepared using said sqlite3*. This is done
 ** next time a statement is prepared using said sqlite3*. This is done
 ** to avoid deadlock issues involving multiple sqlite3.mutex mutexes.
 ** to avoid deadlock issues involving multiple sqlite3.mutex mutexes.
 ** Refer to comments above function sqlite3VtabUnlockList() for an
 ** Refer to comments above function sqlite3VtabUnlockList() for an
 ** explanation as to why it is safe to add an entry to an sqlite3.pDisconnect
 ** explanation as to why it is safe to add an entry to an sqlite3.pDisconnect
 ** list without holding the corresponding sqlite3.mutex mutex.
 ** list without holding the corresponding sqlite3.mutex mutex.
 **
 **
-** The memory for objects of this type is always allocated by 
-** sqlite3DbMalloc(), using the connection handle stored in VTable.db as 
+** The memory for objects of this type is always allocated by
+** sqlite3DbMalloc(), using the connection handle stored in VTable.db as
 ** the first argument.
 ** the first argument.
 */
 */
 struct VTable {
 struct VTable {
@@ -1366,10 +1368,10 @@ struct VTable {
 ** in sqlite.aDb[].  0 is for the main database and 1 is for the file that
 ** in sqlite.aDb[].  0 is for the main database and 1 is for the file that
 ** holds temporary tables and indices.  If TF_Ephemeral is set
 ** holds temporary tables and indices.  If TF_Ephemeral is set
 ** then the table is stored in a file that is automatically deleted
 ** then the table is stored in a file that is automatically deleted
-** when the VDBE cursor to the table is closed.  In this case Table.tnum 
+** when the VDBE cursor to the table is closed.  In this case Table.tnum
 ** refers VDBE cursor number that holds the table open, not to the root
 ** refers VDBE cursor number that holds the table open, not to the root
 ** page number.  Transient tables are used to hold the results of a
 ** page number.  Transient tables are used to hold the results of a
-** sub-query that appears instead of a real table name in the FROM clause 
+** sub-query that appears instead of a real table name in the FROM clause
 ** of a SELECT statement.
 ** of a SELECT statement.
 */
 */
 struct Table {
 struct Table {
@@ -1483,7 +1485,7 @@ struct FKey {
 ** key is set to NULL.  CASCADE means that a DELETE or UPDATE of the
 ** key is set to NULL.  CASCADE means that a DELETE or UPDATE of the
 ** referenced table row is propagated into the row that holds the
 ** referenced table row is propagated into the row that holds the
 ** foreign key.
 ** foreign key.
-** 
+**
 ** The following symbolic values are used to record which type
 ** The following symbolic values are used to record which type
 ** of action to take.
 ** of action to take.
 */
 */
@@ -1504,7 +1506,7 @@ struct FKey {
 
 
 /*
 /*
 ** An instance of the following structure is passed as the first
 ** An instance of the following structure is passed as the first
-** argument to sqlite3VdbeKeyCompare and is used to control the 
+** argument to sqlite3VdbeKeyCompare and is used to control the
 ** comparison of the two index keys.
 ** comparison of the two index keys.
 **
 **
 ** Note that aSortOrder[] and aColl[] have nField+1 slots.  There
 ** Note that aSortOrder[] and aColl[] have nField+1 slots.  There
@@ -1562,7 +1564,7 @@ struct UnpackedRecord {
 ** In the Table structure describing Ex1, nCol==3 because there are
 ** In the Table structure describing Ex1, nCol==3 because there are
 ** three columns in the table.  In the Index structure describing
 ** three columns in the table.  In the Index structure describing
 ** Ex2, nColumn==2 since 2 of the 3 columns of Ex1 are indexed.
 ** Ex2, nColumn==2 since 2 of the 3 columns of Ex1 are indexed.
-** The value of aiColumn is {2, 0}.  aiColumn[0]==2 because the 
+** The value of aiColumn is {2, 0}.  aiColumn[0]==2 because the
 ** first column to be indexed (c3) has an index of 2 in Ex1.aCol[].
 ** first column to be indexed (c3) has an index of 2 in Ex1.aCol[].
 ** The second column to be indexed (c1) has an index of 0 in
 ** The second column to be indexed (c1) has an index of 0 in
 ** Ex1.aCol[], hence Ex2.aiColumn[1]==0.
 ** Ex1.aCol[], hence Ex2.aiColumn[1]==0.
@@ -1570,7 +1572,7 @@ struct UnpackedRecord {
 ** The Index.onError field determines whether or not the indexed columns
 ** The Index.onError field determines whether or not the indexed columns
 ** must be unique and what to do if they are not.  When Index.onError=OE_None,
 ** must be unique and what to do if they are not.  When Index.onError=OE_None,
 ** it means this is not a unique index.  Otherwise it is a unique index
 ** it means this is not a unique index.  Otherwise it is a unique index
-** and the value of Index.onError indicate the which conflict resolution 
+** and the value of Index.onError indicate the which conflict resolution
 ** algorithm to employ whenever an attempt is made to insert a non-unique
 ** algorithm to employ whenever an attempt is made to insert a non-unique
 ** element.
 ** element.
 */
 */
@@ -1601,7 +1603,7 @@ struct Index {
 };
 };
 
 
 /*
 /*
-** Each sample stored in the sqlite_stat3 table is represented in memory 
+** Each sample stored in the sqlite_stat3 table is represented in memory
 ** using a structure of this type.  See documentation at the top of the
 ** using a structure of this type.  See documentation at the top of the
 ** analyze.c source file for additional information.
 ** analyze.c source file for additional information.
 */
 */
@@ -1695,9 +1697,9 @@ typedef int ynVar;
 ** to represent the greater-than-or-equal-to operator in the expression
 ** to represent the greater-than-or-equal-to operator in the expression
 ** tree.
 ** tree.
 **
 **
-** If the expression is an SQL literal (TK_INTEGER, TK_FLOAT, TK_BLOB, 
+** If the expression is an SQL literal (TK_INTEGER, TK_FLOAT, TK_BLOB,
 ** or TK_STRING), then Expr.token contains the text of the SQL literal. If
 ** or TK_STRING), then Expr.token contains the text of the SQL literal. If
-** the expression is a variable (TK_VARIABLE), then Expr.token contains the 
+** the expression is a variable (TK_VARIABLE), then Expr.token contains the
 ** variable name. Finally, if the expression is an SQL function (TK_FUNCTION),
 ** variable name. Finally, if the expression is an SQL function (TK_FUNCTION),
 ** then Expr.token contains the name of the function.
 ** then Expr.token contains the name of the function.
 **
 **
@@ -1708,7 +1710,7 @@ typedef int ynVar;
 ** a CASE expression or an IN expression of the form "<lhs> IN (<y>, <z>...)".
 ** a CASE expression or an IN expression of the form "<lhs> IN (<y>, <z>...)".
 ** Expr.x.pSelect is used if the expression is a sub-select or an expression of
 ** Expr.x.pSelect is used if the expression is a sub-select or an expression of
 ** the form "<lhs> IN (SELECT ...)". If the EP_xIsSelect bit is set in the
 ** the form "<lhs> IN (SELECT ...)". If the EP_xIsSelect bit is set in the
-** Expr.flags mask, then Expr.x.pSelect is valid. Otherwise, Expr.x.pList is 
+** Expr.flags mask, then Expr.x.pSelect is valid. Otherwise, Expr.x.pList is
 ** valid.
 ** valid.
 **
 **
 ** An expression of the form ID or ID.ID refers to a column in a table.
 ** An expression of the form ID or ID.ID refers to a column in a table.
@@ -1719,8 +1721,8 @@ typedef int ynVar;
 ** value is also stored in the Expr.iAgg column in the aggregate so that
 ** value is also stored in the Expr.iAgg column in the aggregate so that
 ** it can be accessed after all aggregates are computed.
 ** it can be accessed after all aggregates are computed.
 **
 **
-** If the expression is an unbound variable marker (a question mark 
-** character '?' in the original SQL) then the Expr.iTable holds the index 
+** If the expression is an unbound variable marker (a question mark
+** character '?' in the original SQL) then the Expr.iTable holds the index
 ** number for that variable.
 ** number for that variable.
 **
 **
 ** If the expression is a subquery then Expr.iColumn holds an integer
 ** If the expression is a subquery then Expr.iColumn holds an integer
@@ -1759,7 +1761,7 @@ struct Expr {
 
 
   /* If the EP_TokenOnly flag is set in the Expr.flags mask, then no
   /* If the EP_TokenOnly flag is set in the Expr.flags mask, then no
   ** space is allocated for the fields below this point. An attempt to
   ** space is allocated for the fields below this point. An attempt to
-  ** access them will result in a segfault or malfunction. 
+  ** access them will result in a segfault or malfunction.
   *********************************************************************/
   *********************************************************************/
 
 
   Expr *pLeft;           /* Left subnode */
   Expr *pLeft;           /* Left subnode */
@@ -1816,7 +1818,7 @@ struct Expr {
 #define EP_Unlikely  0x040000 /* unlikely() or likelihood() function */
 #define EP_Unlikely  0x040000 /* unlikely() or likelihood() function */
 
 
 /*
 /*
-** These macros can be used to test, set, or clear bits in the 
+** These macros can be used to test, set, or clear bits in the
 ** Expr.flags field.
 ** Expr.flags field.
 */
 */
 #define ExprHasProperty(E,P)     (((E)->flags&(P))!=0)
 #define ExprHasProperty(E,P)     (((E)->flags&(P))!=0)
@@ -1835,8 +1837,8 @@ struct Expr {
 #endif
 #endif
 
 
 /*
 /*
-** Macros to determine the number of bytes required by a normal Expr 
-** struct, an Expr struct with the EP_Reduced flag set in Expr.flags 
+** Macros to determine the number of bytes required by a normal Expr
+** struct, an Expr struct with the EP_Reduced flag set in Expr.flags
 ** and an Expr struct with the EP_TokenOnly flag set.
 ** and an Expr struct with the EP_TokenOnly flag set.
 */
 */
 #define EXPR_FULLSIZE           sizeof(Expr)           /* Full size */
 #define EXPR_FULLSIZE           sizeof(Expr)           /* Full size */
@@ -1844,7 +1846,7 @@ struct Expr {
 #define EXPR_TOKENONLYSIZE      offsetof(Expr,pLeft)   /* Fewer features */
 #define EXPR_TOKENONLYSIZE      offsetof(Expr,pLeft)   /* Fewer features */
 
 
 /*
 /*
-** Flags passed to the sqlite3ExprDup() function. See the header comment 
+** Flags passed to the sqlite3ExprDup() function. See the header comment
 ** above sqlite3ExprDup() for details.
 ** above sqlite3ExprDup() for details.
 */
 */
 #define EXPRDUP_REDUCE         0x0001  /* Used reduced-size Expr nodes */
 #define EXPRDUP_REDUCE         0x0001  /* Used reduced-size Expr nodes */
@@ -2025,12 +2027,12 @@ struct SrcList {
 ** pEList corresponds to the result set of a SELECT and is NULL for
 ** pEList corresponds to the result set of a SELECT and is NULL for
 ** other statements.
 ** other statements.
 **
 **
-** NameContexts can be nested.  When resolving names, the inner-most 
+** NameContexts can be nested.  When resolving names, the inner-most
 ** context is searched first.  If no match is found, the next outer
 ** context is searched first.  If no match is found, the next outer
 ** context is checked.  If there is still no match, the next context
 ** context is checked.  If there is still no match, the next context
 ** is checked.  This process continues until either a match is found
 ** is checked.  This process continues until either a match is found
 ** or all contexts are check.  When a match is found, the nRef member of
 ** or all contexts are check.  When a match is found, the nRef member of
-** the context containing the match is incremented. 
+** the context containing the match is incremented.
 **
 **
 ** Each subquery gets a new NameContext.  The pNext field points to the
 ** Each subquery gets a new NameContext.  The pNext field points to the
 ** NameContext in the parent query.  Thus the process of scanning the
 ** NameContext in the parent query.  Thus the process of scanning the
@@ -2145,7 +2147,7 @@ struct SelectDest {
 };
 };
 
 
 /*
 /*
-** During code generation of statements that do inserts into AUTOINCREMENT 
+** During code generation of statements that do inserts into AUTOINCREMENT
 ** tables, the following information is attached to the Table.u.autoInc.p
 ** tables, the following information is attached to the Table.u.autoInc.p
 ** pointer of each autoincrement table to record some side information that
 ** pointer of each autoincrement table to record some side information that
 ** the code generator needs.  We have to keep per-table autoincrement
 ** the code generator needs.  We have to keep per-table autoincrement
@@ -2168,7 +2170,7 @@ struct AutoincInfo {
 #endif
 #endif
 
 
 /*
 /*
-** At least one instance of the following structure is created for each 
+** At least one instance of the following structure is created for each
 ** trigger that may be fired while parsing an INSERT, UPDATE or DELETE
 ** trigger that may be fired while parsing an INSERT, UPDATE or DELETE
 ** statement. All such objects are stored in the linked list headed at
 ** statement. All such objects are stored in the linked list headed at
 ** Parse.pTriggerPrg and deleted once statement compilation has been
 ** Parse.pTriggerPrg and deleted once statement compilation has been
@@ -2181,7 +2183,7 @@ struct AutoincInfo {
 ** values for both pTrigger and orconf.
 ** values for both pTrigger and orconf.
 **
 **
 ** The TriggerPrg.aColmask[0] variable is set to a mask of old.* columns
 ** The TriggerPrg.aColmask[0] variable is set to a mask of old.* columns
-** accessed (or set to 0 for triggers fired as a result of INSERT 
+** accessed (or set to 0 for triggers fired as a result of INSERT
 ** statements). Similarly, the TriggerPrg.aColmask[1] variable is set to
 ** statements). Similarly, the TriggerPrg.aColmask[1] variable is set to
 ** a mask of new.* columns used by the program.
 ** a mask of new.* columns used by the program.
 */
 */
@@ -2212,7 +2214,7 @@ struct TriggerPrg {
 ** is constant but the second part is reset at the beginning and end of
 ** is constant but the second part is reset at the beginning and end of
 ** each recursion.
 ** each recursion.
 **
 **
-** The nTableLock and aTableLock variables are only used if the shared-cache 
+** The nTableLock and aTableLock variables are only used if the shared-cache
 ** feature is enabled (if sqlite3Tsd()->useSharedData is true). They are
 ** feature is enabled (if sqlite3Tsd()->useSharedData is true). They are
 ** used to store the set of table-locks required by the statement being
 ** used to store the set of table-locks required by the statement being
 ** compiled. Function sqlite3TableLock() is used to add entries to the
 ** compiled. Function sqlite3TableLock() is used to add entries to the
@@ -2345,10 +2347,10 @@ struct AuthContext {
 
 
 /*
 /*
  * Each trigger present in the database schema is stored as an instance of
  * Each trigger present in the database schema is stored as an instance of
- * struct Trigger. 
+ * struct Trigger.
  *
  *
  * Pointers to instances of struct Trigger are stored in two ways.
  * Pointers to instances of struct Trigger are stored in two ways.
- * 1. In the "trigHash" hash table (part of the sqlite3* that represents the 
+ * 1. In the "trigHash" hash table (part of the sqlite3* that represents the
  *    database). This allows Trigger structures to be retrieved by name.
  *    database). This allows Trigger structures to be retrieved by name.
  * 2. All triggers associated with a single table form a linked list, using the
  * 2. All triggers associated with a single table form a linked list, using the
  *    pNext member of struct Trigger. A pointer to the first element of the
  *    pNext member of struct Trigger. A pointer to the first element of the
@@ -2374,7 +2376,7 @@ struct Trigger {
 
 
 /*
 /*
 ** A trigger is either a BEFORE or an AFTER trigger.  The following constants
 ** A trigger is either a BEFORE or an AFTER trigger.  The following constants
-** determine which. 
+** determine which.
 **
 **
 ** If there are multiple triggers, you might of some BEFORE and some AFTER.
 ** If there are multiple triggers, you might of some BEFORE and some AFTER.
 ** In that cases, the constants below can be ORed together.
 ** In that cases, the constants below can be ORed together.
@@ -2384,15 +2386,15 @@ struct Trigger {
 
 
 /*
 /*
  * An instance of struct TriggerStep is used to store a single SQL statement
  * An instance of struct TriggerStep is used to store a single SQL statement
- * that is a part of a trigger-program. 
+ * that is a part of a trigger-program.
  *
  *
  * Instances of struct TriggerStep are stored in a singly linked list (linked
  * Instances of struct TriggerStep are stored in a singly linked list (linked
- * using the "pNext" member) referenced by the "step_list" member of the 
+ * using the "pNext" member) referenced by the "step_list" member of the
  * associated struct Trigger instance. The first element of the linked list is
  * associated struct Trigger instance. The first element of the linked list is
  * the first step of the trigger-program.
  * the first step of the trigger-program.
- * 
+ *
  * The "op" member indicates whether this is a "DELETE", "INSERT", "UPDATE" or
  * The "op" member indicates whether this is a "DELETE", "INSERT", "UPDATE" or
- * "SELECT" statement. The meanings of the other members is determined by the 
+ * "SELECT" statement. The meanings of the other members is determined by the
  * value of "op" as follows:
  * value of "op" as follows:
  *
  *
  * (op == TK_INSERT)
  * (op == TK_INSERT)
@@ -2402,7 +2404,7 @@ struct Trigger {
  * target    -> A token holding the quoted name of the table to insert into.
  * target    -> A token holding the quoted name of the table to insert into.
  * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then
  * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then
  *              this stores values to be inserted. Otherwise NULL.
  *              this stores values to be inserted. Otherwise NULL.
- * pIdList   -> If this is an INSERT INTO ... (<column-names>) VALUES ... 
+ * pIdList   -> If this is an INSERT INTO ... (<column-names>) VALUES ...
  *              statement, then this stores the column-names to be
  *              statement, then this stores the column-names to be
  *              inserted into.
  *              inserted into.
  *
  *
@@ -2410,7 +2412,7 @@ struct Trigger {
  * target    -> A token holding the quoted name of the table to delete from.
  * target    -> A token holding the quoted name of the table to delete from.
  * pWhere    -> The WHERE clause of the DELETE statement if one is specified.
  * pWhere    -> The WHERE clause of the DELETE statement if one is specified.
  *              Otherwise NULL.
  *              Otherwise NULL.
- * 
+ *
  * (op == TK_UPDATE)
  * (op == TK_UPDATE)
  * target    -> A token holding the quoted name of the table to update rows of.
  * target    -> A token holding the quoted name of the table to update rows of.
  * pWhere    -> The WHERE clause of the UPDATE statement if one is specified.
  * pWhere    -> The WHERE clause of the UPDATE statement if one is specified.
@@ -2418,7 +2420,7 @@ struct Trigger {
  * pExprList -> A list of the columns to update and the expressions to update
  * pExprList -> A list of the columns to update and the expressions to update
  *              them to. See sqlite3Update() documentation of "pChanges"
  *              them to. See sqlite3Update() documentation of "pChanges"
  *              argument.
  *              argument.
- * 
+ *
  */
  */
 struct TriggerStep {
 struct TriggerStep {
   u8 op;               /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */
   u8 op;               /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */
@@ -2436,7 +2438,7 @@ struct TriggerStep {
 /*
 /*
 ** The following structure contains information used by the sqliteFix...
 ** The following structure contains information used by the sqliteFix...
 ** routines as they walk the parse tree to make database references
 ** routines as they walk the parse tree to make database references
-** explicit.  
+** explicit.
 */
 */
 typedef struct DbFixer DbFixer;
 typedef struct DbFixer DbFixer;
 struct DbFixer {
 struct DbFixer {
@@ -2662,7 +2664,7 @@ int sqlite3HeapNearlyFull(void);
 #ifdef SQLITE_USE_ALLOCA
 #ifdef SQLITE_USE_ALLOCA
 # define sqlite3StackAllocRaw(D,N)   alloca(N)
 # define sqlite3StackAllocRaw(D,N)   alloca(N)
 # define sqlite3StackAllocZero(D,N)  memset(alloca(N), 0, N)
 # define sqlite3StackAllocZero(D,N)  memset(alloca(N), 0, N)
-# define sqlite3StackFree(D,P)       
+# define sqlite3StackFree(D,P)
 #else
 #else
 # define sqlite3StackAllocRaw(D,N)   sqlite3DbMallocRaw(D,N)
 # define sqlite3StackAllocRaw(D,N)   sqlite3DbMallocRaw(D,N)
 # define sqlite3StackAllocZero(D,N)  sqlite3DbMallocZero(D,N)
 # define sqlite3StackAllocZero(D,N)  sqlite3DbMallocZero(D,N)
@@ -3004,7 +3006,7 @@ u64 sqlite3LogEstToInt(LogEst);
 ** Routines to read and write variable-length integers.  These used to
 ** Routines to read and write variable-length integers.  These used to
 ** be defined locally, but now we use the varint routines in the util.c
 ** be defined locally, but now we use the varint routines in the util.c
 ** file.  Code should use the MACRO forms below, as the Varint32 versions
 ** file.  Code should use the MACRO forms below, as the Varint32 versions
-** are coded to assume the single byte case is already handled (which 
+** are coded to assume the single byte case is already handled (which
 ** the MACRO form does).
 ** the MACRO form does).
 */
 */
 int sqlite3PutVarint(unsigned char*, u64);
 int sqlite3PutVarint(unsigned char*, u64);
@@ -3079,7 +3081,7 @@ u8 sqlite3GetBoolean(const char *z,int);
 
 
 const void *sqlite3ValueText(sqlite3_value*, u8);
 const void *sqlite3ValueText(sqlite3_value*, u8);
 int sqlite3ValueBytes(sqlite3_value*, u8);
 int sqlite3ValueBytes(sqlite3_value*, u8);
-void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8, 
+void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8,
                         void(*)(void*));
                         void(*)(void*));
 void sqlite3ValueFree(sqlite3_value*);
 void sqlite3ValueFree(sqlite3_value*);
 sqlite3_value *sqlite3ValueNew(sqlite3 *);
 sqlite3_value *sqlite3ValueNew(sqlite3 *);
@@ -3131,7 +3133,7 @@ Schema *sqlite3SchemaGet(sqlite3 *, Btree *);
 int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
 int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
 KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int);
 KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int);
 KeyInfo *sqlite3IndexKeyinfo(Parse *, Index *);
 KeyInfo *sqlite3IndexKeyinfo(Parse *, Index *);
-int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *, 
+int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
   void (*)(sqlite3_context*,int,sqlite3_value **),
   void (*)(sqlite3_context*,int,sqlite3_value **),
   void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
   void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
   FuncDestructor *pDestructor
   FuncDestructor *pDestructor
@@ -3189,7 +3191,7 @@ void sqlite3AutoLoadExtensions(sqlite3*);
 #  define sqlite3VtabRollback(X)
 #  define sqlite3VtabRollback(X)
 #  define sqlite3VtabCommit(X)
 #  define sqlite3VtabCommit(X)
 #  define sqlite3VtabInSync(db) 0
 #  define sqlite3VtabInSync(db) 0
-#  define sqlite3VtabLock(X) 
+#  define sqlite3VtabLock(X)
 #  define sqlite3VtabUnlock(X)
 #  define sqlite3VtabUnlock(X)
 #  define sqlite3VtabUnlockList(X)
 #  define sqlite3VtabUnlockList(X)
 #  define sqlite3VtabSavepoint(X, Y, Z) SQLITE_OK
 #  define sqlite3VtabSavepoint(X, Y, Z) SQLITE_OK
@@ -3236,7 +3238,7 @@ const char *sqlite3JournalModename(int);
 ** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign
 ** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign
 ** key functionality is available. If OMIT_TRIGGER is defined but
 ** key functionality is available. If OMIT_TRIGGER is defined but
 ** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In
 ** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In
-** this case foreign keys are parsed, but no other functionality is 
+** this case foreign keys are parsed, but no other functionality is
 ** provided (enforcement of FK constraints requires the triggers sub-system).
 ** provided (enforcement of FK constraints requires the triggers sub-system).
 */
 */
 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
@@ -3331,7 +3333,7 @@ void sqlite3Put4byte(u8*, u32);
 /*
 /*
 ** If the SQLITE_ENABLE IOTRACE exists then the global variable
 ** If the SQLITE_ENABLE IOTRACE exists then the global variable
 ** sqlite3IoTrace is a pointer to a printf-like routine used to
 ** sqlite3IoTrace is a pointer to a printf-like routine used to
-** print I/O tracing messages. 
+** print I/O tracing messages.
 */
 */
 #ifdef SQLITE_ENABLE_IOTRACE
 #ifdef SQLITE_ENABLE_IOTRACE
 # define IOTRACE(A)  if( sqlite3IoTrace ){ sqlite3IoTrace A; }
 # define IOTRACE(A)  if( sqlite3IoTrace ){ sqlite3IoTrace A; }
@@ -3365,7 +3367,7 @@ SQLITE_EXTERN void (*sqlite3IoTrace)(const char*,...);
 ** that allocations that might have been satisfied by lookaside are not
 ** that allocations that might have been satisfied by lookaside are not
 ** passed back to non-lookaside free() routines.  Asserts such as the
 ** passed back to non-lookaside free() routines.  Asserts such as the
 ** example above are placed on the non-lookaside free() routines to verify
 ** example above are placed on the non-lookaside free() routines to verify
-** this constraint. 
+** this constraint.
 **
 **
 ** All of this is no-op for a production build.  It only comes into
 ** All of this is no-op for a production build.  It only comes into
 ** play when the SQLITE_MEMDEBUG compile-time option is used.
 ** play when the SQLITE_MEMDEBUG compile-time option is used.

+ 2 - 0
components/external/SQLite-3.8.1/tool/mksqlite3c.tcl

@@ -247,6 +247,7 @@ foreach file {
    mutex_noop.c
    mutex_noop.c
    mutex_unix.c
    mutex_unix.c
    mutex_w32.c
    mutex_w32.c
+   mutex_rtt.c
    malloc.c
    malloc.c
    printf.c
    printf.c
    random.c
    random.c
@@ -257,6 +258,7 @@ foreach file {
 
 
    os_unix.c
    os_unix.c
    os_win.c
    os_win.c
+   os_rtt.c
 
 
    bitvec.c
    bitvec.c
    pcache.c
    pcache.c