[sqlite] SQLIte compilation error on AIX 6.1 - Undefined symbol: .__gcc_qsub
Hi all, I am running AIX 6.1, and GCC 4.2 and when I try compile SQLite (I think version 3.7.5) using the following commands: gcc -maix64 -D_FILE_OFFSET_BITS=64 -c -fPIC -DHAVE_USLEEP ./sqlite/sqlite3.c -o ./sqlite/sqlite3.o gcc -maix64 -shared -L/usr/lib/threads -o ./sqlite/libsqlite3.so ./sqlite/sqlite3.o -ldl -lpthread I get the following errors: ld: 0711-317 ERROR: Undefined symbol: .__gcc_qsub ld: 0711-317 ERROR: Undefined symbol: .__gcc_qmul ld: 0711-317 ERROR: Undefined symbol: .__gcc_qadd ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information. Do you have any idea what this could be caused from? Any help would be hugely appreciated ;-) Lynton NOTICE: Please note that this eMail, and the contents thereof, is subject to the standard Sasol eMail legal notice which may be found at: http://www.sasol.com/legalnotices If you cannot access the legal notice through the URL attached and you wish to receive a copy thereof please send an eMail to legalnot...@sasol.com ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] SQLite on AIX
Hi Ross, Many thanks for your response, I really appreciate it and will definitely drop you a quick email if I have any issues with the build. I am going to install GCC onto the AIX 5.3 box and will give it a try. I have never used the IBM C compiler..do you prefer it to GCC? Chat soon ;-) Lynton -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Ross Hayden Sent: Thursday, September 15, 2011 4:36 AM To: General Discussion of SQLite Database Subject: Re: [sqlite] SQLite on AIX I build the latest version of SQLite on AIX regularly, using IBM's C compiler. GNU will probably work just as well. Feel free to email me directly if you have questions. I can't be much help with GNU, but perhaps I can be with problems during the SQLite build. Good luck. -- Ross On Sep 14, 2011, at 1:14 AM, Grice, Lynton (L) wrote: Hi there, I will need to get SQLite working soon on AIX. I have read the compile notes from 2003 at http://www.sqlite.org/cvstrac/wiki?p=HowToCompile but was just wondering if anyone has it running happily on AIX with the newer versions of SQLIte? Any hints or suggestions from people who have it compiled and working 100% on AIX? I will try install GCC on AIX for the compile Thanks Lynton NOTICE: Please note that this eMail, and the contents thereof, is subject to the standard Sasol eMail legal notice which may be found at: http://www.sasol.com/legalnotices If you cannot access the legal notice through the URL attached and you wish to receive a copy thereof please send an eMail to legalnot...@sasol.com ___ 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
[sqlite] SQLite on AIX
Hi there, I will need to get SQLite working soon on AIX. I have read the compile notes from 2003 at http://www.sqlite.org/cvstrac/wiki?p=HowToCompile but was just wondering if anyone has it running happily on AIX with the newer versions of SQLIte? Any hints or suggestions from people who have it compiled and working 100% on AIX? I will try install GCC on AIX for the compile Thanks Lynton NOTICE: Please note that this eMail, and the contents thereof, is subject to the standard Sasol eMail legal notice which may be found at: http://www.sasol.com/legalnotices If you cannot access the legal notice through the URL attached and you wish to receive a copy thereof please send an eMail to legalnot...@sasol.com ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Implementing persistent queues in sqlite
Hi Allan, I have done this exact thing recently, I needed a "high speed" persistent queue in my one application running on SPARC. My application may have had some different requirements but essentially message stream from one system to the "SQLite queue" and get sent to another system(both directions). I used SQLite in WAL modethis is essentialyou may also need to use a "busy handler" I am not C expert at all but the BASIC queue I implemented in SQLIte seems to work 100% for my purposes.and so far not a single issue with it running. Chat later ;-) Lynton -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Allan Nielsen Sent: Friday, September 09, 2011 9:04 AM To: sqlite-users@sqlite.org Subject: [sqlite] Implementing persistent queues in sqlite Hi Sqlite users After several frustrating days, i have decided to drop using BerkeleyDB for implementing a persistent queue, and new as an alternative I'm looking at sqlite. I have noticed that this topic have been discussed before on this list several time, but I'm asking again as I have some quite specific questions, but also because things might have changed since. First of all, let me explain my use cases: The queue is going to be used as an replacement for the syslog daemon. The sqlite functionality which will push new entries to the to queue, will be linked directly into my logging logging library and should insert into the table every time I do a syslog. The sqlite functionality which pop entries from the queue will be used from a call-home process where it will post new entries to a web server. When an entry is posted successfully the entries must be deleted, not before. If an error occurs, the entries must be posted again. Following are important - Several process will append to the same table simultaneous - Process might die while doing an insert or update - Long lived processes connected to the database may not be affected by other processes which dies doing transactions. - Performance is not unimportant, but is not expected to be a problem either. - Posting of messages might take a long time, during this period it must be possible to add new entries. So, here are my questions: - Could sqlite be the right tool for the job - Is there anything I should be aware of - Do you know of any projects which do this already - Does any of you have examples on how to do this Thanks for your time Allan W. Nielsen ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users NOTICE: Please note that this eMail, and the contents thereof, is subject to the standard Sasol eMail legal notice which may be found at: http://www.sasol.com/legalnotices If you cannot access the legal notice through the URL attached and you wish to receive a copy thereof please send an eMail to legalnot...@sasol.com ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Totalview Debugger & MemoryScape showing leak in my SQLite code?
Hi Pavel, Many thanks for your comments.I will try put together some better code and if I have any issues I will ask again... Thanks again Lynton -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Pavel Ivanov Sent: Tuesday, September 06, 2011 5:20 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] Totalview Debugger & MemoryScape showing leak in my SQLite code? > Well, in the first code example, yes you need to free your peekText pointer. > Since you passed SQLITE_STATIC for the destructor parameter to > sqlite3_bind_text, you should free it before you exit the function and > not before. If you use SQLITE_TRANSIENT, you can free it immediately > after the bind call because SQLite will make its own copy. It's a > leak because you allocated memory on the heap (the memory pointed at > by peekText), and never freed the memory (the pointer itself is > destroyed when the stack frame is reclaimed). Don't do that, Lynton, don't free peekText pointer as it's not allocated from heap, it points to a static area. Concerning your questions: your "code contexts" are not enough to understand will there be a leak at the end of application or not. If you stop your program right after those snippets there definitely will be a leak. But what happens after that in the application can free allocated memory. Overall advice is make sure that for each statement you call sqlite3_finalize(), for each connection you call sqlite3_close() and before exiting application you call sqlite3_shutdown() (don't forget to check all result codes and process any errors appropriately). If there is still some leaks reported try to minimize amount of code that reproduces the leak report down to several lines. Post that code here in full along with the leak report and we'll see if we can explain that. Pavel On Tue, Sep 6, 2011 at 11:05 AM, Michael Stephensonwrote: > Well, in the first code example, yes you need to free your peekText pointer. > Since you passed SQLITE_STATIC for the destructor parameter to > sqlite3_bind_text, you should free it before you exit the function and > not before. If you use SQLITE_TRANSIENT, you can free it immediately > after the bind call because SQLite will make its own copy. It's a > leak because you allocated memory on the heap (the memory pointed at > by peekText), and never freed the memory (the pointer itself is > destroyed when the stack frame is reclaimed). > > Just glanced briefly at the second code sample. Where is the "handle" > variable declared? > > > -Original Message- > From: sqlite-users-boun...@sqlite.org > [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Lynton Grice > Sent: Tuesday, September 06, 2011 1:52 AM > To: General Discussion of SQLite Database > Subject: [sqlite] Totalview Debugger & MemoryScape showing leak in my > SQLite code? > > Hi there, > > I am a huge fan of SQLIte and have recently done some code that I am > debugging with TotalView and MemoryScape (http://www.roguewave.com) - > VERY VERY nice debugger, I have used GDB as well alot but Totalview is > simply awesome > > NOTE: C coding is NOT my day job ;-) > > I am using MemoryScape (I suppose the same as Valgrind) to detect > Memory leaks in my code.when I look at the leak detection I can > see I have some small leaks in my SQLIte codeand would love > someone to tell me how I can fix them? > > For example is moans about the following 2 lines below: > > - idx = sqlite3_bind_parameter_index( stmt, ":tid" ); > - rc = sqlite3_step(stmt); > > Here is more of the code context > > int queue_peekByTID(const char *tid, message *msg){ > char *peekText = "SELECT * FROM queue WHERE tid = :tid;"; > const char *value = NULL; > int idx; > int len; > > sqlite3_prepare_v2(handle,peekText,-1,,0 ); > > idx = sqlite3_bind_parameter_index( stmt, ":tid" ); > sqlite3_bind_text( stmt, idx, tid, -1, SQLITE_STATIC ); > > rc = sqlite3_step(stmt); > if(rc == SQLITE_ROW){ > > > } > > What is wrong with my code above? Must I FREE the char*? Why would > something say it was a "leak"? > > I am also getting it complaining when I do a "sqlite3_finalize(stmt);" > > I another piece of code I am using SQLite to log certain events for > meand complains about the following 3 lines below: > > - rc = sqlite3_open_v2(eventLogName,, SQLITE_OPEN_READWRITE | > SQLITE_OPEN_SHAREDCACHE | SQLITE_OPEN_CREATE, NULL); > - rc = sqlite3_exec(handle,journalMode,0,0,0); > - rc = sqlite3_exec(handle,trigger,0,0,0); > > Here is the code context > > int eventLogOpen(char *eventLogName, unsigned int > eventLogRetentionPeriod){ > char *eventLogTable = "CREATE TABLE IF NOT EXISTS [log] ( " > "[idx] INTEGER NOT NULL PRIMARY KEY > AUTOINCREMENT, " > "[timestamp] CHAR(25), " >
Re: [sqlite] MemoryScape saying I have LEAKS in my SQLite code?
Hi there, Thanks for your comments, and I am passing NULL now to the busy handler..;-) I also say on the SQLite site that the pragma " default_cache_size " should not be used anymore (http://www.sqlite.org/pragma.html#pragma_default_cache_size ) ("Do not use this pragma! This pragma is deprecated and exists for backwards compatibility only.") Let me make some of the changes and see what MemoryScape says as well...I will let you know Thanks Lynton -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Stephan Beal Sent: Tuesday, September 06, 2011 2:38 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] MemoryScape saying I have LEAKS in my SQLite code? On Tue, Sep 6, 2011 at 2:28 PM, Grice, Lynton (L) <lynton.gr...@sasol.com>wrote: > May I ask what you suggest with the way I am using the > sqlite3_busy_handler? What is the "normal approach"? I have tried to > look at examples etc > Hi! i don't use the busy handler, so i can't say, but i do know that it is NEVER valid to use a free()d pointer, and that's essentially what you've done here. If you don't want to pass any data to the busy handler then pass NULL as the final argument instead of a value which will be free()d immediately afterward sqlite3_busy_handler(). > p = sqlite3_malloc(256); > sqlite3_busy_handler(handle, , p); > sqlite3_free(p); > > Also, you mentioned the following "should fail" > sqlite3_exec(handle,"PRAGMA default_cache_size = 50;",0,0,0); > i didn't say it should/would, i implied that it _could_ by asking if you are _sure_ that it won't fail. If that fails, it might be useless to continue with the other queries, but the return code is not checked here. Even "cannot fail" commands with perfect SQL syntax and well-defined semantics can fail because of external problems. e.g. out-of-memory or i/o error. Once you get one of these errors, it's generally not a good idea to continue using the db handle (i would argue, though there are those who could rightly argue otherwise). -- - stephan beal http://wanderinghorse.net/home/stephan/ ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users NOTICE: Please note that this eMail, and the contents thereof, is subject to the standard Sasol eMail legal notice which may be found at: http://www.sasol.com/legalnotices If you cannot access the legal notice through the URL attached and you wish to receive a copy thereof please send an eMail to legalnot...@sasol.com ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] MemoryScape saying I have LEAKS in my SQLite code?
Hi Stephan, Many thanks for your response, much appreciated... May I ask what you suggest with the way I am using the sqlite3_busy_handler? What is the "normal approach"? I have tried to look at examples etc p = sqlite3_malloc(256); sqlite3_busy_handler(handle, , p); sqlite3_free(p); Also, you mentioned the following "should fail" sqlite3_exec(handle,"PRAGMA default_cache_size = 50;",0,0,0); Should I rather take it out? Thanks again for your comments, I will try re-work some of the code ;-) Lynton -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Stephan Beal Sent: Tuesday, September 06, 2011 11:55 AM To: General Discussion of SQLite Database Subject: Re: [sqlite] MemoryScape saying I have LEAKS in my SQLite code? While i can't answer the question about the leaks, i can say... On Tue, Sep 6, 2011 at 10:49 AM, Grice, Lynton (L) <lynton.gr...@sasol.com>wrote: > int queue_peekByTID(const char *tid, message *msg){ What is wrong with > my code above? Must I FREE the char*? Why would something say it was a > "leak"? > This technically isn't legal any more: char *eventLogTable = "CREATE TABLE IF NOT EXISTS [log] ( "... that should be const char *. And NEVER free() a stack-allocated string. I am also getting it complaining when I do a "sqlite3_finalize(stmt);" > If that's happening then it is likely that either your db is hosed, sqlite3_prepare() failed, or you're finalize()ing twice. Your code above does not check the return value of prepare(), and there ARE reasons a prepare() can fail which have nothing to do with the validity of the SQL you give it. >p = sqlite3_malloc(256); >sqlite3_busy_handler(handle, , p); >sqlite3_free(p); > That almost certainly is not what you want to do. p will be passed to the busy handler, but it will be invalid because you free()d it. That same address might later be re-allocated to a different type of object, which would then (invalidly) be accessed by the busy handler. i.e. memory corruption (which might even be a source of reported leaks). sqlite3_exec(handle,"PRAGMA default_cache_size = 50;",0,0,0); > are you sure this cannot fail? rc = sqlite3_exec(handle,journalMode,0,0,0); >if(rc == OK){ > rc = sqlite3_exec(handle,eventLogTable,0,0,0); > if(rc == OK){ >rc = sqlite3_exec(handle,trigger,0,0,0); > } >} >} >return successFlag; > wouldn't it be simpler (and more accurate) to return rc instead of successFlag (which is not set properly, IMO, if journalMode, eventLogTable, or trigger fail to exec(). -- - stephan beal http://wanderinghorse.net/home/stephan/ ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users NOTICE: Please note that this eMail, and the contents thereof, is subject to the standard Sasol eMail legal notice which may be found at: http://www.sasol.com/legalnotices If you cannot access the legal notice through the URL attached and you wish to receive a copy thereof please send an eMail to legalnot...@sasol.com ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] MemoryScape saying I have LEAKS in my SQLite code?
Hi there, I am a huge fan of SQLite and have recently done some code that I am debugging with TotalView and MemoryScape (http://www.roguewave.com) - VERY VERY nice debugger, I have used GDB as well alot but Totalview is simply awesome NOTE: C coding is NOT my day job ;-) So please bear with me I am using MemoryScape (I suppose the same as Valgrind) to detect Memory leaks in my code.when I look at the leak detection I can see I have some small leaks in my SQLIte codeand would love someone to tell me how I can fix them? For example MemoryScape complians about the following 2 lines below: - idx = sqlite3_bind_parameter_index( stmt, ":tid" ); - rc = sqlite3_step(stmt); Here is more of the code context int queue_peekByTID(const char *tid, message *msg){ char *peekText = "SELECT * FROM queue WHERE tid = :tid;"; const char *value = NULL; int idx; int len; sqlite3_prepare_v2(handle,peekText,-1,,0 ); idx = sqlite3_bind_parameter_index( stmt, ":tid" ); sqlite3_bind_text( stmt, idx, tid, -1, SQLITE_STATIC ); rc = sqlite3_step(stmt); if(rc == SQLITE_ROW){ } What is wrong with my code above? Must I FREE the char*? Why would something say it was a "leak"? I am also getting it complaining when I do a "sqlite3_finalize(stmt);" I another piece of code I am using SQLite to log certain events for meand complains about the following 3 lines below: - rc = sqlite3_open_v2(eventLogName,, SQLITE_OPEN_READWRITE | SQLITE_OPEN_SHAREDCACHE | SQLITE_OPEN_CREATE, NULL); - rc = sqlite3_exec(handle,journalMode,0,0,0); - rc = sqlite3_exec(handle,trigger,0,0,0); Here is the code context int eventLogOpen(char *eventLogName, unsigned int eventLogRetentionPeriod){ char *eventLogTable = "CREATE TABLE IF NOT EXISTS [log] ( " "[idx] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " "[timestamp] CHAR(25), " "[timestamp_secs] CHAR(10), " "[event_cat] CHAR(10), " "[event_tid] CHAR(50), " "[event_bus_ref] CHAR(50), " "[event_msg] TEXT);"; char trigger[2024]; if(eventLogRetentionPeriod > 0){ sprintf(trigger, "DROP TRIGGER IF EXISTS [log_retention]; " "CREATE TRIGGER [log_retention] " "AFTER INSERT ON log " "FOR EACH ROW BEGIN " "DELETE FROM log " "WHERE timestamp_secs < (strftime('%%s', 'now') - %i); " "END;", eventLogRetentionPeriod); } char *journalMode = "PRAGMA journal_mode=wal;"; int successFlag = ERROR; rc = sqlite3_open_v2(eventLogName,, SQLITE_OPEN_READWRITE | SQLITE_OPEN_SHAREDCACHE | SQLITE_OPEN_CREATE, NULL); if (rc == OK){ successFlag = OK; p = sqlite3_malloc(256); sqlite3_busy_handler(handle, , p); sqlite3_free(p); sqlite3_exec(handle,"PRAGMA default_cache_size = 50;",0,0,0); rc = sqlite3_exec(handle,journalMode,0,0,0); if(rc == OK){ rc = sqlite3_exec(handle,eventLogTable,0,0,0); if(rc == OK){ rc = sqlite3_exec(handle,trigger,0,0,0); } } } return successFlag; } Is there anything I can do to prevent these "leaks"? Maybe I need to clean up using some other SQLite functions I am not aware of etc? Thanks for the help ;-) Lynton NOTICE: Please note that this eMail, and the contents thereof, is subject to the standard Sasol eMail legal notice which may be found at: http://www.sasol.com/legalnotices If you cannot access the legal notice through the URL attached and you wish to receive a copy thereof please send an eMail to legalnot...@sasol.com ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users