Merge lp:~atcurtis/maria/10.0-opaque-thdvar into lp:maria

Proposed by Antony T Curtis
Status: Needs review
Proposed branch: lp:~atcurtis/maria/10.0-opaque-thdvar
Merge into: lp:maria
Diff against target: 77 lines (+21/-0)
2 files modified
include/mysql/plugin.h (+6/-0)
sql/sql_plugin.cc (+15/-0)
To merge this branch: bzr merge lp:~atcurtis/maria/10.0-opaque-thdvar
Reviewer Review Type Date Requested Status
Sergei Golubchik Pending
Review via email: mp+214139@code.launchpad.net

Description of the change

OPAQUE thdvar is useful for plugins.
Plugin is responsible for freeing data on connection close (plugin dependent behaviour).

To post a comment you must log in.
Revision history for this message
Sergei Golubchik (sergii) wrote :

Hi, Antony!

> OPAQUE thdvar is useful for plugins.
> Plugin is responsible for freeing data on connection close (plugin dependent behaviour).

What's the point of this? To create THD-local storage for plugins, not
visible or accessible from SQL?

Regards,
Sergei

Revision history for this message
Antony T Curtis (atcurtis) wrote :

Yes, exactly.
On Apr 9, 2014 5:45 AM, "Sergei" <email address hidden> wrote:

> Hi, Antony!
>
> > OPAQUE thdvar is useful for plugins.
> > Plugin is responsible for freeing data on connection close (plugin
> dependent behaviour).
>
> What's the point of this? To create THD-local storage for plugins, not
> visible or accessible from SQL?
>
> Regards,
> Sergei
>
> --
> https://code.launchpad.net/~atcurtis/maria/10.0-opaque-thdvar/+merge/214139
> You are the owner of lp:~atcurtis/maria/10.0-opaque-thdvar.
>

Unmerged revisions

4144. By Antony T Curtis

Implement missing OPAQUE plugin thdvar.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/mysql/plugin.h'
2--- include/mysql/plugin.h 2014-03-21 12:30:55 +0000
3+++ include/mysql/plugin.h 2014-04-04 00:33:54 +0000
4@@ -211,6 +211,7 @@
5 #define PLUGIN_VAR_ENUM 0x0006
6 #define PLUGIN_VAR_SET 0x0007
7 #define PLUGIN_VAR_DOUBLE 0x0008
8+#define PLUGIN_VAR_OPAQUE 0x000f
9 #define PLUGIN_VAR_UNSIGNED 0x0080
10 #define PLUGIN_VAR_THDLOCAL 0x0100 /* Variable is per-connection */
11 #define PLUGIN_VAR_READONLY 0x0200 /* Server variable is read only */
12@@ -453,6 +454,11 @@
13 PLUGIN_VAR_DOUBLE | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
14 #name, comment, check, update, -1, def, min, max, blk, NULL }
15
16+#define MYSQL_THDVAR_OPAQUE(name, type) \
17+DECLARE_MYSQL_THDVAR_BASIC(name, __typeof__ (type *)) = { \
18+ PLUGIN_VAR_OPAQUE | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_NOSYSVAR | PLUGIN_VAR_NOCMDOPT, \
19+ #name, NULL, NULL, NULL, -1, NULL, NULL }
20+
21 /* accessor macros */
22
23 #define SYSVAR(name) \
24
25=== modified file 'sql/sql_plugin.cc'
26--- sql/sql_plugin.cc 2014-03-26 21:25:38 +0000
27+++ sql/sql_plugin.cc 2014-04-04 00:33:54 +0000
28@@ -2444,6 +2444,7 @@
29 typedef DECLARE_MYSQL_THDVAR_BASIC(thdvar_bool_t, my_bool);
30 typedef DECLARE_MYSQL_SYSVAR_BASIC(sysvar_str_t, char *);
31 typedef DECLARE_MYSQL_THDVAR_BASIC(thdvar_str_t, char *);
32+typedef DECLARE_MYSQL_THDVAR_BASIC(thdvar_opaque_t, void *);
33
34 typedef DECLARE_MYSQL_SYSVAR_TYPELIB(sysvar_enum_t, unsigned long);
35 typedef DECLARE_MYSQL_THDVAR_TYPELIB(thdvar_enum_t, unsigned long);
36@@ -2862,6 +2863,9 @@
37 case PLUGIN_VAR_DOUBLE:
38 size= sizeof(double);
39 break;
40+ case PLUGIN_VAR_OPAQUE:
41+ size= sizeof(void*);
42+ break;
43 default:
44 DBUG_ASSERT(0);
45 return NULL;
46@@ -3069,6 +3073,11 @@
47 return (double *) intern_sys_var_ptr(thd, offset, true);
48 }
49
50+static void **mysql_sys_var_ptr(THD* thd, int offset)
51+{
52+ return (void **) intern_sys_var_ptr(thd, offset, true);
53+}
54+
55 void plugin_thdvar_init(THD *thd)
56 {
57 plugin_ref old_table_plugin= thd->variables.table_plugin;
58@@ -3643,6 +3652,9 @@
59 case PLUGIN_VAR_DOUBLE:
60 ((thdvar_double_t *) opt)->resolve= mysql_sys_var_double;
61 break;
62+ case PLUGIN_VAR_OPAQUE:
63+ ((thdvar_opaque_t *) opt)->resolve= mysql_sys_var_ptr;
64+ break;
65 default:
66 sql_print_error("Unknown variable type code 0x%x in plugin '%s'.",
67 opt->flags, plugin_name);
68@@ -3712,6 +3724,9 @@
69 if (!opt->update)
70 opt->update= update_func_double;
71 break;
72+ case PLUGIN_VAR_OPAQUE:
73+ /* this type is opaque */
74+ break;
75 default:
76 sql_print_error("Unknown variable type code 0x%x in plugin '%s'.",
77 opt->flags, plugin_name);

Subscribers

People subscribed via source and target branches