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

Quote:
Originally Posted by KyleSmith
Посмотреть сообщение
Is it possible to speed up mysql_real_escape_string?

It takes 193ms for me for about 600 length string.

I'm using R30.
It's not so easy to improve the escaping speed, but I'll see what I can do.

Quote:
Originally Posted by AndreT
Посмотреть сообщение
I think I see a potential problem with the code in CScripting.cpp.

The memory allocated for the output of the C mysql_real_escape_string must be (2*strlen(input))+1. Assuming that you usually know what you're doing, when you write PAWN code, you do this:
pawn Код:
new src[32];
new dest[64];
mysql_real_escape_string(src, dest); // max_len=sizeof(destination) by default
What the plugin native then does is:
pawn Код:
size_t DestLen = (params[4] <= 0 ? 8192 : params[4]); // DestLen becmes 64 (in our case at least)
// ...
char *StrBuffer = (char *)malloc(DestLen*2+1); // Allocates 64*2+1=129 bytes of memory
memset(StrBuffer, 0, DestLen*2 + 1); // Set it all to zeros (?)
cell StringLen = (cell)mysql_real_escape_string(ConnPtr, StrBuffer, Source, strlen(Source));
StrAmx::SetCString(amx, params[2], StrBuffer, params[4]);
free(StrBuffer);
Also, I think that memset needn't be used here - the C mysql_real_escape_string appends a NULL byte by itself. To allocate 64+1 bytes of memory (aka. what we need here to be on the safe side), it needs to make use of the SourceLen variable (cannot exceed 32 in our example) and double it and add 1 byte for the NULL.

I assume this is not going to make a relevant speed difference, and perhaps the AMX interactions with large arrays is just slow, but using heap allocation (alloca instead of malloc) is a possibility here as well. Once again may not make a relevant speed difference, and may even be dangerous (if you start allocating megabytes!)
Looks like I already saw that problem while developing R33, the current code is already using the length of the source string.
Yes, it looks like the library's mysql_real_escape_string appends a NULL-byte, didn't saw that. This indeed saves me the use of memset, thanks for pointing that out.
Quote:
Originally Posted by AndreT
I assume this is not going to make a relevant speed difference, and perhaps the AMX interactions with large arrays is just slow, but using heap allocation (alloca instead of malloc) is a possibility here as well.
I think you meant stack allocation instead of heap. Using stack allocation instead of heap decreases performance by ~6.29%.

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Hi guys, last time (R8 ) there were some issues with mysql_format and linux - is this fixed now?
I completely rewrote mysql_format in R28 and tested it on Linux, I doubt that there are any problems now.
Reply

Thanks BlueG and Pain123
Reply

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
Also, I am not sure if anyone else asked but have you tried running the SQL plugin on a single core? I think it crashes
One of my beta testers has a pretty old one-core CPU and experienced crashes since R21. Well, he didn't got any crashes while using R33 though.
Reply

Quote:
Originally Posted by Pain123
Посмотреть сообщение
One of my beta testers has a pretty old one-core CPU and experienced crashes since R21. Well, he didn't got any crashes while using R33 though.
I guess you're talking about me, haha.

Yes, it was fixed in R33.
Reply

How long left for R33! I really want it for the few non threaded queries I need! xD
Reply

Question!
Is there a way to query two strings?
Reply

Quote:
Originally Posted by Tomer!.$
Посмотреть сообщение
Question!
Is there a way to query two strings?
What you think?
Reply

R33 is released (finally).
Changes:
- added ORM system
- improved Windows XP compatibility (proven to work now)
- added parameter values to debug native log messages
- improved y_inline compatiblity code
- "orm_select" and "orm_insert" support y_inline (use "orm_select_inline" and "orm_insert_inline")
- added Cache-tags to cache_set_active, cache_save and cache_delete
- added natives "cache_get_row_count" and "cache_get_field_count"
- added more safety checks
- speed improvements
- fixed bug where mysql_free_result wasn't called internally if callback processing was skipped
- improved thread safety
- improved HTML-logging, reduced file size
- code cleanup
- rewrote the whole (multi-)threading system, multi-threading works now only per-connection (every connection has their own thread)
- added native "mysql_query" for unthreaded queries
- native "mysql_reconnect" no longer returns true if connection was successful and false if not, use "mysql_errno" instead
- improved makefile, use "make" to create a dynamic and static version, "make dynamic" and "make static" are self-explaining

A tutorial for the new ORM system is available here (thanks to AndreT for this): https://sampforum.blast.hk/showthread.php?tid=461766
Thanks to the beta testers who participated in the whole testing process. And also thanks to everyone who encouraged me to this release.
Reply

Very nice work.
Reply

Brilliant I shall be updating tomorrow.
Reply

Well done on all the hard work.
Reply

Too bad I didn't get to test any of R33 for you. I've been super busy with my new job and stuff. Looking forward to see what's in store for the next feature-set!
Reply

Quote:
Originally Posted by Pain123
Посмотреть сообщение
R33 is released (finally).
Changes:
- added ORM system
- improved Windows XP compatibility (proven to work now)
- added parameter values to debug native log messages
- improved y_inline compatiblity code
- "orm_select" and "orm_insert" support y_inline (use "orm_select_inline" and "orm_insert_inline")
- added Cache-tags to cache_set_active, cache_save and cache_delete
- added natives "cache_get_row_count" and "cache_get_field_count"
- added more safety checks
- speed improvements
- fixed bug where mysql_free_result wasn't called internally if callback processing was skipped
- improved thread safety
- improved HTML-logging, reduced file size
- code cleanup
- rewrote the whole (multi-)threading system, multi-threading works now only per-connection (every connection has their own thread)
- added native "mysql_query" for unthreaded queries
- native "mysql_reconnect" no longer returns true if connection was successful and false if not, use "mysql_errno" instead
- improved makefile, use "make" to create a dynamic and static version, "make dynamic" and "make static" are self-explaining

A tutorial for the new ORM system is available here (thanks to AndreT for this): https://sampforum.blast.hk/showthread.php?tid=461766
Thanks to the beta testers who participated in the whole testing process. And also thanks to everyone who encouraged me to this release.
Awesome ! =X
Reply

Quote:
Originally Posted by -Prodigy-
Посмотреть сообщение
Very nice work.
Quote:
Originally Posted by Luis-
Посмотреть сообщение
Brilliant I shall be updating tomorrow.
Quote:
Originally Posted by KyleSmith
Посмотреть сообщение
Well done on all the hard work.
Quote:
Originally Posted by IstuntmanI
Посмотреть сообщение
Awesome ! =X
Thank you

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Too bad I didn't get to test any of R33 for you. I've been super busy with my new job and stuff. Looking forward to see what's in store for the next feature-set!
No problem, the real life goes first.
Hm, I don't have any planned features yet. If someone has any suggestions, feel free to share them with me/us!
Reply

Testing ... awesome ∞+rep
Reply

What's the difference between plugin for MySQL 5.1 and 5.5?
Reply

Quote:
Originally Posted by ThomasTailor93
Посмотреть сообщение
What's the difference between plugin for MySQL 5.1 and 5.5?
Some Linux distributions only provide packages for a specific version of the MySQL server. For example, Debian 6 (Squeeze) installs MySQL server v5.1 if you run "apt-get install mysql-server", but Debian 7 install MySQL server v5.5 if you run the same command. The shared (dynamic) version of the plugin can't be compatible to both versions, that's why there is one plugin for each MySQL server version.
Reply

Quote:
Originally Posted by Pain123
Посмотреть сообщение
R33 is released (finally).
Changes:
- added ORM system
- improved Windows XP compatibility (proven to work now)
- added parameter values to debug native log messages
- improved y_inline compatiblity code
- "orm_select" and "orm_insert" support y_inline (use "orm_select_inline" and "orm_insert_inline")
- added Cache-tags to cache_set_active, cache_save and cache_delete
- added natives "cache_get_row_count" and "cache_get_field_count"
- added more safety checks
- speed improvements
- fixed bug where mysql_free_result wasn't called internally if callback processing was skipped
- improved thread safety
- improved HTML-logging, reduced file size
- code cleanup
- rewrote the whole (multi-)threading system, multi-threading works now only per-connection (every connection has their own thread)
- added native "mysql_query" for unthreaded queries
- native "mysql_reconnect" no longer returns true if connection was successful and false if not, use "mysql_errno" instead
- improved makefile, use "make" to create a dynamic and static version, "make dynamic" and "make static" are self-explaining

A tutorial for the new ORM system is available here (thanks to AndreT for this): https://sampforum.blast.hk/showthread.php?tid=461766
Thanks to the beta testers who participated in the whole testing process. And also thanks to everyone who encouraged me to this release.
'Finally ! <3 great job man ! X:
Reply

testing R33...
So far, no problem found.

thanks for the update, and continue with your good work !!
Reply

I've always used versions of BlueG's plugin, one was an edited version by AndreT. I have never had issues with it. It's a great plugin.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)