From: drh Date: Fri, 17 Apr 2020 23:46:54 +0000 (+0000) Subject: Fix the ".excel" command and the ".open -x" and ".open -e" command so that X-Git-Tag: version-3.32.0~75 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1d9ea27f7e7e053d99745b58b9109e063b4c03ad;p=thirdparty%2Fsqlite.git Fix the ".excel" command and the ".open -x" and ".open -e" command so that they work better when running from an in-memory database and on Windows and when running from a script. FossilOrigin-Name: 07752164c2bf00b6885808533bbdb2cefbf1bf281a887b0b4f6316649a6cb810 --- diff --git a/manifest b/manifest index 32654b3149..d7bcffe5bc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\saccidentally\screated\sfork. -D 2020-04-16T15:56:03.261 +C Fix\sthe\s".excel"\scommand\sand\sthe\s".open\s-x"\sand\s".open\s-e"\scommand\sso\sthat\nthey\swork\sbetter\swhen\srunning\sfrom\san\sin-memory\sdatabase\sand\son\sWindows\nand\swhen\srunning\sfrom\sa\sscript. +D 2020-04-17T23:46:54.073 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -533,7 +533,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c d36a2b1639e1c33d7b508abfd3452a63e7fd81737f6f3940bfef085fca6f21f4 F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92 F src/select.c ab4eb1aee1bd066feea5b6eff264220ae54459019654264e9f688368a7d0c0b5 -F src/shell.c.in 792b901ae19c7cf8cbac06b3c58ef860328d0ca6d20149bdc469e5c4fc550a1d +F src/shell.c.in d615184e9a5e24da419db6bb9e60905306f45a6ceed760bdbbe656c4a684a18b F src/sqlite.h.in 4276f461ed8405630e3089b682dad77ae7a65c345d8daebcee52a13be8cd880c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 9c5269260409eb3275324ccace6a13a96f4ad330c708415f70ca6097901ff4ee @@ -1861,7 +1861,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a42fdcf54bcbd72a301dad4a040346dc48e67cacab43479ec618f5c32108c55f a9ec8c8f80a59badabb0afdb4189f0fd2934f936530d4151de395b3a7e7c1f1f -R f504f25559e67d24d7bac4ba4fbb1261 -U dan -Z bb44f1eb19ef7e1708ecd20763bc065a +P cb772b7a8fb53694cb267e74c11f49d2b9fd6920821c4e232f90ec35739c8904 +R e921db661ca4e205b542b92ef8a31312 +U drh +Z 880b12b2b5c0e130871dd9c9bbfa0760 diff --git a/manifest.uuid b/manifest.uuid index 587bd3fd29..226a3f3ebc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cb772b7a8fb53694cb267e74c11f49d2b9fd6920821c4e232f90ec35739c8904 \ No newline at end of file +07752164c2bf00b6885808533bbdb2cefbf1bf281a887b0b4f6316649a6cb810 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index b589cb4238..f492285139 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4973,11 +4973,15 @@ static void output_reset(ShellState *p){ zCmd = sqlite3_mprintf("%s %s", zXdgOpenCmd, p->zTempFile); if( system(zCmd) ){ utf8_printf(stderr, "Failed: [%s]\n", zCmd); + }else{ + /* Give the start/open/xdg-open command some time to get + ** going before we continue, and potential delete the + ** p->zTempFile data file out from under it */ + sqlite3_sleep(2000); } sqlite3_free(zCmd); outputModePop(p); p->doXdgOpen = 0; - sqlite3_sleep(100); } #endif /* !defined(SQLITE_NOHAVE_SYSTEM) */ } @@ -5267,9 +5271,21 @@ static void newTempFile(ShellState *p, const char *zSuffix){ sqlite3_file_control(p->db, 0, SQLITE_FCNTL_TEMPFILENAME, &p->zTempFile); } if( p->zTempFile==0 ){ + /* If p->db is an in-memory database then the TEMPFILENAME file-control + ** will not work and we will need to fallback to guessing */ + char *zTemp; sqlite3_uint64 r; sqlite3_randomness(sizeof(r), &r); - p->zTempFile = sqlite3_mprintf("temp%llx.%s", r, zSuffix); + zTemp = getenv("TEMP"); + if( zTemp==0 ) zTemp = getenv("TMP"); + if( zTemp==0 ){ +#ifdef _WIN32 + zTemp = "\\tmp"; +#else + zTemp = "/tmp"; +#endif + } + p->zTempFile = sqlite3_mprintf("%s/temp%llx.%s", zTemp, r, zSuffix); }else{ p->zTempFile = sqlite3_mprintf("%z.%s", p->zTempFile, zSuffix); }