MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / check_license

Function check_license

sql-common/client.c:934–968  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

932*/
933
934static 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

Callers 1

client.cFile · 0.85

Calls 4

mysql_real_queryFunction · 0.85
set_mysql_extended_errorFunction · 0.85
mysql_fetch_rowFunction · 0.85
mysql_free_resultFunction · 0.85

Tested by

no test coverage detected