This post is the fifth 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
We are back to our component and we will see how we can use the dynamic privilege component service to add a new privilege when we install our component.
This privilege will be checked later when we will create our functions.
Of course, when we uninstall our component, the privilege also needs to be removed.
In this article we will only register and “unregister” our privilege and add a message in error log.
As usual we start with our scan.h file:
To create our privilege, we included the dynamic privilege component service header (line 24) and place holder (line 28).
We can now modify the code of scan.cc to register and unregister our new privilege:
On line 32 we added the place holder and we require the service on line 86.
Lines 47 to 55 si the registration of the privilege with a message to error log. The “unregistration” is coded from line 60 to 75.
As you can see this is very easy when using the component infrastructure.
Let’s test it:

Great ! We can now create a component that adds new privileges to MySQL.
On the next article we will create our first function.
Stay tuned and enjoy MySQL coding !
[…] Extending MySQL using the Component Infrastructure – part 5: privileges […]
[…] Extending MySQL using the Component Infrastructure – part 5: privileges […]
[…] Extending MySQL using the Component Infrastructure – part 5: privileges […]
[…] Extending MySQL using the Component Infrastructure – part 5: privileges […]
[…] Extending MySQL using the Component Infrastructure – part 5: privileges […]
[…] Extending MySQL using the Component Infrastructure – part 5: privileges […]
[…] Extending MySQL using the Component Infrastructure – part 5: privileges […]
[…] Extending MySQL using the Component Infrastructure – part 5: privileges […]
[…] Extending MySQL using the Component Infrastructure – part 5: privileges […]
[…] Extending MySQL using the Component Infrastructure – part 5: privileges […]
[…] Extending MySQL using the Component Infrastructure – part 5: privileges […]