diff options
author | Sergei Golubchik <sergii@pisem.net> | 2014-06-03 09:55:08 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2014-06-03 09:55:08 +0200 |
commit | 5d16592d44d8dd7147ee868c661af842ec0f1568 (patch) | |
tree | 57f83c95bf23bdb90bd05e1134ffaaa0e015249f /sql-common | |
parent | 2d687cad5d1154418603a16e58772d91f37d4cbd (diff) | |
parent | c1fd09f3d4848ae59605564ded9628307d59dd27 (diff) | |
download | mariadb-git-5d16592d44d8dd7147ee868c661af842ec0f1568.tar.gz |
mysql-5.5.38 merge
Diffstat (limited to 'sql-common')
-rw-r--r-- | sql-common/client.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/sql-common/client.c b/sql-common/client.c index 913dab75fda..782c4281c03 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -4319,21 +4319,31 @@ const char * STDCALL mysql_error(MYSQL *mysql) RETURN Signed number > 323000 + Zero if there is no connection */ ulong STDCALL mysql_get_server_version(MYSQL *mysql) { - uint major, minor, version; - 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); - return (ulong) major*10000L+(ulong) (minor*100+version); + ulong major= 0, minor= 0, version= 0; + + if (mysql->server_version) + { + const char *pos= mysql->server_version; + char *end_pos; + /* Skip possible prefix */ + while (*pos && !my_isdigit(&my_charset_latin1, *pos)) + pos++; + major= strtoul(pos, &end_pos, 10); pos=end_pos+1; + minor= strtoul(pos, &end_pos, 10); pos=end_pos+1; + version= strtoul(pos, &end_pos, 10); + } + else + { + set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate); + } + + return major*10000 + minor*100 + version; } |