[MDEV-9984] SQL object / class plugin type Created: 2016-04-25 Updated: 2016-04-25 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Minor |
| Reporter: | Anders Karlsson | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
This is an idea for a plugin that is similar to a UDF() but it has many more attributes and a more flexible interface. The idea for this type of plugin is that of a CLASS of which one can instanciate OBJECTS. I use this terminology here, although I am far from sure that this is the right one. A plugin of this class, in different to a UDF, has an both implementation and an instance. I came to think about this kind of plugin when considering implementing sequences, so the examples I give here are based on such a sequence plugin. With a CLASS plugin, the class would be sequence, which implements this, and the instance, which is the actual sequence, let's call it ORDERID. The CLASS defines the "methods" to call and the possible attributes of it. The sequence class could hence define the attributes current_value and increment in much the same way as the storage engine API allows an engine to define engine specific attributes in the create table clause. To get values in and out of a CLASS plugin, again the plugin defines some methods. Methods without arguments, beyond some context, can be called without parentheses so it looks like a plain attribute in SQL and not a function. MariaDB should manage the context for these plugins, so that when an object is instantiated a plugin-specific init function is called, once per instance, that creates and returns a reference to this context. MariaDB would possible manage multiple threads accessing this context simultaneously, but maybe not, An instance is alive as long as the server is up, so the init function should only be called once per instance and server start. Methods of Instances of these objects can then be referenced in a SQL statement, like a function, but in the case of these objects they are called with <instance name>.<method> which means that instance names should probably be in the same namespace as tables. An example use might be:
The sequence_class.so plugin defines the methods (in this case currval and nextval) and attributes (currenv_value and increment).
And then use the class:
Beyond sequences another use case might be as for generic file IO operations, in this case I use a TEMPORARY instance which disappears with the session and is session local:
|