Fossil SCM

merge trunk

jan.nijtmans 2013-08-02 09:42 UTC possible-cygwin-fix merge
Commit 863068e0f0be44aaa7ec4c5090fb1fbce0f63510
+14 -13
--- src/checkin.c
+++ src/checkin.c
@@ -1687,10 +1687,24 @@
16871687
** and rollback the transaction.
16881688
*/
16891689
if( dryRunFlag ){
16901690
blob_write_to_file(&manifest, "");
16911691
}
1692
+ if( outputManifest ){
1693
+ zManifestFile = mprintf("%smanifest", g.zLocalRoot);
1694
+ blob_write_to_file(&manifest, zManifestFile);
1695
+ blob_reset(&manifest);
1696
+ blob_read_from_file(&manifest, zManifestFile);
1697
+ free(zManifestFile);
1698
+ }
1699
+
1700
+ nvid = content_put(&manifest);
1701
+ if( nvid==0 ){
1702
+ fossil_panic("trouble committing manifest: %s", g.zErrMsg);
1703
+ }
1704
+ db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid);
1705
+ manifest_crosslink(nvid, &manifest);
16921706
16931707
db_prepare(&q, "SELECT uuid,merge FROM vmerge JOIN blob ON merge=rid"
16941708
" WHERE id=-4");
16951709
while( db_step(&q)==SQLITE_ROW ){
16961710
const char *zIntegrateUuid = db_column_text(&q, 0);
@@ -1721,23 +1735,10 @@
17211735
fossil_print("Closed: %s\n", zIntegrateUuid);
17221736
}
17231737
}
17241738
db_finalize(&q);
17251739
1726
- if( outputManifest ){
1727
- zManifestFile = mprintf("%smanifest", g.zLocalRoot);
1728
- blob_write_to_file(&manifest, zManifestFile);
1729
- blob_reset(&manifest);
1730
- blob_read_from_file(&manifest, zManifestFile);
1731
- free(zManifestFile);
1732
- }
1733
- nvid = content_put(&manifest);
1734
- if( nvid==0 ){
1735
- fossil_panic("trouble committing manifest: %s", g.zErrMsg);
1736
- }
1737
- db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid);
1738
- manifest_crosslink(nvid, &manifest);
17391740
assert( blob_is_reset(&manifest) );
17401741
content_deltify(vid, nvid, 0);
17411742
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", nvid);
17421743
fossil_print("New_Version: %s\n", zUuid);
17431744
if( outputManifest ){
17441745
--- src/checkin.c
+++ src/checkin.c
@@ -1687,10 +1687,24 @@
1687 ** and rollback the transaction.
1688 */
1689 if( dryRunFlag ){
1690 blob_write_to_file(&manifest, "");
1691 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1692
1693 db_prepare(&q, "SELECT uuid,merge FROM vmerge JOIN blob ON merge=rid"
1694 " WHERE id=-4");
1695 while( db_step(&q)==SQLITE_ROW ){
1696 const char *zIntegrateUuid = db_column_text(&q, 0);
@@ -1721,23 +1735,10 @@
1721 fossil_print("Closed: %s\n", zIntegrateUuid);
1722 }
1723 }
1724 db_finalize(&q);
1725
1726 if( outputManifest ){
1727 zManifestFile = mprintf("%smanifest", g.zLocalRoot);
1728 blob_write_to_file(&manifest, zManifestFile);
1729 blob_reset(&manifest);
1730 blob_read_from_file(&manifest, zManifestFile);
1731 free(zManifestFile);
1732 }
1733 nvid = content_put(&manifest);
1734 if( nvid==0 ){
1735 fossil_panic("trouble committing manifest: %s", g.zErrMsg);
1736 }
1737 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid);
1738 manifest_crosslink(nvid, &manifest);
1739 assert( blob_is_reset(&manifest) );
1740 content_deltify(vid, nvid, 0);
1741 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", nvid);
1742 fossil_print("New_Version: %s\n", zUuid);
1743 if( outputManifest ){
1744
--- src/checkin.c
+++ src/checkin.c
@@ -1687,10 +1687,24 @@
1687 ** and rollback the transaction.
1688 */
1689 if( dryRunFlag ){
1690 blob_write_to_file(&manifest, "");
1691 }
1692 if( outputManifest ){
1693 zManifestFile = mprintf("%smanifest", g.zLocalRoot);
1694 blob_write_to_file(&manifest, zManifestFile);
1695 blob_reset(&manifest);
1696 blob_read_from_file(&manifest, zManifestFile);
1697 free(zManifestFile);
1698 }
1699
1700 nvid = content_put(&manifest);
1701 if( nvid==0 ){
1702 fossil_panic("trouble committing manifest: %s", g.zErrMsg);
1703 }
1704 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid);
1705 manifest_crosslink(nvid, &manifest);
1706
1707 db_prepare(&q, "SELECT uuid,merge FROM vmerge JOIN blob ON merge=rid"
1708 " WHERE id=-4");
1709 while( db_step(&q)==SQLITE_ROW ){
1710 const char *zIntegrateUuid = db_column_text(&q, 0);
@@ -1721,23 +1735,10 @@
1735 fossil_print("Closed: %s\n", zIntegrateUuid);
1736 }
1737 }
1738 db_finalize(&q);
1739
 
 
 
 
 
 
 
 
 
 
 
 
 
1740 assert( blob_is_reset(&manifest) );
1741 content_deltify(vid, nvid, 0);
1742 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", nvid);
1743 fossil_print("New_Version: %s\n", zUuid);
1744 if( outputManifest ){
1745
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -98,11 +98,11 @@
9898
@ SELECT
9999
@ NULL,
100100
@ blob.rid,
101101
@ uuid,
102102
@ CAST(strftime('%%s',event.mtime) AS INTEGER),
103
- @ datetime(event.mtime,'utc'),
103
+ @ datetime(event.mtime),
104104
@ coalesce(ecomment, comment),
105105
@ coalesce(euser, user),
106106
@ blob.rid IN leaf,
107107
@ bgcolor,
108108
@ event.type,
109109
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -98,11 +98,11 @@
98 @ SELECT
99 @ NULL,
100 @ blob.rid,
101 @ uuid,
102 @ CAST(strftime('%%s',event.mtime) AS INTEGER),
103 @ datetime(event.mtime,'utc'),
104 @ coalesce(ecomment, comment),
105 @ coalesce(euser, user),
106 @ blob.rid IN leaf,
107 @ bgcolor,
108 @ event.type,
109
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -98,11 +98,11 @@
98 @ SELECT
99 @ NULL,
100 @ blob.rid,
101 @ uuid,
102 @ CAST(strftime('%%s',event.mtime) AS INTEGER),
103 @ datetime(event.mtime),
104 @ coalesce(ecomment, comment),
105 @ coalesce(euser, user),
106 @ blob.rid IN leaf,
107 @ bgcolor,
108 @ event.type,
109
+176 -222
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -398,10 +398,13 @@
398398
**
399399
** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
400400
** assert() macro is enabled, each call into the Win32 native heap subsystem
401401
** will cause HeapValidate to be called. If heap validation should fail, an
402402
** assertion will be triggered.
403
+**
404
+** (Historical note: There used to be several other options, but we've
405
+** pared it down to just these three.)
403406
**
404407
** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
405408
** the default.
406409
*/
407410
#if defined(SQLITE_SYSTEM_MALLOC) \
@@ -436,17 +439,24 @@
436439
*/
437440
#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
438441
# define _XOPEN_SOURCE 600
439442
#endif
440443
444
+/*
445
+** The TCL headers are only needed when compiling the TCL bindings.
446
+*/
447
+#if defined(SQLITE_TCL) || defined(TCLSH)
448
+# include <tcl.h>
449
+#endif
450
+
441451
/*
442452
** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
443453
** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
444454
** make it true by defining or undefining NDEBUG.
445455
**
446
-** Setting NDEBUG makes the code smaller and faster by disabling the
447
-** assert() statements in the code. So we want the default action
456
+** Setting NDEBUG makes the code smaller and run faster by disabling the
457
+** number assert() statements in the code. So we want the default action
448458
** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
449459
** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
450460
** feature.
451461
*/
452462
#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -512,11 +522,11 @@
512522
** hint of unplanned behavior.
513523
**
514524
** In other words, ALWAYS and NEVER are added for defensive code.
515525
**
516526
** When doing coverage testing ALWAYS and NEVER are hard-coded to
517
-** be true and false so that the unreachable code they specify will
527
+** be true and false so that the unreachable code then specify will
518528
** not be counted as untested code.
519529
*/
520530
#if defined(SQLITE_COVERAGE_TEST)
521531
# define ALWAYS(X) (1)
522532
# define NEVER(X) (0)
@@ -536,16 +546,20 @@
536546
#define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
537547
538548
/*
539549
** The macro unlikely() is a hint that surrounds a boolean
540550
** expression that is usually false. Macro likely() surrounds
541
-** a boolean expression that is usually true. These hints could,
542
-** in theory, be used by the compiler to generate better code, but
543
-** currently they are just comments for human readers.
551
+** a boolean expression that is usually true. GCC is able to
552
+** use these hints to generate better code, sometimes.
544553
*/
545
-#define likely(X) (X)
546
-#define unlikely(X) (X)
554
+#if defined(__GNUC__) && 0
555
+# define likely(X) __builtin_expect((X),1)
556
+# define unlikely(X) __builtin_expect((X),0)
557
+#else
558
+# define likely(X) !!(X)
559
+# define unlikely(X) !!(X)
560
+#endif
547561
548562
/************** Include sqlite3.h in the middle of sqliteInt.h ***************/
549563
/************** Begin file sqlite3.h *****************************************/
550564
/*
551565
** 2001 September 15
@@ -656,11 +670,11 @@
656670
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
657671
** [sqlite_version()] and [sqlite_source_id()].
658672
*/
659673
#define SQLITE_VERSION "3.8.0"
660674
#define SQLITE_VERSION_NUMBER 3008000
661
-#define SQLITE_SOURCE_ID "2013-07-31 23:28:36 136fc2931b156f91cdd76a7a009298cdf09d826a"
675
+#define SQLITE_SOURCE_ID "2013-07-18 14:50:56 5dcffa671f592ae9355628afa439ae9a2d26f0cd"
662676
663677
/*
664678
** CAPI3REF: Run-Time Library Version Numbers
665679
** KEYWORDS: sqlite3_version, sqlite3_sourceid
666680
**
@@ -1025,11 +1039,10 @@
10251039
#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
10261040
#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
10271041
#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
10281042
#define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
10291043
#define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
1030
-#define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
10311044
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
10321045
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
10331046
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
10341047
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
10351048
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -3109,12 +3122,11 @@
31093122
** interface is to keep a GUI updated during a large query.
31103123
**
31113124
** ^The parameter P is passed through as the only parameter to the
31123125
** callback function X. ^The parameter N is the approximate number of
31133126
** [virtual machine instructions] that are evaluated between successive
3114
-** invocations of the callback X. ^If N is less than one then the progress
3115
-** handler is disabled.
3127
+** invocations of the callback X.
31163128
**
31173129
** ^Only a single progress handler may be defined at one time per
31183130
** [database connection]; setting a new progress handler cancels the
31193131
** old one. ^Setting parameter X to NULL disables the progress handler.
31203132
** ^The progress handler is also disabled by setting N to a value less
@@ -4730,49 +4742,50 @@
47304742
SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
47314743
47324744
/*
47334745
** CAPI3REF: Function Auxiliary Data
47344746
**
4735
-** These functions may be used by (non-aggregate) SQL functions to
4747
+** The following two functions may be used by scalar SQL functions to
47364748
** associate metadata with argument values. If the same value is passed to
47374749
** multiple invocations of the same SQL function during query execution, under
4738
-** some circumstances the associated metadata may be preserved. An example
4739
-** of where this might be useful is in a regular-expression matching
4740
-** function. The compiled version of the regular expression can be stored as
4741
-** metadata associated with the pattern string.
4742
-** Then as long as the pattern string remains the same,
4743
-** the compiled regular expression can be reused on multiple
4744
-** invocations of the same function.
4750
+** some circumstances the associated metadata may be preserved. This might
4751
+** be used, for example, in a regular-expression matching
4752
+** function. The compiled version of the regular expression is stored as
4753
+** metadata associated with the SQL value passed as the regular expression
4754
+** pattern. The compiled regular expression can be reused on multiple
4755
+** invocations of the same function so that the original pattern string
4756
+** does not need to be recompiled on each invocation.
47454757
**
47464758
** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
47474759
** associated by the sqlite3_set_auxdata() function with the Nth argument
4748
-** value to the application-defined function. ^If there is no metadata
4749
-** associated with the function argument, this sqlite3_get_auxdata() interface
4750
-** returns a NULL pointer.
4760
+** value to the application-defined function. ^If no metadata has been ever
4761
+** been set for the Nth argument of the function, or if the corresponding
4762
+** function parameter has changed since the meta-data was set,
4763
+** then sqlite3_get_auxdata() returns a NULL pointer.
47514764
**
47524765
** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
47534766
** argument of the application-defined function. ^Subsequent
47544767
** calls to sqlite3_get_auxdata(C,N) return P from the most recent
4755
-** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or
4756
-** NULL if the metadata has been discarded.
4757
-** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
4758
-** SQLite will invoke the destructor function X with parameter P exactly
4759
-** once, when the metadata is discarded.
4760
-** SQLite is free to discard the metadata at any time, including: <ul>
4761
-** <li> when the corresponding function parameter changes, or
4762
-** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4763
-** SQL statement, or
4764
-** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or
4765
-** <li> during the original sqlite3_set_auxdata() call when a memory
4766
-** allocation error occurs. </ul>)^
4768
+** sqlite3_set_auxdata(C,N,P,X) call if the data has not been dropped, or
4769
+** NULL if the data has been dropped.
4770
+** ^(If it is not NULL, SQLite will invoke the destructor
4771
+** function X passed to sqlite3_set_auxdata(C,N,P,X) when <ul>
4772
+** <li> the corresponding function parameter changes,
4773
+** <li> [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4774
+** SQL statement,
4775
+** <li> sqlite3_set_auxdata() is invoked again on the same parameter, or
4776
+** <li> a memory allocation error occurs. </ul>)^
47674777
**
4768
-** Note the last bullet in particular. The destructor X in
4769
-** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
4770
-** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
4778
+** SQLite is free to call the destructor and drop metadata on any
4779
+** parameter of any function at any time. ^The only guarantee is that
4780
+** the destructor will be called when the [prepared statement] is destroyed.
4781
+** Note in particular that the destructor X in the call to
4782
+** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before
4783
+** the sqlite3_set_auxdata() call even returns. Hence sqlite3_set_auxdata()
47714784
** should be called near the end of the function implementation and the
4772
-** function implementation should not make any use of P after
4773
-** sqlite3_set_auxdata() has been called.
4785
+** implementation should not make any use of P after sqlite3_set_auxdata()
4786
+** has been called.
47744787
**
47754788
** ^(In practice, metadata is preserved between function calls for
47764789
** function parameters that are compile-time constants, including literal
47774790
** values and [parameters] and expressions composed from the same.)^
47784791
**
@@ -8811,10 +8824,11 @@
88118824
88128825
/*
88138826
** The names of the following types declared in vdbeInt.h are required
88148827
** for the VdbeOp definition.
88158828
*/
8829
+typedef struct VdbeFunc VdbeFunc;
88168830
typedef struct Mem Mem;
88178831
typedef struct SubProgram SubProgram;
88188832
88198833
/*
88208834
** A single instruction of the virtual machine has an opcode
@@ -8834,10 +8848,11 @@
88348848
void *p; /* Generic pointer */
88358849
char *z; /* Pointer to data for string (char array) types */
88368850
i64 *pI64; /* Used when p4type is P4_INT64 */
88378851
double *pReal; /* Used when p4type is P4_REAL */
88388852
FuncDef *pFunc; /* Used when p4type is P4_FUNCDEF */
8853
+ VdbeFunc *pVdbeFunc; /* Used when p4type is P4_VDBEFUNC */
88398854
CollSeq *pColl; /* Used when p4type is P4_COLLSEQ */
88408855
Mem *pMem; /* Used when p4type is P4_MEM */
88418856
VTable *pVtab; /* Used when p4type is P4_VTAB */
88428857
KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */
88438858
int *ai; /* Used when p4type is P4_INTARRAY */
@@ -8887,10 +8902,11 @@
88878902
#define P4_DYNAMIC (-1) /* Pointer to a string obtained from sqliteMalloc() */
88888903
#define P4_STATIC (-2) /* Pointer to a static string */
88898904
#define P4_COLLSEQ (-4) /* P4 is a pointer to a CollSeq structure */
88908905
#define P4_FUNCDEF (-5) /* P4 is a pointer to a FuncDef structure */
88918906
#define P4_KEYINFO (-6) /* P4 is a pointer to a KeyInfo structure */
8907
+#define P4_VDBEFUNC (-7) /* P4 is a pointer to a VdbeFunc structure */
88928908
#define P4_MEM (-8) /* P4 is a pointer to a Mem* structure */
88938909
#define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */
88948910
#define P4_VTAB (-10) /* P4 is a pointer to an sqlite3_vtab structure */
88958911
#define P4_MPRINTF (-11) /* P4 is a string obtained from sqlite3_mprintf() */
88968912
#define P4_REAL (-12) /* P4 is a 64-bit floating point value */
@@ -13241,13 +13257,10 @@
1324113257
typedef struct VdbeSorter VdbeSorter;
1324213258
1324313259
/* Opaque type used by the explainer */
1324413260
typedef struct Explain Explain;
1324513261
13246
-/* Elements of the linked list at Vdbe.pAuxData */
13247
-typedef struct AuxData AuxData;
13248
-
1324913262
/*
1325013263
** A cursor is a pointer into a single BTree within a database file.
1325113264
** The cursor can seek to a BTree entry with a particular key, or
1325213265
** loop over all entries of the Btree. You can also insert new BTree
1325313266
** entries or retrieve the key or data from the entry that the cursor
@@ -13430,23 +13443,27 @@
1343013443
*/
1343113444
#ifdef SQLITE_DEBUG
1343213445
#define memIsValid(M) ((M)->flags & MEM_Invalid)==0
1343313446
#endif
1343413447
13435
-/*
13436
-** Each auxilliary data pointer stored by a user defined function
13437
-** implementation calling sqlite3_set_auxdata() is stored in an instance
13438
-** of this structure. All such structures associated with a single VM
13439
-** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed
13440
-** when the VM is halted (if not before).
13448
+
13449
+/* A VdbeFunc is just a FuncDef (defined in sqliteInt.h) that contains
13450
+** additional information about auxiliary information bound to arguments
13451
+** of the function. This is used to implement the sqlite3_get_auxdata()
13452
+** and sqlite3_set_auxdata() APIs. The "auxdata" is some auxiliary data
13453
+** that can be associated with a constant argument to a function. This
13454
+** allows functions such as "regexp" to compile their constant regular
13455
+** expression argument once and reused the compiled code for multiple
13456
+** invocations.
1344113457
*/
13442
-struct AuxData {
13443
- int iOp; /* Instruction number of OP_Function opcode */
13444
- int iArg; /* Index of function argument. */
13445
- void *pAux; /* Aux data pointer */
13446
- void (*xDelete)(void *); /* Destructor for the aux data */
13447
- AuxData *pNext; /* Next element in list */
13458
+struct VdbeFunc {
13459
+ FuncDef *pFunc; /* The definition of the function */
13460
+ int nAux; /* Number of entries allocated for apAux[] */
13461
+ struct AuxData {
13462
+ void *pAux; /* Aux data for the i-th argument */
13463
+ void (*xDelete)(void *); /* Destructor for the aux data */
13464
+ } apAux[1]; /* One slot for each function argument */
1344813465
};
1344913466
1345013467
/*
1345113468
** The "context" argument for a installable function. A pointer to an
1345213469
** instance of this structure is the first argument to the routines used
@@ -13460,17 +13477,16 @@
1346013477
** This structure is defined inside of vdbeInt.h because it uses substructures
1346113478
** (Mem) which are only defined there.
1346213479
*/
1346313480
struct sqlite3_context {
1346413481
FuncDef *pFunc; /* Pointer to function information. MUST BE FIRST */
13482
+ VdbeFunc *pVdbeFunc; /* Auxilary data, if created. */
1346513483
Mem s; /* The return value is stored here */
1346613484
Mem *pMem; /* Memory cell used to store aggregate context */
1346713485
CollSeq *pColl; /* Collating sequence */
1346813486
int isError; /* Error code returned by the function. */
1346913487
int skipFlag; /* Skip skip accumulator loading if true */
13470
- int iOp; /* Instruction number of OP_Function */
13471
- Vdbe *pVdbe; /* The VM that owns this context */
1347213488
};
1347313489
1347413490
/*
1347513491
** An Explain object accumulates indented output which is helpful
1347613492
** in describing recursive data structures.
@@ -13565,11 +13581,10 @@
1356513581
int nFrame; /* Number of frames in pFrame list */
1356613582
u32 expmask; /* Binding to these vars invalidates VM */
1356713583
SubProgram *pProgram; /* Linked list of all sub-programs used by VM */
1356813584
int nOnceFlag; /* Size of array aOnceFlag[] */
1356913585
u8 *aOnceFlag; /* Flags for OP_Once */
13570
- AuxData *pAuxData; /* Linked list of auxdata allocations */
1357113586
};
1357213587
1357313588
/*
1357413589
** The following are allowed values for Vdbe.magic
1357513590
*/
@@ -13589,11 +13604,11 @@
1358913604
#endif
1359013605
SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
1359113606
SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int);
1359213607
SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int);
1359313608
SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
13594
-SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe*, int, int);
13609
+SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc*, int);
1359513610
1359613611
int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
1359713612
SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*);
1359813613
SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *);
1359913614
SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
@@ -28361,27 +28376,22 @@
2836128376
*/
2836228377
static const char *unixTempFileDir(void){
2836328378
static const char *azDirs[] = {
2836428379
0,
2836528380
0,
28366
- 0,
28367
- 0,
2836828381
"/var/tmp",
2836928382
"/usr/tmp",
2837028383
"/tmp",
28371
- "."
28384
+ 0 /* List terminator */
2837228385
};
2837328386
unsigned int i;
2837428387
struct stat buf;
28375
- const char *zDir;
28388
+ const char *zDir = 0;
2837628389
2837728390
azDirs[0] = sqlite3_temp_directory;
2837828391
if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR");
28379
- if( !azDirs[2] ) azDirs[2] = getenv("TMP");
28380
- if( !azDirs[3] ) azDirs[3] = getenv("TEMP");
28381
- for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
28382
- zDir = azDirs[i];
28392
+ for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){
2838328393
if( zDir==0 ) continue;
2838428394
if( osStat(zDir, &buf) ) continue;
2838528395
if( !S_ISDIR(buf.st_mode) ) continue;
2838628396
if( osAccess(zDir, 07) ) continue;
2838728397
break;
@@ -28407,10 +28417,11 @@
2840728417
** function failing.
2840828418
*/
2840928419
SimulateIOError( return SQLITE_IOERR );
2841028420
2841128421
zDir = unixTempFileDir();
28422
+ if( zDir==0 ) zDir = ".";
2841228423
2841328424
/* Check that the output buffer is large enough for the temporary file
2841428425
** name. If it is not, return SQLITE_ERROR.
2841528426
*/
2841628427
if( (strlen(zDir) + strlen(SQLITE_TEMP_FILE_PREFIX) + 18) >= (size_t)nBuf ){
@@ -30488,11 +30499,10 @@
3048830499
*/
3048930500
#if SQLITE_OS_WIN /* This file is used for Windows only */
3049030501
3049130502
#ifdef __CYGWIN__
3049230503
# include <sys/cygwin.h>
30493
-/* # include <errno.h> */
3049430504
#endif
3049530505
3049630506
/*
3049730507
** Include code that is common to all os_*.c files
3049830508
*/
@@ -30717,11 +30727,11 @@
3071730727
3071830728
/*
3071930729
** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions
3072030730
** based on the sub-platform)?
3072130731
*/
30722
-#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
30732
+#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)
3072330733
# define SQLITE_WIN32_HAS_ANSI
3072430734
#endif
3072530735
3072630736
/*
3072730737
** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions
@@ -30909,11 +30919,10 @@
3090930919
* zero for the default behavior.
3091030920
*/
3091130921
#ifndef SQLITE_WIN32_HEAP_FLAGS
3091230922
# define SQLITE_WIN32_HEAP_FLAGS (0)
3091330923
#endif
30914
-
3091530924
3091630925
/*
3091730926
** The winMemData structure stores information required by the Win32-specific
3091830927
** sqlite3_mem_methods implementation.
3091930928
*/
@@ -34375,14 +34384,14 @@
3437534384
OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
3437634385
osGetCurrentProcessId(), pFd));
3437734386
return SQLITE_OK;
3437834387
}
3437934388
assert( (nMap % winSysInfo.dwPageSize)==0 );
34380
- assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
3438134389
#if SQLITE_OS_WINRT
34382
- pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap);
34390
+ pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, nMap);
3438334391
#else
34392
+ assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
3438434393
pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
3438534394
#endif
3438634395
if( pNew==NULL ){
3438734396
osCloseHandle(pFd->hMap);
3438834397
pFd->hMap = NULL;
@@ -34549,19 +34558,10 @@
3454934558
return zConverted;
3455034559
}
3455134560
3455234561
static int winIsDir(const void *zConverted);
3455334562
34554
-/*
34555
-** Maximum pathname length (in bytes) for windows. The MAX_PATH macro is
34556
-** in characters, so we allocate 3 bytes per character assuming worst-case
34557
-** 3-bytes-per-character UTF8.
34558
-*/
34559
-#ifndef SQLITE_WIN32_MAX_PATH
34560
-# define SQLITE_WIN32_MAX_PATH (MAX_PATH*3)
34561
-#endif
34562
-
3456334563
/*
3456434564
** Create a temporary file name in zBuf. zBuf must be big enough to
3456534565
** hold at pVfs->mxPathname characters.
3456634566
*/
3456734567
static int getTempname(int nBuf, char *zBuf){
@@ -34569,21 +34569,22 @@
3456934569
"abcdefghijklmnopqrstuvwxyz"
3457034570
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3457134571
"0123456789";
3457234572
size_t i, j;
3457334573
int nTempPath;
34574
- char zTempPath[SQLITE_WIN32_MAX_PATH+2];
34574
+ char zTempPath[MAX_PATH+2];
3457534575
3457634576
/* It's odd to simulate an io-error here, but really this is just
3457734577
** using the io-error infrastructure to test that SQLite handles this
3457834578
** function failing.
3457934579
*/
3458034580
SimulateIOError( return SQLITE_IOERR );
3458134581
34582
+ memset(zTempPath, 0, MAX_PATH+2);
34583
+
3458234584
if( sqlite3_temp_directory ){
34583
- sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s",
34584
- sqlite3_temp_directory);
34585
+ sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
3458534586
}
3458634587
#if defined(__CYGWIN__)
3458734588
else{
3458834589
static const char *azDirs[] = {
3458934590
0,
@@ -34626,58 +34627,36 @@
3462634627
}
3462734628
#elif !SQLITE_OS_WINRT
3462834629
else if( isNT() ){
3462934630
char *zMulti;
3463034631
WCHAR zWidePath[MAX_PATH];
34631
- if( osGetTempPathW(MAX_PATH-30, zWidePath)==0 ){
34632
- OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34633
- return SQLITE_IOERR_GETTEMPPATH;
34634
- }
34632
+ osGetTempPathW(MAX_PATH-30, zWidePath);
3463534633
zMulti = unicodeToUtf8(zWidePath);
3463634634
if( zMulti ){
34637
- sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zMulti);
34635
+ sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti);
3463834636
sqlite3_free(zMulti);
3463934637
}else{
3464034638
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
3464134639
return SQLITE_IOERR_NOMEM;
3464234640
}
3464334641
}
3464434642
#ifdef SQLITE_WIN32_HAS_ANSI
3464534643
else{
3464634644
char *zUtf8;
34647
- char zMbcsPath[SQLITE_WIN32_MAX_PATH];
34648
- if( osGetTempPathA(SQLITE_WIN32_MAX_PATH-30, zMbcsPath)==0 ){
34649
- OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34650
- return SQLITE_IOERR_GETTEMPPATH;
34651
- }
34645
+ char zMbcsPath[MAX_PATH];
34646
+ osGetTempPathA(MAX_PATH-30, zMbcsPath);
3465234647
zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
3465334648
if( zUtf8 ){
34654
- sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zUtf8);
34649
+ sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8);
3465534650
sqlite3_free(zUtf8);
3465634651
}else{
3465734652
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
3465834653
return SQLITE_IOERR_NOMEM;
3465934654
}
3466034655
}
34661
-#else
34662
- else{
34663
- /*
34664
- ** Compiled without ANSI support and the current operating system
34665
- ** is not Windows NT; therefore, just zero the temporary buffer.
34666
- */
34667
- memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34668
- }
34669
-#endif /* SQLITE_WIN32_HAS_ANSI */
34670
-#else
34671
- else{
34672
- /*
34673
- ** Compiled for WinRT and the sqlite3_temp_directory is not set;
34674
- ** therefore, just zero the temporary buffer.
34675
- */
34676
- memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34677
- }
34678
-#endif /* !SQLITE_OS_WINRT */
34656
+#endif
34657
+#endif
3467934658
3468034659
/* Check that the output buffer is large enough for the temporary file
3468134660
** name. If it is not, return SQLITE_ERROR.
3468234661
*/
3468334662
nTempPath = sqlite3Strlen30(zTempPath);
@@ -34759,11 +34738,11 @@
3475934738
int cnt = 0;
3476034739
3476134740
/* If argument zPath is a NULL pointer, this function is required to open
3476234741
** a temporary file. Use this buffer to store the file name in.
3476334742
*/
34764
- char zTmpname[SQLITE_WIN32_MAX_PATH+2]; /* Buffer used to create temp filename */
34743
+ char zTmpname[MAX_PATH+2]; /* Buffer used to create temp filename */
3476534744
3476634745
int rc = SQLITE_OK; /* Function Return Code */
3476734746
#if !defined(NDEBUG) || SQLITE_OS_WINCE
3476834747
int eType = flags&0xFFFFFF00; /* Type of file to open */
3476934748
#endif
@@ -34825,11 +34804,12 @@
3482534804
/* If the second argument to this function is NULL, generate a
3482634805
** temporary file name to use
3482734806
*/
3482834807
if( !zUtf8Name ){
3482934808
assert(isDelete && !isOpenJournal);
34830
- rc = getTempname(SQLITE_WIN32_MAX_PATH+2, zTmpname);
34809
+ memset(zTmpname, 0, MAX_PATH+2);
34810
+ rc = getTempname(MAX_PATH+2, zTmpname);
3483134811
if( rc!=SQLITE_OK ){
3483234812
OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
3483334813
return rc;
3483434814
}
3483534815
zUtf8Name = zTmpname;
@@ -35256,34 +35236,27 @@
3525635236
){
3525735237
3525835238
#if defined(__CYGWIN__)
3525935239
SimulateIOError( return SQLITE_ERROR );
3526035240
UNUSED_PARAMETER(nFull);
35261
- assert( pVfs->mxPathname>=SQLITE_WIN32_MAX_PATH );
35241
+ assert( pVfs->mxPathname>=MAX_PATH );
3526235242
assert( nFull>=pVfs->mxPathname );
3526335243
if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
3526435244
/*
3526535245
** NOTE: We are dealing with a relative path name and the data
3526635246
** directory has been set. Therefore, use it as the basis
3526735247
** for converting the relative path name to an absolute
3526835248
** one by prepending the data directory and a slash.
3526935249
*/
35270
- char zOut[SQLITE_WIN32_MAX_PATH+1];
35271
- if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35272
- SQLITE_WIN32_MAX_PATH+1)<0 ){
35273
- winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35274
- zRelative);
35275
- return SQLITE_CANTOPEN_FULLPATH;
35276
- }
35250
+ char zOut[MAX_PATH+1];
35251
+ memset(zOut, 0, MAX_PATH+1);
35252
+ cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35253
+ MAX_PATH+1);
3527735254
sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
3527835255
sqlite3_data_directory, zOut);
3527935256
}else{
35280
- if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){
35281
- winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35282
- zRelative);
35283
- return SQLITE_CANTOPEN_FULLPATH;
35284
- }
35257
+ cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull);
3528535258
}
3528635259
return SQLITE_OK;
3528735260
#endif
3528835261
3528935262
#if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
@@ -35621,11 +35594,11 @@
3562135594
*/
3562235595
SQLITE_API int sqlite3_os_init(void){
3562335596
static sqlite3_vfs winVfs = {
3562435597
3, /* iVersion */
3562535598
sizeof(winFile), /* szOsFile */
35626
- SQLITE_WIN32_MAX_PATH, /* mxPathname */
35599
+ MAX_PATH, /* mxPathname */
3562735600
0, /* pNext */
3562835601
"win32", /* zName */
3562935602
0, /* pAppData */
3563035603
winOpen, /* xOpen */
3563135604
winDelete, /* xDelete */
@@ -60607,10 +60580,17 @@
6060760580
break;
6060860581
}
6060960582
case P4_MPRINTF: {
6061060583
if( db->pnBytesFreed==0 ) sqlite3_free(p4);
6061160584
break;
60585
+ }
60586
+ case P4_VDBEFUNC: {
60587
+ VdbeFunc *pVdbeFunc = (VdbeFunc *)p4;
60588
+ freeEphemeralFunction(db, pVdbeFunc->pFunc);
60589
+ if( db->pnBytesFreed==0 ) sqlite3VdbeDeleteAuxData(pVdbeFunc, 0);
60590
+ sqlite3DbFree(db, pVdbeFunc);
60591
+ break;
6061260592
}
6061360593
case P4_FUNCDEF: {
6061460594
freeEphemeralFunction(db, (FuncDef*)p4);
6061560595
break;
6061660596
}
@@ -61637,14 +61617,10 @@
6163761617
while( p->pDelFrame ){
6163861618
VdbeFrame *pDel = p->pDelFrame;
6163961619
p->pDelFrame = pDel->pParent;
6164061620
sqlite3VdbeFrameDelete(pDel);
6164161621
}
61642
-
61643
- /* Delete any auxdata allocations made by the VM */
61644
- sqlite3VdbeDeleteAuxData(p, -1, 0);
61645
- assert( p->pAuxData==0 );
6164661622
}
6164761623
6164861624
/*
6164961625
** Clean up the VM after execution.
6165061626
**
@@ -62439,39 +62415,24 @@
6243962415
sqlite3VdbeDelete(p);
6244062416
return rc;
6244162417
}
6244262418
6244362419
/*
62444
-** If parameter iOp is less than zero, then invoke the destructor for
62445
-** all auxiliary data pointers currently cached by the VM passed as
62446
-** the first argument.
62447
-**
62448
-** Or, if iOp is greater than or equal to zero, then the destructor is
62449
-** only invoked for those auxiliary data pointers created by the user
62450
-** function invoked by the OP_Function opcode at instruction iOp of
62451
-** VM pVdbe, and only then if:
62452
-**
62453
-** * the associated function parameter is the 32nd or later (counting
62454
-** from left to right), or
62455
-**
62456
-** * the corresponding bit in argument mask is clear (where the first
62457
-** function parameter corrsponds to bit 0 etc.).
62420
+** Call the destructor for each auxdata entry in pVdbeFunc for which
62421
+** the corresponding bit in mask is clear. Auxdata entries beyond 31
62422
+** are always destroyed. To destroy all auxdata entries, call this
62423
+** routine with mask==0.
6245862424
*/
62459
-SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){
62460
- AuxData **pp = &pVdbe->pAuxData;
62461
- while( *pp ){
62462
- AuxData *pAux = *pp;
62463
- if( (iOp<0)
62464
- || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & ((u32)1<<pAux->iArg))))
62465
- ){
62425
+SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc *pVdbeFunc, int mask){
62426
+ int i;
62427
+ for(i=0; i<pVdbeFunc->nAux; i++){
62428
+ struct AuxData *pAux = &pVdbeFunc->apAux[i];
62429
+ if( (i>31 || !(mask&(((u32)1)<<i))) && pAux->pAux ){
6246662430
if( pAux->xDelete ){
6246762431
pAux->xDelete(pAux->pAux);
6246862432
}
62469
- *pp = pAux->pNext;
62470
- sqlite3DbFree(pVdbe->db, pAux);
62471
- }else{
62472
- pp= &pAux->pNext;
62433
+ pAux->pAux = 0;
6247362434
}
6247462435
}
6247562436
}
6247662437
6247762438
/*
@@ -63866,18 +63827,18 @@
6386663827
/*
6386763828
** Return the auxilary data pointer, if any, for the iArg'th argument to
6386863829
** the user-function defined by pCtx.
6386963830
*/
6387063831
SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
63871
- AuxData *pAuxData;
63832
+ VdbeFunc *pVdbeFunc;
6387263833
6387363834
assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63874
- for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
63875
- if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
63835
+ pVdbeFunc = pCtx->pVdbeFunc;
63836
+ if( !pVdbeFunc || iArg>=pVdbeFunc->nAux || iArg<0 ){
63837
+ return 0;
6387663838
}
63877
-
63878
- return (pAuxData ? pAuxData->pAux : 0);
63839
+ return pVdbeFunc->apAux[iArg].pAux;
6387963840
}
6388063841
6388163842
/*
6388263843
** Set the auxilary data pointer and delete function, for the iArg'th
6388363844
** argument to the user-function defined by pCtx. Any previous value is
@@ -63887,30 +63848,33 @@
6388763848
sqlite3_context *pCtx,
6388863849
int iArg,
6388963850
void *pAux,
6389063851
void (*xDelete)(void*)
6389163852
){
63892
- AuxData *pAuxData;
63893
- Vdbe *pVdbe = pCtx->pVdbe;
63894
-
63895
- assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63853
+ struct AuxData *pAuxData;
63854
+ VdbeFunc *pVdbeFunc;
6389663855
if( iArg<0 ) goto failed;
6389763856
63898
- for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
63899
- if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
63900
- }
63901
- if( pAuxData==0 ){
63902
- pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData));
63903
- if( !pAuxData ) goto failed;
63904
- pAuxData->iOp = pCtx->iOp;
63905
- pAuxData->iArg = iArg;
63906
- pAuxData->pNext = pVdbe->pAuxData;
63907
- pVdbe->pAuxData = pAuxData;
63908
- }else if( pAuxData->xDelete ){
63857
+ assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63858
+ pVdbeFunc = pCtx->pVdbeFunc;
63859
+ if( !pVdbeFunc || pVdbeFunc->nAux<=iArg ){
63860
+ int nAux = (pVdbeFunc ? pVdbeFunc->nAux : 0);
63861
+ int nMalloc = sizeof(VdbeFunc) + sizeof(struct AuxData)*iArg;
63862
+ pVdbeFunc = sqlite3DbRealloc(pCtx->s.db, pVdbeFunc, nMalloc);
63863
+ if( !pVdbeFunc ){
63864
+ goto failed;
63865
+ }
63866
+ pCtx->pVdbeFunc = pVdbeFunc;
63867
+ memset(&pVdbeFunc->apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux));
63868
+ pVdbeFunc->nAux = iArg+1;
63869
+ pVdbeFunc->pFunc = pCtx->pFunc;
63870
+ }
63871
+
63872
+ pAuxData = &pVdbeFunc->apAux[iArg];
63873
+ if( pAuxData->pAux && pAuxData->xDelete ){
6390963874
pAuxData->xDelete(pAuxData->pAux);
6391063875
}
63911
-
6391263876
pAuxData->pAux = pAux;
6391363877
pAuxData->xDelete = xDelete;
6391463878
return;
6391563879
6391663880
failed:
@@ -65518,11 +65482,11 @@
6551865482
u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
6551965483
u8 encoding = ENC(db); /* The database encoding */
6552065484
int iCompare = 0; /* Result of last OP_Compare operation */
6552165485
unsigned nVmStep = 0; /* Number of virtual machine steps */
6552265486
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65523
- unsigned nProgressLimit; /* Invoke xProgress() when nVmStep reaches this */
65487
+ unsigned nProgressOps = 0; /* nVmStep at last progress callback. */
6552465488
#endif
6552565489
Mem *aMem = p->aMem; /* Copy of p->aMem */
6552665490
Mem *pIn1 = 0; /* 1st input operand */
6552765491
Mem *pIn2 = 0; /* 2nd input operand */
6552865492
Mem *pIn3 = 0; /* 3rd input operand */
@@ -65977,21 +65941,10 @@
6597765941
assert( p->explain==0 );
6597865942
p->pResultSet = 0;
6597965943
db->busyHandler.nBusy = 0;
6598065944
CHECK_FOR_INTERRUPT;
6598165945
sqlite3VdbeIOTraceSql(p);
65982
-#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65983
- if( db->xProgress ){
65984
- assert( 0 < db->nProgressOps );
65985
- nProgressLimit = (unsigned)p->aCounter[SQLITE_STMTSTATUS_VM_STEP-1];
65986
- if( nProgressLimit==0 ){
65987
- nProgressLimit = db->nProgressOps;
65988
- }else{
65989
- nProgressLimit %= (unsigned)db->nProgressOps;
65990
- }
65991
- }
65992
-#endif
6599365946
#ifdef SQLITE_DEBUG
6599465947
sqlite3BeginBenignMalloc();
6599565948
if( p->pc==0 && (p->db->flags & SQLITE_VdbeListing)!=0 ){
6599665949
int i;
6599765950
printf("VDBE Program Listing:\n");
@@ -66148,20 +66101,18 @@
6614866101
** of VDBE ops have been executed (either since this invocation of
6614966102
** sqlite3VdbeExec() or since last time the progress callback was called).
6615066103
** If the progress callback returns non-zero, exit the virtual machine with
6615166104
** a return code SQLITE_ABORT.
6615266105
*/
66153
- if( db->xProgress!=0 && nVmStep>=nProgressLimit ){
66106
+ if( db->xProgress!=0 && (nVmStep - nProgressOps)>=db->nProgressOps ){
6615466107
int prc;
6615566108
prc = db->xProgress(db->pProgressArg);
6615666109
if( prc!=0 ){
6615766110
rc = SQLITE_INTERRUPT;
6615866111
goto vdbe_error_halt;
6615966112
}
66160
- if( db->xProgress!=0 ){
66161
- nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);
66162
- }
66113
+ nProgressOps = nVmStep;
6616366114
}
6616466115
#endif
6616566116
6616666117
break;
6616766118
}
@@ -66843,18 +66794,23 @@
6684366794
Deephemeralize(u.ai.pArg);
6684466795
sqlite3VdbeMemStoreType(u.ai.pArg);
6684566796
REGISTER_TRACE(pOp->p2+u.ai.i, u.ai.pArg);
6684666797
}
6684766798
66848
- assert( pOp->p4type==P4_FUNCDEF );
66849
- u.ai.ctx.pFunc = pOp->p4.pFunc;
66799
+ assert( pOp->p4type==P4_FUNCDEF || pOp->p4type==P4_VDBEFUNC );
66800
+ if( pOp->p4type==P4_FUNCDEF ){
66801
+ u.ai.ctx.pFunc = pOp->p4.pFunc;
66802
+ u.ai.ctx.pVdbeFunc = 0;
66803
+ }else{
66804
+ u.ai.ctx.pVdbeFunc = (VdbeFunc*)pOp->p4.pVdbeFunc;
66805
+ u.ai.ctx.pFunc = u.ai.ctx.pVdbeFunc->pFunc;
66806
+ }
66807
+
6685066808
u.ai.ctx.s.flags = MEM_Null;
6685166809
u.ai.ctx.s.db = db;
6685266810
u.ai.ctx.s.xDel = 0;
6685366811
u.ai.ctx.s.zMalloc = 0;
66854
- u.ai.ctx.iOp = pc;
66855
- u.ai.ctx.pVdbe = p;
6685666812
6685766813
/* The output cell may already have a buffer allocated. Move
6685866814
** the pointer to u.ai.ctx.s so in case the user-function can use
6685966815
** the already allocated buffer instead of allocating a new one.
6686066816
*/
@@ -66873,11 +66829,15 @@
6687366829
lastRowid = db->lastRowid;
6687466830
6687566831
/* If any auxiliary data functions have been called by this user function,
6687666832
** immediately call the destructor for any non-static values.
6687766833
*/
66878
- sqlite3VdbeDeleteAuxData(p, pc, pOp->p1);
66834
+ if( u.ai.ctx.pVdbeFunc ){
66835
+ sqlite3VdbeDeleteAuxData(u.ai.ctx.pVdbeFunc, pOp->p1);
66836
+ pOp->p4.pVdbeFunc = u.ai.ctx.pVdbeFunc;
66837
+ pOp->p4type = P4_VDBEFUNC;
66838
+ }
6687966839
6688066840
if( db->mallocFailed ){
6688166841
/* Even though a malloc() has failed, the implementation of the
6688266842
** user function may have called an sqlite3_result_XXX() function
6688366843
** to return a value. The following call releases any resources
@@ -107790,11 +107750,10 @@
107790107750
WhereLevel *pLevel; /* The where level to be coded */
107791107751
WhereLoop *pLoop; /* The WhereLoop object being coded */
107792107752
WhereClause *pWC; /* Decomposition of the entire WHERE clause */
107793107753
WhereTerm *pTerm; /* A WHERE clause term */
107794107754
Parse *pParse; /* Parsing context */
107795
- sqlite3 *db; /* Database connection */
107796107755
Vdbe *v; /* The prepared stmt under constructions */
107797107756
struct SrcList_item *pTabItem; /* FROM clause term being coded */
107798107757
int addrBrk; /* Jump here to break out of the loop */
107799107758
int addrCont; /* Jump here to continue with next cycle */
107800107759
int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
@@ -107802,11 +107761,10 @@
107802107761
Bitmask newNotReady; /* Return value */
107803107762
107804107763
pParse = pWInfo->pParse;
107805107764
v = pParse->pVdbe;
107806107765
pWC = &pWInfo->sWC;
107807
- db = pParse->db;
107808107766
pLevel = &pWInfo->a[iLevel];
107809107767
pLoop = pLevel->pWLoop;
107810107768
pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
107811107769
iCur = pTabItem->iCursor;
107812107770
bRev = (pWInfo->revMask>>iLevel)&1;
@@ -108093,11 +108051,11 @@
108093108051
/* Generate code to evaluate all constraint terms using == or IN
108094108052
** and store the values of those terms in an array of registers
108095108053
** starting at regBase.
108096108054
*/
108097108055
regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
108098
- zEndAff = sqlite3DbStrDup(db, zStartAff);
108056
+ zEndAff = sqlite3DbStrDup(pParse->db, zStartAff);
108099108057
addrNxt = pLevel->addrNxt;
108100108058
108101108059
/* If we are doing a reverse order scan on an ascending index, or
108102108060
** a forward order scan on a descending index, interchange the
108103108061
** start and end terms (pRangeStart and pRangeEnd).
@@ -108178,12 +108136,12 @@
108178108136
}
108179108137
codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
108180108138
nConstraint++;
108181108139
testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108182108140
}
108183
- sqlite3DbFree(db, zStartAff);
108184
- sqlite3DbFree(db, zEndAff);
108141
+ sqlite3DbFree(pParse->db, zStartAff);
108142
+ sqlite3DbFree(pParse->db, zEndAff);
108185108143
108186108144
/* Top of the loop body */
108187108145
pLevel->p2 = sqlite3VdbeCurrentAddr(v);
108188108146
108189108147
/* Check if the index cursor is past the end of the range. */
@@ -108306,11 +108264,11 @@
108306108264
*/
108307108265
if( pWInfo->nLevel>1 ){
108308108266
int nNotReady; /* The number of notReady tables */
108309108267
struct SrcList_item *origSrc; /* Original list of tables */
108310108268
nNotReady = pWInfo->nLevel - iLevel - 1;
108311
- pOrTab = sqlite3StackAllocRaw(db,
108269
+ pOrTab = sqlite3StackAllocRaw(pParse->db,
108312108270
sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
108313108271
if( pOrTab==0 ) return notReady;
108314108272
pOrTab->nAlloc = (u8)(nNotReady + 1);
108315108273
pOrTab->nSrc = pOrTab->nAlloc;
108316108274
memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
@@ -108360,12 +108318,12 @@
108360108318
Expr *pExpr = pWC->a[iTerm].pExpr;
108361108319
if( &pWC->a[iTerm] == pTerm ) continue;
108362108320
if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
108363108321
if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue;
108364108322
if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
108365
- pExpr = sqlite3ExprDup(db, pExpr, 0);
108366
- pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);
108323
+ pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
108324
+ pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr);
108367108325
}
108368108326
if( pAndExpr ){
108369108327
pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
108370108328
}
108371108329
}
@@ -108381,11 +108339,11 @@
108381108339
}
108382108340
/* Loop through table entries that match term pOrTerm. */
108383108341
pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
108384108342
WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
108385108343
WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
108386
- assert( pSubWInfo || pParse->nErr || db->mallocFailed );
108344
+ assert( pSubWInfo || pParse->nErr || pParse->db->mallocFailed );
108387108345
if( pSubWInfo ){
108388108346
WhereLoop *pSubLoop;
108389108347
explainOneScan(
108390108348
pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
108391108349
);
@@ -108436,17 +108394,17 @@
108436108394
}
108437108395
pLevel->u.pCovidx = pCov;
108438108396
if( pCov ) pLevel->iIdxCur = iCovCur;
108439108397
if( pAndExpr ){
108440108398
pAndExpr->pLeft = 0;
108441
- sqlite3ExprDelete(db, pAndExpr);
108399
+ sqlite3ExprDelete(pParse->db, pAndExpr);
108442108400
}
108443108401
sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
108444108402
sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
108445108403
sqlite3VdbeResolveLabel(v, iLoopBody);
108446108404
108447
- if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab);
108405
+ if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab);
108448108406
if( !untestedTerms ) disableTerm(pLevel, pTerm);
108449108407
}else
108450108408
#endif /* SQLITE_OMIT_OR_OPTIMIZATION */
108451108409
108452108410
{
@@ -108497,12 +108455,13 @@
108497108455
** and we are coding the t1 loop and the t2 loop has not yet coded,
108498108456
** then we cannot use the "t1.a=t2.b" constraint, but we can code
108499108457
** the implied "t1.a=123" constraint.
108500108458
*/
108501108459
for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108502
- Expr *pE, *pEAlt;
108460
+ Expr *pE;
108503108461
WhereTerm *pAlt;
108462
+ Expr sEq;
108504108463
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108505108464
if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108506108465
if( pTerm->leftCursor!=iCur ) continue;
108507108466
if( pLevel->iLeftJoin ) continue;
108508108467
pE = pTerm->pExpr;
@@ -108512,17 +108471,13 @@
108512108471
if( pAlt==0 ) continue;
108513108472
if( pAlt->wtFlags & (TERM_CODED) ) continue;
108514108473
testcase( pAlt->eOperator & WO_EQ );
108515108474
testcase( pAlt->eOperator & WO_IN );
108516108475
VdbeNoopComment((v, "begin transitive constraint"));
108517
- pEAlt = sqlite3StackAllocRaw(db, sizeof(*pEAlt));
108518
- if( pEAlt ){
108519
- *pEAlt = *pAlt->pExpr;
108520
- pEAlt->pLeft = pE->pLeft;
108521
- sqlite3ExprIfFalse(pParse, pEAlt, addrCont, SQLITE_JUMPIFNULL);
108522
- sqlite3StackFree(db, pEAlt);
108523
- }
108476
+ sEq = *pAlt->pExpr;
108477
+ sEq.pLeft = pE->pLeft;
108478
+ sqlite3ExprIfFalse(pParse, &sEq, addrCont, SQLITE_JUMPIFNULL);
108524108479
}
108525108480
108526108481
/* For a LEFT OUTER JOIN, generate code that will record the fact that
108527108482
** at least one row of the right table has matched the left table.
108528108483
*/
@@ -116461,11 +116416,10 @@
116461116416
case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break;
116462116417
case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
116463116418
case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
116464116419
case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
116465116420
case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
116466
- case SQLITE_IOERR_GETTEMPPATH: zName = "SQLITE_IOERR_GETTEMPPATH"; break;
116467116421
case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
116468116422
case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
116469116423
case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
116470116424
case SQLITE_FULL: zName = "SQLITE_FULL"; break;
116471116425
case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
@@ -117817,11 +117771,11 @@
117817117771
db->autoCommit = 1;
117818117772
db->nextAutovac = -1;
117819117773
db->szMmap = sqlite3GlobalConfig.szMmap;
117820117774
db->nextPagesize = 0;
117821117775
db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger
117822
-#if !defined(SQLITE_DEFAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
117776
+#if !defined(SQLITE_DEAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
117823117777
| SQLITE_AutoIndex
117824117778
#endif
117825117779
#if SQLITE_DEFAULT_FILE_FORMAT<4
117826117780
| SQLITE_LegacyFileFmt
117827117781
#endif
@@ -128290,11 +128244,11 @@
128290128244
}
128291128245
128292128246
128293128247
#ifdef SQLITE_TEST
128294128248
128295
-#include <tcl.h>
128249
+/* #include <tcl.h> */
128296128250
/* #include <string.h> */
128297128251
128298128252
/*
128299128253
** Implementation of a special SQL scalar function for testing tokenizers
128300128254
** designed to be used in concert with the Tcl testing framework. This
128301128255
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -398,10 +398,13 @@
398 **
399 ** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
400 ** assert() macro is enabled, each call into the Win32 native heap subsystem
401 ** will cause HeapValidate to be called. If heap validation should fail, an
402 ** assertion will be triggered.
 
 
 
403 **
404 ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
405 ** the default.
406 */
407 #if defined(SQLITE_SYSTEM_MALLOC) \
@@ -436,17 +439,24 @@
436 */
437 #if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
438 # define _XOPEN_SOURCE 600
439 #endif
440
 
 
 
 
 
 
 
441 /*
442 ** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
443 ** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
444 ** make it true by defining or undefining NDEBUG.
445 **
446 ** Setting NDEBUG makes the code smaller and faster by disabling the
447 ** assert() statements in the code. So we want the default action
448 ** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
449 ** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
450 ** feature.
451 */
452 #if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -512,11 +522,11 @@
512 ** hint of unplanned behavior.
513 **
514 ** In other words, ALWAYS and NEVER are added for defensive code.
515 **
516 ** When doing coverage testing ALWAYS and NEVER are hard-coded to
517 ** be true and false so that the unreachable code they specify will
518 ** not be counted as untested code.
519 */
520 #if defined(SQLITE_COVERAGE_TEST)
521 # define ALWAYS(X) (1)
522 # define NEVER(X) (0)
@@ -536,16 +546,20 @@
536 #define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
537
538 /*
539 ** The macro unlikely() is a hint that surrounds a boolean
540 ** expression that is usually false. Macro likely() surrounds
541 ** a boolean expression that is usually true. These hints could,
542 ** in theory, be used by the compiler to generate better code, but
543 ** currently they are just comments for human readers.
544 */
545 #define likely(X) (X)
546 #define unlikely(X) (X)
 
 
 
 
 
547
548 /************** Include sqlite3.h in the middle of sqliteInt.h ***************/
549 /************** Begin file sqlite3.h *****************************************/
550 /*
551 ** 2001 September 15
@@ -656,11 +670,11 @@
656 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
657 ** [sqlite_version()] and [sqlite_source_id()].
658 */
659 #define SQLITE_VERSION "3.8.0"
660 #define SQLITE_VERSION_NUMBER 3008000
661 #define SQLITE_SOURCE_ID "2013-07-31 23:28:36 136fc2931b156f91cdd76a7a009298cdf09d826a"
662
663 /*
664 ** CAPI3REF: Run-Time Library Version Numbers
665 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
666 **
@@ -1025,11 +1039,10 @@
1025 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
1026 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
1027 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
1028 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
1029 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
1030 #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
1031 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
1032 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
1033 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
1034 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
1035 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -3109,12 +3122,11 @@
3109 ** interface is to keep a GUI updated during a large query.
3110 **
3111 ** ^The parameter P is passed through as the only parameter to the
3112 ** callback function X. ^The parameter N is the approximate number of
3113 ** [virtual machine instructions] that are evaluated between successive
3114 ** invocations of the callback X. ^If N is less than one then the progress
3115 ** handler is disabled.
3116 **
3117 ** ^Only a single progress handler may be defined at one time per
3118 ** [database connection]; setting a new progress handler cancels the
3119 ** old one. ^Setting parameter X to NULL disables the progress handler.
3120 ** ^The progress handler is also disabled by setting N to a value less
@@ -4730,49 +4742,50 @@
4730 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4731
4732 /*
4733 ** CAPI3REF: Function Auxiliary Data
4734 **
4735 ** These functions may be used by (non-aggregate) SQL functions to
4736 ** associate metadata with argument values. If the same value is passed to
4737 ** multiple invocations of the same SQL function during query execution, under
4738 ** some circumstances the associated metadata may be preserved. An example
4739 ** of where this might be useful is in a regular-expression matching
4740 ** function. The compiled version of the regular expression can be stored as
4741 ** metadata associated with the pattern string.
4742 ** Then as long as the pattern string remains the same,
4743 ** the compiled regular expression can be reused on multiple
4744 ** invocations of the same function.
4745 **
4746 ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
4747 ** associated by the sqlite3_set_auxdata() function with the Nth argument
4748 ** value to the application-defined function. ^If there is no metadata
4749 ** associated with the function argument, this sqlite3_get_auxdata() interface
4750 ** returns a NULL pointer.
 
4751 **
4752 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
4753 ** argument of the application-defined function. ^Subsequent
4754 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
4755 ** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or
4756 ** NULL if the metadata has been discarded.
4757 ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
4758 ** SQLite will invoke the destructor function X with parameter P exactly
4759 ** once, when the metadata is discarded.
4760 ** SQLite is free to discard the metadata at any time, including: <ul>
4761 ** <li> when the corresponding function parameter changes, or
4762 ** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4763 ** SQL statement, or
4764 ** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or
4765 ** <li> during the original sqlite3_set_auxdata() call when a memory
4766 ** allocation error occurs. </ul>)^
4767 **
4768 ** Note the last bullet in particular. The destructor X in
4769 ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
4770 ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
 
 
 
4771 ** should be called near the end of the function implementation and the
4772 ** function implementation should not make any use of P after
4773 ** sqlite3_set_auxdata() has been called.
4774 **
4775 ** ^(In practice, metadata is preserved between function calls for
4776 ** function parameters that are compile-time constants, including literal
4777 ** values and [parameters] and expressions composed from the same.)^
4778 **
@@ -8811,10 +8824,11 @@
8811
8812 /*
8813 ** The names of the following types declared in vdbeInt.h are required
8814 ** for the VdbeOp definition.
8815 */
 
8816 typedef struct Mem Mem;
8817 typedef struct SubProgram SubProgram;
8818
8819 /*
8820 ** A single instruction of the virtual machine has an opcode
@@ -8834,10 +8848,11 @@
8834 void *p; /* Generic pointer */
8835 char *z; /* Pointer to data for string (char array) types */
8836 i64 *pI64; /* Used when p4type is P4_INT64 */
8837 double *pReal; /* Used when p4type is P4_REAL */
8838 FuncDef *pFunc; /* Used when p4type is P4_FUNCDEF */
 
8839 CollSeq *pColl; /* Used when p4type is P4_COLLSEQ */
8840 Mem *pMem; /* Used when p4type is P4_MEM */
8841 VTable *pVtab; /* Used when p4type is P4_VTAB */
8842 KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */
8843 int *ai; /* Used when p4type is P4_INTARRAY */
@@ -8887,10 +8902,11 @@
8887 #define P4_DYNAMIC (-1) /* Pointer to a string obtained from sqliteMalloc() */
8888 #define P4_STATIC (-2) /* Pointer to a static string */
8889 #define P4_COLLSEQ (-4) /* P4 is a pointer to a CollSeq structure */
8890 #define P4_FUNCDEF (-5) /* P4 is a pointer to a FuncDef structure */
8891 #define P4_KEYINFO (-6) /* P4 is a pointer to a KeyInfo structure */
 
8892 #define P4_MEM (-8) /* P4 is a pointer to a Mem* structure */
8893 #define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */
8894 #define P4_VTAB (-10) /* P4 is a pointer to an sqlite3_vtab structure */
8895 #define P4_MPRINTF (-11) /* P4 is a string obtained from sqlite3_mprintf() */
8896 #define P4_REAL (-12) /* P4 is a 64-bit floating point value */
@@ -13241,13 +13257,10 @@
13241 typedef struct VdbeSorter VdbeSorter;
13242
13243 /* Opaque type used by the explainer */
13244 typedef struct Explain Explain;
13245
13246 /* Elements of the linked list at Vdbe.pAuxData */
13247 typedef struct AuxData AuxData;
13248
13249 /*
13250 ** A cursor is a pointer into a single BTree within a database file.
13251 ** The cursor can seek to a BTree entry with a particular key, or
13252 ** loop over all entries of the Btree. You can also insert new BTree
13253 ** entries or retrieve the key or data from the entry that the cursor
@@ -13430,23 +13443,27 @@
13430 */
13431 #ifdef SQLITE_DEBUG
13432 #define memIsValid(M) ((M)->flags & MEM_Invalid)==0
13433 #endif
13434
13435 /*
13436 ** Each auxilliary data pointer stored by a user defined function
13437 ** implementation calling sqlite3_set_auxdata() is stored in an instance
13438 ** of this structure. All such structures associated with a single VM
13439 ** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed
13440 ** when the VM is halted (if not before).
 
 
 
13441 */
13442 struct AuxData {
13443 int iOp; /* Instruction number of OP_Function opcode */
13444 int iArg; /* Index of function argument. */
13445 void *pAux; /* Aux data pointer */
13446 void (*xDelete)(void *); /* Destructor for the aux data */
13447 AuxData *pNext; /* Next element in list */
 
13448 };
13449
13450 /*
13451 ** The "context" argument for a installable function. A pointer to an
13452 ** instance of this structure is the first argument to the routines used
@@ -13460,17 +13477,16 @@
13460 ** This structure is defined inside of vdbeInt.h because it uses substructures
13461 ** (Mem) which are only defined there.
13462 */
13463 struct sqlite3_context {
13464 FuncDef *pFunc; /* Pointer to function information. MUST BE FIRST */
 
13465 Mem s; /* The return value is stored here */
13466 Mem *pMem; /* Memory cell used to store aggregate context */
13467 CollSeq *pColl; /* Collating sequence */
13468 int isError; /* Error code returned by the function. */
13469 int skipFlag; /* Skip skip accumulator loading if true */
13470 int iOp; /* Instruction number of OP_Function */
13471 Vdbe *pVdbe; /* The VM that owns this context */
13472 };
13473
13474 /*
13475 ** An Explain object accumulates indented output which is helpful
13476 ** in describing recursive data structures.
@@ -13565,11 +13581,10 @@
13565 int nFrame; /* Number of frames in pFrame list */
13566 u32 expmask; /* Binding to these vars invalidates VM */
13567 SubProgram *pProgram; /* Linked list of all sub-programs used by VM */
13568 int nOnceFlag; /* Size of array aOnceFlag[] */
13569 u8 *aOnceFlag; /* Flags for OP_Once */
13570 AuxData *pAuxData; /* Linked list of auxdata allocations */
13571 };
13572
13573 /*
13574 ** The following are allowed values for Vdbe.magic
13575 */
@@ -13589,11 +13604,11 @@
13589 #endif
13590 SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
13591 SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int);
13592 SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int);
13593 SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
13594 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe*, int, int);
13595
13596 int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
13597 SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*);
13598 SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *);
13599 SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
@@ -28361,27 +28376,22 @@
28361 */
28362 static const char *unixTempFileDir(void){
28363 static const char *azDirs[] = {
28364 0,
28365 0,
28366 0,
28367 0,
28368 "/var/tmp",
28369 "/usr/tmp",
28370 "/tmp",
28371 "."
28372 };
28373 unsigned int i;
28374 struct stat buf;
28375 const char *zDir;
28376
28377 azDirs[0] = sqlite3_temp_directory;
28378 if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR");
28379 if( !azDirs[2] ) azDirs[2] = getenv("TMP");
28380 if( !azDirs[3] ) azDirs[3] = getenv("TEMP");
28381 for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
28382 zDir = azDirs[i];
28383 if( zDir==0 ) continue;
28384 if( osStat(zDir, &buf) ) continue;
28385 if( !S_ISDIR(buf.st_mode) ) continue;
28386 if( osAccess(zDir, 07) ) continue;
28387 break;
@@ -28407,10 +28417,11 @@
28407 ** function failing.
28408 */
28409 SimulateIOError( return SQLITE_IOERR );
28410
28411 zDir = unixTempFileDir();
 
28412
28413 /* Check that the output buffer is large enough for the temporary file
28414 ** name. If it is not, return SQLITE_ERROR.
28415 */
28416 if( (strlen(zDir) + strlen(SQLITE_TEMP_FILE_PREFIX) + 18) >= (size_t)nBuf ){
@@ -30488,11 +30499,10 @@
30488 */
30489 #if SQLITE_OS_WIN /* This file is used for Windows only */
30490
30491 #ifdef __CYGWIN__
30492 # include <sys/cygwin.h>
30493 /* # include <errno.h> */
30494 #endif
30495
30496 /*
30497 ** Include code that is common to all os_*.c files
30498 */
@@ -30717,11 +30727,11 @@
30717
30718 /*
30719 ** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions
30720 ** based on the sub-platform)?
30721 */
30722 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
30723 # define SQLITE_WIN32_HAS_ANSI
30724 #endif
30725
30726 /*
30727 ** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions
@@ -30909,11 +30919,10 @@
30909 * zero for the default behavior.
30910 */
30911 #ifndef SQLITE_WIN32_HEAP_FLAGS
30912 # define SQLITE_WIN32_HEAP_FLAGS (0)
30913 #endif
30914
30915
30916 /*
30917 ** The winMemData structure stores information required by the Win32-specific
30918 ** sqlite3_mem_methods implementation.
30919 */
@@ -34375,14 +34384,14 @@
34375 OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
34376 osGetCurrentProcessId(), pFd));
34377 return SQLITE_OK;
34378 }
34379 assert( (nMap % winSysInfo.dwPageSize)==0 );
34380 assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
34381 #if SQLITE_OS_WINRT
34382 pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap);
34383 #else
 
34384 pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
34385 #endif
34386 if( pNew==NULL ){
34387 osCloseHandle(pFd->hMap);
34388 pFd->hMap = NULL;
@@ -34549,19 +34558,10 @@
34549 return zConverted;
34550 }
34551
34552 static int winIsDir(const void *zConverted);
34553
34554 /*
34555 ** Maximum pathname length (in bytes) for windows. The MAX_PATH macro is
34556 ** in characters, so we allocate 3 bytes per character assuming worst-case
34557 ** 3-bytes-per-character UTF8.
34558 */
34559 #ifndef SQLITE_WIN32_MAX_PATH
34560 # define SQLITE_WIN32_MAX_PATH (MAX_PATH*3)
34561 #endif
34562
34563 /*
34564 ** Create a temporary file name in zBuf. zBuf must be big enough to
34565 ** hold at pVfs->mxPathname characters.
34566 */
34567 static int getTempname(int nBuf, char *zBuf){
@@ -34569,21 +34569,22 @@
34569 "abcdefghijklmnopqrstuvwxyz"
34570 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
34571 "0123456789";
34572 size_t i, j;
34573 int nTempPath;
34574 char zTempPath[SQLITE_WIN32_MAX_PATH+2];
34575
34576 /* It's odd to simulate an io-error here, but really this is just
34577 ** using the io-error infrastructure to test that SQLite handles this
34578 ** function failing.
34579 */
34580 SimulateIOError( return SQLITE_IOERR );
34581
 
 
34582 if( sqlite3_temp_directory ){
34583 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s",
34584 sqlite3_temp_directory);
34585 }
34586 #if defined(__CYGWIN__)
34587 else{
34588 static const char *azDirs[] = {
34589 0,
@@ -34626,58 +34627,36 @@
34626 }
34627 #elif !SQLITE_OS_WINRT
34628 else if( isNT() ){
34629 char *zMulti;
34630 WCHAR zWidePath[MAX_PATH];
34631 if( osGetTempPathW(MAX_PATH-30, zWidePath)==0 ){
34632 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34633 return SQLITE_IOERR_GETTEMPPATH;
34634 }
34635 zMulti = unicodeToUtf8(zWidePath);
34636 if( zMulti ){
34637 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zMulti);
34638 sqlite3_free(zMulti);
34639 }else{
34640 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34641 return SQLITE_IOERR_NOMEM;
34642 }
34643 }
34644 #ifdef SQLITE_WIN32_HAS_ANSI
34645 else{
34646 char *zUtf8;
34647 char zMbcsPath[SQLITE_WIN32_MAX_PATH];
34648 if( osGetTempPathA(SQLITE_WIN32_MAX_PATH-30, zMbcsPath)==0 ){
34649 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34650 return SQLITE_IOERR_GETTEMPPATH;
34651 }
34652 zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
34653 if( zUtf8 ){
34654 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zUtf8);
34655 sqlite3_free(zUtf8);
34656 }else{
34657 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34658 return SQLITE_IOERR_NOMEM;
34659 }
34660 }
34661 #else
34662 else{
34663 /*
34664 ** Compiled without ANSI support and the current operating system
34665 ** is not Windows NT; therefore, just zero the temporary buffer.
34666 */
34667 memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34668 }
34669 #endif /* SQLITE_WIN32_HAS_ANSI */
34670 #else
34671 else{
34672 /*
34673 ** Compiled for WinRT and the sqlite3_temp_directory is not set;
34674 ** therefore, just zero the temporary buffer.
34675 */
34676 memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34677 }
34678 #endif /* !SQLITE_OS_WINRT */
34679
34680 /* Check that the output buffer is large enough for the temporary file
34681 ** name. If it is not, return SQLITE_ERROR.
34682 */
34683 nTempPath = sqlite3Strlen30(zTempPath);
@@ -34759,11 +34738,11 @@
34759 int cnt = 0;
34760
34761 /* If argument zPath is a NULL pointer, this function is required to open
34762 ** a temporary file. Use this buffer to store the file name in.
34763 */
34764 char zTmpname[SQLITE_WIN32_MAX_PATH+2]; /* Buffer used to create temp filename */
34765
34766 int rc = SQLITE_OK; /* Function Return Code */
34767 #if !defined(NDEBUG) || SQLITE_OS_WINCE
34768 int eType = flags&0xFFFFFF00; /* Type of file to open */
34769 #endif
@@ -34825,11 +34804,12 @@
34825 /* If the second argument to this function is NULL, generate a
34826 ** temporary file name to use
34827 */
34828 if( !zUtf8Name ){
34829 assert(isDelete && !isOpenJournal);
34830 rc = getTempname(SQLITE_WIN32_MAX_PATH+2, zTmpname);
 
34831 if( rc!=SQLITE_OK ){
34832 OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
34833 return rc;
34834 }
34835 zUtf8Name = zTmpname;
@@ -35256,34 +35236,27 @@
35256 ){
35257
35258 #if defined(__CYGWIN__)
35259 SimulateIOError( return SQLITE_ERROR );
35260 UNUSED_PARAMETER(nFull);
35261 assert( pVfs->mxPathname>=SQLITE_WIN32_MAX_PATH );
35262 assert( nFull>=pVfs->mxPathname );
35263 if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
35264 /*
35265 ** NOTE: We are dealing with a relative path name and the data
35266 ** directory has been set. Therefore, use it as the basis
35267 ** for converting the relative path name to an absolute
35268 ** one by prepending the data directory and a slash.
35269 */
35270 char zOut[SQLITE_WIN32_MAX_PATH+1];
35271 if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35272 SQLITE_WIN32_MAX_PATH+1)<0 ){
35273 winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35274 zRelative);
35275 return SQLITE_CANTOPEN_FULLPATH;
35276 }
35277 sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
35278 sqlite3_data_directory, zOut);
35279 }else{
35280 if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){
35281 winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35282 zRelative);
35283 return SQLITE_CANTOPEN_FULLPATH;
35284 }
35285 }
35286 return SQLITE_OK;
35287 #endif
35288
35289 #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
@@ -35621,11 +35594,11 @@
35621 */
35622 SQLITE_API int sqlite3_os_init(void){
35623 static sqlite3_vfs winVfs = {
35624 3, /* iVersion */
35625 sizeof(winFile), /* szOsFile */
35626 SQLITE_WIN32_MAX_PATH, /* mxPathname */
35627 0, /* pNext */
35628 "win32", /* zName */
35629 0, /* pAppData */
35630 winOpen, /* xOpen */
35631 winDelete, /* xDelete */
@@ -60607,10 +60580,17 @@
60607 break;
60608 }
60609 case P4_MPRINTF: {
60610 if( db->pnBytesFreed==0 ) sqlite3_free(p4);
60611 break;
 
 
 
 
 
 
 
60612 }
60613 case P4_FUNCDEF: {
60614 freeEphemeralFunction(db, (FuncDef*)p4);
60615 break;
60616 }
@@ -61637,14 +61617,10 @@
61637 while( p->pDelFrame ){
61638 VdbeFrame *pDel = p->pDelFrame;
61639 p->pDelFrame = pDel->pParent;
61640 sqlite3VdbeFrameDelete(pDel);
61641 }
61642
61643 /* Delete any auxdata allocations made by the VM */
61644 sqlite3VdbeDeleteAuxData(p, -1, 0);
61645 assert( p->pAuxData==0 );
61646 }
61647
61648 /*
61649 ** Clean up the VM after execution.
61650 **
@@ -62439,39 +62415,24 @@
62439 sqlite3VdbeDelete(p);
62440 return rc;
62441 }
62442
62443 /*
62444 ** If parameter iOp is less than zero, then invoke the destructor for
62445 ** all auxiliary data pointers currently cached by the VM passed as
62446 ** the first argument.
62447 **
62448 ** Or, if iOp is greater than or equal to zero, then the destructor is
62449 ** only invoked for those auxiliary data pointers created by the user
62450 ** function invoked by the OP_Function opcode at instruction iOp of
62451 ** VM pVdbe, and only then if:
62452 **
62453 ** * the associated function parameter is the 32nd or later (counting
62454 ** from left to right), or
62455 **
62456 ** * the corresponding bit in argument mask is clear (where the first
62457 ** function parameter corrsponds to bit 0 etc.).
62458 */
62459 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){
62460 AuxData **pp = &pVdbe->pAuxData;
62461 while( *pp ){
62462 AuxData *pAux = *pp;
62463 if( (iOp<0)
62464 || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & ((u32)1<<pAux->iArg))))
62465 ){
62466 if( pAux->xDelete ){
62467 pAux->xDelete(pAux->pAux);
62468 }
62469 *pp = pAux->pNext;
62470 sqlite3DbFree(pVdbe->db, pAux);
62471 }else{
62472 pp= &pAux->pNext;
62473 }
62474 }
62475 }
62476
62477 /*
@@ -63866,18 +63827,18 @@
63866 /*
63867 ** Return the auxilary data pointer, if any, for the iArg'th argument to
63868 ** the user-function defined by pCtx.
63869 */
63870 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
63871 AuxData *pAuxData;
63872
63873 assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63874 for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
63875 if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
 
63876 }
63877
63878 return (pAuxData ? pAuxData->pAux : 0);
63879 }
63880
63881 /*
63882 ** Set the auxilary data pointer and delete function, for the iArg'th
63883 ** argument to the user-function defined by pCtx. Any previous value is
@@ -63887,30 +63848,33 @@
63887 sqlite3_context *pCtx,
63888 int iArg,
63889 void *pAux,
63890 void (*xDelete)(void*)
63891 ){
63892 AuxData *pAuxData;
63893 Vdbe *pVdbe = pCtx->pVdbe;
63894
63895 assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63896 if( iArg<0 ) goto failed;
63897
63898 for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
63899 if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
63900 }
63901 if( pAuxData==0 ){
63902 pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData));
63903 if( !pAuxData ) goto failed;
63904 pAuxData->iOp = pCtx->iOp;
63905 pAuxData->iArg = iArg;
63906 pAuxData->pNext = pVdbe->pAuxData;
63907 pVdbe->pAuxData = pAuxData;
63908 }else if( pAuxData->xDelete ){
 
 
 
 
 
 
63909 pAuxData->xDelete(pAuxData->pAux);
63910 }
63911
63912 pAuxData->pAux = pAux;
63913 pAuxData->xDelete = xDelete;
63914 return;
63915
63916 failed:
@@ -65518,11 +65482,11 @@
65518 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
65519 u8 encoding = ENC(db); /* The database encoding */
65520 int iCompare = 0; /* Result of last OP_Compare operation */
65521 unsigned nVmStep = 0; /* Number of virtual machine steps */
65522 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65523 unsigned nProgressLimit; /* Invoke xProgress() when nVmStep reaches this */
65524 #endif
65525 Mem *aMem = p->aMem; /* Copy of p->aMem */
65526 Mem *pIn1 = 0; /* 1st input operand */
65527 Mem *pIn2 = 0; /* 2nd input operand */
65528 Mem *pIn3 = 0; /* 3rd input operand */
@@ -65977,21 +65941,10 @@
65977 assert( p->explain==0 );
65978 p->pResultSet = 0;
65979 db->busyHandler.nBusy = 0;
65980 CHECK_FOR_INTERRUPT;
65981 sqlite3VdbeIOTraceSql(p);
65982 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65983 if( db->xProgress ){
65984 assert( 0 < db->nProgressOps );
65985 nProgressLimit = (unsigned)p->aCounter[SQLITE_STMTSTATUS_VM_STEP-1];
65986 if( nProgressLimit==0 ){
65987 nProgressLimit = db->nProgressOps;
65988 }else{
65989 nProgressLimit %= (unsigned)db->nProgressOps;
65990 }
65991 }
65992 #endif
65993 #ifdef SQLITE_DEBUG
65994 sqlite3BeginBenignMalloc();
65995 if( p->pc==0 && (p->db->flags & SQLITE_VdbeListing)!=0 ){
65996 int i;
65997 printf("VDBE Program Listing:\n");
@@ -66148,20 +66101,18 @@
66148 ** of VDBE ops have been executed (either since this invocation of
66149 ** sqlite3VdbeExec() or since last time the progress callback was called).
66150 ** If the progress callback returns non-zero, exit the virtual machine with
66151 ** a return code SQLITE_ABORT.
66152 */
66153 if( db->xProgress!=0 && nVmStep>=nProgressLimit ){
66154 int prc;
66155 prc = db->xProgress(db->pProgressArg);
66156 if( prc!=0 ){
66157 rc = SQLITE_INTERRUPT;
66158 goto vdbe_error_halt;
66159 }
66160 if( db->xProgress!=0 ){
66161 nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);
66162 }
66163 }
66164 #endif
66165
66166 break;
66167 }
@@ -66843,18 +66794,23 @@
66843 Deephemeralize(u.ai.pArg);
66844 sqlite3VdbeMemStoreType(u.ai.pArg);
66845 REGISTER_TRACE(pOp->p2+u.ai.i, u.ai.pArg);
66846 }
66847
66848 assert( pOp->p4type==P4_FUNCDEF );
66849 u.ai.ctx.pFunc = pOp->p4.pFunc;
 
 
 
 
 
 
 
66850 u.ai.ctx.s.flags = MEM_Null;
66851 u.ai.ctx.s.db = db;
66852 u.ai.ctx.s.xDel = 0;
66853 u.ai.ctx.s.zMalloc = 0;
66854 u.ai.ctx.iOp = pc;
66855 u.ai.ctx.pVdbe = p;
66856
66857 /* The output cell may already have a buffer allocated. Move
66858 ** the pointer to u.ai.ctx.s so in case the user-function can use
66859 ** the already allocated buffer instead of allocating a new one.
66860 */
@@ -66873,11 +66829,15 @@
66873 lastRowid = db->lastRowid;
66874
66875 /* If any auxiliary data functions have been called by this user function,
66876 ** immediately call the destructor for any non-static values.
66877 */
66878 sqlite3VdbeDeleteAuxData(p, pc, pOp->p1);
 
 
 
 
66879
66880 if( db->mallocFailed ){
66881 /* Even though a malloc() has failed, the implementation of the
66882 ** user function may have called an sqlite3_result_XXX() function
66883 ** to return a value. The following call releases any resources
@@ -107790,11 +107750,10 @@
107790 WhereLevel *pLevel; /* The where level to be coded */
107791 WhereLoop *pLoop; /* The WhereLoop object being coded */
107792 WhereClause *pWC; /* Decomposition of the entire WHERE clause */
107793 WhereTerm *pTerm; /* A WHERE clause term */
107794 Parse *pParse; /* Parsing context */
107795 sqlite3 *db; /* Database connection */
107796 Vdbe *v; /* The prepared stmt under constructions */
107797 struct SrcList_item *pTabItem; /* FROM clause term being coded */
107798 int addrBrk; /* Jump here to break out of the loop */
107799 int addrCont; /* Jump here to continue with next cycle */
107800 int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
@@ -107802,11 +107761,10 @@
107802 Bitmask newNotReady; /* Return value */
107803
107804 pParse = pWInfo->pParse;
107805 v = pParse->pVdbe;
107806 pWC = &pWInfo->sWC;
107807 db = pParse->db;
107808 pLevel = &pWInfo->a[iLevel];
107809 pLoop = pLevel->pWLoop;
107810 pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
107811 iCur = pTabItem->iCursor;
107812 bRev = (pWInfo->revMask>>iLevel)&1;
@@ -108093,11 +108051,11 @@
108093 /* Generate code to evaluate all constraint terms using == or IN
108094 ** and store the values of those terms in an array of registers
108095 ** starting at regBase.
108096 */
108097 regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
108098 zEndAff = sqlite3DbStrDup(db, zStartAff);
108099 addrNxt = pLevel->addrNxt;
108100
108101 /* If we are doing a reverse order scan on an ascending index, or
108102 ** a forward order scan on a descending index, interchange the
108103 ** start and end terms (pRangeStart and pRangeEnd).
@@ -108178,12 +108136,12 @@
108178 }
108179 codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
108180 nConstraint++;
108181 testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108182 }
108183 sqlite3DbFree(db, zStartAff);
108184 sqlite3DbFree(db, zEndAff);
108185
108186 /* Top of the loop body */
108187 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
108188
108189 /* Check if the index cursor is past the end of the range. */
@@ -108306,11 +108264,11 @@
108306 */
108307 if( pWInfo->nLevel>1 ){
108308 int nNotReady; /* The number of notReady tables */
108309 struct SrcList_item *origSrc; /* Original list of tables */
108310 nNotReady = pWInfo->nLevel - iLevel - 1;
108311 pOrTab = sqlite3StackAllocRaw(db,
108312 sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
108313 if( pOrTab==0 ) return notReady;
108314 pOrTab->nAlloc = (u8)(nNotReady + 1);
108315 pOrTab->nSrc = pOrTab->nAlloc;
108316 memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
@@ -108360,12 +108318,12 @@
108360 Expr *pExpr = pWC->a[iTerm].pExpr;
108361 if( &pWC->a[iTerm] == pTerm ) continue;
108362 if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
108363 if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue;
108364 if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
108365 pExpr = sqlite3ExprDup(db, pExpr, 0);
108366 pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);
108367 }
108368 if( pAndExpr ){
108369 pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
108370 }
108371 }
@@ -108381,11 +108339,11 @@
108381 }
108382 /* Loop through table entries that match term pOrTerm. */
108383 pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
108384 WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
108385 WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
108386 assert( pSubWInfo || pParse->nErr || db->mallocFailed );
108387 if( pSubWInfo ){
108388 WhereLoop *pSubLoop;
108389 explainOneScan(
108390 pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
108391 );
@@ -108436,17 +108394,17 @@
108436 }
108437 pLevel->u.pCovidx = pCov;
108438 if( pCov ) pLevel->iIdxCur = iCovCur;
108439 if( pAndExpr ){
108440 pAndExpr->pLeft = 0;
108441 sqlite3ExprDelete(db, pAndExpr);
108442 }
108443 sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
108444 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
108445 sqlite3VdbeResolveLabel(v, iLoopBody);
108446
108447 if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab);
108448 if( !untestedTerms ) disableTerm(pLevel, pTerm);
108449 }else
108450 #endif /* SQLITE_OMIT_OR_OPTIMIZATION */
108451
108452 {
@@ -108497,12 +108455,13 @@
108497 ** and we are coding the t1 loop and the t2 loop has not yet coded,
108498 ** then we cannot use the "t1.a=t2.b" constraint, but we can code
108499 ** the implied "t1.a=123" constraint.
108500 */
108501 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108502 Expr *pE, *pEAlt;
108503 WhereTerm *pAlt;
 
108504 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108505 if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108506 if( pTerm->leftCursor!=iCur ) continue;
108507 if( pLevel->iLeftJoin ) continue;
108508 pE = pTerm->pExpr;
@@ -108512,17 +108471,13 @@
108512 if( pAlt==0 ) continue;
108513 if( pAlt->wtFlags & (TERM_CODED) ) continue;
108514 testcase( pAlt->eOperator & WO_EQ );
108515 testcase( pAlt->eOperator & WO_IN );
108516 VdbeNoopComment((v, "begin transitive constraint"));
108517 pEAlt = sqlite3StackAllocRaw(db, sizeof(*pEAlt));
108518 if( pEAlt ){
108519 *pEAlt = *pAlt->pExpr;
108520 pEAlt->pLeft = pE->pLeft;
108521 sqlite3ExprIfFalse(pParse, pEAlt, addrCont, SQLITE_JUMPIFNULL);
108522 sqlite3StackFree(db, pEAlt);
108523 }
108524 }
108525
108526 /* For a LEFT OUTER JOIN, generate code that will record the fact that
108527 ** at least one row of the right table has matched the left table.
108528 */
@@ -116461,11 +116416,10 @@
116461 case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break;
116462 case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
116463 case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
116464 case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
116465 case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
116466 case SQLITE_IOERR_GETTEMPPATH: zName = "SQLITE_IOERR_GETTEMPPATH"; break;
116467 case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
116468 case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
116469 case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
116470 case SQLITE_FULL: zName = "SQLITE_FULL"; break;
116471 case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
@@ -117817,11 +117771,11 @@
117817 db->autoCommit = 1;
117818 db->nextAutovac = -1;
117819 db->szMmap = sqlite3GlobalConfig.szMmap;
117820 db->nextPagesize = 0;
117821 db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger
117822 #if !defined(SQLITE_DEFAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
117823 | SQLITE_AutoIndex
117824 #endif
117825 #if SQLITE_DEFAULT_FILE_FORMAT<4
117826 | SQLITE_LegacyFileFmt
117827 #endif
@@ -128290,11 +128244,11 @@
128290 }
128291
128292
128293 #ifdef SQLITE_TEST
128294
128295 #include <tcl.h>
128296 /* #include <string.h> */
128297
128298 /*
128299 ** Implementation of a special SQL scalar function for testing tokenizers
128300 ** designed to be used in concert with the Tcl testing framework. This
128301
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -398,10 +398,13 @@
398 **
399 ** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
400 ** assert() macro is enabled, each call into the Win32 native heap subsystem
401 ** will cause HeapValidate to be called. If heap validation should fail, an
402 ** assertion will be triggered.
403 **
404 ** (Historical note: There used to be several other options, but we've
405 ** pared it down to just these three.)
406 **
407 ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
408 ** the default.
409 */
410 #if defined(SQLITE_SYSTEM_MALLOC) \
@@ -436,17 +439,24 @@
439 */
440 #if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
441 # define _XOPEN_SOURCE 600
442 #endif
443
444 /*
445 ** The TCL headers are only needed when compiling the TCL bindings.
446 */
447 #if defined(SQLITE_TCL) || defined(TCLSH)
448 # include <tcl.h>
449 #endif
450
451 /*
452 ** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
453 ** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
454 ** make it true by defining or undefining NDEBUG.
455 **
456 ** Setting NDEBUG makes the code smaller and run faster by disabling the
457 ** number assert() statements in the code. So we want the default action
458 ** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
459 ** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
460 ** feature.
461 */
462 #if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -512,11 +522,11 @@
522 ** hint of unplanned behavior.
523 **
524 ** In other words, ALWAYS and NEVER are added for defensive code.
525 **
526 ** When doing coverage testing ALWAYS and NEVER are hard-coded to
527 ** be true and false so that the unreachable code then specify will
528 ** not be counted as untested code.
529 */
530 #if defined(SQLITE_COVERAGE_TEST)
531 # define ALWAYS(X) (1)
532 # define NEVER(X) (0)
@@ -536,16 +546,20 @@
546 #define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
547
548 /*
549 ** The macro unlikely() is a hint that surrounds a boolean
550 ** expression that is usually false. Macro likely() surrounds
551 ** a boolean expression that is usually true. GCC is able to
552 ** use these hints to generate better code, sometimes.
 
553 */
554 #if defined(__GNUC__) && 0
555 # define likely(X) __builtin_expect((X),1)
556 # define unlikely(X) __builtin_expect((X),0)
557 #else
558 # define likely(X) !!(X)
559 # define unlikely(X) !!(X)
560 #endif
561
562 /************** Include sqlite3.h in the middle of sqliteInt.h ***************/
563 /************** Begin file sqlite3.h *****************************************/
564 /*
565 ** 2001 September 15
@@ -656,11 +670,11 @@
670 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
671 ** [sqlite_version()] and [sqlite_source_id()].
672 */
673 #define SQLITE_VERSION "3.8.0"
674 #define SQLITE_VERSION_NUMBER 3008000
675 #define SQLITE_SOURCE_ID "2013-07-18 14:50:56 5dcffa671f592ae9355628afa439ae9a2d26f0cd"
676
677 /*
678 ** CAPI3REF: Run-Time Library Version Numbers
679 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
680 **
@@ -1025,11 +1039,10 @@
1039 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
1040 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
1041 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
1042 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
1043 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
 
1044 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
1045 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
1046 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
1047 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
1048 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -3109,12 +3122,11 @@
3122 ** interface is to keep a GUI updated during a large query.
3123 **
3124 ** ^The parameter P is passed through as the only parameter to the
3125 ** callback function X. ^The parameter N is the approximate number of
3126 ** [virtual machine instructions] that are evaluated between successive
3127 ** invocations of the callback X.
 
3128 **
3129 ** ^Only a single progress handler may be defined at one time per
3130 ** [database connection]; setting a new progress handler cancels the
3131 ** old one. ^Setting parameter X to NULL disables the progress handler.
3132 ** ^The progress handler is also disabled by setting N to a value less
@@ -4730,49 +4742,50 @@
4742 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4743
4744 /*
4745 ** CAPI3REF: Function Auxiliary Data
4746 **
4747 ** The following two functions may be used by scalar SQL functions to
4748 ** associate metadata with argument values. If the same value is passed to
4749 ** multiple invocations of the same SQL function during query execution, under
4750 ** some circumstances the associated metadata may be preserved. This might
4751 ** be used, for example, in a regular-expression matching
4752 ** function. The compiled version of the regular expression is stored as
4753 ** metadata associated with the SQL value passed as the regular expression
4754 ** pattern. The compiled regular expression can be reused on multiple
4755 ** invocations of the same function so that the original pattern string
4756 ** does not need to be recompiled on each invocation.
4757 **
4758 ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
4759 ** associated by the sqlite3_set_auxdata() function with the Nth argument
4760 ** value to the application-defined function. ^If no metadata has been ever
4761 ** been set for the Nth argument of the function, or if the corresponding
4762 ** function parameter has changed since the meta-data was set,
4763 ** then sqlite3_get_auxdata() returns a NULL pointer.
4764 **
4765 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
4766 ** argument of the application-defined function. ^Subsequent
4767 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
4768 ** sqlite3_set_auxdata(C,N,P,X) call if the data has not been dropped, or
4769 ** NULL if the data has been dropped.
4770 ** ^(If it is not NULL, SQLite will invoke the destructor
4771 ** function X passed to sqlite3_set_auxdata(C,N,P,X) when <ul>
4772 ** <li> the corresponding function parameter changes,
4773 ** <li> [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4774 ** SQL statement,
4775 ** <li> sqlite3_set_auxdata() is invoked again on the same parameter, or
4776 ** <li> a memory allocation error occurs. </ul>)^
 
 
 
4777 **
4778 ** SQLite is free to call the destructor and drop metadata on any
4779 ** parameter of any function at any time. ^The only guarantee is that
4780 ** the destructor will be called when the [prepared statement] is destroyed.
4781 ** Note in particular that the destructor X in the call to
4782 ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before
4783 ** the sqlite3_set_auxdata() call even returns. Hence sqlite3_set_auxdata()
4784 ** should be called near the end of the function implementation and the
4785 ** implementation should not make any use of P after sqlite3_set_auxdata()
4786 ** has been called.
4787 **
4788 ** ^(In practice, metadata is preserved between function calls for
4789 ** function parameters that are compile-time constants, including literal
4790 ** values and [parameters] and expressions composed from the same.)^
4791 **
@@ -8811,10 +8824,11 @@
8824
8825 /*
8826 ** The names of the following types declared in vdbeInt.h are required
8827 ** for the VdbeOp definition.
8828 */
8829 typedef struct VdbeFunc VdbeFunc;
8830 typedef struct Mem Mem;
8831 typedef struct SubProgram SubProgram;
8832
8833 /*
8834 ** A single instruction of the virtual machine has an opcode
@@ -8834,10 +8848,11 @@
8848 void *p; /* Generic pointer */
8849 char *z; /* Pointer to data for string (char array) types */
8850 i64 *pI64; /* Used when p4type is P4_INT64 */
8851 double *pReal; /* Used when p4type is P4_REAL */
8852 FuncDef *pFunc; /* Used when p4type is P4_FUNCDEF */
8853 VdbeFunc *pVdbeFunc; /* Used when p4type is P4_VDBEFUNC */
8854 CollSeq *pColl; /* Used when p4type is P4_COLLSEQ */
8855 Mem *pMem; /* Used when p4type is P4_MEM */
8856 VTable *pVtab; /* Used when p4type is P4_VTAB */
8857 KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */
8858 int *ai; /* Used when p4type is P4_INTARRAY */
@@ -8887,10 +8902,11 @@
8902 #define P4_DYNAMIC (-1) /* Pointer to a string obtained from sqliteMalloc() */
8903 #define P4_STATIC (-2) /* Pointer to a static string */
8904 #define P4_COLLSEQ (-4) /* P4 is a pointer to a CollSeq structure */
8905 #define P4_FUNCDEF (-5) /* P4 is a pointer to a FuncDef structure */
8906 #define P4_KEYINFO (-6) /* P4 is a pointer to a KeyInfo structure */
8907 #define P4_VDBEFUNC (-7) /* P4 is a pointer to a VdbeFunc structure */
8908 #define P4_MEM (-8) /* P4 is a pointer to a Mem* structure */
8909 #define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */
8910 #define P4_VTAB (-10) /* P4 is a pointer to an sqlite3_vtab structure */
8911 #define P4_MPRINTF (-11) /* P4 is a string obtained from sqlite3_mprintf() */
8912 #define P4_REAL (-12) /* P4 is a 64-bit floating point value */
@@ -13241,13 +13257,10 @@
13257 typedef struct VdbeSorter VdbeSorter;
13258
13259 /* Opaque type used by the explainer */
13260 typedef struct Explain Explain;
13261
 
 
 
13262 /*
13263 ** A cursor is a pointer into a single BTree within a database file.
13264 ** The cursor can seek to a BTree entry with a particular key, or
13265 ** loop over all entries of the Btree. You can also insert new BTree
13266 ** entries or retrieve the key or data from the entry that the cursor
@@ -13430,23 +13443,27 @@
13443 */
13444 #ifdef SQLITE_DEBUG
13445 #define memIsValid(M) ((M)->flags & MEM_Invalid)==0
13446 #endif
13447
13448
13449 /* A VdbeFunc is just a FuncDef (defined in sqliteInt.h) that contains
13450 ** additional information about auxiliary information bound to arguments
13451 ** of the function. This is used to implement the sqlite3_get_auxdata()
13452 ** and sqlite3_set_auxdata() APIs. The "auxdata" is some auxiliary data
13453 ** that can be associated with a constant argument to a function. This
13454 ** allows functions such as "regexp" to compile their constant regular
13455 ** expression argument once and reused the compiled code for multiple
13456 ** invocations.
13457 */
13458 struct VdbeFunc {
13459 FuncDef *pFunc; /* The definition of the function */
13460 int nAux; /* Number of entries allocated for apAux[] */
13461 struct AuxData {
13462 void *pAux; /* Aux data for the i-th argument */
13463 void (*xDelete)(void *); /* Destructor for the aux data */
13464 } apAux[1]; /* One slot for each function argument */
13465 };
13466
13467 /*
13468 ** The "context" argument for a installable function. A pointer to an
13469 ** instance of this structure is the first argument to the routines used
@@ -13460,17 +13477,16 @@
13477 ** This structure is defined inside of vdbeInt.h because it uses substructures
13478 ** (Mem) which are only defined there.
13479 */
13480 struct sqlite3_context {
13481 FuncDef *pFunc; /* Pointer to function information. MUST BE FIRST */
13482 VdbeFunc *pVdbeFunc; /* Auxilary data, if created. */
13483 Mem s; /* The return value is stored here */
13484 Mem *pMem; /* Memory cell used to store aggregate context */
13485 CollSeq *pColl; /* Collating sequence */
13486 int isError; /* Error code returned by the function. */
13487 int skipFlag; /* Skip skip accumulator loading if true */
 
 
13488 };
13489
13490 /*
13491 ** An Explain object accumulates indented output which is helpful
13492 ** in describing recursive data structures.
@@ -13565,11 +13581,10 @@
13581 int nFrame; /* Number of frames in pFrame list */
13582 u32 expmask; /* Binding to these vars invalidates VM */
13583 SubProgram *pProgram; /* Linked list of all sub-programs used by VM */
13584 int nOnceFlag; /* Size of array aOnceFlag[] */
13585 u8 *aOnceFlag; /* Flags for OP_Once */
 
13586 };
13587
13588 /*
13589 ** The following are allowed values for Vdbe.magic
13590 */
@@ -13589,11 +13604,11 @@
13604 #endif
13605 SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
13606 SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int);
13607 SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int);
13608 SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
13609 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc*, int);
13610
13611 int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
13612 SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*);
13613 SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *);
13614 SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
@@ -28361,27 +28376,22 @@
28376 */
28377 static const char *unixTempFileDir(void){
28378 static const char *azDirs[] = {
28379 0,
28380 0,
 
 
28381 "/var/tmp",
28382 "/usr/tmp",
28383 "/tmp",
28384 0 /* List terminator */
28385 };
28386 unsigned int i;
28387 struct stat buf;
28388 const char *zDir = 0;
28389
28390 azDirs[0] = sqlite3_temp_directory;
28391 if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR");
28392 for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){
 
 
 
28393 if( zDir==0 ) continue;
28394 if( osStat(zDir, &buf) ) continue;
28395 if( !S_ISDIR(buf.st_mode) ) continue;
28396 if( osAccess(zDir, 07) ) continue;
28397 break;
@@ -28407,10 +28417,11 @@
28417 ** function failing.
28418 */
28419 SimulateIOError( return SQLITE_IOERR );
28420
28421 zDir = unixTempFileDir();
28422 if( zDir==0 ) zDir = ".";
28423
28424 /* Check that the output buffer is large enough for the temporary file
28425 ** name. If it is not, return SQLITE_ERROR.
28426 */
28427 if( (strlen(zDir) + strlen(SQLITE_TEMP_FILE_PREFIX) + 18) >= (size_t)nBuf ){
@@ -30488,11 +30499,10 @@
30499 */
30500 #if SQLITE_OS_WIN /* This file is used for Windows only */
30501
30502 #ifdef __CYGWIN__
30503 # include <sys/cygwin.h>
 
30504 #endif
30505
30506 /*
30507 ** Include code that is common to all os_*.c files
30508 */
@@ -30717,11 +30727,11 @@
30727
30728 /*
30729 ** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions
30730 ** based on the sub-platform)?
30731 */
30732 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)
30733 # define SQLITE_WIN32_HAS_ANSI
30734 #endif
30735
30736 /*
30737 ** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions
@@ -30909,11 +30919,10 @@
30919 * zero for the default behavior.
30920 */
30921 #ifndef SQLITE_WIN32_HEAP_FLAGS
30922 # define SQLITE_WIN32_HEAP_FLAGS (0)
30923 #endif
 
30924
30925 /*
30926 ** The winMemData structure stores information required by the Win32-specific
30927 ** sqlite3_mem_methods implementation.
30928 */
@@ -34375,14 +34384,14 @@
34384 OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
34385 osGetCurrentProcessId(), pFd));
34386 return SQLITE_OK;
34387 }
34388 assert( (nMap % winSysInfo.dwPageSize)==0 );
 
34389 #if SQLITE_OS_WINRT
34390 pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, nMap);
34391 #else
34392 assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
34393 pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
34394 #endif
34395 if( pNew==NULL ){
34396 osCloseHandle(pFd->hMap);
34397 pFd->hMap = NULL;
@@ -34549,19 +34558,10 @@
34558 return zConverted;
34559 }
34560
34561 static int winIsDir(const void *zConverted);
34562
 
 
 
 
 
 
 
 
 
34563 /*
34564 ** Create a temporary file name in zBuf. zBuf must be big enough to
34565 ** hold at pVfs->mxPathname characters.
34566 */
34567 static int getTempname(int nBuf, char *zBuf){
@@ -34569,21 +34569,22 @@
34569 "abcdefghijklmnopqrstuvwxyz"
34570 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
34571 "0123456789";
34572 size_t i, j;
34573 int nTempPath;
34574 char zTempPath[MAX_PATH+2];
34575
34576 /* It's odd to simulate an io-error here, but really this is just
34577 ** using the io-error infrastructure to test that SQLite handles this
34578 ** function failing.
34579 */
34580 SimulateIOError( return SQLITE_IOERR );
34581
34582 memset(zTempPath, 0, MAX_PATH+2);
34583
34584 if( sqlite3_temp_directory ){
34585 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
 
34586 }
34587 #if defined(__CYGWIN__)
34588 else{
34589 static const char *azDirs[] = {
34590 0,
@@ -34626,58 +34627,36 @@
34627 }
34628 #elif !SQLITE_OS_WINRT
34629 else if( isNT() ){
34630 char *zMulti;
34631 WCHAR zWidePath[MAX_PATH];
34632 osGetTempPathW(MAX_PATH-30, zWidePath);
 
 
 
34633 zMulti = unicodeToUtf8(zWidePath);
34634 if( zMulti ){
34635 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti);
34636 sqlite3_free(zMulti);
34637 }else{
34638 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34639 return SQLITE_IOERR_NOMEM;
34640 }
34641 }
34642 #ifdef SQLITE_WIN32_HAS_ANSI
34643 else{
34644 char *zUtf8;
34645 char zMbcsPath[MAX_PATH];
34646 osGetTempPathA(MAX_PATH-30, zMbcsPath);
 
 
 
34647 zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
34648 if( zUtf8 ){
34649 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8);
34650 sqlite3_free(zUtf8);
34651 }else{
34652 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34653 return SQLITE_IOERR_NOMEM;
34654 }
34655 }
34656 #endif
34657 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34658
34659 /* Check that the output buffer is large enough for the temporary file
34660 ** name. If it is not, return SQLITE_ERROR.
34661 */
34662 nTempPath = sqlite3Strlen30(zTempPath);
@@ -34759,11 +34738,11 @@
34738 int cnt = 0;
34739
34740 /* If argument zPath is a NULL pointer, this function is required to open
34741 ** a temporary file. Use this buffer to store the file name in.
34742 */
34743 char zTmpname[MAX_PATH+2]; /* Buffer used to create temp filename */
34744
34745 int rc = SQLITE_OK; /* Function Return Code */
34746 #if !defined(NDEBUG) || SQLITE_OS_WINCE
34747 int eType = flags&0xFFFFFF00; /* Type of file to open */
34748 #endif
@@ -34825,11 +34804,12 @@
34804 /* If the second argument to this function is NULL, generate a
34805 ** temporary file name to use
34806 */
34807 if( !zUtf8Name ){
34808 assert(isDelete && !isOpenJournal);
34809 memset(zTmpname, 0, MAX_PATH+2);
34810 rc = getTempname(MAX_PATH+2, zTmpname);
34811 if( rc!=SQLITE_OK ){
34812 OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
34813 return rc;
34814 }
34815 zUtf8Name = zTmpname;
@@ -35256,34 +35236,27 @@
35236 ){
35237
35238 #if defined(__CYGWIN__)
35239 SimulateIOError( return SQLITE_ERROR );
35240 UNUSED_PARAMETER(nFull);
35241 assert( pVfs->mxPathname>=MAX_PATH );
35242 assert( nFull>=pVfs->mxPathname );
35243 if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
35244 /*
35245 ** NOTE: We are dealing with a relative path name and the data
35246 ** directory has been set. Therefore, use it as the basis
35247 ** for converting the relative path name to an absolute
35248 ** one by prepending the data directory and a slash.
35249 */
35250 char zOut[MAX_PATH+1];
35251 memset(zOut, 0, MAX_PATH+1);
35252 cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35253 MAX_PATH+1);
 
 
 
35254 sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
35255 sqlite3_data_directory, zOut);
35256 }else{
35257 cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull);
 
 
 
 
35258 }
35259 return SQLITE_OK;
35260 #endif
35261
35262 #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
@@ -35621,11 +35594,11 @@
35594 */
35595 SQLITE_API int sqlite3_os_init(void){
35596 static sqlite3_vfs winVfs = {
35597 3, /* iVersion */
35598 sizeof(winFile), /* szOsFile */
35599 MAX_PATH, /* mxPathname */
35600 0, /* pNext */
35601 "win32", /* zName */
35602 0, /* pAppData */
35603 winOpen, /* xOpen */
35604 winDelete, /* xDelete */
@@ -60607,10 +60580,17 @@
60580 break;
60581 }
60582 case P4_MPRINTF: {
60583 if( db->pnBytesFreed==0 ) sqlite3_free(p4);
60584 break;
60585 }
60586 case P4_VDBEFUNC: {
60587 VdbeFunc *pVdbeFunc = (VdbeFunc *)p4;
60588 freeEphemeralFunction(db, pVdbeFunc->pFunc);
60589 if( db->pnBytesFreed==0 ) sqlite3VdbeDeleteAuxData(pVdbeFunc, 0);
60590 sqlite3DbFree(db, pVdbeFunc);
60591 break;
60592 }
60593 case P4_FUNCDEF: {
60594 freeEphemeralFunction(db, (FuncDef*)p4);
60595 break;
60596 }
@@ -61637,14 +61617,10 @@
61617 while( p->pDelFrame ){
61618 VdbeFrame *pDel = p->pDelFrame;
61619 p->pDelFrame = pDel->pParent;
61620 sqlite3VdbeFrameDelete(pDel);
61621 }
 
 
 
 
61622 }
61623
61624 /*
61625 ** Clean up the VM after execution.
61626 **
@@ -62439,39 +62415,24 @@
62415 sqlite3VdbeDelete(p);
62416 return rc;
62417 }
62418
62419 /*
62420 ** Call the destructor for each auxdata entry in pVdbeFunc for which
62421 ** the corresponding bit in mask is clear. Auxdata entries beyond 31
62422 ** are always destroyed. To destroy all auxdata entries, call this
62423 ** routine with mask==0.
 
 
 
 
 
 
 
 
 
 
62424 */
62425 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc *pVdbeFunc, int mask){
62426 int i;
62427 for(i=0; i<pVdbeFunc->nAux; i++){
62428 struct AuxData *pAux = &pVdbeFunc->apAux[i];
62429 if( (i>31 || !(mask&(((u32)1)<<i))) && pAux->pAux ){
 
 
62430 if( pAux->xDelete ){
62431 pAux->xDelete(pAux->pAux);
62432 }
62433 pAux->pAux = 0;
 
 
 
62434 }
62435 }
62436 }
62437
62438 /*
@@ -63866,18 +63827,18 @@
63827 /*
63828 ** Return the auxilary data pointer, if any, for the iArg'th argument to
63829 ** the user-function defined by pCtx.
63830 */
63831 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
63832 VdbeFunc *pVdbeFunc;
63833
63834 assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63835 pVdbeFunc = pCtx->pVdbeFunc;
63836 if( !pVdbeFunc || iArg>=pVdbeFunc->nAux || iArg<0 ){
63837 return 0;
63838 }
63839 return pVdbeFunc->apAux[iArg].pAux;
 
63840 }
63841
63842 /*
63843 ** Set the auxilary data pointer and delete function, for the iArg'th
63844 ** argument to the user-function defined by pCtx. Any previous value is
@@ -63887,30 +63848,33 @@
63848 sqlite3_context *pCtx,
63849 int iArg,
63850 void *pAux,
63851 void (*xDelete)(void*)
63852 ){
63853 struct AuxData *pAuxData;
63854 VdbeFunc *pVdbeFunc;
 
 
63855 if( iArg<0 ) goto failed;
63856
63857 assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63858 pVdbeFunc = pCtx->pVdbeFunc;
63859 if( !pVdbeFunc || pVdbeFunc->nAux<=iArg ){
63860 int nAux = (pVdbeFunc ? pVdbeFunc->nAux : 0);
63861 int nMalloc = sizeof(VdbeFunc) + sizeof(struct AuxData)*iArg;
63862 pVdbeFunc = sqlite3DbRealloc(pCtx->s.db, pVdbeFunc, nMalloc);
63863 if( !pVdbeFunc ){
63864 goto failed;
63865 }
63866 pCtx->pVdbeFunc = pVdbeFunc;
63867 memset(&pVdbeFunc->apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux));
63868 pVdbeFunc->nAux = iArg+1;
63869 pVdbeFunc->pFunc = pCtx->pFunc;
63870 }
63871
63872 pAuxData = &pVdbeFunc->apAux[iArg];
63873 if( pAuxData->pAux && pAuxData->xDelete ){
63874 pAuxData->xDelete(pAuxData->pAux);
63875 }
 
63876 pAuxData->pAux = pAux;
63877 pAuxData->xDelete = xDelete;
63878 return;
63879
63880 failed:
@@ -65518,11 +65482,11 @@
65482 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
65483 u8 encoding = ENC(db); /* The database encoding */
65484 int iCompare = 0; /* Result of last OP_Compare operation */
65485 unsigned nVmStep = 0; /* Number of virtual machine steps */
65486 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65487 unsigned nProgressOps = 0; /* nVmStep at last progress callback. */
65488 #endif
65489 Mem *aMem = p->aMem; /* Copy of p->aMem */
65490 Mem *pIn1 = 0; /* 1st input operand */
65491 Mem *pIn2 = 0; /* 2nd input operand */
65492 Mem *pIn3 = 0; /* 3rd input operand */
@@ -65977,21 +65941,10 @@
65941 assert( p->explain==0 );
65942 p->pResultSet = 0;
65943 db->busyHandler.nBusy = 0;
65944 CHECK_FOR_INTERRUPT;
65945 sqlite3VdbeIOTraceSql(p);
 
 
 
 
 
 
 
 
 
 
 
65946 #ifdef SQLITE_DEBUG
65947 sqlite3BeginBenignMalloc();
65948 if( p->pc==0 && (p->db->flags & SQLITE_VdbeListing)!=0 ){
65949 int i;
65950 printf("VDBE Program Listing:\n");
@@ -66148,20 +66101,18 @@
66101 ** of VDBE ops have been executed (either since this invocation of
66102 ** sqlite3VdbeExec() or since last time the progress callback was called).
66103 ** If the progress callback returns non-zero, exit the virtual machine with
66104 ** a return code SQLITE_ABORT.
66105 */
66106 if( db->xProgress!=0 && (nVmStep - nProgressOps)>=db->nProgressOps ){
66107 int prc;
66108 prc = db->xProgress(db->pProgressArg);
66109 if( prc!=0 ){
66110 rc = SQLITE_INTERRUPT;
66111 goto vdbe_error_halt;
66112 }
66113 nProgressOps = nVmStep;
 
 
66114 }
66115 #endif
66116
66117 break;
66118 }
@@ -66843,18 +66794,23 @@
66794 Deephemeralize(u.ai.pArg);
66795 sqlite3VdbeMemStoreType(u.ai.pArg);
66796 REGISTER_TRACE(pOp->p2+u.ai.i, u.ai.pArg);
66797 }
66798
66799 assert( pOp->p4type==P4_FUNCDEF || pOp->p4type==P4_VDBEFUNC );
66800 if( pOp->p4type==P4_FUNCDEF ){
66801 u.ai.ctx.pFunc = pOp->p4.pFunc;
66802 u.ai.ctx.pVdbeFunc = 0;
66803 }else{
66804 u.ai.ctx.pVdbeFunc = (VdbeFunc*)pOp->p4.pVdbeFunc;
66805 u.ai.ctx.pFunc = u.ai.ctx.pVdbeFunc->pFunc;
66806 }
66807
66808 u.ai.ctx.s.flags = MEM_Null;
66809 u.ai.ctx.s.db = db;
66810 u.ai.ctx.s.xDel = 0;
66811 u.ai.ctx.s.zMalloc = 0;
 
 
66812
66813 /* The output cell may already have a buffer allocated. Move
66814 ** the pointer to u.ai.ctx.s so in case the user-function can use
66815 ** the already allocated buffer instead of allocating a new one.
66816 */
@@ -66873,11 +66829,15 @@
66829 lastRowid = db->lastRowid;
66830
66831 /* If any auxiliary data functions have been called by this user function,
66832 ** immediately call the destructor for any non-static values.
66833 */
66834 if( u.ai.ctx.pVdbeFunc ){
66835 sqlite3VdbeDeleteAuxData(u.ai.ctx.pVdbeFunc, pOp->p1);
66836 pOp->p4.pVdbeFunc = u.ai.ctx.pVdbeFunc;
66837 pOp->p4type = P4_VDBEFUNC;
66838 }
66839
66840 if( db->mallocFailed ){
66841 /* Even though a malloc() has failed, the implementation of the
66842 ** user function may have called an sqlite3_result_XXX() function
66843 ** to return a value. The following call releases any resources
@@ -107790,11 +107750,10 @@
107750 WhereLevel *pLevel; /* The where level to be coded */
107751 WhereLoop *pLoop; /* The WhereLoop object being coded */
107752 WhereClause *pWC; /* Decomposition of the entire WHERE clause */
107753 WhereTerm *pTerm; /* A WHERE clause term */
107754 Parse *pParse; /* Parsing context */
 
107755 Vdbe *v; /* The prepared stmt under constructions */
107756 struct SrcList_item *pTabItem; /* FROM clause term being coded */
107757 int addrBrk; /* Jump here to break out of the loop */
107758 int addrCont; /* Jump here to continue with next cycle */
107759 int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
@@ -107802,11 +107761,10 @@
107761 Bitmask newNotReady; /* Return value */
107762
107763 pParse = pWInfo->pParse;
107764 v = pParse->pVdbe;
107765 pWC = &pWInfo->sWC;
 
107766 pLevel = &pWInfo->a[iLevel];
107767 pLoop = pLevel->pWLoop;
107768 pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
107769 iCur = pTabItem->iCursor;
107770 bRev = (pWInfo->revMask>>iLevel)&1;
@@ -108093,11 +108051,11 @@
108051 /* Generate code to evaluate all constraint terms using == or IN
108052 ** and store the values of those terms in an array of registers
108053 ** starting at regBase.
108054 */
108055 regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
108056 zEndAff = sqlite3DbStrDup(pParse->db, zStartAff);
108057 addrNxt = pLevel->addrNxt;
108058
108059 /* If we are doing a reverse order scan on an ascending index, or
108060 ** a forward order scan on a descending index, interchange the
108061 ** start and end terms (pRangeStart and pRangeEnd).
@@ -108178,12 +108136,12 @@
108136 }
108137 codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
108138 nConstraint++;
108139 testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108140 }
108141 sqlite3DbFree(pParse->db, zStartAff);
108142 sqlite3DbFree(pParse->db, zEndAff);
108143
108144 /* Top of the loop body */
108145 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
108146
108147 /* Check if the index cursor is past the end of the range. */
@@ -108306,11 +108264,11 @@
108264 */
108265 if( pWInfo->nLevel>1 ){
108266 int nNotReady; /* The number of notReady tables */
108267 struct SrcList_item *origSrc; /* Original list of tables */
108268 nNotReady = pWInfo->nLevel - iLevel - 1;
108269 pOrTab = sqlite3StackAllocRaw(pParse->db,
108270 sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
108271 if( pOrTab==0 ) return notReady;
108272 pOrTab->nAlloc = (u8)(nNotReady + 1);
108273 pOrTab->nSrc = pOrTab->nAlloc;
108274 memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
@@ -108360,12 +108318,12 @@
108318 Expr *pExpr = pWC->a[iTerm].pExpr;
108319 if( &pWC->a[iTerm] == pTerm ) continue;
108320 if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
108321 if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue;
108322 if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
108323 pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
108324 pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr);
108325 }
108326 if( pAndExpr ){
108327 pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
108328 }
108329 }
@@ -108381,11 +108339,11 @@
108339 }
108340 /* Loop through table entries that match term pOrTerm. */
108341 pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
108342 WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
108343 WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
108344 assert( pSubWInfo || pParse->nErr || pParse->db->mallocFailed );
108345 if( pSubWInfo ){
108346 WhereLoop *pSubLoop;
108347 explainOneScan(
108348 pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
108349 );
@@ -108436,17 +108394,17 @@
108394 }
108395 pLevel->u.pCovidx = pCov;
108396 if( pCov ) pLevel->iIdxCur = iCovCur;
108397 if( pAndExpr ){
108398 pAndExpr->pLeft = 0;
108399 sqlite3ExprDelete(pParse->db, pAndExpr);
108400 }
108401 sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
108402 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
108403 sqlite3VdbeResolveLabel(v, iLoopBody);
108404
108405 if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab);
108406 if( !untestedTerms ) disableTerm(pLevel, pTerm);
108407 }else
108408 #endif /* SQLITE_OMIT_OR_OPTIMIZATION */
108409
108410 {
@@ -108497,12 +108455,13 @@
108455 ** and we are coding the t1 loop and the t2 loop has not yet coded,
108456 ** then we cannot use the "t1.a=t2.b" constraint, but we can code
108457 ** the implied "t1.a=123" constraint.
108458 */
108459 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108460 Expr *pE;
108461 WhereTerm *pAlt;
108462 Expr sEq;
108463 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108464 if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108465 if( pTerm->leftCursor!=iCur ) continue;
108466 if( pLevel->iLeftJoin ) continue;
108467 pE = pTerm->pExpr;
@@ -108512,17 +108471,13 @@
108471 if( pAlt==0 ) continue;
108472 if( pAlt->wtFlags & (TERM_CODED) ) continue;
108473 testcase( pAlt->eOperator & WO_EQ );
108474 testcase( pAlt->eOperator & WO_IN );
108475 VdbeNoopComment((v, "begin transitive constraint"));
108476 sEq = *pAlt->pExpr;
108477 sEq.pLeft = pE->pLeft;
108478 sqlite3ExprIfFalse(pParse, &sEq, addrCont, SQLITE_JUMPIFNULL);
 
 
 
 
108479 }
108480
108481 /* For a LEFT OUTER JOIN, generate code that will record the fact that
108482 ** at least one row of the right table has matched the left table.
108483 */
@@ -116461,11 +116416,10 @@
116416 case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break;
116417 case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
116418 case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
116419 case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
116420 case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
 
116421 case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
116422 case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
116423 case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
116424 case SQLITE_FULL: zName = "SQLITE_FULL"; break;
116425 case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
@@ -117817,11 +117771,11 @@
117771 db->autoCommit = 1;
117772 db->nextAutovac = -1;
117773 db->szMmap = sqlite3GlobalConfig.szMmap;
117774 db->nextPagesize = 0;
117775 db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger
117776 #if !defined(SQLITE_DEAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
117777 | SQLITE_AutoIndex
117778 #endif
117779 #if SQLITE_DEFAULT_FILE_FORMAT<4
117780 | SQLITE_LegacyFileFmt
117781 #endif
@@ -128290,11 +128244,11 @@
128244 }
128245
128246
128247 #ifdef SQLITE_TEST
128248
128249 /* #include <tcl.h> */
128250 /* #include <string.h> */
128251
128252 /*
128253 ** Implementation of a special SQL scalar function for testing tokenizers
128254 ** designed to be used in concert with the Tcl testing framework. This
128255
+176 -222
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -398,10 +398,13 @@
398398
**
399399
** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
400400
** assert() macro is enabled, each call into the Win32 native heap subsystem
401401
** will cause HeapValidate to be called. If heap validation should fail, an
402402
** assertion will be triggered.
403
+**
404
+** (Historical note: There used to be several other options, but we've
405
+** pared it down to just these three.)
403406
**
404407
** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
405408
** the default.
406409
*/
407410
#if defined(SQLITE_SYSTEM_MALLOC) \
@@ -436,17 +439,24 @@
436439
*/
437440
#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
438441
# define _XOPEN_SOURCE 600
439442
#endif
440443
444
+/*
445
+** The TCL headers are only needed when compiling the TCL bindings.
446
+*/
447
+#if defined(SQLITE_TCL) || defined(TCLSH)
448
+# include <tcl.h>
449
+#endif
450
+
441451
/*
442452
** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
443453
** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
444454
** make it true by defining or undefining NDEBUG.
445455
**
446
-** Setting NDEBUG makes the code smaller and faster by disabling the
447
-** assert() statements in the code. So we want the default action
456
+** Setting NDEBUG makes the code smaller and run faster by disabling the
457
+** number assert() statements in the code. So we want the default action
448458
** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
449459
** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
450460
** feature.
451461
*/
452462
#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -512,11 +522,11 @@
512522
** hint of unplanned behavior.
513523
**
514524
** In other words, ALWAYS and NEVER are added for defensive code.
515525
**
516526
** When doing coverage testing ALWAYS and NEVER are hard-coded to
517
-** be true and false so that the unreachable code they specify will
527
+** be true and false so that the unreachable code then specify will
518528
** not be counted as untested code.
519529
*/
520530
#if defined(SQLITE_COVERAGE_TEST)
521531
# define ALWAYS(X) (1)
522532
# define NEVER(X) (0)
@@ -536,16 +546,20 @@
536546
#define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
537547
538548
/*
539549
** The macro unlikely() is a hint that surrounds a boolean
540550
** expression that is usually false. Macro likely() surrounds
541
-** a boolean expression that is usually true. These hints could,
542
-** in theory, be used by the compiler to generate better code, but
543
-** currently they are just comments for human readers.
551
+** a boolean expression that is usually true. GCC is able to
552
+** use these hints to generate better code, sometimes.
544553
*/
545
-#define likely(X) (X)
546
-#define unlikely(X) (X)
554
+#if defined(__GNUC__) && 0
555
+# define likely(X) __builtin_expect((X),1)
556
+# define unlikely(X) __builtin_expect((X),0)
557
+#else
558
+# define likely(X) !!(X)
559
+# define unlikely(X) !!(X)
560
+#endif
547561
548562
/************** Include sqlite3.h in the middle of sqliteInt.h ***************/
549563
/************** Begin file sqlite3.h *****************************************/
550564
/*
551565
** 2001 September 15
@@ -656,11 +670,11 @@
656670
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
657671
** [sqlite_version()] and [sqlite_source_id()].
658672
*/
659673
#define SQLITE_VERSION "3.8.0"
660674
#define SQLITE_VERSION_NUMBER 3008000
661
-#define SQLITE_SOURCE_ID "2013-07-31 23:28:36 136fc2931b156f91cdd76a7a009298cdf09d826a"
675
+#define SQLITE_SOURCE_ID "2013-07-18 14:50:56 5dcffa671f592ae9355628afa439ae9a2d26f0cd"
662676
663677
/*
664678
** CAPI3REF: Run-Time Library Version Numbers
665679
** KEYWORDS: sqlite3_version, sqlite3_sourceid
666680
**
@@ -1025,11 +1039,10 @@
10251039
#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
10261040
#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
10271041
#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
10281042
#define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
10291043
#define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
1030
-#define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
10311044
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
10321045
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
10331046
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
10341047
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
10351048
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -3109,12 +3122,11 @@
31093122
** interface is to keep a GUI updated during a large query.
31103123
**
31113124
** ^The parameter P is passed through as the only parameter to the
31123125
** callback function X. ^The parameter N is the approximate number of
31133126
** [virtual machine instructions] that are evaluated between successive
3114
-** invocations of the callback X. ^If N is less than one then the progress
3115
-** handler is disabled.
3127
+** invocations of the callback X.
31163128
**
31173129
** ^Only a single progress handler may be defined at one time per
31183130
** [database connection]; setting a new progress handler cancels the
31193131
** old one. ^Setting parameter X to NULL disables the progress handler.
31203132
** ^The progress handler is also disabled by setting N to a value less
@@ -4730,49 +4742,50 @@
47304742
SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
47314743
47324744
/*
47334745
** CAPI3REF: Function Auxiliary Data
47344746
**
4735
-** These functions may be used by (non-aggregate) SQL functions to
4747
+** The following two functions may be used by scalar SQL functions to
47364748
** associate metadata with argument values. If the same value is passed to
47374749
** multiple invocations of the same SQL function during query execution, under
4738
-** some circumstances the associated metadata may be preserved. An example
4739
-** of where this might be useful is in a regular-expression matching
4740
-** function. The compiled version of the regular expression can be stored as
4741
-** metadata associated with the pattern string.
4742
-** Then as long as the pattern string remains the same,
4743
-** the compiled regular expression can be reused on multiple
4744
-** invocations of the same function.
4750
+** some circumstances the associated metadata may be preserved. This might
4751
+** be used, for example, in a regular-expression matching
4752
+** function. The compiled version of the regular expression is stored as
4753
+** metadata associated with the SQL value passed as the regular expression
4754
+** pattern. The compiled regular expression can be reused on multiple
4755
+** invocations of the same function so that the original pattern string
4756
+** does not need to be recompiled on each invocation.
47454757
**
47464758
** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
47474759
** associated by the sqlite3_set_auxdata() function with the Nth argument
4748
-** value to the application-defined function. ^If there is no metadata
4749
-** associated with the function argument, this sqlite3_get_auxdata() interface
4750
-** returns a NULL pointer.
4760
+** value to the application-defined function. ^If no metadata has been ever
4761
+** been set for the Nth argument of the function, or if the corresponding
4762
+** function parameter has changed since the meta-data was set,
4763
+** then sqlite3_get_auxdata() returns a NULL pointer.
47514764
**
47524765
** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
47534766
** argument of the application-defined function. ^Subsequent
47544767
** calls to sqlite3_get_auxdata(C,N) return P from the most recent
4755
-** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or
4756
-** NULL if the metadata has been discarded.
4757
-** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
4758
-** SQLite will invoke the destructor function X with parameter P exactly
4759
-** once, when the metadata is discarded.
4760
-** SQLite is free to discard the metadata at any time, including: <ul>
4761
-** <li> when the corresponding function parameter changes, or
4762
-** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4763
-** SQL statement, or
4764
-** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or
4765
-** <li> during the original sqlite3_set_auxdata() call when a memory
4766
-** allocation error occurs. </ul>)^
4768
+** sqlite3_set_auxdata(C,N,P,X) call if the data has not been dropped, or
4769
+** NULL if the data has been dropped.
4770
+** ^(If it is not NULL, SQLite will invoke the destructor
4771
+** function X passed to sqlite3_set_auxdata(C,N,P,X) when <ul>
4772
+** <li> the corresponding function parameter changes,
4773
+** <li> [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4774
+** SQL statement,
4775
+** <li> sqlite3_set_auxdata() is invoked again on the same parameter, or
4776
+** <li> a memory allocation error occurs. </ul>)^
47674777
**
4768
-** Note the last bullet in particular. The destructor X in
4769
-** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
4770
-** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
4778
+** SQLite is free to call the destructor and drop metadata on any
4779
+** parameter of any function at any time. ^The only guarantee is that
4780
+** the destructor will be called when the [prepared statement] is destroyed.
4781
+** Note in particular that the destructor X in the call to
4782
+** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before
4783
+** the sqlite3_set_auxdata() call even returns. Hence sqlite3_set_auxdata()
47714784
** should be called near the end of the function implementation and the
4772
-** function implementation should not make any use of P after
4773
-** sqlite3_set_auxdata() has been called.
4785
+** implementation should not make any use of P after sqlite3_set_auxdata()
4786
+** has been called.
47744787
**
47754788
** ^(In practice, metadata is preserved between function calls for
47764789
** function parameters that are compile-time constants, including literal
47774790
** values and [parameters] and expressions composed from the same.)^
47784791
**
@@ -8811,10 +8824,11 @@
88118824
88128825
/*
88138826
** The names of the following types declared in vdbeInt.h are required
88148827
** for the VdbeOp definition.
88158828
*/
8829
+typedef struct VdbeFunc VdbeFunc;
88168830
typedef struct Mem Mem;
88178831
typedef struct SubProgram SubProgram;
88188832
88198833
/*
88208834
** A single instruction of the virtual machine has an opcode
@@ -8834,10 +8848,11 @@
88348848
void *p; /* Generic pointer */
88358849
char *z; /* Pointer to data for string (char array) types */
88368850
i64 *pI64; /* Used when p4type is P4_INT64 */
88378851
double *pReal; /* Used when p4type is P4_REAL */
88388852
FuncDef *pFunc; /* Used when p4type is P4_FUNCDEF */
8853
+ VdbeFunc *pVdbeFunc; /* Used when p4type is P4_VDBEFUNC */
88398854
CollSeq *pColl; /* Used when p4type is P4_COLLSEQ */
88408855
Mem *pMem; /* Used when p4type is P4_MEM */
88418856
VTable *pVtab; /* Used when p4type is P4_VTAB */
88428857
KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */
88438858
int *ai; /* Used when p4type is P4_INTARRAY */
@@ -8887,10 +8902,11 @@
88878902
#define P4_DYNAMIC (-1) /* Pointer to a string obtained from sqliteMalloc() */
88888903
#define P4_STATIC (-2) /* Pointer to a static string */
88898904
#define P4_COLLSEQ (-4) /* P4 is a pointer to a CollSeq structure */
88908905
#define P4_FUNCDEF (-5) /* P4 is a pointer to a FuncDef structure */
88918906
#define P4_KEYINFO (-6) /* P4 is a pointer to a KeyInfo structure */
8907
+#define P4_VDBEFUNC (-7) /* P4 is a pointer to a VdbeFunc structure */
88928908
#define P4_MEM (-8) /* P4 is a pointer to a Mem* structure */
88938909
#define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */
88948910
#define P4_VTAB (-10) /* P4 is a pointer to an sqlite3_vtab structure */
88958911
#define P4_MPRINTF (-11) /* P4 is a string obtained from sqlite3_mprintf() */
88968912
#define P4_REAL (-12) /* P4 is a 64-bit floating point value */
@@ -13241,13 +13257,10 @@
1324113257
typedef struct VdbeSorter VdbeSorter;
1324213258
1324313259
/* Opaque type used by the explainer */
1324413260
typedef struct Explain Explain;
1324513261
13246
-/* Elements of the linked list at Vdbe.pAuxData */
13247
-typedef struct AuxData AuxData;
13248
-
1324913262
/*
1325013263
** A cursor is a pointer into a single BTree within a database file.
1325113264
** The cursor can seek to a BTree entry with a particular key, or
1325213265
** loop over all entries of the Btree. You can also insert new BTree
1325313266
** entries or retrieve the key or data from the entry that the cursor
@@ -13430,23 +13443,27 @@
1343013443
*/
1343113444
#ifdef SQLITE_DEBUG
1343213445
#define memIsValid(M) ((M)->flags & MEM_Invalid)==0
1343313446
#endif
1343413447
13435
-/*
13436
-** Each auxilliary data pointer stored by a user defined function
13437
-** implementation calling sqlite3_set_auxdata() is stored in an instance
13438
-** of this structure. All such structures associated with a single VM
13439
-** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed
13440
-** when the VM is halted (if not before).
13448
+
13449
+/* A VdbeFunc is just a FuncDef (defined in sqliteInt.h) that contains
13450
+** additional information about auxiliary information bound to arguments
13451
+** of the function. This is used to implement the sqlite3_get_auxdata()
13452
+** and sqlite3_set_auxdata() APIs. The "auxdata" is some auxiliary data
13453
+** that can be associated with a constant argument to a function. This
13454
+** allows functions such as "regexp" to compile their constant regular
13455
+** expression argument once and reused the compiled code for multiple
13456
+** invocations.
1344113457
*/
13442
-struct AuxData {
13443
- int iOp; /* Instruction number of OP_Function opcode */
13444
- int iArg; /* Index of function argument. */
13445
- void *pAux; /* Aux data pointer */
13446
- void (*xDelete)(void *); /* Destructor for the aux data */
13447
- AuxData *pNext; /* Next element in list */
13458
+struct VdbeFunc {
13459
+ FuncDef *pFunc; /* The definition of the function */
13460
+ int nAux; /* Number of entries allocated for apAux[] */
13461
+ struct AuxData {
13462
+ void *pAux; /* Aux data for the i-th argument */
13463
+ void (*xDelete)(void *); /* Destructor for the aux data */
13464
+ } apAux[1]; /* One slot for each function argument */
1344813465
};
1344913466
1345013467
/*
1345113468
** The "context" argument for a installable function. A pointer to an
1345213469
** instance of this structure is the first argument to the routines used
@@ -13460,17 +13477,16 @@
1346013477
** This structure is defined inside of vdbeInt.h because it uses substructures
1346113478
** (Mem) which are only defined there.
1346213479
*/
1346313480
struct sqlite3_context {
1346413481
FuncDef *pFunc; /* Pointer to function information. MUST BE FIRST */
13482
+ VdbeFunc *pVdbeFunc; /* Auxilary data, if created. */
1346513483
Mem s; /* The return value is stored here */
1346613484
Mem *pMem; /* Memory cell used to store aggregate context */
1346713485
CollSeq *pColl; /* Collating sequence */
1346813486
int isError; /* Error code returned by the function. */
1346913487
int skipFlag; /* Skip skip accumulator loading if true */
13470
- int iOp; /* Instruction number of OP_Function */
13471
- Vdbe *pVdbe; /* The VM that owns this context */
1347213488
};
1347313489
1347413490
/*
1347513491
** An Explain object accumulates indented output which is helpful
1347613492
** in describing recursive data structures.
@@ -13565,11 +13581,10 @@
1356513581
int nFrame; /* Number of frames in pFrame list */
1356613582
u32 expmask; /* Binding to these vars invalidates VM */
1356713583
SubProgram *pProgram; /* Linked list of all sub-programs used by VM */
1356813584
int nOnceFlag; /* Size of array aOnceFlag[] */
1356913585
u8 *aOnceFlag; /* Flags for OP_Once */
13570
- AuxData *pAuxData; /* Linked list of auxdata allocations */
1357113586
};
1357213587
1357313588
/*
1357413589
** The following are allowed values for Vdbe.magic
1357513590
*/
@@ -13589,11 +13604,11 @@
1358913604
#endif
1359013605
SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
1359113606
SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int);
1359213607
SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int);
1359313608
SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
13594
-SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe*, int, int);
13609
+SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc*, int);
1359513610
1359613611
int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
1359713612
SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*);
1359813613
SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *);
1359913614
SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
@@ -28361,27 +28376,22 @@
2836128376
*/
2836228377
static const char *unixTempFileDir(void){
2836328378
static const char *azDirs[] = {
2836428379
0,
2836528380
0,
28366
- 0,
28367
- 0,
2836828381
"/var/tmp",
2836928382
"/usr/tmp",
2837028383
"/tmp",
28371
- "."
28384
+ 0 /* List terminator */
2837228385
};
2837328386
unsigned int i;
2837428387
struct stat buf;
28375
- const char *zDir;
28388
+ const char *zDir = 0;
2837628389
2837728390
azDirs[0] = sqlite3_temp_directory;
2837828391
if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR");
28379
- if( !azDirs[2] ) azDirs[2] = getenv("TMP");
28380
- if( !azDirs[3] ) azDirs[3] = getenv("TEMP");
28381
- for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
28382
- zDir = azDirs[i];
28392
+ for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){
2838328393
if( zDir==0 ) continue;
2838428394
if( osStat(zDir, &buf) ) continue;
2838528395
if( !S_ISDIR(buf.st_mode) ) continue;
2838628396
if( osAccess(zDir, 07) ) continue;
2838728397
break;
@@ -28407,10 +28417,11 @@
2840728417
** function failing.
2840828418
*/
2840928419
SimulateIOError( return SQLITE_IOERR );
2841028420
2841128421
zDir = unixTempFileDir();
28422
+ if( zDir==0 ) zDir = ".";
2841228423
2841328424
/* Check that the output buffer is large enough for the temporary file
2841428425
** name. If it is not, return SQLITE_ERROR.
2841528426
*/
2841628427
if( (strlen(zDir) + strlen(SQLITE_TEMP_FILE_PREFIX) + 18) >= (size_t)nBuf ){
@@ -30488,11 +30499,10 @@
3048830499
*/
3048930500
#if SQLITE_OS_WIN /* This file is used for Windows only */
3049030501
3049130502
#ifdef __CYGWIN__
3049230503
# include <sys/cygwin.h>
30493
-/* # include <errno.h> */
3049430504
#endif
3049530505
3049630506
/*
3049730507
** Include code that is common to all os_*.c files
3049830508
*/
@@ -30717,11 +30727,11 @@
3071730727
3071830728
/*
3071930729
** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions
3072030730
** based on the sub-platform)?
3072130731
*/
30722
-#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
30732
+#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)
3072330733
# define SQLITE_WIN32_HAS_ANSI
3072430734
#endif
3072530735
3072630736
/*
3072730737
** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions
@@ -30909,11 +30919,10 @@
3090930919
* zero for the default behavior.
3091030920
*/
3091130921
#ifndef SQLITE_WIN32_HEAP_FLAGS
3091230922
# define SQLITE_WIN32_HEAP_FLAGS (0)
3091330923
#endif
30914
-
3091530924
3091630925
/*
3091730926
** The winMemData structure stores information required by the Win32-specific
3091830927
** sqlite3_mem_methods implementation.
3091930928
*/
@@ -34375,14 +34384,14 @@
3437534384
OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
3437634385
osGetCurrentProcessId(), pFd));
3437734386
return SQLITE_OK;
3437834387
}
3437934388
assert( (nMap % winSysInfo.dwPageSize)==0 );
34380
- assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
3438134389
#if SQLITE_OS_WINRT
34382
- pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap);
34390
+ pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, nMap);
3438334391
#else
34392
+ assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
3438434393
pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
3438534394
#endif
3438634395
if( pNew==NULL ){
3438734396
osCloseHandle(pFd->hMap);
3438834397
pFd->hMap = NULL;
@@ -34549,19 +34558,10 @@
3454934558
return zConverted;
3455034559
}
3455134560
3455234561
static int winIsDir(const void *zConverted);
3455334562
34554
-/*
34555
-** Maximum pathname length (in bytes) for windows. The MAX_PATH macro is
34556
-** in characters, so we allocate 3 bytes per character assuming worst-case
34557
-** 3-bytes-per-character UTF8.
34558
-*/
34559
-#ifndef SQLITE_WIN32_MAX_PATH
34560
-# define SQLITE_WIN32_MAX_PATH (MAX_PATH*3)
34561
-#endif
34562
-
3456334563
/*
3456434564
** Create a temporary file name in zBuf. zBuf must be big enough to
3456534565
** hold at pVfs->mxPathname characters.
3456634566
*/
3456734567
static int getTempname(int nBuf, char *zBuf){
@@ -34569,21 +34569,22 @@
3456934569
"abcdefghijklmnopqrstuvwxyz"
3457034570
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3457134571
"0123456789";
3457234572
size_t i, j;
3457334573
int nTempPath;
34574
- char zTempPath[SQLITE_WIN32_MAX_PATH+2];
34574
+ char zTempPath[MAX_PATH+2];
3457534575
3457634576
/* It's odd to simulate an io-error here, but really this is just
3457734577
** using the io-error infrastructure to test that SQLite handles this
3457834578
** function failing.
3457934579
*/
3458034580
SimulateIOError( return SQLITE_IOERR );
3458134581
34582
+ memset(zTempPath, 0, MAX_PATH+2);
34583
+
3458234584
if( sqlite3_temp_directory ){
34583
- sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s",
34584
- sqlite3_temp_directory);
34585
+ sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
3458534586
}
3458634587
#if defined(__CYGWIN__)
3458734588
else{
3458834589
static const char *azDirs[] = {
3458934590
0,
@@ -34626,58 +34627,36 @@
3462634627
}
3462734628
#elif !SQLITE_OS_WINRT
3462834629
else if( isNT() ){
3462934630
char *zMulti;
3463034631
WCHAR zWidePath[MAX_PATH];
34631
- if( osGetTempPathW(MAX_PATH-30, zWidePath)==0 ){
34632
- OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34633
- return SQLITE_IOERR_GETTEMPPATH;
34634
- }
34632
+ osGetTempPathW(MAX_PATH-30, zWidePath);
3463534633
zMulti = unicodeToUtf8(zWidePath);
3463634634
if( zMulti ){
34637
- sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zMulti);
34635
+ sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti);
3463834636
sqlite3_free(zMulti);
3463934637
}else{
3464034638
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
3464134639
return SQLITE_IOERR_NOMEM;
3464234640
}
3464334641
}
3464434642
#ifdef SQLITE_WIN32_HAS_ANSI
3464534643
else{
3464634644
char *zUtf8;
34647
- char zMbcsPath[SQLITE_WIN32_MAX_PATH];
34648
- if( osGetTempPathA(SQLITE_WIN32_MAX_PATH-30, zMbcsPath)==0 ){
34649
- OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34650
- return SQLITE_IOERR_GETTEMPPATH;
34651
- }
34645
+ char zMbcsPath[MAX_PATH];
34646
+ osGetTempPathA(MAX_PATH-30, zMbcsPath);
3465234647
zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
3465334648
if( zUtf8 ){
34654
- sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zUtf8);
34649
+ sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8);
3465534650
sqlite3_free(zUtf8);
3465634651
}else{
3465734652
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
3465834653
return SQLITE_IOERR_NOMEM;
3465934654
}
3466034655
}
34661
-#else
34662
- else{
34663
- /*
34664
- ** Compiled without ANSI support and the current operating system
34665
- ** is not Windows NT; therefore, just zero the temporary buffer.
34666
- */
34667
- memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34668
- }
34669
-#endif /* SQLITE_WIN32_HAS_ANSI */
34670
-#else
34671
- else{
34672
- /*
34673
- ** Compiled for WinRT and the sqlite3_temp_directory is not set;
34674
- ** therefore, just zero the temporary buffer.
34675
- */
34676
- memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34677
- }
34678
-#endif /* !SQLITE_OS_WINRT */
34656
+#endif
34657
+#endif
3467934658
3468034659
/* Check that the output buffer is large enough for the temporary file
3468134660
** name. If it is not, return SQLITE_ERROR.
3468234661
*/
3468334662
nTempPath = sqlite3Strlen30(zTempPath);
@@ -34759,11 +34738,11 @@
3475934738
int cnt = 0;
3476034739
3476134740
/* If argument zPath is a NULL pointer, this function is required to open
3476234741
** a temporary file. Use this buffer to store the file name in.
3476334742
*/
34764
- char zTmpname[SQLITE_WIN32_MAX_PATH+2]; /* Buffer used to create temp filename */
34743
+ char zTmpname[MAX_PATH+2]; /* Buffer used to create temp filename */
3476534744
3476634745
int rc = SQLITE_OK; /* Function Return Code */
3476734746
#if !defined(NDEBUG) || SQLITE_OS_WINCE
3476834747
int eType = flags&0xFFFFFF00; /* Type of file to open */
3476934748
#endif
@@ -34825,11 +34804,12 @@
3482534804
/* If the second argument to this function is NULL, generate a
3482634805
** temporary file name to use
3482734806
*/
3482834807
if( !zUtf8Name ){
3482934808
assert(isDelete && !isOpenJournal);
34830
- rc = getTempname(SQLITE_WIN32_MAX_PATH+2, zTmpname);
34809
+ memset(zTmpname, 0, MAX_PATH+2);
34810
+ rc = getTempname(MAX_PATH+2, zTmpname);
3483134811
if( rc!=SQLITE_OK ){
3483234812
OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
3483334813
return rc;
3483434814
}
3483534815
zUtf8Name = zTmpname;
@@ -35256,34 +35236,27 @@
3525635236
){
3525735237
3525835238
#if defined(__CYGWIN__)
3525935239
SimulateIOError( return SQLITE_ERROR );
3526035240
UNUSED_PARAMETER(nFull);
35261
- assert( pVfs->mxPathname>=SQLITE_WIN32_MAX_PATH );
35241
+ assert( pVfs->mxPathname>=MAX_PATH );
3526235242
assert( nFull>=pVfs->mxPathname );
3526335243
if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
3526435244
/*
3526535245
** NOTE: We are dealing with a relative path name and the data
3526635246
** directory has been set. Therefore, use it as the basis
3526735247
** for converting the relative path name to an absolute
3526835248
** one by prepending the data directory and a slash.
3526935249
*/
35270
- char zOut[SQLITE_WIN32_MAX_PATH+1];
35271
- if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35272
- SQLITE_WIN32_MAX_PATH+1)<0 ){
35273
- winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35274
- zRelative);
35275
- return SQLITE_CANTOPEN_FULLPATH;
35276
- }
35250
+ char zOut[MAX_PATH+1];
35251
+ memset(zOut, 0, MAX_PATH+1);
35252
+ cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35253
+ MAX_PATH+1);
3527735254
sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
3527835255
sqlite3_data_directory, zOut);
3527935256
}else{
35280
- if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){
35281
- winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35282
- zRelative);
35283
- return SQLITE_CANTOPEN_FULLPATH;
35284
- }
35257
+ cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull);
3528535258
}
3528635259
return SQLITE_OK;
3528735260
#endif
3528835261
3528935262
#if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
@@ -35621,11 +35594,11 @@
3562135594
*/
3562235595
SQLITE_API int sqlite3_os_init(void){
3562335596
static sqlite3_vfs winVfs = {
3562435597
3, /* iVersion */
3562535598
sizeof(winFile), /* szOsFile */
35626
- SQLITE_WIN32_MAX_PATH, /* mxPathname */
35599
+ MAX_PATH, /* mxPathname */
3562735600
0, /* pNext */
3562835601
"win32", /* zName */
3562935602
0, /* pAppData */
3563035603
winOpen, /* xOpen */
3563135604
winDelete, /* xDelete */
@@ -60607,10 +60580,17 @@
6060760580
break;
6060860581
}
6060960582
case P4_MPRINTF: {
6061060583
if( db->pnBytesFreed==0 ) sqlite3_free(p4);
6061160584
break;
60585
+ }
60586
+ case P4_VDBEFUNC: {
60587
+ VdbeFunc *pVdbeFunc = (VdbeFunc *)p4;
60588
+ freeEphemeralFunction(db, pVdbeFunc->pFunc);
60589
+ if( db->pnBytesFreed==0 ) sqlite3VdbeDeleteAuxData(pVdbeFunc, 0);
60590
+ sqlite3DbFree(db, pVdbeFunc);
60591
+ break;
6061260592
}
6061360593
case P4_FUNCDEF: {
6061460594
freeEphemeralFunction(db, (FuncDef*)p4);
6061560595
break;
6061660596
}
@@ -61637,14 +61617,10 @@
6163761617
while( p->pDelFrame ){
6163861618
VdbeFrame *pDel = p->pDelFrame;
6163961619
p->pDelFrame = pDel->pParent;
6164061620
sqlite3VdbeFrameDelete(pDel);
6164161621
}
61642
-
61643
- /* Delete any auxdata allocations made by the VM */
61644
- sqlite3VdbeDeleteAuxData(p, -1, 0);
61645
- assert( p->pAuxData==0 );
6164661622
}
6164761623
6164861624
/*
6164961625
** Clean up the VM after execution.
6165061626
**
@@ -62439,39 +62415,24 @@
6243962415
sqlite3VdbeDelete(p);
6244062416
return rc;
6244162417
}
6244262418
6244362419
/*
62444
-** If parameter iOp is less than zero, then invoke the destructor for
62445
-** all auxiliary data pointers currently cached by the VM passed as
62446
-** the first argument.
62447
-**
62448
-** Or, if iOp is greater than or equal to zero, then the destructor is
62449
-** only invoked for those auxiliary data pointers created by the user
62450
-** function invoked by the OP_Function opcode at instruction iOp of
62451
-** VM pVdbe, and only then if:
62452
-**
62453
-** * the associated function parameter is the 32nd or later (counting
62454
-** from left to right), or
62455
-**
62456
-** * the corresponding bit in argument mask is clear (where the first
62457
-** function parameter corrsponds to bit 0 etc.).
62420
+** Call the destructor for each auxdata entry in pVdbeFunc for which
62421
+** the corresponding bit in mask is clear. Auxdata entries beyond 31
62422
+** are always destroyed. To destroy all auxdata entries, call this
62423
+** routine with mask==0.
6245862424
*/
62459
-SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){
62460
- AuxData **pp = &pVdbe->pAuxData;
62461
- while( *pp ){
62462
- AuxData *pAux = *pp;
62463
- if( (iOp<0)
62464
- || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & ((u32)1<<pAux->iArg))))
62465
- ){
62425
+SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc *pVdbeFunc, int mask){
62426
+ int i;
62427
+ for(i=0; i<pVdbeFunc->nAux; i++){
62428
+ struct AuxData *pAux = &pVdbeFunc->apAux[i];
62429
+ if( (i>31 || !(mask&(((u32)1)<<i))) && pAux->pAux ){
6246662430
if( pAux->xDelete ){
6246762431
pAux->xDelete(pAux->pAux);
6246862432
}
62469
- *pp = pAux->pNext;
62470
- sqlite3DbFree(pVdbe->db, pAux);
62471
- }else{
62472
- pp= &pAux->pNext;
62433
+ pAux->pAux = 0;
6247362434
}
6247462435
}
6247562436
}
6247662437
6247762438
/*
@@ -63866,18 +63827,18 @@
6386663827
/*
6386763828
** Return the auxilary data pointer, if any, for the iArg'th argument to
6386863829
** the user-function defined by pCtx.
6386963830
*/
6387063831
SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
63871
- AuxData *pAuxData;
63832
+ VdbeFunc *pVdbeFunc;
6387263833
6387363834
assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63874
- for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
63875
- if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
63835
+ pVdbeFunc = pCtx->pVdbeFunc;
63836
+ if( !pVdbeFunc || iArg>=pVdbeFunc->nAux || iArg<0 ){
63837
+ return 0;
6387663838
}
63877
-
63878
- return (pAuxData ? pAuxData->pAux : 0);
63839
+ return pVdbeFunc->apAux[iArg].pAux;
6387963840
}
6388063841
6388163842
/*
6388263843
** Set the auxilary data pointer and delete function, for the iArg'th
6388363844
** argument to the user-function defined by pCtx. Any previous value is
@@ -63887,30 +63848,33 @@
6388763848
sqlite3_context *pCtx,
6388863849
int iArg,
6388963850
void *pAux,
6389063851
void (*xDelete)(void*)
6389163852
){
63892
- AuxData *pAuxData;
63893
- Vdbe *pVdbe = pCtx->pVdbe;
63894
-
63895
- assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63853
+ struct AuxData *pAuxData;
63854
+ VdbeFunc *pVdbeFunc;
6389663855
if( iArg<0 ) goto failed;
6389763856
63898
- for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
63899
- if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
63900
- }
63901
- if( pAuxData==0 ){
63902
- pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData));
63903
- if( !pAuxData ) goto failed;
63904
- pAuxData->iOp = pCtx->iOp;
63905
- pAuxData->iArg = iArg;
63906
- pAuxData->pNext = pVdbe->pAuxData;
63907
- pVdbe->pAuxData = pAuxData;
63908
- }else if( pAuxData->xDelete ){
63857
+ assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63858
+ pVdbeFunc = pCtx->pVdbeFunc;
63859
+ if( !pVdbeFunc || pVdbeFunc->nAux<=iArg ){
63860
+ int nAux = (pVdbeFunc ? pVdbeFunc->nAux : 0);
63861
+ int nMalloc = sizeof(VdbeFunc) + sizeof(struct AuxData)*iArg;
63862
+ pVdbeFunc = sqlite3DbRealloc(pCtx->s.db, pVdbeFunc, nMalloc);
63863
+ if( !pVdbeFunc ){
63864
+ goto failed;
63865
+ }
63866
+ pCtx->pVdbeFunc = pVdbeFunc;
63867
+ memset(&pVdbeFunc->apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux));
63868
+ pVdbeFunc->nAux = iArg+1;
63869
+ pVdbeFunc->pFunc = pCtx->pFunc;
63870
+ }
63871
+
63872
+ pAuxData = &pVdbeFunc->apAux[iArg];
63873
+ if( pAuxData->pAux && pAuxData->xDelete ){
6390963874
pAuxData->xDelete(pAuxData->pAux);
6391063875
}
63911
-
6391263876
pAuxData->pAux = pAux;
6391363877
pAuxData->xDelete = xDelete;
6391463878
return;
6391563879
6391663880
failed:
@@ -65518,11 +65482,11 @@
6551865482
u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
6551965483
u8 encoding = ENC(db); /* The database encoding */
6552065484
int iCompare = 0; /* Result of last OP_Compare operation */
6552165485
unsigned nVmStep = 0; /* Number of virtual machine steps */
6552265486
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65523
- unsigned nProgressLimit; /* Invoke xProgress() when nVmStep reaches this */
65487
+ unsigned nProgressOps = 0; /* nVmStep at last progress callback. */
6552465488
#endif
6552565489
Mem *aMem = p->aMem; /* Copy of p->aMem */
6552665490
Mem *pIn1 = 0; /* 1st input operand */
6552765491
Mem *pIn2 = 0; /* 2nd input operand */
6552865492
Mem *pIn3 = 0; /* 3rd input operand */
@@ -65977,21 +65941,10 @@
6597765941
assert( p->explain==0 );
6597865942
p->pResultSet = 0;
6597965943
db->busyHandler.nBusy = 0;
6598065944
CHECK_FOR_INTERRUPT;
6598165945
sqlite3VdbeIOTraceSql(p);
65982
-#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65983
- if( db->xProgress ){
65984
- assert( 0 < db->nProgressOps );
65985
- nProgressLimit = (unsigned)p->aCounter[SQLITE_STMTSTATUS_VM_STEP-1];
65986
- if( nProgressLimit==0 ){
65987
- nProgressLimit = db->nProgressOps;
65988
- }else{
65989
- nProgressLimit %= (unsigned)db->nProgressOps;
65990
- }
65991
- }
65992
-#endif
6599365946
#ifdef SQLITE_DEBUG
6599465947
sqlite3BeginBenignMalloc();
6599565948
if( p->pc==0 && (p->db->flags & SQLITE_VdbeListing)!=0 ){
6599665949
int i;
6599765950
printf("VDBE Program Listing:\n");
@@ -66148,20 +66101,18 @@
6614866101
** of VDBE ops have been executed (either since this invocation of
6614966102
** sqlite3VdbeExec() or since last time the progress callback was called).
6615066103
** If the progress callback returns non-zero, exit the virtual machine with
6615166104
** a return code SQLITE_ABORT.
6615266105
*/
66153
- if( db->xProgress!=0 && nVmStep>=nProgressLimit ){
66106
+ if( db->xProgress!=0 && (nVmStep - nProgressOps)>=db->nProgressOps ){
6615466107
int prc;
6615566108
prc = db->xProgress(db->pProgressArg);
6615666109
if( prc!=0 ){
6615766110
rc = SQLITE_INTERRUPT;
6615866111
goto vdbe_error_halt;
6615966112
}
66160
- if( db->xProgress!=0 ){
66161
- nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);
66162
- }
66113
+ nProgressOps = nVmStep;
6616366114
}
6616466115
#endif
6616566116
6616666117
break;
6616766118
}
@@ -66843,18 +66794,23 @@
6684366794
Deephemeralize(u.ai.pArg);
6684466795
sqlite3VdbeMemStoreType(u.ai.pArg);
6684566796
REGISTER_TRACE(pOp->p2+u.ai.i, u.ai.pArg);
6684666797
}
6684766798
66848
- assert( pOp->p4type==P4_FUNCDEF );
66849
- u.ai.ctx.pFunc = pOp->p4.pFunc;
66799
+ assert( pOp->p4type==P4_FUNCDEF || pOp->p4type==P4_VDBEFUNC );
66800
+ if( pOp->p4type==P4_FUNCDEF ){
66801
+ u.ai.ctx.pFunc = pOp->p4.pFunc;
66802
+ u.ai.ctx.pVdbeFunc = 0;
66803
+ }else{
66804
+ u.ai.ctx.pVdbeFunc = (VdbeFunc*)pOp->p4.pVdbeFunc;
66805
+ u.ai.ctx.pFunc = u.ai.ctx.pVdbeFunc->pFunc;
66806
+ }
66807
+
6685066808
u.ai.ctx.s.flags = MEM_Null;
6685166809
u.ai.ctx.s.db = db;
6685266810
u.ai.ctx.s.xDel = 0;
6685366811
u.ai.ctx.s.zMalloc = 0;
66854
- u.ai.ctx.iOp = pc;
66855
- u.ai.ctx.pVdbe = p;
6685666812
6685766813
/* The output cell may already have a buffer allocated. Move
6685866814
** the pointer to u.ai.ctx.s so in case the user-function can use
6685966815
** the already allocated buffer instead of allocating a new one.
6686066816
*/
@@ -66873,11 +66829,15 @@
6687366829
lastRowid = db->lastRowid;
6687466830
6687566831
/* If any auxiliary data functions have been called by this user function,
6687666832
** immediately call the destructor for any non-static values.
6687766833
*/
66878
- sqlite3VdbeDeleteAuxData(p, pc, pOp->p1);
66834
+ if( u.ai.ctx.pVdbeFunc ){
66835
+ sqlite3VdbeDeleteAuxData(u.ai.ctx.pVdbeFunc, pOp->p1);
66836
+ pOp->p4.pVdbeFunc = u.ai.ctx.pVdbeFunc;
66837
+ pOp->p4type = P4_VDBEFUNC;
66838
+ }
6687966839
6688066840
if( db->mallocFailed ){
6688166841
/* Even though a malloc() has failed, the implementation of the
6688266842
** user function may have called an sqlite3_result_XXX() function
6688366843
** to return a value. The following call releases any resources
@@ -107790,11 +107750,10 @@
107790107750
WhereLevel *pLevel; /* The where level to be coded */
107791107751
WhereLoop *pLoop; /* The WhereLoop object being coded */
107792107752
WhereClause *pWC; /* Decomposition of the entire WHERE clause */
107793107753
WhereTerm *pTerm; /* A WHERE clause term */
107794107754
Parse *pParse; /* Parsing context */
107795
- sqlite3 *db; /* Database connection */
107796107755
Vdbe *v; /* The prepared stmt under constructions */
107797107756
struct SrcList_item *pTabItem; /* FROM clause term being coded */
107798107757
int addrBrk; /* Jump here to break out of the loop */
107799107758
int addrCont; /* Jump here to continue with next cycle */
107800107759
int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
@@ -107802,11 +107761,10 @@
107802107761
Bitmask newNotReady; /* Return value */
107803107762
107804107763
pParse = pWInfo->pParse;
107805107764
v = pParse->pVdbe;
107806107765
pWC = &pWInfo->sWC;
107807
- db = pParse->db;
107808107766
pLevel = &pWInfo->a[iLevel];
107809107767
pLoop = pLevel->pWLoop;
107810107768
pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
107811107769
iCur = pTabItem->iCursor;
107812107770
bRev = (pWInfo->revMask>>iLevel)&1;
@@ -108093,11 +108051,11 @@
108093108051
/* Generate code to evaluate all constraint terms using == or IN
108094108052
** and store the values of those terms in an array of registers
108095108053
** starting at regBase.
108096108054
*/
108097108055
regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
108098
- zEndAff = sqlite3DbStrDup(db, zStartAff);
108056
+ zEndAff = sqlite3DbStrDup(pParse->db, zStartAff);
108099108057
addrNxt = pLevel->addrNxt;
108100108058
108101108059
/* If we are doing a reverse order scan on an ascending index, or
108102108060
** a forward order scan on a descending index, interchange the
108103108061
** start and end terms (pRangeStart and pRangeEnd).
@@ -108178,12 +108136,12 @@
108178108136
}
108179108137
codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
108180108138
nConstraint++;
108181108139
testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108182108140
}
108183
- sqlite3DbFree(db, zStartAff);
108184
- sqlite3DbFree(db, zEndAff);
108141
+ sqlite3DbFree(pParse->db, zStartAff);
108142
+ sqlite3DbFree(pParse->db, zEndAff);
108185108143
108186108144
/* Top of the loop body */
108187108145
pLevel->p2 = sqlite3VdbeCurrentAddr(v);
108188108146
108189108147
/* Check if the index cursor is past the end of the range. */
@@ -108306,11 +108264,11 @@
108306108264
*/
108307108265
if( pWInfo->nLevel>1 ){
108308108266
int nNotReady; /* The number of notReady tables */
108309108267
struct SrcList_item *origSrc; /* Original list of tables */
108310108268
nNotReady = pWInfo->nLevel - iLevel - 1;
108311
- pOrTab = sqlite3StackAllocRaw(db,
108269
+ pOrTab = sqlite3StackAllocRaw(pParse->db,
108312108270
sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
108313108271
if( pOrTab==0 ) return notReady;
108314108272
pOrTab->nAlloc = (u8)(nNotReady + 1);
108315108273
pOrTab->nSrc = pOrTab->nAlloc;
108316108274
memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
@@ -108360,12 +108318,12 @@
108360108318
Expr *pExpr = pWC->a[iTerm].pExpr;
108361108319
if( &pWC->a[iTerm] == pTerm ) continue;
108362108320
if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
108363108321
if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue;
108364108322
if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
108365
- pExpr = sqlite3ExprDup(db, pExpr, 0);
108366
- pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);
108323
+ pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
108324
+ pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr);
108367108325
}
108368108326
if( pAndExpr ){
108369108327
pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
108370108328
}
108371108329
}
@@ -108381,11 +108339,11 @@
108381108339
}
108382108340
/* Loop through table entries that match term pOrTerm. */
108383108341
pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
108384108342
WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
108385108343
WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
108386
- assert( pSubWInfo || pParse->nErr || db->mallocFailed );
108344
+ assert( pSubWInfo || pParse->nErr || pParse->db->mallocFailed );
108387108345
if( pSubWInfo ){
108388108346
WhereLoop *pSubLoop;
108389108347
explainOneScan(
108390108348
pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
108391108349
);
@@ -108436,17 +108394,17 @@
108436108394
}
108437108395
pLevel->u.pCovidx = pCov;
108438108396
if( pCov ) pLevel->iIdxCur = iCovCur;
108439108397
if( pAndExpr ){
108440108398
pAndExpr->pLeft = 0;
108441
- sqlite3ExprDelete(db, pAndExpr);
108399
+ sqlite3ExprDelete(pParse->db, pAndExpr);
108442108400
}
108443108401
sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
108444108402
sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
108445108403
sqlite3VdbeResolveLabel(v, iLoopBody);
108446108404
108447
- if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab);
108405
+ if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab);
108448108406
if( !untestedTerms ) disableTerm(pLevel, pTerm);
108449108407
}else
108450108408
#endif /* SQLITE_OMIT_OR_OPTIMIZATION */
108451108409
108452108410
{
@@ -108497,12 +108455,13 @@
108497108455
** and we are coding the t1 loop and the t2 loop has not yet coded,
108498108456
** then we cannot use the "t1.a=t2.b" constraint, but we can code
108499108457
** the implied "t1.a=123" constraint.
108500108458
*/
108501108459
for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108502
- Expr *pE, *pEAlt;
108460
+ Expr *pE;
108503108461
WhereTerm *pAlt;
108462
+ Expr sEq;
108504108463
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108505108464
if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108506108465
if( pTerm->leftCursor!=iCur ) continue;
108507108466
if( pLevel->iLeftJoin ) continue;
108508108467
pE = pTerm->pExpr;
@@ -108512,17 +108471,13 @@
108512108471
if( pAlt==0 ) continue;
108513108472
if( pAlt->wtFlags & (TERM_CODED) ) continue;
108514108473
testcase( pAlt->eOperator & WO_EQ );
108515108474
testcase( pAlt->eOperator & WO_IN );
108516108475
VdbeNoopComment((v, "begin transitive constraint"));
108517
- pEAlt = sqlite3StackAllocRaw(db, sizeof(*pEAlt));
108518
- if( pEAlt ){
108519
- *pEAlt = *pAlt->pExpr;
108520
- pEAlt->pLeft = pE->pLeft;
108521
- sqlite3ExprIfFalse(pParse, pEAlt, addrCont, SQLITE_JUMPIFNULL);
108522
- sqlite3StackFree(db, pEAlt);
108523
- }
108476
+ sEq = *pAlt->pExpr;
108477
+ sEq.pLeft = pE->pLeft;
108478
+ sqlite3ExprIfFalse(pParse, &sEq, addrCont, SQLITE_JUMPIFNULL);
108524108479
}
108525108480
108526108481
/* For a LEFT OUTER JOIN, generate code that will record the fact that
108527108482
** at least one row of the right table has matched the left table.
108528108483
*/
@@ -116461,11 +116416,10 @@
116461116416
case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break;
116462116417
case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
116463116418
case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
116464116419
case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
116465116420
case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
116466
- case SQLITE_IOERR_GETTEMPPATH: zName = "SQLITE_IOERR_GETTEMPPATH"; break;
116467116421
case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
116468116422
case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
116469116423
case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
116470116424
case SQLITE_FULL: zName = "SQLITE_FULL"; break;
116471116425
case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
@@ -117817,11 +117771,11 @@
117817117771
db->autoCommit = 1;
117818117772
db->nextAutovac = -1;
117819117773
db->szMmap = sqlite3GlobalConfig.szMmap;
117820117774
db->nextPagesize = 0;
117821117775
db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger
117822
-#if !defined(SQLITE_DEFAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
117776
+#if !defined(SQLITE_DEAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
117823117777
| SQLITE_AutoIndex
117824117778
#endif
117825117779
#if SQLITE_DEFAULT_FILE_FORMAT<4
117826117780
| SQLITE_LegacyFileFmt
117827117781
#endif
@@ -128290,11 +128244,11 @@
128290128244
}
128291128245
128292128246
128293128247
#ifdef SQLITE_TEST
128294128248
128295
-#include <tcl.h>
128249
+/* #include <tcl.h> */
128296128250
/* #include <string.h> */
128297128251
128298128252
/*
128299128253
** Implementation of a special SQL scalar function for testing tokenizers
128300128254
** designed to be used in concert with the Tcl testing framework. This
128301128255
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -398,10 +398,13 @@
398 **
399 ** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
400 ** assert() macro is enabled, each call into the Win32 native heap subsystem
401 ** will cause HeapValidate to be called. If heap validation should fail, an
402 ** assertion will be triggered.
 
 
 
403 **
404 ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
405 ** the default.
406 */
407 #if defined(SQLITE_SYSTEM_MALLOC) \
@@ -436,17 +439,24 @@
436 */
437 #if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
438 # define _XOPEN_SOURCE 600
439 #endif
440
 
 
 
 
 
 
 
441 /*
442 ** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
443 ** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
444 ** make it true by defining or undefining NDEBUG.
445 **
446 ** Setting NDEBUG makes the code smaller and faster by disabling the
447 ** assert() statements in the code. So we want the default action
448 ** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
449 ** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
450 ** feature.
451 */
452 #if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -512,11 +522,11 @@
512 ** hint of unplanned behavior.
513 **
514 ** In other words, ALWAYS and NEVER are added for defensive code.
515 **
516 ** When doing coverage testing ALWAYS and NEVER are hard-coded to
517 ** be true and false so that the unreachable code they specify will
518 ** not be counted as untested code.
519 */
520 #if defined(SQLITE_COVERAGE_TEST)
521 # define ALWAYS(X) (1)
522 # define NEVER(X) (0)
@@ -536,16 +546,20 @@
536 #define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
537
538 /*
539 ** The macro unlikely() is a hint that surrounds a boolean
540 ** expression that is usually false. Macro likely() surrounds
541 ** a boolean expression that is usually true. These hints could,
542 ** in theory, be used by the compiler to generate better code, but
543 ** currently they are just comments for human readers.
544 */
545 #define likely(X) (X)
546 #define unlikely(X) (X)
 
 
 
 
 
547
548 /************** Include sqlite3.h in the middle of sqliteInt.h ***************/
549 /************** Begin file sqlite3.h *****************************************/
550 /*
551 ** 2001 September 15
@@ -656,11 +670,11 @@
656 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
657 ** [sqlite_version()] and [sqlite_source_id()].
658 */
659 #define SQLITE_VERSION "3.8.0"
660 #define SQLITE_VERSION_NUMBER 3008000
661 #define SQLITE_SOURCE_ID "2013-07-31 23:28:36 136fc2931b156f91cdd76a7a009298cdf09d826a"
662
663 /*
664 ** CAPI3REF: Run-Time Library Version Numbers
665 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
666 **
@@ -1025,11 +1039,10 @@
1025 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
1026 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
1027 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
1028 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
1029 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
1030 #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
1031 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
1032 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
1033 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
1034 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
1035 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -3109,12 +3122,11 @@
3109 ** interface is to keep a GUI updated during a large query.
3110 **
3111 ** ^The parameter P is passed through as the only parameter to the
3112 ** callback function X. ^The parameter N is the approximate number of
3113 ** [virtual machine instructions] that are evaluated between successive
3114 ** invocations of the callback X. ^If N is less than one then the progress
3115 ** handler is disabled.
3116 **
3117 ** ^Only a single progress handler may be defined at one time per
3118 ** [database connection]; setting a new progress handler cancels the
3119 ** old one. ^Setting parameter X to NULL disables the progress handler.
3120 ** ^The progress handler is also disabled by setting N to a value less
@@ -4730,49 +4742,50 @@
4730 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4731
4732 /*
4733 ** CAPI3REF: Function Auxiliary Data
4734 **
4735 ** These functions may be used by (non-aggregate) SQL functions to
4736 ** associate metadata with argument values. If the same value is passed to
4737 ** multiple invocations of the same SQL function during query execution, under
4738 ** some circumstances the associated metadata may be preserved. An example
4739 ** of where this might be useful is in a regular-expression matching
4740 ** function. The compiled version of the regular expression can be stored as
4741 ** metadata associated with the pattern string.
4742 ** Then as long as the pattern string remains the same,
4743 ** the compiled regular expression can be reused on multiple
4744 ** invocations of the same function.
4745 **
4746 ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
4747 ** associated by the sqlite3_set_auxdata() function with the Nth argument
4748 ** value to the application-defined function. ^If there is no metadata
4749 ** associated with the function argument, this sqlite3_get_auxdata() interface
4750 ** returns a NULL pointer.
 
4751 **
4752 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
4753 ** argument of the application-defined function. ^Subsequent
4754 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
4755 ** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or
4756 ** NULL if the metadata has been discarded.
4757 ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
4758 ** SQLite will invoke the destructor function X with parameter P exactly
4759 ** once, when the metadata is discarded.
4760 ** SQLite is free to discard the metadata at any time, including: <ul>
4761 ** <li> when the corresponding function parameter changes, or
4762 ** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4763 ** SQL statement, or
4764 ** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or
4765 ** <li> during the original sqlite3_set_auxdata() call when a memory
4766 ** allocation error occurs. </ul>)^
4767 **
4768 ** Note the last bullet in particular. The destructor X in
4769 ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
4770 ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
 
 
 
4771 ** should be called near the end of the function implementation and the
4772 ** function implementation should not make any use of P after
4773 ** sqlite3_set_auxdata() has been called.
4774 **
4775 ** ^(In practice, metadata is preserved between function calls for
4776 ** function parameters that are compile-time constants, including literal
4777 ** values and [parameters] and expressions composed from the same.)^
4778 **
@@ -8811,10 +8824,11 @@
8811
8812 /*
8813 ** The names of the following types declared in vdbeInt.h are required
8814 ** for the VdbeOp definition.
8815 */
 
8816 typedef struct Mem Mem;
8817 typedef struct SubProgram SubProgram;
8818
8819 /*
8820 ** A single instruction of the virtual machine has an opcode
@@ -8834,10 +8848,11 @@
8834 void *p; /* Generic pointer */
8835 char *z; /* Pointer to data for string (char array) types */
8836 i64 *pI64; /* Used when p4type is P4_INT64 */
8837 double *pReal; /* Used when p4type is P4_REAL */
8838 FuncDef *pFunc; /* Used when p4type is P4_FUNCDEF */
 
8839 CollSeq *pColl; /* Used when p4type is P4_COLLSEQ */
8840 Mem *pMem; /* Used when p4type is P4_MEM */
8841 VTable *pVtab; /* Used when p4type is P4_VTAB */
8842 KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */
8843 int *ai; /* Used when p4type is P4_INTARRAY */
@@ -8887,10 +8902,11 @@
8887 #define P4_DYNAMIC (-1) /* Pointer to a string obtained from sqliteMalloc() */
8888 #define P4_STATIC (-2) /* Pointer to a static string */
8889 #define P4_COLLSEQ (-4) /* P4 is a pointer to a CollSeq structure */
8890 #define P4_FUNCDEF (-5) /* P4 is a pointer to a FuncDef structure */
8891 #define P4_KEYINFO (-6) /* P4 is a pointer to a KeyInfo structure */
 
8892 #define P4_MEM (-8) /* P4 is a pointer to a Mem* structure */
8893 #define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */
8894 #define P4_VTAB (-10) /* P4 is a pointer to an sqlite3_vtab structure */
8895 #define P4_MPRINTF (-11) /* P4 is a string obtained from sqlite3_mprintf() */
8896 #define P4_REAL (-12) /* P4 is a 64-bit floating point value */
@@ -13241,13 +13257,10 @@
13241 typedef struct VdbeSorter VdbeSorter;
13242
13243 /* Opaque type used by the explainer */
13244 typedef struct Explain Explain;
13245
13246 /* Elements of the linked list at Vdbe.pAuxData */
13247 typedef struct AuxData AuxData;
13248
13249 /*
13250 ** A cursor is a pointer into a single BTree within a database file.
13251 ** The cursor can seek to a BTree entry with a particular key, or
13252 ** loop over all entries of the Btree. You can also insert new BTree
13253 ** entries or retrieve the key or data from the entry that the cursor
@@ -13430,23 +13443,27 @@
13430 */
13431 #ifdef SQLITE_DEBUG
13432 #define memIsValid(M) ((M)->flags & MEM_Invalid)==0
13433 #endif
13434
13435 /*
13436 ** Each auxilliary data pointer stored by a user defined function
13437 ** implementation calling sqlite3_set_auxdata() is stored in an instance
13438 ** of this structure. All such structures associated with a single VM
13439 ** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed
13440 ** when the VM is halted (if not before).
 
 
 
13441 */
13442 struct AuxData {
13443 int iOp; /* Instruction number of OP_Function opcode */
13444 int iArg; /* Index of function argument. */
13445 void *pAux; /* Aux data pointer */
13446 void (*xDelete)(void *); /* Destructor for the aux data */
13447 AuxData *pNext; /* Next element in list */
 
13448 };
13449
13450 /*
13451 ** The "context" argument for a installable function. A pointer to an
13452 ** instance of this structure is the first argument to the routines used
@@ -13460,17 +13477,16 @@
13460 ** This structure is defined inside of vdbeInt.h because it uses substructures
13461 ** (Mem) which are only defined there.
13462 */
13463 struct sqlite3_context {
13464 FuncDef *pFunc; /* Pointer to function information. MUST BE FIRST */
 
13465 Mem s; /* The return value is stored here */
13466 Mem *pMem; /* Memory cell used to store aggregate context */
13467 CollSeq *pColl; /* Collating sequence */
13468 int isError; /* Error code returned by the function. */
13469 int skipFlag; /* Skip skip accumulator loading if true */
13470 int iOp; /* Instruction number of OP_Function */
13471 Vdbe *pVdbe; /* The VM that owns this context */
13472 };
13473
13474 /*
13475 ** An Explain object accumulates indented output which is helpful
13476 ** in describing recursive data structures.
@@ -13565,11 +13581,10 @@
13565 int nFrame; /* Number of frames in pFrame list */
13566 u32 expmask; /* Binding to these vars invalidates VM */
13567 SubProgram *pProgram; /* Linked list of all sub-programs used by VM */
13568 int nOnceFlag; /* Size of array aOnceFlag[] */
13569 u8 *aOnceFlag; /* Flags for OP_Once */
13570 AuxData *pAuxData; /* Linked list of auxdata allocations */
13571 };
13572
13573 /*
13574 ** The following are allowed values for Vdbe.magic
13575 */
@@ -13589,11 +13604,11 @@
13589 #endif
13590 SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
13591 SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int);
13592 SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int);
13593 SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
13594 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe*, int, int);
13595
13596 int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
13597 SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*);
13598 SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *);
13599 SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
@@ -28361,27 +28376,22 @@
28361 */
28362 static const char *unixTempFileDir(void){
28363 static const char *azDirs[] = {
28364 0,
28365 0,
28366 0,
28367 0,
28368 "/var/tmp",
28369 "/usr/tmp",
28370 "/tmp",
28371 "."
28372 };
28373 unsigned int i;
28374 struct stat buf;
28375 const char *zDir;
28376
28377 azDirs[0] = sqlite3_temp_directory;
28378 if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR");
28379 if( !azDirs[2] ) azDirs[2] = getenv("TMP");
28380 if( !azDirs[3] ) azDirs[3] = getenv("TEMP");
28381 for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
28382 zDir = azDirs[i];
28383 if( zDir==0 ) continue;
28384 if( osStat(zDir, &buf) ) continue;
28385 if( !S_ISDIR(buf.st_mode) ) continue;
28386 if( osAccess(zDir, 07) ) continue;
28387 break;
@@ -28407,10 +28417,11 @@
28407 ** function failing.
28408 */
28409 SimulateIOError( return SQLITE_IOERR );
28410
28411 zDir = unixTempFileDir();
 
28412
28413 /* Check that the output buffer is large enough for the temporary file
28414 ** name. If it is not, return SQLITE_ERROR.
28415 */
28416 if( (strlen(zDir) + strlen(SQLITE_TEMP_FILE_PREFIX) + 18) >= (size_t)nBuf ){
@@ -30488,11 +30499,10 @@
30488 */
30489 #if SQLITE_OS_WIN /* This file is used for Windows only */
30490
30491 #ifdef __CYGWIN__
30492 # include <sys/cygwin.h>
30493 /* # include <errno.h> */
30494 #endif
30495
30496 /*
30497 ** Include code that is common to all os_*.c files
30498 */
@@ -30717,11 +30727,11 @@
30717
30718 /*
30719 ** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions
30720 ** based on the sub-platform)?
30721 */
30722 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
30723 # define SQLITE_WIN32_HAS_ANSI
30724 #endif
30725
30726 /*
30727 ** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions
@@ -30909,11 +30919,10 @@
30909 * zero for the default behavior.
30910 */
30911 #ifndef SQLITE_WIN32_HEAP_FLAGS
30912 # define SQLITE_WIN32_HEAP_FLAGS (0)
30913 #endif
30914
30915
30916 /*
30917 ** The winMemData structure stores information required by the Win32-specific
30918 ** sqlite3_mem_methods implementation.
30919 */
@@ -34375,14 +34384,14 @@
34375 OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
34376 osGetCurrentProcessId(), pFd));
34377 return SQLITE_OK;
34378 }
34379 assert( (nMap % winSysInfo.dwPageSize)==0 );
34380 assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
34381 #if SQLITE_OS_WINRT
34382 pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap);
34383 #else
 
34384 pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
34385 #endif
34386 if( pNew==NULL ){
34387 osCloseHandle(pFd->hMap);
34388 pFd->hMap = NULL;
@@ -34549,19 +34558,10 @@
34549 return zConverted;
34550 }
34551
34552 static int winIsDir(const void *zConverted);
34553
34554 /*
34555 ** Maximum pathname length (in bytes) for windows. The MAX_PATH macro is
34556 ** in characters, so we allocate 3 bytes per character assuming worst-case
34557 ** 3-bytes-per-character UTF8.
34558 */
34559 #ifndef SQLITE_WIN32_MAX_PATH
34560 # define SQLITE_WIN32_MAX_PATH (MAX_PATH*3)
34561 #endif
34562
34563 /*
34564 ** Create a temporary file name in zBuf. zBuf must be big enough to
34565 ** hold at pVfs->mxPathname characters.
34566 */
34567 static int getTempname(int nBuf, char *zBuf){
@@ -34569,21 +34569,22 @@
34569 "abcdefghijklmnopqrstuvwxyz"
34570 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
34571 "0123456789";
34572 size_t i, j;
34573 int nTempPath;
34574 char zTempPath[SQLITE_WIN32_MAX_PATH+2];
34575
34576 /* It's odd to simulate an io-error here, but really this is just
34577 ** using the io-error infrastructure to test that SQLite handles this
34578 ** function failing.
34579 */
34580 SimulateIOError( return SQLITE_IOERR );
34581
 
 
34582 if( sqlite3_temp_directory ){
34583 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s",
34584 sqlite3_temp_directory);
34585 }
34586 #if defined(__CYGWIN__)
34587 else{
34588 static const char *azDirs[] = {
34589 0,
@@ -34626,58 +34627,36 @@
34626 }
34627 #elif !SQLITE_OS_WINRT
34628 else if( isNT() ){
34629 char *zMulti;
34630 WCHAR zWidePath[MAX_PATH];
34631 if( osGetTempPathW(MAX_PATH-30, zWidePath)==0 ){
34632 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34633 return SQLITE_IOERR_GETTEMPPATH;
34634 }
34635 zMulti = unicodeToUtf8(zWidePath);
34636 if( zMulti ){
34637 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zMulti);
34638 sqlite3_free(zMulti);
34639 }else{
34640 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34641 return SQLITE_IOERR_NOMEM;
34642 }
34643 }
34644 #ifdef SQLITE_WIN32_HAS_ANSI
34645 else{
34646 char *zUtf8;
34647 char zMbcsPath[SQLITE_WIN32_MAX_PATH];
34648 if( osGetTempPathA(SQLITE_WIN32_MAX_PATH-30, zMbcsPath)==0 ){
34649 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34650 return SQLITE_IOERR_GETTEMPPATH;
34651 }
34652 zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
34653 if( zUtf8 ){
34654 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zUtf8);
34655 sqlite3_free(zUtf8);
34656 }else{
34657 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34658 return SQLITE_IOERR_NOMEM;
34659 }
34660 }
34661 #else
34662 else{
34663 /*
34664 ** Compiled without ANSI support and the current operating system
34665 ** is not Windows NT; therefore, just zero the temporary buffer.
34666 */
34667 memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34668 }
34669 #endif /* SQLITE_WIN32_HAS_ANSI */
34670 #else
34671 else{
34672 /*
34673 ** Compiled for WinRT and the sqlite3_temp_directory is not set;
34674 ** therefore, just zero the temporary buffer.
34675 */
34676 memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34677 }
34678 #endif /* !SQLITE_OS_WINRT */
34679
34680 /* Check that the output buffer is large enough for the temporary file
34681 ** name. If it is not, return SQLITE_ERROR.
34682 */
34683 nTempPath = sqlite3Strlen30(zTempPath);
@@ -34759,11 +34738,11 @@
34759 int cnt = 0;
34760
34761 /* If argument zPath is a NULL pointer, this function is required to open
34762 ** a temporary file. Use this buffer to store the file name in.
34763 */
34764 char zTmpname[SQLITE_WIN32_MAX_PATH+2]; /* Buffer used to create temp filename */
34765
34766 int rc = SQLITE_OK; /* Function Return Code */
34767 #if !defined(NDEBUG) || SQLITE_OS_WINCE
34768 int eType = flags&0xFFFFFF00; /* Type of file to open */
34769 #endif
@@ -34825,11 +34804,12 @@
34825 /* If the second argument to this function is NULL, generate a
34826 ** temporary file name to use
34827 */
34828 if( !zUtf8Name ){
34829 assert(isDelete && !isOpenJournal);
34830 rc = getTempname(SQLITE_WIN32_MAX_PATH+2, zTmpname);
 
34831 if( rc!=SQLITE_OK ){
34832 OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
34833 return rc;
34834 }
34835 zUtf8Name = zTmpname;
@@ -35256,34 +35236,27 @@
35256 ){
35257
35258 #if defined(__CYGWIN__)
35259 SimulateIOError( return SQLITE_ERROR );
35260 UNUSED_PARAMETER(nFull);
35261 assert( pVfs->mxPathname>=SQLITE_WIN32_MAX_PATH );
35262 assert( nFull>=pVfs->mxPathname );
35263 if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
35264 /*
35265 ** NOTE: We are dealing with a relative path name and the data
35266 ** directory has been set. Therefore, use it as the basis
35267 ** for converting the relative path name to an absolute
35268 ** one by prepending the data directory and a slash.
35269 */
35270 char zOut[SQLITE_WIN32_MAX_PATH+1];
35271 if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35272 SQLITE_WIN32_MAX_PATH+1)<0 ){
35273 winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35274 zRelative);
35275 return SQLITE_CANTOPEN_FULLPATH;
35276 }
35277 sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
35278 sqlite3_data_directory, zOut);
35279 }else{
35280 if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){
35281 winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35282 zRelative);
35283 return SQLITE_CANTOPEN_FULLPATH;
35284 }
35285 }
35286 return SQLITE_OK;
35287 #endif
35288
35289 #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
@@ -35621,11 +35594,11 @@
35621 */
35622 SQLITE_API int sqlite3_os_init(void){
35623 static sqlite3_vfs winVfs = {
35624 3, /* iVersion */
35625 sizeof(winFile), /* szOsFile */
35626 SQLITE_WIN32_MAX_PATH, /* mxPathname */
35627 0, /* pNext */
35628 "win32", /* zName */
35629 0, /* pAppData */
35630 winOpen, /* xOpen */
35631 winDelete, /* xDelete */
@@ -60607,10 +60580,17 @@
60607 break;
60608 }
60609 case P4_MPRINTF: {
60610 if( db->pnBytesFreed==0 ) sqlite3_free(p4);
60611 break;
 
 
 
 
 
 
 
60612 }
60613 case P4_FUNCDEF: {
60614 freeEphemeralFunction(db, (FuncDef*)p4);
60615 break;
60616 }
@@ -61637,14 +61617,10 @@
61637 while( p->pDelFrame ){
61638 VdbeFrame *pDel = p->pDelFrame;
61639 p->pDelFrame = pDel->pParent;
61640 sqlite3VdbeFrameDelete(pDel);
61641 }
61642
61643 /* Delete any auxdata allocations made by the VM */
61644 sqlite3VdbeDeleteAuxData(p, -1, 0);
61645 assert( p->pAuxData==0 );
61646 }
61647
61648 /*
61649 ** Clean up the VM after execution.
61650 **
@@ -62439,39 +62415,24 @@
62439 sqlite3VdbeDelete(p);
62440 return rc;
62441 }
62442
62443 /*
62444 ** If parameter iOp is less than zero, then invoke the destructor for
62445 ** all auxiliary data pointers currently cached by the VM passed as
62446 ** the first argument.
62447 **
62448 ** Or, if iOp is greater than or equal to zero, then the destructor is
62449 ** only invoked for those auxiliary data pointers created by the user
62450 ** function invoked by the OP_Function opcode at instruction iOp of
62451 ** VM pVdbe, and only then if:
62452 **
62453 ** * the associated function parameter is the 32nd or later (counting
62454 ** from left to right), or
62455 **
62456 ** * the corresponding bit in argument mask is clear (where the first
62457 ** function parameter corrsponds to bit 0 etc.).
62458 */
62459 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){
62460 AuxData **pp = &pVdbe->pAuxData;
62461 while( *pp ){
62462 AuxData *pAux = *pp;
62463 if( (iOp<0)
62464 || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & ((u32)1<<pAux->iArg))))
62465 ){
62466 if( pAux->xDelete ){
62467 pAux->xDelete(pAux->pAux);
62468 }
62469 *pp = pAux->pNext;
62470 sqlite3DbFree(pVdbe->db, pAux);
62471 }else{
62472 pp= &pAux->pNext;
62473 }
62474 }
62475 }
62476
62477 /*
@@ -63866,18 +63827,18 @@
63866 /*
63867 ** Return the auxilary data pointer, if any, for the iArg'th argument to
63868 ** the user-function defined by pCtx.
63869 */
63870 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
63871 AuxData *pAuxData;
63872
63873 assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63874 for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
63875 if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
 
63876 }
63877
63878 return (pAuxData ? pAuxData->pAux : 0);
63879 }
63880
63881 /*
63882 ** Set the auxilary data pointer and delete function, for the iArg'th
63883 ** argument to the user-function defined by pCtx. Any previous value is
@@ -63887,30 +63848,33 @@
63887 sqlite3_context *pCtx,
63888 int iArg,
63889 void *pAux,
63890 void (*xDelete)(void*)
63891 ){
63892 AuxData *pAuxData;
63893 Vdbe *pVdbe = pCtx->pVdbe;
63894
63895 assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63896 if( iArg<0 ) goto failed;
63897
63898 for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
63899 if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
63900 }
63901 if( pAuxData==0 ){
63902 pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData));
63903 if( !pAuxData ) goto failed;
63904 pAuxData->iOp = pCtx->iOp;
63905 pAuxData->iArg = iArg;
63906 pAuxData->pNext = pVdbe->pAuxData;
63907 pVdbe->pAuxData = pAuxData;
63908 }else if( pAuxData->xDelete ){
 
 
 
 
 
 
63909 pAuxData->xDelete(pAuxData->pAux);
63910 }
63911
63912 pAuxData->pAux = pAux;
63913 pAuxData->xDelete = xDelete;
63914 return;
63915
63916 failed:
@@ -65518,11 +65482,11 @@
65518 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
65519 u8 encoding = ENC(db); /* The database encoding */
65520 int iCompare = 0; /* Result of last OP_Compare operation */
65521 unsigned nVmStep = 0; /* Number of virtual machine steps */
65522 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65523 unsigned nProgressLimit; /* Invoke xProgress() when nVmStep reaches this */
65524 #endif
65525 Mem *aMem = p->aMem; /* Copy of p->aMem */
65526 Mem *pIn1 = 0; /* 1st input operand */
65527 Mem *pIn2 = 0; /* 2nd input operand */
65528 Mem *pIn3 = 0; /* 3rd input operand */
@@ -65977,21 +65941,10 @@
65977 assert( p->explain==0 );
65978 p->pResultSet = 0;
65979 db->busyHandler.nBusy = 0;
65980 CHECK_FOR_INTERRUPT;
65981 sqlite3VdbeIOTraceSql(p);
65982 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65983 if( db->xProgress ){
65984 assert( 0 < db->nProgressOps );
65985 nProgressLimit = (unsigned)p->aCounter[SQLITE_STMTSTATUS_VM_STEP-1];
65986 if( nProgressLimit==0 ){
65987 nProgressLimit = db->nProgressOps;
65988 }else{
65989 nProgressLimit %= (unsigned)db->nProgressOps;
65990 }
65991 }
65992 #endif
65993 #ifdef SQLITE_DEBUG
65994 sqlite3BeginBenignMalloc();
65995 if( p->pc==0 && (p->db->flags & SQLITE_VdbeListing)!=0 ){
65996 int i;
65997 printf("VDBE Program Listing:\n");
@@ -66148,20 +66101,18 @@
66148 ** of VDBE ops have been executed (either since this invocation of
66149 ** sqlite3VdbeExec() or since last time the progress callback was called).
66150 ** If the progress callback returns non-zero, exit the virtual machine with
66151 ** a return code SQLITE_ABORT.
66152 */
66153 if( db->xProgress!=0 && nVmStep>=nProgressLimit ){
66154 int prc;
66155 prc = db->xProgress(db->pProgressArg);
66156 if( prc!=0 ){
66157 rc = SQLITE_INTERRUPT;
66158 goto vdbe_error_halt;
66159 }
66160 if( db->xProgress!=0 ){
66161 nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);
66162 }
66163 }
66164 #endif
66165
66166 break;
66167 }
@@ -66843,18 +66794,23 @@
66843 Deephemeralize(u.ai.pArg);
66844 sqlite3VdbeMemStoreType(u.ai.pArg);
66845 REGISTER_TRACE(pOp->p2+u.ai.i, u.ai.pArg);
66846 }
66847
66848 assert( pOp->p4type==P4_FUNCDEF );
66849 u.ai.ctx.pFunc = pOp->p4.pFunc;
 
 
 
 
 
 
 
66850 u.ai.ctx.s.flags = MEM_Null;
66851 u.ai.ctx.s.db = db;
66852 u.ai.ctx.s.xDel = 0;
66853 u.ai.ctx.s.zMalloc = 0;
66854 u.ai.ctx.iOp = pc;
66855 u.ai.ctx.pVdbe = p;
66856
66857 /* The output cell may already have a buffer allocated. Move
66858 ** the pointer to u.ai.ctx.s so in case the user-function can use
66859 ** the already allocated buffer instead of allocating a new one.
66860 */
@@ -66873,11 +66829,15 @@
66873 lastRowid = db->lastRowid;
66874
66875 /* If any auxiliary data functions have been called by this user function,
66876 ** immediately call the destructor for any non-static values.
66877 */
66878 sqlite3VdbeDeleteAuxData(p, pc, pOp->p1);
 
 
 
 
66879
66880 if( db->mallocFailed ){
66881 /* Even though a malloc() has failed, the implementation of the
66882 ** user function may have called an sqlite3_result_XXX() function
66883 ** to return a value. The following call releases any resources
@@ -107790,11 +107750,10 @@
107790 WhereLevel *pLevel; /* The where level to be coded */
107791 WhereLoop *pLoop; /* The WhereLoop object being coded */
107792 WhereClause *pWC; /* Decomposition of the entire WHERE clause */
107793 WhereTerm *pTerm; /* A WHERE clause term */
107794 Parse *pParse; /* Parsing context */
107795 sqlite3 *db; /* Database connection */
107796 Vdbe *v; /* The prepared stmt under constructions */
107797 struct SrcList_item *pTabItem; /* FROM clause term being coded */
107798 int addrBrk; /* Jump here to break out of the loop */
107799 int addrCont; /* Jump here to continue with next cycle */
107800 int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
@@ -107802,11 +107761,10 @@
107802 Bitmask newNotReady; /* Return value */
107803
107804 pParse = pWInfo->pParse;
107805 v = pParse->pVdbe;
107806 pWC = &pWInfo->sWC;
107807 db = pParse->db;
107808 pLevel = &pWInfo->a[iLevel];
107809 pLoop = pLevel->pWLoop;
107810 pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
107811 iCur = pTabItem->iCursor;
107812 bRev = (pWInfo->revMask>>iLevel)&1;
@@ -108093,11 +108051,11 @@
108093 /* Generate code to evaluate all constraint terms using == or IN
108094 ** and store the values of those terms in an array of registers
108095 ** starting at regBase.
108096 */
108097 regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
108098 zEndAff = sqlite3DbStrDup(db, zStartAff);
108099 addrNxt = pLevel->addrNxt;
108100
108101 /* If we are doing a reverse order scan on an ascending index, or
108102 ** a forward order scan on a descending index, interchange the
108103 ** start and end terms (pRangeStart and pRangeEnd).
@@ -108178,12 +108136,12 @@
108178 }
108179 codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
108180 nConstraint++;
108181 testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108182 }
108183 sqlite3DbFree(db, zStartAff);
108184 sqlite3DbFree(db, zEndAff);
108185
108186 /* Top of the loop body */
108187 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
108188
108189 /* Check if the index cursor is past the end of the range. */
@@ -108306,11 +108264,11 @@
108306 */
108307 if( pWInfo->nLevel>1 ){
108308 int nNotReady; /* The number of notReady tables */
108309 struct SrcList_item *origSrc; /* Original list of tables */
108310 nNotReady = pWInfo->nLevel - iLevel - 1;
108311 pOrTab = sqlite3StackAllocRaw(db,
108312 sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
108313 if( pOrTab==0 ) return notReady;
108314 pOrTab->nAlloc = (u8)(nNotReady + 1);
108315 pOrTab->nSrc = pOrTab->nAlloc;
108316 memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
@@ -108360,12 +108318,12 @@
108360 Expr *pExpr = pWC->a[iTerm].pExpr;
108361 if( &pWC->a[iTerm] == pTerm ) continue;
108362 if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
108363 if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue;
108364 if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
108365 pExpr = sqlite3ExprDup(db, pExpr, 0);
108366 pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);
108367 }
108368 if( pAndExpr ){
108369 pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
108370 }
108371 }
@@ -108381,11 +108339,11 @@
108381 }
108382 /* Loop through table entries that match term pOrTerm. */
108383 pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
108384 WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
108385 WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
108386 assert( pSubWInfo || pParse->nErr || db->mallocFailed );
108387 if( pSubWInfo ){
108388 WhereLoop *pSubLoop;
108389 explainOneScan(
108390 pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
108391 );
@@ -108436,17 +108394,17 @@
108436 }
108437 pLevel->u.pCovidx = pCov;
108438 if( pCov ) pLevel->iIdxCur = iCovCur;
108439 if( pAndExpr ){
108440 pAndExpr->pLeft = 0;
108441 sqlite3ExprDelete(db, pAndExpr);
108442 }
108443 sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
108444 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
108445 sqlite3VdbeResolveLabel(v, iLoopBody);
108446
108447 if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab);
108448 if( !untestedTerms ) disableTerm(pLevel, pTerm);
108449 }else
108450 #endif /* SQLITE_OMIT_OR_OPTIMIZATION */
108451
108452 {
@@ -108497,12 +108455,13 @@
108497 ** and we are coding the t1 loop and the t2 loop has not yet coded,
108498 ** then we cannot use the "t1.a=t2.b" constraint, but we can code
108499 ** the implied "t1.a=123" constraint.
108500 */
108501 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108502 Expr *pE, *pEAlt;
108503 WhereTerm *pAlt;
 
108504 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108505 if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108506 if( pTerm->leftCursor!=iCur ) continue;
108507 if( pLevel->iLeftJoin ) continue;
108508 pE = pTerm->pExpr;
@@ -108512,17 +108471,13 @@
108512 if( pAlt==0 ) continue;
108513 if( pAlt->wtFlags & (TERM_CODED) ) continue;
108514 testcase( pAlt->eOperator & WO_EQ );
108515 testcase( pAlt->eOperator & WO_IN );
108516 VdbeNoopComment((v, "begin transitive constraint"));
108517 pEAlt = sqlite3StackAllocRaw(db, sizeof(*pEAlt));
108518 if( pEAlt ){
108519 *pEAlt = *pAlt->pExpr;
108520 pEAlt->pLeft = pE->pLeft;
108521 sqlite3ExprIfFalse(pParse, pEAlt, addrCont, SQLITE_JUMPIFNULL);
108522 sqlite3StackFree(db, pEAlt);
108523 }
108524 }
108525
108526 /* For a LEFT OUTER JOIN, generate code that will record the fact that
108527 ** at least one row of the right table has matched the left table.
108528 */
@@ -116461,11 +116416,10 @@
116461 case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break;
116462 case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
116463 case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
116464 case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
116465 case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
116466 case SQLITE_IOERR_GETTEMPPATH: zName = "SQLITE_IOERR_GETTEMPPATH"; break;
116467 case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
116468 case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
116469 case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
116470 case SQLITE_FULL: zName = "SQLITE_FULL"; break;
116471 case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
@@ -117817,11 +117771,11 @@
117817 db->autoCommit = 1;
117818 db->nextAutovac = -1;
117819 db->szMmap = sqlite3GlobalConfig.szMmap;
117820 db->nextPagesize = 0;
117821 db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger
117822 #if !defined(SQLITE_DEFAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
117823 | SQLITE_AutoIndex
117824 #endif
117825 #if SQLITE_DEFAULT_FILE_FORMAT<4
117826 | SQLITE_LegacyFileFmt
117827 #endif
@@ -128290,11 +128244,11 @@
128290 }
128291
128292
128293 #ifdef SQLITE_TEST
128294
128295 #include <tcl.h>
128296 /* #include <string.h> */
128297
128298 /*
128299 ** Implementation of a special SQL scalar function for testing tokenizers
128300 ** designed to be used in concert with the Tcl testing framework. This
128301
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -398,10 +398,13 @@
398 **
399 ** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
400 ** assert() macro is enabled, each call into the Win32 native heap subsystem
401 ** will cause HeapValidate to be called. If heap validation should fail, an
402 ** assertion will be triggered.
403 **
404 ** (Historical note: There used to be several other options, but we've
405 ** pared it down to just these three.)
406 **
407 ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
408 ** the default.
409 */
410 #if defined(SQLITE_SYSTEM_MALLOC) \
@@ -436,17 +439,24 @@
439 */
440 #if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
441 # define _XOPEN_SOURCE 600
442 #endif
443
444 /*
445 ** The TCL headers are only needed when compiling the TCL bindings.
446 */
447 #if defined(SQLITE_TCL) || defined(TCLSH)
448 # include <tcl.h>
449 #endif
450
451 /*
452 ** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
453 ** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
454 ** make it true by defining or undefining NDEBUG.
455 **
456 ** Setting NDEBUG makes the code smaller and run faster by disabling the
457 ** number assert() statements in the code. So we want the default action
458 ** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
459 ** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
460 ** feature.
461 */
462 #if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -512,11 +522,11 @@
522 ** hint of unplanned behavior.
523 **
524 ** In other words, ALWAYS and NEVER are added for defensive code.
525 **
526 ** When doing coverage testing ALWAYS and NEVER are hard-coded to
527 ** be true and false so that the unreachable code then specify will
528 ** not be counted as untested code.
529 */
530 #if defined(SQLITE_COVERAGE_TEST)
531 # define ALWAYS(X) (1)
532 # define NEVER(X) (0)
@@ -536,16 +546,20 @@
546 #define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
547
548 /*
549 ** The macro unlikely() is a hint that surrounds a boolean
550 ** expression that is usually false. Macro likely() surrounds
551 ** a boolean expression that is usually true. GCC is able to
552 ** use these hints to generate better code, sometimes.
 
553 */
554 #if defined(__GNUC__) && 0
555 # define likely(X) __builtin_expect((X),1)
556 # define unlikely(X) __builtin_expect((X),0)
557 #else
558 # define likely(X) !!(X)
559 # define unlikely(X) !!(X)
560 #endif
561
562 /************** Include sqlite3.h in the middle of sqliteInt.h ***************/
563 /************** Begin file sqlite3.h *****************************************/
564 /*
565 ** 2001 September 15
@@ -656,11 +670,11 @@
670 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
671 ** [sqlite_version()] and [sqlite_source_id()].
672 */
673 #define SQLITE_VERSION "3.8.0"
674 #define SQLITE_VERSION_NUMBER 3008000
675 #define SQLITE_SOURCE_ID "2013-07-18 14:50:56 5dcffa671f592ae9355628afa439ae9a2d26f0cd"
676
677 /*
678 ** CAPI3REF: Run-Time Library Version Numbers
679 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
680 **
@@ -1025,11 +1039,10 @@
1039 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
1040 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
1041 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
1042 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
1043 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
 
1044 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
1045 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
1046 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
1047 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
1048 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -3109,12 +3122,11 @@
3122 ** interface is to keep a GUI updated during a large query.
3123 **
3124 ** ^The parameter P is passed through as the only parameter to the
3125 ** callback function X. ^The parameter N is the approximate number of
3126 ** [virtual machine instructions] that are evaluated between successive
3127 ** invocations of the callback X.
 
3128 **
3129 ** ^Only a single progress handler may be defined at one time per
3130 ** [database connection]; setting a new progress handler cancels the
3131 ** old one. ^Setting parameter X to NULL disables the progress handler.
3132 ** ^The progress handler is also disabled by setting N to a value less
@@ -4730,49 +4742,50 @@
4742 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4743
4744 /*
4745 ** CAPI3REF: Function Auxiliary Data
4746 **
4747 ** The following two functions may be used by scalar SQL functions to
4748 ** associate metadata with argument values. If the same value is passed to
4749 ** multiple invocations of the same SQL function during query execution, under
4750 ** some circumstances the associated metadata may be preserved. This might
4751 ** be used, for example, in a regular-expression matching
4752 ** function. The compiled version of the regular expression is stored as
4753 ** metadata associated with the SQL value passed as the regular expression
4754 ** pattern. The compiled regular expression can be reused on multiple
4755 ** invocations of the same function so that the original pattern string
4756 ** does not need to be recompiled on each invocation.
4757 **
4758 ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
4759 ** associated by the sqlite3_set_auxdata() function with the Nth argument
4760 ** value to the application-defined function. ^If no metadata has been ever
4761 ** been set for the Nth argument of the function, or if the corresponding
4762 ** function parameter has changed since the meta-data was set,
4763 ** then sqlite3_get_auxdata() returns a NULL pointer.
4764 **
4765 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
4766 ** argument of the application-defined function. ^Subsequent
4767 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
4768 ** sqlite3_set_auxdata(C,N,P,X) call if the data has not been dropped, or
4769 ** NULL if the data has been dropped.
4770 ** ^(If it is not NULL, SQLite will invoke the destructor
4771 ** function X passed to sqlite3_set_auxdata(C,N,P,X) when <ul>
4772 ** <li> the corresponding function parameter changes,
4773 ** <li> [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4774 ** SQL statement,
4775 ** <li> sqlite3_set_auxdata() is invoked again on the same parameter, or
4776 ** <li> a memory allocation error occurs. </ul>)^
 
 
 
4777 **
4778 ** SQLite is free to call the destructor and drop metadata on any
4779 ** parameter of any function at any time. ^The only guarantee is that
4780 ** the destructor will be called when the [prepared statement] is destroyed.
4781 ** Note in particular that the destructor X in the call to
4782 ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before
4783 ** the sqlite3_set_auxdata() call even returns. Hence sqlite3_set_auxdata()
4784 ** should be called near the end of the function implementation and the
4785 ** implementation should not make any use of P after sqlite3_set_auxdata()
4786 ** has been called.
4787 **
4788 ** ^(In practice, metadata is preserved between function calls for
4789 ** function parameters that are compile-time constants, including literal
4790 ** values and [parameters] and expressions composed from the same.)^
4791 **
@@ -8811,10 +8824,11 @@
8824
8825 /*
8826 ** The names of the following types declared in vdbeInt.h are required
8827 ** for the VdbeOp definition.
8828 */
8829 typedef struct VdbeFunc VdbeFunc;
8830 typedef struct Mem Mem;
8831 typedef struct SubProgram SubProgram;
8832
8833 /*
8834 ** A single instruction of the virtual machine has an opcode
@@ -8834,10 +8848,11 @@
8848 void *p; /* Generic pointer */
8849 char *z; /* Pointer to data for string (char array) types */
8850 i64 *pI64; /* Used when p4type is P4_INT64 */
8851 double *pReal; /* Used when p4type is P4_REAL */
8852 FuncDef *pFunc; /* Used when p4type is P4_FUNCDEF */
8853 VdbeFunc *pVdbeFunc; /* Used when p4type is P4_VDBEFUNC */
8854 CollSeq *pColl; /* Used when p4type is P4_COLLSEQ */
8855 Mem *pMem; /* Used when p4type is P4_MEM */
8856 VTable *pVtab; /* Used when p4type is P4_VTAB */
8857 KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */
8858 int *ai; /* Used when p4type is P4_INTARRAY */
@@ -8887,10 +8902,11 @@
8902 #define P4_DYNAMIC (-1) /* Pointer to a string obtained from sqliteMalloc() */
8903 #define P4_STATIC (-2) /* Pointer to a static string */
8904 #define P4_COLLSEQ (-4) /* P4 is a pointer to a CollSeq structure */
8905 #define P4_FUNCDEF (-5) /* P4 is a pointer to a FuncDef structure */
8906 #define P4_KEYINFO (-6) /* P4 is a pointer to a KeyInfo structure */
8907 #define P4_VDBEFUNC (-7) /* P4 is a pointer to a VdbeFunc structure */
8908 #define P4_MEM (-8) /* P4 is a pointer to a Mem* structure */
8909 #define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */
8910 #define P4_VTAB (-10) /* P4 is a pointer to an sqlite3_vtab structure */
8911 #define P4_MPRINTF (-11) /* P4 is a string obtained from sqlite3_mprintf() */
8912 #define P4_REAL (-12) /* P4 is a 64-bit floating point value */
@@ -13241,13 +13257,10 @@
13257 typedef struct VdbeSorter VdbeSorter;
13258
13259 /* Opaque type used by the explainer */
13260 typedef struct Explain Explain;
13261
 
 
 
13262 /*
13263 ** A cursor is a pointer into a single BTree within a database file.
13264 ** The cursor can seek to a BTree entry with a particular key, or
13265 ** loop over all entries of the Btree. You can also insert new BTree
13266 ** entries or retrieve the key or data from the entry that the cursor
@@ -13430,23 +13443,27 @@
13443 */
13444 #ifdef SQLITE_DEBUG
13445 #define memIsValid(M) ((M)->flags & MEM_Invalid)==0
13446 #endif
13447
13448
13449 /* A VdbeFunc is just a FuncDef (defined in sqliteInt.h) that contains
13450 ** additional information about auxiliary information bound to arguments
13451 ** of the function. This is used to implement the sqlite3_get_auxdata()
13452 ** and sqlite3_set_auxdata() APIs. The "auxdata" is some auxiliary data
13453 ** that can be associated with a constant argument to a function. This
13454 ** allows functions such as "regexp" to compile their constant regular
13455 ** expression argument once and reused the compiled code for multiple
13456 ** invocations.
13457 */
13458 struct VdbeFunc {
13459 FuncDef *pFunc; /* The definition of the function */
13460 int nAux; /* Number of entries allocated for apAux[] */
13461 struct AuxData {
13462 void *pAux; /* Aux data for the i-th argument */
13463 void (*xDelete)(void *); /* Destructor for the aux data */
13464 } apAux[1]; /* One slot for each function argument */
13465 };
13466
13467 /*
13468 ** The "context" argument for a installable function. A pointer to an
13469 ** instance of this structure is the first argument to the routines used
@@ -13460,17 +13477,16 @@
13477 ** This structure is defined inside of vdbeInt.h because it uses substructures
13478 ** (Mem) which are only defined there.
13479 */
13480 struct sqlite3_context {
13481 FuncDef *pFunc; /* Pointer to function information. MUST BE FIRST */
13482 VdbeFunc *pVdbeFunc; /* Auxilary data, if created. */
13483 Mem s; /* The return value is stored here */
13484 Mem *pMem; /* Memory cell used to store aggregate context */
13485 CollSeq *pColl; /* Collating sequence */
13486 int isError; /* Error code returned by the function. */
13487 int skipFlag; /* Skip skip accumulator loading if true */
 
 
13488 };
13489
13490 /*
13491 ** An Explain object accumulates indented output which is helpful
13492 ** in describing recursive data structures.
@@ -13565,11 +13581,10 @@
13581 int nFrame; /* Number of frames in pFrame list */
13582 u32 expmask; /* Binding to these vars invalidates VM */
13583 SubProgram *pProgram; /* Linked list of all sub-programs used by VM */
13584 int nOnceFlag; /* Size of array aOnceFlag[] */
13585 u8 *aOnceFlag; /* Flags for OP_Once */
 
13586 };
13587
13588 /*
13589 ** The following are allowed values for Vdbe.magic
13590 */
@@ -13589,11 +13604,11 @@
13604 #endif
13605 SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
13606 SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int);
13607 SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int);
13608 SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
13609 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc*, int);
13610
13611 int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
13612 SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*);
13613 SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *);
13614 SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
@@ -28361,27 +28376,22 @@
28376 */
28377 static const char *unixTempFileDir(void){
28378 static const char *azDirs[] = {
28379 0,
28380 0,
 
 
28381 "/var/tmp",
28382 "/usr/tmp",
28383 "/tmp",
28384 0 /* List terminator */
28385 };
28386 unsigned int i;
28387 struct stat buf;
28388 const char *zDir = 0;
28389
28390 azDirs[0] = sqlite3_temp_directory;
28391 if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR");
28392 for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){
 
 
 
28393 if( zDir==0 ) continue;
28394 if( osStat(zDir, &buf) ) continue;
28395 if( !S_ISDIR(buf.st_mode) ) continue;
28396 if( osAccess(zDir, 07) ) continue;
28397 break;
@@ -28407,10 +28417,11 @@
28417 ** function failing.
28418 */
28419 SimulateIOError( return SQLITE_IOERR );
28420
28421 zDir = unixTempFileDir();
28422 if( zDir==0 ) zDir = ".";
28423
28424 /* Check that the output buffer is large enough for the temporary file
28425 ** name. If it is not, return SQLITE_ERROR.
28426 */
28427 if( (strlen(zDir) + strlen(SQLITE_TEMP_FILE_PREFIX) + 18) >= (size_t)nBuf ){
@@ -30488,11 +30499,10 @@
30499 */
30500 #if SQLITE_OS_WIN /* This file is used for Windows only */
30501
30502 #ifdef __CYGWIN__
30503 # include <sys/cygwin.h>
 
30504 #endif
30505
30506 /*
30507 ** Include code that is common to all os_*.c files
30508 */
@@ -30717,11 +30727,11 @@
30727
30728 /*
30729 ** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions
30730 ** based on the sub-platform)?
30731 */
30732 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)
30733 # define SQLITE_WIN32_HAS_ANSI
30734 #endif
30735
30736 /*
30737 ** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions
@@ -30909,11 +30919,10 @@
30919 * zero for the default behavior.
30920 */
30921 #ifndef SQLITE_WIN32_HEAP_FLAGS
30922 # define SQLITE_WIN32_HEAP_FLAGS (0)
30923 #endif
 
30924
30925 /*
30926 ** The winMemData structure stores information required by the Win32-specific
30927 ** sqlite3_mem_methods implementation.
30928 */
@@ -34375,14 +34384,14 @@
34384 OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
34385 osGetCurrentProcessId(), pFd));
34386 return SQLITE_OK;
34387 }
34388 assert( (nMap % winSysInfo.dwPageSize)==0 );
 
34389 #if SQLITE_OS_WINRT
34390 pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, nMap);
34391 #else
34392 assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
34393 pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
34394 #endif
34395 if( pNew==NULL ){
34396 osCloseHandle(pFd->hMap);
34397 pFd->hMap = NULL;
@@ -34549,19 +34558,10 @@
34558 return zConverted;
34559 }
34560
34561 static int winIsDir(const void *zConverted);
34562
 
 
 
 
 
 
 
 
 
34563 /*
34564 ** Create a temporary file name in zBuf. zBuf must be big enough to
34565 ** hold at pVfs->mxPathname characters.
34566 */
34567 static int getTempname(int nBuf, char *zBuf){
@@ -34569,21 +34569,22 @@
34569 "abcdefghijklmnopqrstuvwxyz"
34570 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
34571 "0123456789";
34572 size_t i, j;
34573 int nTempPath;
34574 char zTempPath[MAX_PATH+2];
34575
34576 /* It's odd to simulate an io-error here, but really this is just
34577 ** using the io-error infrastructure to test that SQLite handles this
34578 ** function failing.
34579 */
34580 SimulateIOError( return SQLITE_IOERR );
34581
34582 memset(zTempPath, 0, MAX_PATH+2);
34583
34584 if( sqlite3_temp_directory ){
34585 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
 
34586 }
34587 #if defined(__CYGWIN__)
34588 else{
34589 static const char *azDirs[] = {
34590 0,
@@ -34626,58 +34627,36 @@
34627 }
34628 #elif !SQLITE_OS_WINRT
34629 else if( isNT() ){
34630 char *zMulti;
34631 WCHAR zWidePath[MAX_PATH];
34632 osGetTempPathW(MAX_PATH-30, zWidePath);
 
 
 
34633 zMulti = unicodeToUtf8(zWidePath);
34634 if( zMulti ){
34635 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti);
34636 sqlite3_free(zMulti);
34637 }else{
34638 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34639 return SQLITE_IOERR_NOMEM;
34640 }
34641 }
34642 #ifdef SQLITE_WIN32_HAS_ANSI
34643 else{
34644 char *zUtf8;
34645 char zMbcsPath[MAX_PATH];
34646 osGetTempPathA(MAX_PATH-30, zMbcsPath);
 
 
 
34647 zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
34648 if( zUtf8 ){
34649 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8);
34650 sqlite3_free(zUtf8);
34651 }else{
34652 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34653 return SQLITE_IOERR_NOMEM;
34654 }
34655 }
34656 #endif
34657 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34658
34659 /* Check that the output buffer is large enough for the temporary file
34660 ** name. If it is not, return SQLITE_ERROR.
34661 */
34662 nTempPath = sqlite3Strlen30(zTempPath);
@@ -34759,11 +34738,11 @@
34738 int cnt = 0;
34739
34740 /* If argument zPath is a NULL pointer, this function is required to open
34741 ** a temporary file. Use this buffer to store the file name in.
34742 */
34743 char zTmpname[MAX_PATH+2]; /* Buffer used to create temp filename */
34744
34745 int rc = SQLITE_OK; /* Function Return Code */
34746 #if !defined(NDEBUG) || SQLITE_OS_WINCE
34747 int eType = flags&0xFFFFFF00; /* Type of file to open */
34748 #endif
@@ -34825,11 +34804,12 @@
34804 /* If the second argument to this function is NULL, generate a
34805 ** temporary file name to use
34806 */
34807 if( !zUtf8Name ){
34808 assert(isDelete && !isOpenJournal);
34809 memset(zTmpname, 0, MAX_PATH+2);
34810 rc = getTempname(MAX_PATH+2, zTmpname);
34811 if( rc!=SQLITE_OK ){
34812 OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
34813 return rc;
34814 }
34815 zUtf8Name = zTmpname;
@@ -35256,34 +35236,27 @@
35236 ){
35237
35238 #if defined(__CYGWIN__)
35239 SimulateIOError( return SQLITE_ERROR );
35240 UNUSED_PARAMETER(nFull);
35241 assert( pVfs->mxPathname>=MAX_PATH );
35242 assert( nFull>=pVfs->mxPathname );
35243 if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
35244 /*
35245 ** NOTE: We are dealing with a relative path name and the data
35246 ** directory has been set. Therefore, use it as the basis
35247 ** for converting the relative path name to an absolute
35248 ** one by prepending the data directory and a slash.
35249 */
35250 char zOut[MAX_PATH+1];
35251 memset(zOut, 0, MAX_PATH+1);
35252 cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35253 MAX_PATH+1);
 
 
 
35254 sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
35255 sqlite3_data_directory, zOut);
35256 }else{
35257 cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull);
 
 
 
 
35258 }
35259 return SQLITE_OK;
35260 #endif
35261
35262 #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
@@ -35621,11 +35594,11 @@
35594 */
35595 SQLITE_API int sqlite3_os_init(void){
35596 static sqlite3_vfs winVfs = {
35597 3, /* iVersion */
35598 sizeof(winFile), /* szOsFile */
35599 MAX_PATH, /* mxPathname */
35600 0, /* pNext */
35601 "win32", /* zName */
35602 0, /* pAppData */
35603 winOpen, /* xOpen */
35604 winDelete, /* xDelete */
@@ -60607,10 +60580,17 @@
60580 break;
60581 }
60582 case P4_MPRINTF: {
60583 if( db->pnBytesFreed==0 ) sqlite3_free(p4);
60584 break;
60585 }
60586 case P4_VDBEFUNC: {
60587 VdbeFunc *pVdbeFunc = (VdbeFunc *)p4;
60588 freeEphemeralFunction(db, pVdbeFunc->pFunc);
60589 if( db->pnBytesFreed==0 ) sqlite3VdbeDeleteAuxData(pVdbeFunc, 0);
60590 sqlite3DbFree(db, pVdbeFunc);
60591 break;
60592 }
60593 case P4_FUNCDEF: {
60594 freeEphemeralFunction(db, (FuncDef*)p4);
60595 break;
60596 }
@@ -61637,14 +61617,10 @@
61617 while( p->pDelFrame ){
61618 VdbeFrame *pDel = p->pDelFrame;
61619 p->pDelFrame = pDel->pParent;
61620 sqlite3VdbeFrameDelete(pDel);
61621 }
 
 
 
 
61622 }
61623
61624 /*
61625 ** Clean up the VM after execution.
61626 **
@@ -62439,39 +62415,24 @@
62415 sqlite3VdbeDelete(p);
62416 return rc;
62417 }
62418
62419 /*
62420 ** Call the destructor for each auxdata entry in pVdbeFunc for which
62421 ** the corresponding bit in mask is clear. Auxdata entries beyond 31
62422 ** are always destroyed. To destroy all auxdata entries, call this
62423 ** routine with mask==0.
 
 
 
 
 
 
 
 
 
 
62424 */
62425 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc *pVdbeFunc, int mask){
62426 int i;
62427 for(i=0; i<pVdbeFunc->nAux; i++){
62428 struct AuxData *pAux = &pVdbeFunc->apAux[i];
62429 if( (i>31 || !(mask&(((u32)1)<<i))) && pAux->pAux ){
 
 
62430 if( pAux->xDelete ){
62431 pAux->xDelete(pAux->pAux);
62432 }
62433 pAux->pAux = 0;
 
 
 
62434 }
62435 }
62436 }
62437
62438 /*
@@ -63866,18 +63827,18 @@
63827 /*
63828 ** Return the auxilary data pointer, if any, for the iArg'th argument to
63829 ** the user-function defined by pCtx.
63830 */
63831 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
63832 VdbeFunc *pVdbeFunc;
63833
63834 assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63835 pVdbeFunc = pCtx->pVdbeFunc;
63836 if( !pVdbeFunc || iArg>=pVdbeFunc->nAux || iArg<0 ){
63837 return 0;
63838 }
63839 return pVdbeFunc->apAux[iArg].pAux;
 
63840 }
63841
63842 /*
63843 ** Set the auxilary data pointer and delete function, for the iArg'th
63844 ** argument to the user-function defined by pCtx. Any previous value is
@@ -63887,30 +63848,33 @@
63848 sqlite3_context *pCtx,
63849 int iArg,
63850 void *pAux,
63851 void (*xDelete)(void*)
63852 ){
63853 struct AuxData *pAuxData;
63854 VdbeFunc *pVdbeFunc;
 
 
63855 if( iArg<0 ) goto failed;
63856
63857 assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63858 pVdbeFunc = pCtx->pVdbeFunc;
63859 if( !pVdbeFunc || pVdbeFunc->nAux<=iArg ){
63860 int nAux = (pVdbeFunc ? pVdbeFunc->nAux : 0);
63861 int nMalloc = sizeof(VdbeFunc) + sizeof(struct AuxData)*iArg;
63862 pVdbeFunc = sqlite3DbRealloc(pCtx->s.db, pVdbeFunc, nMalloc);
63863 if( !pVdbeFunc ){
63864 goto failed;
63865 }
63866 pCtx->pVdbeFunc = pVdbeFunc;
63867 memset(&pVdbeFunc->apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux));
63868 pVdbeFunc->nAux = iArg+1;
63869 pVdbeFunc->pFunc = pCtx->pFunc;
63870 }
63871
63872 pAuxData = &pVdbeFunc->apAux[iArg];
63873 if( pAuxData->pAux && pAuxData->xDelete ){
63874 pAuxData->xDelete(pAuxData->pAux);
63875 }
 
63876 pAuxData->pAux = pAux;
63877 pAuxData->xDelete = xDelete;
63878 return;
63879
63880 failed:
@@ -65518,11 +65482,11 @@
65482 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
65483 u8 encoding = ENC(db); /* The database encoding */
65484 int iCompare = 0; /* Result of last OP_Compare operation */
65485 unsigned nVmStep = 0; /* Number of virtual machine steps */
65486 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65487 unsigned nProgressOps = 0; /* nVmStep at last progress callback. */
65488 #endif
65489 Mem *aMem = p->aMem; /* Copy of p->aMem */
65490 Mem *pIn1 = 0; /* 1st input operand */
65491 Mem *pIn2 = 0; /* 2nd input operand */
65492 Mem *pIn3 = 0; /* 3rd input operand */
@@ -65977,21 +65941,10 @@
65941 assert( p->explain==0 );
65942 p->pResultSet = 0;
65943 db->busyHandler.nBusy = 0;
65944 CHECK_FOR_INTERRUPT;
65945 sqlite3VdbeIOTraceSql(p);
 
 
 
 
 
 
 
 
 
 
 
65946 #ifdef SQLITE_DEBUG
65947 sqlite3BeginBenignMalloc();
65948 if( p->pc==0 && (p->db->flags & SQLITE_VdbeListing)!=0 ){
65949 int i;
65950 printf("VDBE Program Listing:\n");
@@ -66148,20 +66101,18 @@
66101 ** of VDBE ops have been executed (either since this invocation of
66102 ** sqlite3VdbeExec() or since last time the progress callback was called).
66103 ** If the progress callback returns non-zero, exit the virtual machine with
66104 ** a return code SQLITE_ABORT.
66105 */
66106 if( db->xProgress!=0 && (nVmStep - nProgressOps)>=db->nProgressOps ){
66107 int prc;
66108 prc = db->xProgress(db->pProgressArg);
66109 if( prc!=0 ){
66110 rc = SQLITE_INTERRUPT;
66111 goto vdbe_error_halt;
66112 }
66113 nProgressOps = nVmStep;
 
 
66114 }
66115 #endif
66116
66117 break;
66118 }
@@ -66843,18 +66794,23 @@
66794 Deephemeralize(u.ai.pArg);
66795 sqlite3VdbeMemStoreType(u.ai.pArg);
66796 REGISTER_TRACE(pOp->p2+u.ai.i, u.ai.pArg);
66797 }
66798
66799 assert( pOp->p4type==P4_FUNCDEF || pOp->p4type==P4_VDBEFUNC );
66800 if( pOp->p4type==P4_FUNCDEF ){
66801 u.ai.ctx.pFunc = pOp->p4.pFunc;
66802 u.ai.ctx.pVdbeFunc = 0;
66803 }else{
66804 u.ai.ctx.pVdbeFunc = (VdbeFunc*)pOp->p4.pVdbeFunc;
66805 u.ai.ctx.pFunc = u.ai.ctx.pVdbeFunc->pFunc;
66806 }
66807
66808 u.ai.ctx.s.flags = MEM_Null;
66809 u.ai.ctx.s.db = db;
66810 u.ai.ctx.s.xDel = 0;
66811 u.ai.ctx.s.zMalloc = 0;
 
 
66812
66813 /* The output cell may already have a buffer allocated. Move
66814 ** the pointer to u.ai.ctx.s so in case the user-function can use
66815 ** the already allocated buffer instead of allocating a new one.
66816 */
@@ -66873,11 +66829,15 @@
66829 lastRowid = db->lastRowid;
66830
66831 /* If any auxiliary data functions have been called by this user function,
66832 ** immediately call the destructor for any non-static values.
66833 */
66834 if( u.ai.ctx.pVdbeFunc ){
66835 sqlite3VdbeDeleteAuxData(u.ai.ctx.pVdbeFunc, pOp->p1);
66836 pOp->p4.pVdbeFunc = u.ai.ctx.pVdbeFunc;
66837 pOp->p4type = P4_VDBEFUNC;
66838 }
66839
66840 if( db->mallocFailed ){
66841 /* Even though a malloc() has failed, the implementation of the
66842 ** user function may have called an sqlite3_result_XXX() function
66843 ** to return a value. The following call releases any resources
@@ -107790,11 +107750,10 @@
107750 WhereLevel *pLevel; /* The where level to be coded */
107751 WhereLoop *pLoop; /* The WhereLoop object being coded */
107752 WhereClause *pWC; /* Decomposition of the entire WHERE clause */
107753 WhereTerm *pTerm; /* A WHERE clause term */
107754 Parse *pParse; /* Parsing context */
 
107755 Vdbe *v; /* The prepared stmt under constructions */
107756 struct SrcList_item *pTabItem; /* FROM clause term being coded */
107757 int addrBrk; /* Jump here to break out of the loop */
107758 int addrCont; /* Jump here to continue with next cycle */
107759 int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
@@ -107802,11 +107761,10 @@
107761 Bitmask newNotReady; /* Return value */
107762
107763 pParse = pWInfo->pParse;
107764 v = pParse->pVdbe;
107765 pWC = &pWInfo->sWC;
 
107766 pLevel = &pWInfo->a[iLevel];
107767 pLoop = pLevel->pWLoop;
107768 pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
107769 iCur = pTabItem->iCursor;
107770 bRev = (pWInfo->revMask>>iLevel)&1;
@@ -108093,11 +108051,11 @@
108051 /* Generate code to evaluate all constraint terms using == or IN
108052 ** and store the values of those terms in an array of registers
108053 ** starting at regBase.
108054 */
108055 regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
108056 zEndAff = sqlite3DbStrDup(pParse->db, zStartAff);
108057 addrNxt = pLevel->addrNxt;
108058
108059 /* If we are doing a reverse order scan on an ascending index, or
108060 ** a forward order scan on a descending index, interchange the
108061 ** start and end terms (pRangeStart and pRangeEnd).
@@ -108178,12 +108136,12 @@
108136 }
108137 codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
108138 nConstraint++;
108139 testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108140 }
108141 sqlite3DbFree(pParse->db, zStartAff);
108142 sqlite3DbFree(pParse->db, zEndAff);
108143
108144 /* Top of the loop body */
108145 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
108146
108147 /* Check if the index cursor is past the end of the range. */
@@ -108306,11 +108264,11 @@
108264 */
108265 if( pWInfo->nLevel>1 ){
108266 int nNotReady; /* The number of notReady tables */
108267 struct SrcList_item *origSrc; /* Original list of tables */
108268 nNotReady = pWInfo->nLevel - iLevel - 1;
108269 pOrTab = sqlite3StackAllocRaw(pParse->db,
108270 sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
108271 if( pOrTab==0 ) return notReady;
108272 pOrTab->nAlloc = (u8)(nNotReady + 1);
108273 pOrTab->nSrc = pOrTab->nAlloc;
108274 memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
@@ -108360,12 +108318,12 @@
108318 Expr *pExpr = pWC->a[iTerm].pExpr;
108319 if( &pWC->a[iTerm] == pTerm ) continue;
108320 if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
108321 if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue;
108322 if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
108323 pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
108324 pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr);
108325 }
108326 if( pAndExpr ){
108327 pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
108328 }
108329 }
@@ -108381,11 +108339,11 @@
108339 }
108340 /* Loop through table entries that match term pOrTerm. */
108341 pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
108342 WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
108343 WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
108344 assert( pSubWInfo || pParse->nErr || pParse->db->mallocFailed );
108345 if( pSubWInfo ){
108346 WhereLoop *pSubLoop;
108347 explainOneScan(
108348 pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
108349 );
@@ -108436,17 +108394,17 @@
108394 }
108395 pLevel->u.pCovidx = pCov;
108396 if( pCov ) pLevel->iIdxCur = iCovCur;
108397 if( pAndExpr ){
108398 pAndExpr->pLeft = 0;
108399 sqlite3ExprDelete(pParse->db, pAndExpr);
108400 }
108401 sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
108402 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
108403 sqlite3VdbeResolveLabel(v, iLoopBody);
108404
108405 if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab);
108406 if( !untestedTerms ) disableTerm(pLevel, pTerm);
108407 }else
108408 #endif /* SQLITE_OMIT_OR_OPTIMIZATION */
108409
108410 {
@@ -108497,12 +108455,13 @@
108455 ** and we are coding the t1 loop and the t2 loop has not yet coded,
108456 ** then we cannot use the "t1.a=t2.b" constraint, but we can code
108457 ** the implied "t1.a=123" constraint.
108458 */
108459 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108460 Expr *pE;
108461 WhereTerm *pAlt;
108462 Expr sEq;
108463 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108464 if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108465 if( pTerm->leftCursor!=iCur ) continue;
108466 if( pLevel->iLeftJoin ) continue;
108467 pE = pTerm->pExpr;
@@ -108512,17 +108471,13 @@
108471 if( pAlt==0 ) continue;
108472 if( pAlt->wtFlags & (TERM_CODED) ) continue;
108473 testcase( pAlt->eOperator & WO_EQ );
108474 testcase( pAlt->eOperator & WO_IN );
108475 VdbeNoopComment((v, "begin transitive constraint"));
108476 sEq = *pAlt->pExpr;
108477 sEq.pLeft = pE->pLeft;
108478 sqlite3ExprIfFalse(pParse, &sEq, addrCont, SQLITE_JUMPIFNULL);
 
 
 
 
108479 }
108480
108481 /* For a LEFT OUTER JOIN, generate code that will record the fact that
108482 ** at least one row of the right table has matched the left table.
108483 */
@@ -116461,11 +116416,10 @@
116416 case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break;
116417 case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
116418 case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
116419 case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
116420 case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
 
116421 case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
116422 case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
116423 case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
116424 case SQLITE_FULL: zName = "SQLITE_FULL"; break;
116425 case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
@@ -117817,11 +117771,11 @@
117771 db->autoCommit = 1;
117772 db->nextAutovac = -1;
117773 db->szMmap = sqlite3GlobalConfig.szMmap;
117774 db->nextPagesize = 0;
117775 db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger
117776 #if !defined(SQLITE_DEAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
117777 | SQLITE_AutoIndex
117778 #endif
117779 #if SQLITE_DEFAULT_FILE_FORMAT<4
117780 | SQLITE_LegacyFileFmt
117781 #endif
@@ -128290,11 +128244,11 @@
128244 }
128245
128246
128247 #ifdef SQLITE_TEST
128248
128249 /* #include <tcl.h> */
128250 /* #include <string.h> */
128251
128252 /*
128253 ** Implementation of a special SQL scalar function for testing tokenizers
128254 ** designed to be used in concert with the Tcl testing framework. This
128255
+31 -32
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110110
#define SQLITE_VERSION "3.8.0"
111111
#define SQLITE_VERSION_NUMBER 3008000
112
-#define SQLITE_SOURCE_ID "2013-07-31 23:28:36 136fc2931b156f91cdd76a7a009298cdf09d826a"
112
+#define SQLITE_SOURCE_ID "2013-07-18 14:50:56 5dcffa671f592ae9355628afa439ae9a2d26f0cd"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
@@ -476,11 +476,10 @@
476476
#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
477477
#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
478478
#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
479479
#define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
480480
#define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
481
-#define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
482481
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
483482
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
484483
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
485484
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
486485
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -2560,12 +2559,11 @@
25602559
** interface is to keep a GUI updated during a large query.
25612560
**
25622561
** ^The parameter P is passed through as the only parameter to the
25632562
** callback function X. ^The parameter N is the approximate number of
25642563
** [virtual machine instructions] that are evaluated between successive
2565
-** invocations of the callback X. ^If N is less than one then the progress
2566
-** handler is disabled.
2564
+** invocations of the callback X.
25672565
**
25682566
** ^Only a single progress handler may be defined at one time per
25692567
** [database connection]; setting a new progress handler cancels the
25702568
** old one. ^Setting parameter X to NULL disables the progress handler.
25712569
** ^The progress handler is also disabled by setting N to a value less
@@ -4181,49 +4179,50 @@
41814179
SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
41824180
41834181
/*
41844182
** CAPI3REF: Function Auxiliary Data
41854183
**
4186
-** These functions may be used by (non-aggregate) SQL functions to
4184
+** The following two functions may be used by scalar SQL functions to
41874185
** associate metadata with argument values. If the same value is passed to
41884186
** multiple invocations of the same SQL function during query execution, under
4189
-** some circumstances the associated metadata may be preserved. An example
4190
-** of where this might be useful is in a regular-expression matching
4191
-** function. The compiled version of the regular expression can be stored as
4192
-** metadata associated with the pattern string.
4193
-** Then as long as the pattern string remains the same,
4194
-** the compiled regular expression can be reused on multiple
4195
-** invocations of the same function.
4187
+** some circumstances the associated metadata may be preserved. This might
4188
+** be used, for example, in a regular-expression matching
4189
+** function. The compiled version of the regular expression is stored as
4190
+** metadata associated with the SQL value passed as the regular expression
4191
+** pattern. The compiled regular expression can be reused on multiple
4192
+** invocations of the same function so that the original pattern string
4193
+** does not need to be recompiled on each invocation.
41964194
**
41974195
** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
41984196
** associated by the sqlite3_set_auxdata() function with the Nth argument
4199
-** value to the application-defined function. ^If there is no metadata
4200
-** associated with the function argument, this sqlite3_get_auxdata() interface
4201
-** returns a NULL pointer.
4197
+** value to the application-defined function. ^If no metadata has been ever
4198
+** been set for the Nth argument of the function, or if the corresponding
4199
+** function parameter has changed since the meta-data was set,
4200
+** then sqlite3_get_auxdata() returns a NULL pointer.
42024201
**
42034202
** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
42044203
** argument of the application-defined function. ^Subsequent
42054204
** calls to sqlite3_get_auxdata(C,N) return P from the most recent
4206
-** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or
4207
-** NULL if the metadata has been discarded.
4208
-** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
4209
-** SQLite will invoke the destructor function X with parameter P exactly
4210
-** once, when the metadata is discarded.
4211
-** SQLite is free to discard the metadata at any time, including: <ul>
4212
-** <li> when the corresponding function parameter changes, or
4213
-** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4214
-** SQL statement, or
4215
-** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or
4216
-** <li> during the original sqlite3_set_auxdata() call when a memory
4217
-** allocation error occurs. </ul>)^
4205
+** sqlite3_set_auxdata(C,N,P,X) call if the data has not been dropped, or
4206
+** NULL if the data has been dropped.
4207
+** ^(If it is not NULL, SQLite will invoke the destructor
4208
+** function X passed to sqlite3_set_auxdata(C,N,P,X) when <ul>
4209
+** <li> the corresponding function parameter changes,
4210
+** <li> [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4211
+** SQL statement,
4212
+** <li> sqlite3_set_auxdata() is invoked again on the same parameter, or
4213
+** <li> a memory allocation error occurs. </ul>)^
42184214
**
4219
-** Note the last bullet in particular. The destructor X in
4220
-** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
4221
-** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
4215
+** SQLite is free to call the destructor and drop metadata on any
4216
+** parameter of any function at any time. ^The only guarantee is that
4217
+** the destructor will be called when the [prepared statement] is destroyed.
4218
+** Note in particular that the destructor X in the call to
4219
+** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before
4220
+** the sqlite3_set_auxdata() call even returns. Hence sqlite3_set_auxdata()
42224221
** should be called near the end of the function implementation and the
4223
-** function implementation should not make any use of P after
4224
-** sqlite3_set_auxdata() has been called.
4222
+** implementation should not make any use of P after sqlite3_set_auxdata()
4223
+** has been called.
42254224
**
42264225
** ^(In practice, metadata is preserved between function calls for
42274226
** function parameters that are compile-time constants, including literal
42284227
** values and [parameters] and expressions composed from the same.)^
42294228
**
42304229
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.0"
111 #define SQLITE_VERSION_NUMBER 3008000
112 #define SQLITE_SOURCE_ID "2013-07-31 23:28:36 136fc2931b156f91cdd76a7a009298cdf09d826a"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -476,11 +476,10 @@
476 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
477 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
478 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
479 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
480 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
481 #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
482 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
483 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
484 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
485 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
486 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -2560,12 +2559,11 @@
2560 ** interface is to keep a GUI updated during a large query.
2561 **
2562 ** ^The parameter P is passed through as the only parameter to the
2563 ** callback function X. ^The parameter N is the approximate number of
2564 ** [virtual machine instructions] that are evaluated between successive
2565 ** invocations of the callback X. ^If N is less than one then the progress
2566 ** handler is disabled.
2567 **
2568 ** ^Only a single progress handler may be defined at one time per
2569 ** [database connection]; setting a new progress handler cancels the
2570 ** old one. ^Setting parameter X to NULL disables the progress handler.
2571 ** ^The progress handler is also disabled by setting N to a value less
@@ -4181,49 +4179,50 @@
4181 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4182
4183 /*
4184 ** CAPI3REF: Function Auxiliary Data
4185 **
4186 ** These functions may be used by (non-aggregate) SQL functions to
4187 ** associate metadata with argument values. If the same value is passed to
4188 ** multiple invocations of the same SQL function during query execution, under
4189 ** some circumstances the associated metadata may be preserved. An example
4190 ** of where this might be useful is in a regular-expression matching
4191 ** function. The compiled version of the regular expression can be stored as
4192 ** metadata associated with the pattern string.
4193 ** Then as long as the pattern string remains the same,
4194 ** the compiled regular expression can be reused on multiple
4195 ** invocations of the same function.
4196 **
4197 ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
4198 ** associated by the sqlite3_set_auxdata() function with the Nth argument
4199 ** value to the application-defined function. ^If there is no metadata
4200 ** associated with the function argument, this sqlite3_get_auxdata() interface
4201 ** returns a NULL pointer.
 
4202 **
4203 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
4204 ** argument of the application-defined function. ^Subsequent
4205 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
4206 ** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or
4207 ** NULL if the metadata has been discarded.
4208 ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
4209 ** SQLite will invoke the destructor function X with parameter P exactly
4210 ** once, when the metadata is discarded.
4211 ** SQLite is free to discard the metadata at any time, including: <ul>
4212 ** <li> when the corresponding function parameter changes, or
4213 ** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4214 ** SQL statement, or
4215 ** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or
4216 ** <li> during the original sqlite3_set_auxdata() call when a memory
4217 ** allocation error occurs. </ul>)^
4218 **
4219 ** Note the last bullet in particular. The destructor X in
4220 ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
4221 ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
 
 
 
4222 ** should be called near the end of the function implementation and the
4223 ** function implementation should not make any use of P after
4224 ** sqlite3_set_auxdata() has been called.
4225 **
4226 ** ^(In practice, metadata is preserved between function calls for
4227 ** function parameters that are compile-time constants, including literal
4228 ** values and [parameters] and expressions composed from the same.)^
4229 **
4230
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.0"
111 #define SQLITE_VERSION_NUMBER 3008000
112 #define SQLITE_SOURCE_ID "2013-07-18 14:50:56 5dcffa671f592ae9355628afa439ae9a2d26f0cd"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -476,11 +476,10 @@
476 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
477 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
478 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
479 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
480 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
 
481 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
482 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
483 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
484 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
485 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -2560,12 +2559,11 @@
2559 ** interface is to keep a GUI updated during a large query.
2560 **
2561 ** ^The parameter P is passed through as the only parameter to the
2562 ** callback function X. ^The parameter N is the approximate number of
2563 ** [virtual machine instructions] that are evaluated between successive
2564 ** invocations of the callback X.
 
2565 **
2566 ** ^Only a single progress handler may be defined at one time per
2567 ** [database connection]; setting a new progress handler cancels the
2568 ** old one. ^Setting parameter X to NULL disables the progress handler.
2569 ** ^The progress handler is also disabled by setting N to a value less
@@ -4181,49 +4179,50 @@
4179 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4180
4181 /*
4182 ** CAPI3REF: Function Auxiliary Data
4183 **
4184 ** The following two functions may be used by scalar SQL functions to
4185 ** associate metadata with argument values. If the same value is passed to
4186 ** multiple invocations of the same SQL function during query execution, under
4187 ** some circumstances the associated metadata may be preserved. This might
4188 ** be used, for example, in a regular-expression matching
4189 ** function. The compiled version of the regular expression is stored as
4190 ** metadata associated with the SQL value passed as the regular expression
4191 ** pattern. The compiled regular expression can be reused on multiple
4192 ** invocations of the same function so that the original pattern string
4193 ** does not need to be recompiled on each invocation.
4194 **
4195 ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
4196 ** associated by the sqlite3_set_auxdata() function with the Nth argument
4197 ** value to the application-defined function. ^If no metadata has been ever
4198 ** been set for the Nth argument of the function, or if the corresponding
4199 ** function parameter has changed since the meta-data was set,
4200 ** then sqlite3_get_auxdata() returns a NULL pointer.
4201 **
4202 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
4203 ** argument of the application-defined function. ^Subsequent
4204 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
4205 ** sqlite3_set_auxdata(C,N,P,X) call if the data has not been dropped, or
4206 ** NULL if the data has been dropped.
4207 ** ^(If it is not NULL, SQLite will invoke the destructor
4208 ** function X passed to sqlite3_set_auxdata(C,N,P,X) when <ul>
4209 ** <li> the corresponding function parameter changes,
4210 ** <li> [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4211 ** SQL statement,
4212 ** <li> sqlite3_set_auxdata() is invoked again on the same parameter, or
4213 ** <li> a memory allocation error occurs. </ul>)^
 
 
 
4214 **
4215 ** SQLite is free to call the destructor and drop metadata on any
4216 ** parameter of any function at any time. ^The only guarantee is that
4217 ** the destructor will be called when the [prepared statement] is destroyed.
4218 ** Note in particular that the destructor X in the call to
4219 ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before
4220 ** the sqlite3_set_auxdata() call even returns. Hence sqlite3_set_auxdata()
4221 ** should be called near the end of the function implementation and the
4222 ** implementation should not make any use of P after sqlite3_set_auxdata()
4223 ** has been called.
4224 **
4225 ** ^(In practice, metadata is preserved between function calls for
4226 ** function parameters that are compile-time constants, including literal
4227 ** values and [parameters] and expressions composed from the same.)^
4228 **
4229
+7 -1
--- src/wiki.c
+++ src/wiki.c
@@ -178,14 +178,20 @@
178178
if( !g.perm.RdWiki ){ login_needed(); return; }
179179
zPageName = P("name");
180180
if( zPageName==0 ){
181181
style_header("Wiki");
182182
@ <ul>
183
+ { char *zWikiHomePageName = db_get("index-page",0);
184
+ if( zWikiHomePageName ){
185
+ @ <li> %z(href("%R%s",zWikiHomePageName))
186
+ @ %h(zWikiHomePageName)</a> wiki home page.</li>
187
+ }
188
+ }
183189
{ char *zHomePageName = db_get("project-name",0);
184190
if( zHomePageName ){
185191
@ <li> %z(href("%R/wiki?name=%t",zHomePageName))
186
- @ %h(zHomePageName)</a> wiki home page.</li>
192
+ @ %h(zHomePageName)</a> project home page.</li>
187193
}
188194
}
189195
@ <li> %z(href("%R/timeline?y=w"))Recent changes</a> to wiki pages.</li>
190196
@ <li> %z(href("%R/wiki_rules"))Formatting rules</a> for wiki.</li>
191197
@ <li> Use the %z(href("%R/wiki?name=Sandbox"))Sandbox</a>
192198
--- src/wiki.c
+++ src/wiki.c
@@ -178,14 +178,20 @@
178 if( !g.perm.RdWiki ){ login_needed(); return; }
179 zPageName = P("name");
180 if( zPageName==0 ){
181 style_header("Wiki");
182 @ <ul>
 
 
 
 
 
 
183 { char *zHomePageName = db_get("project-name",0);
184 if( zHomePageName ){
185 @ <li> %z(href("%R/wiki?name=%t",zHomePageName))
186 @ %h(zHomePageName)</a> wiki home page.</li>
187 }
188 }
189 @ <li> %z(href("%R/timeline?y=w"))Recent changes</a> to wiki pages.</li>
190 @ <li> %z(href("%R/wiki_rules"))Formatting rules</a> for wiki.</li>
191 @ <li> Use the %z(href("%R/wiki?name=Sandbox"))Sandbox</a>
192
--- src/wiki.c
+++ src/wiki.c
@@ -178,14 +178,20 @@
178 if( !g.perm.RdWiki ){ login_needed(); return; }
179 zPageName = P("name");
180 if( zPageName==0 ){
181 style_header("Wiki");
182 @ <ul>
183 { char *zWikiHomePageName = db_get("index-page",0);
184 if( zWikiHomePageName ){
185 @ <li> %z(href("%R%s",zWikiHomePageName))
186 @ %h(zWikiHomePageName)</a> wiki home page.</li>
187 }
188 }
189 { char *zHomePageName = db_get("project-name",0);
190 if( zHomePageName ){
191 @ <li> %z(href("%R/wiki?name=%t",zHomePageName))
192 @ %h(zHomePageName)</a> project home page.</li>
193 }
194 }
195 @ <li> %z(href("%R/timeline?y=w"))Recent changes</a> to wiki pages.</li>
196 @ <li> %z(href("%R/wiki_rules"))Formatting rules</a> for wiki.</li>
197 @ <li> Use the %z(href("%R/wiki?name=Sandbox"))Sandbox</a>
198
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -13,15 +13,15 @@
1313
#
1414
1515
#### Select one of MinGW, MinGW-w64 (32-bit) or MinGW-w64 (64-bit) compilers.
1616
# By default, this is an empty string (i.e. use the native compiler).
1717
#
18
-PREFIX =
18
+# PREFIX =
1919
# PREFIX = mingw32-
2020
# PREFIX = i686-pc-mingw32-
2121
# PREFIX = i686-w64-mingw32-
22
-# PREFIX = x86_64-w64-mingw32-
22
+PREFIX = x86_64-w64-mingw32-
2323
2424
#### The toplevel directory of the source tree. Fossil can be built
2525
# in a directory that is separate from the source tree. Just change
2626
# the following to point from the build directory to the src/ folder.
2727
#
2828
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -13,15 +13,15 @@
13 #
14
15 #### Select one of MinGW, MinGW-w64 (32-bit) or MinGW-w64 (64-bit) compilers.
16 # By default, this is an empty string (i.e. use the native compiler).
17 #
18 PREFIX =
19 # PREFIX = mingw32-
20 # PREFIX = i686-pc-mingw32-
21 # PREFIX = i686-w64-mingw32-
22 # PREFIX = x86_64-w64-mingw32-
23
24 #### The toplevel directory of the source tree. Fossil can be built
25 # in a directory that is separate from the source tree. Just change
26 # the following to point from the build directory to the src/ folder.
27 #
28
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -13,15 +13,15 @@
13 #
14
15 #### Select one of MinGW, MinGW-w64 (32-bit) or MinGW-w64 (64-bit) compilers.
16 # By default, this is an empty string (i.e. use the native compiler).
17 #
18 # PREFIX =
19 # PREFIX = mingw32-
20 # PREFIX = i686-pc-mingw32-
21 # PREFIX = i686-w64-mingw32-
22 PREFIX = x86_64-w64-mingw32-
23
24 #### The toplevel directory of the source tree. Fossil can be built
25 # in a directory that is separate from the source tree. Just change
26 # the following to point from the build directory to the src/ folder.
27 #
28
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -13,15 +13,15 @@
1313
#
1414
1515
#### Select one of MinGW, MinGW-w64 (32-bit) or MinGW-w64 (64-bit) compilers.
1616
# By default, this is an empty string (i.e. use the native compiler).
1717
#
18
-PREFIX =
18
+# PREFIX =
1919
# PREFIX = mingw32-
2020
# PREFIX = i686-pc-mingw32-
2121
# PREFIX = i686-w64-mingw32-
22
-# PREFIX = x86_64-w64-mingw32-
22
+PREFIX = x86_64-w64-mingw32-
2323
2424
#### The toplevel directory of the source tree. Fossil can be built
2525
# in a directory that is separate from the source tree. Just change
2626
# the following to point from the build directory to the src/ folder.
2727
#
2828
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -13,15 +13,15 @@
13 #
14
15 #### Select one of MinGW, MinGW-w64 (32-bit) or MinGW-w64 (64-bit) compilers.
16 # By default, this is an empty string (i.e. use the native compiler).
17 #
18 PREFIX =
19 # PREFIX = mingw32-
20 # PREFIX = i686-pc-mingw32-
21 # PREFIX = i686-w64-mingw32-
22 # PREFIX = x86_64-w64-mingw32-
23
24 #### The toplevel directory of the source tree. Fossil can be built
25 # in a directory that is separate from the source tree. Just change
26 # the following to point from the build directory to the src/ folder.
27 #
28
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -13,15 +13,15 @@
13 #
14
15 #### Select one of MinGW, MinGW-w64 (32-bit) or MinGW-w64 (64-bit) compilers.
16 # By default, this is an empty string (i.e. use the native compiler).
17 #
18 # PREFIX =
19 # PREFIX = mingw32-
20 # PREFIX = i686-pc-mingw32-
21 # PREFIX = i686-w64-mingw32-
22 PREFIX = x86_64-w64-mingw32-
23
24 #### The toplevel directory of the source tree. Fossil can be built
25 # in a directory that is separate from the source tree. Just change
26 # the following to point from the build directory to the src/ folder.
27 #
28
--- www/changes.wiki
+++ www/changes.wiki
@@ -5,11 +5,12 @@
55
[/help?cmd=clean | fossil clean], [/help?cmd=extras | fossil extras],
66
[/help?cmd=ls | fossil ls] and [/help?cmd=status | fossil status] commands
77
to restrict operation to files and directories named on the command-line.
88
* New --integrate option to [/help?cmd=merge | fossil merge], which
99
automatically closes the merged branch when committing.
10
- * Renamed <tt>/stats_report</tt> page to [/reports].
10
+ * Renamed <tt>/stats_report</tt> page to [/reports]. Graph width is now
11
+ relative, not absolute.
1112
* Added <tt>yw=YYYY-WW</tt> (year-week) filter to timeline to limit the results
1213
to a specific year and calendar week number, e.g. [/timeline?yw=2013-01].
1314
1415
<h2>Changes For Version 1.26 (2013-06-18)</h2>
1516
* The argument to the --port option for the [/help?cmd=ui | fossil ui] and
1617
--- www/changes.wiki
+++ www/changes.wiki
@@ -5,11 +5,12 @@
5 [/help?cmd=clean | fossil clean], [/help?cmd=extras | fossil extras],
6 [/help?cmd=ls | fossil ls] and [/help?cmd=status | fossil status] commands
7 to restrict operation to files and directories named on the command-line.
8 * New --integrate option to [/help?cmd=merge | fossil merge], which
9 automatically closes the merged branch when committing.
10 * Renamed <tt>/stats_report</tt> page to [/reports].
 
11 * Added <tt>yw=YYYY-WW</tt> (year-week) filter to timeline to limit the results
12 to a specific year and calendar week number, e.g. [/timeline?yw=2013-01].
13
14 <h2>Changes For Version 1.26 (2013-06-18)</h2>
15 * The argument to the --port option for the [/help?cmd=ui | fossil ui] and
16
--- www/changes.wiki
+++ www/changes.wiki
@@ -5,11 +5,12 @@
5 [/help?cmd=clean | fossil clean], [/help?cmd=extras | fossil extras],
6 [/help?cmd=ls | fossil ls] and [/help?cmd=status | fossil status] commands
7 to restrict operation to files and directories named on the command-line.
8 * New --integrate option to [/help?cmd=merge | fossil merge], which
9 automatically closes the merged branch when committing.
10 * Renamed <tt>/stats_report</tt> page to [/reports]. Graph width is now
11 relative, not absolute.
12 * Added <tt>yw=YYYY-WW</tt> (year-week) filter to timeline to limit the results
13 to a specific year and calendar week number, e.g. [/timeline?yw=2013-01].
14
15 <h2>Changes For Version 1.26 (2013-06-18)</h2>
16 * The argument to the --port option for the [/help?cmd=ui | fossil ui] and
17

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button