From: drh <> Date: Sat, 25 Apr 2026 00:29:40 +0000 (+0000) Subject: Fix a problem in the CLI in which the ".www" command followed by X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=50811f74e031c94667368c0b0c87934fb2303ae0;p=thirdparty%2Fsqlite.git Fix a problem in the CLI in which the ".www" command followed by ".dbstat" does not restore the mode to its original setting afterwards. FossilOrigin-Name: 4a5cac1d00e1fa287ab8ce3437c0152a9f362d72bdb9976889c93f6368b3fd66 --- diff --git a/manifest b/manifest index d5c56fd67a..d1c16b5f8b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stest\scases\sdue\sto\srecent\sCLI\sdefault\sprompt\schanges.\s\sMake\ssure\sANSI\nescape\scodes\sare\srecognized\son\sWindows\sterminals. -D 2026-04-24T20:27:42.012 +C Fix\sa\sproblem\sin\sthe\sCLI\sin\swhich\sthe\s".www"\scommand\sfollowed\sby\n".dbstat"\sdoes\snot\srestore\sthe\smode\sto\sits\soriginal\ssetting\safterwards. +D 2026-04-25T00:29:40.729 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea @@ -736,7 +736,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 928ff887f2a7c64275182060d94d06fdddbe32226c569781cf7e7edc6f58d7fd F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4c05cde130f26991b7411d8c6809e0630625e18078742c963a047b4b9cc01d49 -F src/shell.c.in 8fd0b427126284c922895cb664bbc02c1eca0b0530c726ef03f61a87b605d2c6 +F src/shell.c.in 8c0b79f3311868dd1c2e15cdeffd29615d3e997831e937b1f2fd866a2604c5dc F src/sqlite.h.in 39d2e09114d2bdb7afd998f4a469c8f8cd065f8093835a7d0422f260fc78fb4f F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479 F src/sqlite3ext.h 9788c301f95370fa30e808861f1d2e6f022a816ddbe2a4f67486784c1b31db2e @@ -2203,8 +2203,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c -P 9ab0bb487f78ba5a51cd3b4efcee23b11096e90ebf3add4da18aea657e8de0b6 -R 1ee7f0f01a210bd28df579df4aa17424 +P 22b791e404f0895b0f343b2ce0e169a7ada8578e46a39a9f4bd3a31f81c9853c +R 4a307597696b5c814c850a82410492a3 U drh -Z 0c63beb0997dcd285efe96d8e49b849c +Z e597a6ae213e43c8613929f6614f25ce # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index acaf147d40..4ebd5f29d9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -22b791e404f0895b0f343b2ce0e169a7ada8578e46a39a9f4bd3a31f81c9853c +4a5cac1d00e1fa287ab8ce3437c0152a9f362d72bdb9976889c93f6368b3fd66 diff --git a/src/shell.c.in b/src/shell.c.in index 2a02a8942b..fb42d84a91 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -2108,6 +2108,14 @@ static int modeFind(ShellState *p, const char *zName){ /* ** Save or restore the current output mode */ +static void modeSave(ShellState *p, Mode *pSaveAt){ + modeDup(pSaveAt, &p->mode); +} +static void modeRestore(ShellState *p, Mode *pSaveAt){ + modeFree(&p->mode); + p->mode = *pSaveAt; + memset(pSaveAt, 0, sizeof(Mode)); +} static void modePush(ShellState *p){ if( p->nPopMode==0 ){ modeFree(&p->modePrior); @@ -2116,9 +2124,7 @@ static void modePush(ShellState *p){ } static void modePop(ShellState *p){ if( p->modePrior.spec.iVersion>0 ){ - modeFree(&p->mode); - p->mode = p->modePrior; - memset(&p->modePrior, 0, sizeof(p->modePrior)); + modeRestore(p, &p->modePrior); } } @@ -9756,6 +9762,7 @@ static int do_meta_command(const char *zLine, ShellState *p){ const char *zSchema = 0; int ii; char *zSql; + Mode savedMode; open_db(p, 0); for(ii=1; iimode.spec.nLineLimit = 0; p->mode.spec.nCharLimit = 0; p->mode.spec.nTitleLimit = 0; shell_exec(p, zSql, 0); - modePop(p); + modeRestore(p, &savedMode); sqlite3_free(zSql); }else @@ -10395,10 +10402,11 @@ static int do_meta_command(const char *zLine, ShellState *p){ if( debugFlag ){ cli_printf(stdout,"%s;\n", sqlite3_str_value(pSql)); }else{ - modePush(p); + Mode savedMode; + modeSave(p, &savedMode); modeChange(p, MODE_Split); shell_exec(p, sqlite3_str_value(pSql), 0); - modePop(p); + modeRestore(p, &savedMode); } sqlite3_str_free(pSql); }else @@ -11831,6 +11839,7 @@ static int do_meta_command(const char *zLine, ShellState *p){ sqlite3_stmt *pStmt; sqlite3_str *pSql; const char *zPattern = nArg>1 ? azArg[1] : 0; + Mode savedMode; open_db(p, 0); rc = sqlite3_prepare_v2(p->db, "PRAGMA database_list", -1, &pStmt, 0); @@ -11866,11 +11875,11 @@ static int do_meta_command(const char *zLine, ShellState *p){ } /* Run the SQL statement in "split" mode. */ - modePush(p); + modeSave(p, &savedMode); modeChange(p, MODE_Split); shell_exec(p, sqlite3_str_value(pSql), 0); sqlite3_str_free(pSql); - modePop(p); + modeRestore(p, &savedMode); if( rc ) return shellDatabaseError(p->db); }else