Add the ".changes ON|OFF" command to the sqlite3.exe command-line shell, for

testing and verifying the sqlite3_changes() and
sqlite3_total_changes() interfaces.

FossilOrigin-Name: 9bbe1afc1521b111a0a93803b41ff04e0ee55630
This commit is contained in:
drh 2015-12-07 21:46:19 +00:00
parent dc27851e21
commit df12f1c69b
3 changed files with 21 additions and 7 deletions

View File

@ -1,5 +1,5 @@
C Fix\sthe\sopenDirectory()\sroutine\sin\sthe\sunix\sVFS\sso\sthat\sit\sworks\sfor\sdatabases\nlocated\sin\sthe\sroot\sof\sthe\sfilesystem\sand\sfor\sdatabase\sfiles\sthat\shave\sno\npathname\sat\sall.
D 2015-12-07T18:18:33.086
C Add\sthe\s".changes\sON|OFF"\scommand\sto\sthe\ssqlite3.exe\scommand-line\sshell,\sfor\ntesting\sand\sverifying\sthe\ssqlite3_changes()\sand\nsqlite3_total_changes()\sinterfaces.
D 2015-12-07T21:46:19.114
F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d
@ -340,7 +340,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696
F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f
F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
F src/select.c f8fded11fc443a9f5a73cc5db069d06b34460e2f
F src/shell.c 2796237990d42e6a5a7beafee65ef70cc8767d21
F src/shell.c abbc74ea43dbf2f306ea18282d666683fb5efab2
F src/sqlite.h.in 1248a78548024bdc8ef5893faa0ff9552b4cceb4
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d
@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P a9e819082ba19e72db03bba37edfb7702ff489a5
R 24074b14133d8cbad307bf1c20e69806
P e7ae120d04cffafd9bc2b4ecd68571c17e05ed72
R 73237b31faf24d2547a2561196384a88
U drh
Z bce64672fed9a01eb65d3786fa37a9f1
Z 44232263f2d956132c0ce354e853bbb1

View File

@ -1 +1 @@
e7ae120d04cffafd9bc2b4ecd68571c17e05ed72
9bbe1afc1521b111a0a93803b41ff04e0ee55630

View File

@ -525,6 +525,7 @@ struct ShellState {
int autoEQP; /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */
int statsOn; /* True to display memory stats before each finalize */
int scanstatsOn; /* True to display scan stats before each finalize */
int countChanges; /* True to display change counts */
int backslashOn; /* Resolve C-style \x escapes in SQL input text */
int outCount; /* Revert to stdout when reaching zero */
int cnt; /* Number of records displayed so far */
@ -1785,6 +1786,7 @@ static char zHelp[] =
".backup ?DB? FILE Backup DB (default \"main\") to FILE\n"
".bail on|off Stop after hitting an error. Default OFF\n"
".binary on|off Turn binary output on or off. Default OFF\n"
".changes on|off Show number of rows changed by SQL\n"
".clone NEWDB Clone data into NEWDB from the existing database\n"
".databases List names and files of attached databases\n"
".dbinfo ?DB? Show status information about the database\n"
@ -2757,6 +2759,15 @@ static int do_meta_command(char *zLine, ShellState *p){
test_breakpoint();
}else
if( c=='c' && n>=3 && strncmp(azArg[0], "changes", n)==0 ){
if( nArg==2 ){
p->countChanges = booleanValue(azArg[1]);
}else{
fprintf(stderr, "Usage: .changes on|off\n");
rc = 1;
}
}else
if( c=='c' && strncmp(azArg[0], "clone", n)==0 ){
if( nArg==2 ){
tryToClone(p, azArg[1]);
@ -4286,6 +4297,9 @@ static int process_input(ShellState *p, FILE *in){
fprintf(stderr, "%s %s\n", zPrefix, sqlite3_errmsg(p->db));
}
errCnt++;
}else if( p->countChanges ){
fprintf(p->out, "changes: %3d total_changes: %d\n",
sqlite3_changes(p->db), sqlite3_total_changes(p->db));
}
nSql = 0;
if( p->outCount ){