On Sun, Oct 11, 2009 at 01:22:22PM +0200, Wolfgang Enzinger scratched on the wall: > Apologies if this topic has been discussed before ... > > I just came across a surprising behaviour when executing this command: > PRAGMA journal_mode=<something>; > > I would have expected that sqlite3_step() will return SQLITE_DONE with this > command, as is the case with (AFAIK) any other PRAGMA command that assigns > a value, i.e. a "=" is contained. > > However, SQLITE_ROW ist returned instead because the command not only sets > the new value but also returns the current (?) one.
The docs for "PRAGMA journal_mode" are pretty clear on this: it returns the current mode (i.e. after the command is run) because it may not be able to change to the requested mode. > Is this behaviour intended? It can bee watched in the CLI also. Yes. Any SQL value that is "returned" is returned as a result set, i.e. a table. The only way to get result sets back out of the database using sqlite3_step() is via SQLITE_ROW. The function sqlite3_step() returns a C value, but that's an API error/result code, not a return code from the SQL command. Similar things can be seen with sqlite3_exec() or sqlite3_get_table(). If you set "PRAGMA count_changes=yes", INSERT, UPDATE, and DELETE will also cause sqlite3_step()/sqlite3_exec()/sqlite3_get_table() to return a one-row/one-column result set. Also, if you call "PRAGMA table_info( <table> )", you'll get a six-column result with one row for each column of the specified table. In all cases, these are just values returned by SQL commands. -j -- Jay A. Kreibich < J A Y @ K R E I B I.C H > "Our opponent is an alien starship packed with atomic bombs. We have a protractor." "I'll go home and see if I can scrounge up a ruler and a piece of string." --from Anathem by Neal Stephenson _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users