Fossil SCM
Bring in the latest SQLite version 3.7.16 beta from upstream for testing.
Commit
d586f2edfc0ffd8784dfb2743d848fe4ba1b76d0
Parent
5f4881d421b84eb…
2 files changed
+70
-39
+1
-1
+70
-39
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -304,10 +304,14 @@ | ||
| 304 | 304 | /* Needed for various definitions... */ |
| 305 | 305 | #ifndef _GNU_SOURCE |
| 306 | 306 | # define _GNU_SOURCE |
| 307 | 307 | #endif |
| 308 | 308 | |
| 309 | +#if defined(__OpenBSD__) && !defined(_BSD_SOURCE) | |
| 310 | +# define _BSD_SOURCE | |
| 311 | +#endif | |
| 312 | + | |
| 309 | 313 | /* |
| 310 | 314 | ** Include standard header files as necessary |
| 311 | 315 | */ |
| 312 | 316 | #ifdef HAVE_STDINT_H |
| 313 | 317 | #include <stdint.h> |
| @@ -674,11 +678,11 @@ | ||
| 674 | 678 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 675 | 679 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 676 | 680 | */ |
| 677 | 681 | #define SQLITE_VERSION "3.7.16" |
| 678 | 682 | #define SQLITE_VERSION_NUMBER 3007016 |
| 679 | -#define SQLITE_SOURCE_ID "2013-03-06 01:55:27 7097241c1220ada318f8eda938c3e3430b94a606" | |
| 683 | +#define SQLITE_SOURCE_ID "2013-03-11 13:37:52 f9027cb47bdec8dcebf1f038921b28d9e9928c18" | |
| 680 | 684 | |
| 681 | 685 | /* |
| 682 | 686 | ** CAPI3REF: Run-Time Library Version Numbers |
| 683 | 687 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 684 | 688 | ** |
| @@ -48402,10 +48406,29 @@ | ||
| 48402 | 48406 | ** is empty, the offset should be 65536, but the 2-byte value stores zero. |
| 48403 | 48407 | ** This routine makes the necessary adjustment to 65536. |
| 48404 | 48408 | */ |
| 48405 | 48409 | #define get2byteNotZero(X) (((((int)get2byte(X))-1)&0xffff)+1) |
| 48406 | 48410 | |
| 48411 | +/* | |
| 48412 | +** Values passed as the 5th argument to allocateBtreePage() | |
| 48413 | +*/ | |
| 48414 | +#define BTALLOC_ANY 0 /* Allocate any page */ | |
| 48415 | +#define BTALLOC_EXACT 1 /* Allocate exact page if possible */ | |
| 48416 | +#define BTALLOC_LE 2 /* Allocate any page <= the parameter */ | |
| 48417 | + | |
| 48418 | +/* | |
| 48419 | +** Macro IfNotOmitAV(x) returns (x) if SQLITE_OMIT_AUTOVACUUM is not | |
| 48420 | +** defined, or 0 if it is. For example: | |
| 48421 | +** | |
| 48422 | +** bIncrVacuum = IfNotOmitAV(pBtShared->incrVacuum); | |
| 48423 | +*/ | |
| 48424 | +#ifndef SQLITE_OMIT_AUTOVACUUM | |
| 48425 | +#define IfNotOmitAV(expr) (expr) | |
| 48426 | +#else | |
| 48427 | +#define IfNotOmitAV(expr) 0 | |
| 48428 | +#endif | |
| 48429 | + | |
| 48407 | 48430 | #ifndef SQLITE_OMIT_SHARED_CACHE |
| 48408 | 48431 | /* |
| 48409 | 48432 | ** A list of BtShared objects that are eligible for participation |
| 48410 | 48433 | ** in shared cache. This variable has file scope during normal builds, |
| 48411 | 48434 | ** but the test harness needs to access it so we make it global for |
| @@ -50954,11 +50977,11 @@ | ||
| 50954 | 50977 | ** is requested, this is a no-op. |
| 50955 | 50978 | */ |
| 50956 | 50979 | if( p->inTrans==TRANS_WRITE || (p->inTrans==TRANS_READ && !wrflag) ){ |
| 50957 | 50980 | goto trans_begun; |
| 50958 | 50981 | } |
| 50959 | - assert( pBt->bDoTruncate==0 ); | |
| 50982 | + assert( IfNotOmitAV(pBt->bDoTruncate)==0 ); | |
| 50960 | 50983 | |
| 50961 | 50984 | /* Write transactions are not possible on a read-only database */ |
| 50962 | 50985 | if( (pBt->btsFlags & BTS_READ_ONLY)!=0 && wrflag ){ |
| 50963 | 50986 | rc = SQLITE_READONLY; |
| 50964 | 50987 | goto trans_begun; |
| @@ -51269,13 +51292,10 @@ | ||
| 51269 | 51292 | return rc; |
| 51270 | 51293 | } |
| 51271 | 51294 | |
| 51272 | 51295 | /* Forward declaration required by incrVacuumStep(). */ |
| 51273 | 51296 | static int allocateBtreePage(BtShared *, MemPage **, Pgno *, Pgno, u8); |
| 51274 | -#define BTALLOC_ANY 0 /* Allocate any page */ | |
| 51275 | -#define BTALLOC_EXACT 1 /* Allocate exact page if possible */ | |
| 51276 | -#define BTALLOC_LE 2 /* Allocate any page <= the parameter */ | |
| 51277 | 51297 | |
| 51278 | 51298 | /* |
| 51279 | 51299 | ** Perform a single step of an incremental-vacuum. If successful, return |
| 51280 | 51300 | ** SQLITE_OK. If there is no work to do (and therefore no point in |
| 51281 | 51301 | ** calling this function again), return SQLITE_DONE. Or, if an error |
| @@ -53261,11 +53281,11 @@ | ||
| 53261 | 53281 | MemPage *pTrunk = 0; |
| 53262 | 53282 | MemPage *pPrevTrunk = 0; |
| 53263 | 53283 | Pgno mxPage; /* Total size of the database file */ |
| 53264 | 53284 | |
| 53265 | 53285 | assert( sqlite3_mutex_held(pBt->mutex) ); |
| 53266 | - assert( eMode==BTALLOC_ANY || (nearby>0 && pBt->autoVacuum) ); | |
| 53286 | + assert( eMode==BTALLOC_ANY || (nearby>0 && IfNotOmitAV(pBt->autoVacuum)) ); | |
| 53267 | 53287 | pPage1 = pBt->pPage1; |
| 53268 | 53288 | mxPage = btreePagecount(pBt); |
| 53269 | 53289 | n = get4byte(&pPage1->aData[36]); |
| 53270 | 53290 | testcase( n==mxPage-1 ); |
| 53271 | 53291 | if( n>=mxPage ){ |
| @@ -53494,11 +53514,11 @@ | ||
| 53494 | 53514 | ** content for any page that really does lie past the end of the database |
| 53495 | 53515 | ** file on disk. So the effects of disabling the no-content optimization |
| 53496 | 53516 | ** here are confined to those pages that lie between the end of the |
| 53497 | 53517 | ** database image and the end of the database file. |
| 53498 | 53518 | */ |
| 53499 | - int bNoContent = (0==pBt->bDoTruncate); | |
| 53519 | + int bNoContent = (0==IfNotOmitAV(pBt->bDoTruncate)); | |
| 53500 | 53520 | |
| 53501 | 53521 | rc = sqlite3PagerWrite(pBt->pPage1->pDbPage); |
| 53502 | 53522 | if( rc ) return rc; |
| 53503 | 53523 | pBt->nPage++; |
| 53504 | 53524 | if( pBt->nPage==PENDING_BYTE_PAGE(pBt) ) pBt->nPage++; |
| @@ -57554,11 +57574,13 @@ | ||
| 57554 | 57574 | ** SQLITE_OK is returned if the conversion is successful (or not required). |
| 57555 | 57575 | ** SQLITE_NOMEM may be returned if a malloc() fails during conversion |
| 57556 | 57576 | ** between formats. |
| 57557 | 57577 | */ |
| 57558 | 57578 | SQLITE_PRIVATE int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){ |
| 57579 | +#ifndef SQLITE_OMIT_UTF16 | |
| 57559 | 57580 | int rc; |
| 57581 | +#endif | |
| 57560 | 57582 | assert( (pMem->flags&MEM_RowSet)==0 ); |
| 57561 | 57583 | assert( desiredEnc==SQLITE_UTF8 || desiredEnc==SQLITE_UTF16LE |
| 57562 | 57584 | || desiredEnc==SQLITE_UTF16BE ); |
| 57563 | 57585 | if( !(pMem->flags&MEM_Str) || pMem->enc==desiredEnc ){ |
| 57564 | 57586 | return SQLITE_OK; |
| @@ -85357,34 +85379,32 @@ | ||
| 85357 | 85379 | Table *pView, /* View definition */ |
| 85358 | 85380 | Expr *pWhere, /* Optional WHERE clause to be added */ |
| 85359 | 85381 | int iCur /* Cursor number for ephemerial table */ |
| 85360 | 85382 | ){ |
| 85361 | 85383 | SelectDest dest; |
| 85362 | - Select *pDup; | |
| 85384 | + Select *pSel; | |
| 85385 | + SrcList *pFrom; | |
| 85363 | 85386 | sqlite3 *db = pParse->db; |
| 85364 | - | |
| 85365 | - pDup = sqlite3SelectDup(db, pView->pSelect, 0); | |
| 85366 | - if( pWhere ){ | |
| 85367 | - SrcList *pFrom; | |
| 85368 | - | |
| 85369 | - pWhere = sqlite3ExprDup(db, pWhere, 0); | |
| 85370 | - pFrom = sqlite3SrcListAppend(db, 0, 0, 0); | |
| 85371 | - if( pFrom ){ | |
| 85372 | - assert( pFrom->nSrc==1 ); | |
| 85373 | - pFrom->a[0].zAlias = sqlite3DbStrDup(db, pView->zName); | |
| 85374 | - pFrom->a[0].pSelect = pDup; | |
| 85375 | - assert( pFrom->a[0].pOn==0 ); | |
| 85376 | - assert( pFrom->a[0].pUsing==0 ); | |
| 85377 | - }else{ | |
| 85378 | - sqlite3SelectDelete(db, pDup); | |
| 85379 | - } | |
| 85380 | - pDup = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, 0, 0, 0); | |
| 85381 | - if( pDup ) pDup->selFlags |= SF_Materialize; | |
| 85382 | - } | |
| 85387 | + int iDb = sqlite3SchemaToIndex(db, pView->pSchema); | |
| 85388 | + | |
| 85389 | + pWhere = sqlite3ExprDup(db, pWhere, 0); | |
| 85390 | + pFrom = sqlite3SrcListAppend(db, 0, 0, 0); | |
| 85391 | + | |
| 85392 | + if( pFrom ){ | |
| 85393 | + assert( pFrom->nSrc==1 ); | |
| 85394 | + pFrom->a[0].zName = sqlite3DbStrDup(db, pView->zName); | |
| 85395 | + pFrom->a[0].zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zName); | |
| 85396 | + assert( pFrom->a[0].pOn==0 ); | |
| 85397 | + assert( pFrom->a[0].pUsing==0 ); | |
| 85398 | + } | |
| 85399 | + | |
| 85400 | + pSel = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, 0, 0, 0); | |
| 85401 | + if( pSel ) pSel->selFlags |= SF_Materialize; | |
| 85402 | + | |
| 85383 | 85403 | sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur); |
| 85384 | - sqlite3Select(pParse, pDup, &dest); | |
| 85385 | - sqlite3SelectDelete(db, pDup); | |
| 85404 | + sqlite3Select(pParse, pSel, &dest); | |
| 85405 | + sqlite3SelectDelete(db, pSel); | |
| 85386 | 85406 | } |
| 85387 | 85407 | #endif /* !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER) */ |
| 85388 | 85408 | |
| 85389 | 85409 | #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) |
| 85390 | 85410 | /* |
| @@ -86918,22 +86938,27 @@ | ||
| 86918 | 86938 | sqlite3_int64 x; |
| 86919 | 86939 | unsigned c; |
| 86920 | 86940 | x = sqlite3_value_int64(argv[i]); |
| 86921 | 86941 | if( x<0 || x>0x10ffff ) x = 0xfffd; |
| 86922 | 86942 | c = (unsigned)(x & 0x1fffff); |
| 86923 | - if( c<=0xFFFF ){ | |
| 86924 | - if( c>=0xd800 && c<=0xdfff ) c = 0xfffd; | |
| 86925 | - *zOut++ = (u8)(c&0x00FF); | |
| 86926 | - *zOut++ = (u8)((c>>8)&0x00FF); | |
| 86943 | + if( c<0x00080 ){ | |
| 86944 | + *zOut++ = (u8)(c&0xFF); | |
| 86945 | + }else if( c<0x00800 ){ | |
| 86946 | + *zOut++ = 0xC0 + (u8)((c>>6)&0x1F); | |
| 86947 | + *zOut++ = 0x80 + (u8)(c & 0x3F); | |
| 86948 | + }else if( c<0x10000 ){ | |
| 86949 | + *zOut++ = 0xE0 + (u8)((c>>12)&0x0F); | |
| 86950 | + *zOut++ = 0x80 + (u8)((c>>6) & 0x3F); | |
| 86951 | + *zOut++ = 0x80 + (u8)(c & 0x3F); | |
| 86927 | 86952 | }else{ |
| 86928 | - *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0)); | |
| 86929 | - *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03)); | |
| 86930 | - *zOut++ = (u8)(c&0x00FF); | |
| 86931 | - *zOut++ = (u8)(0x00DC + ((c>>8)&0x03)); | |
| 86932 | - } | |
| 86953 | + *zOut++ = 0xF0 + (u8)((c>>18) & 0x07); | |
| 86954 | + *zOut++ = 0x80 + (u8)((c>>12) & 0x3F); | |
| 86955 | + *zOut++ = 0x80 + (u8)((c>>6) & 0x3F); | |
| 86956 | + *zOut++ = 0x80 + (u8)(c & 0x3F); | |
| 86957 | + } \ | |
| 86933 | 86958 | } |
| 86934 | - sqlite3_result_text16le(context, (char*)z, (int)(zOut-z), sqlite3_free); | |
| 86959 | + sqlite3_result_text(context, (char*)z, (int)(zOut-z), sqlite3_free); | |
| 86935 | 86960 | } |
| 86936 | 86961 | |
| 86937 | 86962 | /* |
| 86938 | 86963 | ** The hex() function. Interpret the argument as a blob. Return |
| 86939 | 86964 | ** a hexadecimal rendering as text. |
| @@ -93197,10 +93222,11 @@ | ||
| 93197 | 93222 | } |
| 93198 | 93223 | }else |
| 93199 | 93224 | #endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */ |
| 93200 | 93225 | |
| 93201 | 93226 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 93227 | +#ifndef SQLITE_OMIT_TRIGGER | |
| 93202 | 93228 | if( sqlite3StrICmp(zLeft, "foreign_key_check")==0 ){ |
| 93203 | 93229 | FKey *pFK; /* A foreign key constraint */ |
| 93204 | 93230 | Table *pTab; /* Child table contain "REFERENCES" keyword */ |
| 93205 | 93231 | Table *pParent; /* Parent table that child points to */ |
| 93206 | 93232 | Index *pIdx; /* Index in the parent table */ |
| @@ -93308,10 +93334,11 @@ | ||
| 93308 | 93334 | } |
| 93309 | 93335 | sqlite3VdbeAddOp2(v, OP_Next, 0, addrTop+1); |
| 93310 | 93336 | sqlite3VdbeJumpHere(v, addrTop); |
| 93311 | 93337 | } |
| 93312 | 93338 | }else |
| 93339 | +#endif /* !defined(SQLITE_OMIT_TRIGGER) */ | |
| 93313 | 93340 | #endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */ |
| 93314 | 93341 | |
| 93315 | 93342 | #ifndef NDEBUG |
| 93316 | 93343 | if( sqlite3StrICmp(zLeft, "parser_trace")==0 ){ |
| 93317 | 93344 | if( zRight ){ |
| @@ -94104,15 +94131,19 @@ | ||
| 94104 | 94131 | ** For an attached db, it is an error if the encoding is not the same |
| 94105 | 94132 | ** as sqlite3.enc. |
| 94106 | 94133 | */ |
| 94107 | 94134 | if( meta[BTREE_TEXT_ENCODING-1] ){ /* text encoding */ |
| 94108 | 94135 | if( iDb==0 ){ |
| 94136 | +#ifndef SQLITE_OMIT_UTF16 | |
| 94109 | 94137 | u8 encoding; |
| 94110 | 94138 | /* If opening the main database, set ENC(db). */ |
| 94111 | 94139 | encoding = (u8)meta[BTREE_TEXT_ENCODING-1] & 3; |
| 94112 | 94140 | if( encoding==0 ) encoding = SQLITE_UTF8; |
| 94113 | 94141 | ENC(db) = encoding; |
| 94142 | +#else | |
| 94143 | + ENC(db) = SQLITE_UTF8; | |
| 94144 | +#endif | |
| 94114 | 94145 | }else{ |
| 94115 | 94146 | /* If opening an attached database, the encoding much match ENC(db) */ |
| 94116 | 94147 | if( meta[BTREE_TEXT_ENCODING-1]!=ENC(db) ){ |
| 94117 | 94148 | sqlite3SetString(pzErrMsg, db, "attached databases must use the same" |
| 94118 | 94149 | " text encoding as main database"); |
| 94119 | 94150 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -304,10 +304,14 @@ | |
| 304 | /* Needed for various definitions... */ |
| 305 | #ifndef _GNU_SOURCE |
| 306 | # define _GNU_SOURCE |
| 307 | #endif |
| 308 | |
| 309 | /* |
| 310 | ** Include standard header files as necessary |
| 311 | */ |
| 312 | #ifdef HAVE_STDINT_H |
| 313 | #include <stdint.h> |
| @@ -674,11 +678,11 @@ | |
| 674 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 675 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 676 | */ |
| 677 | #define SQLITE_VERSION "3.7.16" |
| 678 | #define SQLITE_VERSION_NUMBER 3007016 |
| 679 | #define SQLITE_SOURCE_ID "2013-03-06 01:55:27 7097241c1220ada318f8eda938c3e3430b94a606" |
| 680 | |
| 681 | /* |
| 682 | ** CAPI3REF: Run-Time Library Version Numbers |
| 683 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 684 | ** |
| @@ -48402,10 +48406,29 @@ | |
| 48402 | ** is empty, the offset should be 65536, but the 2-byte value stores zero. |
| 48403 | ** This routine makes the necessary adjustment to 65536. |
| 48404 | */ |
| 48405 | #define get2byteNotZero(X) (((((int)get2byte(X))-1)&0xffff)+1) |
| 48406 | |
| 48407 | #ifndef SQLITE_OMIT_SHARED_CACHE |
| 48408 | /* |
| 48409 | ** A list of BtShared objects that are eligible for participation |
| 48410 | ** in shared cache. This variable has file scope during normal builds, |
| 48411 | ** but the test harness needs to access it so we make it global for |
| @@ -50954,11 +50977,11 @@ | |
| 50954 | ** is requested, this is a no-op. |
| 50955 | */ |
| 50956 | if( p->inTrans==TRANS_WRITE || (p->inTrans==TRANS_READ && !wrflag) ){ |
| 50957 | goto trans_begun; |
| 50958 | } |
| 50959 | assert( pBt->bDoTruncate==0 ); |
| 50960 | |
| 50961 | /* Write transactions are not possible on a read-only database */ |
| 50962 | if( (pBt->btsFlags & BTS_READ_ONLY)!=0 && wrflag ){ |
| 50963 | rc = SQLITE_READONLY; |
| 50964 | goto trans_begun; |
| @@ -51269,13 +51292,10 @@ | |
| 51269 | return rc; |
| 51270 | } |
| 51271 | |
| 51272 | /* Forward declaration required by incrVacuumStep(). */ |
| 51273 | static int allocateBtreePage(BtShared *, MemPage **, Pgno *, Pgno, u8); |
| 51274 | #define BTALLOC_ANY 0 /* Allocate any page */ |
| 51275 | #define BTALLOC_EXACT 1 /* Allocate exact page if possible */ |
| 51276 | #define BTALLOC_LE 2 /* Allocate any page <= the parameter */ |
| 51277 | |
| 51278 | /* |
| 51279 | ** Perform a single step of an incremental-vacuum. If successful, return |
| 51280 | ** SQLITE_OK. If there is no work to do (and therefore no point in |
| 51281 | ** calling this function again), return SQLITE_DONE. Or, if an error |
| @@ -53261,11 +53281,11 @@ | |
| 53261 | MemPage *pTrunk = 0; |
| 53262 | MemPage *pPrevTrunk = 0; |
| 53263 | Pgno mxPage; /* Total size of the database file */ |
| 53264 | |
| 53265 | assert( sqlite3_mutex_held(pBt->mutex) ); |
| 53266 | assert( eMode==BTALLOC_ANY || (nearby>0 && pBt->autoVacuum) ); |
| 53267 | pPage1 = pBt->pPage1; |
| 53268 | mxPage = btreePagecount(pBt); |
| 53269 | n = get4byte(&pPage1->aData[36]); |
| 53270 | testcase( n==mxPage-1 ); |
| 53271 | if( n>=mxPage ){ |
| @@ -53494,11 +53514,11 @@ | |
| 53494 | ** content for any page that really does lie past the end of the database |
| 53495 | ** file on disk. So the effects of disabling the no-content optimization |
| 53496 | ** here are confined to those pages that lie between the end of the |
| 53497 | ** database image and the end of the database file. |
| 53498 | */ |
| 53499 | int bNoContent = (0==pBt->bDoTruncate); |
| 53500 | |
| 53501 | rc = sqlite3PagerWrite(pBt->pPage1->pDbPage); |
| 53502 | if( rc ) return rc; |
| 53503 | pBt->nPage++; |
| 53504 | if( pBt->nPage==PENDING_BYTE_PAGE(pBt) ) pBt->nPage++; |
| @@ -57554,11 +57574,13 @@ | |
| 57554 | ** SQLITE_OK is returned if the conversion is successful (or not required). |
| 57555 | ** SQLITE_NOMEM may be returned if a malloc() fails during conversion |
| 57556 | ** between formats. |
| 57557 | */ |
| 57558 | SQLITE_PRIVATE int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){ |
| 57559 | int rc; |
| 57560 | assert( (pMem->flags&MEM_RowSet)==0 ); |
| 57561 | assert( desiredEnc==SQLITE_UTF8 || desiredEnc==SQLITE_UTF16LE |
| 57562 | || desiredEnc==SQLITE_UTF16BE ); |
| 57563 | if( !(pMem->flags&MEM_Str) || pMem->enc==desiredEnc ){ |
| 57564 | return SQLITE_OK; |
| @@ -85357,34 +85379,32 @@ | |
| 85357 | Table *pView, /* View definition */ |
| 85358 | Expr *pWhere, /* Optional WHERE clause to be added */ |
| 85359 | int iCur /* Cursor number for ephemerial table */ |
| 85360 | ){ |
| 85361 | SelectDest dest; |
| 85362 | Select *pDup; |
| 85363 | sqlite3 *db = pParse->db; |
| 85364 | |
| 85365 | pDup = sqlite3SelectDup(db, pView->pSelect, 0); |
| 85366 | if( pWhere ){ |
| 85367 | SrcList *pFrom; |
| 85368 | |
| 85369 | pWhere = sqlite3ExprDup(db, pWhere, 0); |
| 85370 | pFrom = sqlite3SrcListAppend(db, 0, 0, 0); |
| 85371 | if( pFrom ){ |
| 85372 | assert( pFrom->nSrc==1 ); |
| 85373 | pFrom->a[0].zAlias = sqlite3DbStrDup(db, pView->zName); |
| 85374 | pFrom->a[0].pSelect = pDup; |
| 85375 | assert( pFrom->a[0].pOn==0 ); |
| 85376 | assert( pFrom->a[0].pUsing==0 ); |
| 85377 | }else{ |
| 85378 | sqlite3SelectDelete(db, pDup); |
| 85379 | } |
| 85380 | pDup = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, 0, 0, 0); |
| 85381 | if( pDup ) pDup->selFlags |= SF_Materialize; |
| 85382 | } |
| 85383 | sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur); |
| 85384 | sqlite3Select(pParse, pDup, &dest); |
| 85385 | sqlite3SelectDelete(db, pDup); |
| 85386 | } |
| 85387 | #endif /* !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER) */ |
| 85388 | |
| 85389 | #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) |
| 85390 | /* |
| @@ -86918,22 +86938,27 @@ | |
| 86918 | sqlite3_int64 x; |
| 86919 | unsigned c; |
| 86920 | x = sqlite3_value_int64(argv[i]); |
| 86921 | if( x<0 || x>0x10ffff ) x = 0xfffd; |
| 86922 | c = (unsigned)(x & 0x1fffff); |
| 86923 | if( c<=0xFFFF ){ |
| 86924 | if( c>=0xd800 && c<=0xdfff ) c = 0xfffd; |
| 86925 | *zOut++ = (u8)(c&0x00FF); |
| 86926 | *zOut++ = (u8)((c>>8)&0x00FF); |
| 86927 | }else{ |
| 86928 | *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0)); |
| 86929 | *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03)); |
| 86930 | *zOut++ = (u8)(c&0x00FF); |
| 86931 | *zOut++ = (u8)(0x00DC + ((c>>8)&0x03)); |
| 86932 | } |
| 86933 | } |
| 86934 | sqlite3_result_text16le(context, (char*)z, (int)(zOut-z), sqlite3_free); |
| 86935 | } |
| 86936 | |
| 86937 | /* |
| 86938 | ** The hex() function. Interpret the argument as a blob. Return |
| 86939 | ** a hexadecimal rendering as text. |
| @@ -93197,10 +93222,11 @@ | |
| 93197 | } |
| 93198 | }else |
| 93199 | #endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */ |
| 93200 | |
| 93201 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 93202 | if( sqlite3StrICmp(zLeft, "foreign_key_check")==0 ){ |
| 93203 | FKey *pFK; /* A foreign key constraint */ |
| 93204 | Table *pTab; /* Child table contain "REFERENCES" keyword */ |
| 93205 | Table *pParent; /* Parent table that child points to */ |
| 93206 | Index *pIdx; /* Index in the parent table */ |
| @@ -93308,10 +93334,11 @@ | |
| 93308 | } |
| 93309 | sqlite3VdbeAddOp2(v, OP_Next, 0, addrTop+1); |
| 93310 | sqlite3VdbeJumpHere(v, addrTop); |
| 93311 | } |
| 93312 | }else |
| 93313 | #endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */ |
| 93314 | |
| 93315 | #ifndef NDEBUG |
| 93316 | if( sqlite3StrICmp(zLeft, "parser_trace")==0 ){ |
| 93317 | if( zRight ){ |
| @@ -94104,15 +94131,19 @@ | |
| 94104 | ** For an attached db, it is an error if the encoding is not the same |
| 94105 | ** as sqlite3.enc. |
| 94106 | */ |
| 94107 | if( meta[BTREE_TEXT_ENCODING-1] ){ /* text encoding */ |
| 94108 | if( iDb==0 ){ |
| 94109 | u8 encoding; |
| 94110 | /* If opening the main database, set ENC(db). */ |
| 94111 | encoding = (u8)meta[BTREE_TEXT_ENCODING-1] & 3; |
| 94112 | if( encoding==0 ) encoding = SQLITE_UTF8; |
| 94113 | ENC(db) = encoding; |
| 94114 | }else{ |
| 94115 | /* If opening an attached database, the encoding much match ENC(db) */ |
| 94116 | if( meta[BTREE_TEXT_ENCODING-1]!=ENC(db) ){ |
| 94117 | sqlite3SetString(pzErrMsg, db, "attached databases must use the same" |
| 94118 | " text encoding as main database"); |
| 94119 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -304,10 +304,14 @@ | |
| 304 | /* Needed for various definitions... */ |
| 305 | #ifndef _GNU_SOURCE |
| 306 | # define _GNU_SOURCE |
| 307 | #endif |
| 308 | |
| 309 | #if defined(__OpenBSD__) && !defined(_BSD_SOURCE) |
| 310 | # define _BSD_SOURCE |
| 311 | #endif |
| 312 | |
| 313 | /* |
| 314 | ** Include standard header files as necessary |
| 315 | */ |
| 316 | #ifdef HAVE_STDINT_H |
| 317 | #include <stdint.h> |
| @@ -674,11 +678,11 @@ | |
| 678 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 679 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 680 | */ |
| 681 | #define SQLITE_VERSION "3.7.16" |
| 682 | #define SQLITE_VERSION_NUMBER 3007016 |
| 683 | #define SQLITE_SOURCE_ID "2013-03-11 13:37:52 f9027cb47bdec8dcebf1f038921b28d9e9928c18" |
| 684 | |
| 685 | /* |
| 686 | ** CAPI3REF: Run-Time Library Version Numbers |
| 687 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 688 | ** |
| @@ -48402,10 +48406,29 @@ | |
| 48406 | ** is empty, the offset should be 65536, but the 2-byte value stores zero. |
| 48407 | ** This routine makes the necessary adjustment to 65536. |
| 48408 | */ |
| 48409 | #define get2byteNotZero(X) (((((int)get2byte(X))-1)&0xffff)+1) |
| 48410 | |
| 48411 | /* |
| 48412 | ** Values passed as the 5th argument to allocateBtreePage() |
| 48413 | */ |
| 48414 | #define BTALLOC_ANY 0 /* Allocate any page */ |
| 48415 | #define BTALLOC_EXACT 1 /* Allocate exact page if possible */ |
| 48416 | #define BTALLOC_LE 2 /* Allocate any page <= the parameter */ |
| 48417 | |
| 48418 | /* |
| 48419 | ** Macro IfNotOmitAV(x) returns (x) if SQLITE_OMIT_AUTOVACUUM is not |
| 48420 | ** defined, or 0 if it is. For example: |
| 48421 | ** |
| 48422 | ** bIncrVacuum = IfNotOmitAV(pBtShared->incrVacuum); |
| 48423 | */ |
| 48424 | #ifndef SQLITE_OMIT_AUTOVACUUM |
| 48425 | #define IfNotOmitAV(expr) (expr) |
| 48426 | #else |
| 48427 | #define IfNotOmitAV(expr) 0 |
| 48428 | #endif |
| 48429 | |
| 48430 | #ifndef SQLITE_OMIT_SHARED_CACHE |
| 48431 | /* |
| 48432 | ** A list of BtShared objects that are eligible for participation |
| 48433 | ** in shared cache. This variable has file scope during normal builds, |
| 48434 | ** but the test harness needs to access it so we make it global for |
| @@ -50954,11 +50977,11 @@ | |
| 50977 | ** is requested, this is a no-op. |
| 50978 | */ |
| 50979 | if( p->inTrans==TRANS_WRITE || (p->inTrans==TRANS_READ && !wrflag) ){ |
| 50980 | goto trans_begun; |
| 50981 | } |
| 50982 | assert( IfNotOmitAV(pBt->bDoTruncate)==0 ); |
| 50983 | |
| 50984 | /* Write transactions are not possible on a read-only database */ |
| 50985 | if( (pBt->btsFlags & BTS_READ_ONLY)!=0 && wrflag ){ |
| 50986 | rc = SQLITE_READONLY; |
| 50987 | goto trans_begun; |
| @@ -51269,13 +51292,10 @@ | |
| 51292 | return rc; |
| 51293 | } |
| 51294 | |
| 51295 | /* Forward declaration required by incrVacuumStep(). */ |
| 51296 | static int allocateBtreePage(BtShared *, MemPage **, Pgno *, Pgno, u8); |
| 51297 | |
| 51298 | /* |
| 51299 | ** Perform a single step of an incremental-vacuum. If successful, return |
| 51300 | ** SQLITE_OK. If there is no work to do (and therefore no point in |
| 51301 | ** calling this function again), return SQLITE_DONE. Or, if an error |
| @@ -53261,11 +53281,11 @@ | |
| 53281 | MemPage *pTrunk = 0; |
| 53282 | MemPage *pPrevTrunk = 0; |
| 53283 | Pgno mxPage; /* Total size of the database file */ |
| 53284 | |
| 53285 | assert( sqlite3_mutex_held(pBt->mutex) ); |
| 53286 | assert( eMode==BTALLOC_ANY || (nearby>0 && IfNotOmitAV(pBt->autoVacuum)) ); |
| 53287 | pPage1 = pBt->pPage1; |
| 53288 | mxPage = btreePagecount(pBt); |
| 53289 | n = get4byte(&pPage1->aData[36]); |
| 53290 | testcase( n==mxPage-1 ); |
| 53291 | if( n>=mxPage ){ |
| @@ -53494,11 +53514,11 @@ | |
| 53514 | ** content for any page that really does lie past the end of the database |
| 53515 | ** file on disk. So the effects of disabling the no-content optimization |
| 53516 | ** here are confined to those pages that lie between the end of the |
| 53517 | ** database image and the end of the database file. |
| 53518 | */ |
| 53519 | int bNoContent = (0==IfNotOmitAV(pBt->bDoTruncate)); |
| 53520 | |
| 53521 | rc = sqlite3PagerWrite(pBt->pPage1->pDbPage); |
| 53522 | if( rc ) return rc; |
| 53523 | pBt->nPage++; |
| 53524 | if( pBt->nPage==PENDING_BYTE_PAGE(pBt) ) pBt->nPage++; |
| @@ -57554,11 +57574,13 @@ | |
| 57574 | ** SQLITE_OK is returned if the conversion is successful (or not required). |
| 57575 | ** SQLITE_NOMEM may be returned if a malloc() fails during conversion |
| 57576 | ** between formats. |
| 57577 | */ |
| 57578 | SQLITE_PRIVATE int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){ |
| 57579 | #ifndef SQLITE_OMIT_UTF16 |
| 57580 | int rc; |
| 57581 | #endif |
| 57582 | assert( (pMem->flags&MEM_RowSet)==0 ); |
| 57583 | assert( desiredEnc==SQLITE_UTF8 || desiredEnc==SQLITE_UTF16LE |
| 57584 | || desiredEnc==SQLITE_UTF16BE ); |
| 57585 | if( !(pMem->flags&MEM_Str) || pMem->enc==desiredEnc ){ |
| 57586 | return SQLITE_OK; |
| @@ -85357,34 +85379,32 @@ | |
| 85379 | Table *pView, /* View definition */ |
| 85380 | Expr *pWhere, /* Optional WHERE clause to be added */ |
| 85381 | int iCur /* Cursor number for ephemerial table */ |
| 85382 | ){ |
| 85383 | SelectDest dest; |
| 85384 | Select *pSel; |
| 85385 | SrcList *pFrom; |
| 85386 | sqlite3 *db = pParse->db; |
| 85387 | int iDb = sqlite3SchemaToIndex(db, pView->pSchema); |
| 85388 | |
| 85389 | pWhere = sqlite3ExprDup(db, pWhere, 0); |
| 85390 | pFrom = sqlite3SrcListAppend(db, 0, 0, 0); |
| 85391 | |
| 85392 | if( pFrom ){ |
| 85393 | assert( pFrom->nSrc==1 ); |
| 85394 | pFrom->a[0].zName = sqlite3DbStrDup(db, pView->zName); |
| 85395 | pFrom->a[0].zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zName); |
| 85396 | assert( pFrom->a[0].pOn==0 ); |
| 85397 | assert( pFrom->a[0].pUsing==0 ); |
| 85398 | } |
| 85399 | |
| 85400 | pSel = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, 0, 0, 0); |
| 85401 | if( pSel ) pSel->selFlags |= SF_Materialize; |
| 85402 | |
| 85403 | sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur); |
| 85404 | sqlite3Select(pParse, pSel, &dest); |
| 85405 | sqlite3SelectDelete(db, pSel); |
| 85406 | } |
| 85407 | #endif /* !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER) */ |
| 85408 | |
| 85409 | #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) |
| 85410 | /* |
| @@ -86918,22 +86938,27 @@ | |
| 86938 | sqlite3_int64 x; |
| 86939 | unsigned c; |
| 86940 | x = sqlite3_value_int64(argv[i]); |
| 86941 | if( x<0 || x>0x10ffff ) x = 0xfffd; |
| 86942 | c = (unsigned)(x & 0x1fffff); |
| 86943 | if( c<0x00080 ){ |
| 86944 | *zOut++ = (u8)(c&0xFF); |
| 86945 | }else if( c<0x00800 ){ |
| 86946 | *zOut++ = 0xC0 + (u8)((c>>6)&0x1F); |
| 86947 | *zOut++ = 0x80 + (u8)(c & 0x3F); |
| 86948 | }else if( c<0x10000 ){ |
| 86949 | *zOut++ = 0xE0 + (u8)((c>>12)&0x0F); |
| 86950 | *zOut++ = 0x80 + (u8)((c>>6) & 0x3F); |
| 86951 | *zOut++ = 0x80 + (u8)(c & 0x3F); |
| 86952 | }else{ |
| 86953 | *zOut++ = 0xF0 + (u8)((c>>18) & 0x07); |
| 86954 | *zOut++ = 0x80 + (u8)((c>>12) & 0x3F); |
| 86955 | *zOut++ = 0x80 + (u8)((c>>6) & 0x3F); |
| 86956 | *zOut++ = 0x80 + (u8)(c & 0x3F); |
| 86957 | } \ |
| 86958 | } |
| 86959 | sqlite3_result_text(context, (char*)z, (int)(zOut-z), sqlite3_free); |
| 86960 | } |
| 86961 | |
| 86962 | /* |
| 86963 | ** The hex() function. Interpret the argument as a blob. Return |
| 86964 | ** a hexadecimal rendering as text. |
| @@ -93197,10 +93222,11 @@ | |
| 93222 | } |
| 93223 | }else |
| 93224 | #endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */ |
| 93225 | |
| 93226 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 93227 | #ifndef SQLITE_OMIT_TRIGGER |
| 93228 | if( sqlite3StrICmp(zLeft, "foreign_key_check")==0 ){ |
| 93229 | FKey *pFK; /* A foreign key constraint */ |
| 93230 | Table *pTab; /* Child table contain "REFERENCES" keyword */ |
| 93231 | Table *pParent; /* Parent table that child points to */ |
| 93232 | Index *pIdx; /* Index in the parent table */ |
| @@ -93308,10 +93334,11 @@ | |
| 93334 | } |
| 93335 | sqlite3VdbeAddOp2(v, OP_Next, 0, addrTop+1); |
| 93336 | sqlite3VdbeJumpHere(v, addrTop); |
| 93337 | } |
| 93338 | }else |
| 93339 | #endif /* !defined(SQLITE_OMIT_TRIGGER) */ |
| 93340 | #endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */ |
| 93341 | |
| 93342 | #ifndef NDEBUG |
| 93343 | if( sqlite3StrICmp(zLeft, "parser_trace")==0 ){ |
| 93344 | if( zRight ){ |
| @@ -94104,15 +94131,19 @@ | |
| 94131 | ** For an attached db, it is an error if the encoding is not the same |
| 94132 | ** as sqlite3.enc. |
| 94133 | */ |
| 94134 | if( meta[BTREE_TEXT_ENCODING-1] ){ /* text encoding */ |
| 94135 | if( iDb==0 ){ |
| 94136 | #ifndef SQLITE_OMIT_UTF16 |
| 94137 | u8 encoding; |
| 94138 | /* If opening the main database, set ENC(db). */ |
| 94139 | encoding = (u8)meta[BTREE_TEXT_ENCODING-1] & 3; |
| 94140 | if( encoding==0 ) encoding = SQLITE_UTF8; |
| 94141 | ENC(db) = encoding; |
| 94142 | #else |
| 94143 | ENC(db) = SQLITE_UTF8; |
| 94144 | #endif |
| 94145 | }else{ |
| 94146 | /* If opening an attached database, the encoding much match ENC(db) */ |
| 94147 | if( meta[BTREE_TEXT_ENCODING-1]!=ENC(db) ){ |
| 94148 | sqlite3SetString(pzErrMsg, db, "attached databases must use the same" |
| 94149 | " text encoding as main database"); |
| 94150 |
+1
-1
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -107,11 +107,11 @@ | ||
| 107 | 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | 109 | */ |
| 110 | 110 | #define SQLITE_VERSION "3.7.16" |
| 111 | 111 | #define SQLITE_VERSION_NUMBER 3007016 |
| 112 | -#define SQLITE_SOURCE_ID "2013-03-06 01:55:27 7097241c1220ada318f8eda938c3e3430b94a606" | |
| 112 | +#define SQLITE_SOURCE_ID "2013-03-11 13:37:52 f9027cb47bdec8dcebf1f038921b28d9e9928c18" | |
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | 117 | ** |
| 118 | 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.16" |
| 111 | #define SQLITE_VERSION_NUMBER 3007016 |
| 112 | #define SQLITE_SOURCE_ID "2013-03-06 01:55:27 7097241c1220ada318f8eda938c3e3430b94a606" |
| 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.16" |
| 111 | #define SQLITE_VERSION_NUMBER 3007016 |
| 112 | #define SQLITE_SOURCE_ID "2013-03-11 13:37:52 f9027cb47bdec8dcebf1f038921b28d9e9928c18" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| 118 |