-C The\sschema\sname\s"main"\sis\salways\san\sacceptable\salias\sfor\sthe\sprimary\sdatabase\neven\sif\sthe\sprimary\sdatabase\sis\srenamed\susing\sSQLITE_DBCONFIG_MAINDBNAME.
-D 2016-12-24T19:37:16.675
+C Combine\sthe\simplementations\sof\sthe\s".tables"\sand\s".indexes"\scommands\sin\sthe\ncommand-line\sshell.\s\sThe\s".indexes"\scommand\snow\sputs\sthe\sindexes\sin\smultiple\ncolumns,\sjust\slike\s".tables"\sand\sshows\sall\sindexes\sin\sall\sattached\sdatabases.
+D 2016-12-24T21:32:40.591
F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da
F src/resolve.c bb070cf5f23611c44ab7e4788803684e385fc3fb
F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
F src/select.c dfb6cadc3dcfba1b1bdbfba62ebba2b4b673413e
-F src/shell.c 1594340a8c7b75751b73950f0006643d116d3ef5
+F src/shell.c 48ab675e5526903d2b7bea8c9736cafa345544e1
F src/sqlite.h.in e8e2d108d82647f0a812fdb74accf91c1ec08ddc
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 8558512e9ca343300a767ef23810f2d7b50fd925
-R b30977e76e92562c072b2b96c5549420
+P 2f481b854f04bec546eb172d1b6dbc88067d3fda
+R c83fd4223f5b56b5947d45d91cd58312
U drh
-Z d1e40bfcd22533ee4ef2e0ad49608c3a
+Z f50c0755f44c554bddf33086d9d8e98a
if( needCommit ) sqlite3_exec(p->db, "COMMIT", 0, 0, 0);
}else
- if( c=='i' && (strncmp(azArg[0], "indices", n)==0
- || strncmp(azArg[0], "indexes", n)==0) ){
- ShellState data;
- char *zErrMsg = 0;
- open_db(p, 0);
- memcpy(&data, p, sizeof(data));
- data.showHeader = 0;
- data.cMode = data.mode = MODE_List;
- if( nArg==1 ){
- rc = sqlite3_exec(p->db,
- "SELECT name FROM sqlite_master "
- "WHERE type='index' AND name NOT LIKE 'sqlite_%' "
- "UNION ALL "
- "SELECT name FROM sqlite_temp_master "
- "WHERE type='index' "
- "ORDER BY 1",
- callback, &data, &zErrMsg
- );
- }else if( nArg==2 ){
- zShellStatic = azArg[1];
- rc = sqlite3_exec(p->db,
- "SELECT name FROM sqlite_master "
- "WHERE type='index' AND tbl_name LIKE shellstatic() "
- "UNION ALL "
- "SELECT name FROM sqlite_temp_master "
- "WHERE type='index' AND tbl_name LIKE shellstatic() "
- "ORDER BY 1",
- callback, &data, &zErrMsg
- );
- zShellStatic = 0;
- }else{
- raw_printf(stderr, "Usage: .indexes ?LIKE-PATTERN?\n");
- rc = 1;
- goto meta_command_exit;
- }
- if( zErrMsg ){
- utf8_printf(stderr,"Error: %s\n", zErrMsg);
- sqlite3_free(zErrMsg);
- rc = 1;
- }else if( rc != SQLITE_OK ){
- raw_printf(stderr,
- "Error: querying sqlite_master and sqlite_temp_master\n");
- rc = 1;
- }
- }else
-
#ifndef SQLITE_UNTESTABLE
if( c=='i' && strncmp(azArg[0], "imposter", n)==0 ){
char *zSql;
}
}else
- if( c=='t' && n>1 && strncmp(azArg[0], "tables", n)==0 ){
+ if( (c=='t' && n>1 && strncmp(azArg[0], "tables", n)==0)
+ || (c=='i' && (strncmp(azArg[0], "indices", n)==0
+ || strncmp(azArg[0], "indexes", n)==0) )
+ ){
sqlite3_stmt *pStmt;
char **azResult;
int nRow, nAlloc;
/* 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". */
- zSql = sqlite3_mprintf(
- "SELECT name FROM sqlite_master"
- " WHERE type IN ('table','view')"
- " AND name NOT LIKE 'sqlite_%%'"
- " AND name LIKE ?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 ){
+ /* 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++){
const char *zDbName = (const char*)sqlite3_column_text(pStmt, 1);
if( zDbName==0 || ii==0 ) continue;
- if( strcmp(zDbName,"temp")==0 ){
+ if( c=='t' ){
zSql = sqlite3_mprintf(
"%z UNION ALL "
- "SELECT 'temp.' || name FROM sqlite_temp_master"
+ "SELECT '%q.' || name FROM \"%w\".sqlite_master"
" WHERE type IN ('table','view')"
" AND name NOT LIKE 'sqlite_%%'"
- " AND name LIKE ?1", zSql);
+ " AND name LIKE ?1", zSql, zDbName, zDbName);
}else{
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);
+ " WHERE type='index'"
+ " AND tbl_name LIKE ?1", zSql, zDbName, zDbName);
}
}
rc = sqlite3_finalize(pStmt);