Below is the list of changes that have just been committed into a local
5.1 repository of istruewing. When istruewing does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-04-26 11:23:17+02:00, istruewing@stripped +4 -0
WL#2936 - Falcon & MySQL plugin interface: server variables
Added initialization for plugin string variables.
Added deallocation of string values before a plugin and its
variables is deleted.
mysql-test/r/innodb-lock.result@stripped, 2007-04-26 11:23:15+02:00, istruewing@stripped
+1 -1
WL#2936 - Falcon & MySQL plugin interface: server variables
Fixed test result for fixed handling of innodb_table_locks.
mysql-test/t/innodb-lock.test@stripped, 2007-04-26 11:23:15+02:00, istruewing@stripped
+2 -1
WL#2936 - Falcon & MySQL plugin interface: server variables
Fixed usage of session variable. Changing the global value
does not change the session value.
plugin/fulltext/plugin_example.c@stripped, 2007-04-26 11:23:15+02:00,
istruewing@stripped +16 -2
WL#2936 - Falcon & MySQL plugin interface: server variables
Added examples for thread variables, which have a SESSION and
a GLOBAL value.
sql/sql_plugin.cc@stripped, 2007-04-26 11:23:15+02:00, istruewing@stripped +53 -3
WL#2936 - Falcon & MySQL plugin interface: server variables
Clearing newly allocated variable value space. This is important
for string variables.
Added a function to free global value space for string variables.
Call the function before deleting a plugin and its variables.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: istruewing
# Host: chilla.local
# Root: /home/mydev/mysql-5.1-wl2936-two
--- 1.6/mysql-test/r/innodb-lock.result 2007-04-26 11:23:26 +02:00
+++ 1.7/mysql-test/r/innodb-lock.result 2007-04-26 11:23:26 +02:00
@@ -33,7 +33,7 @@ SELECT * from t1 where id = 0 FOR UPDATE
id x
0 0
set autocommit=0;
-set @@innodb_table_locks=0;
+set innodb_table_locks=0;
lock table t1 write;
update t1 set x=10 where id = 2;
SELECT * from t1 where id = 2;
--- 1.15/mysql-test/t/innodb-lock.test 2007-04-26 11:23:26 +02:00
+++ 1.16/mysql-test/t/innodb-lock.test 2007-04-26 11:23:26 +02:00
@@ -69,7 +69,8 @@ SELECT * from t1 where id = 0 FOR UPDATE
connection con2;
set autocommit=0;
-set @@innodb_table_locks=0;
+# Set SESSION value of innodb_table_locks variable.
+set innodb_table_locks=0;
# The following statement should work becase innodb doesn't check table locks
lock table t1 write;
--- 1.54/sql/sql_plugin.cc 2007-04-26 11:23:26 +02:00
+++ 1.55/sql/sql_plugin.cc 2007-04-26 11:23:26 +02:00
@@ -196,6 +196,7 @@ static bool register_builtin(struct st_m
struct st_plugin_int **);
static void unlock_variables(THD *thd, struct system_variables *vars);
static void cleanup_variables(THD *thd, struct system_variables *vars);
+static void plugin_vars_free_values(sys_var *vars);
static void plugin_opt_set_limits(struct my_option *options,
const struct st_mysql_sys_var *opt);
#define my_intern_plugin_lock(A,B) intern_plugin_lock(A,B CALLER_INFO)
@@ -829,6 +830,8 @@ static void plugin_del(struct st_plugin_
{
DBUG_ENTER("plugin_del(plugin)");
safe_mutex_assert_owner(&LOCK_plugin);
+ /* Free allocated strings before deleting the plugin. */
+ plugin_vars_free_values(plugin->system_vars);
hash_delete(&plugin_hash[plugin->plugin->type], (byte*)plugin);
plugin_dl_del(&plugin->plugin_dl->dl);
plugin->state= PLUGIN_IS_FREED;
@@ -1573,6 +1576,7 @@ bool mysql_install_plugin(THD *thd, cons
TABLE *table;
int error, argc;
char *argv[2];
+ char arg0[]= { '\0' };
struct st_plugin_int *tmp;
DBUG_ENTER("mysql_install_plugin");
@@ -1588,7 +1592,8 @@ bool mysql_install_plugin(THD *thd, cons
pthread_mutex_lock(&LOCK_plugin);
rw_wrlock(&LOCK_system_variables_hash);
- argv[0]= ""; /* handle_options() assumes arg0 (program name) always exists */
+ /* handle_options() assumes arg0 (program name) always exists */
+ argv[0]= arg0;
argv[1]= NULL;
argc= 1;
error= plugin_add(thd->mem_root, name, dl, &argc, argv, REPORT_TO_USER);
@@ -2171,6 +2176,17 @@ static st_bookmark *register_var(const c
max_system_variables.dynamic_variables_ptr=
my_realloc(max_system_variables.dynamic_variables_ptr, new_size,
MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
+ /*
+ Clear the new variable value space. This is required for string
+ variables. If their value is non-NULL, it must point to a valid
+ string.
+ */
+ bzero(global_system_variables.dynamic_variables_ptr +
+ global_variables_dynamic_size,
+ new_size - global_variables_dynamic_size);
+ bzero(max_system_variables.dynamic_variables_ptr +
+ global_variables_dynamic_size,
+ new_size - global_variables_dynamic_size);
global_variables_dynamic_size= new_size;
}
@@ -2379,6 +2395,40 @@ void plugin_thdvar_cleanup(THD *thd)
}
+/**
+ @brief Free values of thread variables of a plugin.
+
+ @detail This must be called before a plugin is deleted. Otherwise its
+ variables are no longer accessible and the value space is lost. Note
+ that only string values with PLUGIN_VAR_MEMALLOC are allocated and
+ must be freed.
+
+ @param[in] vars Chain of system variables of a plugin
+*/
+
+static void plugin_vars_free_values(sys_var *vars)
+{
+ DBUG_ENTER("plugin_vars_free_values");
+
+ for (sys_var *var= vars; var; var= var->next)
+ {
+ sys_var_pluginvar *piv= var->cast_pluginvar();
+ if (piv &&
+ ((piv->plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR)
&&
+ (piv->plugin_var->flags & PLUGIN_VAR_MEMALLOC))
+ {
+ /* Free the string from global_system_variables. */
+ char **valptr= (char**) piv->real_value_ptr(NULL, OPT_GLOBAL);
+ DBUG_PRINT("plugin", ("freeing value for: '%s' addr: 0x%lx",
+ var->name, (long) valptr));
+ my_free(*valptr, MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
+ *valptr= NULL;
+ }
+ }
+ DBUG_VOID_RETURN;
+}
+
+
bool sys_var_pluginvar::check_update_type(Item_result type)
{
if (is_readonly())
@@ -2421,10 +2471,10 @@ SHOW_TYPE sys_var_pluginvar::show_type()
byte* sys_var_pluginvar::real_value_ptr(THD *thd, enum_var_type type)
{
- DBUG_ASSERT(thd);
+ DBUG_ASSERT(thd || (type != OPT_SESSION));
if (plugin_var->flags & PLUGIN_VAR_THDLOCAL)
{
- if (type == OPT_GLOBAL)
+ if (type != OPT_SESSION)
thd= NULL;
return intern_sys_var_ptr(thd, *(int*) (plugin_var+1), false);
--- 1.18/plugin/fulltext/plugin_example.c 2007-04-26 11:23:26 +02:00
+++ 1.19/plugin/fulltext/plugin_example.c 2007-04-26 11:23:26 +02:00
@@ -225,16 +225,30 @@ static char *sysvar_two_value;
static MYSQL_SYSVAR_LONG(simple_sysvar_one, sysvar_one_value,
PLUGIN_VAR_RQCMDARG,
"Simple fulltext parser example system variable number one. Give a number.",
- NULL, NULL, 100L, 10L, ~0L, 0);
+ NULL, NULL, 77L, 7L, 777L, 0);
static MYSQL_SYSVAR_STR(simple_sysvar_two, sysvar_two_value,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC,
"Simple fulltext parser example system variable number two. Give a string.",
- NULL, NULL, NULL);
+ NULL, NULL, "simple sysvar two default");
+
+static MYSQL_THDVAR_LONG(simple_thdvar_one,
+ PLUGIN_VAR_RQCMDARG,
+ "Simple fulltext parser example thread variable number one. Give a number.",
+ NULL, NULL, 88L, 8L, 888L, 0);
+ /* Note that string variable default is allowed, but not used. */
+
+static MYSQL_THDVAR_STR(simple_thdvar_two,
+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC,
+ "Simple fulltext parser example thread variable number two. Give a string.",
+ NULL, NULL, "simple thdvar two default");
+ /* Note that string variable default is allowed, but not used. */
static struct st_mysql_sys_var* simple_system_variables[]= {
MYSQL_SYSVAR(simple_sysvar_one),
MYSQL_SYSVAR(simple_sysvar_two),
+ MYSQL_SYSVAR(simple_thdvar_one),
+ MYSQL_SYSVAR(simple_thdvar_two),
NULL
};
| Thread |
|---|
| • bk commit into 5.1 tree (istruewing:1.2585) | ingo | 26 Apr |