aboutsummaryrefslogtreecommitdiff
path: root/tool/sqldiff.c
diff options
context:
space:
mode:
authordan <dan@noemail.net>2016-03-19 16:21:26 +0000
committerdan <dan@noemail.net>2016-03-19 16:21:26 +0000
commitfebfe0230097f4bc0f57edf1d626331b2cbc1bae (patch)
tree60c837e74829aa208314f40b215574810d330cd5 /tool/sqldiff.c
parentf11737fcc86ed0044f6f4f6883266cf362071407 (diff)
downloadsqlite-febfe0230097f4bc0f57edf1d626331b2cbc1bae.tar.gz
sqlite-febfe0230097f4bc0f57edf1d626331b2cbc1bae.zip
Update the sqldiff tool so that it generates an rbu_count table.
FossilOrigin-Name: 1f7afb6e9be9f549a91bf2ab492df15698df89fd
Diffstat (limited to 'tool/sqldiff.c')
-rw-r--r--tool/sqldiff.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/tool/sqldiff.c b/tool/sqldiff.c
index d2423a73b..319acafdb 100644
--- a/tool/sqldiff.c
+++ b/tool/sqldiff.c
@@ -1244,6 +1244,7 @@ static void rbudiff_one_table(const char *zTab, FILE *out){
Str sql = {0, 0, 0}; /* Query to find differences */
Str insert = {0, 0, 0}; /* First part of output INSERT statement */
sqlite3_stmt *pStmt = 0;
+ int nRow = 0; /* Total rows in data_xxx table */
/* --rbu mode must use real primary keys. */
g.bSchemaPK = 1;
@@ -1289,6 +1290,7 @@ static void rbudiff_one_table(const char *zTab, FILE *out){
/* Output the first part of the INSERT statement */
fprintf(out, "%s", insert.z);
+ nRow++;
if( sqlite3_column_type(pStmt, nCol)==SQLITE_INTEGER ){
for(i=0; i<=nCol; i++){
@@ -1342,6 +1344,12 @@ static void rbudiff_one_table(const char *zTab, FILE *out){
}
sqlite3_finalize(pStmt);
+ if( nRow>0 ){
+ Str cnt = {0, 0, 0};
+ strPrintf(&cnt, "INSERT INTO rbu_count VALUES('data_%q', %d);", zTab, nRow);
+ fprintf(out, "%s\n", cnt.z);
+ strFree(&cnt);
+ }
strFree(&ct);
strFree(&sql);
@@ -1856,7 +1864,13 @@ int main(int argc, char **argv){
}
if( neverUseTransaction ) useTransaction = 0;
- if( useTransaction ) printf("BEGIN TRANSACTION;\n");
+ if( useTransaction ) fprintf(out, "BEGIN TRANSACTION;\n");
+ if( xDiff==rbudiff_one_table ){
+ fprintf(out, "CREATE TABLE IF NOT EXISTS rbu_count"
+ "(tbl TEXT PRIMARY KEY COLLATE NOCASE, cnt INTEGER) "
+ "WITHOUT ROWID;\n"
+ );
+ }
if( zTab ){
xDiff(zTab, out);
}else{