@@ -357,6 +357,11 @@ void sqlite3_fsetmode(FILE *stream, int mode);
357357** use O_U8TEXT when writing to the Windows console (or anything
358358** else for which _isatty() returns true) and to use O_BINARY or O_TEXT
359359** for all other output channels.
360+ **
361+ ** The SQLITE_USE_W32_FOR_CONSOLE_IO macro is also available. If
362+ ** defined, it forces the use of Win32 APIs for all console I/O, both
363+ ** input and output. This is necessary for some non-Microsoft run-times
364+ ** that implement stdio differently from Microsoft/Visual-Studio.
360365*/
361366#if defined(SQLITE_U8TEXT_ONLY)
362367# define UseWtextForOutput(fd) 1
@@ -459,10 +464,10 @@ char *sqlite3_fgets(char *buf, int sz, FILE *in){
459464 */
460465 wchar_t *b1 = sqlite3_malloc( sz*sizeof(wchar_t) );
461466 if( b1==0 ) return 0;
462- #ifndef SQLITE_USE_STDIO_FOR_CONSOLE
467+ #ifdef SQLITE_USE_W32_FOR_CONSOLE_IO
463468 DWORD nRead = 0;
464469 if( IsConsole(in)
465- && ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), b1, sz, &nRead, 0)
470+ && ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), b1, sz-1 , &nRead, 0)
466471 ){
467472 b1[nRead] = 0;
468473 }else
@@ -537,7 +542,7 @@ int sqlite3_fputs(const char *z, FILE *out){
537542 sz = MultiByteToWideChar(CP_UTF8, 0, z, sz, b1, sz);
538543 b1[sz] = 0;
539544
540- #ifndef SQLITE_STDIO_FOR_CONSOLE
545+ #ifdef SQLITE_USE_W32_FOR_CONSOLE_IO
541546 DWORD nWr = 0;
542547 if( IsConsole(out)
543548 && WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE),b1,sz,&nWr,0)
@@ -547,8 +552,9 @@ int sqlite3_fputs(const char *z, FILE *out){
547552 }else
548553#endif
549554 {
550- /* For non-console I/O, or if SQLITE_USE_STDIO_FOR_CONSOLE is defined
551- ** then write using the standard library. */
555+ /* As long as SQLITE_USE_W32_FOR_CONSOLE_IO is not defined, or for
556+ ** non-console I/O even if that macro is defined, write using the
557+ ** standard library. */
552558 _setmode(_fileno(out), _O_U8TEXT);
553559 if( UseBinaryWText(out) ){
554560 piecemealOutput(b1, sz, out);
@@ -5314,7 +5320,7 @@ static u8* fromBase64( char *pIn, int ncIn, u8 *pOut ){
53145320 deliberate_fall_through; /* FALLTHRU */
53155321 case 1:
53165322 pOut[0] = (qv>>16) & 0xff;
5317- deliberate_fall_through; /* FALLTHRU */
5323+ break;
53185324 }
53195325 pOut += nbo;
53205326 }
@@ -17199,7 +17205,7 @@ static void vfstraceDlClose(sqlite3_vfs *pVfs, void *pHandle){
1719917205 vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
1720017206 sqlite3_vfs *pRoot = pInfo->pRootVfs;
1720117207 vfstraceOnOff(pInfo, VTR_DLCLOSE);
17202- vfstrace_printf(pInfo, "%s.xDlOpen ()\n", pInfo->zVfsName);
17208+ vfstrace_printf(pInfo, "%s.xDlClose ()\n", pInfo->zVfsName);
1720317209 pRoot->xDlClose(pRoot, pHandle);
1720417210}
1720517211
@@ -28885,6 +28891,9 @@ static int do_meta_command(char *zLine, ShellState *p){
2888528891 const char *zName;
2888628892 int op;
2888728893 } aDbConfig[] = {
28894+ { "attach_create", SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE },
28895+ { "attach_write", SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE },
28896+ { "comments", SQLITE_DBCONFIG_ENABLE_COMMENTS },
2888828897 { "defensive", SQLITE_DBCONFIG_DEFENSIVE },
2888928898 { "dqs_ddl", SQLITE_DBCONFIG_DQS_DDL },
2889028899 { "dqs_dml", SQLITE_DBCONFIG_DQS_DML },
@@ -31635,6 +31644,7 @@ static int do_meta_command(char *zLine, ShellState *p){
3163531644 { 0x04000000, 1, "NullUnusedCols" },
3163631645 { 0x08000000, 1, "OnePass" },
3163731646 { 0x10000000, 1, "OrderBySubq" },
31647+ { 0x20000000, 1, "StarQuery" },
3163831648 { 0xffffffff, 0, "All" },
3163931649 };
3164031650 unsigned int curOpt;
0 commit comments