forward declaration problem in plugin.h

Asked by Kim Kyungnam

Dears...
I'm new in developing mariadb plugin.
I hava a plan about developing special monotoring tool for maraidb and will contribute that code this community.
Simple POC is in progress. and I've a problem in my code.
I read the guide for developing mariadb plugin. I choose my plugin type as deamon type.
So I write the code which collecting THD 's data. (class THD) . I want to use collect perf data by direct memory access method not using sql. ( like gathering v$view data by attaching oracle shared memory not sql)

In my code, there are some errors while building as follows.

----------------------------------------------------------------------------------------------
mysource.cc : error: invalid use of incomplete type 'struct THD'
mysql/plugin.h:41:error : forward declaration of 'struct THD'
----------------------------------------------------------------------------------------------

in mysource.cc
---------------------------------------------------------------------------
...
THD* thd;
void functionA()
{
       thd = ....
       thd->query() // <- at this point , error occurred

}
--------------------------------------------------------------------------------------
Because THD is forward declared in mysql/plugin.h, this errors occurred in my thought. right?
I think that THD's member variable or method is not allowed to access in case of forward declaration.
so I add #include "sql_class.h" in mysource.cc , but errors still exists.
I'm not good at reading mariadb's source code yet. please help me to solve this problem.

if you need addtional infomations, please let me know.
Thanks in advance.

Question information

Language:
English Edit question
Status:
Answered
For:
MariaDB Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Sergei Golubchik (sergii) said :
#1

In the future, please send your questions to the mailing list: <email address hidden>.

As for THD — it's not supposed to be used by plugins, that's why you don't see it's declaration.

And it's because everything that is supposed to be used by plugins is part of the "Plugin API", MariaDB promises that the API is stable, doesn't change often, and so on.

There is no such promise for the THD — it can change between minor releases, and your plugin will need to be recompiled for every minor MariaDB release.

Now, if you still want to use THD — all you need to do is to define MYSQL_SERVER before including sql_class.h. Just keep in mind that by doing that you'll be using MariaDB internal data structures, and there is no guarantee that they won't change in the next release.

Can you help with this problem?

Provide an answer of your own, or ask Kim Kyungnam for more information if necessary.

To post a message you must log in.