[sqlite] SQL error: no such function: and no such column:
bash-3.1# gcc -shared labsinf.c -o inf.so bash-3.1# sqlite3 SQLite version 3.5.7 Enter .help for instructions sqlite select load_extension('/root/inf.so'); sqlite select inf(savio); SQL error: no such column: savio sqlite select inf('savio'); SQL error: no such function: inf sqlite I tell help me for this little program: #include stdio.h #include stdlib.h #include string.h #include sqlite3ext.h SQLITE_EXTENSION_INIT1 void soundex(sqlite3_context* ctx, int nargs, sqlite3_value** values) { int i,j; char c,r; int d; int count; char* str2; char* result; int dim; const char* str; char ret[4]; str = sqlite3_value_text(values[0]); dim = strlen(str); for (i=0;idim;i++) str2[i] = str[i]; for (i=0;i=dim;i++) str2[i] = toupper(str2[i]); for (i=0;i=dim;i++) switch (str[i]) { case 'A': case 'E': case 'I': case 'O': case 'U': case 'H': case 'W': case 'Y': str2[i] = '0'; } for (i=1;idim;i++) switch (str2[i]) { case 'B': case 'F': case 'P': case 'V': str2[i] = '1'; break; case 'C': case 'G': case 'J': case 'K': case 'Q': case 'S': case 'X': case 'Z': str2[i] = '2'; break; case 'D': case 'T': str2[i] = '3'; break; case 'L': str2[i] = '4'; break; case 'M': case 'N': str2[i] = '5'; break; case 'R': str2[i] = '6'; break; } count=1; for (i=0;idim-1;i++) if (str2[i] != str2[i+1]) count++; result = malloc(count); j=0; for (i=0;idim-1;i++) if (str2[i] != str2[i+1]) { result[j]=str2[i]; j++; } // for (i=0;i4;i++) printf(%c, result[i]); for (i=0;i4;i++) ret[i] = result[i]; printf(\n\n); sqlite3_result_text(ctx,(const char*)ret, 4, SQLITE_TRANSIENT); } int sqlite3_extension_init(sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi) { SQLITE_EXTENSION_INIT2(pApi) sqlite3_create_function(db, soundex, 1, SQLITE_UTF8, NULL, soundex, NULL, NULL); return 0; } - 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
[sqlite] segmentation fault
This is last suggestion that I tell, where is the problem now for segmentation fault: bash-3.1# gcc -shared labsinf.c -o soundex.so bash-3.1# sqlite3 SQLite version 3.5.7 Enter .help for instructions sqlite select load_extension('/root/soundex.so'); sqlite select soundex('saverio'); S010 Segmentation fault bash-3.1# - 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
[sqlite] segmentation fault
How must I interpret this output: bash-3.1# gcc -O0 -g -shared labsinf.c -o soundex.so bash-3.1# gdb sqlite3 GNU gdb 6.6 Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type show copying to see the conditions. There is absolutely no warranty for GDB. Type show warranty for details. This GDB was configured as i486-slackware-linux... Using host libthread_db library /lib/libthread_db.so.1. (gdb) select load_extension('/root/soundex.so'); No symbol load_extension in current context. (gdb) select soundex('saverio'); No symbol soundex in current context. (gdb) - 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
[sqlite] segmentation fault
I did not used never gdb. Can I post me commands that I must to use (gdb) run sqlite3 Starting program: sqlite3 No executable file specified. Use the file or exec-file command. (gdb) run select load_extension('/root/soundex.so'); Starting program: select load_extension('/root/soundex.so'); No executable file specified. Use the file or exec-file command. (gdb) run select soundex('saverio'); Starting program: select soundex('saverio'); No executable file specified. Use the file or exec-file command. (gdb) (gdb) run sqlite3 Starting program: sqlite3 No executable file specified. Use the file or exec-file command. (gdb) exec-file select load_extension('/root/soundex.so'); select: No such file or directory. (gdb) You must have to do a run inside gdb to get sqlite shell working then you can get your segfault - 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
[sqlite] extension don't return value
The soundex function don't return results of your processing. My output is below: bash-3.1# gcc -shared labsinf.c -o inf.so bash-3.1# sqlite3 SQLite version 3.5.7 Enter .help for instructions sqlite select load_extension('/root/inf.so') ... select inf(savio) ... I don't understand where is the problem? in sqlite3_result_text function or in sqlite3_create_function #include stdio.h #include stdlib.h #include string.h #include sqlite3ext.h SQLITE_EXTENSION_INIT1 void soundex(sqlite3_context* ctx, int nargs, sqlite3_value** values) { int i,j; char c,r; int d; int count; char* str2; char* result; int dim; const char* str; char ret[4]; str = sqlite3_value_text(values[0]); dim = strlen(str); for (i=0;idim;i++) str2[i] = str[i]; for (i=0;i=dim;i++) str2[i] = toupper(str2[i]); for (i=0;i=dim;i++) switch (str[i]) { case 'A': case 'E': case 'I': case 'O': case 'U': case 'H': case 'W': case 'Y': str2[i] = '0'; } for (i=1;idim;i++) switch (str2[i]) { case 'B': case 'F': case 'P': case 'V': str2[i] = '1'; break; case 'C': case 'G': case 'J': case 'K': case 'Q': case 'S': case 'X': case 'Z': str2[i] = '2'; break; case 'D': case 'T': str2[i] = '3'; break; case 'L': str2[i] = '4'; break; case 'M': case 'N': str2[i] = '5'; break; case 'R': str2[i] = '6'; break; } count=1; for (i=0;idim-1;i++) if (str2[i] != str2[i+1]) count++; result = malloc(count); j=0; for (i=0;idim-1;i++) if (str2[i] != str2[i+1]) { result[j]=str2[i]; j++; } // for (i=0;i4;i++) printf(%c, result[i]); for (i=0;i4;i++) ret[i] = result[i]; printf(\n\n); sqlite3_result_text(ctx,(const char*)result, strlen(result), SQLITE_TRANSIENT); } int sqlite3_extension_init(sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi) { SQLITE_EXTENSION_INIT2(pApi) sqlite3_create_function(db, soundex, 1, SQLITE_UTF8, NULL, soundex, NULL, NULL); return 0; } Thank you in advance to help - 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
[sqlite] extension don't return value
I modified row in function: sqlite3_result_text(ctx,(const char*)ret, 4, SQLITE_TRANSIENT); I know that dimension is 4, but my shell don't return values for extension function also with half.c example copied from wiki: bash-3.1# gcc -shared half.c -o half.so bash-3.1# sqlite3 SQLite version 3.5.7 Enter .help for instructions sqlite select load_extension('/root/half.so') ... select half(7) ... select half(7); SQL error: near select: syntax error sqlite select half(7) ... half.c is below: #include sqlite3ext.h SQLITE_EXTENSION_INIT1 /* ** The half() SQL function returns half of its input value. */ static void halfFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ sqlite3_result_double(context, 0.5*sqlite3_value_double(argv[0])); } /* SQLite invokes this routine once when it loads the extension. ** Create new functions, collating sequences, and virtual table ** modules here. This is usually the only exported symbol in ** the shared library. */ int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi ){ SQLITE_EXTENSION_INIT2(pApi) sqlite3_create_function(db, half, 1, SQLITE_ANY, 0, halfFunc, 0, 0); return 0; } - 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
[sqlite] error in sqlite3_extension_init
Excuse me for my stupid topic, but I am crazying to find error in program below. My output is: bash-3.1# gcc -shared labsinf.c -o inf.so labsinf.c:61: error: expected ';', ',' or ')' before '*' token The errror is for sqlit3_extension_init row, but I don't see strange things #include stdio.h #include stdlib.h #include string.h #include sqlite3ext.h SQLITE_EXTENSION_INIT1 void soundex(sqlite3_context* ctx, int nargs, sqlite3_value** values) { int i,j; char c,r; int d; int count; char* str2; char* result; int dim; const char* str; char ret[4]; str = sqlite3_value_text(values[0]); dim = strlen(str); for (i=0;idim;i++) str2[i] = str[i]; for (i=0;i=dim;i++) str2[i] = toupper(str2[i]); for (i=0;i=dim;i++) switch (str[i]) { case 'A': case 'E': case 'I': case 'O': case 'U': case 'H': case 'W': case 'Y': str2[i] = '0'; } for (i=1;idim;i++) switch (str2[i]) { case 'B': case 'F': case 'P': case 'V': str2[i] = '1'; break; case 'C': case 'G': case 'J': case 'K': case 'Q': case 'S': case 'X': case 'Z': str2[i] = '2'; break; case 'D': case 'T': str2[i] = '3'; break; case 'L': str2[i] = '4'; break; case 'M': case 'N': str2[i] = '5'; break; case 'R': str2[i] = '6'; break; } count=1; for (i=0;idim-1;i++) if (str2[i] != str2[i+1]) count++; result = malloc(count); j=0; for (i=0;idim-1;i++) if (str2[i] != str2[i+1]) { result[j]=str2[i]; j++; } for (i=0;i4;i++) printf(%c, result[i]); for (i=0;i4;i++) ret[i] = result[i]; printf(\n\n); sqlite3_result_text(ctx,ret, 4, SQLITE_TRANSIENT); } int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, const sqlite3_api_rountines *pApi) { SQLITE_EXTENSION_INIT2(pApi) sqlite3_create_function(db, soundex, 1, SQLITE_UTF8, NULL, soundex, NULL, NULL); return 0; } - 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
[sqlite] error in sqlite3_extension_init
But I don't understand where is the error in row below: int sqlite3_extension_init(sqlite3 *db, char **pzErrMsg, const sqlite3_api_rountines *pApi) { Can some suggest me something? - #include stdio.h #include stdlib.h #include string.h #include sqlite3ext.h SQLITE_EXTENSION_INIT1 void soundex(sqlite3_context* ctx, int nargs, sqlite3_value** values) { int i,j; char c,r; int d; int count; char* str2; char* result; int dim; const char* str; char ret[4]; str = sqlite3_value_text(values[0]); dim = strlen(str); for (i=0;idim;i++) str2[i] = str[i]; for (i=0;i=dim;i++) str2[i] = toupper(str2[i]); for (i=0;i=dim;i++) switch (str[i]) { case 'A': case 'E': case 'I': case 'O': case 'U': case 'H': case 'W': case 'Y': str2[i] = '0'; } for (i=1;idim;i++) switch (str2[i]) { case 'B': case 'F': case 'P': case 'V': str2[i] = '1'; break; case 'C': case 'G': case 'J': case 'K': case 'Q': case 'S': case 'X': case 'Z': str2[i] = '2'; break; case 'D': case 'T': str2[i] = '3'; break; case 'L': str2[i] = '4'; break; case 'M': case 'N': str2[i] = '5'; break; case 'R': str2[i] = '6'; break; } count=1; for (i=0;idim-1;i++) if (str2[i] != str2[i+1]) count++; result = malloc(count); j=0; for (i=0;idim-1;i++) if (str2[i] != str2[i+1]) { result[j]=str2[i]; j++; } for (i=0;i4;i++) printf(%c, result[i]); for (i=0;i4;i++) ret[i] = result[i]; printf(\n\n); sqlite3_result_text(ctx,ret, 4, SQLITE_TRANSIENT); } int sqlite3_extension_init(sqlite3 *db, char **pzErrMsg, const sqlite3_api_rountines *pApi) { SQLITE_EXTENSION_INIT2(pApi) sqlite3_create_function(db, soundex, 1, SQLITE_UTF8, NULL, soundex, NULL, NULL); return 0; } - 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
[sqlite] about addition extension
I created half.c program, the output is: bash-3.1# gcc -shared half.c -o half.so bash-3.1# sqlite3 SQLite version 3.5.7 Enter .help for instructions sqlite .load half.so unknown command or invalid arguments: load. Enter .help for help sqlite select load_extension('half.so'); SQL error: no such function: load_extension sqlite SELECT load_extension('half.so'); SQL error: no such function: load_extension sqlite half.c program is below: #include sqlite3ext.h SQLITE_EXTENSION_INIT1 /* ** The half() SQL function returns half of its input value. */ static void halfFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ sqlite3_result_double(context, 0.5*sqlite3_value_double(argv[0])); } /* SQLite invokes this routine once when it loads the extension. ** Create new functions, collating sequences, and virtual table ** modules here. This is usually the only exported symbol in ** the shared library. */ int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi ){ SQLITE_EXTENSION_INIT2(pApi) sqlite3_create_function(db, half, 1, SQLITE_ANY, 0, halfFunc, 0, 0); return 0; } What is the problem? I am desperated. - 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
[sqlite] about addition extension
.load is not present in my shell sqlite3 as command! bash-3.1# sqlite3 SQLite version 3.5.7 Enter .help for instructions sqlite .load unknown command or invalid arguments: load. Enter .help for help sqlite .help .bail ON|OFF Stop after hitting an error. Default OFF .databases List names and files of attached databases .dump ?TABLE? ... Dump the database in an SQL text format .echo ON|OFF Turn command echo on or off .exit Exit this program .explain ON|OFFTurn output mode suitable for EXPLAIN on or off. .header(s) ON|OFF Turn display of headers on or off .help Show this message .import FILE TABLE Import data from FILE into TABLE .indices TABLE Show names of all indices on TABLE .mode MODE ?TABLE? Set output mode where MODE is one of: csv Comma-separated values column Left-aligned columns. (See .width) html HTML table code insert SQL insert statements for TABLE line One value per line list Values delimited by .separator string tabs Tab-separated values tcl TCL list elements .nullvalue STRING Print STRING in place of NULL values .output FILENAME Send output to FILENAME .output stdout Send output to the screen .prompt MAIN CONTINUE Replace the standard prompts .quit Exit this program .read FILENAME Execute SQL in FILENAME .schema ?TABLE?Show the CREATE statements .separator STRING Change separator used by output mode and .import .show Show the current values for various settings .tables ?PATTERN? List names of tables matching a LIKE pattern .timeout MSTry opening locked tables for MS milliseconds .timer ON|OFF Turn the CPU timer measurement on or off .width NUM NUM ... Set column widths for column mode Where is the problem? PS =I 'd like attach my thread at my topic previously, but it don't 'work' 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] about addition extension
bash-3.1# nm libsqlite3.so.0.8.6| grep extension nm: 'libsqlite3.so.0.8.6': No such file bash-3.1# nm libsqlite3.so.0.8.6 nm: 'libsqlite3.so.0.8.6': No such file Ok, I downloaded sqlite-amalgamation-3.5.7. I've untar above file. Can you tell me step by step how to configure and compile this file? Thanks, savio Ken [EMAIL PROTECTED] ha scritto: You need to see if you have the extensions compiled into the sqlite library. Run the fillowing: nm libsqlite3.so.0.8.6 | grep extension Output should be similar too: 00024a40 T sqlite3_auto_extension 000249d0 T sqlite3_enable_load_extension 00024680 T sqlite3_load_extension 00024af0 T sqlite3_reset_auto_extension If you dont see the line with sqlite3_load_extension then you need to rebuild sqlite (I suggest building from the amalgamation). (there is no such thing as a .load command)... sqlite .load half.so This is correct: except you need to provide the FULL path name! SELECT load_extension('half.so'); dark0s dark0s [EMAIL PROTECTED] wrote: I created half.c program, the output is: bash-3.1# gcc -shared half.c -o half.so bash-3.1# sqlite3 SQLite version 3.5.7 Enter .help for instructions sqlite .load half.so unknown command or invalid arguments: load. Enter .help for help sqlite select load_extension('half.so'); SQL error: no such function: load_extension sqlite SELECT load_extension('half.so'); SQL error: no such function: load_extension sqlite half.c program is below: #include sqlite3ext.h SQLITE_EXTENSION_INIT1 /* ** The half() SQL function returns half of its input value. */ static void halfFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ sqlite3_result_double(context, 0.5*sqlite3_value_double(argv[0])); } /* SQLite invokes this routine once when it loads the extension. ** Create new functions, collating sequences, and virtual table ** modules here. This is usually the only exported symbol in ** the shared library. */ int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi ){ SQLITE_EXTENSION_INIT2(pApi) sqlite3_create_function(db, half, 1, SQLITE_ANY, 0, halfFunc, 0, 0); return 0; } What is the problem? I am desperated. - Inviato da Yahoo! Mail. La casella di posta intelligente. - 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
[sqlite] cannot open shared file object: no such file or directory
Ok, I build sqlite3 with load extension support, now I must execute extension: #gcc -shared half.c -o half.so #export LD_LIBRARY_PATH='pwd' #sqlite3 sqlite.load half.so half.so: cannot open shared file object: no such file or directory but #ls half.c half.so Where is the problem now? 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
[sqlite] Addition extension function failed!
I have a new problem, I am attempting add extension function to sqlite3. My program labsinf.c now build successfully, but I didn't add my extension. I don't understand what it is miss. Help me please. The program labsinf.c make inf, and after I typed ./inf, it makes dbforext.db. Some output is below: bash-3.1# gcc -lsqlite3 labsinf.c -o inf bash-3.1# ./inf bash-3.1# sqlite3 dbforext.db SQLite version 3.5.7 Enter .help for instructions sqlite select soundex(saverio); SQL error: no such column: saverio sqlite select soundex(savio); SQL error: no such column: savio sqlite select soundex(); SQL error: no such function: soundex sqlite select soundex; SQL error: no such column: soundex The program is below: #include stdio.h #include stdlib.h #include string.h #include sqlite3.h void soundex(sqlite3_context* ctx, int nargs, sqlite3_value** values) { int i,j; char c,r; int d; int count; char* str2; char* result; int dim; const char* str; char ret[4]; str = sqlite3_value_text(values[0]); dim = strlen(str); for (i=0;idim;i++) str2[i] = str[i]; for (i=0;i=dim;i++) str2[i] = toupper(str2[i]); for (i=0;i=dim;i++) switch (str[i]) { case 'A': case 'E': case 'I': case 'O': case 'U': case 'H': case 'W': case 'Y': str2[i] = '0'; } for (i=1;idim;i++) switch (str2[i]) { case 'B': case 'F': case 'P': case 'V': str2[i] = '1'; break; case 'C': case 'G': case 'J': case 'K': case 'Q': case 'S': case 'X': case 'Z': str2[i] = '2'; break; case 'D': case 'T': str2[i] = '3'; break; case 'L': str2[i] = '4'; break; case 'M': case 'N': str2[i] = '5'; break; case 'R': str2[i] = '6'; break; } count=1; for (i=0;idim-1;i++) if (str2[i] != str2[i+1]) count++; result = malloc(count); j=0; for (i=0;idim-1;i++) if (str2[i] != str2[i+1]) { result[j]=str2[i]; j++; } for (i=0;i4;i++) printf(%c, result[i]); for (i=0;i4;i++) ret[i] = result[i]; printf(\n\n); sqlite3_result_text(ctx,ret, 4, SQLITE_TRANSIENT); } int main(int argc, char* argv[]) { int rc; char* sql; sqlite3* db; sqlite3_stmt* stmt; const char* tail; 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); sql = select soundex(saverio);; sqlite3_prepare(db, sql, strlen(sql), stmt, tail); if (rc != SQLITE_OK) { fprintf(stderr, Errore SQL: %s\n, sqlite3_errmsg(db)); } rc = sqlite3_step(stmt); sqlite3_close(db); return 0; } - 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
[sqlite] Addition extension function failed!
Ok, but I did not understand step by step how work. In wiki there is: #include sqlite3ext.h SQLITE_EXTENSION_INIT1 static void halfFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ sqlite3_result_double(context, 0.5*sqlite3_value_double(argv[0])); } int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi ){ SQLITE_EXTENSION_INIT2(pApi) sqlite3_create_function(db, half, 1, SQLITE_ANY, 0, halfFunc, 0, 0); return 0; } I understood that in my program I must insert sqlite3ext.h instead sqlite3.h, but I have got a doubt: Must I insert sqlite3_extension_init implementation, like below? #include sqlite3ext.h SQLITE_EXTENSION_INIT1 int main(int argc, char* argv[]) { int rc; char* sql; sqlite3* db; sqlite3_stmt* stmt; const char* tail; 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); } static void soundex( sqlite3_context *context, int argc, sqlite3_value **argv ){ ... } int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi ){ SQLITE_EXTENSION_INIT2(pApi) sqlite3_create_function(db, soundex, 1, SQLITE_UTF8, NULL, soundex, NULL, NULL); } sql = select soundex(saverio);; sqlite3_prepare(db, sql, strlen(sql), stmt, tail); if (rc != SQLITE_OK) { fprintf(stderr, Errore SQL: %s\n, sqlite3_errmsg(db)); } rc = sqlite3_step(stmt); sqlite3_close(db); return 0; } Excuse for my ignorance with sqlite3, but I am newbye. 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
[sqlite] about addition extension
Ok, but I did not understand step by step how work. In wiki there is: #include sqlite3ext.h SQLITE_EXTENSION_INIT1 static void halfFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ sqlite3_result_double(context, 0.5*sqlite3_value_double(argv[0])); } int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi ){ SQLITE_EXTENSION_INIT2(pApi) sqlite3_create_function(db, half, 1, SQLITE_ANY, 0, halfFunc, 0, 0); return 0; } I understood that in my program I must insert sqlite3ext.h instead sqlite3.h, but I have got a doubt: Must I insert sqlite3_extension_init implementation, like below? #include sqlite3ext.h SQLITE_EXTENSION_INIT1 int main(int argc, char* argv[]) { int rc; char* sql; sqlite3* db; sqlite3_stmt* stmt; const char* tail; 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); } static void soundex( sqlite3_context *context, int argc, sqlite3_value **argv ){ ... } int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi ){ SQLITE_EXTENSION_INIT2(pApi) sqlite3_create_function(db, soundex, 1, SQLITE_UTF8, NULL, soundex, NULL, NULL); } sql = select soundex(saverio);; sqlite3_prepare(db, sql, strlen(sql), stmt, tail); if (rc != SQLITE_OK) { fprintf(stderr, Errore SQL: %s\n, sqlite3_errmsg(db)); } rc = sqlite3_step(stmt); sqlite3_close(db); return 0; } Excuse for my ignorance with sqlite3, but I am newbye. 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
[sqlite] passing parameters in sql strings
How can I to pass parameters in sql string? For example, I type: sql = create table modulo(id, nome, classe, istanza);; now, I'd like to insert a parametrized name for table. Like echo 'create table $modulo(id, nome, classe, istanza)' in shell scripting. - 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
[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
[sqlite] help about extension
I need help. I am doing sqlite3 extension, but something don't work at compile time. The output of compiler is: bash-3.1# gcc -lsqlite3 labsinf.c -o inf labsinf.c: In function 'soundex': labsinf.c:16: warning: assignment discards qualifiers from pointer target type The program is below, I am desperated: #include stdio.h #include stdlib.h #include string.h #include sqlite3.h void soundex(sqlite3_context* ctx, int nargs, sqlite3_value** values) { int i,j; char c,r; int d; int count; char* result; int dim; char* str; str = sqlite3_value_text(values[0]); dim = strlen(str); for (i=0;i=dim;i++) str[i] = toupper(str[i]); for (i=0;i=dim;i++) switch (str[i]) { case 'A': case 'E': case 'I': case 'O': case 'U': case 'H': case 'W': case 'Y': str[i] = '0'; } for (i=1;idim;i++) switch (str[i]) { case 'B': case 'F': case 'P': case 'V': str[i] = '1'; break; case 'C': case 'G': case 'J': case 'K': case 'Q': case 'S': case 'X': case 'Z': str[i] = '2'; break; case 'D': case 'T': str[i] = '3'; break; case 'L': str[i] = '4'; break; case 'M': case 'N': str[i] = '5'; break; case 'R': str[i] = '6'; break; } count=1; for (i=0;idim-1;i++) if (str[i] != str[i+1]) count++; result = malloc(count); j=0; for (i=0;idim-1;i++) if (str[i] != str[i+1]) { result[j]=str[i]; j++; } for (i=0;i4;i++) printf(%c, result[i]); printf(\n\n); } int main(int argc, char* argv[]) { int rc; char* sql; sqlite3* db; sqlite3_stmt* stmt; const char* tail; 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); sql = select soundex(saverio);; sqlite3_prepare(db, sql, strlen(sql), stmt, tail); if (rc != SQLITE_OK) { fprintf(stderr, Errore SQL: %s\n, sqlite3_errmsg(db)); } rc = sqlite3_step(stmt); sqlite3_close(db); return 0; } - 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
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
[sqlite] problem with sqlite3_bind_text
Hi all, after writing my program, I typed: bash-3.1# gcc -lsqlite3 CreaDB.c -o creadb CreaDB.c: In function 'main': CreaDB.c:35: error: too few arguments to function 'sqlite3_bind_text' CreaDB.c:36: error: too few arguments to function 'sqlite3_bind_text' CreaDB.c:37: error: too few arguments to function 'sqlite3_bind_text' But I don't see the problem, my program is: int main(int argc, char** argv[]) { int rc, i; sqlite3* db; sqlite3_stmt* stmt; char* sql; const char* tail; rc = sqlite3_open(prova.db, db); if (rc) { fprintf(stderr, E' impossibile aprire il file %s\n, sqlite3_errmsg(db)); sqlite3_close(db); exit(1); } sql = create table modulo(id);; rc = sqlite3_prepare(db, sql, strlen(sql), stmt, tail); if (rc != SQLITE_OK) { fprintf(stderr, Errore SQL: %s\n, sqlite3_errmsg(db)); } rc = sqlite3_step(stmt); sqlite3_reset(stmt); sql = insert into modulo(id, nome, classe, istanza) values(?,?,?,?); sqlite3_prepare(db, sql, strlen(sql), stmt, tail); sqlite3_bind_int(stmt, 1, 1); sqlite3_bind_text(stmt, 2, nome1); sqlite3_bind_text(stmt, 3, classe1); sqlite3_bind_text(stmt, 4, istanza1); sqlite3_step(stmt); while (rc == SQLITE_ROW) { for (i = 0; i sqlite3_column_count(stmt); i++) fprintf(stderr, '%s' , sqlite3_column_text(stmt, i)); fprintf(stderr, \n); rc = sqlite3_step(stmt); } sqlite3_finalize(stmt); sqlite3_close(db); return 0; } Thank you very much in advance for answers, 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
[sqlite] problem with undefined reference
Hi all, I am newbye in sqlite programming. I written a little C program to begin with sqlite, and I posted it below: #include stdio.h #include stdlib.h #include sqlite3.h void main() { int rc, i; sqlite3* db; sqlite3_stmt* stmt; char* sql; const char* tail; rc = sqlite3_open(prova.db, db); if (rc) { fprintf(stderr, E' impossibile aprire il file %s\n, sqlite3_errmsg(db)); sqlite3_close(db); exit(1); } sql = create table modulo(id, nome, classe, istanza);; rc = sqlite3_prepare(db, sql, strlen(sql), stmt, tail); if (rc != SQLITE_OK) { fprintf(stderr, Errore SQL: %s\n, sqlite3_errmsg(db)); } rc = sqlite3_step(stmt); while (rc == SQLITE_ROW) { for (i = 0; i sqlite3_column_count(stmt); i++) fprintf(stderr, '%s' , sqlite3_column_text(stmt, i)); fprintf(stderr, \n); rc = sqlite3_step(stmt); } sqlite3_finaqlize(stmt); sqlite3_close(db); } So, when I compile above program the result is: bash-3.1# gcc CreaDB.c -o CreaDB CreaDB.c: In function 'main': CreaDB.c:21: warning: incompatible implicit declaration of built-in function 'strlen' CreaDB.c:5: warning: return type of 'main' is not 'int' CreaDB.c:41:3: warning: no newline at end of file /tmp/ccs8L4Zw.o: In function `main': CreaDB.c:(.text+0x1f): undefined reference to `sqlite3_open' CreaDB.c:(.text+0x37): undefined reference to `sqlite3_errmsg' CreaDB.c:(.text+0x5e): undefined reference to `sqlite3_close' CreaDB.c:(.text+0xa4): undefined reference to `sqlite3_prepare' CreaDB.c:(.text+0xbc): undefined reference to `sqlite3_errmsg' CreaDB.c:(.text+0xe3): undefined reference to `sqlite3_step' CreaDB.c:(.text+0x103): undefined reference to `sqlite3_column_text' CreaDB.c:(.text+0x12d): undefined reference to `sqlite3_column_count' CreaDB.c:(.text+0x154): undefined reference to `sqlite3_step' CreaDB.c:(.text+0x16c): undefined reference to `sqlite3_finaqlize' CreaDB.c:(.text+0x17b): undefined reference to `sqlite3_close' collect2: ld returned 1 exit status What is the problem? Thanks, 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
[sqlite] problem with undefined reference
Ok, excuse my ignorance, how can I to connect dinamic library with gcc Thanks, 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
[sqlite] problem with undefined reference
sqlite3.c is not present in the system I type gcc CreaDB.c sqlite3.c -o CreaDB but after I don't find CreaDB also in my system. 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] problem with undefined reference
bash-3.1# gcc CreaDB.c sqlite3.c -o CreaDb gcc: sqlite3.c: No such file or directory CreaDB.c: In function 'main': CreaDB.c:21: warning: incompatible implicit declaration of built-in function 'strlen' CreaDB.c:5: warning: return type of 'main' is not 'int' CreaDB.c:41:3: warning: no newline at end of file bash-3.1# ls CreaDB.c Desktop GNUstep loadlin16c.txt bash-3.1# What is the problem? CreaDB is not present Amit Uttamchandani [EMAIL PROTECTED] ha scritto: On Sat, 5 Apr 2008 18:16:47 +0200 (CEST) dark0s dark0s wrote: Hi all, I am newbye in sqlite programming. I written a little C program to begin with sqlite, and I posted it below: #include #include #include void main() { int rc, i; sqlite3* db; sqlite3_stmt* stmt; char* sql; const char* tail; rc = sqlite3_open(prova.db, db); if (rc) { fprintf(stderr, E' impossibile aprire il file %s\n, sqlite3_errmsg(db)); sqlite3_close(db); exit(1); } sql = create table modulo(id, nome, classe, istanza);; rc = sqlite3_prepare(db, sql, strlen(sql), stmt, tail); if (rc != SQLITE_OK) { fprintf(stderr, Errore SQL: %s\n, sqlite3_errmsg(db)); } rc = sqlite3_step(stmt); while (rc == SQLITE_ROW) { for (i = 0; i sqlite3_column_count(stmt); i++) fprintf(stderr, '%s' , sqlite3_column_text(stmt, i)); fprintf(stderr, \n); rc = sqlite3_step(stmt); } sqlite3_finaqlize(stmt); sqlite3_close(db); } So, when I compile above program the result is: bash-3.1# gcc CreaDB.c -o CreaDB CreaDB.c: In function 'main': CreaDB.c:21: warning: incompatible implicit declaration of built-in function 'strlen' CreaDB.c:5: warning: return type of 'main' is not 'int' CreaDB.c:41:3: warning: no newline at end of file /tmp/ccs8L4Zw.o: In function `main': CreaDB.c:(.text+0x1f): undefined reference to `sqlite3_open' CreaDB.c:(.text+0x37): undefined reference to `sqlite3_errmsg' CreaDB.c:(.text+0x5e): undefined reference to `sqlite3_close' CreaDB.c:(.text+0xa4): undefined reference to `sqlite3_prepare' CreaDB.c:(.text+0xbc): undefined reference to `sqlite3_errmsg' CreaDB.c:(.text+0xe3): undefined reference to `sqlite3_step' CreaDB.c:(.text+0x103): undefined reference to `sqlite3_column_text' CreaDB.c:(.text+0x12d): undefined reference to `sqlite3_column_count' CreaDB.c:(.text+0x154): undefined reference to `sqlite3_step' CreaDB.c:(.text+0x16c): undefined reference to `sqlite3_finaqlize' CreaDB.c:(.text+0x17b): undefined reference to `sqlite3_close' collect2: ld returned 1 exit status What is the problem? Thanks, savio From what I can see you have to pass sqlite3.c to gcc when compiling your program: gcc CreaDB.c sqlite3.c -o CreaDB Amit - 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] problem with undefined reference
I type also: bash-3.1# find / -name sqlite3.c bash-3.1# sqlite3.c is not present in my system, and after bash-3.1# gcc CreaDB.c sqlite3.c -o CreaDb gcc: sqlite3.c: No such file or directory CreaDB.c: In function 'main': CreaDB.c:21: warning: incompatible implicit declaration of built-in function 'strlen' CreaDB.c:5: warning: return type of 'main' is not 'int' CreaDB.c:41:3: warning: no newline at end of file bash-3.1# ls CreaDB.c Desktop GNUstep loadlin16c.txt dark0s dark0s [EMAIL PROTECTED] ha scritto: bash-3.1# gcc CreaDB.c sqlite3.c -o CreaDb gcc: sqlite3.c: No such file or directory CreaDB.c: In function 'main': CreaDB.c:21: warning: incompatible implicit declaration of built-in function 'strlen' CreaDB.c:5: warning: return type of 'main' is not 'int' CreaDB.c:41:3: warning: no newline at end of file bash-3.1# ls CreaDB.c Desktop GNUstep loadlin16c.txt bash-3.1# What is the problem? CreaDB is not present Amit Uttamchandani [EMAIL PROTECTED] ha scritto: On Sat, 5 Apr 2008 18:16:47 +0200 (CEST) dark0s dark0s wrote: Hi all, I am newbye in sqlite programming. I written a little C program to begin with sqlite, and I posted it below: #include #include #include void main() { int rc, i; sqlite3* db; sqlite3_stmt* stmt; char* sql; const char* tail; rc = sqlite3_open(prova.db, db); if (rc) { fprintf(stderr, E' impossibile aprire il file %s\n, sqlite3_errmsg(db)); sqlite3_close(db); exit(1); } sql = create table modulo(id, nome, classe, istanza);; rc = sqlite3_prepare(db, sql, strlen(sql), stmt, tail); if (rc != SQLITE_OK) { fprintf(stderr, Errore SQL: %s\n, sqlite3_errmsg(db)); } rc = sqlite3_step(stmt); while (rc == SQLITE_ROW) { for (i = 0; i sqlite3_column_count(stmt); i++) fprintf(stderr, '%s' , sqlite3_column_text(stmt, i)); fprintf(stderr, \n); rc = sqlite3_step(stmt); } sqlite3_finaqlize(stmt); sqlite3_close(db); } So, when I compile above program the result is: bash-3.1# gcc CreaDB.c -o CreaDB CreaDB.c: In function 'main': CreaDB.c:21: warning: incompatible implicit declaration of built-in function 'strlen' CreaDB.c:5: warning: return type of 'main' is not 'int' CreaDB.c:41:3: warning: no newline at end of file /tmp/ccs8L4Zw.o: In function `main': CreaDB.c:(.text+0x1f): undefined reference to `sqlite3_open' CreaDB.c:(.text+0x37): undefined reference to `sqlite3_errmsg' CreaDB.c:(.text+0x5e): undefined reference to `sqlite3_close' CreaDB.c:(.text+0xa4): undefined reference to `sqlite3_prepare' CreaDB.c:(.text+0xbc): undefined reference to `sqlite3_errmsg' CreaDB.c:(.text+0xe3): undefined reference to `sqlite3_step' CreaDB.c:(.text+0x103): undefined reference to `sqlite3_column_text' CreaDB.c:(.text+0x12d): undefined reference to `sqlite3_column_count' CreaDB.c:(.text+0x154): undefined reference to `sqlite3_step' CreaDB.c:(.text+0x16c): undefined reference to `sqlite3_finaqlize' CreaDB.c:(.text+0x17b): undefined reference to `sqlite3_close' collect2: ld returned 1 exit status What is the problem? Thanks, savio From what I can see you have to pass sqlite3.c to gcc when compiling your program: gcc CreaDB.c sqlite3.c -o CreaDB Amit - Inviato da Yahoo! Mail. La casella di posta intelligente. - 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
[sqlite] problem with undefined reference
What did you download from http://www.sqlite.org/download.html ? sqlite-3.5.7.so.gz, or sqlite-amalgamation-3.5.7.tar.gz? I've installed sqlite-3.5.7 precompiled package on my slackware system. Below there is results of searches: bash-3.1# find / -name sqlite3.c bash-3.1# bash-3.1# find / -name sqlite3.h /usr/include/seamonkey-1.1.2/sqlite3/sqlite3.h /usr/include/sqlite3.h bash-3.1# find / -name libsqlite3.so /usr/lib/libsqlite3.so bash-3.1# I try to compile: bash-3.1# gcc -llibsqlite3.so CreaDB.c -o CreaDB CreaDB.c: In function 'main': CreaDB.c:21: warning: incompatible implicit declaration of built-in function 'strlen' CreaDB.c:5: warning: return type of 'main' is not 'int' CreaDB.c:41:3: warning: no newline at end of file /usr/lib/gcc/i486-slackware-linux/4.1.2/../../../../i486-slackware-linux/bin/ld: cannot find -llibsqlite3.so collect2: ld returned 1 exit status bash-3.1# ls CreaDB.c Desktop GNUstep loadlin16c.txt - 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