Split issue (Index out of range exception)
[1.03394e+006,26755.5,12.442,"C:\Users\sparcdr\Documents\ArmA 2\mpmissions\test.Chernarus\SQL\ARM2Mysql.sqf:79","PARAMS_3: _databaseName=theapp, _procedureName=RemoveNonExistantItem, _parameters="0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65",1234567"]
DECLARE i INT;
DECLARE amount INT;
DECLARE str VARCHAR(500);
IF i < 355 THEN
SET str = (SELECT SPLIT_STR((items), ',', i));
SET amount = (SELECT count(itemid) FROM inventory WHERE itemid=str AND uid=theuid);
IF (amount > 0) THEN
DELETE FROM `inventory` WHERE itemid = str AND uid = theuid;
ELSEIF i > 354 THEN
SET i = i + 1;
END LOOP split;
"0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65",1234567 as input for items,theuid using native tools (Not pipe) succeeds.
Updated by sparcdr almost 5 years ago
Perhaps add a feature to pass the string literal when the delimiter is a pipe symbol in place of a comma. Now that I think of it, the bug is a symptom of the comma bug, but I absolutely need to delimit by comma for procedure IN, to get around timing bugs with pipe performance on large datasends. Previously I thought, ItemInInventoryIN itemid int(4), uid int(11) would work, but to run on a for loop individually without time control will kill the pipe handle, so lobbing the data together as you would a publicVariable is a reasonable expectation.
This is private because the procedure took me a lot of labor, but if you come up with a fix, use it as a testcase.
Updated by firefly2442 almost 5 years ago
Is this related to the size of the pipe? Right now, the C# side limits reading in characters to 4096. Is this the issue or is it on the Arma2 side?
Updated by sparcdr almost 4 years ago
I've purposely broken apart the procedure sends to <= 2047 characters (In this case ~300 each iteration) using arrays and formatting in ARMA 2 with a 2 second delay on the for loop.
The C# code is attempting to split the string when it receives it, which crashes it, despite the length being well under the ARMA engine limit, same the pipe.
It's an issue with split at delimiter, and glob matching the string in the C# string code when it needs to also check the length (Ignoring the need to split if the string's under 2048 bytes)