Fossil SCM

Update the built-in SQLite to the 3.7.9 release candidate.

drh 2011-10-29 19:29 trunk
Commit 326979358d6db31cc1f9f92329b25b1da19f6582
2 files changed +98 -64 +1 -1
+98 -64
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -314,17 +314,10 @@
314314
#endif
315315
#ifdef HAVE_INTTYPES_H
316316
#include <inttypes.h>
317317
#endif
318318
319
-/*
320
-** The number of samples of an index that SQLite takes in order to
321
-** construct a histogram of the table content when running ANALYZE
322
-** and with SQLITE_ENABLE_STAT2
323
-*/
324
-#define SQLITE_INDEX_SAMPLES 10
325
-
326319
/*
327320
** The following macros are used to cast pointers to integers and
328321
** integers to pointers. The way you do this varies from one compiler
329322
** to the next, so we have developed the following set of #if statements
330323
** to generate appropriate macros for a wide range of compilers.
@@ -656,11 +649,11 @@
656649
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
657650
** [sqlite_version()] and [sqlite_source_id()].
658651
*/
659652
#define SQLITE_VERSION "3.7.9"
660653
#define SQLITE_VERSION_NUMBER 3007009
661
-#define SQLITE_SOURCE_ID "2011-10-20 00:55:54 4344483f7d7f64dffadde0053e6c745948db9486"
654
+#define SQLITE_SOURCE_ID "2011-10-29 19:25:08 5b82ec6fbbd2f4195ad06dd911de3817373ad5bf"
662655
663656
/*
664657
** CAPI3REF: Run-Time Library Version Numbers
665658
** KEYWORDS: sqlite3_version, sqlite3_sourceid
666659
**
@@ -8792,10 +8785,11 @@
87928785
SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*);
87938786
SQLITE_PRIVATE int sqlite3PagerNosync(Pager*);
87948787
SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*);
87958788
SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*);
87968789
SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *, int, int, int *);
8790
+SQLITE_PRIVATE void sqlite3PagerClearCache(Pager *);
87978791
87988792
/* Functions used to truncate the database file. */
87998793
SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno);
88008794
88018795
#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL)
@@ -10189,12 +10183,13 @@
1018910183
IndexSample *aSample; /* Samples of the left-most key */
1019010184
#endif
1019110185
};
1019210186
1019310187
/*
10194
-** Each sample stored in the sqlite_stat2 table is represented in memory
10195
-** using a structure of this type.
10188
+** Each sample stored in the sqlite_stat3 table is represented in memory
10189
+** using a structure of this type. See documentation at the top of the
10190
+** analyze.c source file for additional information.
1019610191
*/
1019710192
struct IndexSample {
1019810193
union {
1019910194
char *z; /* Value if eType is SQLITE_TEXT or SQLITE_BLOB */
1020010195
double r; /* Value if eType is SQLITE_FLOAT */
@@ -12293,13 +12288,10 @@
1229312288
"ENABLE_OVERSIZE_CELL_CHECK",
1229412289
#endif
1229512290
#ifdef SQLITE_ENABLE_RTREE
1229612291
"ENABLE_RTREE",
1229712292
#endif
12298
-#ifdef SQLITE_ENABLE_STAT2
12299
- "ENABLE_STAT2",
12300
-#endif
1230112293
#ifdef SQLITE_ENABLE_STAT3
1230212294
"ENABLE_STAT3",
1230312295
#endif
1230412296
#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
1230512297
"ENABLE_UNLOCK_NOTIFY",
@@ -12996,10 +12988,11 @@
1299612988
SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
1299712989
SQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *, int);
1299812990
SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*);
1299912991
SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *);
1300012992
SQLITE_PRIVATE void sqlite3VdbeMemStoreType(Mem *pMem);
12993
+SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p);
1300112994
1300212995
#ifdef SQLITE_OMIT_MERGE_SORT
1300312996
# define sqlite3VdbeSorterInit(Y,Z) SQLITE_OK
1300412997
# define sqlite3VdbeSorterWrite(X,Y,Z) SQLITE_OK
1300512998
# define sqlite3VdbeSorterClose(Y,Z)
@@ -29483,17 +29476,17 @@
2948329476
** "<path to db>-journal"
2948429477
** "<path to db>-wal"
2948529478
** "<path to db>-journalNN"
2948629479
** "<path to db>-walNN"
2948729480
**
29488
- ** where NN is a 4 digit decimal number. The NN naming schemes are
29481
+ ** where NN is a decimal number. The NN naming schemes are
2948929482
** used by the test_multiplex.c module.
2949029483
*/
2949129484
nDb = sqlite3Strlen30(zPath) - 1;
2949229485
#ifdef SQLITE_ENABLE_8_3_NAMES
29493
- while( nDb>0 && zPath[nDb]!='-' && zPath[nDb]!='/' ) nDb--;
29494
- if( nDb==0 || zPath[nDb]=='/' ) return SQLITE_OK;
29486
+ while( nDb>0 && !sqlite3Isalnum(zPath[nDb]) ) nDb--;
29487
+ if( nDb==0 || zPath[nDb]!='-' ) return SQLITE_OK;
2949529488
#else
2949629489
while( zPath[nDb]!='-' ){
2949729490
assert( nDb>0 );
2949829491
assert( zPath[nDb]!='\n' );
2949929492
nDb--;
@@ -44163,10 +44156,17 @@
4416344156
pPager->pWal = 0;
4416444157
}
4416544158
}
4416644159
return rc;
4416744160
}
44161
+
44162
+/*
44163
+** Unless this is an in-memory or temporary database, clear the pager cache.
44164
+*/
44165
+SQLITE_PRIVATE void sqlite3PagerClearCache(Pager *pPager){
44166
+ if( !MEMDB && pPager->tempFile==0 ) pager_reset(pPager);
44167
+}
4416844168
4416944169
#ifdef SQLITE_HAS_CODEC
4417044170
/*
4417144171
** This function is called by the wal module when writing page content
4417244172
** into the log file.
@@ -57006,10 +57006,12 @@
5700657006
sqlite3_backup_step(&b, 0x7FFFFFFF);
5700757007
assert( b.rc!=SQLITE_OK );
5700857008
rc = sqlite3_backup_finish(&b);
5700957009
if( rc==SQLITE_OK ){
5701057010
pTo->pBt->pageSizeFixed = 0;
57011
+ }else{
57012
+ sqlite3PagerClearCache(sqlite3BtreePager(b.pDest));
5701157013
}
5701257014
5701357015
assert( sqlite3BtreeIsInTrans(pTo)==0 );
5701457016
sqlite3BtreeLeave(pFrom);
5701557017
sqlite3BtreeLeave(pTo);
@@ -60480,10 +60482,34 @@
6048060482
** in p->rc. This routine sets that result back to SQLITE_OK.
6048160483
*/
6048260484
SQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe *p){
6048360485
p->rc = SQLITE_OK;
6048460486
}
60487
+
60488
+/*
60489
+** Copy the error code and error message belonging to the VDBE passed
60490
+** as the first argument to its database handle (so that they will be
60491
+** returned by calls to sqlite3_errcode() and sqlite3_errmsg()).
60492
+**
60493
+** This function does not clear the VDBE error code or message, just
60494
+** copies them to the database handle.
60495
+*/
60496
+SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p){
60497
+ sqlite3 *db = p->db;
60498
+ int rc = p->rc;
60499
+ if( p->zErrMsg ){
60500
+ u8 mallocFailed = db->mallocFailed;
60501
+ sqlite3BeginBenignMalloc();
60502
+ sqlite3ValueSetStr(db->pErr, -1, p->zErrMsg, SQLITE_UTF8, SQLITE_TRANSIENT);
60503
+ sqlite3EndBenignMalloc();
60504
+ db->mallocFailed = mallocFailed;
60505
+ db->errCode = rc;
60506
+ }else{
60507
+ sqlite3Error(db, rc, 0);
60508
+ }
60509
+ return rc;
60510
+}
6048560511
6048660512
/*
6048760513
** Clean up a VDBE after execution but do not delete the VDBE just yet.
6048860514
** Write any error messages into *pzErrMsg. Return the result code.
6048960515
**
@@ -60508,22 +60534,13 @@
6050860534
** and error message from the VDBE into the main database structure. But
6050960535
** if the VDBE has just been set to run but has not actually executed any
6051060536
** instructions yet, leave the main database error information unchanged.
6051160537
*/
6051260538
if( p->pc>=0 ){
60513
- if( p->zErrMsg ){
60514
- sqlite3BeginBenignMalloc();
60515
- sqlite3ValueSetStr(db->pErr,-1,p->zErrMsg,SQLITE_UTF8,SQLITE_TRANSIENT);
60516
- sqlite3EndBenignMalloc();
60517
- db->errCode = p->rc;
60518
- sqlite3DbFree(db, p->zErrMsg);
60519
- p->zErrMsg = 0;
60520
- }else if( p->rc ){
60521
- sqlite3Error(db, p->rc, 0);
60522
- }else{
60523
- sqlite3Error(db, SQLITE_OK, 0);
60524
- }
60539
+ sqlite3VdbeTransferError(p);
60540
+ sqlite3DbFree(db, p->zErrMsg);
60541
+ p->zErrMsg = 0;
6052560542
if( p->runOnlyOnce ) p->expired = 1;
6052660543
}else if( p->rc && p->expired ){
6052760544
/* The expired flag was set on the VDBE before the first call
6052860545
** to sqlite3_step(). For consistency (since sqlite3_step() was
6052960546
** called), set the database error in this case as well.
@@ -61865,11 +61882,11 @@
6186561882
if( p->isPrepareV2 && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){
6186661883
/* If this statement was prepared using sqlite3_prepare_v2(), and an
6186761884
** error has occured, then return the error code in p->rc to the
6186861885
** caller. Set the error code in the database handle to the same value.
6186961886
*/
61870
- rc = db->errCode = p->rc;
61887
+ rc = sqlite3VdbeTransferError(p);
6187161888
}
6187261889
return (rc&db->errMask);
6187361890
}
6187461891
6187561892
/*
@@ -67765,13 +67782,12 @@
6776567782
6776667783
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
6776767784
u.bn.pC = p->apCsr[pOp->p1];
6776867785
assert( u.bn.pC!=0 );
6776967786
u.bn.pCrsr = u.bn.pC->pCursor;
67770
- if( NEVER(u.bn.pCrsr==0) ){
67771
- u.bn.res = 1;
67772
- }else{
67787
+ u.bn.res = 0;
67788
+ if( ALWAYS(u.bn.pCrsr!=0) ){
6777367789
rc = sqlite3BtreeLast(u.bn.pCrsr, &u.bn.res);
6777467790
}
6777567791
u.bn.pC->nullRow = (u8)u.bn.res;
6777667792
u.bn.pC->deferredMoveto = 0;
6777767793
u.bn.pC->rowidIsValid = 0;
@@ -77610,20 +77626,20 @@
7761077626
#ifndef SQLITE_OMIT_ANALYZE
7761177627
7761277628
/*
7761377629
** This routine generates code that opens the sqlite_stat1 table for
7761477630
** writing with cursor iStatCur. If the library was built with the
77615
-** SQLITE_ENABLE_STAT2 macro defined, then the sqlite_stat2 table is
77631
+** SQLITE_ENABLE_STAT3 macro defined, then the sqlite_stat3 table is
7761677632
** opened for writing using cursor (iStatCur+1)
7761777633
**
7761877634
** If the sqlite_stat1 tables does not previously exist, it is created.
77619
-** Similarly, if the sqlite_stat2 table does not exist and the library
77620
-** is compiled with SQLITE_ENABLE_STAT2 defined, it is created.
77635
+** Similarly, if the sqlite_stat3 table does not exist and the library
77636
+** is compiled with SQLITE_ENABLE_STAT3 defined, it is created.
7762177637
**
7762277638
** Argument zWhere may be a pointer to a buffer containing a table name,
7762377639
** or it may be a NULL pointer. If it is not NULL, then all entries in
77624
-** the sqlite_stat1 and (if applicable) sqlite_stat2 tables associated
77640
+** the sqlite_stat1 and (if applicable) sqlite_stat3 tables associated
7762577641
** with the named table are deleted. If zWhere==0, then code is generated
7762677642
** to delete all stat table entries.
7762777643
*/
7762877644
static void openStatTable(
7762977645
Parse *pParse, /* Parsing context */
@@ -81404,31 +81420,28 @@
8140481420
}
8140581421
#endif
8140681422
}
8140781423
8140881424
/*
81409
-** Remove entries from the sqlite_stat1 and sqlite_stat2 tables
81425
+** Remove entries from the sqlite_statN tables (for N in (1,2,3))
8141081426
** after a DROP INDEX or DROP TABLE command.
8141181427
*/
8141281428
static void sqlite3ClearStatTables(
8141381429
Parse *pParse, /* The parsing context */
8141481430
int iDb, /* The database number */
8141581431
const char *zType, /* "idx" or "tbl" */
8141681432
const char *zName /* Name of index or table */
8141781433
){
81418
- static const char *azStatTab[] = {
81419
- "sqlite_stat1",
81420
- "sqlite_stat2",
81421
- "sqlite_stat3",
81422
- };
8142381434
int i;
8142481435
const char *zDbName = pParse->db->aDb[iDb].zName;
81425
- for(i=0; i<ArraySize(azStatTab); i++){
81426
- if( sqlite3FindTable(pParse->db, azStatTab[i], zDbName) ){
81436
+ for(i=1; i<=3; i++){
81437
+ char zTab[24];
81438
+ sqlite3_snprintf(sizeof(zTab),zTab,"sqlite_stat%d",i);
81439
+ if( sqlite3FindTable(pParse->db, zTab, zDbName) ){
8142781440
sqlite3NestedParse(pParse,
8142881441
"DELETE FROM %Q.%s WHERE %s=%Q",
81429
- zDbName, azStatTab[i], zType, zName
81442
+ zDbName, zTab, zType, zName
8143081443
);
8143181444
}
8143281445
}
8143381446
}
8143481447
@@ -89250,12 +89263,14 @@
8925089263
int (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*);
8925189264
int (*busy_handler)(sqlite3*,int(*)(void*,int),void*);
8925289265
int (*busy_timeout)(sqlite3*,int ms);
8925389266
int (*changes)(sqlite3*);
8925489267
int (*close)(sqlite3*);
89255
- int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,int eTextRep,const char*));
89256
- int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,int eTextRep,const void*));
89268
+ int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,
89269
+ int eTextRep,const char*));
89270
+ int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,
89271
+ int eTextRep,const void*));
8925789272
const void * (*column_blob)(sqlite3_stmt*,int iCol);
8925889273
int (*column_bytes)(sqlite3_stmt*,int iCol);
8925989274
int (*column_bytes16)(sqlite3_stmt*,int iCol);
8926089275
int (*column_count)(sqlite3_stmt*pStmt);
8926189276
const char * (*column_database_name)(sqlite3_stmt*,int);
@@ -89276,14 +89291,22 @@
8927689291
int (*column_type)(sqlite3_stmt*,int iCol);
8927789292
sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);
8927889293
void * (*commit_hook)(sqlite3*,int(*)(void*),void*);
8927989294
int (*complete)(const char*sql);
8928089295
int (*complete16)(const void*sql);
89281
- int (*create_collation)(sqlite3*,const char*,int,void*,int(*)(void*,int,const void*,int,const void*));
89282
- int (*create_collation16)(sqlite3*,const void*,int,void*,int(*)(void*,int,const void*,int,const void*));
89283
- int (*create_function)(sqlite3*,const char*,int,int,void*,void (*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void (*xFinal)(sqlite3_context*));
89284
- int (*create_function16)(sqlite3*,const void*,int,int,void*,void (*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void (*xFinal)(sqlite3_context*));
89296
+ int (*create_collation)(sqlite3*,const char*,int,void*,
89297
+ int(*)(void*,int,const void*,int,const void*));
89298
+ int (*create_collation16)(sqlite3*,const void*,int,void*,
89299
+ int(*)(void*,int,const void*,int,const void*));
89300
+ int (*create_function)(sqlite3*,const char*,int,int,void*,
89301
+ void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
89302
+ void (*xStep)(sqlite3_context*,int,sqlite3_value**),
89303
+ void (*xFinal)(sqlite3_context*));
89304
+ int (*create_function16)(sqlite3*,const void*,int,int,void*,
89305
+ void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
89306
+ void (*xStep)(sqlite3_context*,int,sqlite3_value**),
89307
+ void (*xFinal)(sqlite3_context*));
8928589308
int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);
8928689309
int (*data_count)(sqlite3_stmt*pStmt);
8928789310
sqlite3 * (*db_handle)(sqlite3_stmt*);
8928889311
int (*declare_vtab)(sqlite3*,const char*);
8928989312
int (*enable_shared_cache)(int);
@@ -89324,20 +89347,23 @@
8932489347
void (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));
8932589348
void (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));
8932689349
void (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));
8932789350
void (*result_value)(sqlite3_context*,sqlite3_value*);
8932889351
void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);
89329
- int (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,const char*,const char*),void*);
89352
+ int (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,
89353
+ const char*,const char*),void*);
8933089354
void (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));
8933189355
char * (*snprintf)(int,char*,const char*,...);
8933289356
int (*step)(sqlite3_stmt*);
89333
- int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,char const**,char const**,int*,int*,int*);
89357
+ int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,
89358
+ char const**,char const**,int*,int*,int*);
8933489359
void (*thread_cleanup)(void);
8933589360
int (*total_changes)(sqlite3*);
8933689361
void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);
8933789362
int (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);
89338
- void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,sqlite_int64),void*);
89363
+ void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,
89364
+ sqlite_int64),void*);
8933989365
void * (*user_data)(sqlite3_context*);
8934089366
const void * (*value_blob)(sqlite3_value*);
8934189367
int (*value_bytes)(sqlite3_value*);
8934289368
int (*value_bytes16)(sqlite3_value*);
8934389369
double (*value_double)(sqlite3_value*);
@@ -89355,19 +89381,23 @@
8935589381
/* Added by 3.3.13 */
8935689382
int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
8935789383
int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
8935889384
int (*clear_bindings)(sqlite3_stmt*);
8935989385
/* Added by 3.4.1 */
89360
- int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,void (*xDestroy)(void *));
89386
+ int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,
89387
+ void (*xDestroy)(void *));
8936189388
/* Added by 3.5.0 */
8936289389
int (*bind_zeroblob)(sqlite3_stmt*,int,int);
8936389390
int (*blob_bytes)(sqlite3_blob*);
8936489391
int (*blob_close)(sqlite3_blob*);
89365
- int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,int,sqlite3_blob**);
89392
+ int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,
89393
+ int,sqlite3_blob**);
8936689394
int (*blob_read)(sqlite3_blob*,void*,int,int);
8936789395
int (*blob_write)(sqlite3_blob*,const void*,int,int);
89368
- int (*create_collation_v2)(sqlite3*,const char*,int,void*,int(*)(void*,int,const void*,int,const void*),void(*)(void*));
89396
+ int (*create_collation_v2)(sqlite3*,const char*,int,void*,
89397
+ int(*)(void*,int,const void*,int,const void*),
89398
+ void(*)(void*));
8936989399
int (*file_control)(sqlite3*,const char*,int,void*);
8937089400
sqlite3_int64 (*memory_highwater)(int);
8937189401
sqlite3_int64 (*memory_used)(void);
8937289402
sqlite3_mutex *(*mutex_alloc)(int);
8937389403
void (*mutex_enter)(sqlite3_mutex*);
@@ -89399,11 +89429,15 @@
8939989429
int (*backup_pagecount)(sqlite3_backup*);
8940089430
int (*backup_remaining)(sqlite3_backup*);
8940189431
int (*backup_step)(sqlite3_backup*,int);
8940289432
const char *(*compileoption_get)(int);
8940389433
int (*compileoption_used)(const char*);
89404
- int (*create_function_v2)(sqlite3*,const char*,int,int,void*,void (*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void (*xFinal)(sqlite3_context*),void(*xDestroy)(void*));
89434
+ int (*create_function_v2)(sqlite3*,const char*,int,int,void*,
89435
+ void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
89436
+ void (*xStep)(sqlite3_context*,int,sqlite3_value**),
89437
+ void (*xFinal)(sqlite3_context*),
89438
+ void(*xDestroy)(void*));
8940589439
int (*db_config)(sqlite3*,int,...);
8940689440
sqlite3_mutex *(*db_mutex)(sqlite3*);
8940789441
int (*db_status)(sqlite3*,int,int*,int*,int);
8940889442
int (*extended_errcode)(sqlite3*);
8940989443
void (*log)(int,const char*,...);
@@ -100485,11 +100519,11 @@
100485100519
if( db->aVTrans ){
100486100520
int i;
100487100521
for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){
100488100522
VTable *pVTab = db->aVTrans[i];
100489100523
const sqlite3_module *pMod = pVTab->pMod->pModule;
100490
- if( pMod->iVersion>=2 ){
100524
+ if( pVTab->pVtab && pMod->iVersion>=2 ){
100491100525
int (*xMethod)(sqlite3_vtab *, int);
100492100526
switch( op ){
100493100527
case SAVEPOINT_BEGIN:
100494100528
xMethod = pMod->xSavepoint;
100495100529
pVTab->iSavepoint = iSavepoint+1;
@@ -100500,11 +100534,11 @@
100500100534
default:
100501100535
xMethod = pMod->xRelease;
100502100536
break;
100503100537
}
100504100538
if( xMethod && pVTab->iSavepoint>iSavepoint ){
100505
- rc = xMethod(db->aVTrans[i]->pVtab, iSavepoint);
100539
+ rc = xMethod(pVTab->pVtab, iSavepoint);
100506100540
}
100507100541
}
100508100542
}
100509100543
}
100510100544
return rc;
@@ -101367,11 +101401,11 @@
101367101401
int iCol = pRight->iColumn;
101368101402
pVal = sqlite3VdbeGetValue(pReprepare, iCol, SQLITE_AFF_NONE);
101369101403
if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
101370101404
z = (char *)sqlite3_value_text(pVal);
101371101405
}
101372
- sqlite3VdbeSetVarmask(pParse->pVdbe, iCol); /* IMP: R-31526-56213 */
101406
+ sqlite3VdbeSetVarmask(pParse->pVdbe, iCol);
101373101407
assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );
101374101408
}else if( op==TK_STRING ){
101375101409
z = pRight->u.zToken;
101376101410
}
101377101411
if( z ){
@@ -101385,11 +101419,11 @@
101385101419
pPrefix = sqlite3Expr(db, TK_STRING, z);
101386101420
if( pPrefix ) pPrefix->u.zToken[cnt] = 0;
101387101421
*ppPrefix = pPrefix;
101388101422
if( op==TK_VARIABLE ){
101389101423
Vdbe *v = pParse->pVdbe;
101390
- sqlite3VdbeSetVarmask(v, pRight->iColumn); /* IMP: R-31526-56213 */
101424
+ sqlite3VdbeSetVarmask(v, pRight->iColumn);
101391101425
if( *pisComplete && pRight->u.zToken[1] ){
101392101426
/* If the rhs of the LIKE expression is a variable, and the current
101393101427
** value of the variable means there is no need to invoke the LIKE
101394101428
** function, then no OP_Variable will be added to the program.
101395101429
** This causes problems for the sqlite3_bind_parameter_name()
@@ -103299,11 +103333,11 @@
103299103333
){
103300103334
if( pExpr->op==TK_VARIABLE
103301103335
|| (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
103302103336
){
103303103337
int iVar = pExpr->iColumn;
103304
- sqlite3VdbeSetVarmask(pParse->pVdbe, iVar); /* IMP: R-31526-56213 */
103338
+ sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);
103305103339
*pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff);
103306103340
return SQLITE_OK;
103307103341
}
103308103342
return sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, aff, pp);
103309103343
}
@@ -103829,11 +103863,11 @@
103829103863
** a table or index. The actual times can vary, with the size of
103830103864
** records being an important factor. Both moves and searches are
103831103865
** slower with larger records, presumably because fewer records fit
103832103866
** on one page and hence more pages have to be fetched.
103833103867
**
103834
- ** The ANALYZE command and the sqlite_stat1 and sqlite_stat2 tables do
103868
+ ** The ANALYZE command and the sqlite_stat1 and sqlite_stat3 tables do
103835103869
** not give us data on the relative sizes of table and index records.
103836103870
** So this computation assumes table records are about twice as big
103837103871
** as index records
103838103872
*/
103839103873
if( (wsFlags & WHERE_NOT_FULLSCAN)==0 ){
103840103874
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -314,17 +314,10 @@
314 #endif
315 #ifdef HAVE_INTTYPES_H
316 #include <inttypes.h>
317 #endif
318
319 /*
320 ** The number of samples of an index that SQLite takes in order to
321 ** construct a histogram of the table content when running ANALYZE
322 ** and with SQLITE_ENABLE_STAT2
323 */
324 #define SQLITE_INDEX_SAMPLES 10
325
326 /*
327 ** The following macros are used to cast pointers to integers and
328 ** integers to pointers. The way you do this varies from one compiler
329 ** to the next, so we have developed the following set of #if statements
330 ** to generate appropriate macros for a wide range of compilers.
@@ -656,11 +649,11 @@
656 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
657 ** [sqlite_version()] and [sqlite_source_id()].
658 */
659 #define SQLITE_VERSION "3.7.9"
660 #define SQLITE_VERSION_NUMBER 3007009
661 #define SQLITE_SOURCE_ID "2011-10-20 00:55:54 4344483f7d7f64dffadde0053e6c745948db9486"
662
663 /*
664 ** CAPI3REF: Run-Time Library Version Numbers
665 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
666 **
@@ -8792,10 +8785,11 @@
8792 SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*);
8793 SQLITE_PRIVATE int sqlite3PagerNosync(Pager*);
8794 SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*);
8795 SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*);
8796 SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *, int, int, int *);
 
8797
8798 /* Functions used to truncate the database file. */
8799 SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno);
8800
8801 #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL)
@@ -10189,12 +10183,13 @@
10189 IndexSample *aSample; /* Samples of the left-most key */
10190 #endif
10191 };
10192
10193 /*
10194 ** Each sample stored in the sqlite_stat2 table is represented in memory
10195 ** using a structure of this type.
 
10196 */
10197 struct IndexSample {
10198 union {
10199 char *z; /* Value if eType is SQLITE_TEXT or SQLITE_BLOB */
10200 double r; /* Value if eType is SQLITE_FLOAT */
@@ -12293,13 +12288,10 @@
12293 "ENABLE_OVERSIZE_CELL_CHECK",
12294 #endif
12295 #ifdef SQLITE_ENABLE_RTREE
12296 "ENABLE_RTREE",
12297 #endif
12298 #ifdef SQLITE_ENABLE_STAT2
12299 "ENABLE_STAT2",
12300 #endif
12301 #ifdef SQLITE_ENABLE_STAT3
12302 "ENABLE_STAT3",
12303 #endif
12304 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
12305 "ENABLE_UNLOCK_NOTIFY",
@@ -12996,10 +12988,11 @@
12996 SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
12997 SQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *, int);
12998 SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*);
12999 SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *);
13000 SQLITE_PRIVATE void sqlite3VdbeMemStoreType(Mem *pMem);
 
13001
13002 #ifdef SQLITE_OMIT_MERGE_SORT
13003 # define sqlite3VdbeSorterInit(Y,Z) SQLITE_OK
13004 # define sqlite3VdbeSorterWrite(X,Y,Z) SQLITE_OK
13005 # define sqlite3VdbeSorterClose(Y,Z)
@@ -29483,17 +29476,17 @@
29483 ** "<path to db>-journal"
29484 ** "<path to db>-wal"
29485 ** "<path to db>-journalNN"
29486 ** "<path to db>-walNN"
29487 **
29488 ** where NN is a 4 digit decimal number. The NN naming schemes are
29489 ** used by the test_multiplex.c module.
29490 */
29491 nDb = sqlite3Strlen30(zPath) - 1;
29492 #ifdef SQLITE_ENABLE_8_3_NAMES
29493 while( nDb>0 && zPath[nDb]!='-' && zPath[nDb]!='/' ) nDb--;
29494 if( nDb==0 || zPath[nDb]=='/' ) return SQLITE_OK;
29495 #else
29496 while( zPath[nDb]!='-' ){
29497 assert( nDb>0 );
29498 assert( zPath[nDb]!='\n' );
29499 nDb--;
@@ -44163,10 +44156,17 @@
44163 pPager->pWal = 0;
44164 }
44165 }
44166 return rc;
44167 }
 
 
 
 
 
 
 
44168
44169 #ifdef SQLITE_HAS_CODEC
44170 /*
44171 ** This function is called by the wal module when writing page content
44172 ** into the log file.
@@ -57006,10 +57006,12 @@
57006 sqlite3_backup_step(&b, 0x7FFFFFFF);
57007 assert( b.rc!=SQLITE_OK );
57008 rc = sqlite3_backup_finish(&b);
57009 if( rc==SQLITE_OK ){
57010 pTo->pBt->pageSizeFixed = 0;
 
 
57011 }
57012
57013 assert( sqlite3BtreeIsInTrans(pTo)==0 );
57014 sqlite3BtreeLeave(pFrom);
57015 sqlite3BtreeLeave(pTo);
@@ -60480,10 +60482,34 @@
60480 ** in p->rc. This routine sets that result back to SQLITE_OK.
60481 */
60482 SQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe *p){
60483 p->rc = SQLITE_OK;
60484 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60485
60486 /*
60487 ** Clean up a VDBE after execution but do not delete the VDBE just yet.
60488 ** Write any error messages into *pzErrMsg. Return the result code.
60489 **
@@ -60508,22 +60534,13 @@
60508 ** and error message from the VDBE into the main database structure. But
60509 ** if the VDBE has just been set to run but has not actually executed any
60510 ** instructions yet, leave the main database error information unchanged.
60511 */
60512 if( p->pc>=0 ){
60513 if( p->zErrMsg ){
60514 sqlite3BeginBenignMalloc();
60515 sqlite3ValueSetStr(db->pErr,-1,p->zErrMsg,SQLITE_UTF8,SQLITE_TRANSIENT);
60516 sqlite3EndBenignMalloc();
60517 db->errCode = p->rc;
60518 sqlite3DbFree(db, p->zErrMsg);
60519 p->zErrMsg = 0;
60520 }else if( p->rc ){
60521 sqlite3Error(db, p->rc, 0);
60522 }else{
60523 sqlite3Error(db, SQLITE_OK, 0);
60524 }
60525 if( p->runOnlyOnce ) p->expired = 1;
60526 }else if( p->rc && p->expired ){
60527 /* The expired flag was set on the VDBE before the first call
60528 ** to sqlite3_step(). For consistency (since sqlite3_step() was
60529 ** called), set the database error in this case as well.
@@ -61865,11 +61882,11 @@
61865 if( p->isPrepareV2 && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){
61866 /* If this statement was prepared using sqlite3_prepare_v2(), and an
61867 ** error has occured, then return the error code in p->rc to the
61868 ** caller. Set the error code in the database handle to the same value.
61869 */
61870 rc = db->errCode = p->rc;
61871 }
61872 return (rc&db->errMask);
61873 }
61874
61875 /*
@@ -67765,13 +67782,12 @@
67765
67766 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
67767 u.bn.pC = p->apCsr[pOp->p1];
67768 assert( u.bn.pC!=0 );
67769 u.bn.pCrsr = u.bn.pC->pCursor;
67770 if( NEVER(u.bn.pCrsr==0) ){
67771 u.bn.res = 1;
67772 }else{
67773 rc = sqlite3BtreeLast(u.bn.pCrsr, &u.bn.res);
67774 }
67775 u.bn.pC->nullRow = (u8)u.bn.res;
67776 u.bn.pC->deferredMoveto = 0;
67777 u.bn.pC->rowidIsValid = 0;
@@ -77610,20 +77626,20 @@
77610 #ifndef SQLITE_OMIT_ANALYZE
77611
77612 /*
77613 ** This routine generates code that opens the sqlite_stat1 table for
77614 ** writing with cursor iStatCur. If the library was built with the
77615 ** SQLITE_ENABLE_STAT2 macro defined, then the sqlite_stat2 table is
77616 ** opened for writing using cursor (iStatCur+1)
77617 **
77618 ** If the sqlite_stat1 tables does not previously exist, it is created.
77619 ** Similarly, if the sqlite_stat2 table does not exist and the library
77620 ** is compiled with SQLITE_ENABLE_STAT2 defined, it is created.
77621 **
77622 ** Argument zWhere may be a pointer to a buffer containing a table name,
77623 ** or it may be a NULL pointer. If it is not NULL, then all entries in
77624 ** the sqlite_stat1 and (if applicable) sqlite_stat2 tables associated
77625 ** with the named table are deleted. If zWhere==0, then code is generated
77626 ** to delete all stat table entries.
77627 */
77628 static void openStatTable(
77629 Parse *pParse, /* Parsing context */
@@ -81404,31 +81420,28 @@
81404 }
81405 #endif
81406 }
81407
81408 /*
81409 ** Remove entries from the sqlite_stat1 and sqlite_stat2 tables
81410 ** after a DROP INDEX or DROP TABLE command.
81411 */
81412 static void sqlite3ClearStatTables(
81413 Parse *pParse, /* The parsing context */
81414 int iDb, /* The database number */
81415 const char *zType, /* "idx" or "tbl" */
81416 const char *zName /* Name of index or table */
81417 ){
81418 static const char *azStatTab[] = {
81419 "sqlite_stat1",
81420 "sqlite_stat2",
81421 "sqlite_stat3",
81422 };
81423 int i;
81424 const char *zDbName = pParse->db->aDb[iDb].zName;
81425 for(i=0; i<ArraySize(azStatTab); i++){
81426 if( sqlite3FindTable(pParse->db, azStatTab[i], zDbName) ){
 
 
81427 sqlite3NestedParse(pParse,
81428 "DELETE FROM %Q.%s WHERE %s=%Q",
81429 zDbName, azStatTab[i], zType, zName
81430 );
81431 }
81432 }
81433 }
81434
@@ -89250,12 +89263,14 @@
89250 int (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*);
89251 int (*busy_handler)(sqlite3*,int(*)(void*,int),void*);
89252 int (*busy_timeout)(sqlite3*,int ms);
89253 int (*changes)(sqlite3*);
89254 int (*close)(sqlite3*);
89255 int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,int eTextRep,const char*));
89256 int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,int eTextRep,const void*));
 
 
89257 const void * (*column_blob)(sqlite3_stmt*,int iCol);
89258 int (*column_bytes)(sqlite3_stmt*,int iCol);
89259 int (*column_bytes16)(sqlite3_stmt*,int iCol);
89260 int (*column_count)(sqlite3_stmt*pStmt);
89261 const char * (*column_database_name)(sqlite3_stmt*,int);
@@ -89276,14 +89291,22 @@
89276 int (*column_type)(sqlite3_stmt*,int iCol);
89277 sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);
89278 void * (*commit_hook)(sqlite3*,int(*)(void*),void*);
89279 int (*complete)(const char*sql);
89280 int (*complete16)(const void*sql);
89281 int (*create_collation)(sqlite3*,const char*,int,void*,int(*)(void*,int,const void*,int,const void*));
89282 int (*create_collation16)(sqlite3*,const void*,int,void*,int(*)(void*,int,const void*,int,const void*));
89283 int (*create_function)(sqlite3*,const char*,int,int,void*,void (*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void (*xFinal)(sqlite3_context*));
89284 int (*create_function16)(sqlite3*,const void*,int,int,void*,void (*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void (*xFinal)(sqlite3_context*));
 
 
 
 
 
 
 
 
89285 int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);
89286 int (*data_count)(sqlite3_stmt*pStmt);
89287 sqlite3 * (*db_handle)(sqlite3_stmt*);
89288 int (*declare_vtab)(sqlite3*,const char*);
89289 int (*enable_shared_cache)(int);
@@ -89324,20 +89347,23 @@
89324 void (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));
89325 void (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));
89326 void (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));
89327 void (*result_value)(sqlite3_context*,sqlite3_value*);
89328 void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);
89329 int (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,const char*,const char*),void*);
 
89330 void (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));
89331 char * (*snprintf)(int,char*,const char*,...);
89332 int (*step)(sqlite3_stmt*);
89333 int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,char const**,char const**,int*,int*,int*);
 
89334 void (*thread_cleanup)(void);
89335 int (*total_changes)(sqlite3*);
89336 void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);
89337 int (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);
89338 void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,sqlite_int64),void*);
 
89339 void * (*user_data)(sqlite3_context*);
89340 const void * (*value_blob)(sqlite3_value*);
89341 int (*value_bytes)(sqlite3_value*);
89342 int (*value_bytes16)(sqlite3_value*);
89343 double (*value_double)(sqlite3_value*);
@@ -89355,19 +89381,23 @@
89355 /* Added by 3.3.13 */
89356 int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
89357 int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
89358 int (*clear_bindings)(sqlite3_stmt*);
89359 /* Added by 3.4.1 */
89360 int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,void (*xDestroy)(void *));
 
89361 /* Added by 3.5.0 */
89362 int (*bind_zeroblob)(sqlite3_stmt*,int,int);
89363 int (*blob_bytes)(sqlite3_blob*);
89364 int (*blob_close)(sqlite3_blob*);
89365 int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,int,sqlite3_blob**);
 
89366 int (*blob_read)(sqlite3_blob*,void*,int,int);
89367 int (*blob_write)(sqlite3_blob*,const void*,int,int);
89368 int (*create_collation_v2)(sqlite3*,const char*,int,void*,int(*)(void*,int,const void*,int,const void*),void(*)(void*));
 
 
89369 int (*file_control)(sqlite3*,const char*,int,void*);
89370 sqlite3_int64 (*memory_highwater)(int);
89371 sqlite3_int64 (*memory_used)(void);
89372 sqlite3_mutex *(*mutex_alloc)(int);
89373 void (*mutex_enter)(sqlite3_mutex*);
@@ -89399,11 +89429,15 @@
89399 int (*backup_pagecount)(sqlite3_backup*);
89400 int (*backup_remaining)(sqlite3_backup*);
89401 int (*backup_step)(sqlite3_backup*,int);
89402 const char *(*compileoption_get)(int);
89403 int (*compileoption_used)(const char*);
89404 int (*create_function_v2)(sqlite3*,const char*,int,int,void*,void (*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void (*xFinal)(sqlite3_context*),void(*xDestroy)(void*));
 
 
 
 
89405 int (*db_config)(sqlite3*,int,...);
89406 sqlite3_mutex *(*db_mutex)(sqlite3*);
89407 int (*db_status)(sqlite3*,int,int*,int*,int);
89408 int (*extended_errcode)(sqlite3*);
89409 void (*log)(int,const char*,...);
@@ -100485,11 +100519,11 @@
100485 if( db->aVTrans ){
100486 int i;
100487 for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){
100488 VTable *pVTab = db->aVTrans[i];
100489 const sqlite3_module *pMod = pVTab->pMod->pModule;
100490 if( pMod->iVersion>=2 ){
100491 int (*xMethod)(sqlite3_vtab *, int);
100492 switch( op ){
100493 case SAVEPOINT_BEGIN:
100494 xMethod = pMod->xSavepoint;
100495 pVTab->iSavepoint = iSavepoint+1;
@@ -100500,11 +100534,11 @@
100500 default:
100501 xMethod = pMod->xRelease;
100502 break;
100503 }
100504 if( xMethod && pVTab->iSavepoint>iSavepoint ){
100505 rc = xMethod(db->aVTrans[i]->pVtab, iSavepoint);
100506 }
100507 }
100508 }
100509 }
100510 return rc;
@@ -101367,11 +101401,11 @@
101367 int iCol = pRight->iColumn;
101368 pVal = sqlite3VdbeGetValue(pReprepare, iCol, SQLITE_AFF_NONE);
101369 if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
101370 z = (char *)sqlite3_value_text(pVal);
101371 }
101372 sqlite3VdbeSetVarmask(pParse->pVdbe, iCol); /* IMP: R-31526-56213 */
101373 assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );
101374 }else if( op==TK_STRING ){
101375 z = pRight->u.zToken;
101376 }
101377 if( z ){
@@ -101385,11 +101419,11 @@
101385 pPrefix = sqlite3Expr(db, TK_STRING, z);
101386 if( pPrefix ) pPrefix->u.zToken[cnt] = 0;
101387 *ppPrefix = pPrefix;
101388 if( op==TK_VARIABLE ){
101389 Vdbe *v = pParse->pVdbe;
101390 sqlite3VdbeSetVarmask(v, pRight->iColumn); /* IMP: R-31526-56213 */
101391 if( *pisComplete && pRight->u.zToken[1] ){
101392 /* If the rhs of the LIKE expression is a variable, and the current
101393 ** value of the variable means there is no need to invoke the LIKE
101394 ** function, then no OP_Variable will be added to the program.
101395 ** This causes problems for the sqlite3_bind_parameter_name()
@@ -103299,11 +103333,11 @@
103299 ){
103300 if( pExpr->op==TK_VARIABLE
103301 || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
103302 ){
103303 int iVar = pExpr->iColumn;
103304 sqlite3VdbeSetVarmask(pParse->pVdbe, iVar); /* IMP: R-31526-56213 */
103305 *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff);
103306 return SQLITE_OK;
103307 }
103308 return sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, aff, pp);
103309 }
@@ -103829,11 +103863,11 @@
103829 ** a table or index. The actual times can vary, with the size of
103830 ** records being an important factor. Both moves and searches are
103831 ** slower with larger records, presumably because fewer records fit
103832 ** on one page and hence more pages have to be fetched.
103833 **
103834 ** The ANALYZE command and the sqlite_stat1 and sqlite_stat2 tables do
103835 ** not give us data on the relative sizes of table and index records.
103836 ** So this computation assumes table records are about twice as big
103837 ** as index records
103838 */
103839 if( (wsFlags & WHERE_NOT_FULLSCAN)==0 ){
103840
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -314,17 +314,10 @@
314 #endif
315 #ifdef HAVE_INTTYPES_H
316 #include <inttypes.h>
317 #endif
318
 
 
 
 
 
 
 
319 /*
320 ** The following macros are used to cast pointers to integers and
321 ** integers to pointers. The way you do this varies from one compiler
322 ** to the next, so we have developed the following set of #if statements
323 ** to generate appropriate macros for a wide range of compilers.
@@ -656,11 +649,11 @@
649 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
650 ** [sqlite_version()] and [sqlite_source_id()].
651 */
652 #define SQLITE_VERSION "3.7.9"
653 #define SQLITE_VERSION_NUMBER 3007009
654 #define SQLITE_SOURCE_ID "2011-10-29 19:25:08 5b82ec6fbbd2f4195ad06dd911de3817373ad5bf"
655
656 /*
657 ** CAPI3REF: Run-Time Library Version Numbers
658 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
659 **
@@ -8792,10 +8785,11 @@
8785 SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*);
8786 SQLITE_PRIVATE int sqlite3PagerNosync(Pager*);
8787 SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*);
8788 SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*);
8789 SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *, int, int, int *);
8790 SQLITE_PRIVATE void sqlite3PagerClearCache(Pager *);
8791
8792 /* Functions used to truncate the database file. */
8793 SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno);
8794
8795 #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL)
@@ -10189,12 +10183,13 @@
10183 IndexSample *aSample; /* Samples of the left-most key */
10184 #endif
10185 };
10186
10187 /*
10188 ** Each sample stored in the sqlite_stat3 table is represented in memory
10189 ** using a structure of this type. See documentation at the top of the
10190 ** analyze.c source file for additional information.
10191 */
10192 struct IndexSample {
10193 union {
10194 char *z; /* Value if eType is SQLITE_TEXT or SQLITE_BLOB */
10195 double r; /* Value if eType is SQLITE_FLOAT */
@@ -12293,13 +12288,10 @@
12288 "ENABLE_OVERSIZE_CELL_CHECK",
12289 #endif
12290 #ifdef SQLITE_ENABLE_RTREE
12291 "ENABLE_RTREE",
12292 #endif
 
 
 
12293 #ifdef SQLITE_ENABLE_STAT3
12294 "ENABLE_STAT3",
12295 #endif
12296 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
12297 "ENABLE_UNLOCK_NOTIFY",
@@ -12996,10 +12988,11 @@
12988 SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
12989 SQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *, int);
12990 SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*);
12991 SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *);
12992 SQLITE_PRIVATE void sqlite3VdbeMemStoreType(Mem *pMem);
12993 SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p);
12994
12995 #ifdef SQLITE_OMIT_MERGE_SORT
12996 # define sqlite3VdbeSorterInit(Y,Z) SQLITE_OK
12997 # define sqlite3VdbeSorterWrite(X,Y,Z) SQLITE_OK
12998 # define sqlite3VdbeSorterClose(Y,Z)
@@ -29483,17 +29476,17 @@
29476 ** "<path to db>-journal"
29477 ** "<path to db>-wal"
29478 ** "<path to db>-journalNN"
29479 ** "<path to db>-walNN"
29480 **
29481 ** where NN is a decimal number. The NN naming schemes are
29482 ** used by the test_multiplex.c module.
29483 */
29484 nDb = sqlite3Strlen30(zPath) - 1;
29485 #ifdef SQLITE_ENABLE_8_3_NAMES
29486 while( nDb>0 && !sqlite3Isalnum(zPath[nDb]) ) nDb--;
29487 if( nDb==0 || zPath[nDb]!='-' ) return SQLITE_OK;
29488 #else
29489 while( zPath[nDb]!='-' ){
29490 assert( nDb>0 );
29491 assert( zPath[nDb]!='\n' );
29492 nDb--;
@@ -44163,10 +44156,17 @@
44156 pPager->pWal = 0;
44157 }
44158 }
44159 return rc;
44160 }
44161
44162 /*
44163 ** Unless this is an in-memory or temporary database, clear the pager cache.
44164 */
44165 SQLITE_PRIVATE void sqlite3PagerClearCache(Pager *pPager){
44166 if( !MEMDB && pPager->tempFile==0 ) pager_reset(pPager);
44167 }
44168
44169 #ifdef SQLITE_HAS_CODEC
44170 /*
44171 ** This function is called by the wal module when writing page content
44172 ** into the log file.
@@ -57006,10 +57006,12 @@
57006 sqlite3_backup_step(&b, 0x7FFFFFFF);
57007 assert( b.rc!=SQLITE_OK );
57008 rc = sqlite3_backup_finish(&b);
57009 if( rc==SQLITE_OK ){
57010 pTo->pBt->pageSizeFixed = 0;
57011 }else{
57012 sqlite3PagerClearCache(sqlite3BtreePager(b.pDest));
57013 }
57014
57015 assert( sqlite3BtreeIsInTrans(pTo)==0 );
57016 sqlite3BtreeLeave(pFrom);
57017 sqlite3BtreeLeave(pTo);
@@ -60480,10 +60482,34 @@
60482 ** in p->rc. This routine sets that result back to SQLITE_OK.
60483 */
60484 SQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe *p){
60485 p->rc = SQLITE_OK;
60486 }
60487
60488 /*
60489 ** Copy the error code and error message belonging to the VDBE passed
60490 ** as the first argument to its database handle (so that they will be
60491 ** returned by calls to sqlite3_errcode() and sqlite3_errmsg()).
60492 **
60493 ** This function does not clear the VDBE error code or message, just
60494 ** copies them to the database handle.
60495 */
60496 SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p){
60497 sqlite3 *db = p->db;
60498 int rc = p->rc;
60499 if( p->zErrMsg ){
60500 u8 mallocFailed = db->mallocFailed;
60501 sqlite3BeginBenignMalloc();
60502 sqlite3ValueSetStr(db->pErr, -1, p->zErrMsg, SQLITE_UTF8, SQLITE_TRANSIENT);
60503 sqlite3EndBenignMalloc();
60504 db->mallocFailed = mallocFailed;
60505 db->errCode = rc;
60506 }else{
60507 sqlite3Error(db, rc, 0);
60508 }
60509 return rc;
60510 }
60511
60512 /*
60513 ** Clean up a VDBE after execution but do not delete the VDBE just yet.
60514 ** Write any error messages into *pzErrMsg. Return the result code.
60515 **
@@ -60508,22 +60534,13 @@
60534 ** and error message from the VDBE into the main database structure. But
60535 ** if the VDBE has just been set to run but has not actually executed any
60536 ** instructions yet, leave the main database error information unchanged.
60537 */
60538 if( p->pc>=0 ){
60539 sqlite3VdbeTransferError(p);
60540 sqlite3DbFree(db, p->zErrMsg);
60541 p->zErrMsg = 0;
 
 
 
 
 
 
 
 
 
60542 if( p->runOnlyOnce ) p->expired = 1;
60543 }else if( p->rc && p->expired ){
60544 /* The expired flag was set on the VDBE before the first call
60545 ** to sqlite3_step(). For consistency (since sqlite3_step() was
60546 ** called), set the database error in this case as well.
@@ -61865,11 +61882,11 @@
61882 if( p->isPrepareV2 && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){
61883 /* If this statement was prepared using sqlite3_prepare_v2(), and an
61884 ** error has occured, then return the error code in p->rc to the
61885 ** caller. Set the error code in the database handle to the same value.
61886 */
61887 rc = sqlite3VdbeTransferError(p);
61888 }
61889 return (rc&db->errMask);
61890 }
61891
61892 /*
@@ -67765,13 +67782,12 @@
67782
67783 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
67784 u.bn.pC = p->apCsr[pOp->p1];
67785 assert( u.bn.pC!=0 );
67786 u.bn.pCrsr = u.bn.pC->pCursor;
67787 u.bn.res = 0;
67788 if( ALWAYS(u.bn.pCrsr!=0) ){
 
67789 rc = sqlite3BtreeLast(u.bn.pCrsr, &u.bn.res);
67790 }
67791 u.bn.pC->nullRow = (u8)u.bn.res;
67792 u.bn.pC->deferredMoveto = 0;
67793 u.bn.pC->rowidIsValid = 0;
@@ -77610,20 +77626,20 @@
77626 #ifndef SQLITE_OMIT_ANALYZE
77627
77628 /*
77629 ** This routine generates code that opens the sqlite_stat1 table for
77630 ** writing with cursor iStatCur. If the library was built with the
77631 ** SQLITE_ENABLE_STAT3 macro defined, then the sqlite_stat3 table is
77632 ** opened for writing using cursor (iStatCur+1)
77633 **
77634 ** If the sqlite_stat1 tables does not previously exist, it is created.
77635 ** Similarly, if the sqlite_stat3 table does not exist and the library
77636 ** is compiled with SQLITE_ENABLE_STAT3 defined, it is created.
77637 **
77638 ** Argument zWhere may be a pointer to a buffer containing a table name,
77639 ** or it may be a NULL pointer. If it is not NULL, then all entries in
77640 ** the sqlite_stat1 and (if applicable) sqlite_stat3 tables associated
77641 ** with the named table are deleted. If zWhere==0, then code is generated
77642 ** to delete all stat table entries.
77643 */
77644 static void openStatTable(
77645 Parse *pParse, /* Parsing context */
@@ -81404,31 +81420,28 @@
81420 }
81421 #endif
81422 }
81423
81424 /*
81425 ** Remove entries from the sqlite_statN tables (for N in (1,2,3))
81426 ** after a DROP INDEX or DROP TABLE command.
81427 */
81428 static void sqlite3ClearStatTables(
81429 Parse *pParse, /* The parsing context */
81430 int iDb, /* The database number */
81431 const char *zType, /* "idx" or "tbl" */
81432 const char *zName /* Name of index or table */
81433 ){
 
 
 
 
 
81434 int i;
81435 const char *zDbName = pParse->db->aDb[iDb].zName;
81436 for(i=1; i<=3; i++){
81437 char zTab[24];
81438 sqlite3_snprintf(sizeof(zTab),zTab,"sqlite_stat%d",i);
81439 if( sqlite3FindTable(pParse->db, zTab, zDbName) ){
81440 sqlite3NestedParse(pParse,
81441 "DELETE FROM %Q.%s WHERE %s=%Q",
81442 zDbName, zTab, zType, zName
81443 );
81444 }
81445 }
81446 }
81447
@@ -89250,12 +89263,14 @@
89263 int (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*);
89264 int (*busy_handler)(sqlite3*,int(*)(void*,int),void*);
89265 int (*busy_timeout)(sqlite3*,int ms);
89266 int (*changes)(sqlite3*);
89267 int (*close)(sqlite3*);
89268 int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,
89269 int eTextRep,const char*));
89270 int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,
89271 int eTextRep,const void*));
89272 const void * (*column_blob)(sqlite3_stmt*,int iCol);
89273 int (*column_bytes)(sqlite3_stmt*,int iCol);
89274 int (*column_bytes16)(sqlite3_stmt*,int iCol);
89275 int (*column_count)(sqlite3_stmt*pStmt);
89276 const char * (*column_database_name)(sqlite3_stmt*,int);
@@ -89276,14 +89291,22 @@
89291 int (*column_type)(sqlite3_stmt*,int iCol);
89292 sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);
89293 void * (*commit_hook)(sqlite3*,int(*)(void*),void*);
89294 int (*complete)(const char*sql);
89295 int (*complete16)(const void*sql);
89296 int (*create_collation)(sqlite3*,const char*,int,void*,
89297 int(*)(void*,int,const void*,int,const void*));
89298 int (*create_collation16)(sqlite3*,const void*,int,void*,
89299 int(*)(void*,int,const void*,int,const void*));
89300 int (*create_function)(sqlite3*,const char*,int,int,void*,
89301 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
89302 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
89303 void (*xFinal)(sqlite3_context*));
89304 int (*create_function16)(sqlite3*,const void*,int,int,void*,
89305 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
89306 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
89307 void (*xFinal)(sqlite3_context*));
89308 int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);
89309 int (*data_count)(sqlite3_stmt*pStmt);
89310 sqlite3 * (*db_handle)(sqlite3_stmt*);
89311 int (*declare_vtab)(sqlite3*,const char*);
89312 int (*enable_shared_cache)(int);
@@ -89324,20 +89347,23 @@
89347 void (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));
89348 void (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));
89349 void (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));
89350 void (*result_value)(sqlite3_context*,sqlite3_value*);
89351 void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);
89352 int (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,
89353 const char*,const char*),void*);
89354 void (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));
89355 char * (*snprintf)(int,char*,const char*,...);
89356 int (*step)(sqlite3_stmt*);
89357 int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,
89358 char const**,char const**,int*,int*,int*);
89359 void (*thread_cleanup)(void);
89360 int (*total_changes)(sqlite3*);
89361 void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);
89362 int (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);
89363 void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,
89364 sqlite_int64),void*);
89365 void * (*user_data)(sqlite3_context*);
89366 const void * (*value_blob)(sqlite3_value*);
89367 int (*value_bytes)(sqlite3_value*);
89368 int (*value_bytes16)(sqlite3_value*);
89369 double (*value_double)(sqlite3_value*);
@@ -89355,19 +89381,23 @@
89381 /* Added by 3.3.13 */
89382 int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
89383 int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
89384 int (*clear_bindings)(sqlite3_stmt*);
89385 /* Added by 3.4.1 */
89386 int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,
89387 void (*xDestroy)(void *));
89388 /* Added by 3.5.0 */
89389 int (*bind_zeroblob)(sqlite3_stmt*,int,int);
89390 int (*blob_bytes)(sqlite3_blob*);
89391 int (*blob_close)(sqlite3_blob*);
89392 int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,
89393 int,sqlite3_blob**);
89394 int (*blob_read)(sqlite3_blob*,void*,int,int);
89395 int (*blob_write)(sqlite3_blob*,const void*,int,int);
89396 int (*create_collation_v2)(sqlite3*,const char*,int,void*,
89397 int(*)(void*,int,const void*,int,const void*),
89398 void(*)(void*));
89399 int (*file_control)(sqlite3*,const char*,int,void*);
89400 sqlite3_int64 (*memory_highwater)(int);
89401 sqlite3_int64 (*memory_used)(void);
89402 sqlite3_mutex *(*mutex_alloc)(int);
89403 void (*mutex_enter)(sqlite3_mutex*);
@@ -89399,11 +89429,15 @@
89429 int (*backup_pagecount)(sqlite3_backup*);
89430 int (*backup_remaining)(sqlite3_backup*);
89431 int (*backup_step)(sqlite3_backup*,int);
89432 const char *(*compileoption_get)(int);
89433 int (*compileoption_used)(const char*);
89434 int (*create_function_v2)(sqlite3*,const char*,int,int,void*,
89435 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
89436 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
89437 void (*xFinal)(sqlite3_context*),
89438 void(*xDestroy)(void*));
89439 int (*db_config)(sqlite3*,int,...);
89440 sqlite3_mutex *(*db_mutex)(sqlite3*);
89441 int (*db_status)(sqlite3*,int,int*,int*,int);
89442 int (*extended_errcode)(sqlite3*);
89443 void (*log)(int,const char*,...);
@@ -100485,11 +100519,11 @@
100519 if( db->aVTrans ){
100520 int i;
100521 for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){
100522 VTable *pVTab = db->aVTrans[i];
100523 const sqlite3_module *pMod = pVTab->pMod->pModule;
100524 if( pVTab->pVtab && pMod->iVersion>=2 ){
100525 int (*xMethod)(sqlite3_vtab *, int);
100526 switch( op ){
100527 case SAVEPOINT_BEGIN:
100528 xMethod = pMod->xSavepoint;
100529 pVTab->iSavepoint = iSavepoint+1;
@@ -100500,11 +100534,11 @@
100534 default:
100535 xMethod = pMod->xRelease;
100536 break;
100537 }
100538 if( xMethod && pVTab->iSavepoint>iSavepoint ){
100539 rc = xMethod(pVTab->pVtab, iSavepoint);
100540 }
100541 }
100542 }
100543 }
100544 return rc;
@@ -101367,11 +101401,11 @@
101401 int iCol = pRight->iColumn;
101402 pVal = sqlite3VdbeGetValue(pReprepare, iCol, SQLITE_AFF_NONE);
101403 if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
101404 z = (char *)sqlite3_value_text(pVal);
101405 }
101406 sqlite3VdbeSetVarmask(pParse->pVdbe, iCol);
101407 assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );
101408 }else if( op==TK_STRING ){
101409 z = pRight->u.zToken;
101410 }
101411 if( z ){
@@ -101385,11 +101419,11 @@
101419 pPrefix = sqlite3Expr(db, TK_STRING, z);
101420 if( pPrefix ) pPrefix->u.zToken[cnt] = 0;
101421 *ppPrefix = pPrefix;
101422 if( op==TK_VARIABLE ){
101423 Vdbe *v = pParse->pVdbe;
101424 sqlite3VdbeSetVarmask(v, pRight->iColumn);
101425 if( *pisComplete && pRight->u.zToken[1] ){
101426 /* If the rhs of the LIKE expression is a variable, and the current
101427 ** value of the variable means there is no need to invoke the LIKE
101428 ** function, then no OP_Variable will be added to the program.
101429 ** This causes problems for the sqlite3_bind_parameter_name()
@@ -103299,11 +103333,11 @@
103333 ){
103334 if( pExpr->op==TK_VARIABLE
103335 || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
103336 ){
103337 int iVar = pExpr->iColumn;
103338 sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);
103339 *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff);
103340 return SQLITE_OK;
103341 }
103342 return sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, aff, pp);
103343 }
@@ -103829,11 +103863,11 @@
103863 ** a table or index. The actual times can vary, with the size of
103864 ** records being an important factor. Both moves and searches are
103865 ** slower with larger records, presumably because fewer records fit
103866 ** on one page and hence more pages have to be fetched.
103867 **
103868 ** The ANALYZE command and the sqlite_stat1 and sqlite_stat3 tables do
103869 ** not give us data on the relative sizes of table and index records.
103870 ** So this computation assumes table records are about twice as big
103871 ** as index records
103872 */
103873 if( (wsFlags & WHERE_NOT_FULLSCAN)==0 ){
103874
+1 -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.9"
111111
#define SQLITE_VERSION_NUMBER 3007009
112
-#define SQLITE_SOURCE_ID "2011-10-20 00:55:54 4344483f7d7f64dffadde0053e6c745948db9486"
112
+#define SQLITE_SOURCE_ID "2011-10-29 19:25:08 5b82ec6fbbd2f4195ad06dd911de3817373ad5bf"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
118118
--- 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.9"
111 #define SQLITE_VERSION_NUMBER 3007009
112 #define SQLITE_SOURCE_ID "2011-10-20 00:55:54 4344483f7d7f64dffadde0053e6c745948db9486"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
118
--- 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.9"
111 #define SQLITE_VERSION_NUMBER 3007009
112 #define SQLITE_SOURCE_ID "2011-10-29 19:25:08 5b82ec6fbbd2f4195ad06dd911de3817373ad5bf"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
118

Keyboard Shortcuts

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