Fossil SCM

Remove some instances of strcpy() and sprintf() due to warnings on OpenBSD. Update the internal SQLite to the latest 3.7.4 release candidate.

drh 2010-12-02 14:46 trunk
Commit 3ad5891c72016a94d24d0b9702f3ff2dc66b64f1
+1 -1
--- src/blob.c
+++ src/blob.c
@@ -669,11 +669,11 @@
669669
nName = strlen(zFilename);
670670
if( nName>=sizeof(zBuf) ){
671671
zName = mprintf("%s", zFilename);
672672
}else{
673673
zName = zBuf;
674
- strcpy(zName, zFilename);
674
+ memcpy(zName, zFilename, nName+1);
675675
}
676676
nName = file_simplify_name(zName, nName);
677677
for(i=1; i<nName; i++){
678678
if( zName[i]=='/' ){
679679
zName[i] = 0;
680680
--- src/blob.c
+++ src/blob.c
@@ -669,11 +669,11 @@
669 nName = strlen(zFilename);
670 if( nName>=sizeof(zBuf) ){
671 zName = mprintf("%s", zFilename);
672 }else{
673 zName = zBuf;
674 strcpy(zName, zFilename);
675 }
676 nName = file_simplify_name(zName, nName);
677 for(i=1; i<nName; i++){
678 if( zName[i]=='/' ){
679 zName[i] = 0;
680
--- src/blob.c
+++ src/blob.c
@@ -669,11 +669,11 @@
669 nName = strlen(zFilename);
670 if( nName>=sizeof(zBuf) ){
671 zName = mprintf("%s", zFilename);
672 }else{
673 zName = zBuf;
674 memcpy(zName, zFilename, nName+1);
675 }
676 nName = file_simplify_name(zName, nName);
677 for(i=1; i<nName; i++){
678 if( zName[i]=='/' ){
679 zName[i] = 0;
680
+1 -1
--- src/captcha.c
+++ src/captcha.c
@@ -390,11 +390,11 @@
390390
char *z;
391391
392392
for(i=2; i<g.argc; i++){
393393
char zHex[30];
394394
v = (unsigned int)atoi(g.argv[i]);
395
- sprintf(zHex, "%x", v);
395
+ sqlite3_snprintf(sizeof(zHex), zHex, "%x", v);
396396
z = captcha_render(zHex);
397397
printf("%s:\n%s", zHex, z);
398398
free(z);
399399
}
400400
}
401401
--- src/captcha.c
+++ src/captcha.c
@@ -390,11 +390,11 @@
390 char *z;
391
392 for(i=2; i<g.argc; i++){
393 char zHex[30];
394 v = (unsigned int)atoi(g.argv[i]);
395 sprintf(zHex, "%x", v);
396 z = captcha_render(zHex);
397 printf("%s:\n%s", zHex, z);
398 free(z);
399 }
400 }
401
--- src/captcha.c
+++ src/captcha.c
@@ -390,11 +390,11 @@
390 char *z;
391
392 for(i=2; i<g.argc; i++){
393 char zHex[30];
394 v = (unsigned int)atoi(g.argv[i]);
395 sqlite3_snprintf(sizeof(zHex), zHex, "%x", v);
396 z = captcha_render(zHex);
397 printf("%s:\n%s", zHex, z);
398 free(z);
399 }
400 }
401
+89 -70
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -650,11 +650,11 @@
650650
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
651651
** [sqlite_version()] and [sqlite_source_id()].
652652
*/
653653
#define SQLITE_VERSION "3.7.4"
654654
#define SQLITE_VERSION_NUMBER 3007004
655
-#define SQLITE_SOURCE_ID "2010-11-26 16:49:59 c412f61229b6ab1ac90b932afd56f7c5e3ba1cfe"
655
+#define SQLITE_SOURCE_ID "2010-12-02 11:24:58 a94b9a395e0be9549d8c28e2b86b995c73c7b671"
656656
657657
/*
658658
** CAPI3REF: Run-Time Library Version Numbers
659659
** KEYWORDS: sqlite3_version, sqlite3_sourceid
660660
**
@@ -9959,19 +9959,19 @@
99599959
Table *pTab; /* An SQL table corresponding to zName */
99609960
Select *pSelect; /* A SELECT statement used in place of a table name */
99619961
u8 isPopulated; /* Temporary table associated with SELECT is populated */
99629962
u8 jointype; /* Type of join between this able and the previous */
99639963
u8 notIndexed; /* True if there is a NOT INDEXED clause */
9964
+#ifndef SQLITE_OMIT_EXPLAIN
9965
+ u8 iSelectId; /* If pSelect!=0, the id of the sub-select in EQP */
9966
+#endif
99649967
int iCursor; /* The VDBE cursor number used to access this table */
99659968
Expr *pOn; /* The ON clause of a join */
99669969
IdList *pUsing; /* The USING clause of a join */
99679970
Bitmask colUsed; /* Bit N (1<<N) set if column N of pTab is used */
99689971
char *zIndex; /* Identifier from "INDEXED BY <zIndex>" clause */
99699972
Index *pIndex; /* Index structure corresponding to zIndex, if any */
9970
-#ifndef SQLITE_OMIT_EXPLAIN
9971
- int iSelectId; /* If pSelect!=0, the id of the sub-select in EQP */
9972
-#endif
99739973
} a[1]; /* One entry for each identifier on the list */
99749974
};
99759975
99769976
/*
99779977
** Permitted values of the SrcList.a.jointype field
@@ -12056,30 +12056,38 @@
1205612056
** values stored in the Vdbe struct. When the sub-program is finished,
1205712057
** these values are copied back to the Vdbe from the VdbeFrame structure,
1205812058
** restoring the state of the VM to as it was before the sub-program
1205912059
** began executing.
1206012060
**
12061
-** Frames are stored in a linked list headed at Vdbe.pParent. Vdbe.pParent
12062
-** is the parent of the current frame, or zero if the current frame
12063
-** is the main Vdbe program.
12061
+** The memory for a VdbeFrame object is allocated and managed by a memory
12062
+** cell in the parent (calling) frame. When the memory cell is deleted or
12063
+** overwritten, the VdbeFrame object is not freed immediately. Instead, it
12064
+** is linked into the Vdbe.pDelFrame list. The contents of the Vdbe.pDelFrame
12065
+** list is deleted when the VM is reset in VdbeHalt(). The reason for doing
12066
+** this instead of deleting the VdbeFrame immediately is to avoid recursive
12067
+** calls to sqlite3VdbeMemRelease() when the memory cells belonging to the
12068
+** child frame are released.
12069
+**
12070
+** The currently executing frame is stored in Vdbe.pFrame. Vdbe.pFrame is
12071
+** set to NULL if the currently executing frame is the main program.
1206412072
*/
1206512073
typedef struct VdbeFrame VdbeFrame;
1206612074
struct VdbeFrame {
1206712075
Vdbe *v; /* VM this frame belongs to */
12068
- int pc; /* Program Counter */
12069
- Op *aOp; /* Program instructions */
12076
+ int pc; /* Program Counter in parent (calling) frame */
12077
+ Op *aOp; /* Program instructions for parent frame */
1207012078
int nOp; /* Size of aOp array */
12071
- Mem *aMem; /* Array of memory cells */
12079
+ Mem *aMem; /* Array of memory cells for parent frame */
1207212080
int nMem; /* Number of entries in aMem */
12073
- VdbeCursor **apCsr; /* Element of Vdbe cursors */
12081
+ VdbeCursor **apCsr; /* Array of Vdbe cursors for parent frame */
1207412082
u16 nCursor; /* Number of entries in apCsr */
1207512083
void *token; /* Copy of SubProgram.token */
1207612084
int nChildMem; /* Number of memory cells for child frame */
1207712085
int nChildCsr; /* Number of cursors for child frame */
1207812086
i64 lastRowid; /* Last insert rowid (sqlite3.lastRowid) */
1207912087
int nChange; /* Statement changes (Vdbe.nChanges) */
12080
- VdbeFrame *pParent; /* Parent of this frame */
12088
+ VdbeFrame *pParent; /* Parent of this frame, or NULL if parent is main */
1208112089
};
1208212090
1208312091
#define VdbeFrameMem(p) ((Mem *)&((u8 *)p)[ROUND8(sizeof(VdbeFrame))])
1208412092
1208512093
/*
@@ -12292,10 +12300,11 @@
1229212300
int iStatement; /* Statement number (or 0 if has not opened stmt) */
1229312301
#ifdef SQLITE_DEBUG
1229412302
FILE *trace; /* Write an execution trace here, if not NULL */
1229512303
#endif
1229612304
VdbeFrame *pFrame; /* Parent frame */
12305
+ VdbeFrame *pDelFrame; /* List of frame objects to free on VM reset */
1229712306
int nFrame; /* Number of frames in pFrame list */
1229812307
u32 expmask; /* Binding to these vars invalidates VM */
1229912308
SubProgram *pProgram; /* Linked list of all sub-programs used by VM */
1230012309
};
1230112310
@@ -27840,11 +27849,11 @@
2784027849
** message is available, it is written to zBufOut. If no error message
2784127850
** is available, zBufOut is left unmodified and SQLite uses a default
2784227851
** error message.
2784327852
*/
2784427853
static void unixDlError(sqlite3_vfs *NotUsed, int nBuf, char *zBufOut){
27845
- char *zErr;
27854
+ const char *zErr;
2784627855
UNUSED_PARAMETER(NotUsed);
2784727856
unixEnterMutex();
2784827857
zErr = dlerror();
2784927858
if( zErr ){
2785027859
sqlite3_snprintf(nBuf, zBufOut, "%s", zErr);
@@ -28434,31 +28443,31 @@
2843428443
2843528444
/* create a new path by replace the trailing '-conch' with '-break' */
2843628445
pathLen = strlcpy(tPath, cPath, MAXPATHLEN);
2843728446
if( pathLen>MAXPATHLEN || pathLen<6 ||
2843828447
(strlcpy(&tPath[pathLen-5], "break", 6) != 5) ){
28439
- sprintf(errmsg, "path error (len %d)", (int)pathLen);
28448
+ sqlite3_snprintf(sizeof(errmsg),errmsg,"path error (len %d)",(int)pathLen);
2844028449
goto end_breaklock;
2844128450
}
2844228451
/* read the conch content */
2844328452
readLen = pread(conchFile->h, buf, PROXY_MAXCONCHLEN, 0);
2844428453
if( readLen<PROXY_PATHINDEX ){
28445
- sprintf(errmsg, "read error (len %d)", (int)readLen);
28454
+ sqlite3_snprintf(sizeof(errmsg),errmsg,"read error (len %d)",(int)readLen);
2844628455
goto end_breaklock;
2844728456
}
2844828457
/* write it out to the temporary break file */
2844928458
fd = open(tPath, (O_RDWR|O_CREAT|O_EXCL), SQLITE_DEFAULT_FILE_PERMISSIONS);
2845028459
if( fd<0 ){
28451
- sprintf(errmsg, "create failed (%d)", errno);
28460
+ sqlite3_snprintf(sizeof(errmsg), errmsg, "create failed (%d)", errno);
2845228461
goto end_breaklock;
2845328462
}
2845428463
if( pwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){
28455
- sprintf(errmsg, "write failed (%d)", errno);
28464
+ sqlite3_snprintf(sizeof(errmsg), errmsg, "write failed (%d)", errno);
2845628465
goto end_breaklock;
2845728466
}
2845828467
if( rename(tPath, cPath) ){
28459
- sprintf(errmsg, "rename failed (%d)", errno);
28468
+ sqlite3_snprintf(sizeof(errmsg), errmsg, "rename failed (%d)", errno);
2846028469
goto end_breaklock;
2846128470
}
2846228471
rc = 0;
2846328472
fprintf(stderr, "broke stale lock on %s\n", cPath);
2846428473
close(conchFile->h);
@@ -54476,11 +54485,13 @@
5447654485
/*
5447754486
** Delete any previous value and set the value stored in *pMem to NULL.
5447854487
*/
5447954488
SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem *pMem){
5448054489
if( pMem->flags & MEM_Frame ){
54481
- sqlite3VdbeFrameDelete(pMem->u.pFrame);
54490
+ VdbeFrame *pFrame = pMem->u.pFrame;
54491
+ pFrame->pParent = pFrame->v->pDelFrame;
54492
+ pFrame->v->pDelFrame = pFrame;
5448254493
}
5448354494
if( pMem->flags & MEM_RowSet ){
5448454495
sqlite3RowSetClear(pMem->u.pRowSet);
5448554496
}
5448654497
MemSetTypeFlag(pMem, MEM_Null);
@@ -56676,10 +56687,15 @@
5667656687
}
5667756688
}
5667856689
if( p->aMem ){
5667956690
releaseMemArray(&p->aMem[1], p->nMem);
5668056691
}
56692
+ while( p->pDelFrame ){
56693
+ VdbeFrame *pDel = p->pDelFrame;
56694
+ p->pDelFrame = pDel->pParent;
56695
+ sqlite3VdbeFrameDelete(pDel);
56696
+ }
5668156697
}
5668256698
5668356699
/*
5668456700
** Clean up the VM after execution.
5668556701
**
@@ -91416,11 +91432,11 @@
9141691432
}
9141791433
i = -1;
9141891434
}else{
9141991435
sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor);
9142091436
assert( pItem->isPopulated==0 );
91421
- explainSetInteger(pItem->iSelectId, pParse->iNextSelectId);
91437
+ explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId);
9142291438
sqlite3Select(pParse, pSub, &dest);
9142391439
pItem->isPopulated = 1;
9142491440
pItem->pTab->nRowEst = (unsigned)pSub->nSelectRow;
9142591441
}
9142691442
if( /*pParse->nErr ||*/ db->mallocFailed ){
@@ -108828,11 +108844,11 @@
108828108844
while( *zCsr!='=' ){
108829108845
if( *zCsr=='\0' ) return 0;
108830108846
zCsr++;
108831108847
}
108832108848
108833
- *pnKey = zCsr-z;
108849
+ *pnKey = (int)(zCsr-z);
108834108850
zValue = sqlite3_mprintf("%s", &zCsr[1]);
108835108851
if( zValue ){
108836108852
sqlite3Fts3Dequote(zValue);
108837108853
}
108838108854
*pzValue = zValue;
@@ -108883,11 +108899,11 @@
108883108899
nDb = (int)strlen(argv[1]) + 1;
108884108900
nName = (int)strlen(argv[2]) + 1;
108885108901
108886108902
aCol = (const char **)sqlite3_malloc(sizeof(const char *) * (argc-2) );
108887108903
if( !aCol ) return SQLITE_NOMEM;
108888
- memset(aCol, 0, sizeof(const char *) * (argc-2));
108904
+ memset((void *)aCol, 0, sizeof(const char *) * (argc-2));
108889108905
108890108906
/* Loop through all of the arguments passed by the user to the FTS3/4
108891108907
** module (i.e. all the column names and special arguments). This loop
108892108908
** does the following:
108893108909
**
@@ -109015,11 +109031,11 @@
109015109031
/* Declare the table schema to SQLite. */
109016109032
fts3DeclareVtab(&rc, p);
109017109033
109018109034
fts3_init_out:
109019109035
109020
- sqlite3_free(aCol);
109036
+ sqlite3_free((void *)aCol);
109021109037
if( rc!=SQLITE_OK ){
109022109038
if( p ){
109023109039
fts3DisconnectMethod((sqlite3_vtab *)p);
109024109040
}else if( pTokenizer ){
109025109041
pTokenizer->pModule->xDestroy(pTokenizer);
@@ -110371,11 +110387,11 @@
110371110387
p += sqlite3Fts3GetVarint(p, &delta);
110372110388
fts3PoslistCopy(0, &p);
110373110389
pOut += sqlite3Fts3PutVarint(pOut, delta);
110374110390
}
110375110391
110376
- *pnList = (pOut - aList);
110392
+ *pnList = (int)(pOut - aList);
110377110393
}
110378110394
}
110379110395
110380110396
/*
110381110397
** Return a DocList corresponding to the phrase *pPhrase.
@@ -112464,51 +112480,57 @@
112464112480
112465112481
return sqlite3_finalize(pStmt);
112466112482
}
112467112483
112468112484
/*
112469
-** This function is part of the test interface for the query parser. It
112470
-** writes a text representation of the query expression pExpr into the
112471
-** buffer pointed to by argument zBuf. It is assumed that zBuf is large
112472
-** enough to store the required text representation.
112485
+** Return a pointer to a buffer containing a text representation of the
112486
+** expression passed as the first argument. The buffer is obtained from
112487
+** sqlite3_malloc(). It is the responsibility of the caller to use
112488
+** sqlite3_free() to release the memory. If an OOM condition is encountered,
112489
+** NULL is returned.
112490
+**
112491
+** If the second argument is not NULL, then its contents are prepended to
112492
+** the returned expression text and then freed using sqlite3_free().
112473112493
*/
112474
-static void exprToString(Fts3Expr *pExpr, char *zBuf){
112494
+static char *exprToString(Fts3Expr *pExpr, char *zBuf){
112475112495
switch( pExpr->eType ){
112476112496
case FTSQUERY_PHRASE: {
112477112497
Fts3Phrase *pPhrase = pExpr->pPhrase;
112478112498
int i;
112479
- zBuf += sprintf(zBuf, "PHRASE %d %d", pPhrase->iColumn, pPhrase->isNot);
112480
- for(i=0; i<pPhrase->nToken; i++){
112481
- zBuf += sprintf(zBuf," %.*s",pPhrase->aToken[i].n,pPhrase->aToken[i].z);
112482
- zBuf += sprintf(zBuf,"%s", (pPhrase->aToken[i].isPrefix?"+":""));
112499
+ zBuf = sqlite3_mprintf(
112500
+ "%zPHRASE %d %d", zBuf, pPhrase->iColumn, pPhrase->isNot);
112501
+ for(i=0; zBuf && i<pPhrase->nToken; i++){
112502
+ zBuf = sqlite3_mprintf("%z %.*s%s", zBuf,
112503
+ pPhrase->aToken[i].n, pPhrase->aToken[i].z,
112504
+ (pPhrase->aToken[i].isPrefix?"+":"")
112505
+ );
112483112506
}
112484
- return;
112507
+ return zBuf;
112485112508
}
112486112509
112487112510
case FTSQUERY_NEAR:
112488
- zBuf += sprintf(zBuf, "NEAR/%d ", pExpr->nNear);
112511
+ zBuf = sqlite3_mprintf("%zNEAR/%d ", zBuf, pExpr->nNear);
112489112512
break;
112490112513
case FTSQUERY_NOT:
112491
- zBuf += sprintf(zBuf, "NOT ");
112514
+ zBuf = sqlite3_mprintf("%zNOT ", zBuf);
112492112515
break;
112493112516
case FTSQUERY_AND:
112494
- zBuf += sprintf(zBuf, "AND ");
112517
+ zBuf = sqlite3_mprintf("%zAND ", zBuf);
112495112518
break;
112496112519
case FTSQUERY_OR:
112497
- zBuf += sprintf(zBuf, "OR ");
112520
+ zBuf = sqlite3_mprintf("%zOR ", zBuf);
112498112521
break;
112499112522
}
112500112523
112501
- zBuf += sprintf(zBuf, "{");
112502
- exprToString(pExpr->pLeft, zBuf);
112503
- zBuf += strlen(zBuf);
112504
- zBuf += sprintf(zBuf, "} ");
112505
-
112506
- zBuf += sprintf(zBuf, "{");
112507
- exprToString(pExpr->pRight, zBuf);
112508
- zBuf += strlen(zBuf);
112509
- zBuf += sprintf(zBuf, "}");
112524
+ if( zBuf ) zBuf = sqlite3_mprintf("%z{", zBuf);
112525
+ if( zBuf ) zBuf = exprToString(pExpr->pLeft, zBuf);
112526
+ if( zBuf ) zBuf = sqlite3_mprintf("%z} {", zBuf);
112527
+
112528
+ if( zBuf ) zBuf = exprToString(pExpr->pRight, zBuf);
112529
+ if( zBuf ) zBuf = sqlite3_mprintf("%z}", zBuf);
112530
+
112531
+ return zBuf;
112510112532
}
112511112533
112512112534
/*
112513112535
** This is the implementation of a scalar SQL function used to test the
112514112536
** expression parser. It should be called as follows:
@@ -112535,10 +112557,11 @@
112535112557
const char *zExpr;
112536112558
int nExpr;
112537112559
int nCol;
112538112560
int ii;
112539112561
Fts3Expr *pExpr;
112562
+ char *zBuf = 0;
112540112563
sqlite3 *db = sqlite3_context_db_handle(context);
112541112564
112542112565
if( argc<3 ){
112543112566
sqlite3_result_error(context,
112544112567
"Usage: fts3_exprtest(tokenizer, expr, col1, ...", -1
@@ -112577,21 +112600,20 @@
112577112600
}
112578112601
112579112602
rc = sqlite3Fts3ExprParse(
112580112603
pTokenizer, azCol, nCol, nCol, zExpr, nExpr, &pExpr
112581112604
);
112582
- if( rc==SQLITE_NOMEM ){
112605
+ if( rc!=SQLITE_OK && rc!=SQLITE_NOMEM ){
112606
+ sqlite3_result_error(context, "Error parsing expression", -1);
112607
+ }else if( rc==SQLITE_NOMEM || !(zBuf = exprToString(pExpr, 0)) ){
112583112608
sqlite3_result_error_nomem(context);
112584
- goto exprtest_out;
112585
- }else if( rc==SQLITE_OK ){
112586
- char zBuf[4096];
112587
- exprToString(pExpr, zBuf);
112609
+ }else{
112588112610
sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
112589
- sqlite3Fts3ExprFree(pExpr);
112590
- }else{
112591
- sqlite3_result_error(context, "Error parsing expression", -1);
112611
+ sqlite3_free(zBuf);
112592112612
}
112613
+
112614
+ sqlite3Fts3ExprFree(pExpr);
112593112615
112594112616
exprtest_out:
112595112617
if( pModule && pTokenizer ){
112596112618
rc = pModule->xDestroy(pTokenizer);
112597112619
}
@@ -115471,11 +115493,11 @@
115471115493
while( a<pEnd ){
115472115494
a += sqlite3Fts3GetVarint(a, &nByte);
115473115495
}
115474115496
}
115475115497
115476
- pCsr->nRowAvg = (((nByte / nDoc) + pgsz - 1) / pgsz);
115498
+ pCsr->nRowAvg = (int)(((nByte / nDoc) + pgsz - 1) / pgsz);
115477115499
}
115478115500
rc = sqlite3_reset(pStmt);
115479115501
if( rc!=SQLITE_OK || pCsr->nRowAvg==0 ) return rc;
115480115502
}
115481115503
@@ -118278,16 +118300,16 @@
118278118300
pIter->iCol = LCS_ITERATOR_FINISHED;
118279118301
rc = 1;
118280118302
}else{
118281118303
if( iRead==1 ){
118282118304
pRead += sqlite3Fts3GetVarint(pRead, &iRead);
118283
- pIter->iCol = iRead;
118305
+ pIter->iCol = (int)iRead;
118284118306
pIter->iPos = pIter->iPosOffset;
118285118307
pRead += sqlite3Fts3GetVarint(pRead, &iRead);
118286118308
rc = 1;
118287118309
}
118288
- pIter->iPos += (iRead-2);
118310
+ pIter->iPos += (int)(iRead-2);
118289118311
}
118290118312
118291118313
pIter->pRead = pRead;
118292118314
return rc;
118293118315
}
@@ -118432,11 +118454,11 @@
118432118454
if( rc==SQLITE_OK ){
118433118455
int iCol;
118434118456
for(iCol=0; iCol<pInfo->nCol; iCol++){
118435118457
sqlite3_int64 nToken;
118436118458
a += sqlite3Fts3GetVarint(a, &nToken);
118437
- pInfo->aMatchinfo[iCol] = ((u32)(nToken&0xffffffff)+nDoc/2)/nDoc;
118459
+ pInfo->aMatchinfo[iCol] = (u32)(((u32)(nToken&0xffffffff)+nDoc/2)/nDoc);
118438118460
}
118439118461
}
118440118462
}
118441118463
break;
118442118464
@@ -118535,11 +118557,11 @@
118535118557
for(i=0; zArg[i]; i++){
118536118558
nMatchinfo += fts3MatchinfoSize(&sInfo, zArg[i]);
118537118559
}
118538118560
118539118561
/* Allocate space for Fts3Cursor.aMatchinfo[] and Fts3Cursor.zMatchinfo. */
118540
- nArg = strlen(zArg);
118562
+ nArg = (int)strlen(zArg);
118541118563
pCsr->aMatchinfo = (u32 *)sqlite3_malloc(sizeof(u32)*nMatchinfo + nArg + 1);
118542118564
if( !pCsr->aMatchinfo ) return SQLITE_NOMEM;
118543118565
118544118566
pCsr->zMatchinfo = (char *)&pCsr->aMatchinfo[nMatchinfo];
118545118567
pCsr->nMatchinfo = nMatchinfo;
@@ -119778,10 +119800,11 @@
119778119800
*/
119779119801
static int testRtreeCell(Rtree *pRtree, RtreeCursor *pCursor, int *pbEof){
119780119802
RtreeCell cell;
119781119803
int ii;
119782119804
int bRes = 0;
119805
+ int rc = SQLITE_OK;
119783119806
119784119807
nodeGetCell(pRtree, pCursor->pNode, pCursor->iCell, &cell);
119785119808
for(ii=0; bRes==0 && ii<pCursor->nConstraint; ii++){
119786119809
RtreeConstraint *p = &pCursor->aConstraint[ii];
119787119810
double cell_min = DCOORD(cell.aCoord[(p->iCoord>>1)*2]);
@@ -119803,24 +119826,20 @@
119803119826
case RTREE_EQ:
119804119827
bRes = (p->rValue>cell_max || p->rValue<cell_min);
119805119828
break;
119806119829
119807119830
default: {
119808
- int rc;
119809119831
assert( p->op==RTREE_MATCH );
119810119832
rc = testRtreeGeom(pRtree, p, &cell, &bRes);
119811
- if( rc!=SQLITE_OK ){
119812
- return rc;
119813
- }
119814119833
bRes = !bRes;
119815119834
break;
119816119835
}
119817119836
}
119818119837
}
119819119838
119820119839
*pbEof = bRes;
119821
- return SQLITE_OK;
119840
+ return rc;
119822119841
}
119823119842
119824119843
/*
119825119844
** Test if the cell that cursor pCursor currently points to
119826119845
** would be filtered (excluded) by the constraints in the
@@ -119899,28 +119918,27 @@
119899119918
rc = testRtreeEntry(pRtree, pCursor, &isEof);
119900119919
}else{
119901119920
rc = testRtreeCell(pRtree, pCursor, &isEof);
119902119921
}
119903119922
if( rc!=SQLITE_OK || isEof || iHeight==0 ){
119904
- *pEof = isEof;
119905
- return rc;
119923
+ goto descend_to_cell_out;
119906119924
}
119907119925
119908119926
iRowid = nodeGetRowid(pRtree, pCursor->pNode, pCursor->iCell);
119909119927
rc = nodeAcquire(pRtree, iRowid, pCursor->pNode, &pChild);
119910119928
if( rc!=SQLITE_OK ){
119911
- return rc;
119929
+ goto descend_to_cell_out;
119912119930
}
119913119931
119914119932
nodeRelease(pRtree, pCursor->pNode);
119915119933
pCursor->pNode = pChild;
119916119934
isEof = 1;
119917119935
for(ii=0; isEof && ii<NCELL(pChild); ii++){
119918119936
pCursor->iCell = ii;
119919119937
rc = descendToCell(pRtree, pCursor, iHeight-1, &isEof);
119920119938
if( rc!=SQLITE_OK ){
119921
- return rc;
119939
+ goto descend_to_cell_out;
119922119940
}
119923119941
}
119924119942
119925119943
if( isEof ){
119926119944
assert( pCursor->pNode==pChild );
@@ -119928,12 +119946,13 @@
119928119946
nodeRelease(pRtree, pChild);
119929119947
pCursor->pNode = pSavedNode;
119930119948
pCursor->iCell = iSavedCell;
119931119949
}
119932119950
119951
+descend_to_cell_out:
119933119952
*pEof = isEof;
119934
- return SQLITE_OK;
119953
+ return rc;
119935119954
}
119936119955
119937119956
/*
119938119957
** One of the cells in node pNode is guaranteed to have a 64-bit
119939119958
** integer value equal to iRowid. Return the index of this cell.
119940119959
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -650,11 +650,11 @@
650 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
651 ** [sqlite_version()] and [sqlite_source_id()].
652 */
653 #define SQLITE_VERSION "3.7.4"
654 #define SQLITE_VERSION_NUMBER 3007004
655 #define SQLITE_SOURCE_ID "2010-11-26 16:49:59 c412f61229b6ab1ac90b932afd56f7c5e3ba1cfe"
656
657 /*
658 ** CAPI3REF: Run-Time Library Version Numbers
659 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
660 **
@@ -9959,19 +9959,19 @@
9959 Table *pTab; /* An SQL table corresponding to zName */
9960 Select *pSelect; /* A SELECT statement used in place of a table name */
9961 u8 isPopulated; /* Temporary table associated with SELECT is populated */
9962 u8 jointype; /* Type of join between this able and the previous */
9963 u8 notIndexed; /* True if there is a NOT INDEXED clause */
 
 
 
9964 int iCursor; /* The VDBE cursor number used to access this table */
9965 Expr *pOn; /* The ON clause of a join */
9966 IdList *pUsing; /* The USING clause of a join */
9967 Bitmask colUsed; /* Bit N (1<<N) set if column N of pTab is used */
9968 char *zIndex; /* Identifier from "INDEXED BY <zIndex>" clause */
9969 Index *pIndex; /* Index structure corresponding to zIndex, if any */
9970 #ifndef SQLITE_OMIT_EXPLAIN
9971 int iSelectId; /* If pSelect!=0, the id of the sub-select in EQP */
9972 #endif
9973 } a[1]; /* One entry for each identifier on the list */
9974 };
9975
9976 /*
9977 ** Permitted values of the SrcList.a.jointype field
@@ -12056,30 +12056,38 @@
12056 ** values stored in the Vdbe struct. When the sub-program is finished,
12057 ** these values are copied back to the Vdbe from the VdbeFrame structure,
12058 ** restoring the state of the VM to as it was before the sub-program
12059 ** began executing.
12060 **
12061 ** Frames are stored in a linked list headed at Vdbe.pParent. Vdbe.pParent
12062 ** is the parent of the current frame, or zero if the current frame
12063 ** is the main Vdbe program.
 
 
 
 
 
 
 
 
12064 */
12065 typedef struct VdbeFrame VdbeFrame;
12066 struct VdbeFrame {
12067 Vdbe *v; /* VM this frame belongs to */
12068 int pc; /* Program Counter */
12069 Op *aOp; /* Program instructions */
12070 int nOp; /* Size of aOp array */
12071 Mem *aMem; /* Array of memory cells */
12072 int nMem; /* Number of entries in aMem */
12073 VdbeCursor **apCsr; /* Element of Vdbe cursors */
12074 u16 nCursor; /* Number of entries in apCsr */
12075 void *token; /* Copy of SubProgram.token */
12076 int nChildMem; /* Number of memory cells for child frame */
12077 int nChildCsr; /* Number of cursors for child frame */
12078 i64 lastRowid; /* Last insert rowid (sqlite3.lastRowid) */
12079 int nChange; /* Statement changes (Vdbe.nChanges) */
12080 VdbeFrame *pParent; /* Parent of this frame */
12081 };
12082
12083 #define VdbeFrameMem(p) ((Mem *)&((u8 *)p)[ROUND8(sizeof(VdbeFrame))])
12084
12085 /*
@@ -12292,10 +12300,11 @@
12292 int iStatement; /* Statement number (or 0 if has not opened stmt) */
12293 #ifdef SQLITE_DEBUG
12294 FILE *trace; /* Write an execution trace here, if not NULL */
12295 #endif
12296 VdbeFrame *pFrame; /* Parent frame */
 
12297 int nFrame; /* Number of frames in pFrame list */
12298 u32 expmask; /* Binding to these vars invalidates VM */
12299 SubProgram *pProgram; /* Linked list of all sub-programs used by VM */
12300 };
12301
@@ -27840,11 +27849,11 @@
27840 ** message is available, it is written to zBufOut. If no error message
27841 ** is available, zBufOut is left unmodified and SQLite uses a default
27842 ** error message.
27843 */
27844 static void unixDlError(sqlite3_vfs *NotUsed, int nBuf, char *zBufOut){
27845 char *zErr;
27846 UNUSED_PARAMETER(NotUsed);
27847 unixEnterMutex();
27848 zErr = dlerror();
27849 if( zErr ){
27850 sqlite3_snprintf(nBuf, zBufOut, "%s", zErr);
@@ -28434,31 +28443,31 @@
28434
28435 /* create a new path by replace the trailing '-conch' with '-break' */
28436 pathLen = strlcpy(tPath, cPath, MAXPATHLEN);
28437 if( pathLen>MAXPATHLEN || pathLen<6 ||
28438 (strlcpy(&tPath[pathLen-5], "break", 6) != 5) ){
28439 sprintf(errmsg, "path error (len %d)", (int)pathLen);
28440 goto end_breaklock;
28441 }
28442 /* read the conch content */
28443 readLen = pread(conchFile->h, buf, PROXY_MAXCONCHLEN, 0);
28444 if( readLen<PROXY_PATHINDEX ){
28445 sprintf(errmsg, "read error (len %d)", (int)readLen);
28446 goto end_breaklock;
28447 }
28448 /* write it out to the temporary break file */
28449 fd = open(tPath, (O_RDWR|O_CREAT|O_EXCL), SQLITE_DEFAULT_FILE_PERMISSIONS);
28450 if( fd<0 ){
28451 sprintf(errmsg, "create failed (%d)", errno);
28452 goto end_breaklock;
28453 }
28454 if( pwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){
28455 sprintf(errmsg, "write failed (%d)", errno);
28456 goto end_breaklock;
28457 }
28458 if( rename(tPath, cPath) ){
28459 sprintf(errmsg, "rename failed (%d)", errno);
28460 goto end_breaklock;
28461 }
28462 rc = 0;
28463 fprintf(stderr, "broke stale lock on %s\n", cPath);
28464 close(conchFile->h);
@@ -54476,11 +54485,13 @@
54476 /*
54477 ** Delete any previous value and set the value stored in *pMem to NULL.
54478 */
54479 SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem *pMem){
54480 if( pMem->flags & MEM_Frame ){
54481 sqlite3VdbeFrameDelete(pMem->u.pFrame);
 
 
54482 }
54483 if( pMem->flags & MEM_RowSet ){
54484 sqlite3RowSetClear(pMem->u.pRowSet);
54485 }
54486 MemSetTypeFlag(pMem, MEM_Null);
@@ -56676,10 +56687,15 @@
56676 }
56677 }
56678 if( p->aMem ){
56679 releaseMemArray(&p->aMem[1], p->nMem);
56680 }
 
 
 
 
 
56681 }
56682
56683 /*
56684 ** Clean up the VM after execution.
56685 **
@@ -91416,11 +91432,11 @@
91416 }
91417 i = -1;
91418 }else{
91419 sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor);
91420 assert( pItem->isPopulated==0 );
91421 explainSetInteger(pItem->iSelectId, pParse->iNextSelectId);
91422 sqlite3Select(pParse, pSub, &dest);
91423 pItem->isPopulated = 1;
91424 pItem->pTab->nRowEst = (unsigned)pSub->nSelectRow;
91425 }
91426 if( /*pParse->nErr ||*/ db->mallocFailed ){
@@ -108828,11 +108844,11 @@
108828 while( *zCsr!='=' ){
108829 if( *zCsr=='\0' ) return 0;
108830 zCsr++;
108831 }
108832
108833 *pnKey = zCsr-z;
108834 zValue = sqlite3_mprintf("%s", &zCsr[1]);
108835 if( zValue ){
108836 sqlite3Fts3Dequote(zValue);
108837 }
108838 *pzValue = zValue;
@@ -108883,11 +108899,11 @@
108883 nDb = (int)strlen(argv[1]) + 1;
108884 nName = (int)strlen(argv[2]) + 1;
108885
108886 aCol = (const char **)sqlite3_malloc(sizeof(const char *) * (argc-2) );
108887 if( !aCol ) return SQLITE_NOMEM;
108888 memset(aCol, 0, sizeof(const char *) * (argc-2));
108889
108890 /* Loop through all of the arguments passed by the user to the FTS3/4
108891 ** module (i.e. all the column names and special arguments). This loop
108892 ** does the following:
108893 **
@@ -109015,11 +109031,11 @@
109015 /* Declare the table schema to SQLite. */
109016 fts3DeclareVtab(&rc, p);
109017
109018 fts3_init_out:
109019
109020 sqlite3_free(aCol);
109021 if( rc!=SQLITE_OK ){
109022 if( p ){
109023 fts3DisconnectMethod((sqlite3_vtab *)p);
109024 }else if( pTokenizer ){
109025 pTokenizer->pModule->xDestroy(pTokenizer);
@@ -110371,11 +110387,11 @@
110371 p += sqlite3Fts3GetVarint(p, &delta);
110372 fts3PoslistCopy(0, &p);
110373 pOut += sqlite3Fts3PutVarint(pOut, delta);
110374 }
110375
110376 *pnList = (pOut - aList);
110377 }
110378 }
110379
110380 /*
110381 ** Return a DocList corresponding to the phrase *pPhrase.
@@ -112464,51 +112480,57 @@
112464
112465 return sqlite3_finalize(pStmt);
112466 }
112467
112468 /*
112469 ** This function is part of the test interface for the query parser. It
112470 ** writes a text representation of the query expression pExpr into the
112471 ** buffer pointed to by argument zBuf. It is assumed that zBuf is large
112472 ** enough to store the required text representation.
 
 
 
 
112473 */
112474 static void exprToString(Fts3Expr *pExpr, char *zBuf){
112475 switch( pExpr->eType ){
112476 case FTSQUERY_PHRASE: {
112477 Fts3Phrase *pPhrase = pExpr->pPhrase;
112478 int i;
112479 zBuf += sprintf(zBuf, "PHRASE %d %d", pPhrase->iColumn, pPhrase->isNot);
112480 for(i=0; i<pPhrase->nToken; i++){
112481 zBuf += sprintf(zBuf," %.*s",pPhrase->aToken[i].n,pPhrase->aToken[i].z);
112482 zBuf += sprintf(zBuf,"%s", (pPhrase->aToken[i].isPrefix?"+":""));
 
 
 
112483 }
112484 return;
112485 }
112486
112487 case FTSQUERY_NEAR:
112488 zBuf += sprintf(zBuf, "NEAR/%d ", pExpr->nNear);
112489 break;
112490 case FTSQUERY_NOT:
112491 zBuf += sprintf(zBuf, "NOT ");
112492 break;
112493 case FTSQUERY_AND:
112494 zBuf += sprintf(zBuf, "AND ");
112495 break;
112496 case FTSQUERY_OR:
112497 zBuf += sprintf(zBuf, "OR ");
112498 break;
112499 }
112500
112501 zBuf += sprintf(zBuf, "{");
112502 exprToString(pExpr->pLeft, zBuf);
112503 zBuf += strlen(zBuf);
112504 zBuf += sprintf(zBuf, "} ");
112505
112506 zBuf += sprintf(zBuf, "{");
112507 exprToString(pExpr->pRight, zBuf);
112508 zBuf += strlen(zBuf);
112509 zBuf += sprintf(zBuf, "}");
112510 }
112511
112512 /*
112513 ** This is the implementation of a scalar SQL function used to test the
112514 ** expression parser. It should be called as follows:
@@ -112535,10 +112557,11 @@
112535 const char *zExpr;
112536 int nExpr;
112537 int nCol;
112538 int ii;
112539 Fts3Expr *pExpr;
 
112540 sqlite3 *db = sqlite3_context_db_handle(context);
112541
112542 if( argc<3 ){
112543 sqlite3_result_error(context,
112544 "Usage: fts3_exprtest(tokenizer, expr, col1, ...", -1
@@ -112577,21 +112600,20 @@
112577 }
112578
112579 rc = sqlite3Fts3ExprParse(
112580 pTokenizer, azCol, nCol, nCol, zExpr, nExpr, &pExpr
112581 );
112582 if( rc==SQLITE_NOMEM ){
 
 
112583 sqlite3_result_error_nomem(context);
112584 goto exprtest_out;
112585 }else if( rc==SQLITE_OK ){
112586 char zBuf[4096];
112587 exprToString(pExpr, zBuf);
112588 sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
112589 sqlite3Fts3ExprFree(pExpr);
112590 }else{
112591 sqlite3_result_error(context, "Error parsing expression", -1);
112592 }
 
 
112593
112594 exprtest_out:
112595 if( pModule && pTokenizer ){
112596 rc = pModule->xDestroy(pTokenizer);
112597 }
@@ -115471,11 +115493,11 @@
115471 while( a<pEnd ){
115472 a += sqlite3Fts3GetVarint(a, &nByte);
115473 }
115474 }
115475
115476 pCsr->nRowAvg = (((nByte / nDoc) + pgsz - 1) / pgsz);
115477 }
115478 rc = sqlite3_reset(pStmt);
115479 if( rc!=SQLITE_OK || pCsr->nRowAvg==0 ) return rc;
115480 }
115481
@@ -118278,16 +118300,16 @@
118278 pIter->iCol = LCS_ITERATOR_FINISHED;
118279 rc = 1;
118280 }else{
118281 if( iRead==1 ){
118282 pRead += sqlite3Fts3GetVarint(pRead, &iRead);
118283 pIter->iCol = iRead;
118284 pIter->iPos = pIter->iPosOffset;
118285 pRead += sqlite3Fts3GetVarint(pRead, &iRead);
118286 rc = 1;
118287 }
118288 pIter->iPos += (iRead-2);
118289 }
118290
118291 pIter->pRead = pRead;
118292 return rc;
118293 }
@@ -118432,11 +118454,11 @@
118432 if( rc==SQLITE_OK ){
118433 int iCol;
118434 for(iCol=0; iCol<pInfo->nCol; iCol++){
118435 sqlite3_int64 nToken;
118436 a += sqlite3Fts3GetVarint(a, &nToken);
118437 pInfo->aMatchinfo[iCol] = ((u32)(nToken&0xffffffff)+nDoc/2)/nDoc;
118438 }
118439 }
118440 }
118441 break;
118442
@@ -118535,11 +118557,11 @@
118535 for(i=0; zArg[i]; i++){
118536 nMatchinfo += fts3MatchinfoSize(&sInfo, zArg[i]);
118537 }
118538
118539 /* Allocate space for Fts3Cursor.aMatchinfo[] and Fts3Cursor.zMatchinfo. */
118540 nArg = strlen(zArg);
118541 pCsr->aMatchinfo = (u32 *)sqlite3_malloc(sizeof(u32)*nMatchinfo + nArg + 1);
118542 if( !pCsr->aMatchinfo ) return SQLITE_NOMEM;
118543
118544 pCsr->zMatchinfo = (char *)&pCsr->aMatchinfo[nMatchinfo];
118545 pCsr->nMatchinfo = nMatchinfo;
@@ -119778,10 +119800,11 @@
119778 */
119779 static int testRtreeCell(Rtree *pRtree, RtreeCursor *pCursor, int *pbEof){
119780 RtreeCell cell;
119781 int ii;
119782 int bRes = 0;
 
119783
119784 nodeGetCell(pRtree, pCursor->pNode, pCursor->iCell, &cell);
119785 for(ii=0; bRes==0 && ii<pCursor->nConstraint; ii++){
119786 RtreeConstraint *p = &pCursor->aConstraint[ii];
119787 double cell_min = DCOORD(cell.aCoord[(p->iCoord>>1)*2]);
@@ -119803,24 +119826,20 @@
119803 case RTREE_EQ:
119804 bRes = (p->rValue>cell_max || p->rValue<cell_min);
119805 break;
119806
119807 default: {
119808 int rc;
119809 assert( p->op==RTREE_MATCH );
119810 rc = testRtreeGeom(pRtree, p, &cell, &bRes);
119811 if( rc!=SQLITE_OK ){
119812 return rc;
119813 }
119814 bRes = !bRes;
119815 break;
119816 }
119817 }
119818 }
119819
119820 *pbEof = bRes;
119821 return SQLITE_OK;
119822 }
119823
119824 /*
119825 ** Test if the cell that cursor pCursor currently points to
119826 ** would be filtered (excluded) by the constraints in the
@@ -119899,28 +119918,27 @@
119899 rc = testRtreeEntry(pRtree, pCursor, &isEof);
119900 }else{
119901 rc = testRtreeCell(pRtree, pCursor, &isEof);
119902 }
119903 if( rc!=SQLITE_OK || isEof || iHeight==0 ){
119904 *pEof = isEof;
119905 return rc;
119906 }
119907
119908 iRowid = nodeGetRowid(pRtree, pCursor->pNode, pCursor->iCell);
119909 rc = nodeAcquire(pRtree, iRowid, pCursor->pNode, &pChild);
119910 if( rc!=SQLITE_OK ){
119911 return rc;
119912 }
119913
119914 nodeRelease(pRtree, pCursor->pNode);
119915 pCursor->pNode = pChild;
119916 isEof = 1;
119917 for(ii=0; isEof && ii<NCELL(pChild); ii++){
119918 pCursor->iCell = ii;
119919 rc = descendToCell(pRtree, pCursor, iHeight-1, &isEof);
119920 if( rc!=SQLITE_OK ){
119921 return rc;
119922 }
119923 }
119924
119925 if( isEof ){
119926 assert( pCursor->pNode==pChild );
@@ -119928,12 +119946,13 @@
119928 nodeRelease(pRtree, pChild);
119929 pCursor->pNode = pSavedNode;
119930 pCursor->iCell = iSavedCell;
119931 }
119932
 
119933 *pEof = isEof;
119934 return SQLITE_OK;
119935 }
119936
119937 /*
119938 ** One of the cells in node pNode is guaranteed to have a 64-bit
119939 ** integer value equal to iRowid. Return the index of this cell.
119940
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -650,11 +650,11 @@
650 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
651 ** [sqlite_version()] and [sqlite_source_id()].
652 */
653 #define SQLITE_VERSION "3.7.4"
654 #define SQLITE_VERSION_NUMBER 3007004
655 #define SQLITE_SOURCE_ID "2010-12-02 11:24:58 a94b9a395e0be9549d8c28e2b86b995c73c7b671"
656
657 /*
658 ** CAPI3REF: Run-Time Library Version Numbers
659 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
660 **
@@ -9959,19 +9959,19 @@
9959 Table *pTab; /* An SQL table corresponding to zName */
9960 Select *pSelect; /* A SELECT statement used in place of a table name */
9961 u8 isPopulated; /* Temporary table associated with SELECT is populated */
9962 u8 jointype; /* Type of join between this able and the previous */
9963 u8 notIndexed; /* True if there is a NOT INDEXED clause */
9964 #ifndef SQLITE_OMIT_EXPLAIN
9965 u8 iSelectId; /* If pSelect!=0, the id of the sub-select in EQP */
9966 #endif
9967 int iCursor; /* The VDBE cursor number used to access this table */
9968 Expr *pOn; /* The ON clause of a join */
9969 IdList *pUsing; /* The USING clause of a join */
9970 Bitmask colUsed; /* Bit N (1<<N) set if column N of pTab is used */
9971 char *zIndex; /* Identifier from "INDEXED BY <zIndex>" clause */
9972 Index *pIndex; /* Index structure corresponding to zIndex, if any */
 
 
 
9973 } a[1]; /* One entry for each identifier on the list */
9974 };
9975
9976 /*
9977 ** Permitted values of the SrcList.a.jointype field
@@ -12056,30 +12056,38 @@
12056 ** values stored in the Vdbe struct. When the sub-program is finished,
12057 ** these values are copied back to the Vdbe from the VdbeFrame structure,
12058 ** restoring the state of the VM to as it was before the sub-program
12059 ** began executing.
12060 **
12061 ** The memory for a VdbeFrame object is allocated and managed by a memory
12062 ** cell in the parent (calling) frame. When the memory cell is deleted or
12063 ** overwritten, the VdbeFrame object is not freed immediately. Instead, it
12064 ** is linked into the Vdbe.pDelFrame list. The contents of the Vdbe.pDelFrame
12065 ** list is deleted when the VM is reset in VdbeHalt(). The reason for doing
12066 ** this instead of deleting the VdbeFrame immediately is to avoid recursive
12067 ** calls to sqlite3VdbeMemRelease() when the memory cells belonging to the
12068 ** child frame are released.
12069 **
12070 ** The currently executing frame is stored in Vdbe.pFrame. Vdbe.pFrame is
12071 ** set to NULL if the currently executing frame is the main program.
12072 */
12073 typedef struct VdbeFrame VdbeFrame;
12074 struct VdbeFrame {
12075 Vdbe *v; /* VM this frame belongs to */
12076 int pc; /* Program Counter in parent (calling) frame */
12077 Op *aOp; /* Program instructions for parent frame */
12078 int nOp; /* Size of aOp array */
12079 Mem *aMem; /* Array of memory cells for parent frame */
12080 int nMem; /* Number of entries in aMem */
12081 VdbeCursor **apCsr; /* Array of Vdbe cursors for parent frame */
12082 u16 nCursor; /* Number of entries in apCsr */
12083 void *token; /* Copy of SubProgram.token */
12084 int nChildMem; /* Number of memory cells for child frame */
12085 int nChildCsr; /* Number of cursors for child frame */
12086 i64 lastRowid; /* Last insert rowid (sqlite3.lastRowid) */
12087 int nChange; /* Statement changes (Vdbe.nChanges) */
12088 VdbeFrame *pParent; /* Parent of this frame, or NULL if parent is main */
12089 };
12090
12091 #define VdbeFrameMem(p) ((Mem *)&((u8 *)p)[ROUND8(sizeof(VdbeFrame))])
12092
12093 /*
@@ -12292,10 +12300,11 @@
12300 int iStatement; /* Statement number (or 0 if has not opened stmt) */
12301 #ifdef SQLITE_DEBUG
12302 FILE *trace; /* Write an execution trace here, if not NULL */
12303 #endif
12304 VdbeFrame *pFrame; /* Parent frame */
12305 VdbeFrame *pDelFrame; /* List of frame objects to free on VM reset */
12306 int nFrame; /* Number of frames in pFrame list */
12307 u32 expmask; /* Binding to these vars invalidates VM */
12308 SubProgram *pProgram; /* Linked list of all sub-programs used by VM */
12309 };
12310
@@ -27840,11 +27849,11 @@
27849 ** message is available, it is written to zBufOut. If no error message
27850 ** is available, zBufOut is left unmodified and SQLite uses a default
27851 ** error message.
27852 */
27853 static void unixDlError(sqlite3_vfs *NotUsed, int nBuf, char *zBufOut){
27854 const char *zErr;
27855 UNUSED_PARAMETER(NotUsed);
27856 unixEnterMutex();
27857 zErr = dlerror();
27858 if( zErr ){
27859 sqlite3_snprintf(nBuf, zBufOut, "%s", zErr);
@@ -28434,31 +28443,31 @@
28443
28444 /* create a new path by replace the trailing '-conch' with '-break' */
28445 pathLen = strlcpy(tPath, cPath, MAXPATHLEN);
28446 if( pathLen>MAXPATHLEN || pathLen<6 ||
28447 (strlcpy(&tPath[pathLen-5], "break", 6) != 5) ){
28448 sqlite3_snprintf(sizeof(errmsg),errmsg,"path error (len %d)",(int)pathLen);
28449 goto end_breaklock;
28450 }
28451 /* read the conch content */
28452 readLen = pread(conchFile->h, buf, PROXY_MAXCONCHLEN, 0);
28453 if( readLen<PROXY_PATHINDEX ){
28454 sqlite3_snprintf(sizeof(errmsg),errmsg,"read error (len %d)",(int)readLen);
28455 goto end_breaklock;
28456 }
28457 /* write it out to the temporary break file */
28458 fd = open(tPath, (O_RDWR|O_CREAT|O_EXCL), SQLITE_DEFAULT_FILE_PERMISSIONS);
28459 if( fd<0 ){
28460 sqlite3_snprintf(sizeof(errmsg), errmsg, "create failed (%d)", errno);
28461 goto end_breaklock;
28462 }
28463 if( pwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){
28464 sqlite3_snprintf(sizeof(errmsg), errmsg, "write failed (%d)", errno);
28465 goto end_breaklock;
28466 }
28467 if( rename(tPath, cPath) ){
28468 sqlite3_snprintf(sizeof(errmsg), errmsg, "rename failed (%d)", errno);
28469 goto end_breaklock;
28470 }
28471 rc = 0;
28472 fprintf(stderr, "broke stale lock on %s\n", cPath);
28473 close(conchFile->h);
@@ -54476,11 +54485,13 @@
54485 /*
54486 ** Delete any previous value and set the value stored in *pMem to NULL.
54487 */
54488 SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem *pMem){
54489 if( pMem->flags & MEM_Frame ){
54490 VdbeFrame *pFrame = pMem->u.pFrame;
54491 pFrame->pParent = pFrame->v->pDelFrame;
54492 pFrame->v->pDelFrame = pFrame;
54493 }
54494 if( pMem->flags & MEM_RowSet ){
54495 sqlite3RowSetClear(pMem->u.pRowSet);
54496 }
54497 MemSetTypeFlag(pMem, MEM_Null);
@@ -56676,10 +56687,15 @@
56687 }
56688 }
56689 if( p->aMem ){
56690 releaseMemArray(&p->aMem[1], p->nMem);
56691 }
56692 while( p->pDelFrame ){
56693 VdbeFrame *pDel = p->pDelFrame;
56694 p->pDelFrame = pDel->pParent;
56695 sqlite3VdbeFrameDelete(pDel);
56696 }
56697 }
56698
56699 /*
56700 ** Clean up the VM after execution.
56701 **
@@ -91416,11 +91432,11 @@
91432 }
91433 i = -1;
91434 }else{
91435 sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor);
91436 assert( pItem->isPopulated==0 );
91437 explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId);
91438 sqlite3Select(pParse, pSub, &dest);
91439 pItem->isPopulated = 1;
91440 pItem->pTab->nRowEst = (unsigned)pSub->nSelectRow;
91441 }
91442 if( /*pParse->nErr ||*/ db->mallocFailed ){
@@ -108828,11 +108844,11 @@
108844 while( *zCsr!='=' ){
108845 if( *zCsr=='\0' ) return 0;
108846 zCsr++;
108847 }
108848
108849 *pnKey = (int)(zCsr-z);
108850 zValue = sqlite3_mprintf("%s", &zCsr[1]);
108851 if( zValue ){
108852 sqlite3Fts3Dequote(zValue);
108853 }
108854 *pzValue = zValue;
@@ -108883,11 +108899,11 @@
108899 nDb = (int)strlen(argv[1]) + 1;
108900 nName = (int)strlen(argv[2]) + 1;
108901
108902 aCol = (const char **)sqlite3_malloc(sizeof(const char *) * (argc-2) );
108903 if( !aCol ) return SQLITE_NOMEM;
108904 memset((void *)aCol, 0, sizeof(const char *) * (argc-2));
108905
108906 /* Loop through all of the arguments passed by the user to the FTS3/4
108907 ** module (i.e. all the column names and special arguments). This loop
108908 ** does the following:
108909 **
@@ -109015,11 +109031,11 @@
109031 /* Declare the table schema to SQLite. */
109032 fts3DeclareVtab(&rc, p);
109033
109034 fts3_init_out:
109035
109036 sqlite3_free((void *)aCol);
109037 if( rc!=SQLITE_OK ){
109038 if( p ){
109039 fts3DisconnectMethod((sqlite3_vtab *)p);
109040 }else if( pTokenizer ){
109041 pTokenizer->pModule->xDestroy(pTokenizer);
@@ -110371,11 +110387,11 @@
110387 p += sqlite3Fts3GetVarint(p, &delta);
110388 fts3PoslistCopy(0, &p);
110389 pOut += sqlite3Fts3PutVarint(pOut, delta);
110390 }
110391
110392 *pnList = (int)(pOut - aList);
110393 }
110394 }
110395
110396 /*
110397 ** Return a DocList corresponding to the phrase *pPhrase.
@@ -112464,51 +112480,57 @@
112480
112481 return sqlite3_finalize(pStmt);
112482 }
112483
112484 /*
112485 ** Return a pointer to a buffer containing a text representation of the
112486 ** expression passed as the first argument. The buffer is obtained from
112487 ** sqlite3_malloc(). It is the responsibility of the caller to use
112488 ** sqlite3_free() to release the memory. If an OOM condition is encountered,
112489 ** NULL is returned.
112490 **
112491 ** If the second argument is not NULL, then its contents are prepended to
112492 ** the returned expression text and then freed using sqlite3_free().
112493 */
112494 static char *exprToString(Fts3Expr *pExpr, char *zBuf){
112495 switch( pExpr->eType ){
112496 case FTSQUERY_PHRASE: {
112497 Fts3Phrase *pPhrase = pExpr->pPhrase;
112498 int i;
112499 zBuf = sqlite3_mprintf(
112500 "%zPHRASE %d %d", zBuf, pPhrase->iColumn, pPhrase->isNot);
112501 for(i=0; zBuf && i<pPhrase->nToken; i++){
112502 zBuf = sqlite3_mprintf("%z %.*s%s", zBuf,
112503 pPhrase->aToken[i].n, pPhrase->aToken[i].z,
112504 (pPhrase->aToken[i].isPrefix?"+":"")
112505 );
112506 }
112507 return zBuf;
112508 }
112509
112510 case FTSQUERY_NEAR:
112511 zBuf = sqlite3_mprintf("%zNEAR/%d ", zBuf, pExpr->nNear);
112512 break;
112513 case FTSQUERY_NOT:
112514 zBuf = sqlite3_mprintf("%zNOT ", zBuf);
112515 break;
112516 case FTSQUERY_AND:
112517 zBuf = sqlite3_mprintf("%zAND ", zBuf);
112518 break;
112519 case FTSQUERY_OR:
112520 zBuf = sqlite3_mprintf("%zOR ", zBuf);
112521 break;
112522 }
112523
112524 if( zBuf ) zBuf = sqlite3_mprintf("%z{", zBuf);
112525 if( zBuf ) zBuf = exprToString(pExpr->pLeft, zBuf);
112526 if( zBuf ) zBuf = sqlite3_mprintf("%z} {", zBuf);
112527
112528 if( zBuf ) zBuf = exprToString(pExpr->pRight, zBuf);
112529 if( zBuf ) zBuf = sqlite3_mprintf("%z}", zBuf);
112530
112531 return zBuf;
 
112532 }
112533
112534 /*
112535 ** This is the implementation of a scalar SQL function used to test the
112536 ** expression parser. It should be called as follows:
@@ -112535,10 +112557,11 @@
112557 const char *zExpr;
112558 int nExpr;
112559 int nCol;
112560 int ii;
112561 Fts3Expr *pExpr;
112562 char *zBuf = 0;
112563 sqlite3 *db = sqlite3_context_db_handle(context);
112564
112565 if( argc<3 ){
112566 sqlite3_result_error(context,
112567 "Usage: fts3_exprtest(tokenizer, expr, col1, ...", -1
@@ -112577,21 +112600,20 @@
112600 }
112601
112602 rc = sqlite3Fts3ExprParse(
112603 pTokenizer, azCol, nCol, nCol, zExpr, nExpr, &pExpr
112604 );
112605 if( rc!=SQLITE_OK && rc!=SQLITE_NOMEM ){
112606 sqlite3_result_error(context, "Error parsing expression", -1);
112607 }else if( rc==SQLITE_NOMEM || !(zBuf = exprToString(pExpr, 0)) ){
112608 sqlite3_result_error_nomem(context);
112609 }else{
 
 
 
112610 sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
112611 sqlite3_free(zBuf);
 
 
112612 }
112613
112614 sqlite3Fts3ExprFree(pExpr);
112615
112616 exprtest_out:
112617 if( pModule && pTokenizer ){
112618 rc = pModule->xDestroy(pTokenizer);
112619 }
@@ -115471,11 +115493,11 @@
115493 while( a<pEnd ){
115494 a += sqlite3Fts3GetVarint(a, &nByte);
115495 }
115496 }
115497
115498 pCsr->nRowAvg = (int)(((nByte / nDoc) + pgsz - 1) / pgsz);
115499 }
115500 rc = sqlite3_reset(pStmt);
115501 if( rc!=SQLITE_OK || pCsr->nRowAvg==0 ) return rc;
115502 }
115503
@@ -118278,16 +118300,16 @@
118300 pIter->iCol = LCS_ITERATOR_FINISHED;
118301 rc = 1;
118302 }else{
118303 if( iRead==1 ){
118304 pRead += sqlite3Fts3GetVarint(pRead, &iRead);
118305 pIter->iCol = (int)iRead;
118306 pIter->iPos = pIter->iPosOffset;
118307 pRead += sqlite3Fts3GetVarint(pRead, &iRead);
118308 rc = 1;
118309 }
118310 pIter->iPos += (int)(iRead-2);
118311 }
118312
118313 pIter->pRead = pRead;
118314 return rc;
118315 }
@@ -118432,11 +118454,11 @@
118454 if( rc==SQLITE_OK ){
118455 int iCol;
118456 for(iCol=0; iCol<pInfo->nCol; iCol++){
118457 sqlite3_int64 nToken;
118458 a += sqlite3Fts3GetVarint(a, &nToken);
118459 pInfo->aMatchinfo[iCol] = (u32)(((u32)(nToken&0xffffffff)+nDoc/2)/nDoc);
118460 }
118461 }
118462 }
118463 break;
118464
@@ -118535,11 +118557,11 @@
118557 for(i=0; zArg[i]; i++){
118558 nMatchinfo += fts3MatchinfoSize(&sInfo, zArg[i]);
118559 }
118560
118561 /* Allocate space for Fts3Cursor.aMatchinfo[] and Fts3Cursor.zMatchinfo. */
118562 nArg = (int)strlen(zArg);
118563 pCsr->aMatchinfo = (u32 *)sqlite3_malloc(sizeof(u32)*nMatchinfo + nArg + 1);
118564 if( !pCsr->aMatchinfo ) return SQLITE_NOMEM;
118565
118566 pCsr->zMatchinfo = (char *)&pCsr->aMatchinfo[nMatchinfo];
118567 pCsr->nMatchinfo = nMatchinfo;
@@ -119778,10 +119800,11 @@
119800 */
119801 static int testRtreeCell(Rtree *pRtree, RtreeCursor *pCursor, int *pbEof){
119802 RtreeCell cell;
119803 int ii;
119804 int bRes = 0;
119805 int rc = SQLITE_OK;
119806
119807 nodeGetCell(pRtree, pCursor->pNode, pCursor->iCell, &cell);
119808 for(ii=0; bRes==0 && ii<pCursor->nConstraint; ii++){
119809 RtreeConstraint *p = &pCursor->aConstraint[ii];
119810 double cell_min = DCOORD(cell.aCoord[(p->iCoord>>1)*2]);
@@ -119803,24 +119826,20 @@
119826 case RTREE_EQ:
119827 bRes = (p->rValue>cell_max || p->rValue<cell_min);
119828 break;
119829
119830 default: {
 
119831 assert( p->op==RTREE_MATCH );
119832 rc = testRtreeGeom(pRtree, p, &cell, &bRes);
 
 
 
119833 bRes = !bRes;
119834 break;
119835 }
119836 }
119837 }
119838
119839 *pbEof = bRes;
119840 return rc;
119841 }
119842
119843 /*
119844 ** Test if the cell that cursor pCursor currently points to
119845 ** would be filtered (excluded) by the constraints in the
@@ -119899,28 +119918,27 @@
119918 rc = testRtreeEntry(pRtree, pCursor, &isEof);
119919 }else{
119920 rc = testRtreeCell(pRtree, pCursor, &isEof);
119921 }
119922 if( rc!=SQLITE_OK || isEof || iHeight==0 ){
119923 goto descend_to_cell_out;
 
119924 }
119925
119926 iRowid = nodeGetRowid(pRtree, pCursor->pNode, pCursor->iCell);
119927 rc = nodeAcquire(pRtree, iRowid, pCursor->pNode, &pChild);
119928 if( rc!=SQLITE_OK ){
119929 goto descend_to_cell_out;
119930 }
119931
119932 nodeRelease(pRtree, pCursor->pNode);
119933 pCursor->pNode = pChild;
119934 isEof = 1;
119935 for(ii=0; isEof && ii<NCELL(pChild); ii++){
119936 pCursor->iCell = ii;
119937 rc = descendToCell(pRtree, pCursor, iHeight-1, &isEof);
119938 if( rc!=SQLITE_OK ){
119939 goto descend_to_cell_out;
119940 }
119941 }
119942
119943 if( isEof ){
119944 assert( pCursor->pNode==pChild );
@@ -119928,12 +119946,13 @@
119946 nodeRelease(pRtree, pChild);
119947 pCursor->pNode = pSavedNode;
119948 pCursor->iCell = iSavedCell;
119949 }
119950
119951 descend_to_cell_out:
119952 *pEof = isEof;
119953 return rc;
119954 }
119955
119956 /*
119957 ** One of the cells in node pNode is guaranteed to have a 64-bit
119958 ** integer value equal to iRowid. Return the index of this cell.
119959
+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.4"
111111
#define SQLITE_VERSION_NUMBER 3007004
112
-#define SQLITE_SOURCE_ID "2010-11-26 16:49:59 c412f61229b6ab1ac90b932afd56f7c5e3ba1cfe"
112
+#define SQLITE_SOURCE_ID "2010-12-02 11:24:58 a94b9a395e0be9549d8c28e2b86b995c73c7b671"
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.4"
111 #define SQLITE_VERSION_NUMBER 3007004
112 #define SQLITE_SOURCE_ID "2010-11-26 16:49:59 c412f61229b6ab1ac90b932afd56f7c5e3ba1cfe"
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.4"
111 #define SQLITE_VERSION_NUMBER 3007004
112 #define SQLITE_SOURCE_ID "2010-12-02 11:24:58 a94b9a395e0be9549d8c28e2b86b995c73c7b671"
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