| 932 | */ |
| 933 | |
| 934 | static int check_license(MYSQL *mysql) |
| 935 | { |
| 936 | MYSQL_ROW row; |
| 937 | MYSQL_RES *res; |
| 938 | NET *net= &mysql->net; |
| 939 | static const char query[]= "SELECT @@license"; |
| 940 | static const char required_license[]= STRINGIFY_ARG(LICENSE); |
| 941 | |
| 942 | if (mysql_real_query(mysql, query, sizeof(query)-1)) |
| 943 | { |
| 944 | if (net->last_errno == ER_UNKNOWN_SYSTEM_VARIABLE) |
| 945 | { |
| 946 | set_mysql_extended_error(mysql, CR_WRONG_LICENSE, unknown_sqlstate, |
| 947 | ER(CR_WRONG_LICENSE), required_license); |
| 948 | } |
| 949 | return 1; |
| 950 | } |
| 951 | if (!(res= mysql_use_result(mysql))) |
| 952 | return 1; |
| 953 | row= mysql_fetch_row(res); |
| 954 | /* |
| 955 | If no rows in result set, or column value is NULL (none of these |
| 956 | two is ever true for server variables now), or column value |
| 957 | mismatch, set wrong license error. |
| 958 | */ |
| 959 | if (!net->last_errno && |
| 960 | (!row || !row[0] || |
| 961 | strncmp(row[0], required_license, sizeof(required_license)))) |
| 962 | { |
| 963 | set_mysql_extended_error(mysql, CR_WRONG_LICENSE, unknown_sqlstate, |
| 964 | ER(CR_WRONG_LICENSE), required_license); |
| 965 | } |
| 966 | mysql_free_result(res); |
| 967 | return net->last_errno; |
| 968 | } |
| 969 | #endif /* CHECK_LICENSE */ |
| 970 | |
| 971 |
no test coverage detected