0 registered members (),
1,397
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: A7csMySql- Preliminary Testing
[Re: D3D]
#41817
12/12/07 01:51
12/12/07 01:51
|
Joined: Mar 2003
Posts: 5,377 USofA
fastlane69
Senior Expert
|
Senior Expert
Joined: Mar 2003
Posts: 5,377
USofA
|
Thanks for the testing. Here is what we are finding out:
1) Everyone connects fine but and at some seemingly random point, the queries don't get through. All mysql dll functions return zero for their function call.
2) Another piece to the puzzle is that the crash is being recorded on windows as coming from libmysql.dll. I searched the 5.1 folders and found a different libmysql.dll in there (Sept vs July creation date). I don't know if that has ANYTHING to do with anything, but it is clear that 1) our crash is intermittent and b) it's libmysql.dll that windows says is at fault.
3) If application number 5 for example fails once, I can restart it and the other applications and application number 5 will consistently fail. However, if I restart the MySql service, application 5 will ussually work but then application 6 may or may not work (and usually doesn't).
None of the above may help us any, but at least it's helpful to catalog our behaiviour in case someone else has the same problem.
Do me a quick and easy favor. Put your calls on a loop so you do several in a row. In our case, it's never the early applications that fail, but the later ones which leads me to believe that you won't see the problem by running the demo once or twice but you may see it after 10 or 100 calls.
Now that we have the source code, I'm going to put my people on it. I have one programmer in particular who is very c++ and mysql savvy. If I can get him to put in the time (he's currently away but back on the 20th), we might be able to crack this nut in no time!
|
|
|
Re: A7csMySql- Preliminary Testing
[Re: fastlane69]
#41818
12/12/07 06:07
12/12/07 06:07
|
Joined: Apr 2006
Posts: 1,551 Netherlands
D3D
Serious User
|
Serious User
Joined: Apr 2006
Posts: 1,551
Netherlands
|
The libmysql that I included with the CSMySQL example was the latest that worked without crashing the engine/plugin last year. When I was trying to get it working again I just tried any libmysql that I could find. Could be that you actually need a previous version or might be that it works with later release also. Not really sure about that though. Have to say that my demos are very basic and not require heavy load on the database, but I do know that in your case the database connections must be persistent. If I would put a lot of query for the dll to handle it will require a wait(1) to allow the task to complete, at least that's what I thought read somewhere in this topic. Anyways I think it's best to rewrite with current sdk from http://tangentsoft.net/mysql++/
|
|
|
Re: A7csMySql- Preliminary Testing
[Re: D3D]
#41819
12/12/07 21:20
12/12/07 21:20
|
Joined: Mar 2003
Posts: 5,377 USofA
fastlane69
Senior Expert
|
Senior Expert
Joined: Mar 2003
Posts: 5,377
USofA
|
Quote:
but I do know that in your case the database connections must be persistent
That may have been it after all. We went into the MySQL administrator and changed the max queries per hour per user from 100 to 10000... that seems to be working for us right now.
But thanks for the tip on the new MySQL SDK. 5.1 has a new libmysql.dll and it might be easier to attack this from the ground up instead of building on legacy code. Even if we do have to rebuild completely, Destop's and your work will be of great help. After all, things are easier once you know they CAN be done.
More to come but for now, the max quries change has apprearently stablized things.
|
|
|
Re: A7csMySql- Preliminary Testing
[Re: fastlane69]
#41821
12/13/07 20:27
12/13/07 20:27
|
Joined: Apr 2006
Posts: 1,551 Netherlands
D3D
Serious User
|
Serious User
Joined: Apr 2006
Posts: 1,551
Netherlands
|
Have setup a ready-made project for VC++ 2008 Express, MySQL 5.1 SDK and mySQL++ 2.3.2 SDK. Unfortunately I did not yet ported the functions from Destops DLL, but it's a nice start. I'm just hobbyist so this will take me some time and I can learn from the process. Maybe if there is a strong C++ programmer he/she can do this in a hour.
|
|
|
Re: A7csMySql- Preliminary Testing
[Re: D3D]
#41822
12/13/07 23:26
12/13/07 23:26
|
Joined: Apr 2006
Posts: 1,551 Netherlands
D3D
Serious User
|
Serious User
Joined: Apr 2006
Posts: 1,551
Netherlands
|
Tried to update the code a little and got it compiling with few warnings and bunch of linker errors perhaps forgot to add something somewhere, but it's a start. Code:
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #include <windows.h> #include <stdlib.h> #include <malloc.h> #include <memory.h> #include <tchar.h> #include <math.h.>// engine specific header file #define DLL_USE // always define before including adll.h #include "stdafx.h" #include "adll.h" //A6 dll include
#include "mysql++.h" // MySQL++ header
using namespace std; using namespace mysqlpp;
Result res; Connection con(use_exceptions);
BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { engine_bind(); return TRUE; }
//Open database connection DLLFUNC var mySQL_Connectdb(STRING *db,STRING *host,STRING *user,STRING *password) { try { // its in one big try block //con.connect("test","localhost","user1","password"); con.connect(db->chars,host->chars,user->chars,password->chars); if ( !con.connected() ) { return _VAR(0); } } catch (BadQuery er) { // handle any connection or // query errors that may come up return _VAR(0); } // The full format for the Connection constructor is // Connection(cchar *db, cchar *host="", // cchar *user="", cchar *passwd="") // You may need to specify some of them if the database is not on // the local machine or you database username is not the same as your // login name, etc.. //INSERT INTO testtable (name,strengh,stamina,coord) VALUES ("plouf",20,20,20)
return _VAR(1); }
DLLFUNC var mySQL_ExecQuery(STRING *str) { if ( !con.connected() ) { return _VAR(0); }
Query query = con.query();// This creates a query object that is bound to con.
query << str->chars;// You can write to the query object like you would any other ostrem try{ res = query.store(); } catch(BadQuery er){ return _VAR(0); } return _VAR(1); }
//Reterne result item x of line y from resultset //Uses Dramatic Result Set //result[2][5] or result[2]["price"] DLLFUNC var mySQL_GetVal(var x, var y) { double result; try{ //result=(double)(res[_INT(y)])[_INT(x)]; result=(double)(res.at(_INT(y))).at(_INT(x)); } catch (BadQuery& er) { return _VAR(0); } catch (BadConversion& er) { return _VAR(-1); } return _VAR(result); }
//Reterne result item x of line y from resultset //Uses Dramatic Result Set //Return value: -2 str too small // 0 Bad Query // -1 Not Text Field DLLFUNC var mySQL_GetStr(STRING *str, var x, var y) { try{ //string my_str((res[_INT(y)])[_INT(x)]); string my_str((res.at(_INT(y))).at(_INT(x))); my_str+='\0'; if(str->length >= my_str.length()) strcpy(str->chars,my_str.c_str()); else return _VAR(-2); } catch (BadQuery& er) { return _VAR(0); } catch (BadConversion& er) { return _VAR(-1); } return _VAR(1); }
DLLFUNC void mySQL_Closedb() { con.close(); }
DLLFUNC var mySQL_IsConnected() { return _VAR(con.connected()); }
DLLFUNC var mySQL_RowNumber() { return _VAR((double)res.rows()); }
|
|
|
Re: A7csMySql- Preliminary Testing
[Re: fastlane69]
#41824
12/14/07 02:23
12/14/07 02:23
|
Joined: Apr 2006
Posts: 1,551 Netherlands
D3D
Serious User
|
Serious User
Joined: Apr 2006
Posts: 1,551
Netherlands
|
Yesterday i've uploaded the wrong files, but those are replaced now. I have started to put the commands back into the new dll one by one. The connection function and test if connection is true or false has been completed. If anyone like to try the project and source code can be found on the website's url below. Also if someone know how to do things better don't hesitate to improve You will need VC++ 2008 and mySQL 5.0+ Server in order to recompile the DLL. To try the current demo.wdl in CSDemo directory, just change the code inside to reflect your personal database configuration and run from SED with -diag. C-Script mySQL DLL http://a7-files.nixip.com/gsmysql/BETA/ (files are updated frequently)
|
|
|
|