[sqlite] for function extension in sqlite3
Hi all, I'd like write extension for sqlite3 creating soundex function like below: void soundex() { ... ... } int main(int argc, char* argv[]) { int rc; sqlite3* db; rc = sqlite3_open(dbforext.db,db); if (rc) { fprintf(stderr, E' impossibile aprire il file %s\n, sqlite3_errmsg(db)); sqlite3_close(db); exit(1); } sqlite3_create_function(db, soundex, 1, SQLITE_UTF8, NULL, soundex, NULL, NULL); sqlite3_close(db); return 0; } but I have some questions: 1) The output of gcc is: bash-3.1# gcc -lsqlite3 labsinf.c -o inf labsinf.c: In function 'main': labsinf.c:61: warning: passing argument 6 of 'sqlite3_create_function' from incompatible pointer type 2) I must pass to soundex parameters for db connection, for my processing or both? 3) I need a little example of function creating in sqlite3. Thank you savio - Inviato da Yahoo! Mail. La casella di posta intelligente. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] for function extension in sqlite3
On Apr 8, 2008, at 12:57 PM, dark0s dark0s wrote: Hi all, I'd like write extension for sqlite3 creating soundex function like below: SQLite already contains a soundex function. You just have to recompile using -DSQLITE_SOUNDEX=1 D. Richard Hipp [EMAIL PROTECTED] ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] for function extension in sqlite3
I must create a extension for a exam. I don't want know how work soundex, but how make a extension D. Richard Hipp [EMAIL PROTECTED] ha scritto: On Apr 8, 2008, at 12:57 PM, dark0s dark0s wrote: Hi all, I'd like write extension for sqlite3 creating soundex function like below: SQLite already contains a soundex function. You just have to recompile using -DSQLITE_SOUNDEX=1 D. Richard Hipp [EMAIL PROTECTED] - Inviato da Yahoo! Mail. La casella di posta intelligente. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] for function extension in sqlite3
Your assignment above discards the const qualifier. It also ignores the fact that the types differ in their signedness. You should change your str variable to be a const char pointer, and then explicitly cast away the unsigned qualifier. const char *str; str = (const char*)sqlite3_value_text(...); HTH Dennis Cote - Inviato da Yahoo! Mail. La casella di posta intelligente. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] for function extension in sqlite3
No, it don't work, the output is: bash-3.1# gcc -lsqlite3 labsinf.c -o inf labsinf.c: In function 'soundex': labsinf.c:18: error: assignment of read-only location labsinf.c:22: error: assignment of read-only location labsinf.c:27: error: assignment of read-only location labsinf.c:31: error: assignment of read-only location labsinf.c:32: error: assignment of read-only location labsinf.c:33: error: assignment of read-only location labsinf.c:34: error: assignment of read-only location labsinf.c:35: error: assignment of read-only location Your assignment above discards the const qualifier. It also ignores the fact that the types differ in their signedness. You should change your str variable to be a const char pointer, and then explicitly cast away the unsigned qualifier. const char *str; str = (const char*)sqlite3_value_text(...); HTH Dennis Cote - Inviato da Yahoo! Mail. La casella di posta intelligente. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] for function extension in sqlite3
On Wed, Apr 09, 2008 at 12:09:00AM +0200, dark0s dark0s scratched on the wall: No, it don't work, the output is: bash-3.1# gcc -lsqlite3 labsinf.c -o inf labsinf.c: In function 'soundex': labsinf.c:18: error: assignment of read-only location labsinf.c:22: error: assignment of read-only location labsinf.c:27: error: assignment of read-only location labsinf.c:31: error: assignment of read-only location labsinf.c:32: error: assignment of read-only location labsinf.c:33: error: assignment of read-only location labsinf.c:34: error: assignment of read-only location labsinf.c:35: error: assignment of read-only location You're not allowed to modify the buffer referenced by sqlite3_value_text() that's why it returns a const pointer. If you want to modify the returned string, you need to make your own private copy first. -j -- Jay A. Kreibich J A Y @ K R E I B I.C H 'People who live in bamboo houses should not throw pandas.' Jesus said that. - The Ninja, www.AskANinja.com, Special Delivery 10: Pop!Tech 2006 ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users