mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-16 23:02:26 +03:00
Enhance the shell tool ".dump PATTERN" command so that it dumps the contents of shadow tables when a virtual table is identified by the PATTERN.
FossilOrigin-Name: b0bc5ab9ceec496ac260ccfd53b51a2b53a81576fbe04c97b99f6705b063c59f
This commit is contained in:
@@ -7739,11 +7739,26 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
sqlite3_free(zLike);
|
||||
goto meta_command_exit;
|
||||
}
|
||||
}else if( zLike ){
|
||||
zLike = sqlite3_mprintf("%z OR name LIKE %Q ESCAPE '\\'",
|
||||
zLike, azArg[i]);
|
||||
}else{
|
||||
zLike = sqlite3_mprintf("name LIKE %Q ESCAPE '\\'", azArg[i]);
|
||||
/* azArg[i] contains a LIKE pattern. This ".dump" request should
|
||||
** only dump data for tables for which either the table name matches
|
||||
** the LIKE pattern, or the table appears to be a shadow table of
|
||||
** a virtual table for which the name matches the LIKE pattern.
|
||||
*/
|
||||
char *zExpr = sqlite3_mprintf(
|
||||
"name LIKE %Q ESCAPE '\\' OR EXISTS ("
|
||||
" SELECT 1 FROM sqlite_schema WHERE "
|
||||
" name LIKE %Q ESCAPE '\\' AND"
|
||||
" sql LIKE 'CREATE VIRTUAL TABLE%%' AND"
|
||||
" substr(o.name, 1, length(name)+1) == (name||'_')"
|
||||
")", azArg[i], azArg[i]
|
||||
);
|
||||
|
||||
if( zLike ){
|
||||
zLike = sqlite3_mprintf("%z OR %z", zLike, zExpr);
|
||||
}else{
|
||||
zLike = zExpr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7765,7 +7780,7 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
p->nErr = 0;
|
||||
if( zLike==0 ) zLike = sqlite3_mprintf("true");
|
||||
zSql = sqlite3_mprintf(
|
||||
"SELECT name, type, sql FROM sqlite_schema "
|
||||
"SELECT name, type, sql FROM sqlite_schema AS o "
|
||||
"WHERE (%s) AND type=='table'"
|
||||
" AND sql NOT NULL"
|
||||
" ORDER BY tbl_name='sqlite_sequence', rowid",
|
||||
@@ -7775,7 +7790,7 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
sqlite3_free(zSql);
|
||||
if( (p->shellFlgs & SHFLG_DumpDataOnly)==0 ){
|
||||
zSql = sqlite3_mprintf(
|
||||
"SELECT sql FROM sqlite_schema "
|
||||
"SELECT sql FROM sqlite_schema AS o "
|
||||
"WHERE (%s) AND sql NOT NULL"
|
||||
" AND type IN ('index','trigger','view')",
|
||||
zLike
|
||||
|
||||
Reference in New Issue
Block a user