Fossil SCM

Update the built-in SQLite to the latest 3.21.0 alpha that includes the enhancements to the Windows VFS that help it better deal with read-only repository files.

drh 2017-09-21 20:45 trunk
Commit e97d4443d5628702df5ffc533de91827e1dd7fc76a3b6e452bc601601732ecf8
2 files changed +63 -55 +1 -1
+63 -55
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1147,11 +1147,11 @@
11471147
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11481148
** [sqlite_version()] and [sqlite_source_id()].
11491149
*/
11501150
#define SQLITE_VERSION "3.21.0"
11511151
#define SQLITE_VERSION_NUMBER 3021000
1152
-#define SQLITE_SOURCE_ID "2017-09-20 10:47:10 fd7743d96ebeacce621dc79a4de408fbda6a9b35657628e71ac6e3c12595c9d0"
1152
+#define SQLITE_SOURCE_ID "2017-09-21 20:43:48 5d03c738e93d36815248991d9ed3d62297ba1bb966e602e7874410076c144f43"
11531153
11541154
/*
11551155
** CAPI3REF: Run-Time Library Version Numbers
11561156
** KEYWORDS: sqlite3_version sqlite3_sourceid
11571157
**
@@ -43098,10 +43098,18 @@
4309843098
#endif
4309943099
}
4310043100
return (attr!=INVALID_FILE_ATTRIBUTES) && (attr&FILE_ATTRIBUTE_DIRECTORY);
4310143101
}
4310243102
43103
+/* forward reference */
43104
+static int winAccess(
43105
+ sqlite3_vfs *pVfs, /* Not used on win32 */
43106
+ const char *zFilename, /* Name of file to check */
43107
+ int flags, /* Type of test to make on this file */
43108
+ int *pResOut /* OUT: Result */
43109
+);
43110
+
4310343111
/*
4310443112
** Open a file.
4310543113
*/
4310643114
static int winOpen(
4310743115
sqlite3_vfs *pVfs, /* Used to get maximum path length and AppData */
@@ -43283,19 +43291,24 @@
4328343291
&extendedParameters))==INVALID_HANDLE_VALUE &&
4328443292
winRetryIoerr(&cnt, &lastErrno) ){
4328543293
/* Noop */
4328643294
}
4328743295
#else
43288
- while( (h = osCreateFileW((LPCWSTR)zConverted,
43289
- dwDesiredAccess,
43290
- dwShareMode, NULL,
43291
- dwCreationDisposition,
43292
- dwFlagsAndAttributes,
43293
- NULL))==INVALID_HANDLE_VALUE &&
43294
- winRetryIoerr(&cnt, &lastErrno) ){
43295
- /* Noop */
43296
- }
43296
+ do{
43297
+ h = osCreateFileW((LPCWSTR)zConverted,
43298
+ dwDesiredAccess,
43299
+ dwShareMode, NULL,
43300
+ dwCreationDisposition,
43301
+ dwFlagsAndAttributes,
43302
+ NULL);
43303
+ if( h!=INVALID_HANDLE_VALUE ) break;
43304
+ if( isReadWrite ){
43305
+ int isRO = 0;
43306
+ int rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO);
43307
+ if( rc2==SQLITE_OK && isRO ) break;
43308
+ }
43309
+ }while( winRetryIoerr(&cnt, &lastErrno) );
4329743310
#endif
4329843311
}
4329943312
#ifdef SQLITE_WIN32_HAS_ANSI
4330043313
else{
4330143314
while( (h = osCreateFileA((LPCSTR)zConverted,
@@ -43313,20 +43326,20 @@
4331343326
4331443327
OSTRACE(("OPEN file=%p, name=%s, access=%lx, rc=%s\n", h, zUtf8Name,
4331543328
dwDesiredAccess, (h==INVALID_HANDLE_VALUE) ? "failed" : "ok"));
4331643329
4331743330
if( h==INVALID_HANDLE_VALUE ){
43318
- pFile->lastErrno = lastErrno;
43319
- winLogError(SQLITE_CANTOPEN, pFile->lastErrno, "winOpen", zUtf8Name);
4332043331
sqlite3_free(zConverted);
4332143332
sqlite3_free(zTmpname);
4332243333
if( isReadWrite && !isExclusive ){
4332343334
return winOpen(pVfs, zName, id,
4332443335
((flags|SQLITE_OPEN_READONLY) &
4332543336
~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE)),
4332643337
pOutFlags);
4332743338
}else{
43339
+ pFile->lastErrno = lastErrno;
43340
+ winLogError(SQLITE_CANTOPEN, pFile->lastErrno, "winOpen", zUtf8Name);
4332843341
return SQLITE_CANTOPEN_BKPT;
4332943342
}
4333043343
}
4333143344
4333243345
if( pOutFlags ){
@@ -70512,11 +70525,11 @@
7051270525
testcase( bPreserve && pMem->z==0 );
7051370526
7051470527
assert( pMem->szMalloc==0
7051570528
|| pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) );
7051670529
if( n<32 ) n = 32;
70517
- if( bPreserve && pMem->szMalloc>0 && pMem->z==pMem->zMalloc ){
70530
+ if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){
7051870531
pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
7051970532
bPreserve = 0;
7052070533
}else{
7052170534
if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc);
7052270535
pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n);
@@ -70528,11 +70541,12 @@
7052870541
return SQLITE_NOMEM_BKPT;
7052970542
}else{
7053070543
pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->zMalloc);
7053170544
}
7053270545
70533
- if( bPreserve && pMem->z && ALWAYS(pMem->z!=pMem->zMalloc) ){
70546
+ if( bPreserve && pMem->z ){
70547
+ assert( pMem->z!=pMem->zMalloc );
7053470548
memcpy(pMem->zMalloc, pMem->z, pMem->n);
7053570549
}
7053670550
if( (pMem->flags&MEM_Dyn)!=0 ){
7053770551
assert( pMem->xDel!=0 && pMem->xDel!=SQLITE_DYNAMIC );
7053870552
pMem->xDel((void *)(pMem->z));
@@ -70565,10 +70579,24 @@
7056570579
assert( (pMem->flags & MEM_Dyn)==0 );
7056670580
pMem->z = pMem->zMalloc;
7056770581
pMem->flags &= (MEM_Null|MEM_Int|MEM_Real);
7056870582
return SQLITE_OK;
7056970583
}
70584
+
70585
+/*
70586
+** It is already known that pMem contains an unterminated string.
70587
+** Add the zero terminator.
70588
+*/
70589
+static SQLITE_NOINLINE int vdbeMemAddTerminator(Mem *pMem){
70590
+ if( sqlite3VdbeMemGrow(pMem, pMem->n+2, 1) ){
70591
+ return SQLITE_NOMEM_BKPT;
70592
+ }
70593
+ pMem->z[pMem->n] = 0;
70594
+ pMem->z[pMem->n+1] = 0;
70595
+ pMem->flags |= MEM_Term;
70596
+ return SQLITE_OK;
70597
+}
7057070598
7057170599
/*
7057270600
** Change pMem so that its MEM_Str or MEM_Blob value is stored in
7057370601
** MEM.zMalloc, where it can be safely written.
7057470602
**
@@ -70578,16 +70606,12 @@
7057870606
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
7057970607
assert( (pMem->flags&MEM_RowSet)==0 );
7058070608
if( (pMem->flags & (MEM_Str|MEM_Blob))!=0 ){
7058170609
if( ExpandBlob(pMem) ) return SQLITE_NOMEM;
7058270610
if( pMem->szMalloc==0 || pMem->z!=pMem->zMalloc ){
70583
- if( sqlite3VdbeMemGrow(pMem, pMem->n + 2, 1) ){
70584
- return SQLITE_NOMEM_BKPT;
70585
- }
70586
- pMem->z[pMem->n] = 0;
70587
- pMem->z[pMem->n+1] = 0;
70588
- pMem->flags |= MEM_Term;
70611
+ int rc = vdbeMemAddTerminator(pMem);
70612
+ if( rc ) return rc;
7058970613
}
7059070614
}
7059170615
pMem->flags &= ~MEM_Ephem;
7059270616
#ifdef SQLITE_DEBUG
7059370617
pMem->pScopyFrom = 0;
@@ -70622,24 +70646,10 @@
7062270646
pMem->flags &= ~(MEM_Zero|MEM_Term);
7062370647
return SQLITE_OK;
7062470648
}
7062570649
#endif
7062670650
70627
-/*
70628
-** It is already known that pMem contains an unterminated string.
70629
-** Add the zero terminator.
70630
-*/
70631
-static SQLITE_NOINLINE int vdbeMemAddTerminator(Mem *pMem){
70632
- if( sqlite3VdbeMemGrow(pMem, pMem->n+2, 1) ){
70633
- return SQLITE_NOMEM_BKPT;
70634
- }
70635
- pMem->z[pMem->n] = 0;
70636
- pMem->z[pMem->n+1] = 0;
70637
- pMem->flags |= MEM_Term;
70638
- return SQLITE_OK;
70639
-}
70640
-
7064170651
/*
7064270652
** Make sure the given Mem is \u0000 terminated.
7064370653
*/
7064470654
SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem *pMem){
7064570655
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
@@ -71373,16 +71383,14 @@
7137371383
u32 amt, /* Number of bytes to return. */
7137471384
Mem *pMem /* OUT: Return data in this Mem structure. */
7137571385
){
7137671386
int rc;
7137771387
pMem->flags = MEM_Null;
71378
- if( SQLITE_OK==(rc = sqlite3VdbeMemClearAndResize(pMem, amt+2)) ){
71388
+ if( SQLITE_OK==(rc = sqlite3VdbeMemClearAndResize(pMem, amt)) ){
7137971389
rc = sqlite3BtreePayload(pCur, offset, amt, pMem->z);
7138071390
if( rc==SQLITE_OK ){
71381
- pMem->z[amt] = 0;
71382
- pMem->z[amt+1] = 0;
71383
- pMem->flags = MEM_Blob|MEM_Term;
71391
+ pMem->flags = MEM_Blob;
7138471392
pMem->n = (int)amt;
7138571393
}else{
7138671394
sqlite3VdbeMemRelease(pMem);
7138771395
}
7138871396
}
@@ -73522,11 +73530,11 @@
7352273530
case P4_INTARRAY: {
7352373531
int i;
7352473532
int *ai = pOp->p4.ai;
7352573533
int n = ai[0]; /* The first element of an INTARRAY is always the
7352673534
** count of the number of elements to follow */
73527
- for(i=1; i<n; i++){
73535
+ for(i=1; i<=n; i++){
7352873536
sqlite3XPrintf(&x, ",%d", ai[i]);
7352973537
}
7353073538
zTemp[0] = '[';
7353173539
sqlite3StrAccumAppend(&x, "]", 1);
7353273540
break;
@@ -84772,19 +84780,19 @@
8477284780
8477384781
assert( p->bIsReader );
8477484782
nRoot = pOp->p2;
8477584783
aRoot = pOp->p4.ai;
8477684784
assert( nRoot>0 );
84777
- assert( aRoot[nRoot]==0 );
84785
+ assert( aRoot[0]==nRoot );
8477884786
assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
8477984787
pnErr = &aMem[pOp->p3];
8478084788
assert( (pnErr->flags & MEM_Int)!=0 );
8478184789
assert( (pnErr->flags & (MEM_Str|MEM_Blob))==0 );
8478284790
pIn1 = &aMem[pOp->p1];
8478384791
assert( pOp->p5<db->nDb );
8478484792
assert( DbMaskTest(p->btreeMask, pOp->p5) );
84785
- z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p5].pBt, aRoot, nRoot,
84793
+ z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p5].pBt, &aRoot[1], nRoot,
8478684794
(int)pnErr->u.i+1, &nErr);
8478784795
sqlite3VdbeMemSetNull(pIn1);
8478884796
if( nErr==0 ){
8478984797
assert( z==0 );
8479084798
}else if( z==0 ){
@@ -115746,16 +115754,16 @@
115746115754
aRoot = sqlite3DbMallocRawNN(db, sizeof(int)*(cnt+1));
115747115755
if( aRoot==0 ) break;
115748115756
for(cnt=0, x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){
115749115757
Table *pTab = sqliteHashData(x);
115750115758
Index *pIdx;
115751
- if( HasRowid(pTab) ) aRoot[cnt++] = pTab->tnum;
115759
+ if( HasRowid(pTab) ) aRoot[++cnt] = pTab->tnum;
115752115760
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
115753
- aRoot[cnt++] = pIdx->tnum;
115761
+ aRoot[++cnt] = pIdx->tnum;
115754115762
}
115755115763
}
115756
- aRoot[cnt] = 0;
115764
+ aRoot[0] = cnt;
115757115765
115758115766
/* Make sure sufficient number of registers have been allocated */
115759115767
pParse->nMem = MAX( pParse->nMem, 8+mxIdx );
115760115768
sqlite3ClearTempRegCache(pParse);
115761115769
@@ -168376,11 +168384,11 @@
168376168384
*/
168377168385
static int rtreeDeleteRowid(Rtree *pRtree, sqlite3_int64 iDelete){
168378168386
int rc; /* Return code */
168379168387
RtreeNode *pLeaf = 0; /* Leaf node containing record iDelete */
168380168388
int iCell; /* Index of iDelete cell in pLeaf */
168381
- RtreeNode *pRoot; /* Root node of rtree structure */
168389
+ RtreeNode *pRoot = 0; /* Root node of rtree structure */
168382168390
168383168391
168384168392
/* Obtain a reference to the root node to initialize Rtree.iDepth */
168385168393
rc = nodeAcquire(pRtree, 1, 0, &pRoot);
168386168394
@@ -169404,19 +169412,19 @@
169404169412
static int icuLikeCompare(
169405169413
const uint8_t *zPattern, /* LIKE pattern */
169406169414
const uint8_t *zString, /* The UTF-8 string to compare against */
169407169415
const UChar32 uEsc /* The escape character */
169408169416
){
169409
- static const int MATCH_ONE = (UChar32)'_';
169410
- static const int MATCH_ALL = (UChar32)'%';
169417
+ static const uint32_t MATCH_ONE = (uint32_t)'_';
169418
+ static const uint32_t MATCH_ALL = (uint32_t)'%';
169411169419
169412169420
int prevEscape = 0; /* True if the previous character was uEsc */
169413169421
169414169422
while( 1 ){
169415169423
169416169424
/* Read (and consume) the next character from the input pattern. */
169417
- UChar32 uPattern;
169425
+ uint32_t uPattern;
169418169426
SQLITE_ICU_READ_UTF8(zPattern, uPattern);
169419169427
if( uPattern==0 ) break;
169420169428
169421169429
/* There are now 4 possibilities:
169422169430
**
@@ -169454,20 +169462,20 @@
169454169462
}else if( !prevEscape && uPattern==MATCH_ONE ){
169455169463
/* Case 2. */
169456169464
if( *zString==0 ) return 0;
169457169465
SQLITE_ICU_SKIP_UTF8(zString);
169458169466
169459
- }else if( !prevEscape && uPattern==uEsc){
169467
+ }else if( !prevEscape && uPattern==(uint32_t)uEsc){
169460169468
/* Case 3. */
169461169469
prevEscape = 1;
169462169470
169463169471
}else{
169464169472
/* Case 4. */
169465
- UChar32 uString;
169473
+ uint32_t uString;
169466169474
SQLITE_ICU_READ_UTF8(zString, uString);
169467
- uString = u_foldCase(uString, U_FOLD_CASE_DEFAULT);
169468
- uPattern = u_foldCase(uPattern, U_FOLD_CASE_DEFAULT);
169475
+ uString = (uint32_t)u_foldCase((UChar32)uString, U_FOLD_CASE_DEFAULT);
169476
+ uPattern = (uint32_t)u_foldCase((UChar32)uPattern, U_FOLD_CASE_DEFAULT);
169469169477
if( uString!=uPattern ){
169470169478
return 0;
169471169479
}
169472169480
prevEscape = 0;
169473169481
}
@@ -200624,11 +200632,11 @@
200624200632
int nArg, /* Number of args */
200625200633
sqlite3_value **apUnused /* Function arguments */
200626200634
){
200627200635
assert( nArg==0 );
200628200636
UNUSED_PARAM2(nArg, apUnused);
200629
- sqlite3_result_text(pCtx, "fts5: 2017-09-20 10:47:10 7f2bd4ff45fba29528c18cac6da983bd9b164303525d3965056f5b40f85dc83f", -1, SQLITE_TRANSIENT);
200637
+ sqlite3_result_text(pCtx, "fts5: 2017-09-21 20:43:48 5d03c738e93d36815248991d9ed3d62297ba1bb966e602e7874410076c144f43", -1, SQLITE_TRANSIENT);
200630200638
}
200631200639
200632200640
static int fts5Init(sqlite3 *db){
200633200641
static const sqlite3_module fts5Mod = {
200634200642
/* iVersion */ 2,
@@ -204893,12 +204901,12 @@
204893204901
}
204894204902
#endif /* SQLITE_CORE */
204895204903
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
204896204904
204897204905
/************** End of stmt.c ************************************************/
204898
-#if __LINE__!=204898
204906
+#if __LINE__!=204906
204899204907
#undef SQLITE_SOURCE_ID
204900
-#define SQLITE_SOURCE_ID "2017-09-20 10:47:10 fd7743d96ebeacce621dc79a4de408fbda6a9b35657628e71ac6e3c12595alt2"
204908
+#define SQLITE_SOURCE_ID "2017-09-21 20:43:48 5d03c738e93d36815248991d9ed3d62297ba1bb966e602e7874410076c14alt2"
204901204909
#endif
204902204910
/* Return the source-id for this library */
204903204911
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
204904204912
/************************** End of sqlite3.c ******************************/
204905204913
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1147,11 +1147,11 @@
1147 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1148 ** [sqlite_version()] and [sqlite_source_id()].
1149 */
1150 #define SQLITE_VERSION "3.21.0"
1151 #define SQLITE_VERSION_NUMBER 3021000
1152 #define SQLITE_SOURCE_ID "2017-09-20 10:47:10 fd7743d96ebeacce621dc79a4de408fbda6a9b35657628e71ac6e3c12595c9d0"
1153
1154 /*
1155 ** CAPI3REF: Run-Time Library Version Numbers
1156 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1157 **
@@ -43098,10 +43098,18 @@
43098 #endif
43099 }
43100 return (attr!=INVALID_FILE_ATTRIBUTES) && (attr&FILE_ATTRIBUTE_DIRECTORY);
43101 }
43102
 
 
 
 
 
 
 
 
43103 /*
43104 ** Open a file.
43105 */
43106 static int winOpen(
43107 sqlite3_vfs *pVfs, /* Used to get maximum path length and AppData */
@@ -43283,19 +43291,24 @@
43283 &extendedParameters))==INVALID_HANDLE_VALUE &&
43284 winRetryIoerr(&cnt, &lastErrno) ){
43285 /* Noop */
43286 }
43287 #else
43288 while( (h = osCreateFileW((LPCWSTR)zConverted,
43289 dwDesiredAccess,
43290 dwShareMode, NULL,
43291 dwCreationDisposition,
43292 dwFlagsAndAttributes,
43293 NULL))==INVALID_HANDLE_VALUE &&
43294 winRetryIoerr(&cnt, &lastErrno) ){
43295 /* Noop */
43296 }
 
 
 
 
 
43297 #endif
43298 }
43299 #ifdef SQLITE_WIN32_HAS_ANSI
43300 else{
43301 while( (h = osCreateFileA((LPCSTR)zConverted,
@@ -43313,20 +43326,20 @@
43313
43314 OSTRACE(("OPEN file=%p, name=%s, access=%lx, rc=%s\n", h, zUtf8Name,
43315 dwDesiredAccess, (h==INVALID_HANDLE_VALUE) ? "failed" : "ok"));
43316
43317 if( h==INVALID_HANDLE_VALUE ){
43318 pFile->lastErrno = lastErrno;
43319 winLogError(SQLITE_CANTOPEN, pFile->lastErrno, "winOpen", zUtf8Name);
43320 sqlite3_free(zConverted);
43321 sqlite3_free(zTmpname);
43322 if( isReadWrite && !isExclusive ){
43323 return winOpen(pVfs, zName, id,
43324 ((flags|SQLITE_OPEN_READONLY) &
43325 ~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE)),
43326 pOutFlags);
43327 }else{
 
 
43328 return SQLITE_CANTOPEN_BKPT;
43329 }
43330 }
43331
43332 if( pOutFlags ){
@@ -70512,11 +70525,11 @@
70512 testcase( bPreserve && pMem->z==0 );
70513
70514 assert( pMem->szMalloc==0
70515 || pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) );
70516 if( n<32 ) n = 32;
70517 if( bPreserve && pMem->szMalloc>0 && pMem->z==pMem->zMalloc ){
70518 pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
70519 bPreserve = 0;
70520 }else{
70521 if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc);
70522 pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n);
@@ -70528,11 +70541,12 @@
70528 return SQLITE_NOMEM_BKPT;
70529 }else{
70530 pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->zMalloc);
70531 }
70532
70533 if( bPreserve && pMem->z && ALWAYS(pMem->z!=pMem->zMalloc) ){
 
70534 memcpy(pMem->zMalloc, pMem->z, pMem->n);
70535 }
70536 if( (pMem->flags&MEM_Dyn)!=0 ){
70537 assert( pMem->xDel!=0 && pMem->xDel!=SQLITE_DYNAMIC );
70538 pMem->xDel((void *)(pMem->z));
@@ -70565,10 +70579,24 @@
70565 assert( (pMem->flags & MEM_Dyn)==0 );
70566 pMem->z = pMem->zMalloc;
70567 pMem->flags &= (MEM_Null|MEM_Int|MEM_Real);
70568 return SQLITE_OK;
70569 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70570
70571 /*
70572 ** Change pMem so that its MEM_Str or MEM_Blob value is stored in
70573 ** MEM.zMalloc, where it can be safely written.
70574 **
@@ -70578,16 +70606,12 @@
70578 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
70579 assert( (pMem->flags&MEM_RowSet)==0 );
70580 if( (pMem->flags & (MEM_Str|MEM_Blob))!=0 ){
70581 if( ExpandBlob(pMem) ) return SQLITE_NOMEM;
70582 if( pMem->szMalloc==0 || pMem->z!=pMem->zMalloc ){
70583 if( sqlite3VdbeMemGrow(pMem, pMem->n + 2, 1) ){
70584 return SQLITE_NOMEM_BKPT;
70585 }
70586 pMem->z[pMem->n] = 0;
70587 pMem->z[pMem->n+1] = 0;
70588 pMem->flags |= MEM_Term;
70589 }
70590 }
70591 pMem->flags &= ~MEM_Ephem;
70592 #ifdef SQLITE_DEBUG
70593 pMem->pScopyFrom = 0;
@@ -70622,24 +70646,10 @@
70622 pMem->flags &= ~(MEM_Zero|MEM_Term);
70623 return SQLITE_OK;
70624 }
70625 #endif
70626
70627 /*
70628 ** It is already known that pMem contains an unterminated string.
70629 ** Add the zero terminator.
70630 */
70631 static SQLITE_NOINLINE int vdbeMemAddTerminator(Mem *pMem){
70632 if( sqlite3VdbeMemGrow(pMem, pMem->n+2, 1) ){
70633 return SQLITE_NOMEM_BKPT;
70634 }
70635 pMem->z[pMem->n] = 0;
70636 pMem->z[pMem->n+1] = 0;
70637 pMem->flags |= MEM_Term;
70638 return SQLITE_OK;
70639 }
70640
70641 /*
70642 ** Make sure the given Mem is \u0000 terminated.
70643 */
70644 SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem *pMem){
70645 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
@@ -71373,16 +71383,14 @@
71373 u32 amt, /* Number of bytes to return. */
71374 Mem *pMem /* OUT: Return data in this Mem structure. */
71375 ){
71376 int rc;
71377 pMem->flags = MEM_Null;
71378 if( SQLITE_OK==(rc = sqlite3VdbeMemClearAndResize(pMem, amt+2)) ){
71379 rc = sqlite3BtreePayload(pCur, offset, amt, pMem->z);
71380 if( rc==SQLITE_OK ){
71381 pMem->z[amt] = 0;
71382 pMem->z[amt+1] = 0;
71383 pMem->flags = MEM_Blob|MEM_Term;
71384 pMem->n = (int)amt;
71385 }else{
71386 sqlite3VdbeMemRelease(pMem);
71387 }
71388 }
@@ -73522,11 +73530,11 @@
73522 case P4_INTARRAY: {
73523 int i;
73524 int *ai = pOp->p4.ai;
73525 int n = ai[0]; /* The first element of an INTARRAY is always the
73526 ** count of the number of elements to follow */
73527 for(i=1; i<n; i++){
73528 sqlite3XPrintf(&x, ",%d", ai[i]);
73529 }
73530 zTemp[0] = '[';
73531 sqlite3StrAccumAppend(&x, "]", 1);
73532 break;
@@ -84772,19 +84780,19 @@
84772
84773 assert( p->bIsReader );
84774 nRoot = pOp->p2;
84775 aRoot = pOp->p4.ai;
84776 assert( nRoot>0 );
84777 assert( aRoot[nRoot]==0 );
84778 assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
84779 pnErr = &aMem[pOp->p3];
84780 assert( (pnErr->flags & MEM_Int)!=0 );
84781 assert( (pnErr->flags & (MEM_Str|MEM_Blob))==0 );
84782 pIn1 = &aMem[pOp->p1];
84783 assert( pOp->p5<db->nDb );
84784 assert( DbMaskTest(p->btreeMask, pOp->p5) );
84785 z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p5].pBt, aRoot, nRoot,
84786 (int)pnErr->u.i+1, &nErr);
84787 sqlite3VdbeMemSetNull(pIn1);
84788 if( nErr==0 ){
84789 assert( z==0 );
84790 }else if( z==0 ){
@@ -115746,16 +115754,16 @@
115746 aRoot = sqlite3DbMallocRawNN(db, sizeof(int)*(cnt+1));
115747 if( aRoot==0 ) break;
115748 for(cnt=0, x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){
115749 Table *pTab = sqliteHashData(x);
115750 Index *pIdx;
115751 if( HasRowid(pTab) ) aRoot[cnt++] = pTab->tnum;
115752 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
115753 aRoot[cnt++] = pIdx->tnum;
115754 }
115755 }
115756 aRoot[cnt] = 0;
115757
115758 /* Make sure sufficient number of registers have been allocated */
115759 pParse->nMem = MAX( pParse->nMem, 8+mxIdx );
115760 sqlite3ClearTempRegCache(pParse);
115761
@@ -168376,11 +168384,11 @@
168376 */
168377 static int rtreeDeleteRowid(Rtree *pRtree, sqlite3_int64 iDelete){
168378 int rc; /* Return code */
168379 RtreeNode *pLeaf = 0; /* Leaf node containing record iDelete */
168380 int iCell; /* Index of iDelete cell in pLeaf */
168381 RtreeNode *pRoot; /* Root node of rtree structure */
168382
168383
168384 /* Obtain a reference to the root node to initialize Rtree.iDepth */
168385 rc = nodeAcquire(pRtree, 1, 0, &pRoot);
168386
@@ -169404,19 +169412,19 @@
169404 static int icuLikeCompare(
169405 const uint8_t *zPattern, /* LIKE pattern */
169406 const uint8_t *zString, /* The UTF-8 string to compare against */
169407 const UChar32 uEsc /* The escape character */
169408 ){
169409 static const int MATCH_ONE = (UChar32)'_';
169410 static const int MATCH_ALL = (UChar32)'%';
169411
169412 int prevEscape = 0; /* True if the previous character was uEsc */
169413
169414 while( 1 ){
169415
169416 /* Read (and consume) the next character from the input pattern. */
169417 UChar32 uPattern;
169418 SQLITE_ICU_READ_UTF8(zPattern, uPattern);
169419 if( uPattern==0 ) break;
169420
169421 /* There are now 4 possibilities:
169422 **
@@ -169454,20 +169462,20 @@
169454 }else if( !prevEscape && uPattern==MATCH_ONE ){
169455 /* Case 2. */
169456 if( *zString==0 ) return 0;
169457 SQLITE_ICU_SKIP_UTF8(zString);
169458
169459 }else if( !prevEscape && uPattern==uEsc){
169460 /* Case 3. */
169461 prevEscape = 1;
169462
169463 }else{
169464 /* Case 4. */
169465 UChar32 uString;
169466 SQLITE_ICU_READ_UTF8(zString, uString);
169467 uString = u_foldCase(uString, U_FOLD_CASE_DEFAULT);
169468 uPattern = u_foldCase(uPattern, U_FOLD_CASE_DEFAULT);
169469 if( uString!=uPattern ){
169470 return 0;
169471 }
169472 prevEscape = 0;
169473 }
@@ -200624,11 +200632,11 @@
200624 int nArg, /* Number of args */
200625 sqlite3_value **apUnused /* Function arguments */
200626 ){
200627 assert( nArg==0 );
200628 UNUSED_PARAM2(nArg, apUnused);
200629 sqlite3_result_text(pCtx, "fts5: 2017-09-20 10:47:10 7f2bd4ff45fba29528c18cac6da983bd9b164303525d3965056f5b40f85dc83f", -1, SQLITE_TRANSIENT);
200630 }
200631
200632 static int fts5Init(sqlite3 *db){
200633 static const sqlite3_module fts5Mod = {
200634 /* iVersion */ 2,
@@ -204893,12 +204901,12 @@
204893 }
204894 #endif /* SQLITE_CORE */
204895 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
204896
204897 /************** End of stmt.c ************************************************/
204898 #if __LINE__!=204898
204899 #undef SQLITE_SOURCE_ID
204900 #define SQLITE_SOURCE_ID "2017-09-20 10:47:10 fd7743d96ebeacce621dc79a4de408fbda6a9b35657628e71ac6e3c12595alt2"
204901 #endif
204902 /* Return the source-id for this library */
204903 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
204904 /************************** End of sqlite3.c ******************************/
204905
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1147,11 +1147,11 @@
1147 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1148 ** [sqlite_version()] and [sqlite_source_id()].
1149 */
1150 #define SQLITE_VERSION "3.21.0"
1151 #define SQLITE_VERSION_NUMBER 3021000
1152 #define SQLITE_SOURCE_ID "2017-09-21 20:43:48 5d03c738e93d36815248991d9ed3d62297ba1bb966e602e7874410076c144f43"
1153
1154 /*
1155 ** CAPI3REF: Run-Time Library Version Numbers
1156 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1157 **
@@ -43098,10 +43098,18 @@
43098 #endif
43099 }
43100 return (attr!=INVALID_FILE_ATTRIBUTES) && (attr&FILE_ATTRIBUTE_DIRECTORY);
43101 }
43102
43103 /* forward reference */
43104 static int winAccess(
43105 sqlite3_vfs *pVfs, /* Not used on win32 */
43106 const char *zFilename, /* Name of file to check */
43107 int flags, /* Type of test to make on this file */
43108 int *pResOut /* OUT: Result */
43109 );
43110
43111 /*
43112 ** Open a file.
43113 */
43114 static int winOpen(
43115 sqlite3_vfs *pVfs, /* Used to get maximum path length and AppData */
@@ -43283,19 +43291,24 @@
43291 &extendedParameters))==INVALID_HANDLE_VALUE &&
43292 winRetryIoerr(&cnt, &lastErrno) ){
43293 /* Noop */
43294 }
43295 #else
43296 do{
43297 h = osCreateFileW((LPCWSTR)zConverted,
43298 dwDesiredAccess,
43299 dwShareMode, NULL,
43300 dwCreationDisposition,
43301 dwFlagsAndAttributes,
43302 NULL);
43303 if( h!=INVALID_HANDLE_VALUE ) break;
43304 if( isReadWrite ){
43305 int isRO = 0;
43306 int rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO);
43307 if( rc2==SQLITE_OK && isRO ) break;
43308 }
43309 }while( winRetryIoerr(&cnt, &lastErrno) );
43310 #endif
43311 }
43312 #ifdef SQLITE_WIN32_HAS_ANSI
43313 else{
43314 while( (h = osCreateFileA((LPCSTR)zConverted,
@@ -43313,20 +43326,20 @@
43326
43327 OSTRACE(("OPEN file=%p, name=%s, access=%lx, rc=%s\n", h, zUtf8Name,
43328 dwDesiredAccess, (h==INVALID_HANDLE_VALUE) ? "failed" : "ok"));
43329
43330 if( h==INVALID_HANDLE_VALUE ){
 
 
43331 sqlite3_free(zConverted);
43332 sqlite3_free(zTmpname);
43333 if( isReadWrite && !isExclusive ){
43334 return winOpen(pVfs, zName, id,
43335 ((flags|SQLITE_OPEN_READONLY) &
43336 ~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE)),
43337 pOutFlags);
43338 }else{
43339 pFile->lastErrno = lastErrno;
43340 winLogError(SQLITE_CANTOPEN, pFile->lastErrno, "winOpen", zUtf8Name);
43341 return SQLITE_CANTOPEN_BKPT;
43342 }
43343 }
43344
43345 if( pOutFlags ){
@@ -70512,11 +70525,11 @@
70525 testcase( bPreserve && pMem->z==0 );
70526
70527 assert( pMem->szMalloc==0
70528 || pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) );
70529 if( n<32 ) n = 32;
70530 if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){
70531 pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
70532 bPreserve = 0;
70533 }else{
70534 if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc);
70535 pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n);
@@ -70528,11 +70541,12 @@
70541 return SQLITE_NOMEM_BKPT;
70542 }else{
70543 pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->zMalloc);
70544 }
70545
70546 if( bPreserve && pMem->z ){
70547 assert( pMem->z!=pMem->zMalloc );
70548 memcpy(pMem->zMalloc, pMem->z, pMem->n);
70549 }
70550 if( (pMem->flags&MEM_Dyn)!=0 ){
70551 assert( pMem->xDel!=0 && pMem->xDel!=SQLITE_DYNAMIC );
70552 pMem->xDel((void *)(pMem->z));
@@ -70565,10 +70579,24 @@
70579 assert( (pMem->flags & MEM_Dyn)==0 );
70580 pMem->z = pMem->zMalloc;
70581 pMem->flags &= (MEM_Null|MEM_Int|MEM_Real);
70582 return SQLITE_OK;
70583 }
70584
70585 /*
70586 ** It is already known that pMem contains an unterminated string.
70587 ** Add the zero terminator.
70588 */
70589 static SQLITE_NOINLINE int vdbeMemAddTerminator(Mem *pMem){
70590 if( sqlite3VdbeMemGrow(pMem, pMem->n+2, 1) ){
70591 return SQLITE_NOMEM_BKPT;
70592 }
70593 pMem->z[pMem->n] = 0;
70594 pMem->z[pMem->n+1] = 0;
70595 pMem->flags |= MEM_Term;
70596 return SQLITE_OK;
70597 }
70598
70599 /*
70600 ** Change pMem so that its MEM_Str or MEM_Blob value is stored in
70601 ** MEM.zMalloc, where it can be safely written.
70602 **
@@ -70578,16 +70606,12 @@
70606 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
70607 assert( (pMem->flags&MEM_RowSet)==0 );
70608 if( (pMem->flags & (MEM_Str|MEM_Blob))!=0 ){
70609 if( ExpandBlob(pMem) ) return SQLITE_NOMEM;
70610 if( pMem->szMalloc==0 || pMem->z!=pMem->zMalloc ){
70611 int rc = vdbeMemAddTerminator(pMem);
70612 if( rc ) return rc;
 
 
 
 
70613 }
70614 }
70615 pMem->flags &= ~MEM_Ephem;
70616 #ifdef SQLITE_DEBUG
70617 pMem->pScopyFrom = 0;
@@ -70622,24 +70646,10 @@
70646 pMem->flags &= ~(MEM_Zero|MEM_Term);
70647 return SQLITE_OK;
70648 }
70649 #endif
70650
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70651 /*
70652 ** Make sure the given Mem is \u0000 terminated.
70653 */
70654 SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem *pMem){
70655 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
@@ -71373,16 +71383,14 @@
71383 u32 amt, /* Number of bytes to return. */
71384 Mem *pMem /* OUT: Return data in this Mem structure. */
71385 ){
71386 int rc;
71387 pMem->flags = MEM_Null;
71388 if( SQLITE_OK==(rc = sqlite3VdbeMemClearAndResize(pMem, amt)) ){
71389 rc = sqlite3BtreePayload(pCur, offset, amt, pMem->z);
71390 if( rc==SQLITE_OK ){
71391 pMem->flags = MEM_Blob;
 
 
71392 pMem->n = (int)amt;
71393 }else{
71394 sqlite3VdbeMemRelease(pMem);
71395 }
71396 }
@@ -73522,11 +73530,11 @@
73530 case P4_INTARRAY: {
73531 int i;
73532 int *ai = pOp->p4.ai;
73533 int n = ai[0]; /* The first element of an INTARRAY is always the
73534 ** count of the number of elements to follow */
73535 for(i=1; i<=n; i++){
73536 sqlite3XPrintf(&x, ",%d", ai[i]);
73537 }
73538 zTemp[0] = '[';
73539 sqlite3StrAccumAppend(&x, "]", 1);
73540 break;
@@ -84772,19 +84780,19 @@
84780
84781 assert( p->bIsReader );
84782 nRoot = pOp->p2;
84783 aRoot = pOp->p4.ai;
84784 assert( nRoot>0 );
84785 assert( aRoot[0]==nRoot );
84786 assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
84787 pnErr = &aMem[pOp->p3];
84788 assert( (pnErr->flags & MEM_Int)!=0 );
84789 assert( (pnErr->flags & (MEM_Str|MEM_Blob))==0 );
84790 pIn1 = &aMem[pOp->p1];
84791 assert( pOp->p5<db->nDb );
84792 assert( DbMaskTest(p->btreeMask, pOp->p5) );
84793 z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p5].pBt, &aRoot[1], nRoot,
84794 (int)pnErr->u.i+1, &nErr);
84795 sqlite3VdbeMemSetNull(pIn1);
84796 if( nErr==0 ){
84797 assert( z==0 );
84798 }else if( z==0 ){
@@ -115746,16 +115754,16 @@
115754 aRoot = sqlite3DbMallocRawNN(db, sizeof(int)*(cnt+1));
115755 if( aRoot==0 ) break;
115756 for(cnt=0, x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){
115757 Table *pTab = sqliteHashData(x);
115758 Index *pIdx;
115759 if( HasRowid(pTab) ) aRoot[++cnt] = pTab->tnum;
115760 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
115761 aRoot[++cnt] = pIdx->tnum;
115762 }
115763 }
115764 aRoot[0] = cnt;
115765
115766 /* Make sure sufficient number of registers have been allocated */
115767 pParse->nMem = MAX( pParse->nMem, 8+mxIdx );
115768 sqlite3ClearTempRegCache(pParse);
115769
@@ -168376,11 +168384,11 @@
168384 */
168385 static int rtreeDeleteRowid(Rtree *pRtree, sqlite3_int64 iDelete){
168386 int rc; /* Return code */
168387 RtreeNode *pLeaf = 0; /* Leaf node containing record iDelete */
168388 int iCell; /* Index of iDelete cell in pLeaf */
168389 RtreeNode *pRoot = 0; /* Root node of rtree structure */
168390
168391
168392 /* Obtain a reference to the root node to initialize Rtree.iDepth */
168393 rc = nodeAcquire(pRtree, 1, 0, &pRoot);
168394
@@ -169404,19 +169412,19 @@
169412 static int icuLikeCompare(
169413 const uint8_t *zPattern, /* LIKE pattern */
169414 const uint8_t *zString, /* The UTF-8 string to compare against */
169415 const UChar32 uEsc /* The escape character */
169416 ){
169417 static const uint32_t MATCH_ONE = (uint32_t)'_';
169418 static const uint32_t MATCH_ALL = (uint32_t)'%';
169419
169420 int prevEscape = 0; /* True if the previous character was uEsc */
169421
169422 while( 1 ){
169423
169424 /* Read (and consume) the next character from the input pattern. */
169425 uint32_t uPattern;
169426 SQLITE_ICU_READ_UTF8(zPattern, uPattern);
169427 if( uPattern==0 ) break;
169428
169429 /* There are now 4 possibilities:
169430 **
@@ -169454,20 +169462,20 @@
169462 }else if( !prevEscape && uPattern==MATCH_ONE ){
169463 /* Case 2. */
169464 if( *zString==0 ) return 0;
169465 SQLITE_ICU_SKIP_UTF8(zString);
169466
169467 }else if( !prevEscape && uPattern==(uint32_t)uEsc){
169468 /* Case 3. */
169469 prevEscape = 1;
169470
169471 }else{
169472 /* Case 4. */
169473 uint32_t uString;
169474 SQLITE_ICU_READ_UTF8(zString, uString);
169475 uString = (uint32_t)u_foldCase((UChar32)uString, U_FOLD_CASE_DEFAULT);
169476 uPattern = (uint32_t)u_foldCase((UChar32)uPattern, U_FOLD_CASE_DEFAULT);
169477 if( uString!=uPattern ){
169478 return 0;
169479 }
169480 prevEscape = 0;
169481 }
@@ -200624,11 +200632,11 @@
200632 int nArg, /* Number of args */
200633 sqlite3_value **apUnused /* Function arguments */
200634 ){
200635 assert( nArg==0 );
200636 UNUSED_PARAM2(nArg, apUnused);
200637 sqlite3_result_text(pCtx, "fts5: 2017-09-21 20:43:48 5d03c738e93d36815248991d9ed3d62297ba1bb966e602e7874410076c144f43", -1, SQLITE_TRANSIENT);
200638 }
200639
200640 static int fts5Init(sqlite3 *db){
200641 static const sqlite3_module fts5Mod = {
200642 /* iVersion */ 2,
@@ -204893,12 +204901,12 @@
204901 }
204902 #endif /* SQLITE_CORE */
204903 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
204904
204905 /************** End of stmt.c ************************************************/
204906 #if __LINE__!=204906
204907 #undef SQLITE_SOURCE_ID
204908 #define SQLITE_SOURCE_ID "2017-09-21 20:43:48 5d03c738e93d36815248991d9ed3d62297ba1bb966e602e7874410076c14alt2"
204909 #endif
204910 /* Return the source-id for this library */
204911 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
204912 /************************** End of sqlite3.c ******************************/
204913
+1 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123123
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124124
** [sqlite_version()] and [sqlite_source_id()].
125125
*/
126126
#define SQLITE_VERSION "3.21.0"
127127
#define SQLITE_VERSION_NUMBER 3021000
128
-#define SQLITE_SOURCE_ID "2017-09-20 10:47:10 fd7743d96ebeacce621dc79a4de408fbda6a9b35657628e71ac6e3c12595c9d0"
128
+#define SQLITE_SOURCE_ID "2017-09-21 20:43:48 5d03c738e93d36815248991d9ed3d62297ba1bb966e602e7874410076c144f43"
129129
130130
/*
131131
** CAPI3REF: Run-Time Library Version Numbers
132132
** KEYWORDS: sqlite3_version sqlite3_sourceid
133133
**
134134
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.21.0"
127 #define SQLITE_VERSION_NUMBER 3021000
128 #define SQLITE_SOURCE_ID "2017-09-20 10:47:10 fd7743d96ebeacce621dc79a4de408fbda6a9b35657628e71ac6e3c12595c9d0"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
134
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.21.0"
127 #define SQLITE_VERSION_NUMBER 3021000
128 #define SQLITE_SOURCE_ID "2017-09-21 20:43:48 5d03c738e93d36815248991d9ed3d62297ba1bb966e602e7874410076c144f43"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
134

Keyboard Shortcuts

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