From: larrybr Date: Fri, 4 Feb 2022 09:39:30 +0000 (+0000) Subject: Fix .param edit unable to edit script vars (bad assert) X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7f43d714ad61a42e3eddf59ffa559ffdc6370f94;p=thirdparty%2Fsqlite.git Fix .param edit unable to edit script vars (bad assert) FossilOrigin-Name: 62d212d0da93102dd3b7dc4368a0c8acf2469a7f8ef8fcf60e57e69fe028600e --- diff --git a/manifest b/manifest index 1c48fec08e..5cfd5e2c87 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Sync\sto\strunk.\sShell\stests\spass. -D 2022-02-03T21:07:01.851 +C Fix\s.param\sedit\sunable\sto\sedit\sscript\svars\s(bad\sassert) +D 2022-02-04T09:39:30.490 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -553,7 +553,7 @@ F src/random.c 097dc8b31b8fba5a9aca1697aeb9fd82078ec91be734c16bffda620ced7ab83c F src/resolve.c 0dd8e23fda88411d63b2e6650f2380fdb08e88112e9a095fc23d5a08de4b2641 F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92 F src/select.c a6d2d4bed279d7fe4fcedaf297eaf6441e8e17c6e3947a32d24d23be52ac02f2 -F src/shell.c.in af7f6c1140ad80505cdc7c5ba75399fae75d2512ee0202f1b5666805eb955929 +F src/shell.c.in e41dd781a9d11a200d3deb77d0af7983898ad41a49aa0e6d9d183d3559a8d7c4 F src/sqlite.h.in d4daed3b2deb2e43df7f12be119b1b17a2954feadc33d521565bacbd072bfcb6 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h a95cb9ed106e3d39e2118e4dcc15a14faec3fa50d0093425083d340d9dfd96e6 @@ -1943,8 +1943,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a1581118b07b111edbad8dc930a959ec0b98461b2737619d9976ef4a498b6571 f9b763042c5c4446115c5375a8e4731e522e36ad9fc53e9ef775de9bc297ea19 -R cfba6331d2a1a03f8df48b8e7d59c592 +P 79275b81dcd0c7d18b83614f42a0878fb30d93408e599574b61510fc8afa8c80 +R dab9597db7d14def1c5128b9e3768e23 U larrybr -Z d4a2473ccad2f9d355fcdba41c5a3209 +Z 4f2eaf0d0483689e49386676cb02b212 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9a82895b94..e15360fb9d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -79275b81dcd0c7d18b83614f42a0878fb30d93408e599574b61510fc8afa8c80 \ No newline at end of file +62d212d0da93102dd3b7dc4368a0c8acf2469a7f8ef8fcf60e57e69fe028600e \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 17685a1ccd..17be9dac05 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -3196,7 +3196,18 @@ static void restore_sys_schema_protection( sqlite3 *db, DbProtectState *pPS ){ } /* Partition the temp.sqlite_parameters key namespace according to use. */ -typedef enum { PTU_Binding = 0, PTU_Script, PTU_Source } ParamTableUse; +typedef enum { + PTU_Binding = 0, PTU_Script, PTU_Source, PTU_Nil +} ParamTableUse; + +static ParamTableUse classify_param_name( const char *zName ){ + char c = *zName; + switch( c ){ + case '$': case ':': case '@': case '?': return PTU_Binding; + default: return isalpha(c)? PTU_Script : PTU_Nil; + } +} + #define PARAM_TABLE_NAME "sqlite_parameters" #define PARAM_TABLE_SCHEMA "temp" #define PARAM_TABLE_SNAME PARAM_TABLE_SCHEMA"."PARAM_TABLE_NAME @@ -8189,7 +8200,7 @@ static int edit_one_param(sqlite3 *db, char *name, int eval, " key=%Q AND uses=%d", zEditor, name, uses); }else{ /* Editing a new value of same kind. */ - assert(paramVU.value==0); + assert(paramVU.value==0 || paramVU.uses!=uses); zSql = sqlite3_mprintf ("INSERT INTO "PARAM_TABLE_SNAME"(key,value,uses)" " VALUES (%Q,edit('-- %q%s', %Q),%d)", @@ -9933,6 +9944,7 @@ static int do_meta_command(char *zLine, ShellState *p){ * the way that .parameter set ... does. */ while( ia < nArg ){ + ParamTableUse ptu; char cf = (azArg[ia][0]=='-')? azArg[ia][1] : 0; if( cf!=0 && azArg[ia][2]==0 ){ ++ia; @@ -9946,7 +9958,8 @@ static int do_meta_command(char *zLine, ShellState *p){ goto meta_command_exit; } } - rc = edit_one_param(p->db, azArg[ia], eval, PTU_Binding, p->zEditor); + ptu = classify_param_name(azArg[ia]); + rc = edit_one_param(p->db, azArg[ia], eval, ptu, p->zEditor); ++ia; if( rc!=0 ) goto meta_command_exit; }