Solved

Alternative to sqlite3_get_table

Posted on 2011-09-13
7
737 Views
Last Modified: 2012-05-12
I have this function called isadded(), which is giving me an error. And I ran debugdiag, and I found that the place where it errors out is sqlite3_get_table().

      sprintf_s(query,1024,"SELECT * FROM OServs WHERE oservname = '%s' ;", cOServID);
      cout<<query<<endl;
      rc = sqlite3_get_table(db, query, &results, &nrow, &ncol, &zErrMsg);

Basically, I am trying to see if the Oserv is already in the database or not. Is there an alternative function I can use?
Function     Arg 1     Arg 2     Arg 3   Source 
ntdll!RtlpWaitOnCriticalSection+df     00001484     00000002     00000000    
ntdll!RtlEnterCriticalSection+a8     09e10c08     006310a5     09e10c08    
sqlite3!sqlite3_mutex_leave+17b     09caf370     0c81d9c8     0063d240    
sqlite3!sqlite3_get_table+99     09caf370     0c81d9c8     0c81d9bc    
OServHandler!COServHandler::isAdded+17f     059a6fd8     0c8272e0     00000006    
OServHandler!COServHandler::getHierarchy+ba7     0c940020     00008000     6009fb27    
AdminConsoleInterface!CAdminConsoleInterface::handleConnection+178     00001254     00000000     00000000    
AdminConsoleInterface!CAdminConsoleInterface::setOServHandler+33     008c5cd0     0250e9c8     00000000

Open in new window

0
Comment
Question by:zystemsgo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 

Author Comment

by:zystemsgo
ID: 36531877
No Answers, it has been 6 hours since I posted it
0
 
LVL 34

Expert Comment

by:sarabande
ID: 36534121
what error did you get?

did you try the query with some admin tool?

Sara
0
 

Author Comment

by:zystemsgo
ID: 36536024
The error happens when two or more threads access this sqlite3_get_table function, and as per the dump I posted, it causes a ntdll.dll exception.

ntdll!RtlpWaitOnCriticalSection+df     00001484     00000002     00000000    
ntdll!RtlEnterCriticalSection+a8     09e10c08     006310a5     09e10c08    
sqlite3!sqlite3_mutex_leave+17b     09caf370     0c81d9c8     0063d240    
sqlite3!sqlite3_get_table+99     09caf370     0c81d9c8     0c81d9b

Read it in reverse, i.e bottom to top.
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 34

Accepted Solution

by:
sarabande earned 500 total points
ID: 36536086
if you access the same database by different threads you should open a new connection for each thread. all other things will fail sooner or later to my experience.

Sara
0
 

Assisted Solution

by:zystemsgo
zystemsgo earned 0 total points
ID: 36536246
There is a sqlite3_open and sqlite3_close at the beginning and ending of each function. But, I think it was bad design anyway to read the database each time.

I read the database once at the beginning of each thread and store it in a map container and do a map.find() to see if the object exists or not.
0
 

Author Closing Comment

by:zystemsgo
ID: 36558747
Cos, I answered my own question. I eliminated the sqlite3 call altogether.
0
 
LVL 34

Expert Comment

by:sarabande
ID: 36536379
the error in the wait for critical section probably means that you caused a dead-lock somehow. do you call the functions recursively somehow? or is there a way to miss the close?

a map is a good idea, though. you should use the main thread to initially load it and provide a static method or singleton class object to access map from any thread. if the map doesn't need to get refreshed that approach automatically is thread-safe.

Sara
0

Featured Post

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question