2

How can I call a C-function from SQL in Tarantool?

Documentation says:

C functions are imported from .so files

But where shall I specify the reference to my .so file?

It would be great to see an example.

Mike Siomkin
  • 667
  • 8
  • 15
  • In that section is only for Lua Functions . Look at https://www.tarantool.io/en/doc/latest/tutorials/c_tutorial/ . I dont nothing about Tarantool but i think enable dev model allow to you create your custom c functions. – Carlos Cocom Nov 09 '20 at 17:27

1 Answers1

3

You should firstly register your function via :func.create:

box.schema.func.create("function1.divide", {language = 'C', returns = 'number',
                        is_deterministic = true,
                        exports = {'LUA', 'SQL'}})

You can read more info on the subj here: https://www.tarantool.io/en/doc/latest/tutorials/c_tutorial/

Then you can use it in SQL:

box.execute('SELECT "function1.divide"()')

Also you can examine more examples in source code (test/box/function1.test.lua).

NikitaRock
  • 353
  • 2
  • 9