]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
added shell command ".databases" to list name and file of open ones. (CVS 953)
authorjplyon <jplyon@noemail.net>
Sun, 4 May 2003 07:25:57 +0000 (07:25 +0000)
committerjplyon <jplyon@noemail.net>
Sun, 4 May 2003 07:25:57 +0000 (07:25 +0000)
FossilOrigin-Name: 741a5a8d3975fb5db18914b7879b12aead59279b

manifest
manifest.uuid
src/shell.c

index e15d2e4885a807b6bce24cb6ec601d955b5a0847..58bc89bf2ec2acd61544d8fd2fffed68b0b3bb4b 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C new\ssection\sfor\skeywords,\smore\sdocs\sfor\sattached\sdatabases\s,\slinks,\scleanup\s(CVS\s952)
-D 2003-05-04T07:02:55
+C added\sshell\scommand\s".databases"\sto\slist\sname\sand\sfile\sof\sopen\sones.\s(CVS\s953)
+D 2003-05-04T07:25:58
 F Makefile.in 004acec253ecdde985c8ecd5b7c9accdb210378f
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -44,7 +44,7 @@ F src/pragma.c 118fe400d71b7fdcc03580d5eab6bb5aa00772a5
 F src/printf.c fc5fdef6e92ad205005263661fe9716f55a49f3e
 F src/random.c 19e8e00fe0df32a742f115773f57651be327cabe
 F src/select.c 3fe63e3a29df661ba72a67eecd77e8ee82801def
-F src/shell.c 6f59240f69e65a1c4e1d06492eb9238092defc34
+F src/shell.c c53ff468787109cf178c6b14ecb7a78654018fd1
 F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
 F src/sqlite.h.in eec06462cba262c0ee03f38462a18a4bc66dda4e
 F src/sqliteInt.h a3d84942dacaf72fbe1426adfbd37e8cf5f57e97
@@ -165,7 +165,7 @@ F www/speed.tcl cb4c10a722614aea76d2c51f32ee43400d5951be
 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P 24b9b569240d2108b17420d85cafdc718c67269f
-R f59caf097b77c12dfe5196947fa850d1
+P 87e1b6a936972670771cf90670aeb4308ba0a30a
+R 5320898e74f5e804dcf5efe20f5cd8de
 U jplyon
-Z 15d8de3d7ad598167e85986bd9fd5378
+Z 6095dc4d8b2b48d4029c4d0dd1f58135
index ed71258db1f8a0fc1b35c6ff2eebc0ade8f70255..edc44f36f7adeb032c745d7068e116fdddd4b519 100644 (file)
@@ -1 +1 @@
-87e1b6a936972670771cf90670aeb4308ba0a30a
\ No newline at end of file
+741a5a8d3975fb5db18914b7879b12aead59279b
\ No newline at end of file
index 2be8ccbfe4fb0170e672d29b2bb5b86fe6e22ad3..6d261a844c4e1a2ae128664d68432d6abe9f96cd 100644 (file)
 ** This file contains code to implement the "sqlite" command line
 ** utility for accessing SQLite databases.
 **
-** $Id: shell.c,v 1.75 2003/04/30 11:38:26 drh Exp $
+** $Id: shell.c,v 1.76 2003/05/04 07:25:58 jplyon Exp $
 */
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include "sqlite.h"
+#include "sqliteInt.h"
 #include <ctype.h>
 
 #if !defined(_WIN32) && !defined(WIN32) && !defined(__MACOS__)
@@ -472,7 +473,8 @@ static int dump_callback(void *pArg, int nArg, char **azArg, char **azCol){
 ** Text of a help message
 */
 static char zHelp[] =
-  ".dump ?TABLE? ...      Dump the database in an text format\n"
+  ".databases             List names and files of attached databases\n"
+  ".dump ?TABLE? ...      Dump the database in a text format\n"
   ".echo ON|OFF           Turn command echo on or off\n"
   ".exit                  Exit this program\n"
   ".explain ON|OFF        Turn output mode suitable for EXPLAIN on or off.\n"
@@ -560,6 +562,20 @@ static int do_meta_command(char *zLine, struct callback_data *p){
   if( nArg==0 ) return rc;
   n = strlen(azArg[0]);
   c = azArg[0][0];
+  if( c=='d' && n>1 && strncmp(azArg[0], "databases", n)==0 ){
+    int i;
+    open_db(p);
+    fprintf(p->out, "[Name]\t[File]\n");
+    for(i=0; i<db->nDb; i++){
+      sqlite *db = p->db;
+      Db *pDb = &db->aDb[i];
+      BtOps* pOps = btOps(pDb->pBt);
+      const char *zName = pDb->zName;
+      const char *zFilename = pOps->GetFilename(pDb->pBt);
+      fprintf(p->out, "%s\t%s\n", zName, zFilename);
+    }
+  }else
+
   if( c=='d' && strncmp(azArg[0], "dump", n)==0 ){
     char *zErrMsg = 0;
     open_db(p);