mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Update the sqldiff tool so that it generates an rbu_count table.
FossilOrigin-Name: 1f7afb6e9be9f549a91bf2ab492df15698df89fd
This commit is contained in:
@ -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{
|
||||
|
Reference in New Issue
Block a user