This post is the fourth post of a series of articles on extending MySQL with the Component Infrastructure, the list above will be updated as new articles are published:
- Extending MySQL using the Component Infrastructure – part 1
- Extending MySQL using the Component Infrastructure – part 2: building the server
- Extending MySQL using the Component Infrastructure – part 3: component services
- Extending MySQL using the Component Infrastructure – part 4: error logging
- Extending MySQL using the Component Infrastructure – part 5: privileges
- Extending MySQL using the Component Infrastructure – part 6: functions
- Extending MySQL using the Component Infrastructure – part 7: messages to users
In this article we will add to our component the capability to add messages in error log (and performance_schema.error_log
table) using the log builtins component service.
You will notice that this very easy and fast.
We start as usual with scan.h
:
On line 22 and 23 we add the headers. mysqld_error.h
is required to define ER_LOG_PRINTF_MSG.
Then we specify the services that we need.
We can then update scan.cc to also include those services and use them on 42 and 54:
We also need to tell that our component requires those services on line 60 and 61.
We can compile it again (using make component_viruscan
), restart mtr and test it again:
And in error log file, we can also see the following lines:
2022-01-06T09:26:14.450784Z 8 [Note] [MY-011071] [Server] Component viruscan reported: 'initializing...' 2022-01-06T09:26:21.906295Z 8 [Note] [MY-011071] [Server] Component viruscan reported: 'uninstalled.'
On the next article, we will create our new privilege, stay tuned and enjoy MySQL!
[…] Extending MySQL using the Component Infrastructure – part 4: error logging […]
[…] Extending MySQL using the Component Infrastructure – part 4: error logging […]
[…] Extending MySQL using the Component Infrastructure – part 4: error logging […]
[…] Extending MySQL using the Component Infrastructure – part 4: error logging […]
[…] Extending MySQL using the Component Infrastructure – part 4: error logging […]
[…] Extending MySQL using the Component Infrastructure – part 4: error logging […]