Hello,

I noticed a change in behavior of sqlite3_progress_handler for CREATE
TABLE, or rather the calls to the callbacks, and just wanted to get
clarification if this was intentional.

Specifically, given the code below for a callback that prints one "."
for each code for this: (full code below)
sqlite3_progress_handler(db, 1, progress_callback, NULL);
sqlite3_exec(db, "create table foo(a,b)", callback, 0, &zErrMsg);
\n
sqlite3_progress_handler(db, 2, progress_callback, NULL);
sqlite3_exec(db, "create table bar(a,b)", callback, 0, &zErrMsg);

I get the following:
3.7.17> ./test
..................................................................
...........................
3.8.3.1> ./test
........
.......
3.8.4> ./test
.....
.....
3.8.4.1> ./test
.....
.....

Is this intentional, a side effect of  optimization or unintended
behavior? Documentation does day the callbacks are approximate...


Thanks,
Andreas

test code follows...


#include <stdio.h>
#include <sqlite3.h>

static int callback(void *NotUsed, int argc, char **argv, char **azColName){
  int i;
  for(i=0; i<argc; i++){
    printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  }
  printf("\n");
  return 0;
}

int progress_callback(void *p) {
  printf(".");
  return 0;
}


int main(int argc, char** argv) {
  sqlite3 *db;
  char *zErrMsg = 0;
  int rc;

  rc = sqlite3_open( "test.db", &db);
  if (rc) {
    fprintf(stderr, "sqlite_open() failed: %s", sqlite3_errmsg(db));
    sqlite3_close(db);
    return 1;
  }
  sqlite3_progress_handler(db, 1, progress_callback, NULL);
  rc = sqlite3_exec(db, "create table foo(a,b)", callback, 0, &zErrMsg);
  if ( rc != SQLITE_OK ){
    fprintf(stderr, "SQL error: %s\n", zErrMsg );
    sqlite3_free(zErrMsg);
  }
  printf("\n");
  sqlite3_progress_handler(db, 2, progress_callback, NULL);
  rc = sqlite3_exec(db, "create table bar(a,b)", callback, 0, &zErrMsg);
  if ( rc != SQLITE_OK ){
    fprintf(stderr, "SQL error: %s\n", zErrMsg );
    sqlite3_free(zErrMsg);
  }
  printf("\n");
  sqlite3_close(db);
  return 0;
}
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to