Hi,

I can't get the quick_check instruction to work but I'm sure that I   
must be doing something really stupid. It seems like my callback  
function isn't invoked. I have this (just for testing) struct which  
should be initialised properly when the callback is invoked, but the  
values are always unchanged after sqlite3_exec(). Take for instance  
the struct sq member "argc". That struct member is always "-1" after  
sqlite3_exec().

Could someone help me and point out what I'm doing wrong here? I'm  
using SQlite3 3.4.0. My code is below.


Thanks a lot,
   jules



struct sq {
        int argc;
        char *argv;
};

static int
check_callback(void *hook,
               int argc,
               char **argv,
               char **azColName)
{
        struct sq *data = (struct sq*)hook;
        data->argc = argc;
        data->argv = (NULL != argv[0]) ? strdup(argv[0]) : NULL;
        
        return 0;
}

static int
quick_check(sqlite3 *db)
{
         int rc;
        struct sq db_ok;

        db_ok.argc = -1;
        db_ok.argv = NULL;

         rc = sqlite3_exec(db, "pragma quick_check;", check_callback,  
(void*)&db_ok, NULL);

        printf("%s(%d) - argc = %d", __FILE__, __LINE__, db_ok.argc);
        if (db_ok.argv)
                printf("%s(%d) - argv[0] = %s", __FILE__, __LINE__, db_ok.argv);
        else
                printf("%s(%d) - argv[0] = NULL", __FILE__, __LINE__);

         return 0;
}

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to