summaryrefslogtreecommitdiff
path: root/libmysql
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2004-03-19 15:17:56 +0200
committerunknown <monty@mysql.com>2004-03-19 15:17:56 +0200
commit67ea8aac5e9e9ae98a22aff063c48053ea68e5de (patch)
tree788ab6bf4fc7ac236c7c862ab122f19dcdd83768 /libmysql
parentd212d76094f83b1b7ce0692663439f3a67a432ad (diff)
parent6b465557670093b038cb3d2be930e6a036292192 (diff)
downloadmariadb-git-67ea8aac5e9e9ae98a22aff063c48053ea68e5de.tar.gz
merge with 4.0 (to get compiler error fixes for innodb)
client/mysqltest.c: Auto merged include/errmsg.h: Auto merged include/mysql_version.h.in: Auto merged innobase/que/que0que.c: Auto merged mysql-test/t/rpl000009.test: Auto merged sql/set_var.cc: Auto merged libmysql/errmsg.c: merge with 4.0 libmysql/libmysql.c: merge with 4.0 mysql-test/mysql-test-run.sh: merge with 4.0 mysql-test/r/rpl000009.result: merge with 4.0 scripts/mysql_fix_privilege_tables.sh: merge with 4.0 sql/repl_failsafe.cc: merge with 4.0
Diffstat (limited to 'libmysql')
-rw-r--r--libmysql/errmsg.c3
-rw-r--r--libmysql/libmysql.c51
2 files changed, 54 insertions, 0 deletions
diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c
index e651c13897f..ad93c1b8f9e 100644
--- a/libmysql/errmsg.c
+++ b/libmysql/errmsg.c
@@ -52,6 +52,7 @@ const char *client_errors[]=
"Error connecting to master:",
"SSL connection error",
"Malformed packet",
+ "This client library is licensed only for use with MySQL servers having '%s' license",
"Invalid use of null pointer",
"Statement not prepared",
"Parameters data was not supplied",
@@ -110,6 +111,7 @@ const char *client_errors[]=
"Error connecting to master:",
"SSL connection error",
"Malformed packet",
+ "This client library is licensed only for use with MySQL servers having '%s' license",
"Invalid use of null pointer",
"Statement not prepared",
"Parameters data was not supplied",
@@ -166,6 +168,7 @@ const char *client_errors[]=
"Error connecting to master:",
"SSL connection error",
"Malformed packet",
+ "This client library is licensed only for use with MySQL servers having '%s' license",
"Invalid use of null pointer",
"Statement not prepared",
"Not all parameters data supplied",
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 91927e44e49..0a93fe60990 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -603,6 +603,57 @@ mysql_connect(MYSQL *mysql,const char *host,
#endif
+#ifdef CHECK_LICENSE
+/*
+ Check server side variable 'license'.
+ If the variable does not exist or does not contain 'Commercial',
+ we're talking to non-commercial server from commercial client.
+ SYNOPSIS
+ check_license()
+ RETURN VALUE
+ 0 success
+ !0 network error or the server is not commercial.
+ Error code is saved in mysql->net.last_errno.
+*/
+
+static int check_license(MYSQL *mysql)
+{
+ MYSQL_ROW row;
+ MYSQL_RES *res;
+ NET *net= &mysql->net;
+ static const char query[]= "SELECT @@license";
+ static const char required_license[]= LICENSE;
+
+ if (mysql_real_query(mysql, query, sizeof(query)-1))
+ {
+ if (net->last_errno == ER_UNKNOWN_SYSTEM_VARIABLE)
+ {
+ net->last_errno= CR_WRONG_LICENSE;
+ sprintf(net->last_error, ER(net->last_errno), required_license);
+ }
+ return 1;
+ }
+ if (!(res= mysql_use_result(mysql)))
+ return 1;
+ row= mysql_fetch_row(res);
+ /*
+ If no rows in result set, or column value is NULL (none of these
+ two is ever true for server variables now), or column value
+ mismatch, set wrong license error.
+ */
+ if (!net->last_errno &&
+ (!row || !row[0] ||
+ strncmp(row[0], required_license, sizeof(required_license))))
+ {
+ net->last_errno= CR_WRONG_LICENSE;
+ sprintf(net->last_error, ER(net->last_errno), required_license);
+ }
+ mysql_free_result(res);
+ return net->last_errno;
+}
+#endif /* CHECK_LICENSE */
+
+
/**************************************************************************
Change user and database
**************************************************************************/