Skip to content
Snippets Groups Projects
Commit 2187d418 authored by Vladislav Shpilevoy's avatar Vladislav Shpilevoy
Browse files

schema: expose space_mt and index_mt on box.schema table

This commit allows userland to extend the space and index
metatables with their own functions or even metamethods. Reducing
barriers for this kind of experimentation is vital for user
contribution toward the improvement of Tarantool's API.

There are 4 metatables available for extending:
box.schema.space_mt - metatable of all spaces;
box.schema.index_mt - base metatable of all indexes - replicated
                      into the vinyl and memtx. See below how.
box.schema.vinyl_index_mt - metatable of all vinyl indexes;
box.schema.memtx_index_mt - metatable of all memtx indexes.

On the other hand local space/index metatables still can be
extended individually to save compatibility with existing
modules. Routinely space/index metatable is just a proxy for a
global mt. When a user attempts to extend a space or index
methods via local space/index metatable instead of from
box.schema mt, the local metatable is transformed. Its __index
metamethod starts looking up at first in self, and only then into
the global mt.

Closes #3204
parent aea5d9d4
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment