提交 4076bc61 编写于 作者: T Tao Liu

Merge branch 'develop' into feature/tagschema

......@@ -2,6 +2,8 @@
TDengine provides many connectors for development, including C/C++, JAVA, Python, RESTful, Go, Node.JS, etc.
NOTE: All APIs which require a SQL string as parameter, including but not limit to `taos_query`, `taos_query_a`, `taos_subscribe` in the C/C++ Connector and their counterparts in other connectors, can ONLY process one SQL statement at a time. If more than one SQL statements are provided, their behaviors are undefined.
## C/C++ API
C/C++ APIs are similar to the MySQL APIs. Applications should include TDengine head file _taos.h_ to use C/C++ APIs by adding the following line in code:
......
......@@ -2,6 +2,8 @@
TDengine提供了丰富的应用程序开发接口,其中包括C/C++、JAVA、Python、RESTful、Go等,便于用户快速开发应用。
注意:所以执行 SQL 语句的 API,例如 C/C++ Connector 中的 `tao_query``taos_query_a``taos_subscribe` 等,以及其它语言中与它们对应的API,每次都只能执行一条 SQL 语句,如果实际参数中包含了多条语句,它们的行为是未定义的。
## C/C++ Connector
C/C++的API类似于MySQL的C API。应用程序使用时,需要包含TDengine头文件 _taos.h_(安装后,位于 _/usr/local/taos/include_):
......
......@@ -24,24 +24,11 @@ extern "C" {
extern int32_t cDebugFlag;
#define tscError(...) \
if (cDebugFlag & DEBUG_ERROR) { \
taosPrintLog("ERROR TSC ", 255, __VA_ARGS__); \
}
#define tscWarn(...) \
if (cDebugFlag & DEBUG_WARN) { \
taosPrintLog("WARN TSC ", cDebugFlag, __VA_ARGS__); \
}
#define tscTrace(...) \
if (cDebugFlag & DEBUG_TRACE) { \
taosPrintLog("TSC ", cDebugFlag, __VA_ARGS__); \
}
#define tscPrint(...) \
{ taosPrintLog("TSC ", 255, __VA_ARGS__); }
#define tscDump(...) \
if (cDebugFlag & DEBUG_TRACE) { \
taosPrintLongString("TSC ", cDebugFlag, __VA_ARGS__); \
}
#define tscError(...) { if (cDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR TSC ", cDebugFlag, __VA_ARGS__); }}
#define tscWarn(...) { if (cDebugFlag & DEBUG_WARN) { taosPrintLog("WARN TSC ", cDebugFlag, __VA_ARGS__); }}
#define tscTrace(...) { if (cDebugFlag & DEBUG_TRACE) { taosPrintLog("TSC ", cDebugFlag, __VA_ARGS__); }}
#define tscDump(...) { if (cDebugFlag & DEBUG_TRACE) { taosPrintLongString("TSC ", cDebugFlag, __VA_ARGS__); }}
#define tscPrint(...) { taosPrintLog("TSC ", tscEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }
#ifdef __cplusplus
}
......
......@@ -22,20 +22,10 @@
#include "tlog.h"
#include "ttime.h"
#define jniError(...) \
if (jniDebugFlag & DEBUG_ERROR) { \
taosPrintLog("ERROR JNI ", jniDebugFlag, __VA_ARGS__); \
}
#define jniWarn(...) \
if (jniDebugFlag & DEBUG_WARN) { \
taosPrintLog("WARN JNI ", jniDebugFlag, __VA_ARGS__); \
}
#define jniTrace(...) \
if (jniDebugFlag & DEBUG_TRACE) { \
taosPrintLog("JNI ", jniDebugFlag, __VA_ARGS__); \
}
#define jniPrint(...) \
{ taosPrintLog("JNI ", 255, __VA_ARGS__); }
#define jniError(...) { if (jniDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR JNI ", jniDebugFlag, __VA_ARGS__); }}
#define jniWarn(...) { if (jniDebugFlag & DEBUG_WARN) { taosPrintLog("WARN JNI ", jniDebugFlag, __VA_ARGS__); }}
#define jniTrace(...) { if (jniDebugFlag & DEBUG_TRACE) { taosPrintLog("JNI ", jniDebugFlag, __VA_ARGS__); }}
#define jniPrint(...) { taosPrintLog("JNI ", tscEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }
int __init = 0;
......
......@@ -25,31 +25,15 @@ extern "C" {
extern int32_t uDebugFlag;
extern int32_t tscEmbedded;
#define uError(...) \
if (uDebugFlag & DEBUG_ERROR) { \
taosPrintLog("ERROR UTL ", uDebugFlag, __VA_ARGS__); \
}
#define uWarn(...) \
if (uDebugFlag & DEBUG_WARN) { \
taosPrintLog("WARN UTL ", uDebugFlag, __VA_ARGS__); \
}
#define uTrace(...) \
if (uDebugFlag & DEBUG_TRACE) { \
taosPrintLog("UTL ", uDebugFlag, __VA_ARGS__); \
}
#define uDump(x, y) \
if (uDebugFlag & DEBUG_DUMP) { \
taosDumpData(x, y); \
}
#define uPrint(...) \
{ taosPrintLog("UTL ", tscEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }
#define uForcePrint(...) \
{ taosPrintLog("ERROR UTL ", 255, __VA_ARGS__); }
#define pError(...) \
{ taosPrintLog("ERROR APP ", 255, __VA_ARGS__); }
#define pPrint(...) \
{ taosPrintLog("APP ", 255, __VA_ARGS__); }
#define uError(...) { if (uDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR UTL ", uDebugFlag, __VA_ARGS__); }}
#define uWarn(...) { if (uDebugFlag & DEBUG_WARN) { taosPrintLog("WARN UTL ", uDebugFlag, __VA_ARGS__); }}
#define uTrace(...) { if (uDebugFlag & DEBUG_TRACE) { taosPrintLog("UTL ", uDebugFlag, __VA_ARGS__); }}
#define uDump(x, y) { if (uDebugFlag & DEBUG_DUMP) { taosDumpData(x, y); }}
#define uPrint(...) { taosPrintLog("UTL ", tscEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }
#define uForcePrint(...) { taosPrintLog("ERROR UTL ", 255, __VA_ARGS__); }
#define pError(...) { taosPrintLog("ERROR APP ", 255, __VA_ARGS__); }
#define pPrint(...) { taosPrintLog("APP ", 255, __VA_ARGS__); }
#ifdef __cplusplus
}
......
......@@ -31,16 +31,16 @@ void tsSetLocale() {
// default locale or user specified locale is not valid, abort launch
if (locale == NULL) {
uForcePrint("Invalid locale:%s, please set the valid locale in config file", tsLocale);
uError("Invalid locale:%s, please set the valid locale in config file", tsLocale);
}
if (strlen(tsCharset) == 0) {
uForcePrint("failed to get charset, please set the valid charset in config file");
uError("failed to get charset, please set the valid charset in config file");
exit(-1);
}
if (!taosValidateEncodec(tsCharset)) {
uForcePrint("Invalid charset:%s, please set the valid charset in config file", tsCharset);
uError("Invalid charset:%s, please set the valid charset in config file", tsCharset);
exit(-1);
}
}
\ No newline at end of file
......@@ -27,10 +27,10 @@
#include "tcq.h"
#include "taos.h"
#define cError(...) if (cqDebugFlag & DEBUG_ERROR) {taosPrintLog("ERROR CQ ", cqDebugFlag, __VA_ARGS__);}
#define cWarn(...) if (cqDebugFlag & DEBUG_WARN) {taosPrintLog("WARN CQ ", cqDebugFlag, __VA_ARGS__);}
#define cTrace(...) if (cqDebugFlag & DEBUG_TRACE) {taosPrintLog("CQ ", cqDebugFlag, __VA_ARGS__);}
#define cPrint(...) {taosPrintLog("CQ ", 255, __VA_ARGS__);}
#define cError(...) { if (cqDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR CQ ", cqDebugFlag, __VA_ARGS__); }}
#define cWarn(...) { if (cqDebugFlag & DEBUG_WARN) { taosPrintLog("WARN CQ ", cqDebugFlag, __VA_ARGS__); }}
#define cTrace(...) { if (cqDebugFlag & DEBUG_TRACE) { taosPrintLog("CQ ", cqDebugFlag, __VA_ARGS__); }}
#define cPrint(...) { taosPrintLog("CQ ", 255, __VA_ARGS__); }
typedef struct {
int vgId;
......
......@@ -24,10 +24,10 @@ extern "C" {
extern int32_t dDebugFlag;
#define dError(...) if (dDebugFlag & DEBUG_ERROR) {taosPrintLog("ERROR DND ", 255, __VA_ARGS__); }
#define dWarn(...) if (dDebugFlag & DEBUG_WARN) {taosPrintLog("WARN DND ", dDebugFlag, __VA_ARGS__); }
#define dTrace(...) if (dDebugFlag & DEBUG_TRACE) {taosPrintLog("DND ", dDebugFlag, __VA_ARGS__); }
#define dPrint(...) {taosPrintLog("DND ", 255, __VA_ARGS__); }
#define dError(...) { if (dDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR DND ", 255, __VA_ARGS__); }}
#define dWarn(...) { if (dDebugFlag & DEBUG_WARN) { taosPrintLog("WARN DND ", dDebugFlag, __VA_ARGS__); }}
#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", dDebugFlag, __VA_ARGS__); }}
#define dPrint(...) { taosPrintLog("DND ", 255, __VA_ARGS__); }
#ifdef __cplusplus
}
......
......@@ -46,145 +46,144 @@ static STaosError errors[] = {
#endif
// rpc
TAOS_DEFINE_ERROR(TSDB_CODE_ACTION_IN_PROGRESS, 0, 1, "action in progress")
TAOS_DEFINE_ERROR(TSDB_CODE_ACTION_NEED_REPROCESSED, 0, 3, "action need to be reprocessed")
TAOS_DEFINE_ERROR(TSDB_CODE_MSG_NOT_PROCESSED, 0, 4, "message not processed")
TAOS_DEFINE_ERROR(TSDB_CODE_ALREADY_PROCESSED, 0, 5, "message already processed")
TAOS_DEFINE_ERROR(TSDB_CODE_REDIRECT, 0, 6, "redirect")
TAOS_DEFINE_ERROR(TSDB_CODE_LAST_SESSION_NOT_FINISHED, 0, 7, "last session not finished")
TAOS_DEFINE_ERROR(TSDB_CODE_MAX_SESSIONS, 0, 8, "max sessions") // too many sessions
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_SESSION_ID, 0, 9, "invalid session id")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TRAN_ID, 0, 10, "invalid transaction id")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MSG_TYPE, 0, 11, "invalid message type")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MSG_LEN, 0, 12, "invalid message length")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MSG_CONTENT, 0, 13, "invalid message content")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MSG_VERSION, 0, 14, "invalid message version")
TAOS_DEFINE_ERROR(TSDB_CODE_UNEXPECTED_RESPONSE, 0, 15, "unexpected response")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_RESPONSE_TYPE, 0, 16, "invalid response type")
TAOS_DEFINE_ERROR(TSDB_CODE_MISMATCHED_METER_ID, 0, 17, "mismatched meter id")
TAOS_DEFINE_ERROR(TSDB_CODE_DISCONNECTED, 0, 18, "disconnected")
TAOS_DEFINE_ERROR(TSDB_CODE_NOT_READY, 0, 19, "not ready") // peer is not ready to process data
TAOS_DEFINE_ERROR(TSDB_CODE_TOO_SLOW, 0, 20, "too slow")
TAOS_DEFINE_ERROR(TSDB_CODE_OTHERS, 0, 21, "others")
TAOS_DEFINE_ERROR(TSDB_CODE_APP_ERROR, 0, 22, "app error")
TAOS_DEFINE_ERROR(TSDB_CODE_ALREADY_THERE, 0, 23, "already there")
TAOS_DEFINE_ERROR(TSDB_CODE_NO_RESOURCE, 0, 14, "no resource")
TAOS_DEFINE_ERROR(TSDB_CODE_OPS_NOT_SUPPORT, 0, 25, "operations not support")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_OPTION, 0, 26, "invalid option")
TAOS_DEFINE_ERROR(TSDB_CODE_NOT_CONFIGURED, 0, 27, "not configured")
TAOS_DEFINE_ERROR(TSDB_CODE_NODE_OFFLINE, 0, 28, "node offline")
TAOS_DEFINE_ERROR(TSDB_CODE_NETWORK_UNAVAIL, 0, 29, "network unavailable")
TAOS_DEFINE_ERROR(TSDB_CODE_AUTH_REQUIRED, 0, 30, "auth required")
TAOS_DEFINE_ERROR(TSDB_CODE_ACTION_IN_PROGRESS, 0, 0x0001, "action in progress")
TAOS_DEFINE_ERROR(TSDB_CODE_ACTION_NEED_REPROCESSED, 0, 0x0003, "action need to be reprocessed")
TAOS_DEFINE_ERROR(TSDB_CODE_MSG_NOT_PROCESSED, 0, 0x0004, "message not processed")
TAOS_DEFINE_ERROR(TSDB_CODE_ALREADY_PROCESSED, 0, 0x0005, "message already processed")
TAOS_DEFINE_ERROR(TSDB_CODE_REDIRECT, 0, 0x0006, "redirect")
TAOS_DEFINE_ERROR(TSDB_CODE_LAST_SESSION_NOT_FINISHED, 0, 0x0007, "last session not finished")
TAOS_DEFINE_ERROR(TSDB_CODE_MAX_SESSIONS, 0, 0x0008, "max sessions") // too many sessions
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_SESSION_ID, 0, 0x0009, "invalid session id")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TRAN_ID, 0, 0x000A, "invalid transaction id")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MSG_TYPE, 0, 0x000B, "invalid message type")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MSG_LEN, 0, 0x000C, "invalid message length")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MSG_CONTENT, 0, 0x000D, "invalid message content")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MSG_VERSION, 0, 0x000E, "invalid message version")
TAOS_DEFINE_ERROR(TSDB_CODE_UNEXPECTED_RESPONSE, 0, 0x000F, "unexpected response")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_RESPONSE_TYPE, 0, 0x0010, "invalid response type")
TAOS_DEFINE_ERROR(TSDB_CODE_MISMATCHED_METER_ID, 0, 0x0011, "mismatched meter id")
TAOS_DEFINE_ERROR(TSDB_CODE_DISCONNECTED, 0, 0x0012, "disconnected")
TAOS_DEFINE_ERROR(TSDB_CODE_NOT_READY, 0, 0x0013, "not ready") // peer is not ready to process data
TAOS_DEFINE_ERROR(TSDB_CODE_TOO_SLOW, 0, 0x0014, "too slow")
TAOS_DEFINE_ERROR(TSDB_CODE_OTHERS, 0, 0x0015, "others")
TAOS_DEFINE_ERROR(TSDB_CODE_APP_ERROR, 0, 0x0016, "app error")
TAOS_DEFINE_ERROR(TSDB_CODE_ALREADY_THERE, 0, 0x0017, "already there")
TAOS_DEFINE_ERROR(TSDB_CODE_NO_RESOURCE, 0, 0x0018, "no resource")
TAOS_DEFINE_ERROR(TSDB_CODE_OPS_NOT_SUPPORT, 0, 0x0019, "operations not support")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_OPTION, 0, 0x001A, "invalid option")
TAOS_DEFINE_ERROR(TSDB_CODE_NOT_CONFIGURED, 0, 0x001B, "not configured")
TAOS_DEFINE_ERROR(TSDB_CODE_NODE_OFFLINE, 0, 0x001C, "node offline")
TAOS_DEFINE_ERROR(TSDB_CODE_NETWORK_UNAVAIL, 0, 0x001D, "network unavailable")
TAOS_DEFINE_ERROR(TSDB_CODE_AUTH_REQUIRED, 0, 0x001E, "auth required")
// db
TAOS_DEFINE_ERROR(TSDB_CODE_DB_NOT_SELECTED, 0, 100, "db not selected")
TAOS_DEFINE_ERROR(TSDB_CODE_DB_ALREADY_EXIST, 0, 101, "database aleady exist")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_DB, 0, 102, "invalid database")
TAOS_DEFINE_ERROR(TSDB_CODE_MONITOR_DB_FORBIDDEN, 0, 103, "monitor db forbidden")
TAOS_DEFINE_ERROR(TSDB_CODE_DB_NOT_SELECTED, 0, 0x0100, "db not selected")
TAOS_DEFINE_ERROR(TSDB_CODE_DB_ALREADY_EXIST, 0, 0x0101, "database aleady exist")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_DB, 0, 0x0102, "invalid database")
TAOS_DEFINE_ERROR(TSDB_CODE_MONITOR_DB_FORBIDDEN, 0, 0x0103, "monitor db forbidden")
// user
TAOS_DEFINE_ERROR(TSDB_CODE_USER_ALREADY_EXIST, 0, 150, "user already exist")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_USER, 0, 151, "invalid user")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_PASS, 0, 152, "invalid password")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_USER_FORMAT, 0, 153, "invalid user format")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_PASS_FORMAT, 0, 154, "invalid password format")
TAOS_DEFINE_ERROR(TSDB_CODE_NO_USER_FROM_CONN, 0, 155, "can not get user from conn")
TAOS_DEFINE_ERROR(TSDB_CODE_USER_ALREADY_EXIST, 0, 0x0180, "user already exist")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_USER, 0, 0x0181, "invalid user")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_PASS, 0, 0x0182, "invalid password")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_USER_FORMAT, 0, 0x0183, "invalid user format")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_PASS_FORMAT, 0, 0x0184, "invalid password format")
TAOS_DEFINE_ERROR(TSDB_CODE_NO_USER_FROM_CONN, 0, 0x0185, "can not get user from conn")
// table
TAOS_DEFINE_ERROR(TSDB_CODE_TABLE_ALREADY_EXIST, 0, 200, "table already exist")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TABLE_ID, 0, 201, "invalid table id")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TABLE_TYPE, 0, 202, "invalid table typee")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TABLE, 0, 203, "invalid table name")
TAOS_DEFINE_ERROR(TSDB_CODE_NOT_SUPER_TABLE, 0, 204, "no super table") // operation only available for super table
TAOS_DEFINE_ERROR(TSDB_CODE_NOT_ACTIVE_TABLE, 0, 205, "not active table")
TAOS_DEFINE_ERROR(TSDB_CODE_TABLE_ID_MISMATCH, 0, 206, "table id mismatch")
TAOS_DEFINE_ERROR(TSDB_CODE_TAG_ALREAY_EXIST, 0, 207, "tag already exist")
TAOS_DEFINE_ERROR(TSDB_CODE_TAG_NOT_EXIST, 0, 208, "tag not exist")
TAOS_DEFINE_ERROR(TSDB_CODE_FIELD_ALREAY_EXIST, 0, 209, "field already exist")
TAOS_DEFINE_ERROR(TSDB_CODE_FIELD_NOT_EXIST, 0, 210, "field not exist")
TAOS_DEFINE_ERROR(TSDB_CODE_COL_NAME_TOO_LONG, 0, 211, "column name too long")
TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_TAGS, 0, 211, "too many tags")
TAOS_DEFINE_ERROR(TSDB_CODE_TABLE_ALREADY_EXIST, 0, 0x0200, "table already exist")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TABLE_ID, 0, 0x0201, "invalid table id")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TABLE_TYPE, 0, 0x0202, "invalid table typee")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TABLE, 0, 0x0203, "invalid table name")
TAOS_DEFINE_ERROR(TSDB_CODE_NOT_SUPER_TABLE, 0, 0x0204, "no super table") // operation only available for super table
TAOS_DEFINE_ERROR(TSDB_CODE_NOT_ACTIVE_TABLE, 0, 0x0205, "not active table")
TAOS_DEFINE_ERROR(TSDB_CODE_TABLE_ID_MISMATCH, 0, 0x0206, "table id mismatch")
TAOS_DEFINE_ERROR(TSDB_CODE_TAG_ALREAY_EXIST, 0, 0x0207, "tag already exist")
TAOS_DEFINE_ERROR(TSDB_CODE_TAG_NOT_EXIST, 0, 0x0208, "tag not exist")
TAOS_DEFINE_ERROR(TSDB_CODE_FIELD_ALREAY_EXIST, 0, 0x0209, "field already exist")
TAOS_DEFINE_ERROR(TSDB_CODE_FIELD_NOT_EXIST, 0, 0x020A, "field not exist")
TAOS_DEFINE_ERROR(TSDB_CODE_COL_NAME_TOO_LONG, 0, 0x020B, "column name too long")
TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_TAGS, 0, 0x020C, "too many tags")
// dnode & mnode
TAOS_DEFINE_ERROR(TSDB_CODE_NO_ENOUGH_DNODES, 0, 250, "no enough dnodes")
TAOS_DEFINE_ERROR(TSDB_CODE_DNODE_ALREADY_EXIST, 0, 251, "dnode already exist")
TAOS_DEFINE_ERROR(TSDB_CODE_DNODE_NOT_EXIST, 0, 252, "dnode not exist")
TAOS_DEFINE_ERROR(TSDB_CODE_NO_MASTER, 0, 253, "no master")
TAOS_DEFINE_ERROR(TSDB_CODE_NO_REMOVE_MASTER, 0, 254, "no remove master")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_QUERY_ID, 0, 255, "invalid query id")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_STREAM_ID, 0, 256, "invalid stream id")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_CONNECTION, 0, 257, "invalid connection")
TAOS_DEFINE_ERROR(TSDB_CODE_SDB_ERROR, 0, 258, "sdb error")
TAOS_DEFINE_ERROR(TSDB_CODE_TIMESTAMP_OUT_OF_RANGE, 0, 259, "timestamp is out of range")
TAOS_DEFINE_ERROR(TSDB_CODE_NO_ENOUGH_DNODES, 0, 0x0280, "no enough dnodes")
TAOS_DEFINE_ERROR(TSDB_CODE_DNODE_ALREADY_EXIST, 0, 0x0281, "dnode already exist")
TAOS_DEFINE_ERROR(TSDB_CODE_DNODE_NOT_EXIST, 0, 0x0282, "dnode not exist")
TAOS_DEFINE_ERROR(TSDB_CODE_NO_MASTER, 0, 0x0283, "no master")
TAOS_DEFINE_ERROR(TSDB_CODE_NO_REMOVE_MASTER, 0, 0x0284, "no remove master")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_QUERY_ID, 0, 0x0285, "invalid query id")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_STREAM_ID, 0, 0x0286, "invalid stream id")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_CONNECTION, 0, 0x0287, "invalid connection")
TAOS_DEFINE_ERROR(TSDB_CODE_SDB_ERROR, 0, 0x0288, "sdb error")
TAOS_DEFINE_ERROR(TSDB_CODE_TIMESTAMP_OUT_OF_RANGE, 0, 0x0289, "timestamp is out of range")
// acct
TAOS_DEFINE_ERROR(TSDB_CODE_ACCT_ALREADY_EXIST, 0, 300, "accounts already exist")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_ACCT, 0, 301, "invalid account")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_ACCT_PARAMETER, 0, 302, "invalid account parameter")
TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_ACCTS, 0, 303, "too many accounts")
TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_USERS, 0, 304, "too many users")
TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_TABLES, 0, 305, "too many tables")
TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_DATABASES, 0, 306, "too many databases")
TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_TIME_SERIES, 0, 307, "not enough time series")
TAOS_DEFINE_ERROR(TSDB_CODE_ACCT_ALREADY_EXIST, 0, 0x0300, "accounts already exist")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_ACCT, 0, 0x0301, "invalid account")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_ACCT_PARAMETER, 0, 0x0302, "invalid account parameter")
TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_ACCTS, 0, 0x0303, "too many accounts")
TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_USERS, 0, 0x0304, "too many users")
TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_TABLES, 0, 0x0305, "too many tables")
TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_DATABASES, 0, 0x0306, "too many databases")
TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_TIME_SERIES, 0, 0x0307, "not enough time series")
// grant
TAOS_DEFINE_ERROR(TSDB_CODE_AUTH_FAILURE, 0, 350, "auth failure")
TAOS_DEFINE_ERROR(TSDB_CODE_NO_RIGHTS, 0, 351, "no rights")
TAOS_DEFINE_ERROR(TSDB_CODE_NO_WRITE_ACCESS, 0, 352, "no write access")
TAOS_DEFINE_ERROR(TSDB_CODE_NO_READ_ACCESS, 0, 353, "no read access")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_EXPIRED, 0, 354, "grant expired")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_DNODE_LIMITED, 0, 355, "grant dnode limited")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_ACCT_LIMITED, 0, 356, "grant account limited")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_TIMESERIES_LIMITED, 0, 357, "grant timeseries limited")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_DB_LIMITED, 0, 358, "grant db limited")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_USER_LIMITED, 0, 359, "grant user limited")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_CONN_LIMITED, 0, 360, "grant conn limited")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_STREAM_LIMITED, 0, 361, "grant stream limited")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_SPEED_LIMITED, 0, 362, "grant speed limited")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_STORAGE_LIMITED, 0, 363, "grant storage limited")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_QUERYTIME_LIMITED, 0, 364, "grant query time limited")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_CPU_LIMITED, 0, 365, "grant cpu limited")
TAOS_DEFINE_ERROR(TSDB_CODE_AUTH_FAILURE, 0, 0x0380, "auth failure")
TAOS_DEFINE_ERROR(TSDB_CODE_NO_RIGHTS, 0, 0x0381, "no rights")
TAOS_DEFINE_ERROR(TSDB_CODE_NO_WRITE_ACCESS, 0, 0x0382, "no write access")
TAOS_DEFINE_ERROR(TSDB_CODE_NO_READ_ACCESS, 0, 0x0383, "no read access")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_EXPIRED, 0, 0x0384, "grant expired")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_DNODE_LIMITED, 0, 0x0385, "grant dnode limited")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_ACCT_LIMITED, 0, 0x0386, "grant account limited")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_TIMESERIES_LIMITED, 0, 0x0387, "grant timeseries limited")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_DB_LIMITED, 0, 0x0388, "grant db limited")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_USER_LIMITED, 0, 0x0389, "grant user limited")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_CONN_LIMITED, 0, 0x038A, "grant conn limited")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_STREAM_LIMITED, 0, 0x038B, "grant stream limited")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_SPEED_LIMITED, 0, 0x038C, "grant speed limited")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_STORAGE_LIMITED, 0, 0x038D, "grant storage limited")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_QUERYTIME_LIMITED, 0, 0x038E, "grant query time limited")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_CPU_LIMITED, 0, 0x038F, "grant cpu limited")
// server
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_VGROUP_ID, 0, 400, "invalid vgroup id")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_VNODE_ID, 0, 401, "invalid vnode id")
TAOS_DEFINE_ERROR(TSDB_CODE_NOT_ACTIVE_VNODE, 0, 402, "not active vnode")
TAOS_DEFINE_ERROR(TSDB_CODE_VG_INIT_FAILED, 0, 403, "vg init failed")
TAOS_DEFINE_ERROR(TSDB_CODE_SERV_NO_DISKSPACE, 0, 404, "server no diskspace")
TAOS_DEFINE_ERROR(TSDB_CODE_SERV_OUT_OF_MEMORY, 0, 405, "server out of memory")
TAOS_DEFINE_ERROR(TSDB_CODE_NO_DISK_PERMISSIONS, 0, 406, "no disk permissions")
TAOS_DEFINE_ERROR(TSDB_CODE_FILE_CORRUPTED, 0, 407, "file corrupted")
TAOS_DEFINE_ERROR(TSDB_CODE_MEMORY_CORRUPTED, 0, 408, "memory corrupted")
TAOS_DEFINE_ERROR(TSDB_CODE_NOT_SUCH_FILE_OR_DIR, 0, 409, "no such file or directory")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_VGROUP_ID, 0, 0x0400, "invalid vgroup id")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_VNODE_ID, 0, 0x0401, "invalid vnode id")
TAOS_DEFINE_ERROR(TSDB_CODE_NOT_ACTIVE_VNODE, 0, 0x0402, "not active vnode")
TAOS_DEFINE_ERROR(TSDB_CODE_VG_INIT_FAILED, 0, 0x0403, "vg init failed")
TAOS_DEFINE_ERROR(TSDB_CODE_SERV_NO_DISKSPACE, 0, 0x0404, "server no diskspace")
TAOS_DEFINE_ERROR(TSDB_CODE_SERV_OUT_OF_MEMORY, 0, 0x0405, "server out of memory")
TAOS_DEFINE_ERROR(TSDB_CODE_NO_DISK_PERMISSIONS, 0, 0x0406, "no disk permissions")
TAOS_DEFINE_ERROR(TSDB_CODE_FILE_CORRUPTED, 0, 0x0407, "file corrupted")
TAOS_DEFINE_ERROR(TSDB_CODE_MEMORY_CORRUPTED, 0, 0x0408, "memory corrupted")
TAOS_DEFINE_ERROR(TSDB_CODE_NOT_SUCH_FILE_OR_DIR, 0, 0x0409, "no such file or directory")
// client
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_CLIENT_VERSION, 0, 451, "invalid client version")
TAOS_DEFINE_ERROR(TSDB_CODE_CLI_OUT_OF_MEMORY, 0, 452, "client out of memory")
TAOS_DEFINE_ERROR(TSDB_CODE_CLI_NO_DISKSPACE, 0, 453, "client no disk space")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TIME_STAMP, 0, 454, "invalid timestamp")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_SQL, 0, 455, "invalid sql")
TAOS_DEFINE_ERROR(TSDB_CODE_QUERY_CACHE_ERASED, 0, 456, "query cache erased")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_QUERY_MSG, 0, 457, "invalid query message") // failed to validate the sql expression msg by vnode
TAOS_DEFINE_ERROR(TSDB_CODE_SORTED_RES_TOO_MANY, 0, 458, "sorted res too many") // too many result for ordered super table projection query
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_QHANDLE, 0, 459, "invalid handle")
TAOS_DEFINE_ERROR(TSDB_CODE_QUERY_CANCELLED, 0, 460, "query cancelled")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_IE, 0, 461, "invalid ie")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_VALUE, 0, 462, "invalid value")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_FQDN, 0, 463, "invalid FQDN")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_CLIENT_VERSION, 0, 0x0481, "invalid client version")
TAOS_DEFINE_ERROR(TSDB_CODE_CLI_OUT_OF_MEMORY, 0, 0x0482, "client out of memory")
TAOS_DEFINE_ERROR(TSDB_CODE_CLI_NO_DISKSPACE, 0, 0x0483, "client no disk space")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TIME_STAMP, 0, 0x0484, "invalid timestamp")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_SQL, 0, 0x0485, "invalid sql")
TAOS_DEFINE_ERROR(TSDB_CODE_QUERY_CACHE_ERASED, 0, 0x0486, "query cache erased")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_QUERY_MSG, 0, 0x0487, "invalid query message") // failed to validate the sql expression msg by vnode
TAOS_DEFINE_ERROR(TSDB_CODE_SORTED_RES_TOO_MANY, 0, 0x0488, "sorted res too many") // too many result for ordered super table projection query
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_QHANDLE, 0, 0x0489, "invalid handle")
TAOS_DEFINE_ERROR(TSDB_CODE_QUERY_CANCELLED, 0, 0x048A, "query cancelled")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_IE, 0, 0x048B, "invalid ie")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_VALUE, 0, 0x048C, "invalid value")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_FQDN, 0, 0x048D, "invalid FQDN")
// others
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_FILE_FORMAT, 0, 500, "invalid file format")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_FILE_FORMAT, 0, 0x0500, "invalid file format")
// TSDB
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_CONFIG, 0, 550, "invalid TSDB configuration")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_CONFIG, 0, 0x0580, "invalid TSDB configuration")
#ifdef TAOS_ERROR_C
};
#endif
#define TSDB_CODE_MAX_ERROR_CODE 120
#ifdef __cplusplus
}
......
......@@ -335,17 +335,14 @@ void *shellLoopQuery(void *arg) {
tscError("failed to malloc command");
return NULL;
}
while (1) {
// Read command from shell.
do {
// Read command from shell.
memset(command, 0, MAX_COMMAND_SIZE);
set_terminal_mode();
shellReadCommand(con, command);
reset_terminal_mode();
// Run the command
shellRunCommand(con, command);
}
} while (shellRunCommand(con, command) == 0);
pthread_cleanup_pop(1);
......
......@@ -82,20 +82,15 @@ TAOS *shellInit(SShellArguments *args) {
// Check if it is temperory run
if (args->commands != NULL || args->file[0] != 0) {
if (args->commands != NULL) {
char *token;
token = strtok(args->commands, ";");
while (token != NULL) {
printf("%s%s\n", PROMPT_HEADER, token);
shellRunCommand(con, token);
token = strtok(NULL, ";");
}
printf("%s%s\n", PROMPT_HEADER, args->commands);
shellRunCommand(con, args->commands);
}
if (args->file[0] != 0) {
source_file(con, args->file);
}
taos_close(con);
taos_close(con);
write_history();
exit(EXIT_SUCCESS);
}
......@@ -111,96 +106,37 @@ TAOS *shellInit(SShellArguments *args) {
return con;
}
void shellReplaceCtrlChar(char *str) {
_Bool ctrlOn = false;
char *pstr = NULL;
char quote = 0;
for (pstr = str; *str != '\0'; ++str) {
if (ctrlOn) {
switch (*str) {
case 'n':
*pstr = '\n';
pstr++;
break;
case 'r':
*pstr = '\r';
pstr++;
break;
case 't':
*pstr = '\t';
pstr++;
break;
case 'G':
*pstr++ = '\\';
*pstr++ = *str;
break;
case '\\':
*pstr = '\\';
pstr++;
break;
case '\'':
case '"':
if (quote) {
*pstr++ = '\\';
*pstr++ = *str;
}
break;
default:
*pstr = *str;
pstr++;
break;
}
ctrlOn = false;
} else {
if (*str == '\\') {
ctrlOn = true;
} else {
if (quote == *str) {
quote = 0;
} else if (*str == '\'' || *str == '"') {
quote = *str;
}
*pstr = *str;
pstr++;
}
static bool isEmptyCommand(const char* cmd) {
for (char c = *cmd++; c != 0; c = *cmd++) {
if (c != ' ' && c != '\t' && c != ';') {
return false;
}
}
*pstr = '\0';
return true;
}
int32_t shellRunCommand(TAOS *con, char *command) {
static int32_t shellRunSingleCommand(TAOS *con, char *command) {
/* If command is empty just return */
if (regex_match(command, "^[ \t;]*$", REG_EXTENDED)) {
if (isEmptyCommand(command)) {
return 0;
}
/* Update the history vector. */
if (history.hstart == history.hend ||
history.hist[(history.hend + MAX_HISTORY_SIZE - 1) % MAX_HISTORY_SIZE] == NULL ||
strcmp(command, history.hist[(history.hend + MAX_HISTORY_SIZE - 1) % MAX_HISTORY_SIZE]) != 0) {
if (history.hist[history.hend] != NULL) {
tfree(history.hist[history.hend]);
}
history.hist[history.hend] = strdup(command);
history.hend = (history.hend + 1) % MAX_HISTORY_SIZE;
if (history.hend == history.hstart) {
history.hstart = (history.hstart + 1) % MAX_HISTORY_SIZE;
}
}
shellReplaceCtrlChar(command);
// Analyse the command.
if (regex_match(command, "^[ \t]*(quit|q|exit)[ \t;]*$", REG_EXTENDED | REG_ICASE)) {
taos_close(con);
write_history();
return -1;
} else if (regex_match(command, "^[\t ]*clear[ \t;]*$", REG_EXTENDED | REG_ICASE)) {
}
if (regex_match(command, "^[\t ]*clear[ \t;]*$", REG_EXTENDED | REG_ICASE)) {
// If clear the screen.
system("clear");
} else if (regex_match(command, "^[\t ]*set[ \t]+max_binary_display_width[ \t]+(default|[1-9][0-9]*)[ \t;]*$", REG_EXTENDED | REG_ICASE)) {
return 0;
}
if (regex_match(command, "^[\t ]*set[ \t]+max_binary_display_width[ \t]+(default|[1-9][0-9]*)[ \t;]*$", REG_EXTENDED | REG_ICASE)) {
strtok(command, " \t");
strtok(NULL, " \t");
char* p = strtok(NULL, " \t");
......@@ -209,21 +145,102 @@ int32_t shellRunCommand(TAOS *con, char *command) {
} else {
tsMaxBinaryDisplayWidth = atoi(p);
}
} else if (regex_match(command, "^[ \t]*source[\t ]+[^ ]+[ \t;]*$", REG_EXTENDED | REG_ICASE)) {
return 0;
}
if (regex_match(command, "^[ \t]*source[\t ]+[^ ]+[ \t;]*$", REG_EXTENDED | REG_ICASE)) {
/* If source file. */
char *c_ptr = strtok(command, " ;");
assert(c_ptr != NULL);
c_ptr = strtok(NULL, " ;");
assert(c_ptr != NULL);
source_file(con, c_ptr);
} else {
shellRunCommandOnServer(con, command);
return 0;
}
shellRunCommandOnServer(con, command);
return 0;
}
int32_t shellRunCommand(TAOS* con, char* command) {
/* If command is empty just return */
if (isEmptyCommand(command)) {
return 0;
}
/* Update the history vector. */
if (history.hstart == history.hend ||
history.hist[(history.hend + MAX_HISTORY_SIZE - 1) % MAX_HISTORY_SIZE] == NULL ||
strcmp(command, history.hist[(history.hend + MAX_HISTORY_SIZE - 1) % MAX_HISTORY_SIZE]) != 0) {
if (history.hist[history.hend] != NULL) {
tfree(history.hist[history.hend]);
}
history.hist[history.hend] = strdup(command);
history.hend = (history.hend + 1) % MAX_HISTORY_SIZE;
if (history.hend == history.hstart) {
history.hstart = (history.hstart + 1) % MAX_HISTORY_SIZE;
}
}
bool esc = false;
char quote = 0, *cmd = command, *p = command;
for (char c = *command++; c != 0; c = *command++) {
if (esc) {
switch (c) {
case 'n':
c = '\n';
break;
case 'r':
c = '\r';
break;
case 't':
c = '\t';
break;
case 'G':
*p++ = '\\';
break;
case '\'':
case '"':
if (quote) {
*p++ = '\\';
}
break;
}
*p++ = c;
esc = false;
continue;
}
if (c == '\\') {
esc = true;
continue;
}
if (quote == c) {
quote = 0;
} else if (c == '\'' || c == '"') {
quote = c;
}
*p++ = c;
if (c == ';') {
c = *p;
*p = 0;
if (shellRunSingleCommand(con, cmd) < 0) {
return -1;
}
*p = c;
p = cmd;
}
}
*p = 0;
return shellRunSingleCommand(con, cmd);
}
void shellRunCommandOnServer(TAOS *con, char command[]) {
int64_t st, et;
wordexp_t full_path;
......
......@@ -307,19 +307,13 @@ void *shellLoopQuery(void *arg) {
return NULL;
}
while (1) {
do {
// Read command from shell.
memset(command, 0, MAX_COMMAND_SIZE);
set_terminal_mode();
shellReadCommand(con, command);
reset_terminal_mode();
// Run the command
if (shellRunCommand(con, command) != 0) {
break;
}
}
} while (shellRunCommand(con, command) == 0);
tfree(command);
exitShell();
......
......@@ -203,16 +203,13 @@ void *shellLoopQuery(void *arg) {
char *command = malloc(MAX_COMMAND_SIZE);
if (command == NULL) return NULL;
while (1) {
do {
memset(command, 0, MAX_COMMAND_SIZE);
shellPrintPrompt();
// Read command from shell.
shellReadCommand(con, command);
// Run the command
shellRunCommand(con, command);
}
} while (shellRunCommand(con, command) == 0);
return NULL;
}
......
......@@ -27,23 +27,23 @@ extern int32_t mDebugFlag;
extern int32_t sdbDebugFlag;
// mnode log function
#define mError(...) if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR MND ", 255, __VA_ARGS__); }
#define mWarn(...) if (mDebugFlag & DEBUG_WARN) { taosPrintLog("WARN MND ", mDebugFlag, __VA_ARGS__); }
#define mTrace(...) if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }
#define mPrint(...) { taosPrintLog("MND ", 255, __VA_ARGS__); }
#define mLError(...) monitorSaveLog(2, __VA_ARGS__); mError(__VA_ARGS__)
#define mLWarn(...) monitorSaveLog(1, __VA_ARGS__); mWarn(__VA_ARGS__)
#define mLPrint(...) monitorSaveLog(0, __VA_ARGS__); mPrint(__VA_ARGS__)
#define sdbError(...) if (sdbDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR MND-SDB ", 255, __VA_ARGS__); }
#define sdbWarn(...) if (sdbDebugFlag & DEBUG_WARN) { taosPrintLog("WARN MND-SDB ", sdbDebugFlag, __VA_ARGS__); }
#define sdbTrace(...) if (sdbDebugFlag & DEBUG_TRACE) { taosPrintLog("MND-SDB ", sdbDebugFlag, __VA_ARGS__);}
#define sdbPrint(...) { taosPrintLog("MND-SDB ", 255, __VA_ARGS__); }
#define sdbLError(...) monitorSaveLog(2, __VA_ARGS__); sdbError(__VA_ARGS__)
#define sdbLWarn(...) monitorSaveLog(1, __VA_ARGS__); sdbWarn(__VA_ARGS__)
#define sdbLPrint(...) monitorSaveLog(0, __VA_ARGS__); sdbPrint(__VA_ARGS__)
#define mError(...) { if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR MND ", 255, __VA_ARGS__); }}
#define mWarn(...) { if (mDebugFlag & DEBUG_WARN) { taosPrintLog("WARN MND ", mDebugFlag, __VA_ARGS__); }}
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }}
#define mPrint(...) { taosPrintLog("MND ", 255, __VA_ARGS__); }
#define mLError(...) { monitorSaveLog(2, __VA_ARGS__); mError(__VA_ARGS__) }
#define mLWarn(...) { monitorSaveLog(1, __VA_ARGS__); mWarn(__VA_ARGS__) }
#define mLPrint(...) { monitorSaveLog(0, __VA_ARGS__); mPrint(__VA_ARGS__) }
#define sdbError(...) { if (sdbDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR MND-SDB ", 255, __VA_ARGS__); }}
#define sdbWarn(...) { if (sdbDebugFlag & DEBUG_WARN) { taosPrintLog("WARN MND-SDB ", sdbDebugFlag, __VA_ARGS__); }}
#define sdbTrace(...) { if (sdbDebugFlag & DEBUG_TRACE) { taosPrintLog("MND-SDB ", sdbDebugFlag, __VA_ARGS__);}}
#define sdbPrint(...) { taosPrintLog("MND-SDB ", 255, __VA_ARGS__); }
#define sdbLError(...) { monitorSaveLog(2, __VA_ARGS__); sdbError(__VA_ARGS__) }
#define sdbLWarn(...) { monitorSaveLog(1, __VA_ARGS__); sdbWarn(__VA_ARGS__) }
#define sdbLPrint(...) { monitorSaveLog(0, __VA_ARGS__); sdbPrint(__VA_ARGS__) }
#ifdef __cplusplus
}
......
......@@ -226,11 +226,11 @@ static void taosGetSystemLocale() { // get and set default locale
if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
locale = setlocale(LC_CTYPE, "");
if (locale == NULL) {
uForcePrint("can't get locale from system, set it to en_US.UTF-8");
uError("can't get locale from system, set it to en_US.UTF-8");
strcpy(tsLocale, "en_US.UTF-8");
} else {
strncpy(tsLocale, locale, tListLen(tsLocale));
uForcePrint("locale not configured, set to system default:%s", tsLocale);
uError("locale not configured, set to system default:%s", tsLocale);
}
}
......@@ -245,10 +245,10 @@ static void taosGetSystemLocale() { // get and set default locale
strncpy(tsCharset, revisedCharset, tListLen(tsCharset));
free(revisedCharset);
uForcePrint("charset not configured, set to system default:%s", tsCharset);
uError("charset not configured, set to system default:%s", tsCharset);
} else {
strcpy(tsCharset, "UTF-8");
uForcePrint("can't get locale and charset from system, set it to UTF-8");
uError("can't get locale and charset from system, set it to UTF-8");
}
}
}
......
......@@ -20,23 +20,10 @@
extern int32_t httpDebugFlag;
#define httpError(...) \
if (httpDebugFlag & DEBUG_ERROR) { \
taosPrintLog("ERROR HTP ", 255, __VA_ARGS__); \
}
#define httpWarn(...) \
if (httpDebugFlag & DEBUG_WARN) { \
taosPrintLog("WARN HTP ", httpDebugFlag, __VA_ARGS__); \
}
#define httpTrace(...) \
if (httpDebugFlag & DEBUG_TRACE) { \
taosPrintLog("HTP ", httpDebugFlag, __VA_ARGS__); \
}
#define httpDump(...) \
if (httpDebugFlag & DEBUG_TRACE) { \
taosPrintLongString("HTP ", httpDebugFlag, __VA_ARGS__); \
}
#define httpPrint(...) \
{ taosPrintLog("HTP ", 255, __VA_ARGS__); }
#define httpError(...) { if (httpDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR HTP ", 255, __VA_ARGS__); }}
#define httpWarn(...) { if (httpDebugFlag & DEBUG_WARN) { taosPrintLog("WARN HTP ", httpDebugFlag, __VA_ARGS__); }}
#define httpTrace(...) { if (httpDebugFlag & DEBUG_TRACE) { taosPrintLog("HTP ", httpDebugFlag, __VA_ARGS__); }}
#define httpDump(...) { if (httpDebugFlag & DEBUG_TRACE) { taosPrintLongString("HTP ", httpDebugFlag, __VA_ARGS__); }}
#define httpPrint(...) { taosPrintLog("HTP ", 255, __VA_ARGS__); }
#endif
......@@ -27,20 +27,10 @@
#include "dnode.h"
#include "monitor.h"
#define monitorError(...) \
if (monitorDebugFlag & DEBUG_ERROR) { \
taosPrintLog("ERROR MON ", 255, __VA_ARGS__); \
}
#define monitorWarn(...) \
if (monitorDebugFlag & DEBUG_WARN) { \
taosPrintLog("WARN MON ", monitorDebugFlag, __VA_ARGS__); \
}
#define monitorTrace(...) \
if (monitorDebugFlag & DEBUG_TRACE) { \
taosPrintLog("MON ", monitorDebugFlag, __VA_ARGS__); \
}
#define monitorPrint(...) \
{ taosPrintLog("MON ", 255, __VA_ARGS__); }
#define monitorError(...) { if (monitorDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR MON ", 255, __VA_ARGS__); }}
#define monitorWarn(...) { if (monitorDebugFlag & DEBUG_WARN) { taosPrintLog("WARN MON ", monitorDebugFlag, __VA_ARGS__); }}
#define monitorTrace(...) { if (monitorDebugFlag & DEBUG_TRACE) { taosPrintLog("MON ", monitorDebugFlag, __VA_ARGS__); }}
#define monitorPrint(...) { taosPrintLog("MON ", 255, __VA_ARGS__); }
#define SQL_LENGTH 1024
#define LOG_LEN_STR 100
......
......@@ -24,23 +24,12 @@ extern "C" {
extern int32_t qDebugFlag;
#define qTrace(...) \
if (qDebugFlag & DEBUG_TRACE) { \
taosPrintLog("QRY ", qDebugFlag, __VA_ARGS__); \
}
#define qError(...) \
if (qDebugFlag & DEBUG_ERROR) { \
taosPrintLog("ERROR QRY ", qDebugFlag, __VA_ARGS__); \
}
#define qWarn(...) \
if (qDebugFlag & DEBUG_WARN) { \
taosPrintLog("WARN QRY ", qDebugFlag, __VA_ARGS__); \
}
#define qTrace(...) { if (qDebugFlag & DEBUG_TRACE) { taosPrintLog("QRY ", qDebugFlag, __VA_ARGS__); }}
#define qError(...) { if (qDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR QRY ", qDebugFlag, __VA_ARGS__); }}
#define qWarn(...) { if (qDebugFlag & DEBUG_WARN) { taosPrintLog("WARN QRY ", qDebugFlag, __VA_ARGS__); }}
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_QUERY_CACHE_H
#endif // TDENGINE_QUERY_LOG_H
......@@ -24,27 +24,14 @@ extern "C" {
extern int32_t rpcDebugFlag;
#define tError(...) \
if (rpcDebugFlag & DEBUG_ERROR) { \
taosPrintLog("ERROR RPC ", rpcDebugFlag, __VA_ARGS__); \
}
#define tWarn(...) \
if (rpcDebugFlag & DEBUG_WARN) { \
taosPrintLog("WARN RPC ", rpcDebugFlag, __VA_ARGS__); \
}
#define tTrace(...) \
if (rpcDebugFlag & DEBUG_TRACE) { \
taosPrintLog("RPC ", rpcDebugFlag, __VA_ARGS__); \
}
#define tPrint(...) \
{ taosPrintLog("RPC ", 255, __VA_ARGS__); }
#define tDump(x, y) \
if (rpcDebugFlag & DEBUG_DUMP) { \
taosDumpData((unsigned char *)x, y); \
}
#define tError(...) { if (rpcDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR RPC ", rpcDebugFlag, __VA_ARGS__); }}
#define tWarn(...) { if (rpcDebugFlag & DEBUG_WARN) { taosPrintLog("WARN RPC ", rpcDebugFlag, __VA_ARGS__); }}
#define tTrace(...) { if (rpcDebugFlag & DEBUG_TRACE) { taosPrintLog("RPC ", rpcDebugFlag, __VA_ARGS__); }}
#define tDump(x, y) { if (rpcDebugFlag & DEBUG_DUMP) { taosDumpData((unsigned char *)x, y); }}
#define tPrint(...) { taosPrintLog("RPC ", 255, __VA_ARGS__); }
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_RPC_CACHE_H
#endif // TDENGINE_RPC_LOG_H
......@@ -594,7 +594,10 @@ static SRpcConn *rpcAllocateServerConn(SRpcInfo *pRpc, SRecvInfo *pRecv) {
// check if it is already allocated
SRpcConn **ppConn = (SRpcConn **)(taosHashGet(pRpc->hash, hashstr, size));
if (ppConn) pConn = *ppConn;
if (pConn) return pConn;
if (pConn) {
pConn->secured = 0;
return pConn;
}
int sid = taosAllocateId(pRpc->idPool);
if (sid <= 0) {
......
......@@ -29,20 +29,10 @@ extern "C" {
extern int tsdbDebugFlag;
#define tsdbError(...) \
if (tsdbDebugFlag & DEBUG_ERROR) { \
taosPrintLog("ERROR TDB ", tsdbDebugFlag, __VA_ARGS__); \
}
#define tsdbWarn(...) \
if (tsdbDebugFlag & DEBUG_WARN) { \
taosPrintLog("WARN TDB ", tsdbDebugFlag, __VA_ARGS__); \
}
#define tsdbTrace(...) \
if (tsdbDebugFlag & DEBUG_TRACE) { \
taosPrintLog("TDB ", tsdbDebugFlag, __VA_ARGS__); \
}
#define tsdbPrint(...) \
{ taosPrintLog("TDB ", 255, __VA_ARGS__); }
#define tsdbError(...) { if (tsdbDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR TDB ", tsdbDebugFlag, __VA_ARGS__); }}
#define tsdbWarn(...) { if (tsdbDebugFlag & DEBUG_WARN) { taosPrintLog("WARN TDB ", tsdbDebugFlag, __VA_ARGS__); }}
#define tsdbTrace(...) { if (tsdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TDB ", tsdbDebugFlag, __VA_ARGS__); }}
#define tsdbPrint(...) { taosPrintLog("TDB ", 255, __VA_ARGS__); }
// ------------------------------ TSDB META FILE INTERFACES ------------------------------
#define TSDB_META_FILE_NAME "meta"
......
......@@ -936,7 +936,7 @@ static SSkipListIterator **tsdbCreateTableIters(STsdbMeta *pMeta, int maxTables)
for (int tid = 1; tid < maxTables; tid++) {
STable *pTable = pMeta->tables[tid];
if (pTable == NULL || pTable->imem == NULL) continue;
if (pTable == NULL || pTable->imem == NULL || pTable->imem->numOfRows == 0) continue;
iters[tid] = tSkipListCreateIter(pTable->imem->pData);
if (iters[tid] == NULL) goto _err;
......@@ -968,12 +968,12 @@ static void *tsdbCommitData(void *arg) {
SRWHelper whelper = {{0}};
if (pCache->imem == NULL) return NULL;
tsdbPrint("vgId: %d, starting to commit....", pRepo->config.tsdbId);
tsdbPrint("vgId:%d, starting to commit....", pRepo->config.tsdbId);
// Create the iterator to read from cache
SSkipListIterator **iters = tsdbCreateTableIters(pMeta, pCfg->maxTables);
if (iters == NULL) {
// TODO: deal with the error
ASSERT(0);
return NULL;
}
......@@ -1015,6 +1015,7 @@ _exit:
}
}
tsdbUnLockRepo(arg);
tsdbPrint("vgId:%d, commit over....", pRepo->config.tsdbId);
return NULL;
}
......
......@@ -46,7 +46,6 @@ class TDTestCase:
tdLog.info('insert data until the first commit')
dnodesDir = tdDnodes.getDnodesRootDir()
dataDir = dnodesDir + '/dnode1/data/vnode'
tdLog.info('CBD: dataDir=%s' % dataDir)
startTime = self.startTime
rid0 = 1
while (True):
......
run general/cache/new_metrics.sim
run general/column/commit.sim
run general/compress/compress.sim
run general/compute/avg.sim
run general/compute/count.sim
run general/db/len.sim
run general/compute/interval.sim
run general/db/basic4.sim
run general/field/binary.sim
run general/http/restful_insert.sim
run general/import/basic.sim
run general/import/commit.sim
run general/insert/query_file_memory.sim
run general/import/replica1.sim
run general/parser/auto_create_tb_drop_tb.sim
run general/parser/binary_escapeCharacter.sim
run general/parser/select_from_cache_disk.sim
run general/stable/vnode3.sim
run general/table/autocreate.sim
run general/table/column_name.sim
run general/table/int.sim
run general/table/fill.sim
run general/table/vgroup.sim
run general/user/basic1.sim
run general/user/pass_alter.sim
run general/vector/single.sim
#run general/connection/connection.sim
run general/tag/filter.sim
run general/user/authority.sim
run general/user/pass_alter.sim
run general/vector/metrics_mix.sim
run general/vector/table_field.sim
......@@ -16,6 +16,6 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
add_executable(importOneRow importOneRow.c)
target_link_libraries(importOneRow taos_static pthread)
add_executable(importPerTabe importPerTabe.c)
target_link_libraries(importPerTabe taos_static pthread)
add_executable(importPerTable importPerTable.c)
target_link_libraries(importPerTable taos_static pthread)
ENDIF()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册