| | @@ -650,11 +650,11 @@ |
| 650 | 650 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 651 | 651 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 652 | 652 | */ |
| 653 | 653 | #define SQLITE_VERSION "3.7.4" |
| 654 | 654 | #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" |
| 656 | 656 | |
| 657 | 657 | /* |
| 658 | 658 | ** CAPI3REF: Run-Time Library Version Numbers |
| 659 | 659 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 660 | 660 | ** |
| | @@ -9959,19 +9959,19 @@ |
| 9959 | 9959 | Table *pTab; /* An SQL table corresponding to zName */ |
| 9960 | 9960 | Select *pSelect; /* A SELECT statement used in place of a table name */ |
| 9961 | 9961 | u8 isPopulated; /* Temporary table associated with SELECT is populated */ |
| 9962 | 9962 | u8 jointype; /* Type of join between this able and the previous */ |
| 9963 | 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 |
| 9964 | 9967 | int iCursor; /* The VDBE cursor number used to access this table */ |
| 9965 | 9968 | Expr *pOn; /* The ON clause of a join */ |
| 9966 | 9969 | IdList *pUsing; /* The USING clause of a join */ |
| 9967 | 9970 | Bitmask colUsed; /* Bit N (1<<N) set if column N of pTab is used */ |
| 9968 | 9971 | char *zIndex; /* Identifier from "INDEXED BY <zIndex>" clause */ |
| 9969 | 9972 | 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 | 9973 | } a[1]; /* One entry for each identifier on the list */ |
| 9974 | 9974 | }; |
| 9975 | 9975 | |
| 9976 | 9976 | /* |
| 9977 | 9977 | ** Permitted values of the SrcList.a.jointype field |
| | @@ -12056,30 +12056,38 @@ |
| 12056 | 12056 | ** values stored in the Vdbe struct. When the sub-program is finished, |
| 12057 | 12057 | ** these values are copied back to the Vdbe from the VdbeFrame structure, |
| 12058 | 12058 | ** restoring the state of the VM to as it was before the sub-program |
| 12059 | 12059 | ** began executing. |
| 12060 | 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. |
| 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. |
| 12064 | 12072 | */ |
| 12065 | 12073 | typedef struct VdbeFrame VdbeFrame; |
| 12066 | 12074 | struct VdbeFrame { |
| 12067 | 12075 | 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 */ |
| 12070 | 12078 | int nOp; /* Size of aOp array */ |
| 12071 | | - Mem *aMem; /* Array of memory cells */ |
| 12079 | + Mem *aMem; /* Array of memory cells for parent frame */ |
| 12072 | 12080 | int nMem; /* Number of entries in aMem */ |
| 12073 | | - VdbeCursor **apCsr; /* Element of Vdbe cursors */ |
| 12081 | + VdbeCursor **apCsr; /* Array of Vdbe cursors for parent frame */ |
| 12074 | 12082 | u16 nCursor; /* Number of entries in apCsr */ |
| 12075 | 12083 | void *token; /* Copy of SubProgram.token */ |
| 12076 | 12084 | int nChildMem; /* Number of memory cells for child frame */ |
| 12077 | 12085 | int nChildCsr; /* Number of cursors for child frame */ |
| 12078 | 12086 | i64 lastRowid; /* Last insert rowid (sqlite3.lastRowid) */ |
| 12079 | 12087 | 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 */ |
| 12081 | 12089 | }; |
| 12082 | 12090 | |
| 12083 | 12091 | #define VdbeFrameMem(p) ((Mem *)&((u8 *)p)[ROUND8(sizeof(VdbeFrame))]) |
| 12084 | 12092 | |
| 12085 | 12093 | /* |
| | @@ -12292,10 +12300,11 @@ |
| 12292 | 12300 | int iStatement; /* Statement number (or 0 if has not opened stmt) */ |
| 12293 | 12301 | #ifdef SQLITE_DEBUG |
| 12294 | 12302 | FILE *trace; /* Write an execution trace here, if not NULL */ |
| 12295 | 12303 | #endif |
| 12296 | 12304 | VdbeFrame *pFrame; /* Parent frame */ |
| 12305 | + VdbeFrame *pDelFrame; /* List of frame objects to free on VM reset */ |
| 12297 | 12306 | int nFrame; /* Number of frames in pFrame list */ |
| 12298 | 12307 | u32 expmask; /* Binding to these vars invalidates VM */ |
| 12299 | 12308 | SubProgram *pProgram; /* Linked list of all sub-programs used by VM */ |
| 12300 | 12309 | }; |
| 12301 | 12310 | |
| | @@ -27840,11 +27849,11 @@ |
| 27840 | 27849 | ** message is available, it is written to zBufOut. If no error message |
| 27841 | 27850 | ** is available, zBufOut is left unmodified and SQLite uses a default |
| 27842 | 27851 | ** error message. |
| 27843 | 27852 | */ |
| 27844 | 27853 | static void unixDlError(sqlite3_vfs *NotUsed, int nBuf, char *zBufOut){ |
| 27845 | | - char *zErr; |
| 27854 | + const char *zErr; |
| 27846 | 27855 | UNUSED_PARAMETER(NotUsed); |
| 27847 | 27856 | unixEnterMutex(); |
| 27848 | 27857 | zErr = dlerror(); |
| 27849 | 27858 | if( zErr ){ |
| 27850 | 27859 | sqlite3_snprintf(nBuf, zBufOut, "%s", zErr); |
| | @@ -28434,31 +28443,31 @@ |
| 28434 | 28443 | |
| 28435 | 28444 | /* create a new path by replace the trailing '-conch' with '-break' */ |
| 28436 | 28445 | pathLen = strlcpy(tPath, cPath, MAXPATHLEN); |
| 28437 | 28446 | if( pathLen>MAXPATHLEN || pathLen<6 || |
| 28438 | 28447 | (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); |
| 28440 | 28449 | goto end_breaklock; |
| 28441 | 28450 | } |
| 28442 | 28451 | /* read the conch content */ |
| 28443 | 28452 | readLen = pread(conchFile->h, buf, PROXY_MAXCONCHLEN, 0); |
| 28444 | 28453 | 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); |
| 28446 | 28455 | goto end_breaklock; |
| 28447 | 28456 | } |
| 28448 | 28457 | /* write it out to the temporary break file */ |
| 28449 | 28458 | fd = open(tPath, (O_RDWR|O_CREAT|O_EXCL), SQLITE_DEFAULT_FILE_PERMISSIONS); |
| 28450 | 28459 | if( fd<0 ){ |
| 28451 | | - sprintf(errmsg, "create failed (%d)", errno); |
| 28460 | + sqlite3_snprintf(sizeof(errmsg), errmsg, "create failed (%d)", errno); |
| 28452 | 28461 | goto end_breaklock; |
| 28453 | 28462 | } |
| 28454 | 28463 | 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); |
| 28456 | 28465 | goto end_breaklock; |
| 28457 | 28466 | } |
| 28458 | 28467 | if( rename(tPath, cPath) ){ |
| 28459 | | - sprintf(errmsg, "rename failed (%d)", errno); |
| 28468 | + sqlite3_snprintf(sizeof(errmsg), errmsg, "rename failed (%d)", errno); |
| 28460 | 28469 | goto end_breaklock; |
| 28461 | 28470 | } |
| 28462 | 28471 | rc = 0; |
| 28463 | 28472 | fprintf(stderr, "broke stale lock on %s\n", cPath); |
| 28464 | 28473 | close(conchFile->h); |
| | @@ -54476,11 +54485,13 @@ |
| 54476 | 54485 | /* |
| 54477 | 54486 | ** Delete any previous value and set the value stored in *pMem to NULL. |
| 54478 | 54487 | */ |
| 54479 | 54488 | SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem *pMem){ |
| 54480 | 54489 | 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; |
| 54482 | 54493 | } |
| 54483 | 54494 | if( pMem->flags & MEM_RowSet ){ |
| 54484 | 54495 | sqlite3RowSetClear(pMem->u.pRowSet); |
| 54485 | 54496 | } |
| 54486 | 54497 | MemSetTypeFlag(pMem, MEM_Null); |
| | @@ -56676,10 +56687,15 @@ |
| 56676 | 56687 | } |
| 56677 | 56688 | } |
| 56678 | 56689 | if( p->aMem ){ |
| 56679 | 56690 | releaseMemArray(&p->aMem[1], p->nMem); |
| 56680 | 56691 | } |
| 56692 | + while( p->pDelFrame ){ |
| 56693 | + VdbeFrame *pDel = p->pDelFrame; |
| 56694 | + p->pDelFrame = pDel->pParent; |
| 56695 | + sqlite3VdbeFrameDelete(pDel); |
| 56696 | + } |
| 56681 | 56697 | } |
| 56682 | 56698 | |
| 56683 | 56699 | /* |
| 56684 | 56700 | ** Clean up the VM after execution. |
| 56685 | 56701 | ** |
| | @@ -91416,11 +91432,11 @@ |
| 91416 | 91432 | } |
| 91417 | 91433 | i = -1; |
| 91418 | 91434 | }else{ |
| 91419 | 91435 | sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor); |
| 91420 | 91436 | assert( pItem->isPopulated==0 ); |
| 91421 | | - explainSetInteger(pItem->iSelectId, pParse->iNextSelectId); |
| 91437 | + explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId); |
| 91422 | 91438 | sqlite3Select(pParse, pSub, &dest); |
| 91423 | 91439 | pItem->isPopulated = 1; |
| 91424 | 91440 | pItem->pTab->nRowEst = (unsigned)pSub->nSelectRow; |
| 91425 | 91441 | } |
| 91426 | 91442 | if( /*pParse->nErr ||*/ db->mallocFailed ){ |
| | @@ -108828,11 +108844,11 @@ |
| 108828 | 108844 | while( *zCsr!='=' ){ |
| 108829 | 108845 | if( *zCsr=='\0' ) return 0; |
| 108830 | 108846 | zCsr++; |
| 108831 | 108847 | } |
| 108832 | 108848 | |
| 108833 | | - *pnKey = zCsr-z; |
| 108849 | + *pnKey = (int)(zCsr-z); |
| 108834 | 108850 | zValue = sqlite3_mprintf("%s", &zCsr[1]); |
| 108835 | 108851 | if( zValue ){ |
| 108836 | 108852 | sqlite3Fts3Dequote(zValue); |
| 108837 | 108853 | } |
| 108838 | 108854 | *pzValue = zValue; |
| | @@ -108883,11 +108899,11 @@ |
| 108883 | 108899 | nDb = (int)strlen(argv[1]) + 1; |
| 108884 | 108900 | nName = (int)strlen(argv[2]) + 1; |
| 108885 | 108901 | |
| 108886 | 108902 | aCol = (const char **)sqlite3_malloc(sizeof(const char *) * (argc-2) ); |
| 108887 | 108903 | if( !aCol ) return SQLITE_NOMEM; |
| 108888 | | - memset(aCol, 0, sizeof(const char *) * (argc-2)); |
| 108904 | + memset((void *)aCol, 0, sizeof(const char *) * (argc-2)); |
| 108889 | 108905 | |
| 108890 | 108906 | /* Loop through all of the arguments passed by the user to the FTS3/4 |
| 108891 | 108907 | ** module (i.e. all the column names and special arguments). This loop |
| 108892 | 108908 | ** does the following: |
| 108893 | 108909 | ** |
| | @@ -109015,11 +109031,11 @@ |
| 109015 | 109031 | /* Declare the table schema to SQLite. */ |
| 109016 | 109032 | fts3DeclareVtab(&rc, p); |
| 109017 | 109033 | |
| 109018 | 109034 | fts3_init_out: |
| 109019 | 109035 | |
| 109020 | | - sqlite3_free(aCol); |
| 109036 | + sqlite3_free((void *)aCol); |
| 109021 | 109037 | if( rc!=SQLITE_OK ){ |
| 109022 | 109038 | if( p ){ |
| 109023 | 109039 | fts3DisconnectMethod((sqlite3_vtab *)p); |
| 109024 | 109040 | }else if( pTokenizer ){ |
| 109025 | 109041 | pTokenizer->pModule->xDestroy(pTokenizer); |
| | @@ -110371,11 +110387,11 @@ |
| 110371 | 110387 | p += sqlite3Fts3GetVarint(p, &delta); |
| 110372 | 110388 | fts3PoslistCopy(0, &p); |
| 110373 | 110389 | pOut += sqlite3Fts3PutVarint(pOut, delta); |
| 110374 | 110390 | } |
| 110375 | 110391 | |
| 110376 | | - *pnList = (pOut - aList); |
| 110392 | + *pnList = (int)(pOut - aList); |
| 110377 | 110393 | } |
| 110378 | 110394 | } |
| 110379 | 110395 | |
| 110380 | 110396 | /* |
| 110381 | 110397 | ** Return a DocList corresponding to the phrase *pPhrase. |
| | @@ -112464,51 +112480,57 @@ |
| 112464 | 112480 | |
| 112465 | 112481 | return sqlite3_finalize(pStmt); |
| 112466 | 112482 | } |
| 112467 | 112483 | |
| 112468 | 112484 | /* |
| 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(). |
| 112473 | 112493 | */ |
| 112474 | | -static void exprToString(Fts3Expr *pExpr, char *zBuf){ |
| 112494 | +static char *exprToString(Fts3Expr *pExpr, char *zBuf){ |
| 112475 | 112495 | switch( pExpr->eType ){ |
| 112476 | 112496 | case FTSQUERY_PHRASE: { |
| 112477 | 112497 | Fts3Phrase *pPhrase = pExpr->pPhrase; |
| 112478 | 112498 | 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 | + ); |
| 112483 | 112506 | } |
| 112484 | | - return; |
| 112507 | + return zBuf; |
| 112485 | 112508 | } |
| 112486 | 112509 | |
| 112487 | 112510 | case FTSQUERY_NEAR: |
| 112488 | | - zBuf += sprintf(zBuf, "NEAR/%d ", pExpr->nNear); |
| 112511 | + zBuf = sqlite3_mprintf("%zNEAR/%d ", zBuf, pExpr->nNear); |
| 112489 | 112512 | break; |
| 112490 | 112513 | case FTSQUERY_NOT: |
| 112491 | | - zBuf += sprintf(zBuf, "NOT "); |
| 112514 | + zBuf = sqlite3_mprintf("%zNOT ", zBuf); |
| 112492 | 112515 | break; |
| 112493 | 112516 | case FTSQUERY_AND: |
| 112494 | | - zBuf += sprintf(zBuf, "AND "); |
| 112517 | + zBuf = sqlite3_mprintf("%zAND ", zBuf); |
| 112495 | 112518 | break; |
| 112496 | 112519 | case FTSQUERY_OR: |
| 112497 | | - zBuf += sprintf(zBuf, "OR "); |
| 112520 | + zBuf = sqlite3_mprintf("%zOR ", zBuf); |
| 112498 | 112521 | break; |
| 112499 | 112522 | } |
| 112500 | 112523 | |
| 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; |
| 112510 | 112532 | } |
| 112511 | 112533 | |
| 112512 | 112534 | /* |
| 112513 | 112535 | ** This is the implementation of a scalar SQL function used to test the |
| 112514 | 112536 | ** expression parser. It should be called as follows: |
| | @@ -112535,10 +112557,11 @@ |
| 112535 | 112557 | const char *zExpr; |
| 112536 | 112558 | int nExpr; |
| 112537 | 112559 | int nCol; |
| 112538 | 112560 | int ii; |
| 112539 | 112561 | Fts3Expr *pExpr; |
| 112562 | + char *zBuf = 0; |
| 112540 | 112563 | sqlite3 *db = sqlite3_context_db_handle(context); |
| 112541 | 112564 | |
| 112542 | 112565 | if( argc<3 ){ |
| 112543 | 112566 | sqlite3_result_error(context, |
| 112544 | 112567 | "Usage: fts3_exprtest(tokenizer, expr, col1, ...", -1 |
| | @@ -112577,21 +112600,20 @@ |
| 112577 | 112600 | } |
| 112578 | 112601 | |
| 112579 | 112602 | rc = sqlite3Fts3ExprParse( |
| 112580 | 112603 | pTokenizer, azCol, nCol, nCol, zExpr, nExpr, &pExpr |
| 112581 | 112604 | ); |
| 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)) ){ |
| 112583 | 112608 | 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{ |
| 112588 | 112610 | 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); |
| 112592 | 112612 | } |
| 112613 | + |
| 112614 | + sqlite3Fts3ExprFree(pExpr); |
| 112593 | 112615 | |
| 112594 | 112616 | exprtest_out: |
| 112595 | 112617 | if( pModule && pTokenizer ){ |
| 112596 | 112618 | rc = pModule->xDestroy(pTokenizer); |
| 112597 | 112619 | } |
| | @@ -115471,11 +115493,11 @@ |
| 115471 | 115493 | while( a<pEnd ){ |
| 115472 | 115494 | a += sqlite3Fts3GetVarint(a, &nByte); |
| 115473 | 115495 | } |
| 115474 | 115496 | } |
| 115475 | 115497 | |
| 115476 | | - pCsr->nRowAvg = (((nByte / nDoc) + pgsz - 1) / pgsz); |
| 115498 | + pCsr->nRowAvg = (int)(((nByte / nDoc) + pgsz - 1) / pgsz); |
| 115477 | 115499 | } |
| 115478 | 115500 | rc = sqlite3_reset(pStmt); |
| 115479 | 115501 | if( rc!=SQLITE_OK || pCsr->nRowAvg==0 ) return rc; |
| 115480 | 115502 | } |
| 115481 | 115503 | |
| | @@ -118278,16 +118300,16 @@ |
| 118278 | 118300 | pIter->iCol = LCS_ITERATOR_FINISHED; |
| 118279 | 118301 | rc = 1; |
| 118280 | 118302 | }else{ |
| 118281 | 118303 | if( iRead==1 ){ |
| 118282 | 118304 | pRead += sqlite3Fts3GetVarint(pRead, &iRead); |
| 118283 | | - pIter->iCol = iRead; |
| 118305 | + pIter->iCol = (int)iRead; |
| 118284 | 118306 | pIter->iPos = pIter->iPosOffset; |
| 118285 | 118307 | pRead += sqlite3Fts3GetVarint(pRead, &iRead); |
| 118286 | 118308 | rc = 1; |
| 118287 | 118309 | } |
| 118288 | | - pIter->iPos += (iRead-2); |
| 118310 | + pIter->iPos += (int)(iRead-2); |
| 118289 | 118311 | } |
| 118290 | 118312 | |
| 118291 | 118313 | pIter->pRead = pRead; |
| 118292 | 118314 | return rc; |
| 118293 | 118315 | } |
| | @@ -118432,11 +118454,11 @@ |
| 118432 | 118454 | if( rc==SQLITE_OK ){ |
| 118433 | 118455 | int iCol; |
| 118434 | 118456 | for(iCol=0; iCol<pInfo->nCol; iCol++){ |
| 118435 | 118457 | sqlite3_int64 nToken; |
| 118436 | 118458 | 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); |
| 118438 | 118460 | } |
| 118439 | 118461 | } |
| 118440 | 118462 | } |
| 118441 | 118463 | break; |
| 118442 | 118464 | |
| | @@ -118535,11 +118557,11 @@ |
| 118535 | 118557 | for(i=0; zArg[i]; i++){ |
| 118536 | 118558 | nMatchinfo += fts3MatchinfoSize(&sInfo, zArg[i]); |
| 118537 | 118559 | } |
| 118538 | 118560 | |
| 118539 | 118561 | /* Allocate space for Fts3Cursor.aMatchinfo[] and Fts3Cursor.zMatchinfo. */ |
| 118540 | | - nArg = strlen(zArg); |
| 118562 | + nArg = (int)strlen(zArg); |
| 118541 | 118563 | pCsr->aMatchinfo = (u32 *)sqlite3_malloc(sizeof(u32)*nMatchinfo + nArg + 1); |
| 118542 | 118564 | if( !pCsr->aMatchinfo ) return SQLITE_NOMEM; |
| 118543 | 118565 | |
| 118544 | 118566 | pCsr->zMatchinfo = (char *)&pCsr->aMatchinfo[nMatchinfo]; |
| 118545 | 118567 | pCsr->nMatchinfo = nMatchinfo; |
| | @@ -119778,10 +119800,11 @@ |
| 119778 | 119800 | */ |
| 119779 | 119801 | static int testRtreeCell(Rtree *pRtree, RtreeCursor *pCursor, int *pbEof){ |
| 119780 | 119802 | RtreeCell cell; |
| 119781 | 119803 | int ii; |
| 119782 | 119804 | int bRes = 0; |
| 119805 | + int rc = SQLITE_OK; |
| 119783 | 119806 | |
| 119784 | 119807 | nodeGetCell(pRtree, pCursor->pNode, pCursor->iCell, &cell); |
| 119785 | 119808 | for(ii=0; bRes==0 && ii<pCursor->nConstraint; ii++){ |
| 119786 | 119809 | RtreeConstraint *p = &pCursor->aConstraint[ii]; |
| 119787 | 119810 | double cell_min = DCOORD(cell.aCoord[(p->iCoord>>1)*2]); |
| | @@ -119803,24 +119826,20 @@ |
| 119803 | 119826 | case RTREE_EQ: |
| 119804 | 119827 | bRes = (p->rValue>cell_max || p->rValue<cell_min); |
| 119805 | 119828 | break; |
| 119806 | 119829 | |
| 119807 | 119830 | default: { |
| 119808 | | - int rc; |
| 119809 | 119831 | assert( p->op==RTREE_MATCH ); |
| 119810 | 119832 | rc = testRtreeGeom(pRtree, p, &cell, &bRes); |
| 119811 | | - if( rc!=SQLITE_OK ){ |
| 119812 | | - return rc; |
| 119813 | | - } |
| 119814 | 119833 | bRes = !bRes; |
| 119815 | 119834 | break; |
| 119816 | 119835 | } |
| 119817 | 119836 | } |
| 119818 | 119837 | } |
| 119819 | 119838 | |
| 119820 | 119839 | *pbEof = bRes; |
| 119821 | | - return SQLITE_OK; |
| 119840 | + return rc; |
| 119822 | 119841 | } |
| 119823 | 119842 | |
| 119824 | 119843 | /* |
| 119825 | 119844 | ** Test if the cell that cursor pCursor currently points to |
| 119826 | 119845 | ** would be filtered (excluded) by the constraints in the |
| | @@ -119899,28 +119918,27 @@ |
| 119899 | 119918 | rc = testRtreeEntry(pRtree, pCursor, &isEof); |
| 119900 | 119919 | }else{ |
| 119901 | 119920 | rc = testRtreeCell(pRtree, pCursor, &isEof); |
| 119902 | 119921 | } |
| 119903 | 119922 | if( rc!=SQLITE_OK || isEof || iHeight==0 ){ |
| 119904 | | - *pEof = isEof; |
| 119905 | | - return rc; |
| 119923 | + goto descend_to_cell_out; |
| 119906 | 119924 | } |
| 119907 | 119925 | |
| 119908 | 119926 | iRowid = nodeGetRowid(pRtree, pCursor->pNode, pCursor->iCell); |
| 119909 | 119927 | rc = nodeAcquire(pRtree, iRowid, pCursor->pNode, &pChild); |
| 119910 | 119928 | if( rc!=SQLITE_OK ){ |
| 119911 | | - return rc; |
| 119929 | + goto descend_to_cell_out; |
| 119912 | 119930 | } |
| 119913 | 119931 | |
| 119914 | 119932 | nodeRelease(pRtree, pCursor->pNode); |
| 119915 | 119933 | pCursor->pNode = pChild; |
| 119916 | 119934 | isEof = 1; |
| 119917 | 119935 | for(ii=0; isEof && ii<NCELL(pChild); ii++){ |
| 119918 | 119936 | pCursor->iCell = ii; |
| 119919 | 119937 | rc = descendToCell(pRtree, pCursor, iHeight-1, &isEof); |
| 119920 | 119938 | if( rc!=SQLITE_OK ){ |
| 119921 | | - return rc; |
| 119939 | + goto descend_to_cell_out; |
| 119922 | 119940 | } |
| 119923 | 119941 | } |
| 119924 | 119942 | |
| 119925 | 119943 | if( isEof ){ |
| 119926 | 119944 | assert( pCursor->pNode==pChild ); |
| | @@ -119928,12 +119946,13 @@ |
| 119928 | 119946 | nodeRelease(pRtree, pChild); |
| 119929 | 119947 | pCursor->pNode = pSavedNode; |
| 119930 | 119948 | pCursor->iCell = iSavedCell; |
| 119931 | 119949 | } |
| 119932 | 119950 | |
| 119951 | +descend_to_cell_out: |
| 119933 | 119952 | *pEof = isEof; |
| 119934 | | - return SQLITE_OK; |
| 119953 | + return rc; |
| 119935 | 119954 | } |
| 119936 | 119955 | |
| 119937 | 119956 | /* |
| 119938 | 119957 | ** One of the cells in node pNode is guaranteed to have a 64-bit |
| 119939 | 119958 | ** integer value equal to iRowid. Return the index of this cell. |
| 119940 | 119959 | |