[Release] MySQL Async Library - 3.3.2

hello, perfect I had exactly the same problem. So by retrograding the version of the fx the commands / refonctionner? do you still use the latest version of mysql? sorry for my bad English

to me it worked :slight_smile:

Ok I will try it then! thank you for your answer

1 Like

Do you have find any solution ?

Is there anyone willing to test if I try and patch it if it is gone? I got no issues myself so either I need it reproducable for me, or I randomly try one thing, and someone tests it.

Yes I can do it.

I would also like to fix a problem with the phone (script) I use. How is it possible that I modify mysql-async to add the possibility of executing 2 queries at the same time.
Example:

function _internalAddMessage(transmitter, receiver, message, owner)
    local Query = "INSERT INTO phone_messages (`transmitter`, `receiver`,`message`, `isRead`,`owner`) VALUES(@transmitter, @receiver, @message, @isRead, @owner);"
    local Query2 = 'SELECT * from phone_messages WHERE `id` = (SELECT LAST_INSERT_ID());'
	local Parameters = {
        ['@transmitter'] = transmitter,
        ['@receiver'] = receiver,
        ['@message'] = message,
        ['@isRead'] = owner,
        ['@owner'] = owner
    }
	return MySQL.Sync.fetchAll(Query .. Query2, Parameters)[1]
end

With Mysql-async 2.XXX itā€™s possible but no actuallyā€¦

My mysql must execute both queries in a row. They are dependent on each other and I can not adapt my script with your new version ā€¦

3.0.0 only allows one query per execution. If you want to overrule that append &multipleStatements=true to the connection string to recreate that behaviour. Should work with a 3.0 type connection string. So something like this

set mysql_connection_string "mysql://user:pwd@localhost/database?dateStrings=true&multipleStatements=true"

I will pm you a potential fix. But I definately need feedback if it works. If it does not I do not think mysql-async is the problem.

1 Like

This fixed goes into the config file? I do not exactly understand or place it. I go through essentialmode and esplugin_mysql for my sql connection. I suppose I add ā€œ& multipleStatements = trueā€ to my sql connection line?

yes change your sql connection string to one similar to the post above. That solves that multiple statements cannot be used.

It just limits the scope of possible injection attacks. So the security feature is by default on.

With your Mysql.lua file & the new connection line for my sql, when i want to send a message in game iā€™ve this error :

mysql-async.js:209563: Uncaught TypeError: Cannot property ā€˜typeā€™ of undefined

Iā€™m going to try the ref call issue and admin commands

That means options are undefined? Something went bad with the parameter parsing. Which I tested and worked for me. Guess I need to do some more testing.

If the commands work properly with the file I send you. Will publish that with the next update, very likely tomorrow.

So in fact I do not understand this error. On the server side I have this request:

function _internalAddMessage(transmitter, receiver, message, owner)
    local Query = "INSERT INTO phone_messages (`transmitter`, `receiver`,`message`, `isRead`,`owner`) VALUES(@transmitter, @receiver, @message, @isRead, @owner);"
    local Query2 = 'SELECT * from phone_messages WHERE `id` = (SELECT LAST_INSERT_ID());'
	local Parameters = {
        ['@transmitter'] = transmitter,
        ['@receiver'] = receiver,
        ['@message'] = message,
        ['@isRead'] = owner,
        ['@owner'] = owner
    }
	return MySQL.Sync.fetchAll(Query .. Query2, Parameters)[1]
end

This function is server-side. I have no more error sending and the message is well saved in database. However client side:

RegisterNetEvent("gcPhone:receiveMessage")
AddEventHandler("gcPhone:receiveMessage", function(message)
  SendNUIMessage({event = 'newMessage', message = message})
  if message.owner == 0 then
    local text = '~o~You received a new message'
      local text = '~o~You received a new message of ~y~'.. message.transmitter
      for _,contact in pairs(contacts) do
        if contact.number == message.transmitter then
          text = '~o~You received a new message of ~g~'.. contact.display
          break
        end
      end
    FiveLife.ShowAdvancedNotification("CHAR_CHAT_CALL", 1, "~g~Received", "~b~GSM", text)
    PlaySound(-1, "Menu_Accept", "Phone_SoundSet_Default", 0, 0, 1)
    Citizen.Wait(300)
    PlaySound(-1, "Menu_Accept", "Phone_SoundSet_Default", 0, 0, 1)
    Citizen.Wait(300)
    PlaySound(-1, "Menu_Accept", "Phone_SoundSet_Default", 0, 0, 1)
  else
    --
  end
end)

With this new ā€œversionā€ of Mysql I have no error server side but I do not receive the client-side notifications. Incomprehensible to me. it exceeds my skills: /

Actually iā€™ve no error with adminā€™s commands

Using version 3.0.1, specifically commit 28b927f9e964c5f0e81fa9c43f82e811d770e0b0, I have trouble with using base 10 steam IDs.
Test server runs Debian GNU/Linux Sid, MySQL server version: 5.7.18-1 (Debian)
FiveM server build 792-45e7daab29ba0e4b6554084550c8811010f3dd8f (PROOT-LINUX, obviously)

I suspect that somewhere along the line, and I donā€™t know where as Iā€™ve been running an older version for a very long time, the integers lose their 64bit precision?
Iā€™ve seen similar issues in JavaScript, and that fucker wouldnā€™t know a 64bit integer if it was crammed up itā€™s nose.

    local ident,matches = string.gsub(identifier,"steam:","",1)

    if matches > 0 then
        local steamID = tonumber(ident,16)
        log('Running query with steamID',steamID,'derived from',identifier)
        MySQL.Async.fetchAll(
            "SELECT `paradiseName`,`whitelisted`,`banned` FROM `paradiseUsers` WHERE `steamID` = @steamID;",
            {['@steamID'] = steamID},
            function (paradiseUsers)
                log(json.encode(paradiseUsers))
-- etc etc etc

-- Yields:
--[12:47:40] <whitelist> Running query with steamID 76561197992821166 derived from steam:110000101f0c1ae
--[MySQL] [2ms] SELECT `paradiseName`,`whitelisted`,`banned` FROM `paradiseUsers` WHERE `steamID` = 76561197992821170;
--[12:47:40] <whitelist> []

In this case, my Steam ID is 76561197992821166, which is out-of-range for a 32bit integer, gets changed to 76561197992821170 somehow.

This problem is not present in the 2.0 branch, so Iā€™m using that for now. Not a major problem, but I really do think the integer precision is the problem here.
Wild guess is that there was a change in the upstream code that caused this? msyql-connector, or whatever itā€™s called?

Anyway, thank you so very very very much for even having a 2.0 branch. Saved my nuts.
Keep up the good work! <3

Should be the same issue on 3.0.0

Use supportBigNumbers=true can make this standard with 3.0.2

edit:

Updated to 3.0.2

  • Allow multiple statements per query string on the legacy connection string
  • Support bignumbers by default on the legacy connection string
1 Like

With the update 3.0.2 there is a still an error when trying to send a message with the phone

while using the same GCPhone and function as @GrapsZ

Which db version are you using?

Mysql-Async 3.0.2, last update from your github

Still using the legacy connection : set mysql_connection_string ā€œserver=127.0.0.1;database=essentialmode;userid=root;password=ā€

And my MySQL version : 5.7.23

I will install mysql 5.7 tomorrow and see if there are any issues with running it. I donā€™t have any issues when I ran some small scripts over at mine, but I run on MariaDB 10.3.

If someone could give me a basic ESX installation (where the problem occurs resources.zip + server.cfg) with sqls for the database strucutre, that would help alot replicating the problem.

I keep getting a ā€œInvokeNative: execution failed: Argument at index 1 was nullā€ error, Using the latest verison of the linux FX server and version 2.1.1 mysql-async. I have tried it on a fresh fx server, with different sql users, different permissions, etc. Im not sure what the issue is, any help is appreciated. FULL ERROR LOG

EDIT (02/10/18): The current lastest linux build ā€œ796-24a68427a63ced43c9bb1c1f7938e83618188a61ā€ appears to have fixed the issue, i havent tried the windows version but it was made on the same day as the working Linux one.

Hello, I have the same problem as oliverjrose99 with v2 of mysql-async.
But v3.0.2 is fonctional provided someone connect to the server within 10sec if not the first initialization requests make a TimeOutā€¦

FiveM Server 792 on Linux