@@ -365,6 +365,11 @@ void sqlite3_fsetmode(FILE *stream, int mode);
365365** use O_U8TEXT when writing to the Windows console (or anything
366366** else for which _isatty() returns true) and to use O_BINARY or O_TEXT
367367** for all other output channels.
368+ **
369+ ** The SQLITE_USE_W32_FOR_CONSOLE_IO macro is also available. If
370+ ** defined, it forces the use of Win32 APIs for all console I/O, both
371+ ** input and output. This is necessary for some non-Microsoft run-times
372+ ** that implement stdio differently from Microsoft/Visual-Studio.
368373*/
369374#if defined(SQLITE_U8TEXT_ONLY)
370375# define UseWtextForOutput(fd) 1
@@ -467,10 +472,10 @@ char *sqlite3_fgets(char *buf, int sz, FILE *in){
467472 */
468473 wchar_t *b1 = sqlite3_malloc( sz*sizeof(wchar_t) );
469474 if( b1==0 ) return 0;
470- #ifndef SQLITE_USE_STDIO_FOR_CONSOLE
475+ #ifdef SQLITE_USE_W32_FOR_CONSOLE_IO
471476 DWORD nRead = 0;
472477 if( IsConsole(in)
473- && ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), b1, sz, &nRead, 0)
478+ && ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), b1, sz-1 , &nRead, 0)
474479 ){
475480 b1[nRead] = 0;
476481 }else
@@ -545,7 +550,7 @@ int sqlite3_fputs(const char *z, FILE *out){
545550 sz = MultiByteToWideChar(CP_UTF8, 0, z, sz, b1, sz);
546551 b1[sz] = 0;
547552
548- #ifndef SQLITE_STDIO_FOR_CONSOLE
553+ #ifdef SQLITE_USE_W32_FOR_CONSOLE_IO
549554 DWORD nWr = 0;
550555 if( IsConsole(out)
551556 && WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE),b1,sz,&nWr,0)
@@ -555,8 +560,9 @@ int sqlite3_fputs(const char *z, FILE *out){
555560 }else
556561#endif
557562 {
558- /* For non-console I/O, or if SQLITE_USE_STDIO_FOR_CONSOLE is defined
559- ** then write using the standard library. */
563+ /* As long as SQLITE_USE_W32_FOR_CONSOLE_IO is not defined, or for
564+ ** non-console I/O even if that macro is defined, write using the
565+ ** standard library. */
560566 _setmode(_fileno(out), _O_U8TEXT);
561567 if( UseBinaryWText(out) ){
562568 piecemealOutput(b1, sz, out);
@@ -5322,7 +5328,7 @@ static u8* fromBase64( char *pIn, int ncIn, u8 *pOut ){
53225328 deliberate_fall_through; /* FALLTHRU */
53235329 case 1:
53245330 pOut[0] = (qv>>16) & 0xff;
5325- deliberate_fall_through; /* FALLTHRU */
5331+ break;
53265332 }
53275333 pOut += nbo;
53285334 }
@@ -17207,7 +17213,7 @@ static void vfstraceDlClose(sqlite3_vfs *pVfs, void *pHandle){
1720717213 vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
1720817214 sqlite3_vfs *pRoot = pInfo->pRootVfs;
1720917215 vfstraceOnOff(pInfo, VTR_DLCLOSE);
17210- vfstrace_printf(pInfo, "%s.xDlOpen ()\n", pInfo->zVfsName);
17216+ vfstrace_printf(pInfo, "%s.xDlClose ()\n", pInfo->zVfsName);
1721117217 pRoot->xDlClose(pRoot, pHandle);
1721217218}
1721317219
@@ -28893,6 +28899,9 @@ static int do_meta_command(char *zLine, ShellState *p){
2889328899 const char *zName;
2889428900 int op;
2889528901 } aDbConfig[] = {
28902+ { "attach_create", SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE },
28903+ { "attach_write", SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE },
28904+ { "comments", SQLITE_DBCONFIG_ENABLE_COMMENTS },
2889628905 { "defensive", SQLITE_DBCONFIG_DEFENSIVE },
2889728906 { "dqs_ddl", SQLITE_DBCONFIG_DQS_DDL },
2889828907 { "dqs_dml", SQLITE_DBCONFIG_DQS_DML },
@@ -31643,6 +31652,7 @@ static int do_meta_command(char *zLine, ShellState *p){
3164331652 { 0x04000000, 1, "NullUnusedCols" },
3164431653 { 0x08000000, 1, "OnePass" },
3164531654 { 0x10000000, 1, "OrderBySubq" },
31655+ { 0x20000000, 1, "StarQuery" },
3164631656 { 0xffffffff, 0, "All" },
3164731657 };
3164831658 unsigned int curOpt;
0 commit comments