I don't know if this is serious, but a SAVEPOINT command fails with an open
statement handle used to execute PRAGMA journal_mode = off at SQLite 3.8.0, but
appears to succeed at SQLite 3.7.17. This does not appear to be documented.
Note that a BEGIN TRANSACTION will appear to succeed where the SAVEPOINT
appears to fail.
The program:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sqlite3.h"
/* The following program produces an error on a savepoint command at
SQLite 3.8.0, but not at SQLite 3.7.17. */
int main (int argc,
char *argv[])
{
sqlite3 *hdbc;
int s3err,row;
sqlite3_stmt *hpragma;
/* Print SQLite library release. */
printf ("\nSavepoint creation test, run at SQLite %s\n\n",sqlite3_version);
fflush (stdout);
/* Open our test database (assumed to be named sp_test.db). */
s3err = sqlite3_open_v2 ("sp_test.db",
&hdbc,
SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE,
NULL);
if (SQLITE_OK != s3err) {
fprintf (stderr,"Unable to open sp_test.db, err = %d\n",s3err);
return EXIT_FAILURE;
}
/* Start an pragma on sptest. */
s3err = sqlite3_prepare_v2 (hdbc,
"PRAGMA journal_mode = off",
-1,
&hpragma,
NULL);
if (SQLITE_OK != s3err) {
fprintf (stderr,"Unable to prepare pragma on base1, err = %d\n",s3err);
return EXIT_FAILURE;
}
/* Perform a step to execute the pragma (assuming prepare didn't). */
s3err = sqlite3_step (hpragma);
if (SQLITE_DONE != s3err && SQLITE_ROW != s3err) {
fprintf (stderr,"Error on sqlite3_step for pragma, err = %d\n",s3err);
return EXIT_FAILURE;
}
/* Try to perform a savepoint. */
s3err = sqlite3_exec (hdbc,
"SAVEPOINT doesthiswork",
NULL,
NULL,
NULL);
if (SQLITE_OK != s3err) {
const char *errmsg = sqlite3_errmsg (hdbc);
fprintf (stderr,
"Unable create savepoint, err = %d %s\n",
s3err,
errmsg);
return EXIT_FAILURE;
}
printf ("Savepoint successfully created.\n");
/* Done. */
sqlite3_finalize (hpragma);
(void) sqlite3_close (hdbc);
return EXIT_SUCCESS;
}
Peter
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users