From: larrybr Date: Sat, 10 Jul 2021 14:48:46 +0000 (+0000) Subject: .tables fixup for legacy behavior. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b0e5e7b34ae2efb2e2f91e082d75e6dbd1437113;p=thirdparty%2Fsqlite.git .tables fixup for legacy behavior. FossilOrigin-Name: 827ea61d7d509fb6356aeab9e4fdd7619c1eeb4e8860d71ccb79a91737f9dde9 --- diff --git a/manifest b/manifest index 880d94f6f9..2fbccccde9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Migration\sto\sdispatched\smeta-commands\sdone -D 2021-07-10T03:42:25.739 +C .tables\sfixup\sfor\slegacy\sbehavior. +D 2021-07-10T14:48:46.041 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -545,7 +545,7 @@ F src/random.c 097dc8b31b8fba5a9aca1697aeb9fd82078ec91be734c16bffda620ced7ab83c F src/resolve.c b379c5ffe3b692e9c64fa37817cc0efa204b7c9468a818309dde85fd132d9d81 F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92 F src/select.c 4fa607bab6bcc580f12dbaf9c800b2250a1e408f10321a1d3bcb1dd30c447e62 -F src/shell.c.in e295faf6461b1f8051bc9cbeaf6af32479d8d760bdf6abf634dc3f9223ab8ced +F src/shell.c.in cc7c2c8a88af743a2af7e199b2e008c210347949567f74b49d9cfbc31daf3c6e F src/sqlite.h.in ecf5aa981da30c33da3e9f353bf3ebf055d3c380c80d6a4f954e58d18ccd6df1 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h e97f4e9b509408fea4c4e9bef5a41608dfac343b4d3c7a990dedde1e19af9510 @@ -1919,8 +1919,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 8bdd5fbf127e886d4d8dad2775c37d6591e8e24916250774f04dc8cf5951a8a9 -Q +eb8af9a494fb68c0a1c600b3ac71467645b51b296fc6e2116d7d855319d59a59 -R f6369e9d4f17df61dcbdb205a971c4d7 +P ac4267da196020b41f736b72e8ddc97e8e83be5e97e23caabd107a5a6d832921 +R 05b05996f39d22bb5178c3e0aab92706 U larrybr -Z 50d34173cba64575d4cc49626deb4b67 +Z 00b8639d40cc18fa56382ef7ba39d140 diff --git a/manifest.uuid b/manifest.uuid index 2ab2bf2d51..28318af3e6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ac4267da196020b41f736b72e8ddc97e8e83be5e97e23caabd107a5a6d832921 \ No newline at end of file +827ea61d7d509fb6356aeab9e4fdd7619c1eeb4e8860d71ccb79a91737f9dde9 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index be3d9ed03b..8ba84b1c45 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -9781,8 +9781,12 @@ COLLECT_HELP_TEXT[ ".indexes ?TABLE? Show names of indexes", " If TABLE is specified, only show indexes for", " tables matching TABLE using the LIKE operator.", +#ifndef LEGACY_TABLES_LISTING + ".tables ?FLAG? ?TABLE? List names of tables/views matching LIKE pattern TABLE", + " FLAG can be -t to list tables only or -v to list views only", +#else ".tables ?TABLE? List names of tables/views matching LIKE pattern TABLE", - ".views ?VIEW List names of only views matching LIKE pattern TABLE", +#endif ]; static int showTableLike(char *azArg[], int nArg, ShellState *p, char ot){ int rc; @@ -9809,6 +9813,7 @@ static int showTableLike(char *azArg[], int nArg, ShellState *p, char ot){ } for(ii=0; sqlite3_step(pStmt)==SQLITE_ROW; ii++){ const char *zDbName = (const char*)sqlite3_column_text(pStmt, 1); + const char *zFilter = ""; if( zDbName==0 ) continue; if( s.z && s.z[0] ) appendText(&s, " UNION ALL ", 0); if( sqlite3_stricmp(zDbName, "main")==0 ){ @@ -9820,19 +9825,27 @@ static int showTableLike(char *azArg[], int nArg, ShellState *p, char ot){ } appendText(&s, zDbName, '"'); appendText(&s, ".sqlite_schema ", 0); - if( ot=='i' ){ - appendText(&s," WHERE type='index'" - " AND tbl_name LIKE ?1", 0); - }else{ - appendText(&s," WHERE type IN ('view'", 0); - if( ot=='t' ){ - appendText(&s, ",'table'", 0); - } - appendText(&s, ") AND name NOT LIKE 'sqlite_%'" - " AND name LIKE ?1" - " AND name NOT LIKE 'sqlite_%'" - " AND name LIKE ?1", 0); + switch (ot) { + case 'i': + zFilter = "'index'"; + break; +#ifndef LEGACY_TABLES_LISTING + case 't': + zFilter = "'table'"; + break; + case 'v': + zFilter = "'view'"; + break; +#endif + case 'T': + zFilter = "'table','view'"; + break; + default: + assert(0); } + appendText(&s, " WHERE type IN(", 0); + appendText(&s, zFilter, 0); + appendText(&s, ") AND name LIKE ?1 AND name NOT LIKE 'sqlite_%'", 0); } rc = sqlite3_finalize(pStmt); appendText(&s, " ORDER BY 1", 0); @@ -9892,11 +9905,24 @@ static int showTableLike(char *azArg[], int nArg, ShellState *p, char ot){ sqlite3_free(azResult); return 0; } -DISPATCHABLE_COMMAND( tables 2 1 2 ){ - return showTableLike(azArg, nArg, p, 't'); -} -DISPATCHABLE_COMMAND( views 2 1 2 ){ - return showTableLike(azArg, nArg, p, 'v'); +DISPATCHABLE_COMMAND( tables 2 1 3 ){ + char objType = 'T'; +#ifndef LEGACY_TABLES_LISTING + if( nArg>1 && azArg[1][0]=='-' && azArg[1][1]!=0 && azArg[1][2]==0 ){ + char c = azArg[1][1]; + switch (c){ + case 't': + case 'v': + objType = c; + ++azArg; + --nArg; + break; + default: + return INVALID_ARGS; + } + } +#endif + return showTableLike(azArg, nArg, p, objType); } DISPATCHABLE_COMMAND( indexes 3 1 2 ){ return showTableLike(azArg, nArg, p, 'i');