Skip to content

Conversation

@MichaelHillcox
Copy link
Contributor

@MichaelHillcox MichaelHillcox commented Sep 17, 2016

Currently having an issue to where this happens on start up

^1Error: Sys_LoadLibrary error: /home/cod4/.callofduty4/plugin.mysql.tmp: undefined symbol: mysql_get_client_version
^1Error: Failed to load the plugin /home/cod4/.callofduty4/plugin.mysql.tmp!

I know for sure that mysql_get_client_version is fine in the code/ From what I understand its something todo with how the mysql lib is not being loaded because its plugin.

someone much better at this than I will need to take a look at it and see if they can figure out whats going wrong. I've also including a unix build file aswell as adding a readme.md and docs on how to use the functions. I've modified mysql_real_connect's prams to allow for mulitiple different connections to different databases. I've left the port CVAR but removed the rest. They need to be dynamic.

@T-Maxxx
Copy link
Contributor

T-Maxxx commented Sep 17, 2016

Are not header files for Unix and Windows the same?

@T-Maxxx
Copy link
Contributor

T-Maxxx commented Sep 17, 2016

Leave mysql_fetch_row in peace. :D If you want, you can add mysql_fetch_rows, but keep it here as documented mysql function.

@T-Maxxx
Copy link
Contributor

T-Maxxx commented Sep 17, 2016

And you can not create arrays with non constant size ( variable ) specificator. For that you must allocate memory. BUT we should not allocate RAM in any parts of cod4x server. Instead of that we should reserve ehough space in stack.
About cvars. Im thinking about 4 database connections at same time. This must be enough for most cases. As I read, if you didnt pass pointer to MYSQL structure, it allocates a new one. We should avoid that.

@T-Maxxx
Copy link
Contributor

T-Maxxx commented Sep 17, 2016

Thank you. Moved your pull request to pr1 branch because a lot of things must be fixed.

@T-Maxxx T-Maxxx closed this Sep 17, 2016
@MichaelHillcox
Copy link
Contributor Author

MichaelHillcox commented Sep 17, 2016

@T-Maxxx thats so not how branches work nor is it how pull requests work. If this needed fixing then it should of stayed open so I could fix the issues. Not so I can go and work on a different branch. Thats literally more work for me for no reason. Please reopen this and remove the new branch because its unneeded. I'm not offering alternative code here, I'm offering fixes and improvements to the original code. I how no idea what you mean about a few things so could you reopen this and review my code so I can fix said things.

Also no Unix and Windows headers are different not sure why. But they seem to be .

for the array structure I am only every allocating the amount of columns to the stringIndex or what ever its called. Before I was doing it for every rows column of which is stupid of course. So thats been fixed. I replaced your mysql_fetch_row because I have no idea how that would actually work out in game. Could you show me an example.

"About cvars. Im thinking about 4 database connections at same time. This must be enough for most cases. As I read, if you didnt pass pointer to MYSQL structure, it allocates a new one. We should avoid that."? all I did was move it back to using arguments and fail if it does not get them. I don't think I changed anything with now you are doing the pointers. Your way of mysql_init and the assigning it to an &mysql was much better than our original way so I left it :)

"And you can not create arrays with non constant size ( variable ) specificator. For that you must allocate memory. BUT we should not allocate RAM in any parts of cod4x server. Instead of that we should reserve ehough space in stack." to which bit of code are you referring to?

@T-Maxxx
Copy link
Contributor

T-Maxxx commented Sep 17, 2016

@MichaelHillcox Seems you didn't tried to compile this after changes you made so I decided to close PR and fix errors by myself.

@MichaelHillcox
Copy link
Contributor Author

@T-Maxxx I would like to give it ago but fair enough. Also update the readme if you change any functions around :P also "Moved your pull request to pr1 branch because a lot of things must be fixed." does not say that you want to do it yourself :P Maybe more clear next time?

also please leave arguments in the mysql_real_connect. Its really something that should an override system at the least. If the cvar isn't defined then default to arguments or vice verser.

@MichaelHillcox
Copy link
Contributor Author

@T-Maxxx I did compile this. I have the .so to prove it. I also did test it a lot. Look at me fixes in the code. So yeah. I also made a linux build file? how are you not seeing that I didn't compile this?

@T-Maxxx
Copy link
Contributor

T-Maxxx commented Sep 17, 2016

@MichaelHillcox 'mysql_fetch_rows' will return one- or two-dimensional array. Prove me why this is better than unified 2-dimensional array? You have to handle 2 cases instead of one.

a[<keys>] and a[0][<keys>], a[1][<keys>]...
against
a[0][<keys>] and a[0][<keys>], a[1][<keys>]...

@MichaelHillcox
Copy link
Contributor Author

@T-Maxxx I continue to not understand. So you would create a 2D array when you only need a 1D array if there is only one row? remembering that the first dimension is purely for the rows.

@T-Maxxx
Copy link
Contributor

T-Maxxx commented Sep 17, 2016

@MichaelHillcox Why not? You expecting to get unknown numbers of lines by parsing WHOLE MYSQL_RES. In your way, your GSC must handle both cases: when a is a 1D array and when a is a 2D array.
My way: mysql_fetch_rows will return 2D array always and your GSC will handle only 2D arrays whereas mysql_fetch_row will return you only 1D array.

@MichaelHillcox
Copy link
Contributor Author

in gsc check for mysql_row_count or what ever it is. Its just a nicer way of doing it. You can either always use a for loop or use an if.

@T-Maxxx
Copy link
Contributor

T-Maxxx commented Sep 17, 2016

@MichaelHillcox Oh, nice!

rowCount = mysql_row_count(handle);
if(rowCount == 1)
    do_something_with_1D_array();
else
    do_something_more_with_2D_array();

As I said, you have to handle 2 cases in GSC.

@MichaelHillcox
Copy link
Contributor Author

@T-Maxxx You have to handle two cases either way. It doesn't really matter. If you are only expecting one result "SELECT pdsjsapodjs limit 0,1" then its nice to have that ability.

@T-Maxxx
Copy link
Contributor

T-Maxxx commented Sep 17, 2016

@MichaelHillcox

arr = mysql_fetch_rows(handle);
for(i = 0; i < arr.size; ++i) // Got 1 record? Ok... Got 2 records? Not a problem. Got 0 records? Aw, come on...
    do_something_with_row(arr[i]);
arr = mysql_fetch_row(handle); // Expect 1 row? Here you go!
if(arr.size == 0)
    do_something_unexpected();
else
    do_something_with_1D_array(arr);

T-Maxxx pushed a commit that referenced this pull request Dec 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants