提交 350c22c8 编写于 作者: dengyihao's avatar dengyihao

[TD-5466]<enhance> enhance like pattern

上级 83e2e11e
...@@ -431,6 +431,7 @@ int32_t handleUserDefinedFunc(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -431,6 +431,7 @@ int32_t handleUserDefinedFunc(SSqlObj* pSql, struct SSqlInfo* pInfo) {
const char *msg2 = "path is too long"; const char *msg2 = "path is too long";
const char *msg3 = "invalid outputtype"; const char *msg3 = "invalid outputtype";
const char *msg4 = "invalid script"; const char *msg4 = "invalid script";
const char *msg5 = "invalid dyn lib";
SSqlCmd *pCmd = &pSql->cmd; SSqlCmd *pCmd = &pSql->cmd;
switch (pInfo->type) { switch (pInfo->type) {
...@@ -444,6 +445,10 @@ int32_t handleUserDefinedFunc(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -444,6 +445,10 @@ int32_t handleUserDefinedFunc(SSqlObj* pSql, struct SSqlInfo* pInfo) {
} }
createInfo->name.z[createInfo->name.n] = 0; createInfo->name.z[createInfo->name.n] = 0;
// funcname's naming rule is same to column
if (validateColumnName(createInfo->name.z) != TSDB_CODE_SUCCESS) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
}
strdequote(createInfo->name.z); strdequote(createInfo->name.z);
...@@ -463,10 +468,16 @@ int32_t handleUserDefinedFunc(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -463,10 +468,16 @@ int32_t handleUserDefinedFunc(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if (ret) { if (ret) {
return ret; return ret;
} }
//distinguish *.lua and *.so //validate *.lua or .so
int32_t pathLen = (int32_t)strlen(createInfo->path.z); int32_t pathLen = (int32_t)strlen(createInfo->path.z);
if ((pathLen > 3) && (0 == strncmp(createInfo->path.z + pathLen - 3, "lua", 3)) && !isValidScript(buf, len)) { if ((pathLen > 4) && (0 == strncmp(createInfo->path.z + pathLen - 4, ".lua", 4)) && !isValidScript(buf, len)) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4);
} else if (pathLen > 3 && (0 == strncmp(createInfo->path.z + pathLen - 3, ".so", 3))) {
void *handle = taosLoadDll(createInfo->path.z);
taosCloseDll(handle);
if (handle == NULL) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg5);
}
} }
//TODO CHECK CODE //TODO CHECK CODE
......
...@@ -255,8 +255,12 @@ int32_t shellRunCommand(TAOS* con, char* command) { ...@@ -255,8 +255,12 @@ int32_t shellRunCommand(TAOS* con, char* command) {
} }
if (c == '\\') { if (c == '\\') {
esc = true; if (quote != 0 && (*command == '_' || *command == '\\')) {
continue; //DO nothing
} else {
esc = true;
continue;
}
} }
if (quote == c) { if (quote == c) {
......
...@@ -262,6 +262,7 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat ...@@ -262,6 +262,7 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat
c1 = str[j++]; c1 = str[j++];
if (j <= size) { if (j <= size) {
if (c == '\\' && patterStr[i] == '_' && c1 == '_') { i++; continue; }
if (c == c1 || tolower(c) == tolower(c1) || (c == pInfo->matchOne && c1 != 0)) { if (c == c1 || tolower(c) == tolower(c1) || (c == pInfo->matchOne && c1 != 0)) {
continue; continue;
} }
......
...@@ -488,7 +488,7 @@ SOCKET taosOpenTcpServerSocket(uint32_t ip, uint16_t port) { ...@@ -488,7 +488,7 @@ SOCKET taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
return -1; return -1;
} }
if (listen(sockFd, 10) < 0) { if (listen(sockFd, 1024) < 0) {
uError("listen tcp server socket failed, 0x%x:%hu(%s)", ip, port, strerror(errno)); uError("listen tcp server socket failed, 0x%x:%hu(%s)", ip, port, strerror(errno));
taosCloseSocket(sockFd); taosCloseSocket(sockFd);
return -1; return -1;
......
...@@ -64,12 +64,15 @@ int32_t strRmquote(char *z, int32_t len){ ...@@ -64,12 +64,15 @@ int32_t strRmquote(char *z, int32_t len){
int32_t j = 0; int32_t j = 0;
for (uint32_t k = 1; k < len - 1; ++k) { for (uint32_t k = 1; k < len - 1; ++k) {
if (z[k] == '\\' || (z[k] == delim && z[k + 1] == delim)) { if (z[k] == '\\' || (z[k] == delim && z[k + 1] == delim)) {
if (z[k] == '\\' && z[k + 1] == '_') {
//match '_' self
} else {
z[j] = z[k + 1]; z[j] = z[k + 1];
cnt++;
cnt++; j++;
j++; k++;
k++; continue;
continue; }
} }
z[j] = z[k]; z[j] = z[k];
......
...@@ -221,3 +221,4 @@ run general/stream/table_replica1_vnoden.sim ...@@ -221,3 +221,4 @@ run general/stream/table_replica1_vnoden.sim
run general/stream/metrics_replica1_vnoden.sim run general/stream/metrics_replica1_vnoden.sim
run general/db/show_create_db.sim run general/db/show_create_db.sim
run general/db/show_create_table.sim run general/db/show_create_table.sim
run general/parser/like.sim
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册