In the ".sha3sum" command, if there is a LIKE pattern, show the hashes for
each table separately. Without a LIKE pattern, show a single hash over the entire database. FossilOrigin-Name: 30f878832820ce7ccc4627c4f0f98fbe82f8b0f6
This commit is contained in:
parent
1554bc8a2e
commit
3ee83efec1
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Add\sthe\s".sha3sum"\scommand\sto\sthe\sCLI\s-\sused\sto\scompute\sa\scryptographic\shash\nof\sthe\s<em>content</em>\sof\sa\sdatabase\sfile\sor\sof\sindividual\stables\swith\sin\nthat\sfile.
|
||||
D 2017-03-08T16:10:34.827
|
||||
C In\sthe\s".sha3sum"\scommand,\sif\sthere\sis\sa\sLIKE\spattern,\sshow\sthe\shashes\sfor\neach\stable\sseparately.\s\sWithout\sa\sLIKE\spattern,\sshow\sa\ssingle\shash\sover\sthe\nentire\sdatabase.
|
||||
D 2017-03-08T17:56:54.566
|
||||
F Makefile.in edb6bcdd37748d2b1c3422ff727c748df7ffe918
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc a89ea37ab5928026001569f056973b9059492fe2
|
||||
@ -400,7 +400,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
|
||||
F src/resolve.c 3e518b962d932a997fae373366880fc028c75706
|
||||
F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
|
||||
F src/select.c d12f3539f80db38b09015561b569e0eb1c4b6c5f
|
||||
F src/shell.c 8cebab1fdfb7427216c63a46d9116d31ef06dd55
|
||||
F src/shell.c bf10f16352e930e37d26813b5efbf57e89680922
|
||||
F src/sqlite.h.in 4d0c08f8640c586564a7032b259c5f69bf397850
|
||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||
F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae
|
||||
@ -1564,7 +1564,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 54ef7abd7f5b16f4b29c9519d283e142c9340fbf
|
||||
R 1784a0b42056ce37f7cf91782b133804
|
||||
P fc663799075a22b0a61a6a114116bb2d1b96d4ab
|
||||
R ce49cf9f2aa65eda762d2f7f5e9b2cf0
|
||||
U drh
|
||||
Z 89ed86e3a2610bc780c3304d2a434090
|
||||
Z a6a2f37fa5651fb024df2d5d55e36e09
|
||||
|
@ -1 +1 @@
|
||||
fc663799075a22b0a61a6a114116bb2d1b96d4ab
|
||||
30f878832820ce7ccc4627c4f0f98fbe82f8b0f6
|
37
src/shell.c
37
src/shell.c
@ -1260,6 +1260,10 @@ static void sha3QueryFunc(
|
||||
}
|
||||
nCol = sqlite3_column_count(pStmt);
|
||||
z = sqlite3_sql(pStmt);
|
||||
if( z==0 ){
|
||||
sqlite3_finalize(pStmt);
|
||||
continue;
|
||||
}
|
||||
n = (int)strlen(z);
|
||||
hash_step_vformat(&cx,"S%d:",n);
|
||||
SHA3Update(&cx,(unsigned char*)z,n);
|
||||
@ -5701,10 +5705,13 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
const char *zLike = 0; /* Which table to checksum. 0 means everything */
|
||||
int i; /* Loop counter */
|
||||
int bSchema = 0; /* Also hash the schema */
|
||||
int bSeparate = 0; /* Hash each table separately */
|
||||
int iSize = 224; /* Hash algorithm to use */
|
||||
int bDebug = 0; /* Only show the query that would have run */
|
||||
sqlite3_stmt *pStmt; /* For querying tables names */
|
||||
char *zSql; /* SQL to be run */
|
||||
char *zSep; /* Separator */
|
||||
ShellText sSql; /* Complete SQL for the query to run the hash */
|
||||
ShellText sQuery; /* Set of queries used to read all content */
|
||||
for(i=1; i<nArg; i++){
|
||||
const char *z = azArg[i];
|
||||
@ -5724,7 +5731,7 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
}else
|
||||
{
|
||||
utf8_printf(stderr, "Unknown option \"%s\" on \"%s\"\n",
|
||||
azArg[0], azArg[i]);
|
||||
azArg[i], azArg[0]);
|
||||
raw_printf(stderr, "Should be one of: --schema"
|
||||
" --sha3-224 --sha3-255 --sha3-384 --sha3-512\n");
|
||||
rc = 1;
|
||||
@ -5736,7 +5743,8 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
goto meta_command_exit;
|
||||
}else{
|
||||
zLike = z;
|
||||
if( sqlite3_strlike("sqlite3_%", zLike, 0)==0 ) bSchema = 1;
|
||||
bSeparate = 1;
|
||||
if( sqlite3_strlike("sqlite_%", zLike, 0)==0 ) bSchema = 1;
|
||||
}
|
||||
}
|
||||
if( bSchema ){
|
||||
@ -5752,6 +5760,9 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
}
|
||||
sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
|
||||
initText(&sQuery);
|
||||
initText(&sSql);
|
||||
appendText(&sSql, "WITH [sha3sum$query](a,b) AS(",0);
|
||||
zSep = "VALUES(";
|
||||
while( SQLITE_ROW==sqlite3_step(pStmt) ){
|
||||
const char *zTab = (const char*)sqlite3_column_text(pStmt,0);
|
||||
if( zLike && sqlite3_strlike(zLike, zTab, 0)!=0 ) continue;
|
||||
@ -5774,11 +5785,29 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
appendText(&sQuery, zTab, 0);
|
||||
appendText(&sQuery, " ORDER BY tbl, idx, rowid;\n", 0);
|
||||
}
|
||||
appendText(&sSql, zSep, 0);
|
||||
appendText(&sSql, sQuery.z, '\'');
|
||||
sQuery.n = 0;
|
||||
appendText(&sSql, ",", 0);
|
||||
appendText(&sSql, zTab, '\'');
|
||||
zSep = "),(";
|
||||
}
|
||||
sqlite3_finalize(pStmt);
|
||||
zSql = sqlite3_mprintf("SELECT lower(hex(sha3_query(%Q,%d))) AS hash;",
|
||||
sQuery.z, iSize);
|
||||
if( bSeparate ){
|
||||
zSql = sqlite3_mprintf(
|
||||
"%s))"
|
||||
" SELECT lower(hex(sha3_query(a,%d))) AS hash, b AS label"
|
||||
" FROM [sha3sum$query]",
|
||||
sSql.z, iSize);
|
||||
}else{
|
||||
zSql = sqlite3_mprintf(
|
||||
"%s))"
|
||||
" SELECT lower(hex(sha3_query(group_concat(a,''),%d))) AS hash"
|
||||
" FROM [sha3sum$query]",
|
||||
sSql.z, iSize);
|
||||
}
|
||||
freeText(&sQuery);
|
||||
freeText(&sSql);
|
||||
if( bDebug ){
|
||||
utf8_printf(p->out, "%s\n", zSql);
|
||||
}else{
|
||||
|
Loading…
x
Reference in New Issue
Block a user