[Plugin] [REL] MySQL Plugin (Now on github!)

I was thinking of a new feature while reading this thread: http://forum.sa-mp.com/showthread.ph...09#post3513809

pawn Код:
enum
{
    FIELD_TYPE_INT, // int, tinyint, etc.
    FIELD_TYPE_ARRAY, // varchar, text, etc.
    FIELD_TYPE_FLOAT, // float, double
}
#define FIELD_TYPE_STRING FIELD_TYPE_ARRAY

native cache_get_field_type(field_index, connectionHandle = 1);
native cache_get_field_name_type(const field_name[], connectionHandle = 1); // should be renamed, I couldn't think of a better name
Reply

Good Job
Reply

Quote:
Originally Posted by b3nz
Посмотреть сообщение
The problem is that I can't use newer version than R34, as right now I'm using Windows XP, which doesn't support KERNEL32 library.

EDIT: pool_size was added in R35, so I can't even use it. :\
Okay, try re-downloading and re-installing R34 (re-installing = replacing all files with the new download; don't forget the libmysql.dll!).

Quote:
Originally Posted by kvann
Посмотреть сообщение
I was thinking of a new feature while reading this thread: http://forum.sa-mp.com/showthread.ph...09#post3513809

pawn Код:
enum
{
    FIELD_TYPE_INT, // int, tinyint, etc.
    FIELD_TYPE_ARRAY, // varchar, text, etc.
    FIELD_TYPE_FLOAT, // float, double
}
#define FIELD_TYPE_STRING FIELD_TYPE_ARRAY

native cache_get_field_type(field_index, connectionHandle = 1);
native cache_get_field_name_type(const field_name[], connectionHandle = 1); // should be renamed, I couldn't think of a better name
May I ask what kind of purpose those functions would serve?
Reply

Nah, it ain't necassary anymore. Forget about it.
Reply

Hm, no idea why I haven't asked about this before: Is there a way for bulk orm operations? Say, send them as a transaction? Would normal tquery with transaction start beforehand suffice?
Reply

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Hm, no idea why I haven't asked about this before: Is there a way for bulk orm operations? Say, send them as a transaction? Would normal tquery with transaction start beforehand suffice?
All ORM queries use the same direct database connection mysql_tquery uses, thus it should suffice to start/end an transaction through mysql_tquery before/after calling orm_select/orm_update/orm_insert/orm_delete.
Reply

Neat! One more question. If I did chain of queries like: tquery -> callback -> multiple pqueries -> ensure all are finished -> tquery, can I be certain the order (not of the multiple pqueries, just this chain) is preserved?
Reply

Quote:
Originally Posted by maddinat0r
Посмотреть сообщение
Okay, try re-downloading and re-installing R34 (re-installing = replacing all files with the new download; don't forget the libmysql.dll!).
Sorry for a late answer, I totally forgot about it, as this crash seems to be random (not everytime the server is being shut). Nope, it didn't help (but why should it? The last modificate date of each R34 version file is 2013 October, same as it was before).
Reply

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Neat! One more question. If I did chain of queries like: tquery -> callback -> multiple pqueries -> ensure all are finished -> tquery, can I be certain the order (not of the multiple pqueries, just this chain) is preserved?
Yes, that call chain should work just as you stated.

Quote:
Originally Posted by b3nz
Посмотреть сообщение
Sorry for a late answer, I totally forgot about it, as this crash seems to be random (not everytime the server is being shut). Nope, it didn't help (but why should it? The last modificate date of each R34 version file is 2013 October, same as it was before).
Because people often tend to ignore replacing the libmysql.dll, because they think it doesn't change between releases (which it does, but not on every release).
Does your crash log change on every crash or is it always the same (always crashing at mysql_close in OnGameModeExit)?
Reply

Yes, everytime it's caused by mysql_close; take a look at three last crashes:

Код:
[01:00:34] [debug] Server crashed while executing bcrpg_main.amx
[01:00:34] [debug] AMX backtrace:
[01:00:34] [debug] #0 native mysql_close () from mysql.dll
[01:00:34] [debug] #1 00073fd8 in ?? (... <1073741823 arguments>) at C:\Documents and Settings\Administrator\Desktop\misc\boneCounty rpg\gamemodes\bcrpg_main.pwn:84
[01:00:34] [debug] #2 0000b640 in public ScriptInit_OnGameModeExit () at C:\Documents and Settings\Administrator\Desktop\misc\boneCounty rpg\pawno\include\YSI\..\YSI_Coding\..\YSI_Data\..\YSI_Coding\..\YSI_Internal\y_cgen.inc:30
[01:00:34] [debug] #3 00001114 in public OnGameModeExit () at C:\Documents and Settings\Administrator\Desktop\misc\boneCounty rpg\pawno\include\YSI\..\YSI_Coding\..\YSI_Internal\..\YSI_Server\y_scriptinit.inc:213
[01:00:35] [debug] Native backtrace:
[01:00:35] [debug] #0 72632074 in ?? () from samp-server.exe
[01:00:35] [debug] #1 010979d4 in ?? () from LIBMYSQL.dll

[00:23:27] [debug] Server crashed while executing bcrpg_main.amx
[00:23:27] [debug] AMX backtrace:
[00:23:27] [debug] #0 native mysql_close () from mysql.dll
[00:23:27] [debug] #1 0007e504 in ?? (... <1073741823 arguments>) at C:\Documents and Settings\Administrator\Desktop\misc\boneCounty rpg\gamemodes\bcrpg_main.pwn:84
[00:23:27] [debug] #2 00015d4c in public ScriptInit_OnGameModeExit () at C:\Documents and Settings\Administrator\Desktop\misc\boneCounty rpg\pawno\include\YSI\..\YSI_Coding\..\YSI_Data\..\YSI_Coding\..\YSI_Internal\y_cgen.inc:30
[00:23:27] [debug] #3 0000b820 in public FIXES_OnGameModeExit () at C:\Documents and Settings\Administrator\Desktop\misc\boneCounty rpg\pawno\include\YSI\..\YSI_Coding\..\YSI_Internal\..\YSI_Server\y_scriptinit.inc:213
[00:23:27] [debug] #4 00004370 in public OnGameModeExit () at C:\Documents and Settings\Administrator\Desktop\misc\boneCounty rpg\pawno\include\fixes.inc:3419
[00:23:28] [debug] Native backtrace:
[00:23:28] [debug] #0 72632074 in ?? () from samp-server.exe
[00:23:28] [debug] #1 010979d4 in ?? () from LIBMYSQL.dll

[14:24:30] [debug] Server crashed while executing bcrpg_main.amx
[14:24:30] [debug] AMX backtrace:
[14:24:30] [debug] #0 native mysql_close () from mysql.dll
[14:24:30] [debug] #1 0007d950 in ?? (... <1073741823 arguments>) at C:\Documents and Settings\Administrator\Desktop\misc\boneCounty rpg\gamemodes\bcrpg_main.pwn:85
[14:24:30] [debug] #2 00015d4c in public ScriptInit_OnGameModeExit () at C:\Documents and Settings\Administrator\Desktop\misc\boneCounty rpg\pawno\include\YSI\..\YSI_Coding\..\YSI_Data\..\YSI_Coding\..\YSI_Internal\y_cgen.inc:30
[14:24:30] [debug] #3 0000b820 in public FIXES_OnGameModeExit () at C:\Documents and Settings\Administrator\Desktop\misc\boneCounty rpg\pawno\include\YSI\..\YSI_Coding\..\YSI_Internal\..\YSI_Server\y_scriptinit.inc:213
[14:24:30] [debug] #4 00004370 in public OnGameModeExit () at C:\Documents and Settings\Administrator\Desktop\misc\boneCounty rpg\pawno\include\fixes.inc:3419
[14:24:31] [debug] Native backtrace:
[14:24:31] [debug] #0 72632074 in ?? () from samp-server.exe
[14:24:31] [debug] #1 010979d4 in ?? () from LIBMYSQL.dll
Reply

Can you try to insert a delay before calling mysql_close? Something like this:
Код:
public OnGameModeExit()
{
    new tc = tickcount();
    while((tickcount() - tc) < 2000)
    { }
    mysql_close();
}
Reply

Seems like setting up a delay before calling the function fixed it. Thanks! I'll post here if anything still goes wrong with the mysql_close.
Reply

Can you please add a more accurate error, warning logging? Because there's not much info in these:

Код:
[11:56:48] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
[20:35:25] [WARNING] CMySQLResult::GetRowData - invalid row ('0') or field index ('0')
And also would be cool to add year, month and day to the logging.
Reply

Does it close all unclosed connections automatically? Is it necessary to use mysql_close() every time I exit server / make new connection (to the same db)? I have FS using MySQL BlueG to install on server using this too. If server's connection and fs' connection lead at the same database, their handle IDs will be matched, so when fs' connection is closing another's closing too. How can I prevent it?
Reply

Thanks G
Reply

Quote:

"UPDATE `%e` SET `Health` = '%.1f', `Rida` = '%.1f', `Fuel` = '%d', `Color1` = '%d', `Color2` = '%d' WHERE `Owner` = '%e'

Quote:

[20:05:26] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `vehicles` SET `Health` = '1000.0', `Rida` = '1.174e.5', ", callback: "(null)", format: "(null)"

"Rida" save 1.174e.5 instead of 117415. Printf show correct value (117415). I use MySQL R39-3. It is bug?

EDIT: This problem only with mysql_format, with format all ok.
Reply

Quote:
Originally Posted by kadaradam
Посмотреть сообщение
Can you please add a more accurate error, warning logging? Because there's not much info in these:

Код:
[11:56:48] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
[20:35:25] [WARNING] CMySQLResult::GetRowData - invalid row ('0') or field index ('0')
And also would be cool to add year, month and day to the logging.
R40.

Quote:
Originally Posted by BRICS
Посмотреть сообщение
Does it close all unclosed connections automatically? Is it necessary to use mysql_close() every time I exit server / make new connection (to the same db)? I have FS using MySQL BlueG to install on server using this too. If server's connection and fs' connection lead at the same database, their handle IDs will be matched, so when fs' connection is closing another's closing too. How can I prevent it?
The plugin closes all connection on proper server exit.
If you call
Код:
mysql_option(DUPLICATE_CONNECTIONS, true);
before creating a connection, connections with matching credentials won't be detected as duplicate connections (thus every created connection will be unique).

Quote:
Originally Posted by Johurt
Посмотреть сообщение
"Rida" save 1.174e.5 instead of 117415. Printf show correct value (117415). I use MySQL R39-3. It is bug?
EDIT: This problem only with mysql_format, with format all ok.
This is not really a bug, but part of the IEEE 754 floating point standard. This is just an other way of representing a number. Try reading in that "weird" float value and check if it outputs the correct float value - it should.
Reply

Is there any method of using ORM and MD5? Because my server passwords are md5 and would like to start using ORM.
Reply

You'd need to hash them on the PAWN-side with a function (there are a lot of plugins here that provide many hash functions). Alternatively you can send your own queries and use orm_apply_cache.
Reply

Why I have poor load time on Windows 10 Pro(using WAMP server)? On Windows Pro 8.1 I didn't had poor load time.
Reply


Forum Jump:


Users browsing this thread: 14 Guest(s)