Ensure that mysql_get_server_version() also works if there is a non numerical prefix before the version number

This commit is contained in:
Michael Widenius 2009-12-03 17:26:54 +02:00
commit 9aafd0dae2

View file

@ -3208,7 +3208,7 @@ const char * STDCALL mysql_error(MYSQL *mysql)
mysql Connection
EXAMPLE
4.1.0-alfa -> 40100
MariaDB-4.1.0-alfa -> 40100
NOTES
We will ensure that a newer server always has a bigger number.
@ -3221,7 +3221,11 @@ ulong STDCALL
mysql_get_server_version(MYSQL *mysql)
{
uint major, minor, version;
char *pos= mysql->server_version, *end_pos;
const char *pos= mysql->server_version;
char *end_pos;
/* Skip possible prefix */
while (*pos && !my_isdigit(&my_charset_latin1, *pos))
pos++;
major= (uint) strtoul(pos, &end_pos, 10); pos=end_pos+1;
minor= (uint) strtoul(pos, &end_pos, 10); pos=end_pos+1;
version= (uint) strtoul(pos, &end_pos, 10);