提交 89dd1099 编写于 作者: G Ganlin Zhao

Merge branch 'develop' into fix/TD-11248

......@@ -152,6 +152,17 @@ IF (TD_BUILD_HTTP)
ADD_DEFINITIONS(-DHTTP_EMBEDDED)
ENDIF ()
IF (${BUILD_LUA} MATCHES "false")
SET(TD_BUILD_LUA FALSE)
ENDIF ()
IF (TD_BUILD_LUA)
MESSAGE("Enable lua")
ADD_DEFINITIONS(-DLUA_EMBEDDED)
ELSE ()
MESSAGE("Disable lua")
ENDIF ()
IF ("${AVRO_SUPPORT}" MATCHES "true")
SET(TD_AVRO_SUPPORT TRUE)
ELSEIF ("${AVRO_SUPPORT}" MATCHES "false")
......
......@@ -92,6 +92,8 @@ ENDIF ()
SET(TD_BUILD_HTTP FALSE)
SET(TD_BUILD_LUA TRUE)
SET(TD_AVRO_SUPPORT FALSE)
SET(TD_MEMORY_SANITIZER FALSE)
......
......@@ -15,7 +15,10 @@ ADD_SUBDIRECTORY(cJson)
ADD_SUBDIRECTORY(wepoll)
ADD_SUBDIRECTORY(MsvcLibX)
ADD_SUBDIRECTORY(rmonotonic)
ADD_SUBDIRECTORY(lua)
IF (TD_BUILD_LUA)
ADD_SUBDIRECTORY(lua)
ENDIF ()
IF (TD_LINUX AND TD_MQTT)
ADD_SUBDIRECTORY(MQTT-C)
......
......@@ -190,7 +190,7 @@ taosdemo 详细使用方法请参照 [如何使用taosdemo对TDengine进行性
### TDengine 服务器支持的平台列表
| | **CentOS 6/7/8** | **Ubuntu 16/18/20** | **Other Linux** | **统信 UOS** | **银河/中标麒麟** | **凝思 V60/V80** | **华为 EulerOS** |
| | **CentOS 7/8** | **Ubuntu 16/18/20** | **Other Linux** | **统信 UOS** | **银河/中标麒麟** | **凝思 V60/V80** | **华为 EulerOS** |
| -------------- | --------------------- | ------------------------ | --------------- | --------------- | ------------------------- | --------------------- | --------------------- |
| X64 | ● | ● | | ○ | ● | ● | ● |
| 龙芯 MIPS64 | | | ● | | | | |
......
......@@ -439,7 +439,9 @@ int32_t handleUserDefinedFunc(SSqlObj* pSql, struct SSqlInfo* pInfo) {
const char *msg1 = "invalidate function name";
const char *msg2 = "path is too long";
const char *msg3 = "invalid outputtype";
#ifdef LUA_EMBEDDED
const char *msg4 = "invalid script";
#endif
const char *msg5 = "invalid dyn lib";
SSqlCmd *pCmd = &pSql->cmd;
......@@ -478,9 +480,12 @@ int32_t handleUserDefinedFunc(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
//validate *.lua or .so
int32_t pathLen = (int32_t)strlen(createInfo->path.z);
#ifdef LUA_EMBEDDED
if ((pathLen > 4) && (0 == strncmp(createInfo->path.z + pathLen - 4, ".lua", 4)) && !isValidScript(buf, len)) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4);
} else if (pathLen > 3 && (0 == strncmp(createInfo->path.z + pathLen - 3, ".so", 3))) {
} else
#endif
if (pathLen > 3 && (0 == strncmp(createInfo->path.z + pathLen - 3, ".so", 3))) {
void *handle = taosLoadDll(createInfo->path.z);
taosCloseDll(handle);
if (handle == NULL) {
......
......@@ -1536,7 +1536,17 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pMsg += sizeof(SCreateTableMsg);
SCreatedTableInfo* p = taosArrayGet(list, i);
strcpy(pCreate->tableName, p->fullname);
//what pCreate->tableName point is a fixed char array which size is 237
//what p->fullname point is a char*
//before the time we copy p->fullname to pCreate->tableName , we need to check the length of p->fullname
if (strlen(p->fullname) > 237) {
tscError("failed to write this name, which is over 237, just save the first 237 char here");
strncpy(pCreate->tableName, p->fullname,237);
pCreate->tableName[236]='\0';//I don't know if this line is working properly
}else{
strcpy(pCreate->tableName, p->fullname);
}
pCreate->igExists = (p->igExist)? 1 : 0;
// use dbinfo from table id without modifying current db info
......
......@@ -210,9 +210,9 @@ void taos_init_imp(void) {
taosInitNotes();
rpcInit();
#ifdef LUA_EMBEDDED
scriptEnvPoolInit();
#endif
tscDebug("starting to initialize TAOS client ...");
tscDebug("Local End Point is:%s", tsLocalEp);
}
......@@ -276,7 +276,9 @@ void taos_cleanup(void) {
}
if (tscEmbedded == 0) {
#ifdef LUA_EMBEDDED
scriptEnvPoolCleanup();
#endif
}
int32_t id = tscObjRef;
......
......@@ -89,7 +89,9 @@ static SStep tsDnodeSteps[] = {
{"dnode-shell", dnodeInitShell, dnodeCleanupShell},
{"dnode-statustmr", dnodeInitStatusTimer,dnodeCleanupStatusTimer},
{"dnode-telemetry", dnodeInitTelemetry, dnodeCleanupTelemetry},
#ifdef LUA_EMBEDDED
{"dnode-script", scriptEnvPoolInit, scriptEnvPoolCleanup},
#endif
{"dnode-grant", grantInit, grantCleanUp},
};
......
......@@ -11,11 +11,19 @@ SET_SOURCE_FILES_PROPERTIES(src/sql.c PROPERTIES COMPILE_FLAGS -w)
TARGET_LINK_LIBRARIES(query tsdb tutil lua)
IF (TD_LINUX)
TARGET_LINK_LIBRARIES(query m rt lua)
IF (TD_BUILD_LUA)
TARGET_LINK_LIBRARIES(query m rt lua)
ELSE ()
TARGET_LINK_LIBRARIES(query m rt)
ENDIF ()
ADD_SUBDIRECTORY(tests)
ENDIF ()
IF (TD_DARWIN)
TARGET_LINK_LIBRARIES(query m lua)
IF (TD_BUILD_LUA)
TARGET_LINK_LIBRARIES(query m lua)
ELSE ()
TARGET_LINK_LIBRARIES(query m)
ENDIF ()
ADD_SUBDIRECTORY(tests)
ENDIF ()
......@@ -15,7 +15,7 @@
#ifndef TDENGINE_QSCRIPT_H
#define TDENGINE_QSCRIPT_H
#ifdef LUA_EMBEDDED
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
......@@ -78,5 +78,5 @@ void destroyScriptCtx(void *pScriptCtx);
int32_t scriptEnvPoolInit();
void scriptEnvPoolCleanup();
bool isValidScript(char *script, int32_t len);
#endif //LUA_EMBEDDED
#endif //TDENGINE_QSCRIPT_H
......@@ -8240,7 +8240,7 @@ void destroyUdfInfo(SUdfInfo* pUdfInfo) {
taosCloseDll(pUdfInfo->handle);
tfree(pUdfInfo);
}
#ifdef LUA_EMBEDDED
static char* getUdfFuncName(char* funcname, char* name, int type) {
switch (type) {
case TSDB_UDF_FUNC_NORMAL:
......@@ -8265,8 +8265,9 @@ static char* getUdfFuncName(char* funcname, char* name, int type) {
return funcname;
}
#endif
int32_t initUdfInfo(SUdfInfo* pUdfInfo) {
#ifdef LUA_EMBEDDED
if (pUdfInfo == NULL || pUdfInfo->handle) {
return TSDB_CODE_SUCCESS;
}
......@@ -8350,7 +8351,7 @@ int32_t initUdfInfo(SUdfInfo* pUdfInfo) {
return (*(udfInitFunc)pUdfInfo->funcs[TSDB_UDF_FUNC_INIT])(&pUdfInfo->init);
}
}
#endif //LUA_EMBEDDED
return TSDB_CODE_SUCCESS;
}
......
......@@ -12,7 +12,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef LUA_EMBEDDED
#include "os.h"
#include "qScript.h"
#include "ttype.h"
......@@ -444,3 +444,4 @@ bool isValidScript(char *script, int32_t len) {
return ret;
}
#endif
......@@ -334,8 +334,9 @@ bool taosReadConfigOption(const char *option, char *value, char *value2, char *v
if (taosReadDirectoryConfig(cfg, value)) {
taosReadDataDirCfg(value, value2, value3);
ret = true;
} else {
ret = false;
}
ret = false;
break;
default:
uError("config option:%s, input value:%s, can't be recognized", option, value);
......
......@@ -63,6 +63,7 @@ else
end
--[[
local flag = false
function query_callback(res)
if res.code ~=0 then
......@@ -80,9 +81,10 @@ end
driver.query_a(conn,"insert into m1 values ('2019-09-01 00:00:00.001', 3, 'robotspace'),('2019-09-01 00:00:00.006', 4, 'Hilink'),('2019-09-01 00:00:00.007', 6, 'Harmony')", query_callback)
while not flag do
-- ngx.say("i am here once...")
ngx.say("i am here once...")
ngx.sleep(0.001) -- time unit is second
end
--]]
ngx.say("pool water_mark:"..pool:get_water_mark())
......
# 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, the built-in lua module conflicts with external lua. 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:
```
......
......@@ -102,7 +102,7 @@ static int l_query(lua_State *L){
printf("failed, reason:%s\n", taos_errstr(result));
lua_pushinteger(L, -1);
lua_setfield(L, table_index, "code");
lua_pushstring(L, taos_errstr(taos));
lua_pushstring(L, taos_errstr(result));
lua_setfield(L, table_index, "error");
return 1;
......
......@@ -102,7 +102,7 @@ static int l_query(lua_State *L){
printf("failed, reason:%s\n", taos_errstr(result));
lua_pushinteger(L, -1);
lua_setfield(L, table_index, "code");
lua_pushstring(L, taos_errstr(taos));
lua_pushstring(L, taos_errstr(result));
lua_setfield(L, table_index, "error");
return 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册