Solved

Alternative to sqlite3_get_table

Posted on 2011-09-13
7
732 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

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

Learn how to PXE Boot both BIOS & UEFI machines with DHCP Policies and Custom Vendor Classes
Determining the an SCCM package name from the Package ID
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

738 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