Improvements to the ".tables" command in the command-line shell so that
it shows the name of all schemas if the name is anything other than "main". FossilOrigin-Name: c7f778b7cee16a1dcebccd256408ee1d08ef2b62e388a9ebba5738a0a89bf3a0
This commit is contained in:
parent
20c9c3f4eb
commit
594ccd09b1
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C In\sthe\scommand-line\sshell,\senhance\sthe\s".schema"\scommand\sshow\sthat\sit\nshows\sthe\sschema\sfor\sATTACH-ed\sdatabases\sin\saddition\sto\s"main".
|
||||
D 2017-06-15T12:21:09.255
|
||||
C Improvements\sto\sthe\s".tables"\scommand\sin\sthe\scommand-line\sshell\sso\sthat\nit\sshows\sthe\sname\sof\sall\sschemas\sif\sthe\sname\sis\sanything\sother\sthan\s"main".
|
||||
D 2017-06-15T12:50:47.020
|
||||
F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc
|
||||
@ -406,7 +406,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
|
||||
F src/resolve.c adf3ef9843135b1383321ad751f16f5a40c3f37925154555a3e61653d2a954e8
|
||||
F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
|
||||
F src/select.c 0d2afdbdba5fbc61432c5454a35e0236e7aa4aa3756986a7d51b81a508e8083a
|
||||
F src/shell.c 41671b1b9cfed9d1686699ae91ce6ee6e2a8cac5d148a99e2a363a209c549ad8
|
||||
F src/shell.c 9be3234b47eede8451b791c08f40dfe188b43704733ab47ef882102eb3a8a8ca
|
||||
F src/sqlite.h.in 67fa8bd29808e7988e0ce36c8d4c6043eb1727f94522fc612687aa5af51931e6
|
||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||
F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28
|
||||
@ -1582,7 +1582,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 43ad41efa9e1fdd79a9804197a227491236495f14ed56c656224d6ce181703c1
|
||||
R d9f0817a6699b9c8517903bc72312e9f
|
||||
P 48e086284a76da10a85315bc992e2294bd4711e35ec5a5abaa16e39a6a69d206
|
||||
R f0a1a3360ef0fa824ad1508573cdd91a
|
||||
U drh
|
||||
Z 79d9a69908657f1d338372f7df43a962
|
||||
Z 8b4c48c5024c7add103abe54a8cb3650
|
||||
|
@ -1 +1 @@
|
||||
48e086284a76da10a85315bc992e2294bd4711e35ec5a5abaa16e39a6a69d206
|
||||
c7f778b7cee16a1dcebccd256408ee1d08ef2b62e388a9ebba5738a0a89bf3a0
|
60
src/shell.c
60
src/shell.c
@ -6399,59 +6399,47 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
sqlite3_stmt *pStmt;
|
||||
char **azResult;
|
||||
int nRow, nAlloc;
|
||||
char *zSql = 0;
|
||||
int ii;
|
||||
ShellText s;
|
||||
initText(&s);
|
||||
open_db(p, 0);
|
||||
rc = sqlite3_prepare_v2(p->db, "PRAGMA database_list", -1, &pStmt, 0);
|
||||
if( rc ) return shellDatabaseError(p->db);
|
||||
|
||||
/* Create an SQL statement to query for the list of tables in the
|
||||
** main and all attached databases where the table name matches the
|
||||
** LIKE pattern bound to variable "?1". */
|
||||
if( c=='t' ){
|
||||
zSql = sqlite3_mprintf(
|
||||
"SELECT name FROM sqlite_master"
|
||||
" WHERE type IN ('table','view')"
|
||||
" AND name NOT LIKE 'sqlite_%%'"
|
||||
" AND name LIKE ?1");
|
||||
}else if( nArg>2 ){
|
||||
if( nArg>2 && c=='i' ){
|
||||
/* It is an historical accident that the .indexes command shows an error
|
||||
** when called with the wrong number of arguments whereas the .tables
|
||||
** command does not. */
|
||||
raw_printf(stderr, "Usage: .indexes ?LIKE-PATTERN?\n");
|
||||
rc = 1;
|
||||
goto meta_command_exit;
|
||||
}else{
|
||||
zSql = sqlite3_mprintf(
|
||||
"SELECT name FROM sqlite_master"
|
||||
" WHERE type='index'"
|
||||
" AND tbl_name LIKE ?1");
|
||||
}
|
||||
for(ii=0; zSql && sqlite3_step(pStmt)==SQLITE_ROW; ii++){
|
||||
for(ii=0; sqlite3_step(pStmt)==SQLITE_ROW; ii++){
|
||||
const char *zDbName = (const char*)sqlite3_column_text(pStmt, 1);
|
||||
if( zDbName==0 || ii==0 ) continue;
|
||||
if( c=='t' ){
|
||||
zSql = sqlite3_mprintf(
|
||||
"%z UNION ALL "
|
||||
"SELECT '%q.' || name FROM \"%w\".sqlite_master"
|
||||
" WHERE type IN ('table','view')"
|
||||
" AND name NOT LIKE 'sqlite_%%'"
|
||||
" AND name LIKE ?1", zSql, zDbName, zDbName);
|
||||
if( zDbName==0 ) continue;
|
||||
if( s.z && s.z[0] ) appendText(&s, " UNION ALL ", 0);
|
||||
if( sqlite3_stricmp(zDbName, "main")==0 ){
|
||||
appendText(&s, "SELECT name FROM ", 0);
|
||||
}else{
|
||||
zSql = sqlite3_mprintf(
|
||||
"%z UNION ALL "
|
||||
"SELECT '%q.' || name FROM \"%w\".sqlite_master"
|
||||
" WHERE type='index'"
|
||||
" AND tbl_name LIKE ?1", zSql, zDbName, zDbName);
|
||||
appendText(&s, "SELECT ", 0);
|
||||
appendText(&s, zDbName, '\'');
|
||||
appendText(&s, "||'.'||name FROM ", 0);
|
||||
}
|
||||
appendText(&s, zDbName, '"');
|
||||
appendText(&s, ".sqlite_master ", 0);
|
||||
if( c=='t' ){
|
||||
appendText(&s," WHERE type IN ('table','view')"
|
||||
" AND name NOT LIKE 'sqlite_%'"
|
||||
" AND name LIKE ?1", 0);
|
||||
}else{
|
||||
appendText(&s," WHERE type='index'"
|
||||
" AND tbl_name LIKE ?1", 0);
|
||||
}
|
||||
}
|
||||
rc = sqlite3_finalize(pStmt);
|
||||
if( zSql && rc==SQLITE_OK ){
|
||||
zSql = sqlite3_mprintf("%z ORDER BY 1", zSql);
|
||||
if( zSql ) rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
|
||||
}
|
||||
sqlite3_free(zSql);
|
||||
if( !zSql ) return shellNomemError();
|
||||
appendText(&s, " ORDER BY 1", 0);
|
||||
rc = sqlite3_prepare_v2(p->db, s.z, -1, &pStmt, 0);
|
||||
freeText(&s);
|
||||
if( rc ) return shellDatabaseError(p->db);
|
||||
|
||||
/* Run the SQL statement prepared by the above block. Store the results
|
||||
|
Loading…
Reference in New Issue
Block a user