Would someone, please, show me an example (several actual, successive lines of code) in C (or C++) showing a proper use of
sqlite3_auto_extension()? I have searched the web looking for examples, but there are none that I can tell. I have also, to the best of my understanding, readhttp://www.sqlite.org/c3ref/auto_extension.html numerous times and I have had no success. I am trying to use SQLite with extensionfunctions.c, but extensionfunctions.c lacks a function called "xEntryPoint()". I do not know if I am actually supposed to pass a pointer to a function called "xEntryPoint()" or not. I am leaning toward 'no' and in reality I would think "xEntryPoint()" is merely to represent some function found in extensionfunctions.c. Below is code I have tried: if (sqlite3Database) sqlite3_close(sqlite3Database); iCommandResult = sqlite3_open(":memory:",&sqlite3Database); bContinue = (iCommandResult == 0); if (bContinue) { iCommandResult = sqlite3_exec(sqlite3Database, "CREATE TABLE data_table (DataID INT, RandomData INT, V_In INT);", &GitData, 0, &cErrorMessage); ... Some Code to Fill the sqlite3Database in memory with data bContinue = (iCommandResult == 0); } if (bContinue) { iCommandResult = sqlite3_exec(sqlite3Database, "SELECT DataID, RandomData, V_In FROM data_table", &GitData, this, &cErrorMessage); } if (sqlite3Database) { iCommandResult = sqlite3_auto_extension(0); if (iCommandResult == 0) iCommandResult = sqlite3_exec(sqlite3Database, "SELECT STDEV(RandomData) AS RandomData_STDEV, V_In FROM data_table GROUP BY V_In", &GitData, this, &cErrorMessage); } Since I cannot find a function called "xEntryPoint()", I tried zero as an argument to sqlite3_auto_extension(). Not surprisingly, that did not work. Here is some more code I tried ('adapted' from the commented out help section at the top of extensionfunctions.c): if (sqlite3Database) sqlite3_close(sqlite3Database); iCommandResult = sqlite3_open(":memory:",&sqlite3Database); iCommandResult = sqlite3_enable_load_extension(sqlite3Database, 1); bContinue = (iCommandResult == 0); if (bContinue) { iCommandResult = sqlite3_exec(sqlite3Database, "CREATE TABLE data_table (DataID INT, RandomData INT, V_In INT);", &GitData, 0, &cErrorMessage); ... Some Code to Fill the sqlite3Database in memory with data bContinue = (iCommandResult == 0); } if (bContinue) { iCommandResult = sqlite3_exec(sqlite3Database, "SELECT DataID, RandomData, V_In FROM data_table", &GitData, this, &cErrorMessage); } if (sqlite3Database) { iCommandResult = sqlite3_load_extension(sqlite3Database, 0, 0, ppcLoadExtErrorMessage); if (iCommandResult == 0) iCommandResult = sqlite3_exec(sqlite3Database, "SELECT STDEV(RandomData) AS RandomData_STDEV, V_In FROM data_table GROUP BY V_In", &GitData, this, &cErrorMessage); } After executing sqlite3_load_extension, iCommandResult was set to SQLITE_ERROR (exactly what I expected), but ppcLoadExtErrorMessage was NULL, so I could not tell what the error was about. Usage instructions from top of extensionfunctions.c: Usage instructions for applications calling the sqlite3 API functions: In your application, call sqlite3_enable_load_extension(db,1) to allow loading external libraries. Then load the library libsqlitefunctions using sqlite3_load_extension; the third argument should be 0. See http://www.sqlite.org/cvstrac/wiki?p=LoadableExtensions. Select statements may now use these functions, as in SELECT cos(radians(inclination)) FROM satsum WHERE satnum = 25544; Alterations: The instructions are for Linux, Mac OS X, and Windows; users of other OSes may need to modify this procedure. In particular, if your math library lacks one or more of the needed trig or log functions, comment out the appropriate HAVE_ #define at the top of file. If you do not wish to make a loadable module, comment out the define for COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE. If you are using a version of SQLite without the trim functions and replace, comment out the HAVE_TRIM #define. I tried the above code both with and without COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE commented out. Based on reading http://www.sqlite.org/cvstrac/wiki?p=LoadableExtensions, I am confident COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE *should* be commented out to force the compiler to use "sqlite3.h" instead of "sqlite3ext.h". By the way, what does "libsqlitefunctions" mean? Is it supposed to be a generic description for an external library? Or is it a specific .h file or .c file? Anybody who is willing to share some simple lines of code would be much appreciated. ultimately, not being able to use extensionfunctions.c will not be the end of the world. Thanks Very Much! Steve. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users