Fossil SCM

Pull the SQLite 3.7.15 beta from upstream for testing.

drh 2012-12-05 15:47 trunk
Commit 0eb3d8e828ef580aa65f12a9c42c259bcdc01e50
3 files changed +9 -5 +173 -42 +18 -1
+9 -5
--- src/shell.c
+++ src/shell.c
@@ -304,11 +304,11 @@
304304
}
305305
306306
/*
307307
** A global char* and an SQL function to access its current value
308308
** from within an SQL statement. This program used to use the
309
-** sqlite_exec_printf() API to substitute a string into an SQL statement.
309
+** sqlite_exec_printf() API to substitue a string into an SQL statement.
310310
** The correct way to do this with sqlite3 is to use the bind API, but
311311
** since the shell is built around the callback paradigm it would be a lot
312312
** of work. Instead just use this hack, which is quite harmless.
313313
*/
314314
static const char *zShellStatic = 0;
@@ -539,10 +539,13 @@
539539
fputc('"', out);
540540
while( (c = *(z++))!=0 ){
541541
if( c=='\\' ){
542542
fputc(c, out);
543543
fputc(c, out);
544
+ }else if( c=='"' ){
545
+ fputc('\\', out);
546
+ fputc('"', out);
544547
}else if( c=='\t' ){
545548
fputc('\\', out);
546549
fputc('t', out);
547550
}else if( c=='\n' ){
548551
fputc('\\', out);
@@ -794,18 +797,18 @@
794797
}
795798
case MODE_Tcl: {
796799
if( p->cnt++==0 && p->showHeader ){
797800
for(i=0; i<nArg; i++){
798801
output_c_string(p->out,azCol[i] ? azCol[i] : "");
799
- fprintf(p->out, "%s", p->separator);
802
+ if(i<nArg-1) fprintf(p->out, "%s", p->separator);
800803
}
801804
fprintf(p->out,"\n");
802805
}
803806
if( azArg==0 ) break;
804807
for(i=0; i<nArg; i++){
805808
output_c_string(p->out, azArg[i] ? azArg[i] : p->nullvalue);
806
- fprintf(p->out, "%s", p->separator);
809
+ if(i<nArg-1) fprintf(p->out, "%s", p->separator);
807810
}
808811
fprintf(p->out,"\n");
809812
break;
810813
}
811814
case MODE_Csv: {
@@ -1148,11 +1151,11 @@
11481151
zSql = zLeftover;
11491152
while( IsSpace(zSql[0]) ) zSql++;
11501153
continue;
11511154
}
11521155
1153
- /* save off the prepared statement handle and reset row count */
1156
+ /* save off the prepared statment handle and reset row count */
11541157
if( pArg ){
11551158
pArg->pStmt = pStmt;
11561159
pArg->cnt = 0;
11571160
}
11581161
@@ -2016,10 +2019,11 @@
20162019
p->mode = MODE_List;
20172020
}else if( n2==4 && strncmp(azArg[1],"html",n2)==0 ){
20182021
p->mode = MODE_Html;
20192022
}else if( n2==3 && strncmp(azArg[1],"tcl",n2)==0 ){
20202023
p->mode = MODE_Tcl;
2024
+ sqlite3_snprintf(sizeof(p->separator), p->separator, " ");
20212025
}else if( n2==3 && strncmp(azArg[1],"csv",n2)==0 ){
20222026
p->mode = MODE_Csv;
20232027
sqlite3_snprintf(sizeof(p->separator), p->separator, ",");
20242028
}else if( n2==4 && strncmp(azArg[1],"tabs",n2)==0 ){
20252029
p->mode = MODE_List;
@@ -2709,11 +2713,11 @@
27092713
fprintf(stderr, "Error: incomplete SQL: %s\n", zSql);
27102714
}
27112715
free(zSql);
27122716
}
27132717
free(zLine);
2714
- return errCnt;
2718
+ return errCnt>0;
27152719
}
27162720
27172721
/*
27182722
** Return a pathname which is the user's home directory. A
27192723
** 0 return indicates an error of some kind.
27202724
--- src/shell.c
+++ src/shell.c
@@ -304,11 +304,11 @@
304 }
305
306 /*
307 ** A global char* and an SQL function to access its current value
308 ** from within an SQL statement. This program used to use the
309 ** sqlite_exec_printf() API to substitute a string into an SQL statement.
310 ** The correct way to do this with sqlite3 is to use the bind API, but
311 ** since the shell is built around the callback paradigm it would be a lot
312 ** of work. Instead just use this hack, which is quite harmless.
313 */
314 static const char *zShellStatic = 0;
@@ -539,10 +539,13 @@
539 fputc('"', out);
540 while( (c = *(z++))!=0 ){
541 if( c=='\\' ){
542 fputc(c, out);
543 fputc(c, out);
 
 
 
544 }else if( c=='\t' ){
545 fputc('\\', out);
546 fputc('t', out);
547 }else if( c=='\n' ){
548 fputc('\\', out);
@@ -794,18 +797,18 @@
794 }
795 case MODE_Tcl: {
796 if( p->cnt++==0 && p->showHeader ){
797 for(i=0; i<nArg; i++){
798 output_c_string(p->out,azCol[i] ? azCol[i] : "");
799 fprintf(p->out, "%s", p->separator);
800 }
801 fprintf(p->out,"\n");
802 }
803 if( azArg==0 ) break;
804 for(i=0; i<nArg; i++){
805 output_c_string(p->out, azArg[i] ? azArg[i] : p->nullvalue);
806 fprintf(p->out, "%s", p->separator);
807 }
808 fprintf(p->out,"\n");
809 break;
810 }
811 case MODE_Csv: {
@@ -1148,11 +1151,11 @@
1148 zSql = zLeftover;
1149 while( IsSpace(zSql[0]) ) zSql++;
1150 continue;
1151 }
1152
1153 /* save off the prepared statement handle and reset row count */
1154 if( pArg ){
1155 pArg->pStmt = pStmt;
1156 pArg->cnt = 0;
1157 }
1158
@@ -2016,10 +2019,11 @@
2016 p->mode = MODE_List;
2017 }else if( n2==4 && strncmp(azArg[1],"html",n2)==0 ){
2018 p->mode = MODE_Html;
2019 }else if( n2==3 && strncmp(azArg[1],"tcl",n2)==0 ){
2020 p->mode = MODE_Tcl;
 
2021 }else if( n2==3 && strncmp(azArg[1],"csv",n2)==0 ){
2022 p->mode = MODE_Csv;
2023 sqlite3_snprintf(sizeof(p->separator), p->separator, ",");
2024 }else if( n2==4 && strncmp(azArg[1],"tabs",n2)==0 ){
2025 p->mode = MODE_List;
@@ -2709,11 +2713,11 @@
2709 fprintf(stderr, "Error: incomplete SQL: %s\n", zSql);
2710 }
2711 free(zSql);
2712 }
2713 free(zLine);
2714 return errCnt;
2715 }
2716
2717 /*
2718 ** Return a pathname which is the user's home directory. A
2719 ** 0 return indicates an error of some kind.
2720
--- src/shell.c
+++ src/shell.c
@@ -304,11 +304,11 @@
304 }
305
306 /*
307 ** A global char* and an SQL function to access its current value
308 ** from within an SQL statement. This program used to use the
309 ** sqlite_exec_printf() API to substitue a string into an SQL statement.
310 ** The correct way to do this with sqlite3 is to use the bind API, but
311 ** since the shell is built around the callback paradigm it would be a lot
312 ** of work. Instead just use this hack, which is quite harmless.
313 */
314 static const char *zShellStatic = 0;
@@ -539,10 +539,13 @@
539 fputc('"', out);
540 while( (c = *(z++))!=0 ){
541 if( c=='\\' ){
542 fputc(c, out);
543 fputc(c, out);
544 }else if( c=='"' ){
545 fputc('\\', out);
546 fputc('"', out);
547 }else if( c=='\t' ){
548 fputc('\\', out);
549 fputc('t', out);
550 }else if( c=='\n' ){
551 fputc('\\', out);
@@ -794,18 +797,18 @@
797 }
798 case MODE_Tcl: {
799 if( p->cnt++==0 && p->showHeader ){
800 for(i=0; i<nArg; i++){
801 output_c_string(p->out,azCol[i] ? azCol[i] : "");
802 if(i<nArg-1) fprintf(p->out, "%s", p->separator);
803 }
804 fprintf(p->out,"\n");
805 }
806 if( azArg==0 ) break;
807 for(i=0; i<nArg; i++){
808 output_c_string(p->out, azArg[i] ? azArg[i] : p->nullvalue);
809 if(i<nArg-1) fprintf(p->out, "%s", p->separator);
810 }
811 fprintf(p->out,"\n");
812 break;
813 }
814 case MODE_Csv: {
@@ -1148,11 +1151,11 @@
1151 zSql = zLeftover;
1152 while( IsSpace(zSql[0]) ) zSql++;
1153 continue;
1154 }
1155
1156 /* save off the prepared statment handle and reset row count */
1157 if( pArg ){
1158 pArg->pStmt = pStmt;
1159 pArg->cnt = 0;
1160 }
1161
@@ -2016,10 +2019,11 @@
2019 p->mode = MODE_List;
2020 }else if( n2==4 && strncmp(azArg[1],"html",n2)==0 ){
2021 p->mode = MODE_Html;
2022 }else if( n2==3 && strncmp(azArg[1],"tcl",n2)==0 ){
2023 p->mode = MODE_Tcl;
2024 sqlite3_snprintf(sizeof(p->separator), p->separator, " ");
2025 }else if( n2==3 && strncmp(azArg[1],"csv",n2)==0 ){
2026 p->mode = MODE_Csv;
2027 sqlite3_snprintf(sizeof(p->separator), p->separator, ",");
2028 }else if( n2==4 && strncmp(azArg[1],"tabs",n2)==0 ){
2029 p->mode = MODE_List;
@@ -2709,11 +2713,11 @@
2713 fprintf(stderr, "Error: incomplete SQL: %s\n", zSql);
2714 }
2715 free(zSql);
2716 }
2717 free(zLine);
2718 return errCnt>0;
2719 }
2720
2721 /*
2722 ** Return a pathname which is the user's home directory. A
2723 ** 0 return indicates an error of some kind.
2724
+173 -42
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -673,11 +673,11 @@
673673
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
674674
** [sqlite_version()] and [sqlite_source_id()].
675675
*/
676676
#define SQLITE_VERSION "3.7.15"
677677
#define SQLITE_VERSION_NUMBER 3007015
678
-#define SQLITE_SOURCE_ID "2012-11-09 21:40:02 5a3b07f0f5dfae7eea870303f52f37d6a17f1da2"
678
+#define SQLITE_SOURCE_ID "2012-12-05 14:31:13 9f6c68856b694373b7ffb124abd996e519ba5921"
679679
680680
/*
681681
** CAPI3REF: Run-Time Library Version Numbers
682682
** KEYWORDS: sqlite3_version, sqlite3_sourceid
683683
**
@@ -2162,10 +2162,26 @@
21622162
** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
21632163
** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
21642164
** <dd> These options are obsolete and should not be used by new code.
21652165
** They are retained for backwards compatibility but are now no-ops.
21662166
** </dl>
2167
+**
2168
+** [[SQLITE_CONFIG_SQLLOG]]
2169
+** <dt>SQLITE_CONFIG_SQLLOG
2170
+** <dd>This option is only available if sqlite is compiled with the
2171
+** SQLITE_ENABLE_SQLLOG pre-processor macro defined. The first argument should
2172
+** be a pointer to a function of type void(*)(void*,sqlite3*,const char*, int).
2173
+** The second should be of type (void*). The callback is invoked by the library
2174
+** in three separate circumstances, identified by the value passed as the
2175
+** fourth parameter. If the fourth parameter is 0, then the database connection
2176
+** passed as the second argument has just been opened. The third argument
2177
+** points to a buffer containing the name of the main database file. If the
2178
+** fourth parameter is 1, then the SQL statement that the third parameter
2179
+** points to has just been executed. Or, if the fourth parameter is 2, then
2180
+** the connection being passed as the second parameter is being closed. The
2181
+** third parameter is passed NULL In this case.
2182
+** </dl>
21672183
*/
21682184
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
21692185
#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
21702186
#define SQLITE_CONFIG_SERIALIZED 3 /* nil */
21712187
#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */
@@ -2183,10 +2199,11 @@
21832199
#define SQLITE_CONFIG_LOG 16 /* xFunc, void* */
21842200
#define SQLITE_CONFIG_URI 17 /* int */
21852201
#define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */
21862202
#define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */
21872203
#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */
2204
+#define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */
21882205
21892206
/*
21902207
** CAPI3REF: Database Connection Configuration Options
21912208
**
21922209
** These constants are the available integer configuration options that
@@ -11557,10 +11574,14 @@
1155711574
sqlite3_mutex *pInitMutex; /* Mutex used by sqlite3_initialize() */
1155811575
int nRefInitMutex; /* Number of users of pInitMutex */
1155911576
void (*xLog)(void*,int,const char*); /* Function for logging */
1156011577
void *pLogArg; /* First argument to xLog() */
1156111578
int bLocaltimeFault; /* True to fail localtime() calls */
11579
+#ifdef SQLITE_ENABLE_SQLLOG
11580
+ void(*xSqllog)(void*,sqlite3*,const char*, int);
11581
+ void *pSqllogArg;
11582
+#endif
1156211583
};
1156311584
1156411585
/*
1156511586
** Context pointer passed down through the tree-walk.
1156611587
*/
@@ -12291,12 +12312,14 @@
1229112312
1229212313
#ifdef SQLITE_ENABLE_ATOMIC_WRITE
1229312314
SQLITE_PRIVATE int sqlite3JournalOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int);
1229412315
SQLITE_PRIVATE int sqlite3JournalSize(sqlite3_vfs *);
1229512316
SQLITE_PRIVATE int sqlite3JournalCreate(sqlite3_file *);
12317
+SQLITE_PRIVATE int sqlite3JournalExists(sqlite3_file *p);
1229612318
#else
1229712319
#define sqlite3JournalSize(pVfs) ((pVfs)->szOsFile)
12320
+ #define sqlite3JournalExists(p) 1
1229812321
#endif
1229912322
1230012323
SQLITE_PRIVATE void sqlite3MemJournalOpen(sqlite3_file *);
1230112324
SQLITE_PRIVATE int sqlite3MemJournalSize(void);
1230212325
SQLITE_PRIVATE int sqlite3IsMemJournal(sqlite3_file *);
@@ -12563,10 +12586,14 @@
1256312586
0, /* pInitMutex */
1256412587
0, /* nRefInitMutex */
1256512588
0, /* xLog */
1256612589
0, /* pLogArg */
1256712590
0, /* bLocaltimeFault */
12591
+#ifdef SQLITE_ENABLE_SQLLOG
12592
+ 0, /* xSqllog */
12593
+ 0 /* pSqllogArg */
12594
+#endif
1256812595
};
1256912596
1257012597
1257112598
/*
1257212599
** Hash table for global functions - functions common to all
@@ -22686,10 +22713,17 @@
2268622713
** * Definitions of sqlite3_vfs objects for all locking methods
2268722714
** plus implementations of sqlite3_os_init() and sqlite3_os_end().
2268822715
*/
2268922716
#if SQLITE_OS_UNIX /* This file is used on unix only */
2269022717
22718
+/* Use posix_fallocate() if it is available
22719
+*/
22720
+#if !defined(HAVE_POSIX_FALLOCATE) \
22721
+ && (_XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L)
22722
+# define HAVE_POSIX_FALLOCATE 1
22723
+#endif
22724
+
2269122725
/*
2269222726
** There are various methods for file locking used for concurrency
2269322727
** control:
2269422728
**
2269522729
** 1. POSIX locking (the default),
@@ -27016,15 +27050,23 @@
2701627050
**
2701727051
** Alternatively, if bExtend is true, use ftruncate() to allocate
2701827052
** the requested memory region.
2701927053
*/
2702027054
if( !bExtend ) goto shmpage_out;
27055
+#if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE
27056
+ if( osFallocate(pShmNode->h, sStat.st_size, nByte)!=0 ){
27057
+ rc = unixLogError(SQLITE_IOERR_SHMSIZE, "fallocate",
27058
+ pShmNode->zFilename);
27059
+ goto shmpage_out;
27060
+ }
27061
+#else
2702127062
if( robust_ftruncate(pShmNode->h, nByte) ){
2702227063
rc = unixLogError(SQLITE_IOERR_SHMSIZE, "ftruncate",
2702327064
pShmNode->zFilename);
2702427065
goto shmpage_out;
2702527066
}
27067
+#endif
2702627068
}
2702727069
}
2702827070
2702927071
/* Map the requested memory region into this processes address space. */
2703027072
apNew = (char **)sqlite3_realloc(
@@ -33937,18 +33979,28 @@
3393733979
memset(&sAttrData, 0, sizeof(sAttrData));
3393833980
if ( osGetFileAttributesExW(zConverted, GetFileExInfoStandard,
3393933981
&sAttrData) ){
3394033982
attr = sAttrData.dwFileAttributes;
3394133983
}else{
33942
- rc = SQLITE_OK; /* Already gone? */
33984
+ lastErrno = osGetLastError();
33985
+ if( lastErrno==ERROR_FILE_NOT_FOUND || lastErrno==ERROR_PATH_NOT_FOUND ){
33986
+ rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */
33987
+ }else{
33988
+ rc = SQLITE_ERROR;
33989
+ }
3394333990
break;
3394433991
}
3394533992
#else
3394633993
attr = osGetFileAttributesW(zConverted);
3394733994
#endif
3394833995
if ( attr==INVALID_FILE_ATTRIBUTES ){
33949
- rc = SQLITE_OK; /* Already gone? */
33996
+ lastErrno = osGetLastError();
33997
+ if( lastErrno==ERROR_FILE_NOT_FOUND || lastErrno==ERROR_PATH_NOT_FOUND ){
33998
+ rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */
33999
+ }else{
34000
+ rc = SQLITE_ERROR;
34001
+ }
3395034002
break;
3395134003
}
3395234004
if ( attr&FILE_ATTRIBUTE_DIRECTORY ){
3395334005
rc = SQLITE_ERROR; /* Files only. */
3395434006
break;
@@ -33966,11 +34018,16 @@
3396634018
#ifdef SQLITE_WIN32_HAS_ANSI
3396734019
else{
3396834020
do {
3396934021
attr = osGetFileAttributesA(zConverted);
3397034022
if ( attr==INVALID_FILE_ATTRIBUTES ){
33971
- rc = SQLITE_OK; /* Already gone? */
34023
+ lastErrno = osGetLastError();
34024
+ if( lastErrno==ERROR_FILE_NOT_FOUND || lastErrno==ERROR_PATH_NOT_FOUND ){
34025
+ rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */
34026
+ }else{
34027
+ rc = SQLITE_ERROR;
34028
+ }
3397234029
break;
3397334030
}
3397434031
if ( attr&FILE_ATTRIBUTE_DIRECTORY ){
3397534032
rc = SQLITE_ERROR; /* Files only. */
3397634033
break;
@@ -33984,11 +34041,11 @@
3398434041
break;
3398534042
}
3398634043
} while(1);
3398734044
}
3398834045
#endif
33989
- if( rc ){
34046
+ if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){
3399034047
rc = winLogError(SQLITE_IOERR_DELETE, lastErrno,
3399134048
"winDelete", zFilename);
3399234049
}else{
3399334050
logIoerr(cnt);
3399434051
}
@@ -39178,16 +39235,17 @@
3917839235
/* This branch may be executed with Pager.journalMode==MEMORY if
3917939236
** a hot-journal was just rolled back. In this case the journal
3918039237
** file should be closed and deleted. If this connection writes to
3918139238
** the database file, it will do so using an in-memory journal.
3918239239
*/
39240
+ int bDelete = (!pPager->tempFile && sqlite3JournalExists(pPager->jfd));
3918339241
assert( pPager->journalMode==PAGER_JOURNALMODE_DELETE
3918439242
|| pPager->journalMode==PAGER_JOURNALMODE_MEMORY
3918539243
|| pPager->journalMode==PAGER_JOURNALMODE_WAL
3918639244
);
3918739245
sqlite3OsClose(pPager->jfd);
39188
- if( !pPager->tempFile ){
39246
+ if( bDelete ){
3918939247
rc = sqlite3OsDelete(pPager->pVfs, pPager->zJournal, 0);
3919039248
}
3919139249
}
3919239250
}
3919339251
@@ -40722,11 +40780,11 @@
4072240780
4072340781
if( isOpen(pPager->fd) ){
4072440782
void **ap = (void **)&pPager->xBusyHandler;
4072540783
assert( ((int(*)(void *))(ap[0]))==xBusyHandler );
4072640784
assert( ap[1]==pBusyHandlerArg );
40727
- sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_BUSYHANDLER, (void *)ap);
40785
+ sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_BUSYHANDLER, (void *)ap);
4072840786
}
4072940787
}
4073040788
4073140789
/*
4073240790
** Change the page size used by the Pager object. The new page size
@@ -58521,11 +58579,11 @@
5852158579
** Remember the SQL string for a prepared statement.
5852258580
*/
5852358581
SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepareV2){
5852458582
assert( isPrepareV2==1 || isPrepareV2==0 );
5852558583
if( p==0 ) return;
58526
-#ifdef SQLITE_OMIT_TRACE
58584
+#if defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_ENABLE_SQLLOG)
5852758585
if( !isPrepareV2 ) return;
5852858586
#endif
5852958587
assert( p->zSql==0 );
5853058588
p->zSql = sqlite3DbStrNDup(p->db, z, n);
5853158589
p->isPrepareV2 = (u8)isPrepareV2;
@@ -59191,10 +59249,11 @@
5919159249
assert( addr<p->nOp );
5919259250
if( addr<0 ){
5919359251
addr = p->nOp - 1;
5919459252
}
5919559253
pOp = &p->aOp[addr];
59254
+ assert( pOp->p4type==P4_NOTUSED || pOp->p4type==P4_INT32 );
5919659255
freeP4(db, pOp->p4type, pOp->p4.p);
5919759256
pOp->p4.p = 0;
5919859257
if( n==P4_INT32 ){
5919959258
/* Note: this cast is safe, because the origin data point was an int
5920059259
** that was cast to a (const char *). */
@@ -60794,10 +60853,31 @@
6079460853
sqlite3Error(db, rc, 0);
6079560854
}
6079660855
return rc;
6079760856
}
6079860857
60858
+#ifdef SQLITE_ENABLE_SQLLOG
60859
+/*
60860
+** If an SQLITE_CONFIG_SQLLOG hook is registered and the VM has been run,
60861
+** invoke it.
60862
+*/
60863
+static void vdbeInvokeSqllog(Vdbe *v){
60864
+ if( sqlite3GlobalConfig.xSqllog && v->rc==SQLITE_OK && v->zSql && v->pc>=0 ){
60865
+ char *zExpanded = sqlite3VdbeExpandSql(v, v->zSql);
60866
+ assert( v->db->init.busy==0 );
60867
+ if( zExpanded ){
60868
+ sqlite3GlobalConfig.xSqllog(
60869
+ sqlite3GlobalConfig.pSqllogArg, v->db, zExpanded, 1
60870
+ );
60871
+ sqlite3DbFree(v->db, zExpanded);
60872
+ }
60873
+ }
60874
+}
60875
+#else
60876
+# define vdbeInvokeSqllog(x)
60877
+#endif
60878
+
6079960879
/*
6080060880
** Clean up a VDBE after execution but do not delete the VDBE just yet.
6080160881
** Write any error messages into *pzErrMsg. Return the result code.
6080260882
**
6080360883
** After this routine is run, the VDBE should be ready to be executed
@@ -60821,10 +60901,11 @@
6082160901
** and error message from the VDBE into the main database structure. But
6082260902
** if the VDBE has just been set to run but has not actually executed any
6082360903
** instructions yet, leave the main database error information unchanged.
6082460904
*/
6082560905
if( p->pc>=0 ){
60906
+ vdbeInvokeSqllog(p);
6082660907
sqlite3VdbeTransferError(p);
6082760908
sqlite3DbFree(db, p->zErrMsg);
6082860909
p->zErrMsg = 0;
6082960910
if( p->runOnlyOnce ) p->expired = 1;
6083060911
}else if( p->rc && p->expired ){
@@ -60927,11 +61008,11 @@
6092761008
sqlite3DbFree(db, p->aLabel);
6092861009
sqlite3DbFree(db, p->aColName);
6092961010
sqlite3DbFree(db, p->zSql);
6093061011
sqlite3DbFree(db, p->pFree);
6093161012
#if defined(SQLITE_ENABLE_TREE_EXPLAIN)
60932
- sqlite3DbFree(db, p->zExplain);
61013
+ sqlite3_free(p->zExplain);
6093361014
sqlite3DbFree(db, p->pExplain);
6093461015
#endif
6093561016
}
6093661017
6093761018
/*
@@ -67163,11 +67244,11 @@
6716367244
u.az.pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);
6716467245
u.az.pCx->isIndex = !u.az.pCx->isTable;
6716567246
break;
6716667247
}
6716767248
67168
-/* Opcode: OpenSorter P1 P2 * P4 *
67249
+/* Opcode: SorterOpen P1 P2 * P4 *
6716967250
**
6717067251
** This opcode works like OP_OpenEphemeral except that it opens
6717167252
** a transient index that is specifically designed to sort large
6717267253
** tables using an external merge-sort algorithm.
6717367254
*/
@@ -71947,10 +72028,20 @@
7194772028
if( p->pMethods!=&JournalFileMethods ){
7194872029
return SQLITE_OK;
7194972030
}
7195072031
return createFile((JournalFile *)p);
7195172032
}
72033
+
72034
+/*
72035
+** The file-handle passed as the only argument is guaranteed to be an open
72036
+** file. It may or may not be of class JournalFile. If the file is a
72037
+** JournalFile, and the underlying file on disk has not yet been opened,
72038
+** return 0. Otherwise, return 1.
72039
+*/
72040
+SQLITE_PRIVATE int sqlite3JournalExists(sqlite3_file *p){
72041
+ return (p->pMethods!=&JournalFileMethods || ((JournalFile *)p)->pReal!=0);
72042
+}
7195272043
7195372044
/*
7195472045
** Return the number of bytes required to store a JournalFile that uses vfs
7195572046
** pVfs to create the underlying on-disk files.
7195672047
*/
@@ -80206,11 +80297,11 @@
8020680297
sqlite3ErrorMsg(pFix->pParse,
8020780298
"%s %T cannot reference objects in database %s",
8020880299
pFix->zType, pFix->pName, pItem->zDatabase);
8020980300
return 1;
8021080301
}
80211
- sqlite3_free(pItem->zDatabase);
80302
+ sqlite3DbFree(pFix->pParse->db, pItem->zDatabase);
8021280303
pItem->zDatabase = 0;
8021380304
pItem->pSchema = pFix->pSchema;
8021480305
#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)
8021580306
if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1;
8021680307
if( sqlite3FixExpr(pFix, pItem->pOn) ) return 1;
@@ -85737,10 +85828,11 @@
8573785828
int nNeedle;
8573885829
int typeHaystack, typeNeedle;
8573985830
int N = 1;
8574085831
int isText;
8574185832
85833
+ UNUSED_PARAMETER(argc);
8574285834
typeHaystack = sqlite3_value_type(argv[0]);
8574385835
typeNeedle = sqlite3_value_type(argv[1]);
8574485836
if( typeHaystack==SQLITE_NULL || typeNeedle==SQLITE_NULL ) return;
8574585837
nHaystack = sqlite3_value_bytes(argv[0]);
8574685838
nNeedle = sqlite3_value_bytes(argv[1]);
@@ -88450,11 +88542,11 @@
8845088542
int iDb, /* The database index in sqlite3.aDb[] */
8845188543
Table *pTab, /* The table to be opened */
8845288544
int opcode /* OP_OpenRead or OP_OpenWrite */
8845388545
){
8845488546
Vdbe *v;
88455
- if( IsVirtual(pTab) ) return;
88547
+ assert( !IsVirtual(pTab) );
8845688548
v = sqlite3GetVdbe(p);
8845788549
assert( opcode==OP_OpenWrite || opcode==OP_OpenRead );
8845888550
sqlite3TableLock(p, iDb, pTab->tnum, (opcode==OP_OpenWrite)?1:0, pTab->zName);
8845988551
sqlite3VdbeAddOp3(v, opcode, iCur, pTab->tnum, iDb);
8846088552
sqlite3VdbeChangeP4(v, -1, SQLITE_INT_TO_PTR(pTab->nCol), P4_INT32);
@@ -107515,10 +107607,12 @@
107515107607
#ifndef SQLITE_OMIT_VIRTUALTABLE
107516107608
if( (pLevel->plan.wsFlags & WHERE_VIRTUALTABLE)!=0 ){
107517107609
const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);
107518107610
int iCur = pTabItem->iCursor;
107519107611
sqlite3VdbeAddOp4(v, OP_VOpen, iCur, 0, 0, pVTab, P4_VTAB);
107612
+ }else if( IsVirtual(pTab) ){
107613
+ /* noop */
107520107614
}else
107521107615
#endif
107522107616
if( (pLevel->plan.wsFlags & WHERE_IDX_ONLY)==0
107523107617
&& (wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0 ){
107524107618
int op = pWInfo->okOnePass ? OP_OpenWrite : OP_OpenRead;
@@ -112550,10 +112644,17 @@
112550112644
** to sqlite3_initialize() should be a no-op. But the initialization
112551112645
** must be complete. So isInit must not be set until the very end
112552112646
** of this routine.
112553112647
*/
112554112648
if( sqlite3GlobalConfig.isInit ) return SQLITE_OK;
112649
+
112650
+#ifdef SQLITE_ENABLE_SQLLOG
112651
+ {
112652
+ extern void sqlite3_init_sqllog(void);
112653
+ sqlite3_init_sqllog();
112654
+ }
112655
+#endif
112555112656
112556112657
/* Make sure the mutex subsystem is initialized. If unable to
112557112658
** initialize the mutex subsystem, return early with the error.
112558112659
** If the system is so sick that we are unable to allocate a mutex,
112559112660
** there is not much SQLite is going to be able to do.
@@ -112898,10 +112999,19 @@
112898112999
112899113000
case SQLITE_CONFIG_COVERING_INDEX_SCAN: {
112900113001
sqlite3GlobalConfig.bUseCis = va_arg(ap, int);
112901113002
break;
112902113003
}
113004
+
113005
+#ifdef SQLITE_ENABLE_SQLLOG
113006
+ case SQLITE_CONFIG_SQLLOG: {
113007
+ typedef void(*SQLLOGFUNC_t)(void*, sqlite3*, const char*, int);
113008
+ sqlite3GlobalConfig.xSqllog = va_arg(ap, SQLLOGFUNC_t);
113009
+ sqlite3GlobalConfig.pSqllogArg = va_arg(ap, void *);
113010
+ break;
113011
+ }
113012
+#endif
112903113013
112904113014
default: {
112905113015
rc = SQLITE_ERROR;
112906113016
break;
112907113017
}
@@ -113237,10 +113347,17 @@
113237113347
sqlite3Error(db, SQLITE_BUSY, "unable to close due to unfinalized "
113238113348
"statements or unfinished backups");
113239113349
sqlite3_mutex_leave(db->mutex);
113240113350
return SQLITE_BUSY;
113241113351
}
113352
+
113353
+#ifdef SQLITE_ENABLE_SQLLOG
113354
+ if( sqlite3GlobalConfig.xSqllog ){
113355
+ /* Closing the handle. Fourth parameter is passed the value 2. */
113356
+ sqlite3GlobalConfig.xSqllog(sqlite3GlobalConfig.pSqllogArg, db, 0, 2);
113357
+ }
113358
+#endif
113242113359
113243113360
/* Convert the connection into a zombie and then close it.
113244113361
*/
113245113362
db->magic = SQLITE_MAGIC_ZOMBIE;
113246113363
sqlite3LeaveMutexAndCloseZombie(db);
@@ -114870,10 +114987,17 @@
114870114987
db = 0;
114871114988
}else if( rc!=SQLITE_OK ){
114872114989
db->magic = SQLITE_MAGIC_SICK;
114873114990
}
114874114991
*ppDb = db;
114992
+#ifdef SQLITE_ENABLE_SQLLOG
114993
+ if( sqlite3GlobalConfig.xSqllog ){
114994
+ /* Opening a db handle. Fourth parameter is passed 0. */
114995
+ void *pArg = sqlite3GlobalConfig.pSqllogArg;
114996
+ sqlite3GlobalConfig.xSqllog(pArg, db, zFilename, 0);
114997
+ }
114998
+#endif
114875114999
return sqlite3ApiExit(0, rc);
114876115000
}
114877115001
114878115002
/*
114879115003
** Open a new database handle.
@@ -126142,11 +126266,11 @@
126142126266
static int fts3PendingTermsAdd(
126143126267
Fts3Table *p, /* Table into which text will be inserted */
126144126268
int iLangid, /* Language id to use */
126145126269
const char *zText, /* Text of document to be inserted */
126146126270
int iCol, /* Column into which text is being inserted */
126147
- u32 *pnWord /* OUT: Number of tokens inserted */
126271
+ u32 *pnWord /* IN/OUT: Incr. by number tokens inserted */
126148126272
){
126149126273
int rc;
126150126274
int iStart = 0;
126151126275
int iEnd = 0;
126152126276
int iPos = 0;
@@ -126206,11 +126330,11 @@
126206126330
);
126207126331
}
126208126332
}
126209126333
126210126334
pModule->xClose(pCsr);
126211
- *pnWord = nWord;
126335
+ *pnWord += nWord;
126212126336
return (rc==SQLITE_DONE ? SQLITE_OK : rc);
126213126337
}
126214126338
126215126339
/*
126216126340
** Calling this function indicates that subsequent calls to
@@ -126410,15 +126534,17 @@
126410126534
*/
126411126535
static void fts3DeleteTerms(
126412126536
int *pRC, /* Result code */
126413126537
Fts3Table *p, /* The FTS table to delete from */
126414126538
sqlite3_value *pRowid, /* The docid to be deleted */
126415
- u32 *aSz /* Sizes of deleted document written here */
126539
+ u32 *aSz, /* Sizes of deleted document written here */
126540
+ int *pbFound /* OUT: Set to true if row really does exist */
126416126541
){
126417126542
int rc;
126418126543
sqlite3_stmt *pSelect;
126419126544
126545
+ assert( *pbFound==0 );
126420126546
if( *pRC ) return;
126421126547
rc = fts3SqlStmt(p, SQL_SELECT_CONTENT_BY_ROWID, &pSelect, &pRowid);
126422126548
if( rc==SQLITE_OK ){
126423126549
if( SQLITE_ROW==sqlite3_step(pSelect) ){
126424126550
int i;
@@ -126432,10 +126558,11 @@
126432126558
if( rc!=SQLITE_OK ){
126433126559
sqlite3_reset(pSelect);
126434126560
*pRC = rc;
126435126561
return;
126436126562
}
126563
+ *pbFound = 1;
126437126564
}
126438126565
rc = sqlite3_reset(pSelect);
126439126566
}else{
126440126567
sqlite3_reset(pSelect);
126441126568
}
@@ -128656,11 +128783,11 @@
128656128783
128657128784
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
128658128785
int iCol;
128659128786
int iLangid = langidFromSelect(p, pStmt);
128660128787
rc = fts3PendingTermsDocid(p, iLangid, sqlite3_column_int64(pStmt, 0));
128661
- aSz[p->nColumn] = 0;
128788
+ memset(aSz, 0, sizeof(aSz[0]) * (p->nColumn+1));
128662128789
for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){
128663128790
const char *z = (const char *) sqlite3_column_text(pStmt, iCol+1);
128664128791
rc = fts3PendingTermsAdd(p, iLangid, z, iCol, &aSz[iCol]);
128665128792
aSz[p->nColumn] += sqlite3_column_bytes(pStmt, iCol+1);
128666128793
}
@@ -130560,32 +130687,36 @@
130560130687
** of subsiduary data structures accordingly.
130561130688
*/
130562130689
static int fts3DeleteByRowid(
130563130690
Fts3Table *p,
130564130691
sqlite3_value *pRowid,
130565
- int *pnDoc,
130692
+ int *pnChng, /* IN/OUT: Decrement if row is deleted */
130566130693
u32 *aSzDel
130567130694
){
130568
- int isEmpty = 0;
130569
- int rc = fts3IsEmpty(p, pRowid, &isEmpty);
130570
- if( rc==SQLITE_OK ){
130571
- if( isEmpty ){
130572
- /* Deleting this row means the whole table is empty. In this case
130573
- ** delete the contents of all three tables and throw away any
130574
- ** data in the pendingTerms hash table. */
130575
- rc = fts3DeleteAll(p, 1);
130576
- *pnDoc = *pnDoc - 1;
130577
- }else{
130578
- fts3DeleteTerms(&rc, p, pRowid, aSzDel);
130579
- if( p->zContentTbl==0 ){
130580
- fts3SqlExec(&rc, p, SQL_DELETE_CONTENT, &pRowid);
130581
- if( sqlite3_changes(p->db) ) *pnDoc = *pnDoc - 1;
130582
- }else{
130583
- *pnDoc = *pnDoc - 1;
130584
- }
130585
- if( p->bHasDocsize ){
130586
- fts3SqlExec(&rc, p, SQL_DELETE_DOCSIZE, &pRowid);
130695
+ int rc = SQLITE_OK; /* Return code */
130696
+ int bFound = 0; /* True if *pRowid really is in the table */
130697
+
130698
+ fts3DeleteTerms(&rc, p, pRowid, aSzDel, &bFound);
130699
+ if( bFound && rc==SQLITE_OK ){
130700
+ int isEmpty = 0; /* Deleting *pRowid leaves the table empty */
130701
+ rc = fts3IsEmpty(p, pRowid, &isEmpty);
130702
+ if( rc==SQLITE_OK ){
130703
+ if( isEmpty ){
130704
+ /* Deleting this row means the whole table is empty. In this case
130705
+ ** delete the contents of all three tables and throw away any
130706
+ ** data in the pendingTerms hash table. */
130707
+ rc = fts3DeleteAll(p, 1);
130708
+ *pnChng = 0;
130709
+ memset(aSzDel, 0, sizeof(u32) * (p->nColumn+1) * 2);
130710
+ }else{
130711
+ *pnChng = *pnChng - 1;
130712
+ if( p->zContentTbl==0 ){
130713
+ fts3SqlExec(&rc, p, SQL_DELETE_CONTENT, &pRowid);
130714
+ }
130715
+ if( p->bHasDocsize ){
130716
+ fts3SqlExec(&rc, p, SQL_DELETE_DOCSIZE, &pRowid);
130717
+ }
130587130718
}
130588130719
}
130589130720
}
130590130721
130591130722
return rc;
@@ -130612,11 +130743,11 @@
130612130743
){
130613130744
Fts3Table *p = (Fts3Table *)pVtab;
130614130745
int rc = SQLITE_OK; /* Return Code */
130615130746
int isRemove = 0; /* True for an UPDATE or DELETE */
130616130747
u32 *aSzIns = 0; /* Sizes of inserted documents */
130617
- u32 *aSzDel; /* Sizes of deleted documents */
130748
+ u32 *aSzDel = 0; /* Sizes of deleted documents */
130618130749
int nChng = 0; /* Net change in number of documents */
130619130750
int bInsertDone = 0;
130620130751
130621130752
assert( p->pSegments==0 );
130622130753
assert(
@@ -130640,17 +130771,17 @@
130640130771
rc = SQLITE_CONSTRAINT;
130641130772
goto update_out;
130642130773
}
130643130774
130644130775
/* Allocate space to hold the change in document sizes */
130645
- aSzIns = sqlite3_malloc( sizeof(aSzIns[0])*(p->nColumn+1)*2 );
130646
- if( aSzIns==0 ){
130776
+ aSzDel = sqlite3_malloc( sizeof(aSzDel[0])*(p->nColumn+1)*2 );
130777
+ if( aSzDel==0 ){
130647130778
rc = SQLITE_NOMEM;
130648130779
goto update_out;
130649130780
}
130650
- aSzDel = &aSzIns[p->nColumn+1];
130651
- memset(aSzIns, 0, sizeof(aSzIns[0])*(p->nColumn+1)*2);
130781
+ aSzIns = &aSzDel[p->nColumn+1];
130782
+ memset(aSzDel, 0, sizeof(aSzDel[0])*(p->nColumn+1)*2);
130652130783
130653130784
/* If this is an INSERT operation, or an UPDATE that modifies the rowid
130654130785
** value, then this operation requires constraint handling.
130655130786
**
130656130787
** If the on-conflict mode is REPLACE, this means that the existing row
@@ -130731,11 +130862,11 @@
130731130862
if( p->bFts4 ){
130732130863
fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nChng);
130733130864
}
130734130865
130735130866
update_out:
130736
- sqlite3_free(aSzIns);
130867
+ sqlite3_free(aSzDel);
130737130868
sqlite3Fts3SegmentsClose(p);
130738130869
return rc;
130739130870
}
130740130871
130741130872
/*
130742130873
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -673,11 +673,11 @@
673 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
674 ** [sqlite_version()] and [sqlite_source_id()].
675 */
676 #define SQLITE_VERSION "3.7.15"
677 #define SQLITE_VERSION_NUMBER 3007015
678 #define SQLITE_SOURCE_ID "2012-11-09 21:40:02 5a3b07f0f5dfae7eea870303f52f37d6a17f1da2"
679
680 /*
681 ** CAPI3REF: Run-Time Library Version Numbers
682 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
683 **
@@ -2162,10 +2162,26 @@
2162 ** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
2163 ** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
2164 ** <dd> These options are obsolete and should not be used by new code.
2165 ** They are retained for backwards compatibility but are now no-ops.
2166 ** </dl>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2167 */
2168 #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
2169 #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
2170 #define SQLITE_CONFIG_SERIALIZED 3 /* nil */
2171 #define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */
@@ -2183,10 +2199,11 @@
2183 #define SQLITE_CONFIG_LOG 16 /* xFunc, void* */
2184 #define SQLITE_CONFIG_URI 17 /* int */
2185 #define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */
2186 #define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */
2187 #define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */
 
2188
2189 /*
2190 ** CAPI3REF: Database Connection Configuration Options
2191 **
2192 ** These constants are the available integer configuration options that
@@ -11557,10 +11574,14 @@
11557 sqlite3_mutex *pInitMutex; /* Mutex used by sqlite3_initialize() */
11558 int nRefInitMutex; /* Number of users of pInitMutex */
11559 void (*xLog)(void*,int,const char*); /* Function for logging */
11560 void *pLogArg; /* First argument to xLog() */
11561 int bLocaltimeFault; /* True to fail localtime() calls */
 
 
 
 
11562 };
11563
11564 /*
11565 ** Context pointer passed down through the tree-walk.
11566 */
@@ -12291,12 +12312,14 @@
12291
12292 #ifdef SQLITE_ENABLE_ATOMIC_WRITE
12293 SQLITE_PRIVATE int sqlite3JournalOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int);
12294 SQLITE_PRIVATE int sqlite3JournalSize(sqlite3_vfs *);
12295 SQLITE_PRIVATE int sqlite3JournalCreate(sqlite3_file *);
 
12296 #else
12297 #define sqlite3JournalSize(pVfs) ((pVfs)->szOsFile)
 
12298 #endif
12299
12300 SQLITE_PRIVATE void sqlite3MemJournalOpen(sqlite3_file *);
12301 SQLITE_PRIVATE int sqlite3MemJournalSize(void);
12302 SQLITE_PRIVATE int sqlite3IsMemJournal(sqlite3_file *);
@@ -12563,10 +12586,14 @@
12563 0, /* pInitMutex */
12564 0, /* nRefInitMutex */
12565 0, /* xLog */
12566 0, /* pLogArg */
12567 0, /* bLocaltimeFault */
 
 
 
 
12568 };
12569
12570
12571 /*
12572 ** Hash table for global functions - functions common to all
@@ -22686,10 +22713,17 @@
22686 ** * Definitions of sqlite3_vfs objects for all locking methods
22687 ** plus implementations of sqlite3_os_init() and sqlite3_os_end().
22688 */
22689 #if SQLITE_OS_UNIX /* This file is used on unix only */
22690
 
 
 
 
 
 
 
22691 /*
22692 ** There are various methods for file locking used for concurrency
22693 ** control:
22694 **
22695 ** 1. POSIX locking (the default),
@@ -27016,15 +27050,23 @@
27016 **
27017 ** Alternatively, if bExtend is true, use ftruncate() to allocate
27018 ** the requested memory region.
27019 */
27020 if( !bExtend ) goto shmpage_out;
 
 
 
 
 
 
 
27021 if( robust_ftruncate(pShmNode->h, nByte) ){
27022 rc = unixLogError(SQLITE_IOERR_SHMSIZE, "ftruncate",
27023 pShmNode->zFilename);
27024 goto shmpage_out;
27025 }
 
27026 }
27027 }
27028
27029 /* Map the requested memory region into this processes address space. */
27030 apNew = (char **)sqlite3_realloc(
@@ -33937,18 +33979,28 @@
33937 memset(&sAttrData, 0, sizeof(sAttrData));
33938 if ( osGetFileAttributesExW(zConverted, GetFileExInfoStandard,
33939 &sAttrData) ){
33940 attr = sAttrData.dwFileAttributes;
33941 }else{
33942 rc = SQLITE_OK; /* Already gone? */
 
 
 
 
 
33943 break;
33944 }
33945 #else
33946 attr = osGetFileAttributesW(zConverted);
33947 #endif
33948 if ( attr==INVALID_FILE_ATTRIBUTES ){
33949 rc = SQLITE_OK; /* Already gone? */
 
 
 
 
 
33950 break;
33951 }
33952 if ( attr&FILE_ATTRIBUTE_DIRECTORY ){
33953 rc = SQLITE_ERROR; /* Files only. */
33954 break;
@@ -33966,11 +34018,16 @@
33966 #ifdef SQLITE_WIN32_HAS_ANSI
33967 else{
33968 do {
33969 attr = osGetFileAttributesA(zConverted);
33970 if ( attr==INVALID_FILE_ATTRIBUTES ){
33971 rc = SQLITE_OK; /* Already gone? */
 
 
 
 
 
33972 break;
33973 }
33974 if ( attr&FILE_ATTRIBUTE_DIRECTORY ){
33975 rc = SQLITE_ERROR; /* Files only. */
33976 break;
@@ -33984,11 +34041,11 @@
33984 break;
33985 }
33986 } while(1);
33987 }
33988 #endif
33989 if( rc ){
33990 rc = winLogError(SQLITE_IOERR_DELETE, lastErrno,
33991 "winDelete", zFilename);
33992 }else{
33993 logIoerr(cnt);
33994 }
@@ -39178,16 +39235,17 @@
39178 /* This branch may be executed with Pager.journalMode==MEMORY if
39179 ** a hot-journal was just rolled back. In this case the journal
39180 ** file should be closed and deleted. If this connection writes to
39181 ** the database file, it will do so using an in-memory journal.
39182 */
 
39183 assert( pPager->journalMode==PAGER_JOURNALMODE_DELETE
39184 || pPager->journalMode==PAGER_JOURNALMODE_MEMORY
39185 || pPager->journalMode==PAGER_JOURNALMODE_WAL
39186 );
39187 sqlite3OsClose(pPager->jfd);
39188 if( !pPager->tempFile ){
39189 rc = sqlite3OsDelete(pPager->pVfs, pPager->zJournal, 0);
39190 }
39191 }
39192 }
39193
@@ -40722,11 +40780,11 @@
40722
40723 if( isOpen(pPager->fd) ){
40724 void **ap = (void **)&pPager->xBusyHandler;
40725 assert( ((int(*)(void *))(ap[0]))==xBusyHandler );
40726 assert( ap[1]==pBusyHandlerArg );
40727 sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_BUSYHANDLER, (void *)ap);
40728 }
40729 }
40730
40731 /*
40732 ** Change the page size used by the Pager object. The new page size
@@ -58521,11 +58579,11 @@
58521 ** Remember the SQL string for a prepared statement.
58522 */
58523 SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepareV2){
58524 assert( isPrepareV2==1 || isPrepareV2==0 );
58525 if( p==0 ) return;
58526 #ifdef SQLITE_OMIT_TRACE
58527 if( !isPrepareV2 ) return;
58528 #endif
58529 assert( p->zSql==0 );
58530 p->zSql = sqlite3DbStrNDup(p->db, z, n);
58531 p->isPrepareV2 = (u8)isPrepareV2;
@@ -59191,10 +59249,11 @@
59191 assert( addr<p->nOp );
59192 if( addr<0 ){
59193 addr = p->nOp - 1;
59194 }
59195 pOp = &p->aOp[addr];
 
59196 freeP4(db, pOp->p4type, pOp->p4.p);
59197 pOp->p4.p = 0;
59198 if( n==P4_INT32 ){
59199 /* Note: this cast is safe, because the origin data point was an int
59200 ** that was cast to a (const char *). */
@@ -60794,10 +60853,31 @@
60794 sqlite3Error(db, rc, 0);
60795 }
60796 return rc;
60797 }
60798
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60799 /*
60800 ** Clean up a VDBE after execution but do not delete the VDBE just yet.
60801 ** Write any error messages into *pzErrMsg. Return the result code.
60802 **
60803 ** After this routine is run, the VDBE should be ready to be executed
@@ -60821,10 +60901,11 @@
60821 ** and error message from the VDBE into the main database structure. But
60822 ** if the VDBE has just been set to run but has not actually executed any
60823 ** instructions yet, leave the main database error information unchanged.
60824 */
60825 if( p->pc>=0 ){
 
60826 sqlite3VdbeTransferError(p);
60827 sqlite3DbFree(db, p->zErrMsg);
60828 p->zErrMsg = 0;
60829 if( p->runOnlyOnce ) p->expired = 1;
60830 }else if( p->rc && p->expired ){
@@ -60927,11 +61008,11 @@
60927 sqlite3DbFree(db, p->aLabel);
60928 sqlite3DbFree(db, p->aColName);
60929 sqlite3DbFree(db, p->zSql);
60930 sqlite3DbFree(db, p->pFree);
60931 #if defined(SQLITE_ENABLE_TREE_EXPLAIN)
60932 sqlite3DbFree(db, p->zExplain);
60933 sqlite3DbFree(db, p->pExplain);
60934 #endif
60935 }
60936
60937 /*
@@ -67163,11 +67244,11 @@
67163 u.az.pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);
67164 u.az.pCx->isIndex = !u.az.pCx->isTable;
67165 break;
67166 }
67167
67168 /* Opcode: OpenSorter P1 P2 * P4 *
67169 **
67170 ** This opcode works like OP_OpenEphemeral except that it opens
67171 ** a transient index that is specifically designed to sort large
67172 ** tables using an external merge-sort algorithm.
67173 */
@@ -71947,10 +72028,20 @@
71947 if( p->pMethods!=&JournalFileMethods ){
71948 return SQLITE_OK;
71949 }
71950 return createFile((JournalFile *)p);
71951 }
 
 
 
 
 
 
 
 
 
 
71952
71953 /*
71954 ** Return the number of bytes required to store a JournalFile that uses vfs
71955 ** pVfs to create the underlying on-disk files.
71956 */
@@ -80206,11 +80297,11 @@
80206 sqlite3ErrorMsg(pFix->pParse,
80207 "%s %T cannot reference objects in database %s",
80208 pFix->zType, pFix->pName, pItem->zDatabase);
80209 return 1;
80210 }
80211 sqlite3_free(pItem->zDatabase);
80212 pItem->zDatabase = 0;
80213 pItem->pSchema = pFix->pSchema;
80214 #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)
80215 if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1;
80216 if( sqlite3FixExpr(pFix, pItem->pOn) ) return 1;
@@ -85737,10 +85828,11 @@
85737 int nNeedle;
85738 int typeHaystack, typeNeedle;
85739 int N = 1;
85740 int isText;
85741
 
85742 typeHaystack = sqlite3_value_type(argv[0]);
85743 typeNeedle = sqlite3_value_type(argv[1]);
85744 if( typeHaystack==SQLITE_NULL || typeNeedle==SQLITE_NULL ) return;
85745 nHaystack = sqlite3_value_bytes(argv[0]);
85746 nNeedle = sqlite3_value_bytes(argv[1]);
@@ -88450,11 +88542,11 @@
88450 int iDb, /* The database index in sqlite3.aDb[] */
88451 Table *pTab, /* The table to be opened */
88452 int opcode /* OP_OpenRead or OP_OpenWrite */
88453 ){
88454 Vdbe *v;
88455 if( IsVirtual(pTab) ) return;
88456 v = sqlite3GetVdbe(p);
88457 assert( opcode==OP_OpenWrite || opcode==OP_OpenRead );
88458 sqlite3TableLock(p, iDb, pTab->tnum, (opcode==OP_OpenWrite)?1:0, pTab->zName);
88459 sqlite3VdbeAddOp3(v, opcode, iCur, pTab->tnum, iDb);
88460 sqlite3VdbeChangeP4(v, -1, SQLITE_INT_TO_PTR(pTab->nCol), P4_INT32);
@@ -107515,10 +107607,12 @@
107515 #ifndef SQLITE_OMIT_VIRTUALTABLE
107516 if( (pLevel->plan.wsFlags & WHERE_VIRTUALTABLE)!=0 ){
107517 const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);
107518 int iCur = pTabItem->iCursor;
107519 sqlite3VdbeAddOp4(v, OP_VOpen, iCur, 0, 0, pVTab, P4_VTAB);
 
 
107520 }else
107521 #endif
107522 if( (pLevel->plan.wsFlags & WHERE_IDX_ONLY)==0
107523 && (wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0 ){
107524 int op = pWInfo->okOnePass ? OP_OpenWrite : OP_OpenRead;
@@ -112550,10 +112644,17 @@
112550 ** to sqlite3_initialize() should be a no-op. But the initialization
112551 ** must be complete. So isInit must not be set until the very end
112552 ** of this routine.
112553 */
112554 if( sqlite3GlobalConfig.isInit ) return SQLITE_OK;
 
 
 
 
 
 
 
112555
112556 /* Make sure the mutex subsystem is initialized. If unable to
112557 ** initialize the mutex subsystem, return early with the error.
112558 ** If the system is so sick that we are unable to allocate a mutex,
112559 ** there is not much SQLite is going to be able to do.
@@ -112898,10 +112999,19 @@
112898
112899 case SQLITE_CONFIG_COVERING_INDEX_SCAN: {
112900 sqlite3GlobalConfig.bUseCis = va_arg(ap, int);
112901 break;
112902 }
 
 
 
 
 
 
 
 
 
112903
112904 default: {
112905 rc = SQLITE_ERROR;
112906 break;
112907 }
@@ -113237,10 +113347,17 @@
113237 sqlite3Error(db, SQLITE_BUSY, "unable to close due to unfinalized "
113238 "statements or unfinished backups");
113239 sqlite3_mutex_leave(db->mutex);
113240 return SQLITE_BUSY;
113241 }
 
 
 
 
 
 
 
113242
113243 /* Convert the connection into a zombie and then close it.
113244 */
113245 db->magic = SQLITE_MAGIC_ZOMBIE;
113246 sqlite3LeaveMutexAndCloseZombie(db);
@@ -114870,10 +114987,17 @@
114870 db = 0;
114871 }else if( rc!=SQLITE_OK ){
114872 db->magic = SQLITE_MAGIC_SICK;
114873 }
114874 *ppDb = db;
 
 
 
 
 
 
 
114875 return sqlite3ApiExit(0, rc);
114876 }
114877
114878 /*
114879 ** Open a new database handle.
@@ -126142,11 +126266,11 @@
126142 static int fts3PendingTermsAdd(
126143 Fts3Table *p, /* Table into which text will be inserted */
126144 int iLangid, /* Language id to use */
126145 const char *zText, /* Text of document to be inserted */
126146 int iCol, /* Column into which text is being inserted */
126147 u32 *pnWord /* OUT: Number of tokens inserted */
126148 ){
126149 int rc;
126150 int iStart = 0;
126151 int iEnd = 0;
126152 int iPos = 0;
@@ -126206,11 +126330,11 @@
126206 );
126207 }
126208 }
126209
126210 pModule->xClose(pCsr);
126211 *pnWord = nWord;
126212 return (rc==SQLITE_DONE ? SQLITE_OK : rc);
126213 }
126214
126215 /*
126216 ** Calling this function indicates that subsequent calls to
@@ -126410,15 +126534,17 @@
126410 */
126411 static void fts3DeleteTerms(
126412 int *pRC, /* Result code */
126413 Fts3Table *p, /* The FTS table to delete from */
126414 sqlite3_value *pRowid, /* The docid to be deleted */
126415 u32 *aSz /* Sizes of deleted document written here */
 
126416 ){
126417 int rc;
126418 sqlite3_stmt *pSelect;
126419
 
126420 if( *pRC ) return;
126421 rc = fts3SqlStmt(p, SQL_SELECT_CONTENT_BY_ROWID, &pSelect, &pRowid);
126422 if( rc==SQLITE_OK ){
126423 if( SQLITE_ROW==sqlite3_step(pSelect) ){
126424 int i;
@@ -126432,10 +126558,11 @@
126432 if( rc!=SQLITE_OK ){
126433 sqlite3_reset(pSelect);
126434 *pRC = rc;
126435 return;
126436 }
 
126437 }
126438 rc = sqlite3_reset(pSelect);
126439 }else{
126440 sqlite3_reset(pSelect);
126441 }
@@ -128656,11 +128783,11 @@
128656
128657 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
128658 int iCol;
128659 int iLangid = langidFromSelect(p, pStmt);
128660 rc = fts3PendingTermsDocid(p, iLangid, sqlite3_column_int64(pStmt, 0));
128661 aSz[p->nColumn] = 0;
128662 for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){
128663 const char *z = (const char *) sqlite3_column_text(pStmt, iCol+1);
128664 rc = fts3PendingTermsAdd(p, iLangid, z, iCol, &aSz[iCol]);
128665 aSz[p->nColumn] += sqlite3_column_bytes(pStmt, iCol+1);
128666 }
@@ -130560,32 +130687,36 @@
130560 ** of subsiduary data structures accordingly.
130561 */
130562 static int fts3DeleteByRowid(
130563 Fts3Table *p,
130564 sqlite3_value *pRowid,
130565 int *pnDoc,
130566 u32 *aSzDel
130567 ){
130568 int isEmpty = 0;
130569 int rc = fts3IsEmpty(p, pRowid, &isEmpty);
130570 if( rc==SQLITE_OK ){
130571 if( isEmpty ){
130572 /* Deleting this row means the whole table is empty. In this case
130573 ** delete the contents of all three tables and throw away any
130574 ** data in the pendingTerms hash table. */
130575 rc = fts3DeleteAll(p, 1);
130576 *pnDoc = *pnDoc - 1;
130577 }else{
130578 fts3DeleteTerms(&rc, p, pRowid, aSzDel);
130579 if( p->zContentTbl==0 ){
130580 fts3SqlExec(&rc, p, SQL_DELETE_CONTENT, &pRowid);
130581 if( sqlite3_changes(p->db) ) *pnDoc = *pnDoc - 1;
130582 }else{
130583 *pnDoc = *pnDoc - 1;
130584 }
130585 if( p->bHasDocsize ){
130586 fts3SqlExec(&rc, p, SQL_DELETE_DOCSIZE, &pRowid);
 
 
 
 
130587 }
130588 }
130589 }
130590
130591 return rc;
@@ -130612,11 +130743,11 @@
130612 ){
130613 Fts3Table *p = (Fts3Table *)pVtab;
130614 int rc = SQLITE_OK; /* Return Code */
130615 int isRemove = 0; /* True for an UPDATE or DELETE */
130616 u32 *aSzIns = 0; /* Sizes of inserted documents */
130617 u32 *aSzDel; /* Sizes of deleted documents */
130618 int nChng = 0; /* Net change in number of documents */
130619 int bInsertDone = 0;
130620
130621 assert( p->pSegments==0 );
130622 assert(
@@ -130640,17 +130771,17 @@
130640 rc = SQLITE_CONSTRAINT;
130641 goto update_out;
130642 }
130643
130644 /* Allocate space to hold the change in document sizes */
130645 aSzIns = sqlite3_malloc( sizeof(aSzIns[0])*(p->nColumn+1)*2 );
130646 if( aSzIns==0 ){
130647 rc = SQLITE_NOMEM;
130648 goto update_out;
130649 }
130650 aSzDel = &aSzIns[p->nColumn+1];
130651 memset(aSzIns, 0, sizeof(aSzIns[0])*(p->nColumn+1)*2);
130652
130653 /* If this is an INSERT operation, or an UPDATE that modifies the rowid
130654 ** value, then this operation requires constraint handling.
130655 **
130656 ** If the on-conflict mode is REPLACE, this means that the existing row
@@ -130731,11 +130862,11 @@
130731 if( p->bFts4 ){
130732 fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nChng);
130733 }
130734
130735 update_out:
130736 sqlite3_free(aSzIns);
130737 sqlite3Fts3SegmentsClose(p);
130738 return rc;
130739 }
130740
130741 /*
130742
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -673,11 +673,11 @@
673 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
674 ** [sqlite_version()] and [sqlite_source_id()].
675 */
676 #define SQLITE_VERSION "3.7.15"
677 #define SQLITE_VERSION_NUMBER 3007015
678 #define SQLITE_SOURCE_ID "2012-12-05 14:31:13 9f6c68856b694373b7ffb124abd996e519ba5921"
679
680 /*
681 ** CAPI3REF: Run-Time Library Version Numbers
682 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
683 **
@@ -2162,10 +2162,26 @@
2162 ** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
2163 ** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
2164 ** <dd> These options are obsolete and should not be used by new code.
2165 ** They are retained for backwards compatibility but are now no-ops.
2166 ** </dl>
2167 **
2168 ** [[SQLITE_CONFIG_SQLLOG]]
2169 ** <dt>SQLITE_CONFIG_SQLLOG
2170 ** <dd>This option is only available if sqlite is compiled with the
2171 ** SQLITE_ENABLE_SQLLOG pre-processor macro defined. The first argument should
2172 ** be a pointer to a function of type void(*)(void*,sqlite3*,const char*, int).
2173 ** The second should be of type (void*). The callback is invoked by the library
2174 ** in three separate circumstances, identified by the value passed as the
2175 ** fourth parameter. If the fourth parameter is 0, then the database connection
2176 ** passed as the second argument has just been opened. The third argument
2177 ** points to a buffer containing the name of the main database file. If the
2178 ** fourth parameter is 1, then the SQL statement that the third parameter
2179 ** points to has just been executed. Or, if the fourth parameter is 2, then
2180 ** the connection being passed as the second parameter is being closed. The
2181 ** third parameter is passed NULL In this case.
2182 ** </dl>
2183 */
2184 #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
2185 #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
2186 #define SQLITE_CONFIG_SERIALIZED 3 /* nil */
2187 #define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */
@@ -2183,10 +2199,11 @@
2199 #define SQLITE_CONFIG_LOG 16 /* xFunc, void* */
2200 #define SQLITE_CONFIG_URI 17 /* int */
2201 #define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */
2202 #define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */
2203 #define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */
2204 #define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */
2205
2206 /*
2207 ** CAPI3REF: Database Connection Configuration Options
2208 **
2209 ** These constants are the available integer configuration options that
@@ -11557,10 +11574,14 @@
11574 sqlite3_mutex *pInitMutex; /* Mutex used by sqlite3_initialize() */
11575 int nRefInitMutex; /* Number of users of pInitMutex */
11576 void (*xLog)(void*,int,const char*); /* Function for logging */
11577 void *pLogArg; /* First argument to xLog() */
11578 int bLocaltimeFault; /* True to fail localtime() calls */
11579 #ifdef SQLITE_ENABLE_SQLLOG
11580 void(*xSqllog)(void*,sqlite3*,const char*, int);
11581 void *pSqllogArg;
11582 #endif
11583 };
11584
11585 /*
11586 ** Context pointer passed down through the tree-walk.
11587 */
@@ -12291,12 +12312,14 @@
12312
12313 #ifdef SQLITE_ENABLE_ATOMIC_WRITE
12314 SQLITE_PRIVATE int sqlite3JournalOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int);
12315 SQLITE_PRIVATE int sqlite3JournalSize(sqlite3_vfs *);
12316 SQLITE_PRIVATE int sqlite3JournalCreate(sqlite3_file *);
12317 SQLITE_PRIVATE int sqlite3JournalExists(sqlite3_file *p);
12318 #else
12319 #define sqlite3JournalSize(pVfs) ((pVfs)->szOsFile)
12320 #define sqlite3JournalExists(p) 1
12321 #endif
12322
12323 SQLITE_PRIVATE void sqlite3MemJournalOpen(sqlite3_file *);
12324 SQLITE_PRIVATE int sqlite3MemJournalSize(void);
12325 SQLITE_PRIVATE int sqlite3IsMemJournal(sqlite3_file *);
@@ -12563,10 +12586,14 @@
12586 0, /* pInitMutex */
12587 0, /* nRefInitMutex */
12588 0, /* xLog */
12589 0, /* pLogArg */
12590 0, /* bLocaltimeFault */
12591 #ifdef SQLITE_ENABLE_SQLLOG
12592 0, /* xSqllog */
12593 0 /* pSqllogArg */
12594 #endif
12595 };
12596
12597
12598 /*
12599 ** Hash table for global functions - functions common to all
@@ -22686,10 +22713,17 @@
22713 ** * Definitions of sqlite3_vfs objects for all locking methods
22714 ** plus implementations of sqlite3_os_init() and sqlite3_os_end().
22715 */
22716 #if SQLITE_OS_UNIX /* This file is used on unix only */
22717
22718 /* Use posix_fallocate() if it is available
22719 */
22720 #if !defined(HAVE_POSIX_FALLOCATE) \
22721 && (_XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L)
22722 # define HAVE_POSIX_FALLOCATE 1
22723 #endif
22724
22725 /*
22726 ** There are various methods for file locking used for concurrency
22727 ** control:
22728 **
22729 ** 1. POSIX locking (the default),
@@ -27016,15 +27050,23 @@
27050 **
27051 ** Alternatively, if bExtend is true, use ftruncate() to allocate
27052 ** the requested memory region.
27053 */
27054 if( !bExtend ) goto shmpage_out;
27055 #if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE
27056 if( osFallocate(pShmNode->h, sStat.st_size, nByte)!=0 ){
27057 rc = unixLogError(SQLITE_IOERR_SHMSIZE, "fallocate",
27058 pShmNode->zFilename);
27059 goto shmpage_out;
27060 }
27061 #else
27062 if( robust_ftruncate(pShmNode->h, nByte) ){
27063 rc = unixLogError(SQLITE_IOERR_SHMSIZE, "ftruncate",
27064 pShmNode->zFilename);
27065 goto shmpage_out;
27066 }
27067 #endif
27068 }
27069 }
27070
27071 /* Map the requested memory region into this processes address space. */
27072 apNew = (char **)sqlite3_realloc(
@@ -33937,18 +33979,28 @@
33979 memset(&sAttrData, 0, sizeof(sAttrData));
33980 if ( osGetFileAttributesExW(zConverted, GetFileExInfoStandard,
33981 &sAttrData) ){
33982 attr = sAttrData.dwFileAttributes;
33983 }else{
33984 lastErrno = osGetLastError();
33985 if( lastErrno==ERROR_FILE_NOT_FOUND || lastErrno==ERROR_PATH_NOT_FOUND ){
33986 rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */
33987 }else{
33988 rc = SQLITE_ERROR;
33989 }
33990 break;
33991 }
33992 #else
33993 attr = osGetFileAttributesW(zConverted);
33994 #endif
33995 if ( attr==INVALID_FILE_ATTRIBUTES ){
33996 lastErrno = osGetLastError();
33997 if( lastErrno==ERROR_FILE_NOT_FOUND || lastErrno==ERROR_PATH_NOT_FOUND ){
33998 rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */
33999 }else{
34000 rc = SQLITE_ERROR;
34001 }
34002 break;
34003 }
34004 if ( attr&FILE_ATTRIBUTE_DIRECTORY ){
34005 rc = SQLITE_ERROR; /* Files only. */
34006 break;
@@ -33966,11 +34018,16 @@
34018 #ifdef SQLITE_WIN32_HAS_ANSI
34019 else{
34020 do {
34021 attr = osGetFileAttributesA(zConverted);
34022 if ( attr==INVALID_FILE_ATTRIBUTES ){
34023 lastErrno = osGetLastError();
34024 if( lastErrno==ERROR_FILE_NOT_FOUND || lastErrno==ERROR_PATH_NOT_FOUND ){
34025 rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */
34026 }else{
34027 rc = SQLITE_ERROR;
34028 }
34029 break;
34030 }
34031 if ( attr&FILE_ATTRIBUTE_DIRECTORY ){
34032 rc = SQLITE_ERROR; /* Files only. */
34033 break;
@@ -33984,11 +34041,11 @@
34041 break;
34042 }
34043 } while(1);
34044 }
34045 #endif
34046 if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){
34047 rc = winLogError(SQLITE_IOERR_DELETE, lastErrno,
34048 "winDelete", zFilename);
34049 }else{
34050 logIoerr(cnt);
34051 }
@@ -39178,16 +39235,17 @@
39235 /* This branch may be executed with Pager.journalMode==MEMORY if
39236 ** a hot-journal was just rolled back. In this case the journal
39237 ** file should be closed and deleted. If this connection writes to
39238 ** the database file, it will do so using an in-memory journal.
39239 */
39240 int bDelete = (!pPager->tempFile && sqlite3JournalExists(pPager->jfd));
39241 assert( pPager->journalMode==PAGER_JOURNALMODE_DELETE
39242 || pPager->journalMode==PAGER_JOURNALMODE_MEMORY
39243 || pPager->journalMode==PAGER_JOURNALMODE_WAL
39244 );
39245 sqlite3OsClose(pPager->jfd);
39246 if( bDelete ){
39247 rc = sqlite3OsDelete(pPager->pVfs, pPager->zJournal, 0);
39248 }
39249 }
39250 }
39251
@@ -40722,11 +40780,11 @@
40780
40781 if( isOpen(pPager->fd) ){
40782 void **ap = (void **)&pPager->xBusyHandler;
40783 assert( ((int(*)(void *))(ap[0]))==xBusyHandler );
40784 assert( ap[1]==pBusyHandlerArg );
40785 sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_BUSYHANDLER, (void *)ap);
40786 }
40787 }
40788
40789 /*
40790 ** Change the page size used by the Pager object. The new page size
@@ -58521,11 +58579,11 @@
58579 ** Remember the SQL string for a prepared statement.
58580 */
58581 SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepareV2){
58582 assert( isPrepareV2==1 || isPrepareV2==0 );
58583 if( p==0 ) return;
58584 #if defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_ENABLE_SQLLOG)
58585 if( !isPrepareV2 ) return;
58586 #endif
58587 assert( p->zSql==0 );
58588 p->zSql = sqlite3DbStrNDup(p->db, z, n);
58589 p->isPrepareV2 = (u8)isPrepareV2;
@@ -59191,10 +59249,11 @@
59249 assert( addr<p->nOp );
59250 if( addr<0 ){
59251 addr = p->nOp - 1;
59252 }
59253 pOp = &p->aOp[addr];
59254 assert( pOp->p4type==P4_NOTUSED || pOp->p4type==P4_INT32 );
59255 freeP4(db, pOp->p4type, pOp->p4.p);
59256 pOp->p4.p = 0;
59257 if( n==P4_INT32 ){
59258 /* Note: this cast is safe, because the origin data point was an int
59259 ** that was cast to a (const char *). */
@@ -60794,10 +60853,31 @@
60853 sqlite3Error(db, rc, 0);
60854 }
60855 return rc;
60856 }
60857
60858 #ifdef SQLITE_ENABLE_SQLLOG
60859 /*
60860 ** If an SQLITE_CONFIG_SQLLOG hook is registered and the VM has been run,
60861 ** invoke it.
60862 */
60863 static void vdbeInvokeSqllog(Vdbe *v){
60864 if( sqlite3GlobalConfig.xSqllog && v->rc==SQLITE_OK && v->zSql && v->pc>=0 ){
60865 char *zExpanded = sqlite3VdbeExpandSql(v, v->zSql);
60866 assert( v->db->init.busy==0 );
60867 if( zExpanded ){
60868 sqlite3GlobalConfig.xSqllog(
60869 sqlite3GlobalConfig.pSqllogArg, v->db, zExpanded, 1
60870 );
60871 sqlite3DbFree(v->db, zExpanded);
60872 }
60873 }
60874 }
60875 #else
60876 # define vdbeInvokeSqllog(x)
60877 #endif
60878
60879 /*
60880 ** Clean up a VDBE after execution but do not delete the VDBE just yet.
60881 ** Write any error messages into *pzErrMsg. Return the result code.
60882 **
60883 ** After this routine is run, the VDBE should be ready to be executed
@@ -60821,10 +60901,11 @@
60901 ** and error message from the VDBE into the main database structure. But
60902 ** if the VDBE has just been set to run but has not actually executed any
60903 ** instructions yet, leave the main database error information unchanged.
60904 */
60905 if( p->pc>=0 ){
60906 vdbeInvokeSqllog(p);
60907 sqlite3VdbeTransferError(p);
60908 sqlite3DbFree(db, p->zErrMsg);
60909 p->zErrMsg = 0;
60910 if( p->runOnlyOnce ) p->expired = 1;
60911 }else if( p->rc && p->expired ){
@@ -60927,11 +61008,11 @@
61008 sqlite3DbFree(db, p->aLabel);
61009 sqlite3DbFree(db, p->aColName);
61010 sqlite3DbFree(db, p->zSql);
61011 sqlite3DbFree(db, p->pFree);
61012 #if defined(SQLITE_ENABLE_TREE_EXPLAIN)
61013 sqlite3_free(p->zExplain);
61014 sqlite3DbFree(db, p->pExplain);
61015 #endif
61016 }
61017
61018 /*
@@ -67163,11 +67244,11 @@
67244 u.az.pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);
67245 u.az.pCx->isIndex = !u.az.pCx->isTable;
67246 break;
67247 }
67248
67249 /* Opcode: SorterOpen P1 P2 * P4 *
67250 **
67251 ** This opcode works like OP_OpenEphemeral except that it opens
67252 ** a transient index that is specifically designed to sort large
67253 ** tables using an external merge-sort algorithm.
67254 */
@@ -71947,10 +72028,20 @@
72028 if( p->pMethods!=&JournalFileMethods ){
72029 return SQLITE_OK;
72030 }
72031 return createFile((JournalFile *)p);
72032 }
72033
72034 /*
72035 ** The file-handle passed as the only argument is guaranteed to be an open
72036 ** file. It may or may not be of class JournalFile. If the file is a
72037 ** JournalFile, and the underlying file on disk has not yet been opened,
72038 ** return 0. Otherwise, return 1.
72039 */
72040 SQLITE_PRIVATE int sqlite3JournalExists(sqlite3_file *p){
72041 return (p->pMethods!=&JournalFileMethods || ((JournalFile *)p)->pReal!=0);
72042 }
72043
72044 /*
72045 ** Return the number of bytes required to store a JournalFile that uses vfs
72046 ** pVfs to create the underlying on-disk files.
72047 */
@@ -80206,11 +80297,11 @@
80297 sqlite3ErrorMsg(pFix->pParse,
80298 "%s %T cannot reference objects in database %s",
80299 pFix->zType, pFix->pName, pItem->zDatabase);
80300 return 1;
80301 }
80302 sqlite3DbFree(pFix->pParse->db, pItem->zDatabase);
80303 pItem->zDatabase = 0;
80304 pItem->pSchema = pFix->pSchema;
80305 #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)
80306 if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1;
80307 if( sqlite3FixExpr(pFix, pItem->pOn) ) return 1;
@@ -85737,10 +85828,11 @@
85828 int nNeedle;
85829 int typeHaystack, typeNeedle;
85830 int N = 1;
85831 int isText;
85832
85833 UNUSED_PARAMETER(argc);
85834 typeHaystack = sqlite3_value_type(argv[0]);
85835 typeNeedle = sqlite3_value_type(argv[1]);
85836 if( typeHaystack==SQLITE_NULL || typeNeedle==SQLITE_NULL ) return;
85837 nHaystack = sqlite3_value_bytes(argv[0]);
85838 nNeedle = sqlite3_value_bytes(argv[1]);
@@ -88450,11 +88542,11 @@
88542 int iDb, /* The database index in sqlite3.aDb[] */
88543 Table *pTab, /* The table to be opened */
88544 int opcode /* OP_OpenRead or OP_OpenWrite */
88545 ){
88546 Vdbe *v;
88547 assert( !IsVirtual(pTab) );
88548 v = sqlite3GetVdbe(p);
88549 assert( opcode==OP_OpenWrite || opcode==OP_OpenRead );
88550 sqlite3TableLock(p, iDb, pTab->tnum, (opcode==OP_OpenWrite)?1:0, pTab->zName);
88551 sqlite3VdbeAddOp3(v, opcode, iCur, pTab->tnum, iDb);
88552 sqlite3VdbeChangeP4(v, -1, SQLITE_INT_TO_PTR(pTab->nCol), P4_INT32);
@@ -107515,10 +107607,12 @@
107607 #ifndef SQLITE_OMIT_VIRTUALTABLE
107608 if( (pLevel->plan.wsFlags & WHERE_VIRTUALTABLE)!=0 ){
107609 const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);
107610 int iCur = pTabItem->iCursor;
107611 sqlite3VdbeAddOp4(v, OP_VOpen, iCur, 0, 0, pVTab, P4_VTAB);
107612 }else if( IsVirtual(pTab) ){
107613 /* noop */
107614 }else
107615 #endif
107616 if( (pLevel->plan.wsFlags & WHERE_IDX_ONLY)==0
107617 && (wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0 ){
107618 int op = pWInfo->okOnePass ? OP_OpenWrite : OP_OpenRead;
@@ -112550,10 +112644,17 @@
112644 ** to sqlite3_initialize() should be a no-op. But the initialization
112645 ** must be complete. So isInit must not be set until the very end
112646 ** of this routine.
112647 */
112648 if( sqlite3GlobalConfig.isInit ) return SQLITE_OK;
112649
112650 #ifdef SQLITE_ENABLE_SQLLOG
112651 {
112652 extern void sqlite3_init_sqllog(void);
112653 sqlite3_init_sqllog();
112654 }
112655 #endif
112656
112657 /* Make sure the mutex subsystem is initialized. If unable to
112658 ** initialize the mutex subsystem, return early with the error.
112659 ** If the system is so sick that we are unable to allocate a mutex,
112660 ** there is not much SQLite is going to be able to do.
@@ -112898,10 +112999,19 @@
112999
113000 case SQLITE_CONFIG_COVERING_INDEX_SCAN: {
113001 sqlite3GlobalConfig.bUseCis = va_arg(ap, int);
113002 break;
113003 }
113004
113005 #ifdef SQLITE_ENABLE_SQLLOG
113006 case SQLITE_CONFIG_SQLLOG: {
113007 typedef void(*SQLLOGFUNC_t)(void*, sqlite3*, const char*, int);
113008 sqlite3GlobalConfig.xSqllog = va_arg(ap, SQLLOGFUNC_t);
113009 sqlite3GlobalConfig.pSqllogArg = va_arg(ap, void *);
113010 break;
113011 }
113012 #endif
113013
113014 default: {
113015 rc = SQLITE_ERROR;
113016 break;
113017 }
@@ -113237,10 +113347,17 @@
113347 sqlite3Error(db, SQLITE_BUSY, "unable to close due to unfinalized "
113348 "statements or unfinished backups");
113349 sqlite3_mutex_leave(db->mutex);
113350 return SQLITE_BUSY;
113351 }
113352
113353 #ifdef SQLITE_ENABLE_SQLLOG
113354 if( sqlite3GlobalConfig.xSqllog ){
113355 /* Closing the handle. Fourth parameter is passed the value 2. */
113356 sqlite3GlobalConfig.xSqllog(sqlite3GlobalConfig.pSqllogArg, db, 0, 2);
113357 }
113358 #endif
113359
113360 /* Convert the connection into a zombie and then close it.
113361 */
113362 db->magic = SQLITE_MAGIC_ZOMBIE;
113363 sqlite3LeaveMutexAndCloseZombie(db);
@@ -114870,10 +114987,17 @@
114987 db = 0;
114988 }else if( rc!=SQLITE_OK ){
114989 db->magic = SQLITE_MAGIC_SICK;
114990 }
114991 *ppDb = db;
114992 #ifdef SQLITE_ENABLE_SQLLOG
114993 if( sqlite3GlobalConfig.xSqllog ){
114994 /* Opening a db handle. Fourth parameter is passed 0. */
114995 void *pArg = sqlite3GlobalConfig.pSqllogArg;
114996 sqlite3GlobalConfig.xSqllog(pArg, db, zFilename, 0);
114997 }
114998 #endif
114999 return sqlite3ApiExit(0, rc);
115000 }
115001
115002 /*
115003 ** Open a new database handle.
@@ -126142,11 +126266,11 @@
126266 static int fts3PendingTermsAdd(
126267 Fts3Table *p, /* Table into which text will be inserted */
126268 int iLangid, /* Language id to use */
126269 const char *zText, /* Text of document to be inserted */
126270 int iCol, /* Column into which text is being inserted */
126271 u32 *pnWord /* IN/OUT: Incr. by number tokens inserted */
126272 ){
126273 int rc;
126274 int iStart = 0;
126275 int iEnd = 0;
126276 int iPos = 0;
@@ -126206,11 +126330,11 @@
126330 );
126331 }
126332 }
126333
126334 pModule->xClose(pCsr);
126335 *pnWord += nWord;
126336 return (rc==SQLITE_DONE ? SQLITE_OK : rc);
126337 }
126338
126339 /*
126340 ** Calling this function indicates that subsequent calls to
@@ -126410,15 +126534,17 @@
126534 */
126535 static void fts3DeleteTerms(
126536 int *pRC, /* Result code */
126537 Fts3Table *p, /* The FTS table to delete from */
126538 sqlite3_value *pRowid, /* The docid to be deleted */
126539 u32 *aSz, /* Sizes of deleted document written here */
126540 int *pbFound /* OUT: Set to true if row really does exist */
126541 ){
126542 int rc;
126543 sqlite3_stmt *pSelect;
126544
126545 assert( *pbFound==0 );
126546 if( *pRC ) return;
126547 rc = fts3SqlStmt(p, SQL_SELECT_CONTENT_BY_ROWID, &pSelect, &pRowid);
126548 if( rc==SQLITE_OK ){
126549 if( SQLITE_ROW==sqlite3_step(pSelect) ){
126550 int i;
@@ -126432,10 +126558,11 @@
126558 if( rc!=SQLITE_OK ){
126559 sqlite3_reset(pSelect);
126560 *pRC = rc;
126561 return;
126562 }
126563 *pbFound = 1;
126564 }
126565 rc = sqlite3_reset(pSelect);
126566 }else{
126567 sqlite3_reset(pSelect);
126568 }
@@ -128656,11 +128783,11 @@
128783
128784 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
128785 int iCol;
128786 int iLangid = langidFromSelect(p, pStmt);
128787 rc = fts3PendingTermsDocid(p, iLangid, sqlite3_column_int64(pStmt, 0));
128788 memset(aSz, 0, sizeof(aSz[0]) * (p->nColumn+1));
128789 for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){
128790 const char *z = (const char *) sqlite3_column_text(pStmt, iCol+1);
128791 rc = fts3PendingTermsAdd(p, iLangid, z, iCol, &aSz[iCol]);
128792 aSz[p->nColumn] += sqlite3_column_bytes(pStmt, iCol+1);
128793 }
@@ -130560,32 +130687,36 @@
130687 ** of subsiduary data structures accordingly.
130688 */
130689 static int fts3DeleteByRowid(
130690 Fts3Table *p,
130691 sqlite3_value *pRowid,
130692 int *pnChng, /* IN/OUT: Decrement if row is deleted */
130693 u32 *aSzDel
130694 ){
130695 int rc = SQLITE_OK; /* Return code */
130696 int bFound = 0; /* True if *pRowid really is in the table */
130697
130698 fts3DeleteTerms(&rc, p, pRowid, aSzDel, &bFound);
130699 if( bFound && rc==SQLITE_OK ){
130700 int isEmpty = 0; /* Deleting *pRowid leaves the table empty */
130701 rc = fts3IsEmpty(p, pRowid, &isEmpty);
130702 if( rc==SQLITE_OK ){
130703 if( isEmpty ){
130704 /* Deleting this row means the whole table is empty. In this case
130705 ** delete the contents of all three tables and throw away any
130706 ** data in the pendingTerms hash table. */
130707 rc = fts3DeleteAll(p, 1);
130708 *pnChng = 0;
130709 memset(aSzDel, 0, sizeof(u32) * (p->nColumn+1) * 2);
130710 }else{
130711 *pnChng = *pnChng - 1;
130712 if( p->zContentTbl==0 ){
130713 fts3SqlExec(&rc, p, SQL_DELETE_CONTENT, &pRowid);
130714 }
130715 if( p->bHasDocsize ){
130716 fts3SqlExec(&rc, p, SQL_DELETE_DOCSIZE, &pRowid);
130717 }
130718 }
130719 }
130720 }
130721
130722 return rc;
@@ -130612,11 +130743,11 @@
130743 ){
130744 Fts3Table *p = (Fts3Table *)pVtab;
130745 int rc = SQLITE_OK; /* Return Code */
130746 int isRemove = 0; /* True for an UPDATE or DELETE */
130747 u32 *aSzIns = 0; /* Sizes of inserted documents */
130748 u32 *aSzDel = 0; /* Sizes of deleted documents */
130749 int nChng = 0; /* Net change in number of documents */
130750 int bInsertDone = 0;
130751
130752 assert( p->pSegments==0 );
130753 assert(
@@ -130640,17 +130771,17 @@
130771 rc = SQLITE_CONSTRAINT;
130772 goto update_out;
130773 }
130774
130775 /* Allocate space to hold the change in document sizes */
130776 aSzDel = sqlite3_malloc( sizeof(aSzDel[0])*(p->nColumn+1)*2 );
130777 if( aSzDel==0 ){
130778 rc = SQLITE_NOMEM;
130779 goto update_out;
130780 }
130781 aSzIns = &aSzDel[p->nColumn+1];
130782 memset(aSzDel, 0, sizeof(aSzDel[0])*(p->nColumn+1)*2);
130783
130784 /* If this is an INSERT operation, or an UPDATE that modifies the rowid
130785 ** value, then this operation requires constraint handling.
130786 **
130787 ** If the on-conflict mode is REPLACE, this means that the existing row
@@ -130731,11 +130862,11 @@
130862 if( p->bFts4 ){
130863 fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nChng);
130864 }
130865
130866 update_out:
130867 sqlite3_free(aSzDel);
130868 sqlite3Fts3SegmentsClose(p);
130869 return rc;
130870 }
130871
130872 /*
130873
+18 -1
--- 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.7.15"
111111
#define SQLITE_VERSION_NUMBER 3007015
112
-#define SQLITE_SOURCE_ID "2012-11-09 21:40:02 5a3b07f0f5dfae7eea870303f52f37d6a17f1da2"
112
+#define SQLITE_SOURCE_ID "2012-12-05 14:31:13 9f6c68856b694373b7ffb124abd996e519ba5921"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
@@ -1596,10 +1596,26 @@
15961596
** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
15971597
** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
15981598
** <dd> These options are obsolete and should not be used by new code.
15991599
** They are retained for backwards compatibility but are now no-ops.
16001600
** </dl>
1601
+**
1602
+** [[SQLITE_CONFIG_SQLLOG]]
1603
+** <dt>SQLITE_CONFIG_SQLLOG
1604
+** <dd>This option is only available if sqlite is compiled with the
1605
+** SQLITE_ENABLE_SQLLOG pre-processor macro defined. The first argument should
1606
+** be a pointer to a function of type void(*)(void*,sqlite3*,const char*, int).
1607
+** The second should be of type (void*). The callback is invoked by the library
1608
+** in three separate circumstances, identified by the value passed as the
1609
+** fourth parameter. If the fourth parameter is 0, then the database connection
1610
+** passed as the second argument has just been opened. The third argument
1611
+** points to a buffer containing the name of the main database file. If the
1612
+** fourth parameter is 1, then the SQL statement that the third parameter
1613
+** points to has just been executed. Or, if the fourth parameter is 2, then
1614
+** the connection being passed as the second parameter is being closed. The
1615
+** third parameter is passed NULL In this case.
1616
+** </dl>
16011617
*/
16021618
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
16031619
#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
16041620
#define SQLITE_CONFIG_SERIALIZED 3 /* nil */
16051621
#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */
@@ -1617,10 +1633,11 @@
16171633
#define SQLITE_CONFIG_LOG 16 /* xFunc, void* */
16181634
#define SQLITE_CONFIG_URI 17 /* int */
16191635
#define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */
16201636
#define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */
16211637
#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */
1638
+#define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */
16221639
16231640
/*
16241641
** CAPI3REF: Database Connection Configuration Options
16251642
**
16261643
** These constants are the available integer configuration options that
16271644
--- 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.7.15"
111 #define SQLITE_VERSION_NUMBER 3007015
112 #define SQLITE_SOURCE_ID "2012-11-09 21:40:02 5a3b07f0f5dfae7eea870303f52f37d6a17f1da2"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -1596,10 +1596,26 @@
1596 ** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
1597 ** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
1598 ** <dd> These options are obsolete and should not be used by new code.
1599 ** They are retained for backwards compatibility but are now no-ops.
1600 ** </dl>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1601 */
1602 #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
1603 #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
1604 #define SQLITE_CONFIG_SERIALIZED 3 /* nil */
1605 #define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */
@@ -1617,10 +1633,11 @@
1617 #define SQLITE_CONFIG_LOG 16 /* xFunc, void* */
1618 #define SQLITE_CONFIG_URI 17 /* int */
1619 #define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */
1620 #define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */
1621 #define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */
 
1622
1623 /*
1624 ** CAPI3REF: Database Connection Configuration Options
1625 **
1626 ** These constants are the available integer configuration options that
1627
--- 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.7.15"
111 #define SQLITE_VERSION_NUMBER 3007015
112 #define SQLITE_SOURCE_ID "2012-12-05 14:31:13 9f6c68856b694373b7ffb124abd996e519ba5921"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -1596,10 +1596,26 @@
1596 ** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
1597 ** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
1598 ** <dd> These options are obsolete and should not be used by new code.
1599 ** They are retained for backwards compatibility but are now no-ops.
1600 ** </dl>
1601 **
1602 ** [[SQLITE_CONFIG_SQLLOG]]
1603 ** <dt>SQLITE_CONFIG_SQLLOG
1604 ** <dd>This option is only available if sqlite is compiled with the
1605 ** SQLITE_ENABLE_SQLLOG pre-processor macro defined. The first argument should
1606 ** be a pointer to a function of type void(*)(void*,sqlite3*,const char*, int).
1607 ** The second should be of type (void*). The callback is invoked by the library
1608 ** in three separate circumstances, identified by the value passed as the
1609 ** fourth parameter. If the fourth parameter is 0, then the database connection
1610 ** passed as the second argument has just been opened. The third argument
1611 ** points to a buffer containing the name of the main database file. If the
1612 ** fourth parameter is 1, then the SQL statement that the third parameter
1613 ** points to has just been executed. Or, if the fourth parameter is 2, then
1614 ** the connection being passed as the second parameter is being closed. The
1615 ** third parameter is passed NULL In this case.
1616 ** </dl>
1617 */
1618 #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
1619 #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
1620 #define SQLITE_CONFIG_SERIALIZED 3 /* nil */
1621 #define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */
@@ -1617,10 +1633,11 @@
1633 #define SQLITE_CONFIG_LOG 16 /* xFunc, void* */
1634 #define SQLITE_CONFIG_URI 17 /* int */
1635 #define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */
1636 #define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */
1637 #define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */
1638 #define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */
1639
1640 /*
1641 ** CAPI3REF: Database Connection Configuration Options
1642 **
1643 ** These constants are the available integer configuration options that
1644

Keyboard Shortcuts

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