SQLite4
Check-in [035df9b1de]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix over-length source code lines in sqliteInt.h.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 035df9b1de8c5af520d9f4a58b2a6e797bcb6d72
User & Date: drh 2013-02-22 20:23:12
Context
2013-02-23
14:16
Add the "Programmers Introduction To SQLite4" document outlining the desired API for SQLite4. check-in: a4782fccbe user: drh tags: trunk
2013-02-22
20:23
Fix over-length source code lines in sqliteInt.h. check-in: 035df9b1de user: drh tags: trunk
2013-02-21
19:56
Add other notes to lsm.wiki. check-in: ec9a805164 user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/sqliteInt.h.

164
165
166
167
168
169
170
171

172
173
174
175

176
177
178
179
180
181
182
...
193
194
195
196
197
198
199
200

201
202
203
204
205
206
207
...
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
...
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
....
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
....
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
....
2737
2738
2739
2740
2741
2742
2743
2744
2745

2746
2747
2748
2749
2750
2751
2752
....
2918
2919
2920
2921
2922
2923
2924
2925

2926


2927
2928
2929
2930
2931
2932
2933
**
** (Historical note:  There used to be several other options, but we've
** pared it down to just these three.)
**
** If none of the above are defined, then set SQLITE4_SYSTEM_MALLOC as
** the default.
*/
#if defined(SQLITE4_SYSTEM_MALLOC)+defined(SQLITE4_WIN32_MALLOC)+defined(SQLITE4_MEMDEBUG)>1

# error "At most one of the following compile-time configuration options\
 is allows: SQLITE4_SYSTEM_MALLOC, SQLITE4_WIN32_MALLOC, SQLITE4_MEMDEBUG"
#endif
#if defined(SQLITE4_SYSTEM_MALLOC)+defined(SQLITE4_WIN32_MALLOC)+defined(SQLITE4_MEMDEBUG)==0

# define SQLITE4_SYSTEM_MALLOC 1
#endif

/*
** If SQLITE4_MALLOC_SOFT_LIMIT is not zero, then try to keep the
** sizes of memory allocations below this value where possible.
*/
................................................................................
** Later we learn that _XOPEN_SOURCE is poorly or incorrectly
** implemented on some systems.  So we avoid defining it at all
** if it is already defined or if it is unneeded because we are
** not doing a threadsafe build.  Ticket #2681.
**
** See also ticket #2741.
*/
#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__) && SQLITE4_THREADSAFE

#  define _XOPEN_SOURCE 500  /* Needed to enable pthread recursive mutexes */
#endif

/*
** The TCL headers are only needed when compiling the TCL bindings.
*/
#if defined(SQLITE4_TCL) || defined(TCLSH)
................................................................................
#define SQLITE4_VdbeAddopTrace 0x00001000  /* Trace sqlite4VdbeAddOp() calls */
#define SQLITE4_InternChanges  0x00010000  /* Uncommitted Hash table changes */
#define SQLITE4_WriteSchema    0x00020000  /* OK to update SQLITE4_MASTER */
#define SQLITE4_IgnoreChecks   0x00040000  /* Dont enforce check constraints */
#define SQLITE4_RecoveryMode   0x00080000  /* Ignore schema errors */
#define SQLITE4_ReverseOrder   0x01000000  /* Reverse unordered SELECTs */
#define SQLITE4_RecTriggers    0x02000000  /* Enable recursive triggers */
#define SQLITE4_ForeignKeys    0x04000000  /* Enforce foreign key constraints  */
#define SQLITE4_AutoIndex      0x08000000  /* Enable automatic indexes */
#define SQLITE4_PreferBuiltin  0x10000000  /* Preference to built-in funcs */
#define SQLITE4_EnableTrigger  0x40000000  /* True to enable triggers */

/*
** Bits of the sqlite4.flags field that are used by the
** sqlite4_test_control(SQLITE4_TESTCTRL_OPTIMIZATIONS,...) interface.
** These must be the low-order bits of the flags field.
*/
#define SQLITE4_QueryFlattener 0x01        /* Disable query flattening */
#define SQLITE4_ColumnCache    0x02        /* Disable the column cache */
#define SQLITE4_IndexSort      0x04        /* Disable indexes for sorting */
#define SQLITE4_IndexSearch    0x08        /* Disable indexes for searching */
#define SQLITE4_IndexCover     0x10        /* Disable index covering table */
#define SQLITE4_GroupByOrder   0x20        /* Disable GROUPBY cover of ORDERBY */
#define SQLITE4_FactorOutConst 0x40        /* Disable factoring out constants */
#define SQLITE4_IdxRealAsInt   0x80        /* Store REAL as INT in indices */
#define SQLITE4_DistinctOpt    0x80        /* DISTINCT using indexes */
#define SQLITE4_OptMask        0xff        /* Mask of all disablable opts */

/*
** Possible values for the sqlite.magic field.
** The numbers are obtained at random and have no special meaning, other
** than being distinct from one another.
*/
#define SQLITE4_MAGIC_OPEN     0xa029a697  /* Database is open */
#define SQLITE4_MAGIC_CLOSED   0x9f3c2d33  /* Database is closed */
#define SQLITE4_MAGIC_SICK     0x4b771290  /* Error and awaiting close */
#define SQLITE4_MAGIC_BUSY     0xf03b7906  /* Database currently in use */
#define SQLITE4_MAGIC_ERROR    0xb5357930  /* An SQLITE4_MISUSE error occurred */

/*
** This structure encapsulates a user-function destructor callback (as
** configured using create_function_v2()) and a reference counter. When
** 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 
** the number of FuncDef objects created (either 1 or 3, depending on whether
................................................................................
*/
#define SQLITE4_FUNC_LIKE     0x01 /* Candidate for the LIKE optimization */
#define SQLITE4_FUNC_CASE     0x02 /* Case-sensitive LIKE-type function */
#define SQLITE4_FUNC_EPHEM    0x04 /* Ephemeral.  Delete with VDBE */
#define SQLITE4_FUNC_NEEDCOLL 0x08 /* sqlite4GetFuncCollSeq() might be called */
#define SQLITE4_FUNC_PRIVATE  0x10 /* Allowed for internal use only */
#define SQLITE4_FUNC_COUNT    0x20 /* Built-in count(*) aggregate */
#define SQLITE4_FUNC_COALESCE 0x40 /* Built-in coalesce() or ifnull() function */

/*
** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
** used to create the initializers for the FuncDef structures.
**
**   FUNCTION(zName, nArg, iArg, bNC, xFunc)
**     Used to create a scalar function definition of a function zName 
................................................................................
*/
#define SQLITE4_AFF_MASK     0x67

/*
** Additional bit values that can be ORed with an affinity without
** changing the affinity.
*/
#define SQLITE4_JUMPIFNULL   0x08  /* jumps if either operand is NULL */
#define SQLITE4_STOREP2      0x10  /* Store result in reg[P2] rather than jump */
#define SQLITE4_NULLEQ       0x80  /* NULL=NULL */

/*
** An object of this type is created for each virtual table present in
** the database schema. 
**
** If the database schema is shared, then there is one instance of this
** structure for each database connection (sqlite4*) that uses the shared
................................................................................
  int nOnce;           /* Number of OP_Once instructions so far */
  int ckBase;          /* Base register of data during check constraints */
  int iCacheLevel;     /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
  int iCacheCnt;       /* Counter used to generate aColCache[].lru values */
  int iNewidxReg;      /* First argument to OP_NewIdxid */
  u8 nColCache;        /* Number of entries in aColCache[] */
  u8 iColCache;        /* Next entry in aColCache[] to replace */
  ParseYColCache aColCache[SQLITE4_N_COLCACHE]; /* One for each column cache entry */
  yDbMask writeMask;   /* Start a write transaction on these databases */
  yDbMask cookieMask;  /* Bitmask of schema verified databases */
  u8 isMultiWrite;     /* True if statement may affect/insert multiple rows */
  u8 mayAbort;         /* True if statement may throw an ABORT exception */
  int cookieGoto;      /* Address of OP_Goto to cookie verifier subroutine */
  int cookieValue[SQLITE4_MAX_ATTACHED+2];  /* Values of cookies to verify */
  int regRowid;        /* Register holding rowid of CREATE TABLE entry */
................................................................................
int sqlite4Select(Parse*, Select*, SelectDest*);
Select *sqlite4SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
                         Expr*,ExprList*,int,Expr*,Expr*);
void sqlite4SelectDelete(sqlite4*, Select*);
Table *sqlite4SrcListLookup(Parse*, SrcList*);
int sqlite4IsReadOnly(Parse*, Table*, int);
void sqlite4OpenTable(Parse*, int iCur, int iDb, Table*, int);
#if defined(SQLITE4_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE4_OMIT_SUBQUERY)
Expr *sqlite4LimitWhere(Parse *, SrcList *, Expr *, ExprList *, Expr *, Expr *, char *);

#endif
void sqlite4DeleteFrom(Parse*, SrcList*, Expr*);
void sqlite4Update(Parse*, SrcList*, ExprList*, Expr*, int);
WhereInfo *sqlite4WhereBegin(Parse*, SrcList*, Expr*, ExprList**,ExprList*,u16);
void sqlite4WhereEnd(WhereInfo*);
int sqlite4ExprCodeGetColumn(Parse*, Table*, int, int, int);
void sqlite4ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
................................................................................
**     x = sqlite4GetVarint32( A, &B );
**     x = sqlite4PutVarint32( A, B );
**
**     x = getVarint32( A, B );
**     x = putVarint32( A, B );
**
*/
#define getVarint32(A,B)  (u8)((*(A)<(u8)0x80) ? ((B) = (u32)*(A)),1 : sqlite4GetVarint32((A), (u32 *)&(B)))

#define putVarint32(A,B)  (u8)(((u32)(B)<(u32)0x80) ? (*(A) = (unsigned char)(B)),1 : sqlite4PutVarint32((A), (B)))


#define getVarint    sqlite4GetVarint
#define putVarint    sqlite4PutVarint


const char *sqlite4IndexAffinityStr(Vdbe *, Index *);
void sqlite4TableAffinityStr(Vdbe *, Table *);
char sqlite4CompareAffinity(Expr *pExpr, char aff2);







|
>



|
>







 







|
>







 







|









|
|
|
|
|
|
|
|
|
|






|
|
|
|
|







 







|







 







|
|
|







 







|







 







|
|
>







 







|
>
|
>
>







164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
...
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
...
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
...
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
....
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
....
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
....
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
....
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
**
** (Historical note:  There used to be several other options, but we've
** pared it down to just these three.)
**
** If none of the above are defined, then set SQLITE4_SYSTEM_MALLOC as
** the default.
*/
#if defined(SQLITE4_SYSTEM_MALLOC)+defined(SQLITE4_WIN32_MALLOC)\
   +defined(SQLITE4_MEMDEBUG)>1
# error "At most one of the following compile-time configuration options\
 is allows: SQLITE4_SYSTEM_MALLOC, SQLITE4_WIN32_MALLOC, SQLITE4_MEMDEBUG"
#endif
#if defined(SQLITE4_SYSTEM_MALLOC)+defined(SQLITE4_WIN32_MALLOC)\
   +defined(SQLITE4_MEMDEBUG)==0
# define SQLITE4_SYSTEM_MALLOC 1
#endif

/*
** If SQLITE4_MALLOC_SOFT_LIMIT is not zero, then try to keep the
** sizes of memory allocations below this value where possible.
*/
................................................................................
** Later we learn that _XOPEN_SOURCE is poorly or incorrectly
** implemented on some systems.  So we avoid defining it at all
** if it is already defined or if it is unneeded because we are
** not doing a threadsafe build.  Ticket #2681.
**
** See also ticket #2741.
*/
#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)\
     && SQLITE4_THREADSAFE
#  define _XOPEN_SOURCE 500  /* Needed to enable pthread recursive mutexes */
#endif

/*
** The TCL headers are only needed when compiling the TCL bindings.
*/
#if defined(SQLITE4_TCL) || defined(TCLSH)
................................................................................
#define SQLITE4_VdbeAddopTrace 0x00001000  /* Trace sqlite4VdbeAddOp() calls */
#define SQLITE4_InternChanges  0x00010000  /* Uncommitted Hash table changes */
#define SQLITE4_WriteSchema    0x00020000  /* OK to update SQLITE4_MASTER */
#define SQLITE4_IgnoreChecks   0x00040000  /* Dont enforce check constraints */
#define SQLITE4_RecoveryMode   0x00080000  /* Ignore schema errors */
#define SQLITE4_ReverseOrder   0x01000000  /* Reverse unordered SELECTs */
#define SQLITE4_RecTriggers    0x02000000  /* Enable recursive triggers */
#define SQLITE4_ForeignKeys    0x04000000  /* Enable foreign key constraints */
#define SQLITE4_AutoIndex      0x08000000  /* Enable automatic indexes */
#define SQLITE4_PreferBuiltin  0x10000000  /* Preference to built-in funcs */
#define SQLITE4_EnableTrigger  0x40000000  /* True to enable triggers */

/*
** Bits of the sqlite4.flags field that are used by the
** sqlite4_test_control(SQLITE4_TESTCTRL_OPTIMIZATIONS,...) interface.
** These must be the low-order bits of the flags field.
*/
#define SQLITE4_QueryFlattener 0x01     /* Disable query flattening */
#define SQLITE4_ColumnCache    0x02     /* Disable the column cache */
#define SQLITE4_IndexSort      0x04     /* Disable indexes for sorting */
#define SQLITE4_IndexSearch    0x08     /* Disable indexes for searching */
#define SQLITE4_IndexCover     0x10     /* Disable index covering table */
#define SQLITE4_GroupByOrder   0x20     /* Disable GROUPBY cover of ORDERBY */
#define SQLITE4_FactorOutConst 0x40     /* Disable factoring out constants */
#define SQLITE4_IdxRealAsInt   0x80     /* Store REAL as INT in indices */
#define SQLITE4_DistinctOpt    0x80     /* DISTINCT using indexes */
#define SQLITE4_OptMask        0xff     /* Mask of all disablable opts */

/*
** Possible values for the sqlite.magic field.
** The numbers are obtained at random and have no special meaning, other
** than being distinct from one another.
*/
#define SQLITE4_MAGIC_OPEN    0x4d06c919  /* Database is open */
#define SQLITE4_MAGIC_CLOSED  0x5f2246b4  /* Database is closed */
#define SQLITE4_MAGIC_SICK    0xcaad9e61  /* Error and awaiting close */
#define SQLITE4_MAGIC_BUSY    0xb07f8c8c  /* Database currently in use */
#define SQLITE4_MAGIC_ERROR   0x912e4c46  /* An SQLITE4_MISUSE error occurred */

/*
** This structure encapsulates a user-function destructor callback (as
** configured using create_function_v2()) and a reference counter. When
** 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 
** the number of FuncDef objects created (either 1 or 3, depending on whether
................................................................................
*/
#define SQLITE4_FUNC_LIKE     0x01 /* Candidate for the LIKE optimization */
#define SQLITE4_FUNC_CASE     0x02 /* Case-sensitive LIKE-type function */
#define SQLITE4_FUNC_EPHEM    0x04 /* Ephemeral.  Delete with VDBE */
#define SQLITE4_FUNC_NEEDCOLL 0x08 /* sqlite4GetFuncCollSeq() might be called */
#define SQLITE4_FUNC_PRIVATE  0x10 /* Allowed for internal use only */
#define SQLITE4_FUNC_COUNT    0x20 /* Built-in count(*) aggregate */
#define SQLITE4_FUNC_COALESCE 0x40 /* Built-in coalesce() or ifnull() func */

/*
** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
** used to create the initializers for the FuncDef structures.
**
**   FUNCTION(zName, nArg, iArg, bNC, xFunc)
**     Used to create a scalar function definition of a function zName 
................................................................................
*/
#define SQLITE4_AFF_MASK     0x67

/*
** Additional bit values that can be ORed with an affinity without
** changing the affinity.
*/
#define SQLITE4_JUMPIFNULL  0x08  /* jumps if either operand is NULL */
#define SQLITE4_STOREP2     0x10  /* Store result in reg[P2] rather than jump */
#define SQLITE4_NULLEQ      0x80  /* NULL=NULL */

/*
** An object of this type is created for each virtual table present in
** the database schema. 
**
** If the database schema is shared, then there is one instance of this
** structure for each database connection (sqlite4*) that uses the shared
................................................................................
  int nOnce;           /* Number of OP_Once instructions so far */
  int ckBase;          /* Base register of data during check constraints */
  int iCacheLevel;     /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
  int iCacheCnt;       /* Counter used to generate aColCache[].lru values */
  int iNewidxReg;      /* First argument to OP_NewIdxid */
  u8 nColCache;        /* Number of entries in aColCache[] */
  u8 iColCache;        /* Next entry in aColCache[] to replace */
  ParseYColCache aColCache[SQLITE4_N_COLCACHE]; /* One per colcache entry */
  yDbMask writeMask;   /* Start a write transaction on these databases */
  yDbMask cookieMask;  /* Bitmask of schema verified databases */
  u8 isMultiWrite;     /* True if statement may affect/insert multiple rows */
  u8 mayAbort;         /* True if statement may throw an ABORT exception */
  int cookieGoto;      /* Address of OP_Goto to cookie verifier subroutine */
  int cookieValue[SQLITE4_MAX_ATTACHED+2];  /* Values of cookies to verify */
  int regRowid;        /* Register holding rowid of CREATE TABLE entry */
................................................................................
int sqlite4Select(Parse*, Select*, SelectDest*);
Select *sqlite4SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
                         Expr*,ExprList*,int,Expr*,Expr*);
void sqlite4SelectDelete(sqlite4*, Select*);
Table *sqlite4SrcListLookup(Parse*, SrcList*);
int sqlite4IsReadOnly(Parse*, Table*, int);
void sqlite4OpenTable(Parse*, int iCur, int iDb, Table*, int);
#if defined(SQLITE4_ENABLE_UPDATE_DELETE_LIMIT) \
    && !defined(SQLITE4_OMIT_SUBQUERY)
Expr *sqlite4LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,Expr*,char*);
#endif
void sqlite4DeleteFrom(Parse*, SrcList*, Expr*);
void sqlite4Update(Parse*, SrcList*, ExprList*, Expr*, int);
WhereInfo *sqlite4WhereBegin(Parse*, SrcList*, Expr*, ExprList**,ExprList*,u16);
void sqlite4WhereEnd(WhereInfo*);
int sqlite4ExprCodeGetColumn(Parse*, Table*, int, int, int);
void sqlite4ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
................................................................................
**     x = sqlite4GetVarint32( A, &B );
**     x = sqlite4PutVarint32( A, B );
**
**     x = getVarint32( A, B );
**     x = putVarint32( A, B );
**
*/
#define getVarint32(A,B)  \
  (u8)((*(A)<(u8)0x80)?((B)=(u32)*(A)),1:sqlite4GetVarint32((A),(u32 *)&(B)))
#define putVarint32(A,B)  \
  (u8)(((u32)(B)<(u32)0x80)?(*(A)=(unsigned char)(B)),1\
  :sqlite4PutVarint32((A),(B)))
#define getVarint    sqlite4GetVarint
#define putVarint    sqlite4PutVarint


const char *sqlite4IndexAffinityStr(Vdbe *, Index *);
void sqlite4TableAffinityStr(Vdbe *, Table *);
char sqlite4CompareAffinity(Expr *pExpr, char aff2);