diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/loadext.c | 5 | ||||
-rw-r--r-- | src/pager.c | 7 | ||||
-rw-r--r-- | src/select.c | 4 | ||||
-rw-r--r-- | src/shell.c.in | 15 | ||||
-rw-r--r-- | src/sqlite3ext.h | 6 |
5 files changed, 28 insertions, 9 deletions
diff --git a/src/loadext.c b/src/loadext.c index cfa8ba4ca..7e0ae2543 100644 --- a/src/loadext.c +++ b/src/loadext.c @@ -514,7 +514,10 @@ static const sqlite3_api_routines sqlite3Apis = { /* Version 3.41.0 and later */ sqlite3_is_interrupted, /* Version 3.43.0 and later */ - sqlite3_stmt_explain + sqlite3_stmt_explain, + /* Version 3.44.0 and later */ + sqlite3_get_clientdata, + sqlite3_set_clientdata }; /* True if x is the directory separator character diff --git a/src/pager.c b/src/pager.c index 5c2d556b3..e54750424 100644 --- a/src/pager.c +++ b/src/pager.c @@ -6588,6 +6588,13 @@ int sqlite3PagerCommitPhaseOne( rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_BEGIN_ATOMIC_WRITE, 0); if( rc==SQLITE_OK ){ rc = pager_write_pagelist(pPager, pList); + if( rc==SQLITE_OK && pPager->dbSize>pPager->dbFileSize ){ + char *pTmp = pPager->pTmpSpace; + int szPage = (int)pPager->pageSize; + memset(pTmp, 0, szPage); + rc = sqlite3OsWrite(pPager->fd, pTmp, szPage, + ((i64)pPager->dbSize*pPager->pageSize)-szPage); + } if( rc==SQLITE_OK ){ rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_COMMIT_ATOMIC_WRITE, 0); } diff --git a/src/select.c b/src/select.c index 0dac37b10..7a79385e0 100644 --- a/src/select.c +++ b/src/select.c @@ -6743,10 +6743,10 @@ static void finalizeAggFunctions(Parse *pParse, AggInfo *pAggInfo){ ** registers if register regAcc contains 0. The caller will take care ** of setting and clearing regAcc. ** -** For an ORDER BY aggregate, the actually accumulator memory cell update +** For an ORDER BY aggregate, the actual accumulator memory cell update ** is deferred until after all input rows have been received, so that they ** can be run in the requested order. In that case, instead of invoking -** OP_AggStep to update accumulator, just add the arguments that would +** OP_AggStep to update the accumulator, just add the arguments that would ** have been passed into OP_AggStep into the sorting ephemeral table ** (along with the appropriate sort key). */ diff --git a/src/shell.c.in b/src/shell.c.in index cf8e4f061..ad16d7204 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -644,23 +644,26 @@ static short console_attrs(unsigned stnum, HANDLE *pH, DWORD *pConsMode){ */ static short ConsoleDoesUTF8(void){ UINT ocp = GetConsoleOutputCP(); + const char TrialUtf8[] = { '\xC8', '\xAB' }; /* "ȫ" or 2 MBCS characters */ + WCHAR aReadBack[1] = { 0 }; /* Read back as 0x022B when decoded as UTF-8. */ CONSOLE_SCREEN_BUFFER_INFO csbInfo = {0}; /* Create an inactive screen buffer with which to do the experiment. */ HANDLE hCSB = CreateConsoleScreenBuffer(GENERIC_READ|GENERIC_WRITE, 0, 0, CONSOLE_TEXTMODE_BUFFER, NULL); if( hCSB!=INVALID_HANDLE_VALUE ){ - const char TrialUtf8[] = { '\xC8', '\xAB' }; /* "ȫ" or 2 MBCS characters */ COORD cpos = {0,0}; + DWORD rbc; SetConsoleCursorPosition(hCSB, cpos); SetConsoleOutputCP(CP_UTF8); /* Write 2 chars which are a single character in UTF-8 but more in MBCS. */ WriteConsoleA(hCSB, TrialUtf8, sizeof(TrialUtf8), NULL, NULL); + ReadConsoleOutputCharacterW(hCSB, &aReadBack[0], 1, cpos, &rbc); GetConsoleScreenBufferInfo(hCSB, &csbInfo); SetConsoleOutputCP(ocp); CloseHandle(hCSB); } /* Return 1 if cursor advanced by 1 position, else 0. */ - return (short)(csbInfo.dwCursorPosition.X == 1); + return (short)(csbInfo.dwCursorPosition.X == 1 && aReadBack[0] == 0x022B); } static short in_console = 0; @@ -3438,7 +3441,7 @@ static void display_explain_scanstats( if( sqlite3_stmt_scanstatus_v2(p,ii,SQLITE_SCANSTAT_EXPLAIN,f,(void*)&z) ){ break; } - n = strlen(z) + scanStatsHeight(p, ii)*3; + n = (int)strlen(z) + scanStatsHeight(p, ii)*3; if( n>nWidth ) nWidth = n; } nWidth += 4; @@ -3450,12 +3453,12 @@ static void display_explain_scanstats( i64 nCycle = 0; int iId = 0; int iPid = 0; - const char *z = 0; + const char *zo = 0; const char *zName = 0; char *zText = 0; double rEst = 0.0; - if( sqlite3_stmt_scanstatus_v2(p,ii,SQLITE_SCANSTAT_EXPLAIN,f,(void*)&z) ){ + if( sqlite3_stmt_scanstatus_v2(p,ii,SQLITE_SCANSTAT_EXPLAIN,f,(void*)&zo) ){ break; } sqlite3_stmt_scanstatus_v2(p, ii, SQLITE_SCANSTAT_EST,f,(void*)&rEst); @@ -3466,7 +3469,7 @@ static void display_explain_scanstats( sqlite3_stmt_scanstatus_v2(p, ii, SQLITE_SCANSTAT_PARENTID,f,(void*)&iPid); sqlite3_stmt_scanstatus_v2(p, ii, SQLITE_SCANSTAT_NAME,f,(void*)&zName); - zText = sqlite3_mprintf("%s", z); + zText = sqlite3_mprintf("%s", zo); if( nCycle>=0 || nLoop>=0 || nRow>=0 ){ char *z = 0; if( nCycle>=0 && nTotal>0 ){ diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h index 711638099..ae0949baf 100644 --- a/src/sqlite3ext.h +++ b/src/sqlite3ext.h @@ -363,6 +363,9 @@ struct sqlite3_api_routines { int (*is_interrupted)(sqlite3*); /* Version 3.43.0 and later */ int (*stmt_explain)(sqlite3_stmt*,int); + /* Version 3.44.0 and later */ + void *(*get_clientdata)(sqlite3*,const char*); + int (*set_clientdata)(sqlite3*, const char*, void*, void(*)(void*)); }; /* @@ -693,6 +696,9 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_is_interrupted sqlite3_api->is_interrupted /* Version 3.43.0 and later */ #define sqlite3_stmt_explain sqlite3_api->stmt_explain +/* Version 3.44.0 and later */ +#define sqlite3_get_clientdata sqlite3_api->get_clientdata +#define sqlite3_set_clientdata sqlite3_api->set_clientdata #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) |