Re: [sqlite] How to compile and load the example fts4 rank function?
I have now built the example rank function and it loads without error. However, due to the matchinfo problem I discovered (and started a new thread about) I have yet to get the example to work correctly. Instead it always prints out Error: near line 19: wrong number of arguments to function rank() The unadulterated example code with the required headers / footers and an over simplified Makefile and documentation is available here: https://github.com/coolaj86/sqlite3-fts4-rank If you would like to try it for yourselves and point out any failing in my attempt, it would be much appreciated. AJ ONeal ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] How to compile and load the example fts4 rank function?
Thanks Keith! I put up a project which is exactly the same as the example, except that it includes a full buildable example for Mac, Linux, and Windows: https://github.com/coolaj86/sqlite3-fts4-rank I also found a document on the wiki: http://www.sqlite.org/cvstrac/wiki?p=LoadableExtensions The search terms I used were 'sqlite3 loadable extensions'. The search terms that I was using before were things like 'sqlite3 custom function' and 'sqlite3 user extension'. Luckily one of my searches lead me to a forum which linked to the wiki. AJ ONeal ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] How to compile and load the example fts4 rank function?
You need to wrap the rankfunc code with code to link back into the engine. You then need to define DLL_EXPORT to whatever (if anything) your platform compiler needs to generate an external shared library symbol, and then compile as a shared library. The code basically sets up the linkage necessary to let the extension reference the sqlite3 functions. The sqlite3_extension_init is called when you .load the module. It initializes the linkage then calls the function which registers "rankfunc" in the C code as the function "rank" in SQLite's SQL engine. I haven't any experience with MAC OS X do I don't know how you build a dynamic library on a mac. You should be able to look at how the sqlite3 library itself is built and duplicate that, however. #ifdef __cplusplus extern "C" { #endif #ifndef SQLITE_PRIVATE #define SQLITE_PRIVATE static #endif #ifdef SQLITE_CORE #include "sqlite3.h" #else #include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 #endif // (rankfunc code as SQLITE_PRIVATE) #ifndef SQLITE_CORE SQLITE_PRIVATE #endif int sqlite3_sqlfunc_init(sqlite3 *db) { int nErr = 0; nErr += sqlite3_create_function(db, "rank", 0, SQLITE_ANY, 0, rankfunc, 0, 0); return nErr ? SQLITE_ERROR : SQLITE_OK; } #ifndef SQLITE_CORE DLL_EXPORT int sqlite3_extension_init(sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi) { SQLITE_EXTENSION_INIT2(pApi) return sqlite3_sqlfunc_init(db); } #endif #ifdef __cplusplus } #endif --- () ascii ribbon campaign against html e-mail /\ www.asciiribbon.org > -Original Message- > From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users- > boun...@sqlite.org] On Behalf Of AJ ONeal > Sent: Saturday, 21 July, 2012 10:43 > To: General Discussion of SQLite Database; d...@sqlite.org > Subject: Re: [sqlite] How to compile and load the example fts4 rank function? > > That example isn't from a 3rd party. It's the rank function listed here: > http://www.sqlite.org/fts3.html#appendix_a > > Can you give me a link to documentation for what options to pass to gcc and > what functions to call to activate such an extension? > > I've never done this before. > > AJ ONeal > > On Sat, Jul 21, 2012 at 10:34 AM, Richard Hipp wrote: > > > On Sat, Jul 21, 2012 at 3:36 AM, AJ ONeal wrote: > > > > > I naively tried > > > > > > wget > > > > > > > > > https://raw.github.com/gist/3154964/d570955d45580c095c99de6eb0c378395d4b076d/ > sqlite3-fts4-rank.c > > > gcc -c sqlite3-fts4-rank.c -o sqlite3-fts4-rank.o > > > > > > sqlite3 > > > .load sqlite3-fts4-rank.o > > > > > > But that didn't work. > > > > > > Can I get a link to the docs on this? I don't think I was using the right > > > search terms to find it. > > > > > > > Anything you find on GitHub is put there by a private third-party and is > > not endorsed or supported by the SQLite core team. This doesn't mean it is > > bad or deficient - it might be great software. It also doesn't mean you > > cannot get help for it on this mailing list, since lots of people hang out > > here who might know what you are talking about. Just understand that what > > you are working with is not part of the SQLite core and is thus likely to > > be unknown to a large percentage of the readers of this list, so don't be > > disappointed if you don't get a quick response. Also, please don't blame > > us if it lacks appropriate documentation or doesn't work so well. Thanks. > > > > > > > > > > > > AJ ONeal > > > ___ > > > sqlite-users mailing list > > > sqlite-users@sqlite.org > > > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > > > > > > > > > > -- > > D. Richard Hipp > > d...@sqlite.org > > ___ > > sqlite-users mailing list > > sqlite-users@sqlite.org > > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] How to compile and load the example fts4 rank function?
On 21 Jul 2012 at 17:51, Pavel Ivanov wrote: > On Sat, Jul 21, 2012 at 3:36 AM, AJ ONeal wrote: >> I naively tried >> >> wget >> https://raw.github.com/gist/3154964/d570955d45580c095c99de6eb0c378395d4b076d/ >> sqlite3-fts4-rank.c >> gcc -c sqlite3-fts4-rank.c -o sqlite3-fts4-rank.o >> >> sqlite3 >> .load sqlite3-fts4-rank.o >> >> But that didn't work. >> >> Can I get a link to the docs on this? I don't think I was using the right >> search terms to find it. > > You cannot load an object file, you should load a shared library (*.so > on Linux). If it's OS X then I'd suggest making an Xcode project to create a dynamic library (.dylib) and try loading that. (I expect you can do that directly without needing Xcode but I've no idea how). -- Cheers -- Tim ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] How to compile and load the example fts4 rank function?
On Sat, Jul 21, 2012 at 3:36 AM, AJ ONeal wrote: > I naively tried > > wget > https://raw.github.com/gist/3154964/d570955d45580c095c99de6eb0c378395d4b076d/sqlite3-fts4-rank.c > gcc -c sqlite3-fts4-rank.c -o sqlite3-fts4-rank.o > > sqlite3 > .load sqlite3-fts4-rank.o > > But that didn't work. > > Can I get a link to the docs on this? I don't think I was using the right > search terms to find it. You cannot load an object file, you should load a shared library (*.so on Linux). Pavel ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] How to compile and load the example fts4 rank function?
That example isn't from a 3rd party. It's the rank function listed here: http://www.sqlite.org/fts3.html#appendix_a Can you give me a link to documentation for what options to pass to gcc and what functions to call to activate such an extension? I've never done this before. AJ ONeal On Sat, Jul 21, 2012 at 10:34 AM, Richard Hipp wrote: > On Sat, Jul 21, 2012 at 3:36 AM, AJ ONeal wrote: > > > I naively tried > > > > wget > > > > > https://raw.github.com/gist/3154964/d570955d45580c095c99de6eb0c378395d4b076d/sqlite3-fts4-rank.c > > gcc -c sqlite3-fts4-rank.c -o sqlite3-fts4-rank.o > > > > sqlite3 > > .load sqlite3-fts4-rank.o > > > > But that didn't work. > > > > Can I get a link to the docs on this? I don't think I was using the right > > search terms to find it. > > > > Anything you find on GitHub is put there by a private third-party and is > not endorsed or supported by the SQLite core team. This doesn't mean it is > bad or deficient - it might be great software. It also doesn't mean you > cannot get help for it on this mailing list, since lots of people hang out > here who might know what you are talking about. Just understand that what > you are working with is not part of the SQLite core and is thus likely to > be unknown to a large percentage of the readers of this list, so don't be > disappointed if you don't get a quick response. Also, please don't blame > us if it lacks appropriate documentation or doesn't work so well. Thanks. > > > > > > > AJ ONeal > > ___ > > sqlite-users mailing list > > sqlite-users@sqlite.org > > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > > > > > -- > D. Richard Hipp > d...@sqlite.org > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] How to compile and load the example fts4 rank function?
On Sat, Jul 21, 2012 at 3:36 AM, AJ ONeal wrote: > I naively tried > > wget > > https://raw.github.com/gist/3154964/d570955d45580c095c99de6eb0c378395d4b076d/sqlite3-fts4-rank.c > gcc -c sqlite3-fts4-rank.c -o sqlite3-fts4-rank.o > > sqlite3 > .load sqlite3-fts4-rank.o > > But that didn't work. > > Can I get a link to the docs on this? I don't think I was using the right > search terms to find it. > Anything you find on GitHub is put there by a private third-party and is not endorsed or supported by the SQLite core team. This doesn't mean it is bad or deficient - it might be great software. It also doesn't mean you cannot get help for it on this mailing list, since lots of people hang out here who might know what you are talking about. Just understand that what you are working with is not part of the SQLite core and is thus likely to be unknown to a large percentage of the readers of this list, so don't be disappointed if you don't get a quick response. Also, please don't blame us if it lacks appropriate documentation or doesn't work so well. Thanks. > > AJ ONeal > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > -- D. Richard Hipp d...@sqlite.org ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users