Creating a custom sqlite3 function in a Qt program



  • Hello,

    In a Qt 5.2 program I open an SQLite database and I can use it well. Then I take the files in Qt source code (Src/qtbase/src/3rdparty/sqlite), I include sqlite3.h and add sqlite3.h and sqlite3.c in my .pro file. I get the handle to its driver, it is valid. Then I try to create a custom sqlite3 function. The sqlite3_create_function function gives segmentation fault. It is called like this:

    @sqlite3_create_function(handler, "funcname", 2,
    SQLITE_ANY, 0, &func, NULL, NULL);@

    The segmentation fault is given from function sqlite3_mutex_enter (line 17821 in sqlite3.c) called from sqlite3_create_function_v2 (line 116246) which is called from sqlite3_create_function (line 116229).

    @** Obtain the mutex p. If some other thread already has the mutex, block
    ** until it can be obtained.
    */
    SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex *p){
    if( p ){
    sqlite3GlobalConfig.mutex.xMutexEnter(p); // segfault here
    }
    }@

    What can I do to be able to define a custom function for my SQL?

    Thanks.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.