mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Add the --transaction option to the sqldiff tool.
FossilOrigin-Name: 8882d1f3ef0fc53d7c19918c3af43c5bdd79e88f
This commit is contained in:
@ -1741,6 +1741,7 @@ static void showHelp(void){
|
||||
" --schema Show only differences in the schema\n"
|
||||
" --summary Show only a summary of the differences\n"
|
||||
" --table TAB Show only differences in table TAB\n"
|
||||
" --transaction Show SQL output inside a transaction\n"
|
||||
);
|
||||
}
|
||||
|
||||
@ -1757,6 +1758,8 @@ int main(int argc, char **argv){
|
||||
void (*xDiff)(const char*,FILE*) = diff_one_table;
|
||||
int nExt = 0;
|
||||
char **azExt = 0;
|
||||
int useTransaction = 0;
|
||||
int neverUseTransaction = 0;
|
||||
|
||||
g.zArgv0 = argv[0];
|
||||
sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
|
||||
@ -1770,6 +1773,7 @@ int main(int argc, char **argv){
|
||||
out = fopen(argv[++i], "wb");
|
||||
if( out==0 ) cmdlineError("cannot open: %s", argv[i]);
|
||||
xDiff = changeset_one_table;
|
||||
neverUseTransaction = 1;
|
||||
}else
|
||||
if( strcmp(z,"debug")==0 ){
|
||||
if( i==argc-1 ) cmdlineError("missing argument to %s", argv[i]);
|
||||
@ -1803,6 +1807,9 @@ int main(int argc, char **argv){
|
||||
if( i==argc-1 ) cmdlineError("missing argument to %s", argv[i]);
|
||||
zTab = argv[++i];
|
||||
}else
|
||||
if( strcmp(z,"transaction")==0 ){
|
||||
useTransaction = 1;
|
||||
}else
|
||||
{
|
||||
cmdlineError("unknown option: %s", argv[i]);
|
||||
}
|
||||
@ -1845,6 +1852,8 @@ int main(int argc, char **argv){
|
||||
cmdlineError("\"%s\" does not appear to be a valid SQLite database", zDb2);
|
||||
}
|
||||
|
||||
if( neverUseTransaction ) useTransaction = 0;
|
||||
if( useTransaction ) printf("BEGIN TRANSACTION;\n");
|
||||
if( zTab ){
|
||||
xDiff(zTab, out);
|
||||
}else{
|
||||
@ -1862,6 +1871,7 @@ int main(int argc, char **argv){
|
||||
}
|
||||
sqlite3_finalize(pStmt);
|
||||
}
|
||||
if( useTransaction ) printf("COMMIT;\n");
|
||||
|
||||
/* TBD: Handle trigger differences */
|
||||
/* TBD: Handle view differences */
|
||||
|
Reference in New Issue
Block a user