From 7956512d8208a894409f88b39d702ea01a4872d8 Mon Sep 17 00:00:00 2001
From: Igor Kuznetsov <kuznetsovin@gmail.com>
Date: Mon, 7 Feb 2022 14:08:24 +0300
Subject: [PATCH] feat: update to actual tarantool-module

---
 Cargo.toml             |  2 +-
 Makefile               |  4 ++--
 src/executor/result.rs |  2 +-
 src/ir/relation.rs     |  2 +-
 src/lua_bridge.rs      | 11 +++++------
 5 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index d1074fdb54..d5685a522e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,7 +14,7 @@ pest = "2.0"
 pest_derive = "2.0"
 serde = { version = "1.0", features = ["derive"] }
 serde_yaml = "0.8"
-tarantool = { git = "https://sbroad-cargo-token:t-nZyqJVVuhGQv17BX6v@gitlab.com/picodata/picodata/tarantool-module.git", rev="6f6bc329"}
+tarantool = { git = "https://sbroad-cargo-token:t-nZyqJVVuhGQv17BX6v@gitlab.com/picodata/picodata/tarantool-module.git", rev="d8921ec6"}
 traversal = "0.1.2"
 yaml-rust = "0.4.1"
 
diff --git a/Makefile b/Makefile
index 1367dc5da3..d1f6d309cf 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@ else
 	endif
 endif
 build:
-	cargo build
+	cargo build --release
 
 integration_test_app:
 	cd test_app && rm -rf tmp/tarantool.log && TARANTOOL_LOG=tmp/tarantool.log ./.rocks/bin/luatest --coverage -v test/
@@ -24,6 +24,6 @@ lint:
 
 build_test_app:
 	cd test_app && cartridge build
-	cp -rf target/debug/$(SRC_LIB) test_app/.rocks/lib/tarantool/$(DEST_LIB)
+	cp -rf target/release/$(SRC_LIB) test_app/.rocks/lib/tarantool/$(DEST_LIB)
 
 test_all: test build build_test_app integration_test_app
diff --git a/src/executor/result.rs b/src/executor/result.rs
index 5bed961f60..6fc1f35bff 100644
--- a/src/executor/result.rs
+++ b/src/executor/result.rs
@@ -1,6 +1,6 @@
 use crate::errors::QueryPlannerError;
 use serde::ser::{Serialize, SerializeMap, Serializer};
-use tarantool::hlua::{self, LuaRead};
+use tarantool::tlua::{self, LuaRead};
 
 use crate::ir::relation::Column;
 
diff --git a/src/ir/relation.rs b/src/ir/relation.rs
index 71e33d87a0..8d3350a64a 100644
--- a/src/ir/relation.rs
+++ b/src/ir/relation.rs
@@ -6,7 +6,7 @@ use std::fmt::Formatter;
 use serde::de::{Error, MapAccess, Visitor};
 use serde::ser::{Serialize as SerSerialize, SerializeMap, Serializer};
 use serde::{Deserialize, Deserializer, Serialize};
-use tarantool::hlua::{self, LuaRead};
+use tarantool::tlua::{self, LuaRead};
 
 use crate::errors::QueryPlannerError;
 
diff --git a/src/lua_bridge.rs b/src/lua_bridge.rs
index ce4e5fb12e..f5f1a2124d 100644
--- a/src/lua_bridge.rs
+++ b/src/lua_bridge.rs
@@ -1,10 +1,9 @@
 use crate::executor::result::BoxExecuteFormat;
-use tarantool::ffi::tarantool::luaT_state;
-use tarantool::hlua::{Lua, LuaError, LuaFunction};
+use tarantool::tlua::{LuaError, LuaFunction};
 
 /// Function get cartridge cluster schema
 pub fn get_cluster_schema() -> Result<String, LuaError> {
-    let lua = unsafe { Lua::from_existing_state(luaT_state(), false) };
+    let lua = tarantool::lua_state();
 
     let get_schema: LuaFunction<_> = lua.eval("return require('cartridge').get_schema")?;
     let res = get_schema.call()?;
@@ -14,7 +13,7 @@ pub fn get_cluster_schema() -> Result<String, LuaError> {
 
 /// Function execute sql query on selected node
 pub fn exec_query(bucket_id: u64, query: &str) -> Result<BoxExecuteFormat, LuaError> {
-    let lua = unsafe { Lua::from_existing_state(luaT_state(), false) };
+    let lua = tarantool::lua_state();
 
     lua.exec(
         r#"
@@ -46,7 +45,7 @@ pub fn exec_query(bucket_id: u64, query: &str) -> Result<BoxExecuteFormat, LuaEr
 
 /// Sends query to all instances and merges results after (map-reduce).
 pub fn mp_exec_query(query: &str) -> Result<BoxExecuteFormat, LuaError> {
-    let lua = unsafe { Lua::from_existing_state(luaT_state(), false) };
+    let lua = tarantool::lua_state();
 
     lua.exec(
         r#"
@@ -96,7 +95,7 @@ pub fn mp_exec_query(query: &str) -> Result<BoxExecuteFormat, LuaError> {
 
 /// Function get summary count of bucket from vshard
 pub fn bucket_count() -> Result<u64, LuaError> {
-    let lua = unsafe { Lua::from_existing_state(luaT_state(), false) };
+    let lua = tarantool::lua_state();
 
     let bucket_count_fn: LuaFunction<_> =
         lua.eval("return require('vshard').router.bucket_count")?;
-- 
GitLab