Drop stream when test case is over. Add commands to disable built-in lualib. (#17134)
This commit is contained in:
parent
44b8d659ba
commit
8a74613a13
|
@ -1,6 +1,12 @@
|
||||||
# TDengine driver connector for Lua
|
# TDengine driver connector for Lua
|
||||||
|
|
||||||
It's a Lua implementation for [TDengine](https://github.com/taosdata/TDengine), an open-sourced big data platform designed and optimized for the Internet of Things (IoT), Connected Cars, Industrial IoT, and IT Infrastructure and Application Monitoring. You may need to install Lua5.3 .
|
It's a Lua implementation for [TDengine](https://github.com/taosdata/TDengine), an open-sourced big data platform designed and optimized for the Internet of Things (IoT), Connected Cars, Industrial IoT, and IT Infrastructure and Application Monitoring. You may need to install Lua5.3 .
|
||||||
|
As TDengine is built with lua-enable with default configure, the built-in lua lib conflicts with external lua lib. The following commands require TDengine built with lua-disable.
|
||||||
|
To disable built-in lua:
|
||||||
|
```
|
||||||
|
mkdir debug && cd debug
|
||||||
|
cmake .. -DBUILD_LUA=false && cmake --build .
|
||||||
|
```
|
||||||
|
|
||||||
## Lua Dependencies
|
## Lua Dependencies
|
||||||
- Lua:
|
- Lua:
|
||||||
|
|
|
@ -60,6 +60,7 @@ static int l_connect(lua_State *L){
|
||||||
|
|
||||||
lua_settop(L, 0);
|
lua_settop(L, 0);
|
||||||
|
|
||||||
|
taos_init();
|
||||||
|
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
int table_index = lua_gettop(L);
|
int table_index = lua_gettop(L);
|
||||||
|
@ -136,15 +137,19 @@ static int l_query(lua_State *L){
|
||||||
lua_pushstring(L,fields[i].name);
|
lua_pushstring(L,fields[i].name);
|
||||||
int32_t* length = taos_fetch_lengths(result);
|
int32_t* length = taos_fetch_lengths(result);
|
||||||
switch (fields[i].type) {
|
switch (fields[i].type) {
|
||||||
|
case TSDB_DATA_TYPE_UTINYINT:
|
||||||
case TSDB_DATA_TYPE_TINYINT:
|
case TSDB_DATA_TYPE_TINYINT:
|
||||||
lua_pushinteger(L,*((char *)row[i]));
|
lua_pushinteger(L,*((char *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
case TSDB_DATA_TYPE_USMALLINT:
|
||||||
case TSDB_DATA_TYPE_SMALLINT:
|
case TSDB_DATA_TYPE_SMALLINT:
|
||||||
lua_pushinteger(L,*((short *)row[i]));
|
lua_pushinteger(L,*((short *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
case TSDB_DATA_TYPE_UINT:
|
||||||
case TSDB_DATA_TYPE_INT:
|
case TSDB_DATA_TYPE_INT:
|
||||||
lua_pushinteger(L,*((int *)row[i]));
|
lua_pushinteger(L,*((int *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
case TSDB_DATA_TYPE_UBIGINT:
|
||||||
case TSDB_DATA_TYPE_BIGINT:
|
case TSDB_DATA_TYPE_BIGINT:
|
||||||
lua_pushinteger(L,*((int64_t *)row[i]));
|
lua_pushinteger(L,*((int64_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
@ -154,6 +159,7 @@ static int l_query(lua_State *L){
|
||||||
case TSDB_DATA_TYPE_DOUBLE:
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
lua_pushnumber(L,*((double *)row[i]));
|
lua_pushnumber(L,*((double *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
case TSDB_DATA_TYPE_JSON:
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
case TSDB_DATA_TYPE_BINARY:
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
case TSDB_DATA_TYPE_NCHAR:
|
||||||
//printf("type:%d, max len:%d, current len:%d\n",fields[i].type, fields[i].bytes, length[i]);
|
//printf("type:%d, max len:%d, current len:%d\n",fields[i].type, fields[i].bytes, length[i]);
|
||||||
|
@ -197,7 +203,7 @@ void async_query_callback(void *param, TAOS_RES *result, int code){
|
||||||
printf("failed, reason:%s\n", taos_errstr(result));
|
printf("failed, reason:%s\n", taos_errstr(result));
|
||||||
lua_pushinteger(L, -1);
|
lua_pushinteger(L, -1);
|
||||||
lua_setfield(L, table_index, "code");
|
lua_setfield(L, table_index, "code");
|
||||||
lua_pushstring(L,"something is wrong");// taos_errstr(taos));
|
lua_pushstring(L, taos_errstr(result));
|
||||||
lua_setfield(L, table_index, "error");
|
lua_setfield(L, table_index, "error");
|
||||||
}else{
|
}else{
|
||||||
//printf("success to async query.\n");
|
//printf("success to async query.\n");
|
||||||
|
|
|
@ -203,7 +203,7 @@ void async_query_callback(void *param, TAOS_RES *result, int code){
|
||||||
printf("failed, reason:%s\n", taos_errstr(result));
|
printf("failed, reason:%s\n", taos_errstr(result));
|
||||||
lua_pushinteger(L, -1);
|
lua_pushinteger(L, -1);
|
||||||
lua_setfield(L, table_index, "code");
|
lua_setfield(L, table_index, "code");
|
||||||
lua_pushstring(L,"something is wrong");// taos_errstr(taos));
|
lua_pushstring(L, taos_errstr(result));
|
||||||
lua_setfield(L, table_index, "error");
|
lua_setfield(L, table_index, "error");
|
||||||
}else{
|
}else{
|
||||||
//printf("success to async query.\n");
|
//printf("success to async query.\n");
|
||||||
|
|
|
@ -176,8 +176,14 @@ end
|
||||||
driver.query_a(conn,"INSERT INTO therm1 VALUES ('2019-09-01 00:00:00.005', 100),('2019-09-01 00:00:00.006', 101),('2019-09-01 00:00:00.007', 102)", async_query_callback)
|
driver.query_a(conn,"INSERT INTO therm1 VALUES ('2019-09-01 00:00:00.005', 100),('2019-09-01 00:00:00.006', 101),('2019-09-01 00:00:00.007', 102)", async_query_callback)
|
||||||
|
|
||||||
res = driver.query(conn, "create stream stream_avg_degree into avg_degree as select avg(degree) from thermometer interval(5s) sliding(1s)")
|
res = driver.query(conn, "create stream stream_avg_degree into avg_degree as select avg(degree) from thermometer interval(5s) sliding(1s)")
|
||||||
|
if res.code ~=0 then
|
||||||
|
print("create stream--- failed:"..res.error)
|
||||||
|
return
|
||||||
|
else
|
||||||
|
print("create stream--- pass")
|
||||||
|
end
|
||||||
|
|
||||||
print("From now on we start continous insert in an definite loop, pls wait for about 10 seconds and check stream table for result.")
|
print("From now on we start continous insertion in an definite loop, please wait for about 10 seconds and check stream table avg_degree for result.")
|
||||||
local loop_index = 0
|
local loop_index = 0
|
||||||
while loop_index < 10 do
|
while loop_index < 10 do
|
||||||
local t = os.time()*1000
|
local t = os.time()*1000
|
||||||
|
@ -193,5 +199,5 @@ while loop_index < 10 do
|
||||||
os.execute("sleep " .. 1)
|
os.execute("sleep " .. 1)
|
||||||
loop_index = loop_index + 1
|
loop_index = loop_index + 1
|
||||||
end
|
end
|
||||||
driver.query(conn,"DROP STREAM IF EXISTS avg_therm_s")
|
driver.query(conn,"DROP STREAM IF EXISTS stream_avg_degree")
|
||||||
driver.close(conn)
|
driver.close(conn)
|
||||||
|
|
Loading…
Reference in New Issue