Merge remote-tracking branch 'origin/3.0' into test/bug_last_first
This commit is contained in:
commit
400d769cc8
|
@ -202,6 +202,10 @@ The configuration parameters in the URL are as follows.
|
|||
- batchfetch: true: pull the result set in batch when executing the query; false: pull the result set row by row. The default value is false. batchfetch uses HTTP for data transfer. The JDBC REST connection supports bulk data pulling function in taos-jdbcdriver-2.0.38 and TDengine 2.4.0.12 and later versions. taos-jdbcdriver and TDengine transfer data via WebSocket connection. Compared with HTTP, WebSocket enables JDBC REST connection to support large data volume querying and improve query performance.
|
||||
- charset: specify the charset to parse the string, this parameter is valid only when set batchfetch to true.
|
||||
- batchErrorIgnore: true: when executing executeBatch of Statement, if one SQL execution fails in the middle, continue to execute the following SQL. false: no longer execute any statement after the failed SQL. The default value is: false.
|
||||
- httpConnectTimeout: REST connection timeout in milliseconds, the default value is 5000 ms.
|
||||
- httpSocketTimeout: socket timeout in milliseconds, the default value is 5000 ms. It only takes effect when batchfetch is false.
|
||||
- messageWaitTimeout: message transmission timeout in milliseconds, the default value is 3000 ms. It only takes effect when batchfetch is true.
|
||||
- useSSL: connecting Securely Using SSL. true: using SSL conneciton, false: not using SSL connection.
|
||||
|
||||
**Note**: Some configuration items (e.g., locale, timezone) do not work in the REST connection.
|
||||
|
||||
|
@ -257,14 +261,18 @@ In the above example, a connection is established to `taosdemo.com`, port is 603
|
|||
|
||||
The configuration parameters in properties are as follows.
|
||||
|
||||
- TSDBDriver.PROPERTY_KEY_USER: Login TDengine user name, default value 'root'.
|
||||
- TSDBDriver.PROPERTY_KEY_USER: login TDengine user name, default value 'root'.
|
||||
- TSDBDriver.PROPERTY_KEY_PASSWORD: user login password, default value 'taosdata'.
|
||||
- TSDBDriver.PROPERTY_KEY_BATCH_LOAD: true: pull the result set in batch when executing query; false: pull the result set row by row. The default value is: false.
|
||||
- TSDBDriver.PROPERTY_KEY_BATCH_ERROR_IGNORE: true: when executing executeBatch of Statement, if there is a SQL execution failure in the middle, continue to execute the following sq. false: no longer execute any statement after the failed SQL. The default value is: false.
|
||||
- TSDBDriver.PROPERTY_KEY_CONFIG_DIR: Only works when using JDBC native connection. Client configuration file directory path, default value `/etc/taos` on Linux OS, default value `C:/TDengine/cfg` on Windows OS.
|
||||
- TSDBDriver.PROPERTY_KEY_CONFIG_DIR: only works when using JDBC native connection. Client configuration file directory path, default value `/etc/taos` on Linux OS, default value `C:/TDengine/cfg` on Windows OS.
|
||||
- TSDBDriver.PROPERTY_KEY_CHARSET: In the character set used by the client, the default value is the system character set.
|
||||
- TSDBDriver.PROPERTY_KEY_LOCALE: this only takes effect when using JDBC native connection. Client language environment, the default value is system current locale.
|
||||
- TSDBDriver.PROPERTY_KEY_TIME_ZONE: only takes effect when using JDBC native connection. In the time zone used by the client, the default value is the system's current time zone.
|
||||
- TSDBDriver.HTTP_CONNECT_TIMEOUT: REST connection timeout in milliseconds, the default value is 5000 ms. It only takes effect when using JDBC REST connection.
|
||||
- TSDBDriver.HTTP_SOCKET_TIMEOUT: socket timeout in milliseconds, the default value is 5000 ms. It only takes effect when using JDBC REST connection and batchfetch is false.
|
||||
- TSDBDriver.PROPERTY_KEY_MESSAGE_WAIT_TIMEOUT: message transmission timeout in milliseconds, the default value is 3000 ms. It only takes effect when using JDBC REST connection and batchfetch is true.
|
||||
- TSDBDriver.PROPERTY_KEY_USE_SSL: connecting Securely Using SSL. true: using SSL conneciton, false: not using SSL connection. It only takes effect when using using JDBC REST connection.
|
||||
For JDBC native connections, you can specify other parameters, such as log level, SQL length, etc., by specifying URL and Properties. For more detailed configuration, please refer to [Client Configuration](/reference/config/#Client-Only).
|
||||
|
||||
### Priority of configuration parameters
|
||||
|
@ -812,11 +820,12 @@ Please refer to: [JDBC example](https://github.com/taosdata/TDengine/tree/develo
|
|||
|
||||
## Recent update logs
|
||||
|
||||
| taos-jdbcdriver version | major changes |
|
||||
| :---------------------: | :------------------------------------------: |
|
||||
| 2.0.38 | JDBC REST connections add bulk pull function |
|
||||
| 2.0.37 | Added support for json tags |
|
||||
| 2.0.36 | Add support for schemaless writing |
|
||||
| taos-jdbcdriver version | major changes |
|
||||
| :---------------------: | :--------------------------------------------: |
|
||||
| 2.0.39 - 2.0.40 | Add REST connection/request timeout parameters |
|
||||
| 2.0.38 | JDBC REST connections add bulk pull function |
|
||||
| 2.0.37 | Support json tags |
|
||||
| 2.0.36 | Support schemaless writing |
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
|
|
|
@ -201,6 +201,10 @@ url 中的配置参数如下:
|
|||
- batchfetch: true:在执行查询时批量拉取结果集;false:逐行拉取结果集。默认值为:false。逐行拉取结果集使用 HTTP 方式进行数据传输。从 taos-jdbcdriver-2.0.38 和 TDengine 2.4.0.12 版本开始,JDBC REST 连接增加批量拉取数据功能。taos-jdbcdriver 与 TDengine 之间通过 WebSocket 连接进行数据传输。相较于 HTTP,WebSocket 可以使 JDBC REST 连接支持大数据量查询,并提升查询性能。
|
||||
- charset: 当开启批量拉取数据时,指定解析字符串数据的字符集。
|
||||
- batchErrorIgnore:true:在执行 Statement 的 executeBatch 时,如果中间有一条 SQL 执行失败,继续执行下面的 SQL 了。false:不再执行失败 SQL 后的任何语句。默认值为:false。
|
||||
- httpConnectTimeout: 连接超时时间,单位 ms, 默认值为 5000。
|
||||
- httpSocketTimeout: socket 超时时间,单位 ms,默认值为 5000。仅在 batchfetch 设置为 false 时生效。
|
||||
- messageWaitTimeout: 消息超时时间, 单位 ms, 默认值为 3000。 仅在 batchfetch 设置为 true 时生效。
|
||||
- useSSL: 连接中是否使用 SSL。
|
||||
|
||||
**注意**:部分配置项(比如:locale、timezone)在 REST 连接中不生效。
|
||||
|
||||
|
@ -264,7 +268,11 @@ properties 中的配置参数如下:
|
|||
- TSDBDriver.PROPERTY_KEY_CHARSET:客户端使用的字符集,默认值为系统字符集。
|
||||
- TSDBDriver.PROPERTY_KEY_LOCALE:仅在使用 JDBC 原生连接时生效。 客户端语言环境,默认值系统当前 locale。
|
||||
- TSDBDriver.PROPERTY_KEY_TIME_ZONE:仅在使用 JDBC 原生连接时生效。 客户端使用的时区,默认值为系统当前时区。
|
||||
- 此外对 JDBC 原生连接,通过指定 URL 和 Properties 还可以指定其他参数,比如日志级别、SQL 长度等。更多详细配置请参考[客户端配置](/reference/config/#仅客户端适用)。
|
||||
- TSDBDriver.HTTP_CONNECT_TIMEOUT: 连接超时时间,单位 ms, 默认值为 5000。仅在 REST 连接时生效。
|
||||
- TSDBDriver.HTTP_SOCKET_TIMEOUT: socket 超时时间,单位 ms,默认值为 5000。仅在 REST 连接且 batchfetch 设置为 false 时生效。
|
||||
- TSDBDriver.PROPERTY_KEY_MESSAGE_WAIT_TIMEOUT: 消息超时时间, 单位 ms, 默认值为 3000。 仅在 REST 连接且 batchfetch 设置为 true 时生效。
|
||||
- TSDBDriver.PROPERTY_KEY_USE_SSL: 连接中是否使用 SSL。仅在 REST 连接时生效。
|
||||
此外对 JDBC 原生连接,通过指定 URL 和 Properties 还可以指定其他参数,比如日志级别、SQL 长度等。更多详细配置请参考[客户端配置](/reference/config/#仅客户端适用)。
|
||||
|
||||
### 配置参数的优先级
|
||||
|
||||
|
@ -809,6 +817,7 @@ Query OK, 1 row(s) in set (0.000141s)
|
|||
|
||||
| taos-jdbcdriver 版本 | 主要变化 |
|
||||
| :------------------: | :----------------------------: |
|
||||
| 2.0.39 - 2.0.40 | 增加 REST 连接/请求 超时设置 |
|
||||
| 2.0.38 | JDBC REST 连接增加批量拉取功能 |
|
||||
| 2.0.37 | 增加对 json tag 支持 |
|
||||
| 2.0.36 | 增加对 schemaless 写入支持 |
|
||||
|
|
|
@ -28,8 +28,9 @@ static void msg_process(TAOS_RES* msg) {
|
|||
printf("db: %s\n", tmq_get_db_name(msg));
|
||||
printf("vg: %d\n", tmq_get_vgroup_id(msg));
|
||||
if (tmq_get_res_type(msg) == TMQ_RES_TABLE_META) {
|
||||
tmq_raw_data* raw = tmq_get_raw_meta(msg);
|
||||
if (raw) {
|
||||
tmq_raw_data raw = {0};
|
||||
int32_t code = tmq_get_raw_meta(msg, &raw);
|
||||
if (code == 0) {
|
||||
TAOS* pConn = taos_connect("192.168.1.86", "root", "taosdata", NULL, 0);
|
||||
if (pConn == NULL) {
|
||||
return;
|
||||
|
@ -53,7 +54,6 @@ static void msg_process(TAOS_RES* msg) {
|
|||
printf("write raw data: %s\n", tmq_err2str(ret));
|
||||
taos_close(pConn);
|
||||
}
|
||||
tmq_free_raw_meta(raw);
|
||||
char* result = tmq_get_json_meta(msg);
|
||||
if (result) {
|
||||
printf("meta result: %s\n", result);
|
||||
|
|
|
@ -259,13 +259,17 @@ enum tmq_res_t {
|
|||
TMQ_RES_TABLE_META = 2,
|
||||
};
|
||||
|
||||
typedef struct tmq_raw_data{
|
||||
void* raw_meta;
|
||||
uint32_t raw_meta_len;
|
||||
uint16_t raw_meta_type;
|
||||
} tmq_raw_data;
|
||||
|
||||
typedef enum tmq_res_t tmq_res_t;
|
||||
typedef struct tmq_raw_data tmq_raw_data;
|
||||
|
||||
DLL_EXPORT tmq_res_t tmq_get_res_type(TAOS_RES *res);
|
||||
DLL_EXPORT tmq_raw_data *tmq_get_raw_meta(TAOS_RES *res);
|
||||
DLL_EXPORT int32_t taos_write_raw_meta(TAOS *taos, tmq_raw_data *raw_meta);
|
||||
DLL_EXPORT void tmq_free_raw_meta(tmq_raw_data *rawMeta);
|
||||
DLL_EXPORT int32_t tmq_get_raw_meta(TAOS_RES *res, tmq_raw_data *raw_meta);
|
||||
DLL_EXPORT int32_t taos_write_raw_meta(TAOS *taos, tmq_raw_data raw_meta);
|
||||
DLL_EXPORT char *tmq_get_json_meta(TAOS_RES *res); // Returning null means error. Returned result need to be freed by tmq_free_json_meta
|
||||
DLL_EXPORT void tmq_free_json_meta(char* jsonMeta);
|
||||
DLL_EXPORT const char *tmq_get_topic_name(TAOS_RES *res);
|
||||
|
|
|
@ -54,12 +54,12 @@ enum {
|
|||
enum {
|
||||
STREAM_INPUT__DATA_SUBMIT = 1,
|
||||
STREAM_INPUT__DATA_BLOCK,
|
||||
STREAM_INPUT__MERGED_SUBMIT,
|
||||
// STREAM_INPUT__TABLE_SCAN,
|
||||
STREAM_INPUT__TQ_SCAN,
|
||||
STREAM_INPUT__DATA_RETRIEVE,
|
||||
STREAM_INPUT__GET_RES,
|
||||
STREAM_INPUT__CHECKPOINT,
|
||||
STREAM_INPUT__DROP,
|
||||
};
|
||||
|
||||
typedef enum EStreamType {
|
||||
|
|
|
@ -2803,6 +2803,7 @@ typedef struct {
|
|||
|
||||
int32_t tSerializeSTableIndexRsp(void* buf, int32_t bufLen, const STableIndexRsp* pRsp);
|
||||
int32_t tDeserializeSTableIndexRsp(void* buf, int32_t bufLen, STableIndexRsp* pRsp);
|
||||
void tFreeSerializeSTableIndexRsp(STableIndexRsp* pRsp);
|
||||
|
||||
void tFreeSTableIndexInfo(void* pInfo);
|
||||
|
||||
|
|
|
@ -73,7 +73,6 @@ static FORCE_INLINE int64_t taosGetTimestampToday(int32_t precision) {
|
|||
}
|
||||
|
||||
int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision);
|
||||
int64_t taosTimeSub(int64_t t, int64_t duration, char unit, int32_t precision);
|
||||
|
||||
int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precision);
|
||||
int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char unit, int32_t precision);
|
||||
|
|
|
@ -40,6 +40,7 @@ typedef struct SReadHandle {
|
|||
bool initMetaReader;
|
||||
bool initTableReader;
|
||||
bool initTqReader;
|
||||
int32_t numOfVgroups;
|
||||
} SReadHandle;
|
||||
|
||||
// in queue mode, data streams are seperated by msg
|
||||
|
@ -63,7 +64,7 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers);
|
|||
* @param SReadHandle
|
||||
* @return
|
||||
*/
|
||||
qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers);
|
||||
qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* numOfCols);
|
||||
|
||||
/**
|
||||
* Set the input data block for the stream scan.
|
||||
|
|
|
@ -162,9 +162,12 @@ typedef struct SRequestConnInfo {
|
|||
SEpSet mgmtEps;
|
||||
} SRequestConnInfo;
|
||||
|
||||
typedef void (*__freeFunc)(void *param);
|
||||
|
||||
typedef struct SMsgSendInfo {
|
||||
__async_send_cb_fn_t fp; // async callback function
|
||||
STargetInfo target; // for update epset
|
||||
__freeFunc paramFreeFp;
|
||||
void* param;
|
||||
uint64_t requestId;
|
||||
uint64_t requestObjRefId;
|
||||
|
@ -188,6 +191,8 @@ int32_t cleanupTaskQueue();
|
|||
*/
|
||||
int32_t taosAsyncExec(__async_exec_fn_t execFn, void* execParam, int32_t* code);
|
||||
|
||||
void destroySendMsgInfo(SMsgSendInfo* pMsgBody);
|
||||
|
||||
int32_t asyncSendMsgToServerExt(void* pTransporter, SEpSet* epSet, int64_t* pTransporterId, const SMsgSendInfo* pInfo,
|
||||
bool persistHandle, void* ctx);
|
||||
|
||||
|
|
|
@ -77,6 +77,13 @@ typedef struct {
|
|||
SSubmitReq* data;
|
||||
} SStreamDataSubmit;
|
||||
|
||||
typedef struct {
|
||||
int8_t type;
|
||||
int64_t ver;
|
||||
SArray* dataRefs; // SArray<int32_t*>
|
||||
SArray* reqs; // SArray<SSubmitReq*>
|
||||
} SStreamMergedSubmit;
|
||||
|
||||
typedef struct {
|
||||
int8_t type;
|
||||
|
||||
|
@ -262,6 +269,7 @@ typedef struct SStreamTask {
|
|||
int64_t startVer;
|
||||
int64_t checkpointVer;
|
||||
int64_t processedVer;
|
||||
int32_t numOfVgroups;
|
||||
|
||||
// children info
|
||||
SArray* childEpInfo; // SArray<SStreamChildEpInfo*>
|
||||
|
|
|
@ -26,7 +26,7 @@ extern "C" {
|
|||
|
||||
extern bool gRaftDetailLog;
|
||||
|
||||
#define SYNC_RESP_TTL_MS 5000
|
||||
#define SYNC_RESP_TTL_MS 10000
|
||||
|
||||
#define SYNC_MAX_BATCH_SIZE 500
|
||||
#define SYNC_INDEX_BEGIN 0
|
||||
|
|
|
@ -33,16 +33,16 @@ extern "C" {
|
|||
#define wTrace(...) { if (wDebugFlag & DEBUG_TRACE) { taosPrintLog("WAL ", DEBUG_TRACE, wDebugFlag, __VA_ARGS__); }}
|
||||
// clang-format on
|
||||
|
||||
#define WAL_PROTO_VER 0
|
||||
#define WAL_NOSUFFIX_LEN 20
|
||||
#define WAL_SUFFIX_AT (WAL_NOSUFFIX_LEN + 1)
|
||||
#define WAL_LOG_SUFFIX "log"
|
||||
#define WAL_INDEX_SUFFIX "idx"
|
||||
#define WAL_REFRESH_MS 1000
|
||||
#define WAL_MAX_SIZE (TSDB_MAX_WAL_SIZE + sizeof(SWalCkHead))
|
||||
#define WAL_PATH_LEN (TSDB_FILENAME_LEN + 12)
|
||||
#define WAL_FILE_LEN (WAL_PATH_LEN + 32)
|
||||
#define WAL_MAGIC 0xFAFBFCFDULL
|
||||
#define WAL_PROTO_VER 0
|
||||
#define WAL_NOSUFFIX_LEN 20
|
||||
#define WAL_SUFFIX_AT (WAL_NOSUFFIX_LEN + 1)
|
||||
#define WAL_LOG_SUFFIX "log"
|
||||
#define WAL_INDEX_SUFFIX "idx"
|
||||
#define WAL_REFRESH_MS 1000
|
||||
#define WAL_PATH_LEN (TSDB_FILENAME_LEN + 12)
|
||||
#define WAL_FILE_LEN (WAL_PATH_LEN + 32)
|
||||
#define WAL_MAGIC 0xFAFBFCFDULL
|
||||
#define WAL_SCAN_BUF_SIZE (1024 * 1024 * 3)
|
||||
|
||||
typedef enum {
|
||||
TAOS_WAL_WRITE = 1,
|
||||
|
@ -64,6 +64,7 @@ typedef struct {
|
|||
int64_t verInSnapshotting;
|
||||
int64_t snapshotVer;
|
||||
int64_t commitVer;
|
||||
int64_t appliedVer;
|
||||
int64_t lastVer;
|
||||
} SWalVer;
|
||||
|
||||
|
@ -172,6 +173,9 @@ int32_t walRollback(SWal *, int64_t ver);
|
|||
int32_t walBeginSnapshot(SWal *, int64_t ver);
|
||||
int32_t walEndSnapshot(SWal *);
|
||||
int32_t walRestoreFromSnapshot(SWal *, int64_t ver);
|
||||
// for tq
|
||||
int32_t walApplyVer(SWal *, int64_t ver);
|
||||
|
||||
// int32_t walDataCorrupted(SWal*);
|
||||
|
||||
// read
|
||||
|
@ -186,7 +190,6 @@ void walSetReaderCapacity(SWalReader *pRead, int32_t capacity);
|
|||
int32_t walFetchHead(SWalReader *pRead, int64_t ver, SWalCkHead *pHead);
|
||||
int32_t walFetchBody(SWalReader *pRead, SWalCkHead **ppHead);
|
||||
int32_t walSkipFetchBody(SWalReader *pRead, const SWalCkHead *pHead);
|
||||
|
||||
typedef struct {
|
||||
int64_t refId;
|
||||
int64_t ver;
|
||||
|
@ -206,6 +209,7 @@ int64_t walGetFirstVer(SWal *);
|
|||
int64_t walGetSnapshotVer(SWal *);
|
||||
int64_t walGetLastVer(SWal *);
|
||||
int64_t walGetCommittedVer(SWal *);
|
||||
int64_t walGetAppliedVer(SWal *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -493,10 +493,11 @@ int32_t* taosGetErrno();
|
|||
|
||||
//parser
|
||||
#define TSDB_CODE_PAR_SYNTAX_ERROR TAOS_DEF_ERROR_CODE(0, 0x2600)
|
||||
#define TSDB_CODE_PAR_INVALID_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2601)
|
||||
#define TSDB_CODE_PAR_TABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x2602)
|
||||
#define TSDB_CODE_PAR_AMBIGUOUS_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2603)
|
||||
#define TSDB_CODE_PAR_WRONG_VALUE_TYPE TAOS_DEF_ERROR_CODE(0, 0x2604)
|
||||
#define TSDB_CODE_PAR_INCOMPLETE_SQL TAOS_DEF_ERROR_CODE(0, 0x2601)
|
||||
#define TSDB_CODE_PAR_INVALID_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2602)
|
||||
#define TSDB_CODE_PAR_TABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x2603)
|
||||
#define TSDB_CODE_PAR_AMBIGUOUS_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2604)
|
||||
#define TSDB_CODE_PAR_WRONG_VALUE_TYPE TAOS_DEF_ERROR_CODE(0, 0x2605)
|
||||
#define TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION TAOS_DEF_ERROR_CODE(0, 0x2608)
|
||||
#define TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT TAOS_DEF_ERROR_CODE(0, 0x2609)
|
||||
#define TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION TAOS_DEF_ERROR_CODE(0, 0x260A)
|
||||
|
@ -504,7 +505,6 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_PAR_NOT_SINGLE_GROUP TAOS_DEF_ERROR_CODE(0, 0x260C)
|
||||
#define TSDB_CODE_PAR_TAGS_NOT_MATCHED TAOS_DEF_ERROR_CODE(0, 0x260D)
|
||||
#define TSDB_CODE_PAR_INVALID_TAG_NAME TAOS_DEF_ERROR_CODE(0, 0x260E)
|
||||
#define TSDB_CODE_PAR_INCOMPLETE_SQL TAOS_DEF_ERROR_CODE(0, 0x260F)
|
||||
#define TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x2610)
|
||||
#define TSDB_CODE_PAR_PASSWD_EMPTY TAOS_DEF_ERROR_CODE(0, 0x2611)
|
||||
#define TSDB_CODE_PAR_INVALID_PORT TAOS_DEF_ERROR_CODE(0, 0x2612)
|
||||
|
@ -514,19 +514,9 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_PAR_DB_NOT_SPECIFIED TAOS_DEF_ERROR_CODE(0, 0x2616)
|
||||
#define TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME TAOS_DEF_ERROR_CODE(0, 0x2617)
|
||||
#define TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR TAOS_DEF_ERROR_CODE(0, 0x2618)
|
||||
#define TSDB_CODE_PAR_INVALID_RANGE_OPTION TAOS_DEF_ERROR_CODE(0, 0x2619)
|
||||
#define TSDB_CODE_PAR_INVALID_STR_OPTION TAOS_DEF_ERROR_CODE(0, 0x261A)
|
||||
#define TSDB_CODE_PAR_INVALID_ENUM_OPTION TAOS_DEF_ERROR_CODE(0, 0x261B)
|
||||
#define TSDB_CODE_PAR_INVALID_KEEP_NUM TAOS_DEF_ERROR_CODE(0, 0x261D)
|
||||
#define TSDB_CODE_PAR_INVALID_KEEP_ORDER TAOS_DEF_ERROR_CODE(0, 0x261E)
|
||||
#define TSDB_CODE_PAR_INVALID_KEEP_VALUE TAOS_DEF_ERROR_CODE(0, 0x261F)
|
||||
#define TSDB_CODE_PAR_INVALID_COMMENT_OPTION TAOS_DEF_ERROR_CODE(0, 0x2620)
|
||||
#define TSDB_CODE_PAR_INVALID_F_RANGE_OPTION TAOS_DEF_ERROR_CODE(0, 0x2621)
|
||||
#define TSDB_CODE_PAR_INVALID_ROLLUP_OPTION TAOS_DEF_ERROR_CODE(0, 0x2622)
|
||||
#define TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION TAOS_DEF_ERROR_CODE(0, 0x2623)
|
||||
#define TSDB_CODE_PAR_INVALID_DB_OPTION TAOS_DEF_ERROR_CODE(0, 0x2619)
|
||||
#define TSDB_CODE_PAR_INVALID_TABLE_OPTION TAOS_DEF_ERROR_CODE(0, 0x261A)
|
||||
#define TSDB_CODE_PAR_GROUPBY_WINDOW_COEXIST TAOS_DEF_ERROR_CODE(0, 0x2624)
|
||||
#define TSDB_CODE_PAR_INVALID_OPTION_UNIT TAOS_DEF_ERROR_CODE(0, 0x2625)
|
||||
#define TSDB_CODE_PAR_INVALID_KEEP_UNIT TAOS_DEF_ERROR_CODE(0, 0x2626)
|
||||
#define TSDB_CODE_PAR_AGG_FUNC_NESTING TAOS_DEF_ERROR_CODE(0, 0x2627)
|
||||
#define TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE TAOS_DEF_ERROR_CODE(0, 0x2628)
|
||||
#define TSDB_CODE_PAR_INVALID_STATE_WIN_COL TAOS_DEF_ERROR_CODE(0, 0x2629)
|
||||
|
@ -580,7 +570,6 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x2659)
|
||||
#define TSDB_CODE_PAR_STREAM_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x265A)
|
||||
#define TSDB_CODE_PAR_GROUP_BY_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x265B)
|
||||
#define TSDB_CODE_PAR_INVALID_TABLE_OPTION TAOS_DEF_ERROR_CODE(0, 0x265C)
|
||||
#define TSDB_CODE_PAR_INVALID_INTERP_CLAUSE TAOS_DEF_ERROR_CODE(0, 0x265D)
|
||||
#define TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN TAOS_DEF_ERROR_CODE(0, 0x265E)
|
||||
#define TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE TAOS_DEF_ERROR_CODE(0, 0x265F)
|
||||
|
|
|
@ -87,6 +87,14 @@ void taosArrayRemoveBatch(SArray* pArray, const int32_t* pData, int32_t numOfEle
|
|||
*/
|
||||
void taosArrayRemoveDuplicate(SArray* pArray, __compar_fn_t comparFn, void (*fp)(void*));
|
||||
|
||||
/**
|
||||
*
|
||||
* @param pArray
|
||||
* @param comparFn
|
||||
* @param fp
|
||||
*/
|
||||
void taosArrayRemoveDuplicateP(SArray* pArray, __compar_fn_t comparFn, void (*fp)(void*));
|
||||
|
||||
/**
|
||||
* add all element from the source array list into the destination
|
||||
* @param pArray
|
||||
|
|
|
@ -421,7 +421,7 @@ typedef enum ELogicConditionType {
|
|||
#define TSDB_DEFAULT_STABLES_HASH_SIZE 100
|
||||
#define TSDB_DEFAULT_CTABLES_HASH_SIZE 20000
|
||||
|
||||
#define TSDB_MAX_WAL_SIZE (1024 * 1024 * 3)
|
||||
#define TSDB_MAX_MSG_SIZE (1024 * 1024 * 10)
|
||||
|
||||
#define TSDB_ARB_DUMMY_TIME 4765104000000 // 2121-01-01 00:00:00.000, :P
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@ void taosIp2String(uint32_t ip, char *str);
|
|||
void taosIpPort2String(uint32_t ip, uint16_t port, char *str);
|
||||
|
||||
void *tmemmem(const char *haystack, int hlen, const char *needle, int nlen);
|
||||
char *strDupUnquo(const char *src);
|
||||
|
||||
static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *target) {
|
||||
T_MD5_CTX context;
|
||||
|
|
|
@ -38,4 +38,4 @@ fi
|
|||
|
||||
# there can not libtaos.so*, otherwise ln -s error
|
||||
${csudo}rm -f ${install_main_dir}/driver/libtaos.* || :
|
||||
${csudo}rm -f ${install_main_dir}/driver/libtaosws.* || :
|
||||
[ -f ${install_main_dir}/driver/libtaosws.so ] && ${csudo}rm -f ${install_main_dir}/driver/libtaosws.so || :
|
||||
|
|
|
@ -32,9 +32,9 @@ else
|
|||
${csudo}rm -f ${inc_link_dir}/taosdef.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taoserror.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taosudf.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taosws.h || :
|
||||
[ -f ${inc_link_dir}/taosws.h ] && ${csudo}rm -f ${inc_link_dir}/taosws.h || :
|
||||
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
|
||||
${csudo}rm -f ${lib_link_dir}/libtaosws.* || :
|
||||
[ -f ${lib_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.so || :
|
||||
|
||||
${csudo}rm -f ${log_link_dir} || :
|
||||
${csudo}rm -f ${data_link_dir} || :
|
||||
|
|
|
@ -68,12 +68,12 @@ fi
|
|||
|
||||
cp ${compile_dir}/build/bin/taos ${pkg_dir}${install_home_path}/bin
|
||||
cp ${compile_dir}/build/lib/${libfile} ${pkg_dir}${install_home_path}/driver
|
||||
cp ${compile_dir}/build/lib/${wslibfile} ${pkg_dir}${install_home_path}/driver ||:
|
||||
[ -f ${compile_dir}/build/lib/${wslibfile} ] && cp ${compile_dir}/build/lib/${wslibfile} ${pkg_dir}${install_home_path}/driver ||:
|
||||
cp ${compile_dir}/../include/client/taos.h ${pkg_dir}${install_home_path}/include
|
||||
cp ${compile_dir}/../include/common/taosdef.h ${pkg_dir}${install_home_path}/include
|
||||
cp ${compile_dir}/../include/util/taoserror.h ${pkg_dir}${install_home_path}/include
|
||||
cp ${compile_dir}/../include/libs/function/taosudf.h ${pkg_dir}${install_home_path}/include
|
||||
cp ${compile_dir}/../src/inc/taosws.h ${pkg_dir}${install_home_path}/include ||:
|
||||
[ -f ${compile_dir}/build/include/taosws.h ] && cp ${compile_dir}/build/include/taosws.h ${pkg_dir}${install_home_path}/include ||:
|
||||
cp -r ${top_dir}/examples/* ${pkg_dir}${install_home_path}/examples
|
||||
#cp -r ${top_dir}/src/connector/python ${pkg_dir}${install_home_path}/connector
|
||||
#cp -r ${top_dir}/src/connector/go ${pkg_dir}${install_home_path}/connector
|
||||
|
|
|
@ -75,12 +75,12 @@ if [ -f %{_compiledir}/build/bin/taosadapter ]; then
|
|||
cp %{_compiledir}/build/bin/taosadapter %{buildroot}%{homepath}/bin ||:
|
||||
fi
|
||||
cp %{_compiledir}/build/lib/${libfile} %{buildroot}%{homepath}/driver
|
||||
cp %{_compiledir}/build/lib/${wslibfile} %{buildroot}%{homepath}/driver ||:
|
||||
[ -f %{_compiledir}/build/lib/${wslibfile} ] && cp %{_compiledir}/build/lib/${wslibfile} %{buildroot}%{homepath}/driver ||:
|
||||
cp %{_compiledir}/../include/client/taos.h %{buildroot}%{homepath}/include
|
||||
cp %{_compiledir}/../include/common/taosdef.h %{buildroot}%{homepath}/include
|
||||
cp %{_compiledir}/../include/util/taoserror.h %{buildroot}%{homepath}/include
|
||||
cp %{_compiledir}/../include/libs/function/taosudf.h %{buildroot}%{homepath}/include
|
||||
cp %{_compiledir}/../src/inc/taosws.h %{buildroot}%{homepath}/include ||:
|
||||
[ -f %{_compiledir}/build/include/taosws.h ] && cp %{_compiledir}/build/include/taosws.h %{buildroot}%{homepath}/include ||:
|
||||
#cp -r %{_compiledir}/../src/connector/python %{buildroot}%{homepath}/connector
|
||||
#cp -r %{_compiledir}/../src/connector/go %{buildroot}%{homepath}/connector
|
||||
#cp -r %{_compiledir}/../src/connector/nodejs %{buildroot}%{homepath}/connector
|
||||
|
|
|
@ -229,13 +229,13 @@ function install_lib() {
|
|||
${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1
|
||||
${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
|
||||
|
||||
${csudo}ln -s ${lib_link_dir}/libtaosws.so ${lib_link_dir}/libtaosws.so || :
|
||||
[ -f ${install_main_dir}/driver/libtaosws.so ] && ${csudo}ln -sf ${install_main_dir}/driver/libtaosws.so ${lib_link_dir}/libtaosws.so || :
|
||||
|
||||
if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then
|
||||
${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || :
|
||||
${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || :
|
||||
|
||||
${csudo}ln -s ${lib64_link_dir}/libtaosws.so ${lib64_link_dir}/libtaosws.so || :
|
||||
[ -f ${install_main_dir}/libtaosws.so ] && ${csudo}ln -sf ${install_main_dir}/libtaosws.so ${lib64_link_dir}/libtaosws.so || :
|
||||
fi
|
||||
|
||||
${csudo}ldconfig
|
||||
|
@ -320,7 +320,7 @@ function install_jemalloc() {
|
|||
function install_header() {
|
||||
${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h ${inc_link_dir}/taosudf.h || :
|
||||
|
||||
${csudo}rm -f ${inc_link_dir}/taosws.h || :
|
||||
[ -f ${inc_link_dir}/taosws.h ] && ${csudo}rm -f ${inc_link_dir}/taosws.h || :
|
||||
|
||||
${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/*
|
||||
${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h
|
||||
|
@ -328,7 +328,7 @@ function install_header() {
|
|||
${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h
|
||||
${csudo}ln -s ${install_main_dir}/include/taosudf.h ${inc_link_dir}/taosudf.h
|
||||
|
||||
[ -f ${install_main_dir}/include/taosws.h ] && ${csudo}ln -s ${install_main_dir}/include/taosws.h ${inc_link_dir}/taosws.h || :
|
||||
[ -f ${install_main_dir}/include/taosws.h ] && ${csudo}ln -sf ${install_main_dir}/include/taosws.h ${inc_link_dir}/taosws.h || :
|
||||
}
|
||||
|
||||
function add_newHostname_to_hosts() {
|
||||
|
|
|
@ -116,6 +116,8 @@ function install_bin() {
|
|||
|
||||
function clean_lib() {
|
||||
sudo rm -f /usr/lib/libtaos.* || :
|
||||
[ -f /usr/lib/libtaosws.so ] && sudo rm -f /usr/lib/libtaosws.so || :
|
||||
[ -f /usr/lib64/libtaosws.so ] && sudo rm -f /usr/lib64/libtaosws.so || :
|
||||
sudo rm -rf ${lib_dir} || :
|
||||
}
|
||||
|
||||
|
@ -123,6 +125,10 @@ function install_lib() {
|
|||
# Remove links
|
||||
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
|
||||
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
|
||||
|
||||
[ -f ${lib_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.so || :
|
||||
[ -f ${lib64_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.so || :
|
||||
|
||||
#${csudo}rm -rf ${v15_java_app_dir} || :
|
||||
|
||||
${csudo}cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/*
|
||||
|
@ -131,13 +137,19 @@ function install_lib() {
|
|||
${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1
|
||||
${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
|
||||
|
||||
[ -f ${install_main_dir}/driver/libtaosws.so ] && ${csudo}ln -sf ${install_main_dir}/driver/libtaosws.so ${lib_link_dir}/libtaosws.so ||:
|
||||
|
||||
if [ -d "${lib64_link_dir}" ]; then
|
||||
${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || :
|
||||
${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || :
|
||||
|
||||
[ -f ${install_main_dir}/driver/libtaosws.so ] && ${csudo}ln -sf ${install_main_dir}/driver/libtaosws.so ${lib64_link_dir}/libtaosws.so || :
|
||||
fi
|
||||
else
|
||||
${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.1.dylib
|
||||
${csudo}ln -s ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib
|
||||
|
||||
[ -f ${install_main_dir}/driver/libtaosws.dylib ] && ${csudo}ln -sf ${install_main_dir}/driver/libtaosws.dylib ${lib_link_dir}/libtaosws.dylib ||:
|
||||
fi
|
||||
|
||||
if [ "$osType" != "Darwin" ]; then
|
||||
|
@ -154,6 +166,8 @@ function install_header() {
|
|||
${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h
|
||||
${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h
|
||||
${csudo}ln -s ${install_main_dir}/include/taosudf.h ${inc_link_dir}/taosudf.h
|
||||
|
||||
[ -f ${install_main_dir}/include/taosws.h ] && ${csudo}ln -sf ${install_main_dir}/include/taosws.h ${inc_link_dir}/taosws.h ||:
|
||||
}
|
||||
|
||||
function install_jemalloc() {
|
||||
|
|
|
@ -294,10 +294,10 @@ function install_avro() {
|
|||
function install_lib() {
|
||||
# Remove links
|
||||
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
|
||||
${csudo}rm -f ${lib_link_dir}/libtaosws.* || :
|
||||
[ -f ${lib_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.so || :
|
||||
if [ "$osType" != "Darwin" ]; then
|
||||
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
|
||||
${csudo}rm -f ${lib64_link_dir}/libtaosws.* || :
|
||||
[ -f ${lib64_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.so || :
|
||||
fi
|
||||
|
||||
if [ "$osType" != "Darwin" ]; then
|
||||
|
@ -362,13 +362,13 @@ function install_header() {
|
|||
|
||||
if [ "$osType" != "Darwin" ]; then
|
||||
${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h ${inc_link_dir}/taosudf.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taosws.h ||:
|
||||
[ -f ${inc_link_dir}/taosws.h ] && ${csudo}rm -f ${inc_link_dir}/taosws.h ||:
|
||||
${csudo}cp -f ${source_dir}/include/client/taos.h ${source_dir}/include/common/taosdef.h ${source_dir}/include/util/taoserror.h ${source_dir}/include/libs/function/taosudf.h \
|
||||
${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/*
|
||||
|
||||
if [ -f ${binary_dir}/build/include/taosws.h ]; then
|
||||
${csudo}cp -f ${binary_dir}/build/include/taosws.h ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/taosws.h ||:
|
||||
${csudo}ln -s ${install_main_dir}/include/taosws.h ${inc_link_dir}/taosws.h ||:
|
||||
${csudo}ln -sf ${install_main_dir}/include/taosws.h ${inc_link_dir}/taosws.h ||:
|
||||
fi
|
||||
|
||||
${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h
|
||||
|
|
|
@ -57,12 +57,16 @@ if [ "$osType" != "Darwin" ]; then
|
|||
${script_dir}/get_client.sh"
|
||||
fi
|
||||
lib_files="${build_dir}/lib/libtaos.so.${version}"
|
||||
wslib_files="${build_dir}/lib/libtaosws.so"
|
||||
else
|
||||
bin_files="${build_dir}/bin/${clientName} ${script_dir}/remove_client.sh"
|
||||
lib_files="${build_dir}/lib/libtaos.${version}.dylib"
|
||||
wslib_files="${build_dir}/lib/libtaosws.dylib"
|
||||
fi
|
||||
|
||||
header_files="${code_dir}/include/client/taos.h ${code_dir}/include/common/taosdef.h ${code_dir}/include/util/taoserror.h ${code_dir}/include/libs/function/taosudf.h"
|
||||
wsheader_files="${build_dir}/include/taosws.h"
|
||||
|
||||
if [ "$dbName" != "taos" ]; then
|
||||
cfg_dir="${top_dir}/../enterprise/packaging/cfg"
|
||||
else
|
||||
|
@ -74,6 +78,8 @@ install_files="${script_dir}/install_client.sh"
|
|||
# make directories.
|
||||
mkdir -p ${install_dir}
|
||||
mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc
|
||||
[ -f ${wsheader_files} ] && cp ${wsheader_files} ${install_dir}/inc
|
||||
|
||||
mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/${configFile} ${install_dir}/cfg/${configFile}
|
||||
mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/*
|
||||
|
||||
|
@ -187,6 +193,7 @@ cp ${lib_files} ${install_dir}/driver
|
|||
# Copy connector
|
||||
connector_dir="${code_dir}/connector"
|
||||
mkdir -p ${install_dir}/connector
|
||||
[ -f ${wslib_files} ] && cp ${wslib_files} ${install_dir}/driver
|
||||
|
||||
if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then
|
||||
if [ "$osType" != "Darwin" ]; then
|
||||
|
|
|
@ -93,10 +93,10 @@ else
|
|||
fi
|
||||
|
||||
lib_files="${build_dir}/lib/libtaos.so.${version}"
|
||||
wslib_files="${build_dir}/lib/libtaosws.so."
|
||||
wslib_files="${build_dir}/lib/libtaosws.so"
|
||||
header_files="${code_dir}/include/client/taos.h ${code_dir}/include/common/taosdef.h ${code_dir}/include/util/taoserror.h ${code_dir}/include/libs/function/taosudf.h"
|
||||
|
||||
wsheader_files="${code_dir}/inc/taosws.h"
|
||||
wsheader_files="${build_dir}/include/taosws.h"
|
||||
|
||||
if [ "$dbName" != "taos" ]; then
|
||||
cfg_dir="${top_dir}/../enterprise/packaging/cfg"
|
||||
|
@ -114,7 +114,7 @@ init_file_rpm=${script_dir}/../rpm/taosd
|
|||
mkdir -p ${install_dir}
|
||||
mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc
|
||||
|
||||
${wsheader_files} ${install_dir}/inc || :
|
||||
[ -f ${wsheader_files} ] && cp ${wsheader_files} ${install_dir}/inc || :
|
||||
|
||||
mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/${configFile} ${install_dir}/cfg/${configFile}
|
||||
|
||||
|
|
|
@ -82,22 +82,33 @@ function kill_taosd() {
|
|||
|
||||
function install_include() {
|
||||
${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h ${inc_link_dir}/taosudf.h || :
|
||||
[ -f ${inc_link_dir}/taosws.h ] && ${csudo}rm -f ${inc_link_dir}/taosws.h ||:
|
||||
|
||||
${csudo}ln -s ${inc_dir}/taos.h ${inc_link_dir}/taos.h
|
||||
${csudo}ln -s ${inc_dir}/taosdef.h ${inc_link_dir}/taosdef.h
|
||||
${csudo}ln -s ${inc_dir}/taoserror.h ${inc_link_dir}/taoserror.h
|
||||
${csudo}ln -s ${inc_dir}/taosudf.h ${inc_link_dir}/taosudf.h
|
||||
${csudo}ln -s ${inc_dir}/taosudf.h ${inc_link_dir}/taosudf.h
|
||||
|
||||
[ -f ${inc_dir}/taosws.h ] && ${csudo}ln -sf ${inc_dir}/taosws.h ${inc_link_dir}/taosws.h ||:
|
||||
}
|
||||
|
||||
function install_lib() {
|
||||
${csudo}rm -f ${lib_link_dir}/libtaos* || :
|
||||
${csudo}rm -f ${lib64_link_dir}/libtaos* || :
|
||||
|
||||
[ -f ${lib_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.so || :
|
||||
[ -f ${lib64_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.so || :
|
||||
|
||||
${csudo}ln -s ${lib_dir}/libtaos.* ${lib_link_dir}/libtaos.so.1
|
||||
${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
|
||||
|
||||
[ -f ${lib_dir}/libtaosws.so ] && ${csudo}ln -sf ${lib_dir}/libtaosws.so ${lib_link_dir}/libtaosws.so ||:
|
||||
|
||||
if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then
|
||||
${csudo}ln -s ${lib_dir}/libtaos.* ${lib64_link_dir}/libtaos.so.1 || :
|
||||
${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || :
|
||||
|
||||
[ -f ${lib_dir}/libtaosws.so ] && ${csudo}ln -sf ${lib_dir}/libtaosws.so ${lib64_link_dir}/libtaosws.so || :
|
||||
fi
|
||||
|
||||
${csudo}ldconfig
|
||||
|
|
|
@ -102,10 +102,10 @@ function clean_local_bin() {
|
|||
function clean_lib() {
|
||||
# Remove link
|
||||
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
|
||||
${csudo}rm -f ${lib_link_dir}/libtaosws.* || :
|
||||
[ -f ${lib_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.so || :
|
||||
|
||||
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
|
||||
${csudo}rm -f ${lib64_link_dir}/libtaosws.* || :
|
||||
[ -f ${lib64_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.so || :
|
||||
#${csudo}rm -rf ${v15_java_app_dir} || :
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ function clean_header() {
|
|||
${csudo}rm -f ${inc_link_dir}/taoserror.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taosudf.h || :
|
||||
|
||||
${csudo}rm -f ${inc_link_dir}/taosws.h || :
|
||||
[ -f ${inc_link_dir}/taosws.h ] && ${csudo}rm -f ${inc_link_dir}/taosws.h || :
|
||||
}
|
||||
|
||||
function clean_config() {
|
||||
|
|
|
@ -286,13 +286,10 @@ static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
|
|||
if (pInst == NULL || NULL == *pInst) {
|
||||
taosThreadMutexUnlock(&appInfo.mutex);
|
||||
tscError("cluster not exist, key:%s", key);
|
||||
taosMemoryFreeClear(param);
|
||||
tFreeClientHbBatchRsp(&pRsp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
taosMemoryFreeClear(param);
|
||||
|
||||
if (code != 0) {
|
||||
(*pInst)->onlineDnodes = ((*pInst)->totalDnodes ? 0 : -1);
|
||||
tscDebug("hb rsp error %s, update server status %d/%d", tstrerror(code), (*pInst)->onlineDnodes, (*pInst)->totalDnodes);
|
||||
|
@ -716,6 +713,7 @@ static void *hbThreadFunc(void *param) {
|
|||
pInfo->msgInfo.len = tlen;
|
||||
pInfo->msgType = TDMT_MND_HEARTBEAT;
|
||||
pInfo->param = strdup(pAppHbMgr->key);
|
||||
pInfo->paramFreeFp = taosMemoryFree;
|
||||
pInfo->requestId = generateRequestId();
|
||||
pInfo->requestObjRefId = 0;
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
|
||||
static int32_t initEpSetFromCfg(const char* firstEp, const char* secondEp, SCorEpSet* pEpSet);
|
||||
static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest);
|
||||
static void destroySendMsgInfo(SMsgSendInfo* pMsgBody);
|
||||
|
||||
static bool stringLengthCheck(const char* str, size_t maxsize) {
|
||||
if (str == NULL) {
|
||||
|
@ -1215,13 +1214,6 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) {
|
|||
return pMsgSendInfo;
|
||||
}
|
||||
|
||||
static void destroySendMsgInfo(SMsgSendInfo* pMsgBody) {
|
||||
assert(pMsgBody != NULL);
|
||||
taosMemoryFreeClear(pMsgBody->target.dbFName);
|
||||
taosMemoryFreeClear(pMsgBody->msgInfo.pData);
|
||||
taosMemoryFreeClear(pMsgBody);
|
||||
}
|
||||
|
||||
void updateTargetEpSet(SMsgSendInfo* pSendInfo, STscObj* pTscObj, SRpcMsg* pMsg, SEpSet* pEpSet) {
|
||||
if (NULL == pEpSet) {
|
||||
return;
|
||||
|
@ -2101,8 +2093,9 @@ TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly) {
|
|||
|
||||
taosAsyncQueryImpl(*(int64_t*)taos, sql, syncQueryFn, param, validateOnly);
|
||||
tsem_wait(¶m->sem);
|
||||
|
||||
param->pRequest->syncQuery = true;
|
||||
if (param->pRequest != NULL) {
|
||||
param->pRequest->syncQuery = true;
|
||||
}
|
||||
return param->pRequest;
|
||||
#else
|
||||
size_t sqlLen = strlen(sql);
|
||||
|
|
|
@ -255,6 +255,8 @@ int32_t processDropDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
catalogRemoveDB(pCatalog, dropdbRsp.db, dropdbRsp.uid);
|
||||
}
|
||||
|
||||
taosMemoryFree(pMsg->pData);
|
||||
|
||||
if (pRequest->body.queryFp != NULL) {
|
||||
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
||||
} else {
|
||||
|
@ -278,6 +280,8 @@ int32_t processAlterStbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
pRequest->body.resInfo.execRes.res = alterRsp.pMeta;
|
||||
}
|
||||
|
||||
taosMemoryFree(pMsg->pData);
|
||||
|
||||
if (pRequest->body.queryFp != NULL) {
|
||||
SExecResult* pRes = &pRequest->body.resInfo.execRes;
|
||||
|
||||
|
@ -387,6 +391,8 @@ int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
tFreeSShowVariablesRsp(&rsp);
|
||||
}
|
||||
|
||||
taosMemoryFree(pMsg->pData);
|
||||
|
||||
if (pRequest->body.queryFp != NULL) {
|
||||
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
||||
} else {
|
||||
|
|
|
@ -268,7 +268,7 @@ static int32_t smlGenerateSchemaAction(SSchema *colField, SHashObj *colHash, SSm
|
|||
*actionNeeded = true;
|
||||
}
|
||||
if (*actionNeeded) {
|
||||
uDebug("SML:0x%" PRIx64 " generate schema action. column name: %s, action: %d", info->id, colField->name,
|
||||
uDebug("SML:0x%" PRIx64 " generate schema action. kv->name: %s, action: %d", info->id, kv->key,
|
||||
action->action);
|
||||
}
|
||||
return 0;
|
||||
|
@ -436,6 +436,7 @@ static int32_t smlProcessSchemaAction(SSmlHandle *info, SSchema *schemaField, SH
|
|||
SSchemaAction *action, bool isTag) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
for (int j = 0; j < taosArrayGetSize(cols); ++j) {
|
||||
if(j == 0 && !isTag) continue;
|
||||
SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, j);
|
||||
bool actionNeeded = false;
|
||||
code = smlGenerateSchemaAction(schemaField, schemaHash, kv, isTag, action, &actionNeeded, info);
|
||||
|
@ -452,18 +453,25 @@ static int32_t smlProcessSchemaAction(SSmlHandle *info, SSchema *schemaField, SH
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t smlCheckMeta(SSchema *schema, int32_t length, SArray *cols) {
|
||||
static int32_t smlCheckMeta(SSchema *schema, int32_t length, SArray *cols, bool isTag) {
|
||||
SHashObj *hashTmp = taosHashInit(length, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
for (uint16_t i = 0; i < length; i++) {
|
||||
int32_t i = 0;
|
||||
for ( ;i < length; i++) {
|
||||
taosHashPut(hashTmp, schema[i].name, strlen(schema[i].name), &i, SHORT_BYTES);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < taosArrayGetSize(cols); i++) {
|
||||
if (isTag){
|
||||
i = 0;
|
||||
} else {
|
||||
i = 1;
|
||||
}
|
||||
for (; i < taosArrayGetSize(cols); i++) {
|
||||
SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i);
|
||||
if (taosHashGet(hashTmp, kv->key, kv->keyLen) == NULL) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
taosHashCleanup(hashTmp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -523,7 +531,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
}
|
||||
|
||||
taosHashClear(hashTmp);
|
||||
for (uint16_t i = 0; i < pTableMeta->tableInfo.numOfColumns; i++) {
|
||||
for (uint16_t i = 1; i < pTableMeta->tableInfo.numOfColumns; i++) {
|
||||
taosHashPut(hashTmp, pTableMeta->schema[i].name, strlen(pTableMeta->schema[i].name), &i, SHORT_BYTES);
|
||||
}
|
||||
code = smlProcessSchemaAction(info, pTableMeta->schema, hashTmp, sTableData->cols, &schemaAction, false);
|
||||
|
@ -551,12 +559,12 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
|
||||
if (needCheckMeta) {
|
||||
code = smlCheckMeta(&(pTableMeta->schema[pTableMeta->tableInfo.numOfColumns]), pTableMeta->tableInfo.numOfTags,
|
||||
sTableData->tags);
|
||||
sTableData->tags, true);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " check tag failed. super table name %s", info->id, (char *)superTable);
|
||||
goto end;
|
||||
}
|
||||
code = smlCheckMeta(&(pTableMeta->schema[0]), pTableMeta->tableInfo.numOfColumns, sTableData->cols);
|
||||
code = smlCheckMeta(&(pTableMeta->schema[0]), pTableMeta->tableInfo.numOfColumns, sTableData->cols, false);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " check cols failed. super table name %s", info->id, (char *)superTable);
|
||||
goto end;
|
||||
|
@ -832,6 +840,7 @@ static int64_t smlParseOpenTsdbTime(SSmlHandle *info, const char *data, int32_t
|
|||
static int32_t smlParseTS(SSmlHandle *info, const char *data, int32_t len, SArray *cols) {
|
||||
int64_t ts = 0;
|
||||
if (info->protocol == TSDB_SML_LINE_PROTOCOL) {
|
||||
// uError("SML:data:%s,len:%d", data, len);
|
||||
ts = smlParseInfluxTime(info, data, len);
|
||||
} else if (info->protocol == TSDB_SML_TELNET_PROTOCOL) {
|
||||
ts = smlParseOpenTsdbTime(info, data, len);
|
||||
|
@ -1208,6 +1217,9 @@ static int32_t smlParseCols(const char *data, int32_t len, SArray *cols, char *c
|
|||
kv->value = value;
|
||||
kv->length = valueLen;
|
||||
if (isTag) {
|
||||
if(valueLen > (TSDB_MAX_NCHAR_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE){
|
||||
return TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN;
|
||||
}
|
||||
kv->type = TSDB_DATA_TYPE_NCHAR;
|
||||
} else {
|
||||
int32_t ret = smlParseValue(kv, msg);
|
||||
|
@ -2031,6 +2043,8 @@ static int32_t smlParseJSONString(SSmlHandle *info, cJSON *root, SSmlTableInfo *
|
|||
|
||||
static int32_t smlParseInfluxLine(SSmlHandle *info, const char *sql) {
|
||||
SSmlLineInfo elements = {0};
|
||||
uDebug("SML:0x%" PRIx64 " smlParseInfluxLine sql:%s, hello", info->id, sql);
|
||||
|
||||
int ret = smlParseInfluxString(sql, &elements, &info->msgBuf);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlParseInfluxLine failed", info->id);
|
||||
|
@ -2196,7 +2210,7 @@ static int32_t smlParseTelnetLine(SSmlHandle *info, void *data) {
|
|||
(SSmlSTableMeta **)taosHashGet(info->superTables, (*oneTable)->sTableName, (*oneTable)->sTableNameLen);
|
||||
if (tableMeta) { // update meta
|
||||
ret = smlUpdateMeta((*tableMeta)->colHash, (*tableMeta)->cols, cols, &info->msgBuf);
|
||||
if (!hasTable && ret) {
|
||||
if (!hasTable && ret == TSDB_CODE_SUCCESS) {
|
||||
ret = smlUpdateMeta((*tableMeta)->tagHash, (*tableMeta)->tags, (*oneTable)->tags, &info->msgBuf);
|
||||
}
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
|
|
|
@ -113,12 +113,6 @@ struct tmq_t {
|
|||
tsem_t rspSem;
|
||||
};
|
||||
|
||||
struct tmq_raw_data {
|
||||
void* raw_meta;
|
||||
int32_t raw_meta_len;
|
||||
int16_t raw_meta_type;
|
||||
};
|
||||
|
||||
enum {
|
||||
TMQ_VG_STATUS__IDLE = 0,
|
||||
TMQ_VG_STATUS__WAIT,
|
||||
|
@ -510,6 +504,7 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT
|
|||
pMsgSendInfo->requestId = generateRequestId();
|
||||
pMsgSendInfo->requestObjRefId = 0;
|
||||
pMsgSendInfo->param = pParam;
|
||||
pMsgSendInfo->paramFreeFp = taosMemoryFree;
|
||||
pMsgSendInfo->fp = tmqCommitCb2;
|
||||
pMsgSendInfo->msgType = TDMT_VND_MQ_COMMIT_OFFSET;
|
||||
// send msg
|
||||
|
@ -1918,16 +1913,15 @@ const char* tmq_get_table_name(TAOS_RES* res) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
tmq_raw_data* tmq_get_raw_meta(TAOS_RES* res) {
|
||||
if (TD_RES_TMQ_META(res)) {
|
||||
tmq_raw_data* raw = taosMemoryCalloc(1, sizeof(tmq_raw_data));
|
||||
int32_t tmq_get_raw_meta(TAOS_RES* res, tmq_raw_data *raw) {
|
||||
if (TD_RES_TMQ_META(res) && raw) {
|
||||
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res;
|
||||
raw->raw_meta = pMetaRspObj->metaRsp.metaRsp;
|
||||
raw->raw_meta_len = pMetaRspObj->metaRsp.metaRspLen;
|
||||
raw->raw_meta_type = pMetaRspObj->metaRsp.resMsgType;
|
||||
return raw;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
return NULL;
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
static char* buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* schemaTag, char* name, int64_t id,
|
||||
|
@ -2199,17 +2193,19 @@ static char* buildCreateCTableJson(STag* pTag, char* sname, char* name, SArray*
|
|||
cJSON* ttype = cJSON_CreateNumber(pTagVal->type);
|
||||
cJSON_AddItemToObject(tag, "type", ttype);
|
||||
|
||||
char* buf = NULL;
|
||||
cJSON* tvalue = NULL;
|
||||
if (IS_VAR_DATA_TYPE(pTagVal->type)) {
|
||||
buf = taosMemoryCalloc(pTagVal->nData + 1, 1);
|
||||
char* buf = taosMemoryCalloc(pTagVal->nData + 3, 1);
|
||||
if(!buf) goto end;
|
||||
dataConverToStr(buf, pTagVal->type, pTagVal->pData, pTagVal->nData, NULL);
|
||||
tvalue = cJSON_CreateString(buf);
|
||||
taosMemoryFree(buf);
|
||||
} else {
|
||||
buf = taosMemoryCalloc(32, 1);
|
||||
dataConverToStr(buf, pTagVal->type, &pTagVal->i64, tDataTypes[pTagVal->type].bytes, NULL);
|
||||
double val = 0;
|
||||
GET_TYPED_DATA(val, double, pTagVal->type, &pTagVal->i64);
|
||||
tvalue = cJSON_CreateNumber(val);
|
||||
}
|
||||
|
||||
cJSON* tvalue = cJSON_CreateString(buf);
|
||||
taosMemoryFree(buf);
|
||||
cJSON_AddItemToObject(tag, "value", tvalue);
|
||||
cJSON_AddItemToArray(tags, tag);
|
||||
}
|
||||
|
@ -2935,23 +2931,23 @@ end:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t taos_write_raw_meta(TAOS* taos, tmq_raw_data* raw_meta) {
|
||||
if (!taos || !raw_meta) {
|
||||
int32_t taos_write_raw_meta(TAOS *taos, tmq_raw_data raw_meta){
|
||||
if (!taos) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
if (raw_meta->raw_meta_type == TDMT_VND_CREATE_STB) {
|
||||
return taosCreateStb(taos, raw_meta->raw_meta, raw_meta->raw_meta_len);
|
||||
} else if (raw_meta->raw_meta_type == TDMT_VND_ALTER_STB) {
|
||||
return taosCreateStb(taos, raw_meta->raw_meta, raw_meta->raw_meta_len);
|
||||
} else if (raw_meta->raw_meta_type == TDMT_VND_DROP_STB) {
|
||||
return taosDropStb(taos, raw_meta->raw_meta, raw_meta->raw_meta_len);
|
||||
} else if (raw_meta->raw_meta_type == TDMT_VND_CREATE_TABLE) {
|
||||
return taosCreateTable(taos, raw_meta->raw_meta, raw_meta->raw_meta_len);
|
||||
} else if (raw_meta->raw_meta_type == TDMT_VND_ALTER_TABLE) {
|
||||
return taosAlterTable(taos, raw_meta->raw_meta, raw_meta->raw_meta_len);
|
||||
} else if (raw_meta->raw_meta_type == TDMT_VND_DROP_TABLE) {
|
||||
return taosDropTable(taos, raw_meta->raw_meta, raw_meta->raw_meta_len);
|
||||
if(raw_meta.raw_meta_type == TDMT_VND_CREATE_STB) {
|
||||
return taosCreateStb(taos, raw_meta.raw_meta, raw_meta.raw_meta_len);
|
||||
}else if(raw_meta.raw_meta_type == TDMT_VND_ALTER_STB){
|
||||
return taosCreateStb(taos, raw_meta.raw_meta, raw_meta.raw_meta_len);
|
||||
}else if(raw_meta.raw_meta_type == TDMT_VND_DROP_STB){
|
||||
return taosDropStb(taos, raw_meta.raw_meta, raw_meta.raw_meta_len);
|
||||
}else if(raw_meta.raw_meta_type == TDMT_VND_CREATE_TABLE){
|
||||
return taosCreateTable(taos, raw_meta.raw_meta, raw_meta.raw_meta_len);
|
||||
}else if(raw_meta.raw_meta_type == TDMT_VND_ALTER_TABLE){
|
||||
return taosAlterTable(taos, raw_meta.raw_meta, raw_meta.raw_meta_len);
|
||||
}else if(raw_meta.raw_meta_type == TDMT_VND_DROP_TABLE){
|
||||
return taosDropTable(taos, raw_meta.raw_meta, raw_meta.raw_meta_len);
|
||||
}
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -40,11 +40,11 @@ bool tsPrintAuth = false;
|
|||
|
||||
// multi process
|
||||
int32_t tsMultiProcess = 0;
|
||||
int32_t tsMnodeShmSize = TSDB_MAX_WAL_SIZE * 2 + 1024;
|
||||
int32_t tsVnodeShmSize = TSDB_MAX_WAL_SIZE * 10 + 1024;
|
||||
int32_t tsQnodeShmSize = TSDB_MAX_WAL_SIZE * 4 + 1024;
|
||||
int32_t tsSnodeShmSize = TSDB_MAX_WAL_SIZE * 4 + 1024;
|
||||
int32_t tsBnodeShmSize = TSDB_MAX_WAL_SIZE * 4 + 1024;
|
||||
int32_t tsMnodeShmSize = TSDB_MAX_MSG_SIZE * 2 + 1024;
|
||||
int32_t tsVnodeShmSize = TSDB_MAX_MSG_SIZE * 10 + 1024;
|
||||
int32_t tsQnodeShmSize = TSDB_MAX_MSG_SIZE * 4 + 1024;
|
||||
int32_t tsSnodeShmSize = TSDB_MAX_MSG_SIZE * 4 + 1024;
|
||||
int32_t tsBnodeShmSize = TSDB_MAX_MSG_SIZE * 4 + 1024;
|
||||
int32_t tsNumOfShmThreads = 1;
|
||||
|
||||
// queue & threads
|
||||
|
@ -387,11 +387,11 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
if (cfgAddBool(pCfg, "deadLockKillQuery", tsDeadLockKillQuery, 0) != 0) return -1;
|
||||
|
||||
if (cfgAddInt32(pCfg, "multiProcess", tsMultiProcess, 0, 2, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "mnodeShmSize", tsMnodeShmSize, TSDB_MAX_WAL_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "vnodeShmSize", tsVnodeShmSize, TSDB_MAX_WAL_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "qnodeShmSize", tsQnodeShmSize, TSDB_MAX_WAL_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "snodeShmSize", tsSnodeShmSize, TSDB_MAX_WAL_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "bnodeShmSize", tsBnodeShmSize, TSDB_MAX_WAL_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "mnodeShmSize", tsMnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "vnodeShmSize", tsVnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "qnodeShmSize", tsQnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "snodeShmSize", tsSnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "bnodeShmSize", tsBnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "mumOfShmThreads", tsNumOfShmThreads, 1, 1024, 0) != 0) return -1;
|
||||
|
||||
tsNumOfRpcThreads = tsNumOfCores / 2;
|
||||
|
@ -447,8 +447,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
if (cfgAddInt32(pCfg, "numOfSnodeUniqueThreads", tsNumOfSnodeUniqueThreads, 1, 1024, 0) != 0) return -1;
|
||||
|
||||
tsRpcQueueMemoryAllowed = tsTotalMemoryKB * 1024 * 0.1;
|
||||
tsRpcQueueMemoryAllowed = TRANGE(tsRpcQueueMemoryAllowed, TSDB_MAX_WAL_SIZE * 10L, TSDB_MAX_WAL_SIZE * 10000L);
|
||||
if (cfgAddInt64(pCfg, "rpcQueueMemoryAllowed", tsRpcQueueMemoryAllowed, TSDB_MAX_WAL_SIZE * 10L, INT64_MAX, 0) != 0)
|
||||
tsRpcQueueMemoryAllowed = TRANGE(tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10L, TSDB_MAX_MSG_SIZE * 10000L);
|
||||
if (cfgAddInt64(pCfg, "rpcQueueMemoryAllowed", tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10L, INT64_MAX, 0) != 0)
|
||||
return -1;
|
||||
|
||||
if (cfgAddBool(pCfg, "monitor", tsEnableMonitor, 0) != 0) return -1;
|
||||
|
@ -556,7 +556,7 @@ static void taosSetSystemCfg(SConfig *pCfg) {
|
|||
osSetSystemLocale(locale, charset);
|
||||
|
||||
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
|
||||
taosSetConsoleEcho(enableCore);
|
||||
taosSetCoreDump(enableCore);
|
||||
|
||||
// todo
|
||||
tsVersion = 30000000;
|
||||
|
@ -675,7 +675,7 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
|
|||
case 'e': {
|
||||
if (strcasecmp("enableCoreFile", name) == 0) {
|
||||
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
|
||||
taosSetConsoleEcho(enableCore);
|
||||
taosSetCoreDump(enableCore);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -2933,6 +2933,13 @@ int32_t tSerializeSTableIndexRsp(void *buf, int32_t bufLen, const STableIndexRsp
|
|||
return tlen;
|
||||
}
|
||||
|
||||
void tFreeSerializeSTableIndexRsp(STableIndexRsp *pRsp) {
|
||||
if (pRsp->pIndex != NULL) {
|
||||
taosArrayDestroy(pRsp->pIndex);
|
||||
pRsp->pIndex = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t tDeserializeSTableIndexInfo(SDecoder *pDecoder, STableIndexInfo *pInfo) {
|
||||
if (tDecodeI8(pDecoder, &pInfo->intervalUnit) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pInfo->slidingUnit) < 0) return -1;
|
||||
|
@ -5342,6 +5349,7 @@ int32_t tEncodeSVAlterTbReq(SEncoder *pEncoder, const SVAlterTbReq *pReq) {
|
|||
|
||||
if (tEncodeCStr(pEncoder, pReq->tbName) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pReq->action) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pReq->colId) < 0) return -1;
|
||||
switch (pReq->action) {
|
||||
case TSDB_ALTER_TABLE_ADD_COLUMN:
|
||||
if (tEncodeCStr(pEncoder, pReq->colName) < 0) return -1;
|
||||
|
@ -5392,6 +5400,7 @@ int32_t tDecodeSVAlterTbReq(SDecoder *pDecoder, SVAlterTbReq *pReq) {
|
|||
|
||||
if (tDecodeCStr(pDecoder, &pReq->tbName) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pReq->action) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pReq->colId) < 0) return -1;
|
||||
switch (pReq->action) {
|
||||
case TSDB_ALTER_TABLE_ADD_COLUMN:
|
||||
if (tDecodeCStr(pDecoder, &pReq->colName) < 0) return -1;
|
||||
|
|
|
@ -700,6 +700,8 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
|
|||
numOfMonth *= 12;
|
||||
}
|
||||
|
||||
int64_t fraction = t % TSDB_TICK_PER_SECOND(precision);
|
||||
|
||||
struct tm tm;
|
||||
time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision));
|
||||
taosLocalTime(&tt, &tm);
|
||||
|
@ -707,35 +709,9 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
|
|||
tm.tm_year = mon / 12;
|
||||
tm.tm_mon = mon % 12;
|
||||
|
||||
return (int64_t)(taosMktime(&tm) * TSDB_TICK_PER_SECOND(precision));
|
||||
return (int64_t)(taosMktime(&tm) * TSDB_TICK_PER_SECOND(precision) + fraction);
|
||||
}
|
||||
|
||||
int64_t taosTimeSub(int64_t t, int64_t duration, char unit, int32_t precision) {
|
||||
if (duration == 0) {
|
||||
return t;
|
||||
}
|
||||
|
||||
if (unit != 'n' && unit != 'y') {
|
||||
return t - duration;
|
||||
}
|
||||
|
||||
// The following code handles the y/n time duration
|
||||
int64_t numOfMonth = duration;
|
||||
if (unit == 'y') {
|
||||
numOfMonth *= 12;
|
||||
}
|
||||
|
||||
struct tm tm;
|
||||
time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision));
|
||||
taosLocalTime(&tt, &tm);
|
||||
int32_t mon = tm.tm_year * 12 + tm.tm_mon - (int32_t)numOfMonth;
|
||||
tm.tm_year = mon / 12;
|
||||
tm.tm_mon = mon % 12;
|
||||
|
||||
return (int64_t)(taosMktime(&tm) * TSDB_TICK_PER_SECOND(precision));
|
||||
}
|
||||
|
||||
|
||||
int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char unit, int32_t precision) {
|
||||
if (ekey < skey) {
|
||||
int64_t tmp = ekey;
|
||||
|
@ -844,11 +820,14 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
|
|||
} else {
|
||||
// try to move current window to the left-hande-side, due to the offset effect.
|
||||
int64_t end = taosTimeAdd(start, pInterval->interval, pInterval->intervalUnit, precision) - 1;
|
||||
ASSERT(end >= t);
|
||||
end = taosTimeAdd(end, -pInterval->sliding, pInterval->slidingUnit, precision);
|
||||
if (end >= t) {
|
||||
start = taosTimeAdd(start, -pInterval->sliding, pInterval->slidingUnit, precision);
|
||||
|
||||
int64_t newEnd = end;
|
||||
while(newEnd >= t) {
|
||||
end = newEnd;
|
||||
newEnd = taosTimeAdd(newEnd, -pInterval->sliding, pInterval->slidingUnit, precision);
|
||||
}
|
||||
|
||||
start = taosTimeAdd(end, -pInterval->interval, pInterval->intervalUnit, precision) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,9 +49,9 @@ static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
|
|||
dmUpdateEps(pMgmt->pData, statusRsp.pDnodeEps);
|
||||
}
|
||||
}
|
||||
rpcFreeCont(pRsp->pCont);
|
||||
tFreeSStatusRsp(&statusRsp);
|
||||
}
|
||||
rpcFreeCont(pRsp->pCont);
|
||||
}
|
||||
|
||||
void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||
|
|
|
@ -35,6 +35,46 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
MND_OPER_CONNECT = 1,
|
||||
MND_OPER_CREATE_ACCT,
|
||||
MND_OPER_DROP_ACCT,
|
||||
MND_OPER_ALTER_ACCT,
|
||||
MND_OPER_CREATE_USER,
|
||||
MND_OPER_DROP_USER,
|
||||
MND_OPER_ALTER_USER,
|
||||
MND_OPER_CREATE_BNODE,
|
||||
MND_OPER_DROP_BNODE,
|
||||
MND_OPER_CREATE_DNODE,
|
||||
MND_OPER_DROP_DNODE,
|
||||
MND_OPER_CONFIG_DNODE,
|
||||
MND_OPER_CREATE_MNODE,
|
||||
MND_OPER_DROP_MNODE,
|
||||
MND_OPER_CREATE_QNODE,
|
||||
MND_OPER_DROP_QNODE,
|
||||
MND_OPER_CREATE_SNODE,
|
||||
MND_OPER_DROP_SNODE,
|
||||
MND_OPER_REDISTRIBUTE_VGROUP,
|
||||
MND_OPER_MERGE_VGROUP,
|
||||
MND_OPER_SPLIT_VGROUP,
|
||||
MND_OPER_BALANCE_VGROUP,
|
||||
MND_OPER_CREATE_FUNC,
|
||||
MND_OPER_DROP_FUNC,
|
||||
MND_OPER_KILL_TRANS,
|
||||
MND_OPER_KILL_CONN,
|
||||
MND_OPER_KILL_QUERY,
|
||||
MND_OPER_CREATE_DB,
|
||||
MND_OPER_ALTER_DB,
|
||||
MND_OPER_DROP_DB,
|
||||
MND_OPER_COMPACT_DB,
|
||||
MND_OPER_TRIM_DB,
|
||||
MND_OPER_USE_DB,
|
||||
MND_OPER_WRITE_DB,
|
||||
MND_OPER_READ_DB,
|
||||
MND_OPER_READ_OR_WRITE_DB,
|
||||
MND_OPER_SHOW_VARIBALES,
|
||||
} EOperType;
|
||||
|
||||
typedef enum {
|
||||
MND_AUTH_ACCT_START = 0,
|
||||
MND_AUTH_ACCT_USER,
|
||||
|
@ -109,9 +149,9 @@ typedef struct {
|
|||
ETrnPolicy policy;
|
||||
ETrnConflct conflict;
|
||||
ETrnExec exec;
|
||||
EOperType oper;
|
||||
int32_t code;
|
||||
int32_t failedTimes;
|
||||
SRpcHandleInfo rpcInfo;
|
||||
void* rpcRsp;
|
||||
int32_t rpcRspLen;
|
||||
int32_t redoActionPos;
|
||||
|
@ -130,6 +170,7 @@ typedef struct {
|
|||
int32_t stopFunc;
|
||||
int32_t paramLen;
|
||||
void* param;
|
||||
SArray* pRpcArray;
|
||||
} STrans;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -22,46 +22,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
MND_OPER_CONNECT = 1,
|
||||
MND_OPER_CREATE_ACCT,
|
||||
MND_OPER_DROP_ACCT,
|
||||
MND_OPER_ALTER_ACCT,
|
||||
MND_OPER_CREATE_USER,
|
||||
MND_OPER_DROP_USER,
|
||||
MND_OPER_ALTER_USER,
|
||||
MND_OPER_CREATE_BNODE,
|
||||
MND_OPER_DROP_BNODE,
|
||||
MND_OPER_CREATE_DNODE,
|
||||
MND_OPER_DROP_DNODE,
|
||||
MND_OPER_CONFIG_DNODE,
|
||||
MND_OPER_CREATE_MNODE,
|
||||
MND_OPER_DROP_MNODE,
|
||||
MND_OPER_CREATE_QNODE,
|
||||
MND_OPER_DROP_QNODE,
|
||||
MND_OPER_CREATE_SNODE,
|
||||
MND_OPER_DROP_SNODE,
|
||||
MND_OPER_REDISTRIBUTE_VGROUP,
|
||||
MND_OPER_MERGE_VGROUP,
|
||||
MND_OPER_SPLIT_VGROUP,
|
||||
MND_OPER_BALANCE_VGROUP,
|
||||
MND_OPER_CREATE_FUNC,
|
||||
MND_OPER_DROP_FUNC,
|
||||
MND_OPER_KILL_TRANS,
|
||||
MND_OPER_KILL_CONN,
|
||||
MND_OPER_KILL_QUERY,
|
||||
MND_OPER_CREATE_DB,
|
||||
MND_OPER_ALTER_DB,
|
||||
MND_OPER_DROP_DB,
|
||||
MND_OPER_COMPACT_DB,
|
||||
MND_OPER_TRIM_DB,
|
||||
MND_OPER_USE_DB,
|
||||
MND_OPER_WRITE_DB,
|
||||
MND_OPER_READ_DB,
|
||||
MND_OPER_READ_OR_WRITE_DB,
|
||||
MND_OPER_SHOW_VARIBALES,
|
||||
} EOperType;
|
||||
|
||||
int32_t mndInitPrivilege(SMnode *pMnode);
|
||||
void mndCleanupPrivilege(SMnode *pMnode);
|
||||
|
||||
|
|
|
@ -73,12 +73,14 @@ void mndTransSetRpcRsp(STrans *pTrans, void *pCont, int32_t contLen);
|
|||
void mndTransSetCb(STrans *pTrans, ETrnFunc startFunc, ETrnFunc stopFunc, void *param, int32_t paramLen);
|
||||
void mndTransSetDbName(STrans *pTrans, const char *dbname1, const char *dbname2);
|
||||
void mndTransSetSerial(STrans *pTrans);
|
||||
void mndTransSetOper(STrans *pTrans, EOperType oper);
|
||||
|
||||
int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans);
|
||||
int32_t mndTransProcessRsp(SRpcMsg *pRsp);
|
||||
void mndTransPullup(SMnode *pMnode);
|
||||
int32_t mndKillTrans(SMnode *pMnode, STrans *pTrans);
|
||||
void mndTransExecute(SMnode *pMnode, STrans *pTrans);
|
||||
int32_t mndSetRpcInfoForDbTrans(SMnode *pMnode, SRpcMsg *pMsg, EOperType oper, const char *dbname);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -265,6 +265,10 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) {
|
|||
int64_t consumerId = be64toh(pReq->consumerId);
|
||||
|
||||
SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, consumerId);
|
||||
if (pConsumer == NULL) {
|
||||
terrno = TSDB_CODE_MND_CONSUMER_NOT_EXIST;
|
||||
return -1;
|
||||
}
|
||||
|
||||
atomic_store_32(&pConsumer->hbStatus, 0);
|
||||
|
||||
|
@ -452,7 +456,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
|||
int32_t code = -1;
|
||||
SArray *newSub = subscribe.topicNames;
|
||||
taosArraySortString(newSub, taosArrayCompareString);
|
||||
taosArrayRemoveDuplicate(newSub, taosArrayCompareString, taosMemoryFree);
|
||||
taosArrayRemoveDuplicateP(newSub, taosArrayCompareString, taosMemoryFree);
|
||||
|
||||
int32_t newTopicNum = taosArrayGetSize(newSub);
|
||||
// check topic existance
|
||||
|
|
|
@ -487,6 +487,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
|
|||
mDebug("trans:%d, used to create db:%s", pTrans->id, pCreate->db);
|
||||
|
||||
mndTransSetDbName(pTrans, dbObj.name, NULL);
|
||||
mndTransSetOper(pTrans, MND_OPER_CREATE_DB);
|
||||
if (mndSetCreateDbRedoLogs(pMnode, pTrans, &dbObj, pVgroups) != 0) goto _OVER;
|
||||
if (mndSetCreateDbUndoLogs(pMnode, pTrans, &dbObj, pVgroups) != 0) goto _OVER;
|
||||
if (mndSetCreateDbCommitLogs(pMnode, pTrans, &dbObj, pVgroups) != 0) goto _OVER;
|
||||
|
@ -534,6 +535,14 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
|
|||
terrno = TSDB_CODE_MND_DB_ALREADY_EXIST;
|
||||
goto _OVER;
|
||||
}
|
||||
} else if (terrno == TSDB_CODE_SDB_OBJ_CREATING) {
|
||||
if (mndSetRpcInfoForDbTrans(pMnode, pReq, MND_OPER_CREATE_DB, createReq.db) == 0) {
|
||||
mDebug("db:%s, is creating and response after trans finished", createReq.db);
|
||||
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
goto _OVER;
|
||||
} else {
|
||||
goto _OVER;
|
||||
}
|
||||
} else if (terrno != TSDB_CODE_MND_DB_NOT_EXIST) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
|
|
@ -383,6 +383,11 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) {
|
|||
// exec
|
||||
pInnerTask->execType = TASK_EXEC__PIPE;
|
||||
|
||||
SDbObj* pSourceDb = mndAcquireDb(pMnode, pStream->sourceDb);
|
||||
ASSERT(pDbObj != NULL);
|
||||
sdbRelease(pSdb, pSourceDb);
|
||||
pInnerTask->numOfVgroups = pSourceDb->cfg.numOfVgroups;
|
||||
|
||||
if (tsSchedStreamToSnode) {
|
||||
SSnodeObj* pSnode = mndSchedFetchOneSnode(pMnode);
|
||||
if (pSnode == NULL) {
|
||||
|
|
|
@ -1153,6 +1153,7 @@ _OVER:
|
|||
mError("failed to get table index %s since %s", indexReq.tbFName, terrstr());
|
||||
}
|
||||
|
||||
tFreeSerializeSTableIndexRsp(&rsp);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,10 @@ void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbM
|
|||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||
SSdbRaw *pRaw = pMsg->pCont;
|
||||
|
||||
// delete msg handle
|
||||
SRpcMsg rpcMsg = {0};
|
||||
syncGetAndDelRespRpc(pMnode->syncMgmt.sync, cbMeta.seqNum, &rpcMsg.info);
|
||||
|
||||
int32_t transId = sdbGetIdFromRaw(pMnode->pSdb, pRaw);
|
||||
pMgmt->errCode = cbMeta.code;
|
||||
mDebug("trans:%d, is proposed, saved:%d code:0x%x, apply index:%" PRId64 " term:%" PRIu64 " config:%" PRId64
|
||||
|
@ -144,9 +148,11 @@ int32_t mndSnapshotStartWrite(struct SSyncFSM *pFsm, void *pParam, void **ppWrit
|
|||
}
|
||||
|
||||
int32_t mndSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply, SSnapshot *pSnapshot) {
|
||||
mInfo("stop to apply snapshot to sdb, apply:%d", isApply);
|
||||
mInfo("stop to apply snapshot to sdb, apply:%d, index:%" PRId64 " term:%" PRIu64 " config:%" PRId64, isApply,
|
||||
pSnapshot->lastApplyIndex, pSnapshot->lastApplyTerm, pSnapshot->lastApplyIndex);
|
||||
SMnode *pMnode = pFsm->data;
|
||||
return sdbStopWrite(pMnode->pSdb, pWriter, isApply);
|
||||
return sdbStopWrite(pMnode->pSdb, pWriter, isApply, pSnapshot->lastApplyIndex, pSnapshot->lastApplyTerm,
|
||||
pSnapshot->lastConfigIndex);
|
||||
}
|
||||
|
||||
int32_t mndSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) {
|
||||
|
@ -157,7 +163,7 @@ int32_t mndSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *pBuf, int
|
|||
void mndLeaderTransfer(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
||||
SMnode *pMnode = pFsm->data;
|
||||
atomic_store_8(&(pMnode->syncMgmt.leaderTransferFinish), 1);
|
||||
mDebug("vgId:1, mnd leader transfer finish");
|
||||
mDebug("vgId:1, mnode leader transfer finish");
|
||||
}
|
||||
|
||||
SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) {
|
||||
|
|
|
@ -122,6 +122,10 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
|
|||
SDB_SET_INT8(pRaw, dataPos, pTrans->policy, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pTrans->conflict, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pTrans->exec, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pTrans->oper, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, 0, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, 0, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, 0, _OVER)
|
||||
SDB_SET_INT64(pRaw, dataPos, pTrans->createdTime, _OVER)
|
||||
SDB_SET_BINARY(pRaw, dataPos, pTrans->dbname1, TSDB_DB_FNAME_LEN, _OVER)
|
||||
SDB_SET_BINARY(pRaw, dataPos, pTrans->dbname2, TSDB_DB_FNAME_LEN, _OVER)
|
||||
|
@ -269,15 +273,22 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
|||
int8_t policy = 0;
|
||||
int8_t conflict = 0;
|
||||
int8_t exec = 0;
|
||||
int8_t oper = 0;
|
||||
int8_t reserved = 0;
|
||||
int8_t actionType = 0;
|
||||
SDB_GET_INT8(pRaw, dataPos, &stage, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &policy, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &conflict, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &exec, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &oper, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &reserved, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &reserved, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &reserved, _OVER)
|
||||
pTrans->stage = stage;
|
||||
pTrans->policy = policy;
|
||||
pTrans->conflict = conflict;
|
||||
pTrans->exec = exec;
|
||||
pTrans->oper = oper;
|
||||
SDB_GET_INT64(pRaw, dataPos, &pTrans->createdTime, _OVER)
|
||||
SDB_GET_BINARY(pRaw, dataPos, pTrans->dbname1, TSDB_DB_FNAME_LEN, _OVER)
|
||||
SDB_GET_BINARY(pRaw, dataPos, pTrans->dbname2, TSDB_DB_FNAME_LEN, _OVER)
|
||||
|
@ -495,6 +506,10 @@ static void mndTransDropData(STrans *pTrans) {
|
|||
mndTransDropActions(pTrans->commitActions);
|
||||
pTrans->commitActions = NULL;
|
||||
}
|
||||
if (pTrans->pRpcArray != NULL) {
|
||||
taosArrayDestroy(pTrans->pRpcArray);
|
||||
pTrans->pRpcArray = NULL;
|
||||
}
|
||||
if (pTrans->rpcRsp != NULL) {
|
||||
taosMemoryFree(pTrans->rpcRsp);
|
||||
pTrans->rpcRsp = NULL;
|
||||
|
@ -585,14 +600,18 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict,
|
|||
pTrans->redoActions = taosArrayInit(TRANS_ARRAY_SIZE, sizeof(STransAction));
|
||||
pTrans->undoActions = taosArrayInit(TRANS_ARRAY_SIZE, sizeof(STransAction));
|
||||
pTrans->commitActions = taosArrayInit(TRANS_ARRAY_SIZE, sizeof(STransAction));
|
||||
pTrans->pRpcArray = taosArrayInit(1, sizeof(SRpcHandleInfo));
|
||||
|
||||
if (pTrans->redoActions == NULL || pTrans->undoActions == NULL || pTrans->commitActions == NULL) {
|
||||
if (pTrans->redoActions == NULL || pTrans->undoActions == NULL || pTrans->commitActions == NULL ||
|
||||
pTrans->pRpcArray == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
mError("failed to create transaction since %s", terrstr());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (pReq != NULL) pTrans->rpcInfo = pReq->info;
|
||||
if (pReq != NULL) {
|
||||
taosArrayPush(pTrans->pRpcArray, &pReq->info);
|
||||
}
|
||||
mTrace("trans:%d, local object is created, data:%p", pTrans->id, pTrans);
|
||||
return pTrans;
|
||||
}
|
||||
|
@ -677,6 +696,35 @@ void mndTransSetCb(STrans *pTrans, ETrnFunc startFunc, ETrnFunc stopFunc, void *
|
|||
pTrans->paramLen = paramLen;
|
||||
}
|
||||
|
||||
int32_t mndSetRpcInfoForDbTrans(SMnode *pMnode, SRpcMsg *pMsg, EOperType oper, const char *dbname) {
|
||||
STrans *pTrans = NULL;
|
||||
void *pIter = NULL;
|
||||
int32_t code = -1;
|
||||
|
||||
while (1) {
|
||||
pIter = sdbFetch(pMnode->pSdb, SDB_TRANS, pIter, (void **)&pTrans);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
if (pTrans->oper == oper) {
|
||||
if (strcasecmp(dbname, pTrans->dbname1) == 0) {
|
||||
mDebug("trans:%d, db:%s oper:%d matched with input", pTrans->id, dbname, oper);
|
||||
if (pTrans->pRpcArray == NULL) {
|
||||
pTrans->pRpcArray = taosArrayInit(1, sizeof(SRpcHandleInfo));
|
||||
}
|
||||
if (pTrans->pRpcArray != NULL && taosArrayPush(pTrans->pRpcArray, &pMsg->info) != NULL) {
|
||||
code = 0;
|
||||
}
|
||||
|
||||
sdbRelease(pMnode->pSdb, pTrans);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sdbRelease(pMnode->pSdb, pTrans);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
void mndTransSetDbName(STrans *pTrans, const char *dbname1, const char *dbname2) {
|
||||
if (dbname1 != NULL) {
|
||||
memcpy(pTrans->dbname1, dbname1, TSDB_DB_FNAME_LEN);
|
||||
|
@ -688,6 +736,8 @@ void mndTransSetDbName(STrans *pTrans, const char *dbname1, const char *dbname2)
|
|||
|
||||
void mndTransSetSerial(STrans *pTrans) { pTrans->exec = TRN_EXEC_SERIAL; }
|
||||
|
||||
void mndTransSetOper(STrans *pTrans, EOperType oper) { pTrans->oper = oper; }
|
||||
|
||||
static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) {
|
||||
SSdbRaw *pRaw = mndTransActionEncode(pTrans);
|
||||
if (pRaw == NULL) {
|
||||
|
@ -711,7 +761,7 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) {
|
|||
|
||||
static bool mndCheckDbConflict(const char *db, STrans *pTrans) {
|
||||
if (db[0] == 0) return false;
|
||||
if (strcmp(db, pTrans->dbname1) == 0 || strcmp(db, pTrans->dbname2) == 0) return true;
|
||||
if (strcasecmp(db, pTrans->dbname1) == 0 || strcasecmp(db, pTrans->dbname2) == 0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -784,9 +834,10 @@ int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
pNew->rpcInfo = pTrans->rpcInfo;
|
||||
pNew->pRpcArray = pTrans->pRpcArray;
|
||||
pNew->rpcRsp = pTrans->rpcRsp;
|
||||
pNew->rpcRspLen = pTrans->rpcRspLen;
|
||||
pTrans->pRpcArray = NULL;
|
||||
pTrans->rpcRsp = NULL;
|
||||
pTrans->rpcRspLen = 0;
|
||||
|
||||
|
@ -835,29 +886,34 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
|||
}
|
||||
}
|
||||
|
||||
if (sendRsp && pTrans->rpcInfo.handle != NULL) {
|
||||
mDebug("trans:%d, send rsp, code:0x%x stage:%s app:%p", pTrans->id, code, mndTransStr(pTrans->stage),
|
||||
pTrans->rpcInfo.ahandle);
|
||||
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL) {
|
||||
code = TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL;
|
||||
}
|
||||
SRpcMsg rspMsg = {.code = code, .info = pTrans->rpcInfo};
|
||||
if (!sendRsp) return;
|
||||
|
||||
if (pTrans->rpcRspLen != 0) {
|
||||
void *rpcCont = rpcMallocCont(pTrans->rpcRspLen);
|
||||
if (rpcCont != NULL) {
|
||||
memcpy(rpcCont, pTrans->rpcRsp, pTrans->rpcRspLen);
|
||||
rspMsg.pCont = rpcCont;
|
||||
rspMsg.contLen = pTrans->rpcRspLen;
|
||||
int32_t size = taosArrayGetSize(pTrans->pRpcArray);
|
||||
if (size <= 0) return;
|
||||
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
SRpcHandleInfo *pInfo = taosArrayGet(pTrans->pRpcArray, i);
|
||||
if (pInfo->handle != NULL) {
|
||||
mDebug("trans:%d, send rsp, code:0x%x stage:%s app:%p", pTrans->id, code, mndTransStr(pTrans->stage),
|
||||
pInfo->ahandle);
|
||||
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL) {
|
||||
code = TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL;
|
||||
}
|
||||
taosMemoryFree(pTrans->rpcRsp);
|
||||
}
|
||||
SRpcMsg rspMsg = {.code = code, .info = *pInfo};
|
||||
|
||||
tmsgSendRsp(&rspMsg);
|
||||
pTrans->rpcInfo.handle = NULL;
|
||||
pTrans->rpcRsp = NULL;
|
||||
pTrans->rpcRspLen = 0;
|
||||
if (pTrans->rpcRspLen != 0) {
|
||||
void *rpcCont = rpcMallocCont(pTrans->rpcRspLen);
|
||||
if (rpcCont != NULL) {
|
||||
memcpy(rpcCont, pTrans->rpcRsp, pTrans->rpcRspLen);
|
||||
rspMsg.pCont = rpcCont;
|
||||
rspMsg.contLen = pTrans->rpcRspLen;
|
||||
}
|
||||
}
|
||||
|
||||
tmsgSendRsp(&rspMsg);
|
||||
}
|
||||
}
|
||||
taosArrayClear(pTrans->pRpcArray);
|
||||
}
|
||||
|
||||
int32_t mndTransProcessRsp(SRpcMsg *pRsp) {
|
||||
|
|
|
@ -925,7 +925,7 @@ TEST_F(MndTestSdb, 01_Read_Str) {
|
|||
}
|
||||
|
||||
sdbStopRead(pSdb, pReader);
|
||||
sdbStopWrite(pSdb, pWritter, true);
|
||||
sdbStopWrite(pSdb, pWritter, true, -1, -1, -1);
|
||||
}
|
||||
|
||||
ASSERT_EQ(sdbGetSize(pSdb, SDB_CONSUMER), 1);
|
||||
|
|
|
@ -394,7 +394,7 @@ int32_t sdbStopRead(SSdb *pSdb, SSdbIter *pIter);
|
|||
int32_t sdbDoRead(SSdb *pSdb, SSdbIter *pIter, void **ppBuf, int32_t *len);
|
||||
|
||||
int32_t sdbStartWrite(SSdb *pSdb, SSdbIter **ppIter);
|
||||
int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply);
|
||||
int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply, int64_t index, int64_t term, int64_t config);
|
||||
int32_t sdbDoWrite(SSdb *pSdb, SSdbIter *pIter, void *pBuf, int32_t len);
|
||||
|
||||
const char *sdbTableName(ESdbType type);
|
||||
|
|
|
@ -231,7 +231,7 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
|
|||
snprintf(file, sizeof(file), "%s%ssdb.data", pSdb->currDir, TD_DIRSEP);
|
||||
mDebug("start to read sdb file:%s", file);
|
||||
|
||||
SSdbRaw *pRaw = taosMemoryMalloc(WAL_MAX_SIZE + 100);
|
||||
SSdbRaw *pRaw = taosMemoryMalloc(TSDB_MAX_MSG_SIZE + 100);
|
||||
if (pRaw == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
mError("failed read sdb file since %s", terrstr());
|
||||
|
@ -556,8 +556,9 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter, int64_t *index, int64_t *ter
|
|||
if (term != NULL) *term = commitTerm;
|
||||
if (config != NULL) *config = commitConfig;
|
||||
|
||||
mDebug("sdbiter:%p, is created to read snapshot, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64 " file:%s",
|
||||
pIter, commitIndex, commitTerm, commitConfig, pIter->name);
|
||||
mDebug("sdbiter:%p, is created to read snapshot, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64
|
||||
" file:%s",
|
||||
pIter, commitIndex, commitTerm, commitConfig, pIter->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -613,7 +614,7 @@ int32_t sdbStartWrite(SSdb *pSdb, SSdbIter **ppIter) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply) {
|
||||
int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply, int64_t index, int64_t term, int64_t config) {
|
||||
int32_t code = 0;
|
||||
|
||||
if (!isApply) {
|
||||
|
@ -641,6 +642,19 @@ int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (config > 0) {
|
||||
ASSERT(pSdb->commitConfig == config);
|
||||
pSdb->commitConfig = config;
|
||||
}
|
||||
if (term > 0) {
|
||||
ASSERT(pSdb->commitTerm == term);
|
||||
pSdb->commitTerm = term;
|
||||
}
|
||||
if (index > 0) {
|
||||
ASSERT(pSdb->commitIndex == index);
|
||||
pSdb->commitIndex = index;
|
||||
}
|
||||
|
||||
mDebug("sdbiter:%p, successfully applyed to sdb", pIter);
|
||||
return 0;
|
||||
}
|
||||
|
@ -656,4 +670,4 @@ int32_t sdbDoWrite(SSdb *pSdb, SSdbIter *pIter, void *pBuf, int32_t len) {
|
|||
pIter->total += writelen;
|
||||
mDebug("sdbiter:%p, write:%d bytes to snapshot, total:%" PRId64, pIter, writelen, pIter->total);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,23 +153,22 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
|||
return terrno;
|
||||
}
|
||||
|
||||
taosThreadRwlockUnlock(pLock);
|
||||
|
||||
int32_t code = 0;
|
||||
SdbInsertFp insertFp = pSdb->insertFps[pRow->type];
|
||||
if (insertFp != NULL) {
|
||||
code = (*insertFp)(pSdb, pRow->pObj);
|
||||
if (code != 0) {
|
||||
code = terrno;
|
||||
taosThreadRwlockWrlock(pLock);
|
||||
taosHashRemove(hash, pRow->pObj, keySize);
|
||||
taosThreadRwlockUnlock(pLock);
|
||||
sdbFreeRow(pSdb, pRow, false);
|
||||
terrno = code;
|
||||
taosThreadRwlockUnlock(pLock);
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
|
||||
taosThreadRwlockUnlock(pLock);
|
||||
|
||||
if (pSdb->keyTypes[pRow->type] == SDB_KEY_INT32) {
|
||||
pSdb->maxId[pRow->type] = TMAX(pSdb->maxId[pRow->type], *((int32_t *)pRow->pObj));
|
||||
}
|
||||
|
@ -194,7 +193,6 @@ static int32_t sdbUpdateRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
|||
SSdbRow *pOldRow = *ppOldRow;
|
||||
pOldRow->status = pRaw->status;
|
||||
sdbPrintOper(pSdb, pOldRow, "update");
|
||||
taosThreadRwlockUnlock(pLock);
|
||||
|
||||
int32_t code = 0;
|
||||
SdbUpdateFp updateFp = pSdb->updateFps[pNewRow->type];
|
||||
|
@ -202,6 +200,7 @@ static int32_t sdbUpdateRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
|||
code = (*updateFp)(pSdb, pOldRow->pObj, pNewRow->pObj);
|
||||
}
|
||||
|
||||
taosThreadRwlockUnlock(pLock);
|
||||
sdbFreeRow(pSdb, pNewRow, false);
|
||||
|
||||
pSdb->tableVer[pOldRow->type]++;
|
||||
|
|
|
@ -88,7 +88,7 @@ typedef struct {
|
|||
STqExecTb execTb;
|
||||
STqExecDb execDb;
|
||||
};
|
||||
|
||||
int32_t numOfCols; // number of out pout column, temporarily used
|
||||
} STqExecHandle;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -174,6 +174,10 @@ void tsdbCalcColDataSMA(SColData *pColData, SColumnDataAgg *pColAgg);
|
|||
int32_t tsdbMemTableCreate(STsdb *pTsdb, SMemTable **ppMemTable);
|
||||
void tsdbMemTableDestroy(SMemTable *pMemTable);
|
||||
void tsdbGetTbDataFromMemTable(SMemTable *pMemTable, tb_uid_t suid, tb_uid_t uid, STbData **ppTbData);
|
||||
void tsdbRefMemTable(SMemTable *pMemTable);
|
||||
void tsdbUnrefMemTable(SMemTable *pMemTable);
|
||||
int32_t tsdbTakeMemSnapshot(STsdb *pTsdb, SMemTable **ppMem, SMemTable **ppIMem);
|
||||
void tsdbUntakeMemSnapshot(STsdb *pTsdb, SMemTable *pMem, SMemTable *pIMem);
|
||||
// STbDataIter
|
||||
int32_t tsdbTbDataIterCreate(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDataIter **ppIter);
|
||||
void *tsdbTbDataIterDestroy(STbDataIter *pIter);
|
||||
|
@ -186,6 +190,7 @@ int32_t tsdbGetNRowsInTbData(STbData *pTbData);
|
|||
typedef enum { TSDB_HEAD_FILE = 0, TSDB_DATA_FILE, TSDB_LAST_FILE, TSDB_SMA_FILE } EDataFileT;
|
||||
void tsdbDataFileName(STsdb *pTsdb, SDFileSet *pDFileSet, EDataFileT ftype, char fname[]);
|
||||
bool tsdbFileIsSame(SDFileSet *pDFileSet1, SDFileSet *pDFileSet2, EDataFileT ftype);
|
||||
bool tsdbDelFileIsSame(SDelFile *pDelFile1, SDelFile *pDelFile2);
|
||||
int32_t tsdbUpdateDFileHdr(TdFilePtr pFD, SDFileSet *pSet, EDataFileT ftype);
|
||||
int32_t tsdbDFileRollback(STsdb *pTsdb, SDFileSet *pSet, EDataFileT ftype);
|
||||
int32_t tPutDataFileHdr(uint8_t *p, SDFileSet *pSet, EDataFileT ftype);
|
||||
|
@ -272,23 +277,14 @@ typedef struct {
|
|||
} SRtn;
|
||||
|
||||
struct STsdb {
|
||||
char *path;
|
||||
SVnode *pVnode;
|
||||
TdThreadMutex mutex;
|
||||
bool repoLocked;
|
||||
STsdbKeepCfg keepCfg;
|
||||
SMemTable *mem;
|
||||
SMemTable *imem;
|
||||
SRtn rtn;
|
||||
STsdbFS *fs;
|
||||
SLRUCache *lruCache;
|
||||
};
|
||||
|
||||
struct STable {
|
||||
uint64_t suid;
|
||||
uint64_t uid;
|
||||
STSchema *pSchema; // latest schema
|
||||
STSchema *pCacheSchema; // cached cache
|
||||
char *path;
|
||||
SVnode *pVnode;
|
||||
STsdbKeepCfg keepCfg;
|
||||
TdThreadRwlock rwLock;
|
||||
SMemTable *mem;
|
||||
SMemTable *imem;
|
||||
STsdbFS *pFS;
|
||||
SLRUCache *lruCache;
|
||||
};
|
||||
|
||||
struct TSDBKEY {
|
||||
|
@ -329,21 +325,19 @@ struct STbData {
|
|||
};
|
||||
|
||||
struct SMemTable {
|
||||
SRWLatch latch;
|
||||
STsdb *pTsdb;
|
||||
int32_t nRef;
|
||||
TSKEY minKey;
|
||||
TSKEY maxKey;
|
||||
int64_t minVersion;
|
||||
int64_t maxVersion;
|
||||
int64_t nRow;
|
||||
int64_t nDel;
|
||||
SArray *aTbData; // SArray<STbData*>
|
||||
SRWLatch latch;
|
||||
STsdb *pTsdb;
|
||||
SVBufPool *pPool;
|
||||
volatile int32_t nRef;
|
||||
TSKEY minKey;
|
||||
TSKEY maxKey;
|
||||
int64_t minVersion;
|
||||
int64_t maxVersion;
|
||||
int64_t nRow;
|
||||
int64_t nDel;
|
||||
SArray *aTbData; // SArray<STbData*>
|
||||
};
|
||||
|
||||
int tsdbLockRepo(STsdb *pTsdb);
|
||||
int tsdbUnlockRepo(STsdb *pTsdb);
|
||||
|
||||
struct TSDBROW {
|
||||
int8_t type; // 0 for row from tsRow, 1 for row from block data
|
||||
union {
|
||||
|
|
|
@ -62,12 +62,13 @@ struct SVBufPoolNode {
|
|||
};
|
||||
|
||||
struct SVBufPool {
|
||||
SVBufPool* next;
|
||||
int64_t nRef;
|
||||
int64_t size;
|
||||
uint8_t* ptr;
|
||||
SVBufPoolNode* pTail;
|
||||
SVBufPoolNode node;
|
||||
SVBufPool* next;
|
||||
SVnode* pVnode;
|
||||
volatile int32_t nRef;
|
||||
int64_t size;
|
||||
uint8_t* ptr;
|
||||
SVBufPoolNode* pTail;
|
||||
SVBufPoolNode node;
|
||||
};
|
||||
|
||||
int32_t vnodeOpenBufPool(SVnode* pVnode, int64_t size);
|
||||
|
@ -78,7 +79,7 @@ void vnodeBufPoolReset(SVBufPool* pPool);
|
|||
int32_t vnodeQueryOpen(SVnode* pVnode);
|
||||
void vnodeQueryClose(SVnode* pVnode);
|
||||
int32_t vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg);
|
||||
int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg);
|
||||
int vnodeGetTableCfg(SVnode* pVnode, SRpcMsg* pMsg);
|
||||
|
||||
// vnodeCommit.c
|
||||
int32_t vnodeBegin(SVnode* pVnode);
|
||||
|
|
|
@ -77,6 +77,8 @@ typedef struct SSnapDataHdr SSnapDataHdr;
|
|||
// vnd.h
|
||||
void* vnodeBufPoolMalloc(SVBufPool* pPool, int size);
|
||||
void vnodeBufPoolFree(SVBufPool* pPool, void* p);
|
||||
void vnodeBufPoolRef(SVBufPool* pPool);
|
||||
void vnodeBufPoolUnRef(SVBufPool* pPool);
|
||||
|
||||
// meta
|
||||
typedef struct SMCtbCursor SMCtbCursor;
|
||||
|
@ -89,7 +91,7 @@ int metaBegin(SMeta* pMeta);
|
|||
int metaCommit(SMeta* pMeta);
|
||||
int metaCreateSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
||||
int metaAlterSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
||||
int metaDropSTable(SMeta* pMeta, int64_t verison, SVDropStbReq* pReq);
|
||||
int metaDropSTable(SMeta* pMeta, int64_t verison, SVDropStbReq* pReq, SArray* tbUidList);
|
||||
int metaCreateTable(SMeta* pMeta, int64_t version, SVCreateTbReq* pReq);
|
||||
int metaDropTable(SMeta* pMeta, int64_t version, SVDropTbReq* pReq, SArray* tbUids);
|
||||
int metaTtlDropTable(SMeta* pMeta, int64_t ttl, SArray* tbUids);
|
||||
|
@ -247,34 +249,34 @@ struct STsdbKeepCfg {
|
|||
};
|
||||
|
||||
struct SVnode {
|
||||
char* path;
|
||||
SVnodeCfg config;
|
||||
SVState state;
|
||||
STfs* pTfs;
|
||||
SMsgCb msgCb;
|
||||
SVBufPool* pPool;
|
||||
SVBufPool* inUse;
|
||||
SVBufPool* onCommit;
|
||||
SVBufPool* onRecycle;
|
||||
SMeta* pMeta;
|
||||
SSma* pSma;
|
||||
STsdb* pTsdb;
|
||||
SWal* pWal;
|
||||
STQ* pTq;
|
||||
SSink* pSink;
|
||||
tsem_t canCommit;
|
||||
int64_t sync;
|
||||
int32_t blockCount;
|
||||
tsem_t syncSem;
|
||||
SQHandle* pQuery;
|
||||
char* path;
|
||||
SVnodeCfg config;
|
||||
SVState state;
|
||||
STfs* pTfs;
|
||||
SMsgCb msgCb;
|
||||
TdThreadMutex mutex;
|
||||
TdThreadCond poolNotEmpty;
|
||||
SVBufPool* pPool;
|
||||
SVBufPool* inUse;
|
||||
SMeta* pMeta;
|
||||
SSma* pSma;
|
||||
STsdb* pTsdb;
|
||||
SWal* pWal;
|
||||
STQ* pTq;
|
||||
SSink* pSink;
|
||||
tsem_t canCommit;
|
||||
int64_t sync;
|
||||
int32_t blockCount;
|
||||
tsem_t syncSem;
|
||||
SQHandle* pQuery;
|
||||
};
|
||||
|
||||
#define TD_VID(PVNODE) ((PVNODE)->config.vgId)
|
||||
|
||||
#define VND_TSDB(vnd) ((vnd)->pTsdb)
|
||||
#define VND_RSMA0(vnd) ((vnd)->pTsdb)
|
||||
#define VND_RSMA1(vnd) ((vnd)->pSma->pRSmaTsdb1)
|
||||
#define VND_RSMA2(vnd) ((vnd)->pSma->pRSmaTsdb2)
|
||||
#define VND_RSMA1(vnd) ((vnd)->pSma->pRSmaTsdb[TSDB_RETENTION_L0])
|
||||
#define VND_RSMA2(vnd) ((vnd)->pSma->pRSmaTsdb[TSDB_RETENTION_L1])
|
||||
#define VND_RETENTIONS(vnd) (&(vnd)->config.tsdbCfg.retentions)
|
||||
#define VND_IS_RSMA(v) ((v)->config.isRsma == 1)
|
||||
#define VND_IS_TSMA(v) ((v)->config.isTsma == 1)
|
||||
|
@ -289,8 +291,7 @@ struct SSma {
|
|||
bool locked;
|
||||
TdThreadMutex mutex;
|
||||
SVnode* pVnode;
|
||||
STsdb* pRSmaTsdb1;
|
||||
STsdb* pRSmaTsdb2;
|
||||
STsdb* pRSmaTsdb[TSDB_RETENTION_L2];
|
||||
void* pTSmaEnv;
|
||||
void* pRSmaEnv;
|
||||
};
|
||||
|
@ -305,8 +306,8 @@ struct SSma {
|
|||
#define SMA_TSMA_ENV(s) ((s)->pTSmaEnv)
|
||||
#define SMA_RSMA_ENV(s) ((s)->pRSmaEnv)
|
||||
#define SMA_RSMA_TSDB0(s) ((s)->pVnode->pTsdb)
|
||||
#define SMA_RSMA_TSDB1(s) ((s)->pRSmaTsdb1)
|
||||
#define SMA_RSMA_TSDB2(s) ((s)->pRSmaTsdb2)
|
||||
#define SMA_RSMA_TSDB1(s) ((s)->pRSmaTsdb[TSDB_RETENTION_L0])
|
||||
#define SMA_RSMA_TSDB2(s) ((s)->pRSmaTsdb[TSDB_RETENTION_L1])
|
||||
|
||||
// sma
|
||||
void smaHandleRes(void* pVnode, int64_t smaId, const SArray* data);
|
||||
|
|
|
@ -212,7 +212,7 @@ _err:
|
|||
return -1;
|
||||
}
|
||||
|
||||
int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq) {
|
||||
int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tbUidList) {
|
||||
void *pKey = NULL;
|
||||
int nKey = 0;
|
||||
void *pData = NULL;
|
||||
|
@ -228,8 +228,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq) {
|
|||
}
|
||||
|
||||
// drop all child tables
|
||||
TBC *pCtbIdxc = NULL;
|
||||
SArray *pArray = taosArrayInit(8, sizeof(tb_uid_t));
|
||||
TBC *pCtbIdxc = NULL;
|
||||
|
||||
tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, &pMeta->txn);
|
||||
rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = pReq->suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
||||
|
@ -249,20 +248,18 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq) {
|
|||
break;
|
||||
}
|
||||
|
||||
taosArrayPush(pArray, &(((SCtbIdxKey *)pKey)->uid));
|
||||
taosArrayPush(tbUidList, &(((SCtbIdxKey *)pKey)->uid));
|
||||
}
|
||||
|
||||
tdbTbcClose(pCtbIdxc);
|
||||
|
||||
metaWLock(pMeta);
|
||||
|
||||
for (int32_t iChild = 0; iChild < taosArrayGetSize(pArray); iChild++) {
|
||||
tb_uid_t uid = *(tb_uid_t *)taosArrayGet(pArray, iChild);
|
||||
for (int32_t iChild = 0; iChild < taosArrayGetSize(tbUidList); iChild++) {
|
||||
tb_uid_t uid = *(tb_uid_t *)taosArrayGet(tbUidList, iChild);
|
||||
metaDropTableByUid(pMeta, uid, NULL);
|
||||
}
|
||||
|
||||
taosArrayDestroy(pArray);
|
||||
|
||||
// drop super table
|
||||
_drop_super_table:
|
||||
tdbTbGet(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), &pData, &nData);
|
||||
|
@ -374,6 +371,13 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq) {
|
|||
}
|
||||
metaReaderClear(&mr);
|
||||
|
||||
if (pReq->type == TSDB_CHILD_TABLE) {
|
||||
tb_uid_t suid = metaGetTableEntryUidByName(pMeta, pReq->ctb.name);
|
||||
if (suid == 0) {
|
||||
terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
// build SMetaEntry
|
||||
me.version = version;
|
||||
me.type = pReq->type;
|
||||
|
|
|
@ -123,11 +123,9 @@ int32_t smaOpen(SVnode *pVnode) {
|
|||
}
|
||||
|
||||
// restore the rsma
|
||||
#if 1
|
||||
if (rsmaRestore(pSma) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -605,7 +605,7 @@ static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSche
|
|||
snprintf(flag, 10, "level %" PRIi8, pItem->level);
|
||||
blockDebugShowDataBlocks(pResult, flag);
|
||||
#endif
|
||||
STsdb *sinkTsdb = (pItem->level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb1 : pSma->pRSmaTsdb2);
|
||||
STsdb *sinkTsdb = (pItem->level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb[0] : pSma->pRSmaTsdb[1]);
|
||||
SSubmitReq *pReq = NULL;
|
||||
// TODO: the schema update should be handled
|
||||
if (buildSubmitReqFromDataBlock(&pReq, pResult, pTSchema, SMA_VID(pSma), suid) < 0) {
|
||||
|
@ -949,13 +949,8 @@ _err:
|
|||
* @return int32_t
|
||||
*/
|
||||
static int32_t tdRSmaRestoreTSDataReload(SSma *pSma, int64_t committed) {
|
||||
// TODO
|
||||
smaDebug("vgId:%d, rsma restore from %" PRIi64 ", ts data reload success", SMA_VID(pSma), committed);
|
||||
// NOTHING TODO: the data would be restored from the unified WAL replay procedure
|
||||
return TSDB_CODE_SUCCESS;
|
||||
_err:
|
||||
smaError("vgId:%d, rsma restore from %" PRIi64 ", ts data reload failed since %s", SMA_VID(pSma), committed,
|
||||
terrstr());
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
int32_t tdProcessRSmaRestoreImpl(SSma *pSma) {
|
||||
|
|
|
@ -506,7 +506,8 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
|
|||
.initTqReader = true,
|
||||
.version = ver,
|
||||
};
|
||||
pHandle->execHandle.execCol.task[i] = qCreateQueueExecTaskInfo(pHandle->execHandle.execCol.qmsg, &handle);
|
||||
pHandle->execHandle.execCol.task[i] =
|
||||
qCreateQueueExecTaskInfo(pHandle->execHandle.execCol.qmsg, &handle, &pHandle->execHandle.numOfCols);
|
||||
ASSERT(pHandle->execHandle.execCol.task[i]);
|
||||
void* scanner = NULL;
|
||||
qExtractStreamScanner(pHandle->execHandle.execCol.task[i], &scanner);
|
||||
|
@ -591,7 +592,11 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) {
|
|||
};
|
||||
pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle);
|
||||
} else {
|
||||
pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, NULL);
|
||||
SReadHandle mgHandle = {
|
||||
.vnode = NULL,
|
||||
.numOfVgroups = pTask->numOfVgroups,
|
||||
};
|
||||
pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &mgHandle);
|
||||
}
|
||||
ASSERT(pTask->exec.executor);
|
||||
}
|
||||
|
@ -675,9 +680,9 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
//
|
||||
SStreamTaskRunReq* pReq = pMsg->pCont;
|
||||
int32_t taskId = pReq->taskId;
|
||||
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (pTask) {
|
||||
streamProcessRunReq(pTask);
|
||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (ppTask) {
|
||||
streamProcessRunReq(*ppTask);
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -692,14 +697,14 @@ int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
SDecoder decoder;
|
||||
tDecoderInit(&decoder, msgBody, msgLen);
|
||||
tDecodeStreamDispatchReq(&decoder, &req);
|
||||
int32_t taskId = req.taskId;
|
||||
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (pTask) {
|
||||
int32_t taskId = req.taskId;
|
||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (ppTask) {
|
||||
SRpcMsg rsp = {
|
||||
.info = pMsg->info,
|
||||
.code = 0,
|
||||
};
|
||||
streamProcessDispatchReq(pTask, &req, &rsp);
|
||||
streamProcessDispatchReq(*ppTask, &req, &rsp);
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -709,9 +714,9 @@ int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||
SStreamTaskRecoverReq* pReq = pMsg->pCont;
|
||||
int32_t taskId = pReq->taskId;
|
||||
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (pTask) {
|
||||
streamProcessRecoverReq(pTask, pReq, pMsg);
|
||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (ppTask) {
|
||||
streamProcessRecoverReq(*ppTask, pReq, pMsg);
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -721,9 +726,9 @@ int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) {
|
||||
SStreamDispatchRsp* pRsp = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||
int32_t taskId = pRsp->taskId;
|
||||
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (pTask) {
|
||||
streamProcessDispatchRsp(pTask, pRsp);
|
||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (ppTask) {
|
||||
streamProcessDispatchRsp(*ppTask, pRsp);
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -733,9 +738,9 @@ int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) {
|
|||
int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg) {
|
||||
SStreamTaskRecoverRsp* pRsp = pMsg->pCont;
|
||||
int32_t taskId = pRsp->taskId;
|
||||
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (pTask) {
|
||||
streamProcessRecoverRsp(pTask, pRsp);
|
||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (ppTask) {
|
||||
streamProcessRecoverRsp(*ppTask, pRsp);
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -745,10 +750,10 @@ int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg) {
|
|||
int32_t tqProcessTaskDropReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||
SVDropStreamTaskReq* pReq = (SVDropStreamTaskReq*)msg;
|
||||
|
||||
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &pReq->taskId, sizeof(int32_t));
|
||||
if (pTask) {
|
||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pTq->pStreamTasks, &pReq->taskId, sizeof(int32_t));
|
||||
if (ppTask) {
|
||||
taosHashRemove(pTq->pStreamTasks, &pReq->taskId, sizeof(int32_t));
|
||||
atomic_store_8(&pTask->taskStatus, TASK_STATUS__DROPPING);
|
||||
atomic_store_8(&(*ppTask)->taskStatus, TASK_STATUS__DROPPING);
|
||||
}
|
||||
// todo
|
||||
// clear queue
|
||||
|
@ -776,16 +781,17 @@ int32_t tqProcessTaskRetrieveReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
SDecoder decoder;
|
||||
tDecoderInit(&decoder, msgBody, msgLen);
|
||||
tDecodeStreamRetrieveReq(&decoder, &req);
|
||||
int32_t taskId = req.dstTaskId;
|
||||
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (atomic_load_8(&pTask->taskStatus) != TASK_STATUS__NORMAL) {
|
||||
return 0;
|
||||
int32_t taskId = req.dstTaskId;
|
||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (ppTask) {
|
||||
SRpcMsg rsp = {
|
||||
.info = pMsg->info,
|
||||
.code = 0,
|
||||
};
|
||||
streamProcessRetrieveReq(*ppTask, &req, &rsp);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
SRpcMsg rsp = {
|
||||
.info = pMsg->info,
|
||||
.code = 0,
|
||||
};
|
||||
streamProcessRetrieveReq(pTask, &req, &rsp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include "tq.h"
|
||||
|
||||
static int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp) {
|
||||
static int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols) {
|
||||
int32_t dataStrLen = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock);
|
||||
void* buf = taosMemoryCalloc(1, dataStrLen);
|
||||
if (buf == NULL) return -1;
|
||||
|
@ -29,7 +29,7 @@ static int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp)
|
|||
|
||||
// TODO enable compress
|
||||
int32_t actualLen = 0;
|
||||
blockEncode(pBlock, pRetrieve->data, &actualLen, taosArrayGetSize(pBlock->pDataBlock), false);
|
||||
blockEncode(pBlock, pRetrieve->data, &actualLen, numOfCols, false);
|
||||
actualLen += sizeof(SRetrieveTableRsp);
|
||||
ASSERT(actualLen <= dataStrLen);
|
||||
taosArrayPush(pRsp->blockDataLen, &actualLen);
|
||||
|
@ -49,8 +49,8 @@ static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, int32_t workerI
|
|||
static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, SMqDataRsp* pRsp) {
|
||||
SMetaReader mr = {0};
|
||||
metaReaderInit(&mr, pTq->pVnode->pMeta, 0);
|
||||
// TODO add reference to gurantee success
|
||||
if (metaGetTableEntryByUid(&mr, uid) < 0) {
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
char* tbName = strdup(mr.me.name);
|
||||
|
@ -87,16 +87,18 @@ int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVa
|
|||
tqDebug("task execute end, get %p", pDataBlock);
|
||||
|
||||
if (pDataBlock != NULL) {
|
||||
tqAddBlockDataToRsp(pDataBlock, pRsp);
|
||||
pRsp->blockNum++;
|
||||
if (pRsp->withTbName) {
|
||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||
int64_t uid = pExec->pExecReader[0]->msgIter.uid;
|
||||
tqAddTbNameToRsp(pTq, uid, pRsp);
|
||||
if (tqAddTbNameToRsp(pTq, uid, pRsp) < 0) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
pRsp->withTbName = 0;
|
||||
}
|
||||
}
|
||||
tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols);
|
||||
pRsp->blockNum++;
|
||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||
continue;
|
||||
} else {
|
||||
|
@ -193,13 +195,14 @@ int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataR
|
|||
SSDataBlock block = {0};
|
||||
if (tqRetrieveDataBlock(&block, pReader) < 0) {
|
||||
if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) continue;
|
||||
ASSERT(0);
|
||||
}
|
||||
tqAddBlockDataToRsp(&block, pRsp);
|
||||
if (pRsp->withTbName) {
|
||||
int64_t uid = pExec->pExecReader[workerId]->msgIter.uid;
|
||||
tqAddTbNameToRsp(pTq, uid, pRsp);
|
||||
if (tqAddTbNameToRsp(pTq, uid, pRsp) < 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
tqAddBlockDataToRsp(&block, pRsp, taosArrayGetSize(block.pDataBlock));
|
||||
tqAddBlockSchemaToRsp(pExec, workerId, pRsp);
|
||||
pRsp->blockNum++;
|
||||
}
|
||||
|
@ -211,13 +214,14 @@ int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataR
|
|||
SSDataBlock block = {0};
|
||||
if (tqRetrieveDataBlock(&block, pReader) < 0) {
|
||||
if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) continue;
|
||||
ASSERT(0);
|
||||
}
|
||||
tqAddBlockDataToRsp(&block, pRsp);
|
||||
if (pRsp->withTbName) {
|
||||
int64_t uid = pExec->pExecReader[workerId]->msgIter.uid;
|
||||
tqAddTbNameToRsp(pTq, uid, pRsp);
|
||||
if (tqAddTbNameToRsp(pTq, uid, pRsp) < 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
tqAddBlockDataToRsp(&block, pRsp, taosArrayGetSize(block.pDataBlock));
|
||||
tqAddBlockSchemaToRsp(pExec, workerId, pRsp);
|
||||
pRsp->blockNum++;
|
||||
}
|
||||
|
|
|
@ -92,7 +92,8 @@ int32_t tqMetaOpen(STQ* pTq) {
|
|||
.initTqReader = true,
|
||||
.version = handle.snapshotVer,
|
||||
};
|
||||
handle.execHandle.execCol.task[i] = qCreateQueueExecTaskInfo(handle.execHandle.execCol.qmsg, &reader);
|
||||
|
||||
handle.execHandle.execCol.task[i] = qCreateQueueExecTaskInfo(handle.execHandle.execCol.qmsg, &reader, &handle.execHandle.numOfCols);
|
||||
ASSERT(handle.execHandle.execCol.task[i]);
|
||||
void* scanner = NULL;
|
||||
qExtractStreamScanner(handle.execHandle.execCol.task[i], &scanner);
|
||||
|
|
|
@ -237,6 +237,8 @@ int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_
|
|||
#endif
|
||||
|
||||
int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) {
|
||||
walApplyVer(pTq->pVnode->pWal, ver);
|
||||
|
||||
if (msgType == TDMT_VND_SUBMIT) {
|
||||
if (taosHashGetSize(pTq->pStreamTasks) == 0) return 0;
|
||||
|
||||
|
@ -253,4 +255,3 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -299,6 +299,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReader* pReader) {
|
|||
}
|
||||
|
||||
if (blockDataEnsureCapacity(pBlock, pReader->msgIter.numOfRows) < 0) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,8 +49,11 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo
|
|||
}
|
||||
|
||||
SVCreateTbReq createTbReq = {0};
|
||||
SName name = {0};
|
||||
tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
|
||||
createTbReq.name = buildCtbNameByGroupId(stbFullName, pDataBlock->info.groupId);
|
||||
createTbReq.ctb.name = strdup(stbFullName);
|
||||
createTbReq.ctb.name = strdup((char*)tNameGetTableName(&name)); // strdup(stbFullName);
|
||||
createTbReq.flags = 0;
|
||||
createTbReq.type = TSDB_CHILD_TABLE;
|
||||
createTbReq.ctb.suid = suid;
|
||||
|
@ -175,6 +178,8 @@ void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data) {
|
|||
const SArray* pRes = (const SArray*)data;
|
||||
SVnode* pVnode = (SVnode*)vnode;
|
||||
|
||||
tqDebug("task write into table, vgId %d, block num: %d", pVnode->config.vgId, (int32_t)pRes->size);
|
||||
|
||||
ASSERT(pTask->tbSink.pTSchema);
|
||||
SSubmitReq* pReq = tdBlockToSubmit(pRes, pTask->tbSink.pTSchema, true, pTask->tbSink.stbUid,
|
||||
pTask->tbSink.stbFullName, pVnode->config.vgId);
|
||||
|
|
|
@ -464,7 +464,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) {
|
|||
|
||||
switch (state->state) {
|
||||
case SFSNEXTROW_FS:
|
||||
state->aDFileSet = state->pTsdb->fs->cState->aDFileSet;
|
||||
state->aDFileSet = state->pTsdb->pFS->cState->aDFileSet;
|
||||
state->nFileSet = taosArrayGetSize(state->aDFileSet);
|
||||
state->iFileSet = state->nFileSet;
|
||||
|
||||
|
@ -793,6 +793,9 @@ typedef struct {
|
|||
TSDBROW memRow, imemRow, fsRow;
|
||||
|
||||
TsdbNextRowState input[3];
|
||||
SMemTable *pMemTable;
|
||||
SMemTable *pIMemTable;
|
||||
STsdb *pTsdb;
|
||||
} CacheNextRowIter;
|
||||
|
||||
static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTsdb) {
|
||||
|
@ -800,21 +803,25 @@ static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTs
|
|||
|
||||
tb_uid_t suid = getTableSuidByUid(uid, pTsdb);
|
||||
|
||||
tsdbTakeMemSnapshot(pTsdb, &pIter->pMemTable, &pIter->pIMemTable);
|
||||
|
||||
STbData *pMem = NULL;
|
||||
if (pTsdb->mem) {
|
||||
tsdbGetTbDataFromMemTable(pTsdb->mem, suid, uid, &pMem);
|
||||
if (pIter->pMemTable) {
|
||||
tsdbGetTbDataFromMemTable(pIter->pMemTable, suid, uid, &pMem);
|
||||
}
|
||||
|
||||
STbData *pIMem = NULL;
|
||||
if (pTsdb->imem) {
|
||||
tsdbGetTbDataFromMemTable(pTsdb->imem, suid, uid, &pIMem);
|
||||
if (pIter->pIMemTable) {
|
||||
tsdbGetTbDataFromMemTable(pIter->pIMemTable, suid, uid, &pIMem);
|
||||
}
|
||||
|
||||
pIter->pTsdb = pTsdb;
|
||||
|
||||
pIter->pSkyline = taosArrayInit(32, sizeof(TSDBKEY));
|
||||
|
||||
SDelIdx delIdx;
|
||||
|
||||
SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->fs->cState);
|
||||
SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState);
|
||||
if (pDelFile) {
|
||||
SDelFReader *pDelFReader;
|
||||
|
||||
|
@ -878,6 +885,8 @@ static int32_t nextRowIterClose(CacheNextRowIter *pIter) {
|
|||
taosArrayDestroy(pIter->pSkyline);
|
||||
}
|
||||
|
||||
tsdbUntakeMemSnapshot(pIter->pTsdb, pIter->pMemTable, pIter->pIMemTable);
|
||||
|
||||
return code;
|
||||
_err:
|
||||
return code;
|
||||
|
@ -1189,7 +1198,7 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRo
|
|||
|
||||
SDelIdx delIdx;
|
||||
|
||||
SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->fs->cState);
|
||||
SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState);
|
||||
if (pDelFile) {
|
||||
SDelFReader *pDelFReader;
|
||||
|
||||
|
@ -1377,7 +1386,7 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) {
|
|||
|
||||
SDelIdx delIdx;
|
||||
|
||||
SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->fs->cState);
|
||||
SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState);
|
||||
if (pDelFile) {
|
||||
SDelFReader *pDelFReader;
|
||||
|
||||
|
|
|
@ -64,9 +64,26 @@ int32_t tsdbBegin(STsdb *pTsdb) {
|
|||
|
||||
if (!pTsdb) return code;
|
||||
|
||||
code = tsdbMemTableCreate(pTsdb, &pTsdb->mem);
|
||||
SMemTable *pMemTable;
|
||||
code = tsdbMemTableCreate(pTsdb, &pMemTable);
|
||||
if (code) goto _err;
|
||||
|
||||
// lock
|
||||
code = taosThreadRwlockWrlock(&pTsdb->rwLock);
|
||||
if (code) {
|
||||
code = TAOS_SYSTEM_ERROR(code);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
pTsdb->mem = pMemTable;
|
||||
|
||||
// unlock
|
||||
code = taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
if (code) {
|
||||
code = TAOS_SYSTEM_ERROR(code);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
return code;
|
||||
|
||||
_err:
|
||||
|
@ -83,9 +100,11 @@ int32_t tsdbCommit(STsdb *pTsdb) {
|
|||
|
||||
// check
|
||||
if (pMemTable->nRow == 0 && pMemTable->nDel == 0) {
|
||||
// TODO: lock?
|
||||
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
||||
pTsdb->mem = NULL;
|
||||
tsdbMemTableDestroy(pMemTable);
|
||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
|
||||
tsdbUnrefMemTable(pMemTable);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
|
@ -139,7 +158,7 @@ static int32_t tsdbCommitDelStart(SCommitter *pCommitter) {
|
|||
goto _err;
|
||||
}
|
||||
|
||||
SDelFile *pDelFileR = pTsdb->fs->nState->pDelFile;
|
||||
SDelFile *pDelFileR = pTsdb->pFS->nState->pDelFile;
|
||||
if (pDelFileR) {
|
||||
code = tsdbDelFReaderOpen(&pCommitter->pDelFReader, pDelFileR, pTsdb, NULL);
|
||||
if (code) goto _err;
|
||||
|
@ -228,7 +247,7 @@ static int32_t tsdbCommitDelEnd(SCommitter *pCommitter) {
|
|||
code = tsdbUpdateDelFileHdr(pCommitter->pDelFWriter);
|
||||
if (code) goto _err;
|
||||
|
||||
code = tsdbFSStateUpsertDelFile(pTsdb->fs->nState, &pCommitter->pDelFWriter->fDel);
|
||||
code = tsdbFSStateUpsertDelFile(pTsdb->pFS->nState, &pCommitter->pDelFWriter->fDel);
|
||||
if (code) goto _err;
|
||||
|
||||
code = tsdbDelFWriterClose(&pCommitter->pDelFWriter, 1);
|
||||
|
@ -263,7 +282,7 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
|
|||
taosArrayClear(pCommitter->aBlockIdx);
|
||||
tMapDataReset(&pCommitter->oBlockMap);
|
||||
tBlockDataReset(&pCommitter->oBlockData);
|
||||
pRSet = tsdbFSStateGetDFileSet(pTsdb->fs->nState, pCommitter->commitFid, TD_EQ);
|
||||
pRSet = tsdbFSStateGetDFileSet(pTsdb->pFS->nState, pCommitter->commitFid, TD_EQ);
|
||||
if (pRSet) {
|
||||
code = tsdbDataFReaderOpen(&pCommitter->pReader, pTsdb, pRSet);
|
||||
if (code) goto _err;
|
||||
|
@ -836,7 +855,7 @@ static int32_t tsdbCommitFileDataEnd(SCommitter *pCommitter) {
|
|||
if (code) goto _err;
|
||||
|
||||
// upsert SDFileSet
|
||||
code = tsdbFSStateUpsertDFileSet(pCommitter->pTsdb->fs->nState, tsdbDataFWriterGetWSet(pCommitter->pWriter));
|
||||
code = tsdbFSStateUpsertDFileSet(pCommitter->pTsdb->pFS->nState, tsdbDataFWriterGetWSet(pCommitter->pWriter));
|
||||
if (code) goto _err;
|
||||
|
||||
// close and sync
|
||||
|
@ -941,10 +960,10 @@ static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter) {
|
|||
memset(pCommitter, 0, sizeof(*pCommitter));
|
||||
ASSERT(pTsdb->mem && pTsdb->imem == NULL);
|
||||
|
||||
// lock();
|
||||
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
||||
pTsdb->imem = pTsdb->mem;
|
||||
pTsdb->mem = NULL;
|
||||
// unlock();
|
||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
|
||||
pCommitter->pTsdb = pTsdb;
|
||||
pCommitter->commitID = pTsdb->pVnode->state.commitID;
|
||||
|
@ -954,7 +973,7 @@ static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter) {
|
|||
pCommitter->maxRow = pTsdb->pVnode->config.tsdbCfg.maxRows;
|
||||
pCommitter->cmprAlg = pTsdb->pVnode->config.tsdbCfg.compression;
|
||||
|
||||
code = tsdbFSBegin(pTsdb->fs);
|
||||
code = tsdbFSBegin(pTsdb->pFS);
|
||||
if (code) goto _err;
|
||||
|
||||
return code;
|
||||
|
@ -1135,13 +1154,16 @@ static int32_t tsdbEndCommit(SCommitter *pCommitter, int32_t eno) {
|
|||
SMemTable *pMemTable = pTsdb->imem;
|
||||
|
||||
if (eno == 0) {
|
||||
code = tsdbFSCommit(pTsdb->fs);
|
||||
code = tsdbFSCommit(pTsdb->pFS);
|
||||
} else {
|
||||
code = tsdbFSRollback(pTsdb->fs);
|
||||
code = tsdbFSRollback(pTsdb->pFS);
|
||||
}
|
||||
|
||||
tsdbMemTableDestroy(pMemTable);
|
||||
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
||||
pTsdb->imem = NULL;
|
||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
|
||||
tsdbUnrefMemTable(pMemTable);
|
||||
|
||||
tsdbInfo("vgId:%d tsdb end commit", TD_VID(pTsdb->pVnode));
|
||||
return code;
|
||||
|
|
|
@ -245,7 +245,7 @@ static int32_t tsdbApplyDelFileChange(STsdbFS *pFS, SDelFile *pFrom, SDelFile *p
|
|||
char fname[TSDB_FILENAME_LEN];
|
||||
|
||||
if (pFrom && pTo) {
|
||||
if (pFrom != pTo) {
|
||||
if (!tsdbDelFileIsSame(pFrom, pTo)) {
|
||||
tsdbDelFileName(pFS->pTsdb, pFrom, fname);
|
||||
if (taosRemoveFile(fname) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
|
|
|
@ -140,6 +140,8 @@ bool tsdbFileIsSame(SDFileSet *pDFileSet1, SDFileSet *pDFileSet2, EDataFileT fty
|
|||
}
|
||||
}
|
||||
|
||||
bool tsdbDelFileIsSame(SDelFile *pDelFile1, SDelFile *pDelFile2) { return pDelFile1->commitID == pDelFile2->commitID; }
|
||||
|
||||
int32_t tsdbUpdateDFileHdr(TdFilePtr pFD, SDFileSet *pSet, EDataFileT ftype) {
|
||||
int32_t code = 0;
|
||||
int64_t n;
|
||||
|
|
|
@ -41,6 +41,7 @@ int32_t tsdbMemTableCreate(STsdb *pTsdb, SMemTable **ppMemTable) {
|
|||
}
|
||||
taosInitRWLatch(&pMemTable->latch);
|
||||
pMemTable->pTsdb = pTsdb;
|
||||
pMemTable->pPool = pTsdb->pVnode->inUse;
|
||||
pMemTable->nRef = 1;
|
||||
pMemTable->minKey = TSKEY_MAX;
|
||||
pMemTable->maxKey = TSKEY_MIN;
|
||||
|
@ -54,6 +55,7 @@ int32_t tsdbMemTableCreate(STsdb *pTsdb, SMemTable **ppMemTable) {
|
|||
taosMemoryFree(pMemTable);
|
||||
goto _err;
|
||||
}
|
||||
vnodeBufPoolRef(pMemTable->pPool);
|
||||
|
||||
*ppMemTable = pMemTable;
|
||||
return code;
|
||||
|
@ -65,6 +67,7 @@ _err:
|
|||
|
||||
void tsdbMemTableDestroy(SMemTable *pMemTable) {
|
||||
if (pMemTable) {
|
||||
vnodeBufPoolUnRef(pMemTable->pPool);
|
||||
taosArrayDestroy(pMemTable->aTbData);
|
||||
taosMemoryFree(pMemTable);
|
||||
}
|
||||
|
@ -590,3 +593,58 @@ _err:
|
|||
}
|
||||
|
||||
int32_t tsdbGetNRowsInTbData(STbData *pTbData) { return pTbData->sl.size; }
|
||||
|
||||
void tsdbRefMemTable(SMemTable *pMemTable) {
|
||||
int32_t nRef = atomic_fetch_add_32(&pMemTable->nRef, 1);
|
||||
ASSERT(nRef > 0);
|
||||
}
|
||||
|
||||
void tsdbUnrefMemTable(SMemTable *pMemTable) {
|
||||
int32_t nRef = atomic_sub_fetch_32(&pMemTable->nRef, 1);
|
||||
if (nRef == 0) {
|
||||
tsdbMemTableDestroy(pMemTable);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t tsdbTakeMemSnapshot(STsdb *pTsdb, SMemTable **ppMem, SMemTable **ppIMem) {
|
||||
int32_t code = 0;
|
||||
|
||||
// lock
|
||||
code = taosThreadRwlockRdlock(&pTsdb->rwLock);
|
||||
if (code) {
|
||||
code = TAOS_SYSTEM_ERROR(code);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
// take snapshot
|
||||
*ppMem = pTsdb->mem;
|
||||
*ppIMem = pTsdb->imem;
|
||||
|
||||
if (*ppMem) {
|
||||
tsdbRefMemTable(*ppMem);
|
||||
}
|
||||
|
||||
if (*ppIMem) {
|
||||
tsdbRefMemTable(*ppIMem);
|
||||
}
|
||||
|
||||
// unlock
|
||||
code = taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
if (code) {
|
||||
code = TAOS_SYSTEM_ERROR(code);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
|
||||
void tsdbUntakeMemSnapshot(STsdb *pTsdb, SMemTable *pMem, SMemTable *pIMem) {
|
||||
if (pMem) {
|
||||
tsdbUnrefMemTable(pMem);
|
||||
}
|
||||
|
||||
if (pIMem) {
|
||||
tsdbUnrefMemTable(pIMem);
|
||||
}
|
||||
}
|
|
@ -54,8 +54,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee
|
|||
sprintf(pTsdb->path, "%s%s%s", pVnode->path, TD_DIRSEP, dir);
|
||||
taosRealPath(pTsdb->path, NULL, slen);
|
||||
pTsdb->pVnode = pVnode;
|
||||
pTsdb->repoLocked = false;
|
||||
taosThreadMutexInit(&pTsdb->mutex, NULL);
|
||||
taosThreadRwlockInit(&pTsdb->rwLock, NULL);
|
||||
if (!pKeepCfg) {
|
||||
tsdbSetKeepCfg(&pTsdb->keepCfg, &pVnode->config.tsdbCfg);
|
||||
} else {
|
||||
|
@ -67,7 +66,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee
|
|||
tfsMkdir(pVnode->pTfs, pTsdb->path);
|
||||
|
||||
// open tsdb
|
||||
if (tsdbFSOpen(pTsdb, &pTsdb->fs) < 0) {
|
||||
if (tsdbFSOpen(pTsdb, &pTsdb->pFS) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -88,33 +87,10 @@ _err:
|
|||
|
||||
int tsdbClose(STsdb **pTsdb) {
|
||||
if (*pTsdb) {
|
||||
taosThreadMutexDestroy(&(*pTsdb)->mutex);
|
||||
tsdbFSClose((*pTsdb)->fs);
|
||||
taosThreadRwlockDestroy(&(*pTsdb)->rwLock);
|
||||
tsdbFSClose((*pTsdb)->pFS);
|
||||
tsdbCloseCache((*pTsdb)->lruCache);
|
||||
taosMemoryFreeClear(*pTsdb);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tsdbLockRepo(STsdb *pTsdb) {
|
||||
int code = taosThreadMutexLock(&pTsdb->mutex);
|
||||
if (code != 0) {
|
||||
tsdbError("vgId:%d, failed to lock tsdb since %s", TD_VID(pTsdb->pVnode), strerror(errno));
|
||||
terrno = TAOS_SYSTEM_ERROR(code);
|
||||
return -1;
|
||||
}
|
||||
pTsdb->repoLocked = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tsdbUnlockRepo(STsdb *pTsdb) {
|
||||
// ASSERT(IS_REPO_LOCKED(pTsdb));
|
||||
pTsdb->repoLocked = false;
|
||||
int code = taosThreadMutexUnlock(&pTsdb->mutex);
|
||||
if (code != 0) {
|
||||
tsdbError("vgId:%d, failed to unlock tsdb since %s", TD_VID(pTsdb->pVnode), strerror(errno));
|
||||
terrno = TAOS_SYSTEM_ERROR(code);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -118,6 +118,8 @@ struct STsdbReader {
|
|||
char* idStr; // query info handle, for debug purpose
|
||||
int32_t type; // query type: 1. retrieve all data blocks, 2. retrieve direct prev|next rows
|
||||
SBlockLoadSuppInfo suppInfo;
|
||||
SMemTable* pMem;
|
||||
SMemTable* pIMem;
|
||||
|
||||
SIOCostSummary cost;
|
||||
STSchema* pSchema;
|
||||
|
@ -1453,38 +1455,70 @@ static bool keyOverlapFileBlock(TSDBKEY key, SBlock* pBlock, SVersionRange* pVer
|
|||
(pBlock->minVersion <= pVerRange->maxVer);
|
||||
}
|
||||
|
||||
static bool overlapWithDelSkyline(STableBlockScanInfo* pBlockScanInfo, const SBlock* pBlock, int32_t order) {
|
||||
if (pBlockScanInfo->delSkyline == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TSDBKEY* pFirst = taosArrayGet(pBlockScanInfo->delSkyline, 0);
|
||||
TSDBKEY* pLast = taosArrayGetLast(pBlockScanInfo->delSkyline);
|
||||
|
||||
// ts is not overlap
|
||||
if (pBlock->minKey.ts > pLast->ts || pBlock->maxKey.ts < pFirst->ts) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t step = ASCENDING_TRAVERSE(order) ? 1 : -1;
|
||||
|
||||
// version is not overlap
|
||||
static bool doCheckforDatablockOverlap(STableBlockScanInfo* pBlockScanInfo, const SBlock* pBlock) {
|
||||
size_t num = taosArrayGetSize(pBlockScanInfo->delSkyline);
|
||||
for (int32_t i = pBlockScanInfo->fileDelIndex; i < num; i += step) {
|
||||
|
||||
for (int32_t i = pBlockScanInfo->fileDelIndex; i < num; i += 1) {
|
||||
TSDBKEY* p = taosArrayGet(pBlockScanInfo->delSkyline, i);
|
||||
if (p->ts >= pBlock->minKey.ts && p->ts <= pBlock->maxKey.ts) {
|
||||
if (p->version >= pBlock->minVersion) {
|
||||
return true;
|
||||
}
|
||||
} else if (p->ts > pBlock->maxKey.ts) {
|
||||
} else if (p->ts < pBlock->minKey.ts) { // p->ts < pBlock->minKey.ts
|
||||
if (p->version >= pBlock->minVersion) {
|
||||
if (i < num - 1) {
|
||||
TSDBKEY* pnext = taosArrayGet(pBlockScanInfo->delSkyline, i + 1);
|
||||
if (i + 1 == num - 1) { // pnext is the last point
|
||||
if (pnext->ts >= pBlock->minKey.ts) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (pnext->ts >= pBlock->minKey.ts && pnext->version >= pBlock->minVersion) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else { // it must be the last point
|
||||
ASSERT(p->version == 0);
|
||||
}
|
||||
}
|
||||
} else { // (p->ts > pBlock->maxKey.ts) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool overlapWithDelSkyline(STableBlockScanInfo* pBlockScanInfo, const SBlock* pBlock, int32_t order) {
|
||||
if (pBlockScanInfo->delSkyline == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// ts is not overlap
|
||||
TSDBKEY* pFirst = taosArrayGet(pBlockScanInfo->delSkyline, 0);
|
||||
TSDBKEY* pLast = taosArrayGetLast(pBlockScanInfo->delSkyline);
|
||||
if (pBlock->minKey.ts > pLast->ts || pBlock->maxKey.ts < pFirst->ts) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// version is not overlap
|
||||
if (ASCENDING_TRAVERSE(order)) {
|
||||
return doCheckforDatablockOverlap(pBlockScanInfo, pBlock);
|
||||
} else {
|
||||
int32_t index = pBlockScanInfo->fileDelIndex;
|
||||
while (1) {
|
||||
TSDBKEY* p = taosArrayGet(pBlockScanInfo->delSkyline, index);
|
||||
if (p->ts > pBlock->minKey.ts && index > 0) {
|
||||
index -= 1;
|
||||
} else { // find the first point that is smaller than the minKey.ts of dataBlock.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return doCheckforDatablockOverlap(pBlockScanInfo, pBlock);
|
||||
}
|
||||
}
|
||||
|
||||
// 1. the version of all rows should be less than the endVersion
|
||||
// 2. current block should not overlap with next neighbor block
|
||||
// 3. current timestamp should not be overlap with each other
|
||||
|
@ -1847,8 +1881,8 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
|
|||
int32_t backward = (!ASCENDING_TRAVERSE(pReader->order));
|
||||
|
||||
STbData* d = NULL;
|
||||
if (pReader->pTsdb->mem != NULL) {
|
||||
tsdbGetTbDataFromMemTable(pReader->pTsdb->mem, pReader->suid, pBlockScanInfo->uid, &d);
|
||||
if (pReader->pMem != NULL) {
|
||||
tsdbGetTbDataFromMemTable(pReader->pMem, pReader->suid, pBlockScanInfo->uid, &d);
|
||||
if (d != NULL) {
|
||||
code = tsdbTbDataIterCreate(d, &startKey, backward, &pBlockScanInfo->iter.iter);
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
|
@ -1868,8 +1902,8 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
|
|||
}
|
||||
|
||||
STbData* di = NULL;
|
||||
if (pReader->pTsdb->imem != NULL) {
|
||||
tsdbGetTbDataFromMemTable(pReader->pTsdb->imem, pReader->suid, pBlockScanInfo->uid, &di);
|
||||
if (pReader->pIMem != NULL) {
|
||||
tsdbGetTbDataFromMemTable(pReader->pIMem, pReader->suid, pBlockScanInfo->uid, &di);
|
||||
if (di != NULL) {
|
||||
code = tsdbTbDataIterCreate(di, &startKey, backward, &pBlockScanInfo->iiter.iter);
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
|
@ -1905,7 +1939,7 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader*
|
|||
|
||||
SArray* pDelData = taosArrayInit(4, sizeof(SDelData));
|
||||
|
||||
SDelFile* pDelFile = tsdbFSStateGetDelFile(pTsdb->fs->cState);
|
||||
SDelFile* pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState);
|
||||
if (pDelFile) {
|
||||
SDelFReader* pDelFReader = NULL;
|
||||
code = tsdbDelFReaderOpen(&pDelFReader, pDelFile, pTsdb, NULL);
|
||||
|
@ -1926,9 +1960,11 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader*
|
|||
SDelIdx idx = {.suid = pReader->suid, .uid = pBlockScanInfo->uid};
|
||||
SDelIdx* pIdx = taosArraySearch(aDelIdx, &idx, tCmprDelIdx, TD_EQ);
|
||||
|
||||
code = tsdbReadDelData(pDelFReader, pIdx, pDelData, NULL);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _err;
|
||||
if (pIdx != NULL) {
|
||||
code = tsdbReadDelData(pDelFReader, pIdx, pDelData, NULL);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2540,10 +2576,10 @@ void updateSchema(TSDBROW* pRow, uint64_t uid, STsdbReader* pReader) {
|
|||
int32_t sversion = TSDBROW_SVERSION(pRow);
|
||||
|
||||
if (pReader->pSchema == NULL) {
|
||||
pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, uid, sversion);
|
||||
metaGetTbTSchemaEx(pReader->pTsdb->pVnode->pMeta, pReader->suid, uid, sversion, &pReader->pSchema);
|
||||
} else if (pReader->pSchema->version != sversion) {
|
||||
taosMemoryFreeClear(pReader->pSchema);
|
||||
pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, uid, sversion);
|
||||
metaGetTbTSchemaEx(pReader->pTsdb->pVnode->pMeta, pReader->suid, uid, sversion, &pReader->pSchema);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2771,7 +2807,6 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
|
|||
|
||||
if (pCond->suid != 0) {
|
||||
(*ppReader)->pSchema = metaGetTbTSchema((*ppReader)->pTsdb->pVnode->pMeta, (*ppReader)->suid, -1);
|
||||
ASSERT((*ppReader)->pSchema);
|
||||
} else if (taosArrayGetSize(pTableList) > 0) {
|
||||
STableKeyInfo* pKey = taosArrayGet(pTableList, 0);
|
||||
(*ppReader)->pSchema = metaGetTbTSchema((*ppReader)->pTsdb->pVnode->pMeta, pKey->uid, -1);
|
||||
|
@ -2795,7 +2830,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
|
|||
|
||||
SDataBlockIter* pBlockIter = &pReader->status.blockIter;
|
||||
|
||||
STsdbFSState* pFState = pReader->pTsdb->fs->cState;
|
||||
STsdbFSState* pFState = pReader->pTsdb->pFS->cState;
|
||||
initFilesetIterator(&pReader->status.fileIter, pFState, pReader->order, pReader->idStr);
|
||||
resetDataBlockIterator(&pReader->status.blockIter, pReader->order);
|
||||
|
||||
|
@ -2809,6 +2844,8 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
|
|||
}
|
||||
}
|
||||
|
||||
tsdbTakeMemSnapshot(pReader->pTsdb, &pReader->pMem, &pReader->pIMem);
|
||||
|
||||
tsdbDebug("%p total numOfTable:%d in this query %s", pReader, numOfTables, pReader->idStr);
|
||||
return code;
|
||||
|
||||
|
@ -2824,6 +2861,8 @@ void tsdbReaderClose(STsdbReader* pReader) {
|
|||
|
||||
SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo;
|
||||
|
||||
tsdbUntakeMemSnapshot(pReader->pTsdb, pReader->pMem, pReader->pIMem);
|
||||
|
||||
taosMemoryFreeClear(pSupInfo->plist);
|
||||
taosMemoryFree(pSupInfo->colIds);
|
||||
|
||||
|
@ -3042,7 +3081,7 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
|
|||
|
||||
tsdbDataFReaderClose(&pReader->pFileReader);
|
||||
|
||||
STsdbFSState* pFState = pReader->pTsdb->fs->cState;
|
||||
STsdbFSState* pFState = pReader->pTsdb->pFS->cState;
|
||||
initFilesetIterator(&pReader->status.fileIter, pFState, pReader->order, pReader->idStr);
|
||||
resetDataBlockIterator(&pReader->status.blockIter, pReader->order);
|
||||
resetDataBlockScanInfo(pReader->status.pTableMap);
|
||||
|
|
|
@ -246,7 +246,7 @@ int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb
|
|||
|
||||
tsdbDelFileName(pTsdb, pFile, fname);
|
||||
pDelFReader->pReadH = taosOpenFile(fname, TD_FILE_READ);
|
||||
if (pDelFReader == NULL) {
|
||||
if (pDelFReader->pReadH == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
taosMemoryFree(pDelFReader);
|
||||
goto _err;
|
||||
|
|
|
@ -20,10 +20,10 @@ static int32_t tsdbDoRetentionImpl(STsdb *pTsdb, int64_t now, int8_t try, int8_t
|
|||
STsdbFSState *pState;
|
||||
|
||||
if (try) {
|
||||
pState = pTsdb->fs->cState;
|
||||
pState = pTsdb->pFS->cState;
|
||||
*canDo = 0;
|
||||
} else {
|
||||
pState = pTsdb->fs->nState;
|
||||
pState = pTsdb->pFS->nState;
|
||||
}
|
||||
|
||||
for (int32_t iSet = 0; iSet < taosArrayGetSize(pState->aDFileSet); iSet++) {
|
||||
|
@ -83,7 +83,7 @@ int32_t tsdbDoRetention(STsdb *pTsdb, int64_t now) {
|
|||
if (!canDo) goto _exit;
|
||||
|
||||
// begin
|
||||
code = tsdbFSBegin(pTsdb->fs);
|
||||
code = tsdbFSBegin(pTsdb->pFS);
|
||||
if (code) goto _err;
|
||||
|
||||
// do retention
|
||||
|
@ -91,7 +91,7 @@ int32_t tsdbDoRetention(STsdb *pTsdb, int64_t now) {
|
|||
if (code) goto _err;
|
||||
|
||||
// commit
|
||||
code = tsdbFSCommit(pTsdb->fs);
|
||||
code = tsdbFSCommit(pTsdb->pFS);
|
||||
if (code) goto _err;
|
||||
|
||||
_exit:
|
||||
|
@ -99,6 +99,6 @@ _exit:
|
|||
|
||||
_err:
|
||||
tsdbError("vgId:%d tsdb do retention failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
|
||||
tsdbFSRollback(pTsdb->fs);
|
||||
tsdbFSRollback(pTsdb->pFS);
|
||||
return code;
|
||||
}
|
|
@ -45,7 +45,7 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) {
|
|||
|
||||
while (true) {
|
||||
if (pReader->pDataFReader == NULL) {
|
||||
SDFileSet* pSet = tsdbFSStateGetDFileSet(pTsdb->fs->cState, pReader->fid, TD_GT);
|
||||
SDFileSet* pSet = tsdbFSStateGetDFileSet(pTsdb->pFS->cState, pReader->fid, TD_GT);
|
||||
|
||||
if (pSet == NULL) goto _exit;
|
||||
|
||||
|
@ -159,7 +159,7 @@ _err:
|
|||
static int32_t tsdbSnapReadDel(STsdbSnapReader* pReader, uint8_t** ppData) {
|
||||
int32_t code = 0;
|
||||
STsdb* pTsdb = pReader->pTsdb;
|
||||
SDelFile* pDelFile = pTsdb->fs->cState->pDelFile;
|
||||
SDelFile* pDelFile = pTsdb->pFS->cState->pDelFile;
|
||||
|
||||
if (pReader->pDelFReader == NULL) {
|
||||
if (pDelFile == NULL) {
|
||||
|
@ -798,7 +798,7 @@ static int32_t tsdbSnapWriteDataEnd(STsdbSnapWriter* pWriter) {
|
|||
code = tsdbWriteBlockIdx(pWriter->pDataFWriter, pWriter->aBlockIdxW, NULL);
|
||||
if (code) goto _err;
|
||||
|
||||
code = tsdbFSStateUpsertDFileSet(pTsdb->fs->nState, tsdbDataFWriterGetWSet(pWriter->pDataFWriter));
|
||||
code = tsdbFSStateUpsertDFileSet(pTsdb->pFS->nState, tsdbDataFWriterGetWSet(pWriter->pDataFWriter));
|
||||
if (code) goto _err;
|
||||
|
||||
code = tsdbDataFWriterClose(&pWriter->pDataFWriter, 1);
|
||||
|
@ -843,7 +843,7 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3
|
|||
pWriter->fid = fid;
|
||||
|
||||
// read
|
||||
SDFileSet* pSet = tsdbFSStateGetDFileSet(pTsdb->fs->nState, fid, TD_EQ);
|
||||
SDFileSet* pSet = tsdbFSStateGetDFileSet(pTsdb->pFS->nState, fid, TD_EQ);
|
||||
if (pSet) {
|
||||
code = tsdbDataFReaderOpen(&pWriter->pDataFReader, pTsdb, pSet);
|
||||
if (code) goto _err;
|
||||
|
@ -907,7 +907,7 @@ static int32_t tsdbSnapWriteDel(STsdbSnapWriter* pWriter, uint8_t* pData, uint32
|
|||
STsdb* pTsdb = pWriter->pTsdb;
|
||||
|
||||
if (pWriter->pDelFWriter == NULL) {
|
||||
SDelFile* pDelFile = tsdbFSStateGetDelFile(pTsdb->fs->nState);
|
||||
SDelFile* pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->nState);
|
||||
|
||||
// reader
|
||||
if (pDelFile) {
|
||||
|
@ -1017,7 +1017,7 @@ static int32_t tsdbSnapWriteDelEnd(STsdbSnapWriter* pWriter) {
|
|||
code = tsdbUpdateDelFileHdr(pWriter->pDelFWriter);
|
||||
if (code) goto _err;
|
||||
|
||||
code = tsdbFSStateUpsertDelFile(pTsdb->fs->nState, &pWriter->pDelFWriter->fDel);
|
||||
code = tsdbFSStateUpsertDelFile(pTsdb->pFS->nState, &pWriter->pDelFWriter->fDel);
|
||||
if (code) goto _err;
|
||||
|
||||
code = tsdbDelFWriterClose(&pWriter->pDelFWriter, 1);
|
||||
|
@ -1096,7 +1096,7 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
|
|||
goto _err;
|
||||
}
|
||||
|
||||
code = tsdbFSBegin(pTsdb->fs);
|
||||
code = tsdbFSBegin(pTsdb->pFS);
|
||||
if (code) goto _err;
|
||||
|
||||
*ppWriter = pWriter;
|
||||
|
@ -1113,7 +1113,7 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) {
|
|||
STsdbSnapWriter* pWriter = *ppWriter;
|
||||
|
||||
if (rollback) {
|
||||
code = tsdbFSRollback(pWriter->pTsdb->fs);
|
||||
code = tsdbFSRollback(pWriter->pTsdb->pFS);
|
||||
if (code) goto _err;
|
||||
} else {
|
||||
code = tsdbSnapWriteDataEnd(pWriter);
|
||||
|
@ -1122,7 +1122,7 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) {
|
|||
code = tsdbSnapWriteDelEnd(pWriter);
|
||||
if (code) goto _err;
|
||||
|
||||
code = tsdbFSCommit(pWriter->pTsdb->fs);
|
||||
code = tsdbFSCommit(pWriter->pTsdb->pFS);
|
||||
if (code) goto _err;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
/* ------------------------ STRUCTURES ------------------------ */
|
||||
|
||||
static int vnodeBufPoolCreate(int64_t size, SVBufPool **ppPool);
|
||||
static int vnodeBufPoolCreate(SVnode *pVnode, int64_t size, SVBufPool **ppPool);
|
||||
static int vnodeBufPoolDestroy(SVBufPool *pPool);
|
||||
|
||||
int vnodeOpenBufPool(SVnode *pVnode, int64_t size) {
|
||||
|
@ -28,7 +28,7 @@ int vnodeOpenBufPool(SVnode *pVnode, int64_t size) {
|
|||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
// create pool
|
||||
ret = vnodeBufPoolCreate(size, &pPool);
|
||||
ret = vnodeBufPoolCreate(pVnode, size, &pPool);
|
||||
if (ret < 0) {
|
||||
vError("vgId:%d, failed to open vnode buffer pool since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
vnodeCloseBufPool(pVnode);
|
||||
|
@ -120,7 +120,7 @@ void vnodeBufPoolFree(SVBufPool *pPool, void *p) {
|
|||
}
|
||||
|
||||
// STATIC METHODS -------------------
|
||||
static int vnodeBufPoolCreate(int64_t size, SVBufPool **ppPool) {
|
||||
static int vnodeBufPoolCreate(SVnode *pVnode, int64_t size, SVBufPool **ppPool) {
|
||||
SVBufPool *pPool;
|
||||
|
||||
pPool = taosMemoryMalloc(sizeof(SVBufPool) + size);
|
||||
|
@ -130,6 +130,7 @@ static int vnodeBufPoolCreate(int64_t size, SVBufPool **ppPool) {
|
|||
}
|
||||
|
||||
pPool->next = NULL;
|
||||
pPool->pVnode = pVnode;
|
||||
pPool->nRef = 0;
|
||||
pPool->size = 0;
|
||||
pPool->ptr = pPool->node.data;
|
||||
|
@ -146,4 +147,26 @@ static int vnodeBufPoolDestroy(SVBufPool *pPool) {
|
|||
vnodeBufPoolReset(pPool);
|
||||
taosMemoryFree(pPool);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vnodeBufPoolRef(SVBufPool *pPool) {
|
||||
int32_t nRef = atomic_fetch_add_32(&pPool->nRef, 1);
|
||||
ASSERT(nRef > 0);
|
||||
}
|
||||
|
||||
void vnodeBufPoolUnRef(SVBufPool *pPool) {
|
||||
int32_t nRef = atomic_sub_fetch_32(&pPool->nRef, 1);
|
||||
if (nRef == 0) {
|
||||
SVnode *pVnode = pPool->pVnode;
|
||||
|
||||
vnodeBufPoolReset(pPool);
|
||||
|
||||
taosThreadMutexLock(&pVnode->mutex);
|
||||
|
||||
pPool->next = pVnode->pPool;
|
||||
pVnode->pPool = pPool;
|
||||
taosThreadCondSignal(&pVnode->poolNotEmpty);
|
||||
|
||||
taosThreadMutexUnlock(&pVnode->mutex);
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include "vnd.h"
|
||||
|
||||
#define VND_INFO_FNAME "vnode.json"
|
||||
#define VND_INFO_FNAME "vnode.json"
|
||||
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
|
||||
|
||||
static int vnodeEncodeInfo(const SVnodeInfo *pInfo, char **ppData);
|
||||
|
@ -27,18 +27,18 @@ static void vnodeWaitCommit(SVnode *pVnode);
|
|||
|
||||
int vnodeBegin(SVnode *pVnode) {
|
||||
// alloc buffer pool
|
||||
/* pthread_mutex_lock(); */
|
||||
taosThreadMutexLock(&pVnode->mutex);
|
||||
|
||||
while (pVnode->pPool == NULL) {
|
||||
/* pthread_cond_wait(); */
|
||||
taosThreadCondWait(&pVnode->poolNotEmpty, &pVnode->mutex);
|
||||
}
|
||||
|
||||
pVnode->inUse = pVnode->pPool;
|
||||
pVnode->inUse->nRef = 1;
|
||||
pVnode->pPool = pVnode->inUse->next;
|
||||
pVnode->inUse->next = NULL;
|
||||
/* ref pVnode->inUse buffer pool */
|
||||
|
||||
/* pthread_mutex_unlock(); */
|
||||
taosThreadMutexUnlock(&pVnode->mutex);
|
||||
|
||||
pVnode->state.commitID++;
|
||||
// begin meta
|
||||
|
@ -217,7 +217,7 @@ int vnodeCommit(SVnode *pVnode) {
|
|||
vInfo("vgId:%d, start to commit, commit ID:%" PRId64 " version:%" PRId64, TD_VID(pVnode), pVnode->state.commitID,
|
||||
pVnode->state.applied);
|
||||
|
||||
pVnode->onCommit = pVnode->inUse;
|
||||
vnodeBufPoolUnRef(pVnode->inUse);
|
||||
pVnode->inUse = NULL;
|
||||
|
||||
// save info
|
||||
|
@ -284,10 +284,6 @@ int vnodeCommit(SVnode *pVnode) {
|
|||
|
||||
// apply the commit (TODO)
|
||||
walEndSnapshot(pVnode->pWal);
|
||||
vnodeBufPoolReset(pVnode->onCommit);
|
||||
pVnode->onCommit->next = pVnode->pPool;
|
||||
pVnode->pPool = pVnode->onCommit;
|
||||
pVnode->onCommit = NULL;
|
||||
|
||||
vInfo("vgId:%d, commit over", TD_VID(pVnode));
|
||||
|
||||
|
|
|
@ -89,6 +89,8 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
|||
|
||||
tsem_init(&pVnode->syncSem, 0, 0);
|
||||
tsem_init(&(pVnode->canCommit), 0, 1);
|
||||
taosThreadMutexInit(&pVnode->mutex, NULL);
|
||||
taosThreadCondInit(&pVnode->poolNotEmpty, NULL);
|
||||
|
||||
// open buffer pool
|
||||
if (vnodeOpenBufPool(pVnode, pVnode->config.isHeap ? 0 : pVnode->config.szBuf / 3) < 0) {
|
||||
|
@ -195,6 +197,8 @@ void vnodeClose(SVnode *pVnode) {
|
|||
// destroy handle
|
||||
tsem_destroy(&(pVnode->canCommit));
|
||||
tsem_destroy(&pVnode->syncSem);
|
||||
taosThreadCondDestroy(&pVnode->poolNotEmpty);
|
||||
taosThreadMutexDestroy(&pVnode->mutex);
|
||||
taosMemoryFree(pVnode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ struct SVSnapReader {
|
|||
// tsdb
|
||||
int8_t tsdbDone;
|
||||
STsdbSnapReader *pTsdbReader;
|
||||
// rsma
|
||||
int8_t rsmaDone[TSDB_RETENTION_L2];
|
||||
};
|
||||
|
||||
int32_t vnodeSnapReaderOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapReader **ppReader) {
|
||||
|
@ -115,6 +117,42 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
|
|||
}
|
||||
}
|
||||
|
||||
// RSMA ==============
|
||||
#if 0
|
||||
if (VND_IS_RSMA(pReader->pVnode)) {
|
||||
// RSMA1/RSMA2
|
||||
for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
|
||||
if (!pReader->rsmaDone[i]) {
|
||||
if (!pReader->pVnode->pSma->pRSmaTsdb[i]) {
|
||||
// no valid tsdb
|
||||
pReader->rsmaDone[i] = 1;
|
||||
continue;
|
||||
}
|
||||
if (pReader->pTsdbReader == NULL) {
|
||||
code = tsdbSnapReaderOpen(pReader->pVnode->pSma->pRSmaTsdb[i], pReader->sver, pReader->ever,
|
||||
&pReader->pTsdbReader);
|
||||
if (code) goto _err;
|
||||
}
|
||||
|
||||
code = tsdbSnapRead(pReader->pTsdbReader, ppData);
|
||||
if (code) {
|
||||
goto _err;
|
||||
} else {
|
||||
if (*ppData) {
|
||||
goto _exit;
|
||||
} else {
|
||||
pReader->tsdbDone = 1;
|
||||
code = tsdbSnapReaderClose(&pReader->pTsdbReader);
|
||||
if (code) goto _err;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// QTaskInfoFile
|
||||
// TODO ...
|
||||
}
|
||||
#endif
|
||||
|
||||
*ppData = NULL;
|
||||
*nData = 0;
|
||||
|
||||
|
|
|
@ -557,6 +557,7 @@ static int32_t vnodeProcessDropStbReq(SVnode *pVnode, int64_t version, void *pRe
|
|||
SVDropStbReq req = {0};
|
||||
int32_t rcode = TSDB_CODE_SUCCESS;
|
||||
SDecoder decoder = {0};
|
||||
SArray *tbUidList = NULL;
|
||||
|
||||
pRsp->msgType = TDMT_VND_CREATE_STB_RSP;
|
||||
pRsp->pCont = NULL;
|
||||
|
@ -570,7 +571,14 @@ static int32_t vnodeProcessDropStbReq(SVnode *pVnode, int64_t version, void *pRe
|
|||
}
|
||||
|
||||
// process request
|
||||
if (metaDropSTable(pVnode->pMeta, version, &req) < 0) {
|
||||
tbUidList = taosArrayInit(8, sizeof(int64_t));
|
||||
if (tbUidList == NULL) goto _exit;
|
||||
if (metaDropSTable(pVnode->pMeta, version, &req, tbUidList) < 0) {
|
||||
rcode = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
if (tqUpdateTbUidList(pVnode->pTq, tbUidList, false) < 0) {
|
||||
rcode = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
@ -582,6 +590,7 @@ static int32_t vnodeProcessDropStbReq(SVnode *pVnode, int64_t version, void *pRe
|
|||
|
||||
// return rsp
|
||||
_exit:
|
||||
if (tbUidList) taosArrayDestroy(tbUidList);
|
||||
pRsp->code = rcode;
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
|
@ -869,6 +878,8 @@ _exit:
|
|||
tdProcessRSmaSubmit(pVnode->pSma, pReq, STREAM_INPUT__DATA_SUBMIT);
|
||||
}
|
||||
|
||||
vDebug("successful submit in vg %d version %ld", pVnode->config.vgId, version);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -532,6 +532,14 @@ typedef struct SCtgOperation {
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define CTG_API_JENTER() do { \
|
||||
CTG_API_DEBUG("CTG API enter %s", __FUNCTION__); \
|
||||
CTG_LOCK(CTG_READ, &gCtgMgmt.lock); \
|
||||
if (atomic_load_8((int8_t*)&gCtgMgmt.exit)) { \
|
||||
CTG_ERR_JRET(TSDB_CODE_CTG_OUT_OF_SERVICE); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define CTG_API_LEAVE_NOLOCK(c) do { \
|
||||
int32_t __code = c; \
|
||||
|
|
|
@ -244,10 +244,11 @@ int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize,
|
|||
int32_t ctgHandleMsgCallback(void *param, SDataBuf *pMsg, int32_t rspCode) {
|
||||
SCtgTaskCallbackParam* cbParam = (SCtgTaskCallbackParam*)param;
|
||||
int32_t code = 0;
|
||||
SCtgJob* pJob = NULL;
|
||||
|
||||
CTG_API_ENTER();
|
||||
CTG_API_JENTER();
|
||||
|
||||
SCtgJob* pJob = taosAcquireRef(gCtgMgmt.jobPool, cbParam->refId);
|
||||
pJob = taosAcquireRef(gCtgMgmt.jobPool, cbParam->refId);
|
||||
if (NULL == pJob) {
|
||||
qDebug("ctg job refId 0x%" PRIx64 " already dropped", cbParam->refId);
|
||||
goto _return;
|
||||
|
@ -266,8 +267,6 @@ _return:
|
|||
if (pJob) {
|
||||
taosReleaseRef(gCtgMgmt.jobPool, cbParam->refId);
|
||||
}
|
||||
|
||||
taosMemoryFree(param);
|
||||
|
||||
CTG_API_LEAVE(code);
|
||||
}
|
||||
|
@ -293,6 +292,7 @@ int32_t ctgMakeMsgSendInfo(SCtgTask* pTask, int32_t msgType, SMsgSendInfo **pMsg
|
|||
param->taskId = pTask->taskId;
|
||||
|
||||
msgSendInfo->param = param;
|
||||
msgSendInfo->paramFreeFp = taosMemoryFree;
|
||||
msgSendInfo->fp = ctgHandleMsgCallback;
|
||||
|
||||
*pMsgSendInfo = msgSendInfo;
|
||||
|
|
|
@ -159,27 +159,28 @@ typedef struct {
|
|||
int64_t recoverEndVer;
|
||||
} SStreamTaskInfo;
|
||||
|
||||
typedef struct {
|
||||
char* tablename;
|
||||
char* dbname;
|
||||
int32_t tversion;
|
||||
SSchemaWrapper* sw;
|
||||
} SSchemaInfo;
|
||||
|
||||
typedef struct SExecTaskInfo {
|
||||
STaskIdInfo id;
|
||||
uint32_t status;
|
||||
STimeWindow window;
|
||||
STaskCostInfo cost;
|
||||
int64_t owner; // if it is in execution
|
||||
int32_t code;
|
||||
STaskIdInfo id;
|
||||
uint32_t status;
|
||||
STimeWindow window;
|
||||
STaskCostInfo cost;
|
||||
int64_t owner; // if it is in execution
|
||||
int32_t code;
|
||||
|
||||
SStreamTaskInfo streamInfo;
|
||||
|
||||
struct {
|
||||
char* tablename;
|
||||
char* dbname;
|
||||
int32_t tversion;
|
||||
SSchemaWrapper* sw;
|
||||
} schemaVer;
|
||||
|
||||
STableListInfo tableqinfoList; // this is a table list
|
||||
const char* sql; // query sql string
|
||||
jmp_buf env; // jump to this position when error happens.
|
||||
EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model]
|
||||
SStreamTaskInfo streamInfo;
|
||||
SSchemaInfo schemaInfo;
|
||||
STableListInfo tableqinfoList; // this is a table list
|
||||
const char* sql; // query sql string
|
||||
jmp_buf env; // jump to this position when error happens.
|
||||
EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model]
|
||||
SSubplan* pSubplan;
|
||||
struct SOperatorInfo* pRoot;
|
||||
} SExecTaskInfo;
|
||||
|
||||
|
@ -248,13 +249,13 @@ typedef struct SLoadRemoteDataInfo {
|
|||
} SLoadRemoteDataInfo;
|
||||
|
||||
typedef struct SLimitInfo {
|
||||
SLimit limit;
|
||||
SLimit slimit;
|
||||
uint64_t currentGroupId;
|
||||
int64_t remainGroupOffset;
|
||||
int64_t numOfOutputGroups;
|
||||
int64_t remainOffset;
|
||||
int64_t numOfOutputRows;
|
||||
SLimit limit;
|
||||
SLimit slimit;
|
||||
uint64_t currentGroupId;
|
||||
int64_t remainGroupOffset;
|
||||
int64_t numOfOutputGroups;
|
||||
int64_t remainOffset;
|
||||
int64_t numOfOutputRows;
|
||||
} SLimitInfo;
|
||||
|
||||
typedef struct SExchangeInfo {
|
||||
|
@ -743,8 +744,8 @@ typedef struct SSortOperatorInfo {
|
|||
|
||||
int64_t startTs; // sort start time
|
||||
uint64_t sortElapsed; // sort elapsed time, time to flush to disk not included.
|
||||
|
||||
SNode* pCondition;
|
||||
SLimitInfo limitInfo;
|
||||
SNode* pCondition;
|
||||
} SSortOperatorInfo;
|
||||
|
||||
typedef struct STagFilterOperatorInfo {
|
||||
|
@ -784,7 +785,7 @@ int32_t initExprSupp(SExprSupp* pSup, SExprInfo* pExprInfo, int32_t numOfExpr);
|
|||
void cleanupExprSupp(SExprSupp* pSup);
|
||||
int32_t initAggInfo(SExprSupp *pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, size_t keyBufSize,
|
||||
const char* pkey);
|
||||
void initResultSizeInfo(SOperatorInfo* pOperator, int32_t numOfRows);
|
||||
void initResultSizeInfo(SResultInfo * pResultInfo, int32_t numOfRows);
|
||||
void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SGroupResInfo* pGroupResInfo, SDiskbasedBuf* pBuf);
|
||||
int32_t handleLimitOffset(SOperatorInfo *pOperator, SLimitInfo* pLimitInfo, SSDataBlock* pBlock, bool holdDataInBuf);
|
||||
bool hasLimitOffsetInfo(SLimitInfo* pLimitInfo);
|
||||
|
@ -796,7 +797,7 @@ void doApplyFunctions(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, STimeWin
|
|||
int32_t extractDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadInfo, int32_t numOfRows, char* pData,
|
||||
int32_t compLen, int32_t numOfOutput, int64_t startTs, uint64_t* total,
|
||||
SArray* pColList);
|
||||
void getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int64_t key, STimeWindow* win);
|
||||
STimeWindow getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int64_t key);
|
||||
STimeWindow getFirstQualifiedTimeWindow(int64_t ts, STimeWindow* pWindow, SInterval* pInterval, int32_t order);
|
||||
|
||||
int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t *order, int32_t* scanFlag);
|
||||
|
|
|
@ -50,7 +50,7 @@ SOperatorInfo* createLastrowScanOperator(SLastRowScanPhysiNode* pScanNode, SRead
|
|||
|
||||
STableListInfo* pTableList = &pTaskInfo->tableqinfoList;
|
||||
|
||||
initResultSizeInfo(pOperator, 1024);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 1024);
|
||||
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||
pInfo->pUidList = taosArrayInit(4, sizeof(int64_t));
|
||||
|
||||
|
@ -227,14 +227,14 @@ int32_t extractTargetSlotId(const SArray* pColMatchInfo, SExecTaskInfo* pTaskInf
|
|||
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
SColMatchInfo* pColMatch = taosArrayGet(pColMatchInfo, i);
|
||||
for (int32_t j = 0; j < pTaskInfo->schemaVer.sw->nCols; ++j) {
|
||||
if (pColMatch->colId == pTaskInfo->schemaVer.sw->pSchema[j].colId &&
|
||||
for (int32_t j = 0; j < pTaskInfo->schemaInfo.sw->nCols; ++j) {
|
||||
if (pColMatch->colId == pTaskInfo->schemaInfo.sw->pSchema[j].colId &&
|
||||
pColMatch->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||
(*pSlotIds)[pColMatch->targetSlotId] = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (pColMatch->colId == pTaskInfo->schemaVer.sw->pSchema[j].colId) {
|
||||
if (pColMatch->colId == pTaskInfo->schemaInfo.sw->pSchema[j].colId) {
|
||||
(*pSlotIds)[pColMatch->targetSlotId] = j;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -67,15 +67,15 @@ static bool needCompress(const SSDataBlock* pData, int32_t numOfCols) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
// data format:
|
||||
// +----------------+--------------+----------+--------------------------------------------+--------------------------------------+-------------+-----------+-------------+-----------+
|
||||
// |SDataCacheEntry | total length | group id | col1_schema | col2_schema | col3_schema ...| column#1 length, column#2
|
||||
// length ... | col1 bitmap | col1 data | col2 bitmap | col2 data | .... | | (4 bytes) |(8 bytes)
|
||||
// |(sizeof(int16_t)+sizeof(int32_t))*numOfCols | sizeof(int32_t) * numOfCols | actual size | |
|
||||
// actual size | |
|
||||
// +----------------+--------------+----------+--------------------------------------------+--------------------------------------+-------------+-----------+-------------+-----------+
|
||||
// +----------------+--------------+-----------------+--------------------------------------------+------------------------------------+-------------+-----------+-------------+-----------+
|
||||
// |SDataCacheEntry | total length | group id | col1_schema | col2_schema | col3_schema... | column#1 length, column#2 length...| col1 bitmap | col1 data | col2 bitmap | col2 data | .... | | (4 bytes) |(8 bytes)
|
||||
// | |sizeof(int32) |sizeof(uint64_t) |(sizeof(int16_t)+sizeof(int32_t))*numOfCols | sizeof(int32_t) * numOfCols | actual size | |
|
||||
// +----------------+--------------+-----------------+--------------------------------------------+------------------------------------+-------------+-----------+-------------+-----------+
|
||||
// The length of bitmap is decided by number of rows of this data block, and the length of each column data is
|
||||
// recorded in the first segment, next to the struct header
|
||||
// clang-format on
|
||||
static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pInput, SDataDispatchBuf* pBuf) {
|
||||
int32_t numOfCols = 0;
|
||||
SNode* pNode;
|
||||
|
|
|
@ -91,7 +91,6 @@ _return:
|
|||
tsem_post(&pInserter->ready);
|
||||
|
||||
taosMemoryFree(pMsg->pData);
|
||||
taosMemoryFree(param);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -110,6 +109,7 @@ static int32_t sendSubmitRequest(SDataInserterHandle* pInserter, SSubmitReq* pMs
|
|||
pParam->pInserter = pInserter;
|
||||
|
||||
pMsgSendInfo->param = pParam;
|
||||
pMsgSendInfo->paramFreeFp = taosMemoryFree;
|
||||
pMsgSendInfo->msgInfo.pData = pMsg;
|
||||
pMsgSendInfo->msgInfo.len = ntohl(pMsg->length);
|
||||
pMsgSendInfo->msgType = TDMT_VND_SUBMIT;
|
||||
|
|
|
@ -824,10 +824,10 @@ int32_t convertFillType(int32_t mode) {
|
|||
|
||||
static void getInitialStartTimeWindow(SInterval* pInterval, TSKEY ts, STimeWindow* w, bool ascQuery) {
|
||||
if (ascQuery) {
|
||||
getAlignQueryTimeWindow(pInterval, pInterval->precision, ts, w);
|
||||
*w = getAlignQueryTimeWindow(pInterval, pInterval->precision, ts);
|
||||
} else {
|
||||
// the start position of the first time window in the endpoint that spreads beyond the queried last timestamp
|
||||
getAlignQueryTimeWindow(pInterval, pInterval->precision, ts, w);
|
||||
*w = getAlignQueryTimeWindow(pInterval, pInterval->precision, ts);
|
||||
|
||||
int64_t key = w->skey;
|
||||
while (key < ts) { // moving towards end
|
||||
|
@ -842,30 +842,10 @@ static void getInitialStartTimeWindow(SInterval* pInterval, TSKEY ts, STimeWindo
|
|||
}
|
||||
|
||||
static STimeWindow doCalculateTimeWindow(int64_t ts, SInterval* pInterval) {
|
||||
STimeWindow w = {0};
|
||||
|
||||
if (pInterval->intervalUnit == 'n' || pInterval->intervalUnit == 'y') {
|
||||
w.skey = taosTimeTruncate(ts, pInterval, pInterval->precision);
|
||||
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
|
||||
} else {
|
||||
int64_t st = w.skey;
|
||||
if (pInterval->offset > 0) {
|
||||
st = taosTimeAdd(st, pInterval->offset, pInterval->offsetUnit, pInterval->precision);
|
||||
}
|
||||
|
||||
if (st > ts) {
|
||||
st -= ((st - ts + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding;
|
||||
}
|
||||
|
||||
int64_t et = st + pInterval->interval - 1;
|
||||
if (et < ts) {
|
||||
st += ((ts - et + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding;
|
||||
}
|
||||
|
||||
w.skey = st;
|
||||
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
|
||||
}
|
||||
STimeWindow w = {0};
|
||||
|
||||
w.skey = taosTimeTruncate(ts, pInterval, pInterval->precision);
|
||||
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
|
||||
return w;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,17 +42,32 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
|||
|
||||
// TODO: if a block was set but not consumed,
|
||||
// prevent setting a different type of block
|
||||
pInfo->blockType = type;
|
||||
pInfo->validBlockIndex = 0;
|
||||
taosArrayClear(pInfo->pBlockLists);
|
||||
|
||||
if (type == STREAM_INPUT__DATA_SUBMIT) {
|
||||
if (tqReaderSetDataMsg(pInfo->tqReader, input, 0) < 0) {
|
||||
qError("submit msg messed up when initing stream block, %s" PRIx64, id);
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
if (type == STREAM_INPUT__MERGED_SUBMIT) {
|
||||
ASSERT(numOfBlocks > 1);
|
||||
for (int32_t i = 0; i < numOfBlocks; i++) {
|
||||
SSubmitReq* pReq = *(void**)POINTER_SHIFT(input, i * sizeof(void*));
|
||||
taosArrayPush(pInfo->pBlockLists, &pReq);
|
||||
}
|
||||
pInfo->blockType = STREAM_INPUT__DATA_SUBMIT;
|
||||
} else if (type == STREAM_INPUT__DATA_SUBMIT) {
|
||||
/*if (tqReaderSetDataMsg(pInfo->tqReader, input, 0) < 0) {*/
|
||||
/*qError("submit msg messed up when initing stream block, %s" PRIx64, id);*/
|
||||
/*return TSDB_CODE_QRY_APP_ERROR;*/
|
||||
/*}*/
|
||||
ASSERT(numOfBlocks == 1);
|
||||
/*if (numOfBlocks == 1) {*/
|
||||
taosArrayPush(pInfo->pBlockLists, &input);
|
||||
pInfo->blockType = STREAM_INPUT__DATA_SUBMIT;
|
||||
/*} else {*/
|
||||
/*}*/
|
||||
} else if (type == STREAM_INPUT__DATA_BLOCK) {
|
||||
for (int32_t i = 0; i < numOfBlocks; ++i) {
|
||||
SSDataBlock* pDataBlock = &((SSDataBlock*)input)[i];
|
||||
|
||||
// TODO optimize
|
||||
SSDataBlock* p = createOneDataBlock(pDataBlock, false);
|
||||
p->info = pDataBlock->info;
|
||||
|
||||
|
@ -60,6 +75,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
|||
taosArrayAddAll(p->pDataBlock, pDataBlock->pDataBlock);
|
||||
taosArrayPush(pInfo->pBlockLists, &p);
|
||||
}
|
||||
pInfo->blockType = STREAM_INPUT__DATA_BLOCK;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
@ -104,27 +120,40 @@ int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numO
|
|||
return code;
|
||||
}
|
||||
|
||||
qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers) {
|
||||
qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* numOfCols) {
|
||||
if (msg == NULL) {
|
||||
// TODO create raw scan
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct SSubplan* plan = NULL;
|
||||
int32_t code = qStringToSubplan(msg, &plan);
|
||||
struct SSubplan* pPlan = NULL;
|
||||
int32_t code = qStringToSubplan(msg, &pPlan);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
terrno = code;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
qTaskInfo_t pTaskInfo = NULL;
|
||||
code = qCreateExecTask(readers, 0, 0, plan, &pTaskInfo, NULL, NULL, OPTR_EXEC_MODEL_QUEUE);
|
||||
code = qCreateExecTask(readers, 0, 0, pPlan, &pTaskInfo, NULL, NULL, OPTR_EXEC_MODEL_QUEUE);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
// TODO: destroy SSubplan & pTaskInfo
|
||||
nodesDestroyNode((SNode*)pPlan);
|
||||
qDestroyTask(pTaskInfo);
|
||||
terrno = code;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// extract the number of output columns
|
||||
SDataBlockDescNode* pDescNode = pPlan->pNode->pOutputDataBlockDesc;
|
||||
*numOfCols = 0;
|
||||
|
||||
SNode* pNode;
|
||||
FOREACH(pNode, pDescNode->pSlots) {
|
||||
SSlotDescNode* pSlotDesc = (SSlotDescNode*)pNode;
|
||||
if (pSlotDesc->output) {
|
||||
++(*numOfCols);
|
||||
}
|
||||
}
|
||||
|
||||
return pTaskInfo;
|
||||
}
|
||||
|
||||
|
@ -135,17 +164,18 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers) {
|
|||
|
||||
/*qDebugL("stream task string %s", (const char*)msg);*/
|
||||
|
||||
struct SSubplan* plan = NULL;
|
||||
int32_t code = qStringToSubplan(msg, &plan);
|
||||
struct SSubplan* pPlan = NULL;
|
||||
int32_t code = qStringToSubplan(msg, &pPlan);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
terrno = code;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
qTaskInfo_t pTaskInfo = NULL;
|
||||
code = qCreateExecTask(readers, 0, 0, plan, &pTaskInfo, NULL, NULL, OPTR_EXEC_MODEL_STREAM);
|
||||
code = qCreateExecTask(readers, 0, 0, pPlan, &pTaskInfo, NULL, NULL, OPTR_EXEC_MODEL_STREAM);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
// TODO: destroy SSubplan & pTaskInfo
|
||||
nodesDestroyNode((SNode*)pPlan);
|
||||
qDestroyTask(pTaskInfo);
|
||||
terrno = code;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -153,7 +183,8 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers) {
|
|||
return pTaskInfo;
|
||||
}
|
||||
|
||||
static SArray* filterQualifiedChildTables(const SStreamScanInfo* pScanInfo, const SArray* tableIdList, const char* idstr) {
|
||||
static SArray* filterQualifiedChildTables(const SStreamScanInfo* pScanInfo, const SArray* tableIdList,
|
||||
const char* idstr) {
|
||||
SArray* qa = taosArrayInit(4, sizeof(tb_uid_t));
|
||||
|
||||
// let's discard the tables those are not created according to the queried super table.
|
||||
|
@ -227,19 +258,19 @@ int32_t qGetQueryTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* table
|
|||
ASSERT(tinfo != NULL && dbName != NULL && tableName != NULL);
|
||||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
||||
|
||||
if (pTaskInfo->schemaVer.sw == NULL) {
|
||||
if (pTaskInfo->schemaInfo.sw == NULL) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
*sversion = pTaskInfo->schemaVer.sw->version;
|
||||
*tversion = pTaskInfo->schemaVer.tversion;
|
||||
if (pTaskInfo->schemaVer.dbname) {
|
||||
strcpy(dbName, pTaskInfo->schemaVer.dbname);
|
||||
*sversion = pTaskInfo->schemaInfo.sw->version;
|
||||
*tversion = pTaskInfo->schemaInfo.tversion;
|
||||
if (pTaskInfo->schemaInfo.dbname) {
|
||||
strcpy(dbName, pTaskInfo->schemaInfo.dbname);
|
||||
} else {
|
||||
dbName[0] = 0;
|
||||
}
|
||||
if (pTaskInfo->schemaVer.tablename) {
|
||||
strcpy(tableName, pTaskInfo->schemaVer.tablename);
|
||||
if (pTaskInfo->schemaInfo.tablename) {
|
||||
strcpy(tableName, pTaskInfo->schemaInfo.tablename);
|
||||
} else {
|
||||
tableName[0] = 0;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId,
|
|||
|
||||
taosThreadOnce(&initPoolOnce, initRefPool);
|
||||
atexit(cleanupRefPool);
|
||||
|
||||
int32_t code = createExecTaskInfoImpl(pSubplan, pTask, readHandle, taskId, sql, model);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
|
|
|
@ -834,18 +834,20 @@ bool isTaskKilled(SExecTaskInfo* pTaskInfo) {
|
|||
void setTaskKilled(SExecTaskInfo* pTaskInfo) { pTaskInfo->code = TSDB_CODE_TSC_QUERY_CANCELLED; }
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// todo refactor : return window
|
||||
void getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int64_t key, STimeWindow* win) {
|
||||
win->skey = taosTimeTruncate(key, pInterval, precision);
|
||||
STimeWindow getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int64_t key) {
|
||||
STimeWindow win = {0};
|
||||
win.skey = taosTimeTruncate(key, pInterval, precision);
|
||||
|
||||
/*
|
||||
* if the realSkey > INT64_MAX - pInterval->interval, the query duration between
|
||||
* realSkey and realEkey must be less than one interval.Therefore, no need to adjust the query ranges.
|
||||
*/
|
||||
win->ekey = taosTimeAdd(win->skey, pInterval->interval, pInterval->intervalUnit, precision) - 1;
|
||||
if (win->ekey < win->skey) {
|
||||
win->ekey = INT64_MAX;
|
||||
win.ekey = taosTimeAdd(win.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1;
|
||||
if (win.ekey < win.skey) {
|
||||
win.ekey = INT64_MAX;
|
||||
}
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -1337,7 +1339,9 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock) {
|
|||
if (pFilterNode == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (pBlock->info.rows == 0) {
|
||||
return;
|
||||
}
|
||||
SFilterInfo* filter = NULL;
|
||||
|
||||
// todo move to the initialization function
|
||||
|
@ -1994,16 +1998,9 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
tsem_post(&pExchangeInfo->ready);
|
||||
taosReleaseRef(exchangeObjRefPool, pWrapper->exchangeId);
|
||||
|
||||
taosMemoryFree(pWrapper);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void destroySendMsgInfo(SMsgSendInfo* pMsgBody) {
|
||||
assert(pMsgBody != NULL);
|
||||
taosMemoryFreeClear(pMsgBody->msgInfo.pData);
|
||||
taosMemoryFreeClear(pMsgBody);
|
||||
}
|
||||
|
||||
void qProcessRspMsg(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
|
||||
SMsgSendInfo* pSendInfo = (SMsgSendInfo*)pMsg->info.ahandle;
|
||||
assert(pMsg->info.ahandle != NULL);
|
||||
|
@ -2063,6 +2060,7 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf
|
|||
pWrapper->sourceIndex = sourceIndex;
|
||||
|
||||
pMsgSendInfo->param = pWrapper;
|
||||
pMsgSendInfo->paramFreeFp = taosMemoryFree;
|
||||
pMsgSendInfo->msgInfo.pData = pMsg;
|
||||
pMsgSendInfo->msgInfo.len = sizeof(SResFetchReq);
|
||||
pMsgSendInfo->msgType = pSource->fetchMsgType;
|
||||
|
@ -3607,13 +3605,13 @@ int32_t initAggInfo(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInf
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void initResultSizeInfo(SOperatorInfo* pOperator, int32_t numOfRows) {
|
||||
void initResultSizeInfo(SResultInfo * pResultInfo, int32_t numOfRows) {
|
||||
ASSERT(numOfRows != 0);
|
||||
pOperator->resultInfo.capacity = numOfRows;
|
||||
pOperator->resultInfo.threshold = numOfRows * 0.75;
|
||||
pResultInfo->capacity = numOfRows;
|
||||
pResultInfo->threshold = numOfRows * 0.75;
|
||||
|
||||
if (pOperator->resultInfo.threshold == 0) {
|
||||
pOperator->resultInfo.threshold = numOfRows;
|
||||
if (pResultInfo->threshold == 0) {
|
||||
pResultInfo->threshold = numOfRows;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3676,7 +3674,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
|||
int32_t numOfRows = 1024;
|
||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||
|
||||
initResultSizeInfo(pOperator, numOfRows);
|
||||
initResultSizeInfo(&pOperator->resultInfo, numOfRows);
|
||||
int32_t code = initAggInfo(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
|
@ -3831,7 +3829,7 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys
|
|||
if (numOfRows * pResBlock->info.rowSize > TWOMB) {
|
||||
numOfRows = TWOMB / pResBlock->info.rowSize;
|
||||
}
|
||||
initResultSizeInfo(pOperator, numOfRows);
|
||||
initResultSizeInfo(&pOperator->resultInfo, numOfRows);
|
||||
|
||||
initAggInfo(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str);
|
||||
initBasicInfo(&pInfo->binfo, pResBlock);
|
||||
|
@ -4009,7 +4007,7 @@ SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhy
|
|||
numOfRows = TWOMB / pResBlock->info.rowSize;
|
||||
}
|
||||
|
||||
initResultSizeInfo(pOperator, numOfRows);
|
||||
initResultSizeInfo(&pOperator->resultInfo, numOfRows);
|
||||
|
||||
initAggInfo(pSup, &pInfo->aggSup, pExprInfo, numOfExpr, keyBufSize, pTaskInfo->id.str);
|
||||
initBasicInfo(&pInfo->binfo, pResBlock);
|
||||
|
@ -4048,8 +4046,7 @@ static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t
|
|||
STimeWindow win, int32_t capacity, const char* id, SInterval* pInterval, int32_t fillType) {
|
||||
SFillColInfo* pColInfo = createFillColInfo(pExpr, numOfCols, pValNode);
|
||||
|
||||
STimeWindow w = TSWINDOW_INITIALIZER;
|
||||
getAlignQueryTimeWindow(pInterval, pInterval->precision, win.skey, &w);
|
||||
STimeWindow w = getAlignQueryTimeWindow(pInterval, pInterval->precision, win.skey);
|
||||
w = getFirstQualifiedTimeWindow(win.skey, &w, pInterval, TSDB_ORDER_ASC);
|
||||
|
||||
int32_t order = TSDB_ORDER_ASC;
|
||||
|
@ -4086,7 +4083,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode*
|
|||
int32_t type = convertFillType(pPhyFillNode->mode);
|
||||
|
||||
SResultInfo* pResultInfo = &pOperator->resultInfo;
|
||||
initResultSizeInfo(pOperator, 4096);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
pInfo->primaryTsCol = ((SColumnNode*)pPhyFillNode->pWStartTs)->slotId;
|
||||
|
||||
int32_t numOfOutputCols = 0;
|
||||
|
@ -4127,7 +4124,7 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId, EOPT
|
|||
SExecTaskInfo* pTaskInfo = taosMemoryCalloc(1, sizeof(SExecTaskInfo));
|
||||
setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED);
|
||||
|
||||
pTaskInfo->schemaVer.dbname = strdup(dbFName);
|
||||
pTaskInfo->schemaInfo.dbname = strdup(dbFName);
|
||||
pTaskInfo->cost.created = taosGetTimestampMs();
|
||||
pTaskInfo->id.queryId = queryId;
|
||||
pTaskInfo->execModel = model;
|
||||
|
@ -4153,35 +4150,35 @@ int32_t extractTableSchemaInfo(SReadHandle* pHandle, uint64_t uid, SExecTaskInfo
|
|||
return terrno;
|
||||
}
|
||||
|
||||
pTaskInfo->schemaVer.tablename = strdup(mr.me.name);
|
||||
pTaskInfo->schemaInfo.tablename = strdup(mr.me.name);
|
||||
|
||||
if (mr.me.type == TSDB_SUPER_TABLE) {
|
||||
pTaskInfo->schemaVer.sw = tCloneSSchemaWrapper(&mr.me.stbEntry.schemaRow);
|
||||
pTaskInfo->schemaVer.tversion = mr.me.stbEntry.schemaTag.version;
|
||||
pTaskInfo->schemaInfo.sw = tCloneSSchemaWrapper(&mr.me.stbEntry.schemaRow);
|
||||
pTaskInfo->schemaInfo.tversion = mr.me.stbEntry.schemaTag.version;
|
||||
} else if (mr.me.type == TSDB_CHILD_TABLE) {
|
||||
tDecoderClear(&mr.coder);
|
||||
|
||||
tb_uid_t suid = mr.me.ctbEntry.suid;
|
||||
metaGetTableEntryByUid(&mr, suid);
|
||||
pTaskInfo->schemaVer.sw = tCloneSSchemaWrapper(&mr.me.stbEntry.schemaRow);
|
||||
pTaskInfo->schemaVer.tversion = mr.me.stbEntry.schemaTag.version;
|
||||
pTaskInfo->schemaInfo.sw = tCloneSSchemaWrapper(&mr.me.stbEntry.schemaRow);
|
||||
pTaskInfo->schemaInfo.tversion = mr.me.stbEntry.schemaTag.version;
|
||||
} else {
|
||||
pTaskInfo->schemaVer.sw = tCloneSSchemaWrapper(&mr.me.ntbEntry.schemaRow);
|
||||
pTaskInfo->schemaInfo.sw = tCloneSSchemaWrapper(&mr.me.ntbEntry.schemaRow);
|
||||
}
|
||||
|
||||
metaReaderClear(&mr);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void cleanupTableSchemaInfo(SExecTaskInfo* pTaskInfo) {
|
||||
taosMemoryFreeClear(pTaskInfo->schemaVer.dbname);
|
||||
if (pTaskInfo->schemaVer.sw == NULL) {
|
||||
static void cleanupTableSchemaInfo(SSchemaInfo* pSchemaInfo) {
|
||||
taosMemoryFreeClear(pSchemaInfo->dbname);
|
||||
if (pSchemaInfo->sw == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
taosMemoryFree(pTaskInfo->schemaVer.sw->pSchema);
|
||||
taosMemoryFree(pTaskInfo->schemaVer.sw);
|
||||
taosMemoryFree(pTaskInfo->schemaVer.tablename);
|
||||
taosMemoryFree(pSchemaInfo->tablename);
|
||||
taosMemoryFree(pSchemaInfo->sw->pSchema);
|
||||
taosMemoryFree(pSchemaInfo->sw);
|
||||
}
|
||||
|
||||
static int32_t sortTableGroup(STableListInfo* pTableListInfo, int32_t groupNum) {
|
||||
|
@ -4424,7 +4421,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
.calTrigger = pTableScanNode->triggerType,
|
||||
.maxTs = INT64_MIN,
|
||||
};
|
||||
if (pHandle) {
|
||||
if (pHandle->vnode) {
|
||||
int32_t code = createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags,
|
||||
pTableScanNode->groupSort, pHandle, pTableListInfo, pTagCond, pTagIndexCond, GET_TASKID(pTaskInfo));
|
||||
if (code) {
|
||||
|
@ -4590,7 +4587,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
int32_t children = 0;
|
||||
pOptr = createStreamFinalIntervalOperatorInfo(ops[0], pPhyNode, pTaskInfo, children);
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL == type) {
|
||||
int32_t children = 1;
|
||||
int32_t children = pHandle->numOfVgroups;
|
||||
pOptr = createStreamFinalIntervalOperatorInfo(ops[0], pPhyNode, pTaskInfo, children);
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_SORT == type) {
|
||||
pOptr = createSortOperatorInfo(ops[0], (SSortPhysiNode*)pPhyNode, pTaskInfo);
|
||||
|
@ -4939,6 +4936,7 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead
|
|||
}
|
||||
|
||||
(*pTaskInfo)->sql = sql;
|
||||
(*pTaskInfo)->pSubplan = pPlan;
|
||||
(*pTaskInfo)->pRoot = createOperatorTree(pPlan->pNode, *pTaskInfo, pHandle, &(*pTaskInfo)->tableqinfoList, pPlan->pTagCond, pPlan->pTagIndexCond, pPlan->user);
|
||||
|
||||
if (NULL == (*pTaskInfo)->pRoot) {
|
||||
|
@ -4977,7 +4975,9 @@ void doDestroyTask(SExecTaskInfo* pTaskInfo) {
|
|||
|
||||
doDestroyTableList(&pTaskInfo->tableqinfoList);
|
||||
destroyOperatorInfo(pTaskInfo->pRoot);
|
||||
cleanupTableSchemaInfo(pTaskInfo);
|
||||
cleanupTableSchemaInfo(&pTaskInfo->schemaInfo);
|
||||
|
||||
nodesDestroyNode((SNode*)pTaskInfo->pSubplan);
|
||||
|
||||
taosMemoryFreeClear(pTaskInfo->sql);
|
||||
taosMemoryFreeClear(pTaskInfo->id.str);
|
||||
|
|
|
@ -406,7 +406,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
|
|||
goto _error;
|
||||
}
|
||||
|
||||
initResultSizeInfo(pOperator, 4096);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
initAggInfo(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, pInfo->groupKeyLen, pTaskInfo->id.str);
|
||||
initBasicInfo(&pInfo->binfo, pResultBlock);
|
||||
initResultRowInfo(&pInfo->binfo.resultRowInfo);
|
||||
|
|
|
@ -41,7 +41,7 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t
|
|||
int32_t numOfCols = 0;
|
||||
SExprInfo* pExprInfo = createExprInfo(pJoinNode->pTargets, NULL, &numOfCols);
|
||||
|
||||
initResultSizeInfo(pOperator, 4096);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
|
||||
pInfo->pRes = pResBlock;
|
||||
pOperator->name = "MergeJoinOperator";
|
||||
|
|
|
@ -125,7 +125,7 @@ static bool overlapWithTimeWindow(SInterval* pInterval, SDataBlockInfo* pBlockIn
|
|||
}
|
||||
|
||||
if (order == TSDB_ORDER_ASC) {
|
||||
getAlignQueryTimeWindow(pInterval, pInterval->precision, pBlockInfo->window.skey, &w);
|
||||
w = getAlignQueryTimeWindow(pInterval, pInterval->precision, pBlockInfo->window.skey);
|
||||
assert(w.ekey >= pBlockInfo->window.skey);
|
||||
|
||||
if (w.ekey < pBlockInfo->window.ekey) {
|
||||
|
@ -144,7 +144,7 @@ static bool overlapWithTimeWindow(SInterval* pInterval, SDataBlockInfo* pBlockIn
|
|||
}
|
||||
}
|
||||
} else {
|
||||
getAlignQueryTimeWindow(pInterval, pInterval->precision, pBlockInfo->window.ekey, &w);
|
||||
w = getAlignQueryTimeWindow(pInterval, pInterval->precision, pBlockInfo->window.ekey);
|
||||
assert(w.skey <= pBlockInfo->window.ekey);
|
||||
|
||||
if (w.skey > pBlockInfo->window.skey) {
|
||||
|
@ -1196,7 +1196,6 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
|||
if (pResCol->info.colId == pColMatchInfo->colId) {
|
||||
SColumnInfoData* pDst = taosArrayGet(pInfo->pRes->pDataBlock, pColMatchInfo->targetSlotId);
|
||||
colDataAssign(pDst, pResCol, pBlock->info.rows, &pInfo->pRes->info);
|
||||
// taosArraySet(pInfo->pRes->pDataBlock, pColMatchInfo->targetSlotId, pResCol);
|
||||
colExists = true;
|
||||
break;
|
||||
}
|
||||
|
@ -1393,24 +1392,49 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
|
|||
}
|
||||
|
||||
SDataBlockInfo* pBlockInfo = &pInfo->pRes->info;
|
||||
blockDataCleanup(pInfo->pRes);
|
||||
|
||||
while (tqNextDataBlock(pInfo->tqReader)) {
|
||||
SSDataBlock block = {0};
|
||||
int32_t totBlockNum = taosArrayGetSize(pInfo->pBlockLists);
|
||||
|
||||
// todo refactor
|
||||
int32_t code = tqRetrieveDataBlock(&block, pInfo->tqReader);
|
||||
while (1) {
|
||||
if (pInfo->tqReader->pMsg == NULL) {
|
||||
if (pInfo->validBlockIndex >= totBlockNum) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (code != TSDB_CODE_SUCCESS || block.info.rows == 0) {
|
||||
pTaskInfo->code = code;
|
||||
return NULL;
|
||||
int32_t current = pInfo->validBlockIndex++;
|
||||
SSubmitReq* pSubmit = taosArrayGetP(pInfo->pBlockLists, current);
|
||||
if (tqReaderSetDataMsg(pInfo->tqReader, pSubmit, 0) < 0) {
|
||||
qError("submit msg messed up when initing stream submit block %p, current %d, total %d", pSubmit, current,
|
||||
totBlockNum);
|
||||
pInfo->tqReader->pMsg = NULL;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
setBlockIntoRes(pInfo, &block);
|
||||
blockDataCleanup(pInfo->pRes);
|
||||
|
||||
while (tqNextDataBlock(pInfo->tqReader)) {
|
||||
SSDataBlock block = {0};
|
||||
|
||||
int32_t code = tqRetrieveDataBlock(&block, pInfo->tqReader);
|
||||
|
||||
if (code != TSDB_CODE_SUCCESS || block.info.rows == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
setBlockIntoRes(pInfo, &block);
|
||||
|
||||
if (pBlockInfo->rows > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pBlockInfo->rows > 0) {
|
||||
break;
|
||||
} else {
|
||||
pInfo->tqReader->pMsg = NULL;
|
||||
continue;
|
||||
}
|
||||
/*blockDataCleanup(pInfo->pRes);*/
|
||||
}
|
||||
|
||||
// record the scan action.
|
||||
|
@ -1435,6 +1459,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
qDebug("scan rows: %d", pBlockInfo->rows);
|
||||
return (pBlockInfo->rows == 0) ? NULL : pInfo->pRes;
|
||||
|
||||
|
@ -1507,8 +1532,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
|||
goto _error;
|
||||
}
|
||||
|
||||
SScanPhysiNode* pScanPhyNode = &pTableScanNode->scan;
|
||||
|
||||
SScanPhysiNode* pScanPhyNode = &pTableScanNode->scan;
|
||||
SDataBlockDescNode* pDescNode = pScanPhyNode->node.pOutputDataBlockDesc;
|
||||
|
||||
pInfo->pTagCond = pTagCond;
|
||||
|
@ -1539,7 +1563,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
|||
goto _error;
|
||||
}
|
||||
|
||||
if (pHandle) {
|
||||
if (pHandle->vnode) {
|
||||
SOperatorInfo* pTableScanOp = createTableScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo);
|
||||
STableScanInfo* pTSInfo = (STableScanInfo*)pTableScanOp->info;
|
||||
if (pHandle->version > 0) {
|
||||
|
@ -2300,7 +2324,7 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
|
|||
pInfo->pCondition = pScanNode->node.pConditions;
|
||||
pInfo->scanCols = colList;
|
||||
|
||||
initResultSizeInfo(pOperator, 4096);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
|
||||
tNameAssign(&pInfo->name, &pScanNode->tableName);
|
||||
const char* name = tNameGetTableName(&pInfo->name);
|
||||
|
@ -2530,7 +2554,7 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
|
|||
pOperator->info = pInfo;
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
|
||||
initResultSizeInfo(pOperator, 4096);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||
|
||||
pOperator->fpSet =
|
||||
|
@ -2558,30 +2582,30 @@ typedef struct STableMergeScanInfo {
|
|||
SArray* pSortInfo;
|
||||
SSortHandle* pSortHandle;
|
||||
|
||||
SSDataBlock* pSortInputBlock;
|
||||
int64_t startTs; // sort start time
|
||||
SArray* sortSourceParams;
|
||||
SSDataBlock* pSortInputBlock;
|
||||
int64_t startTs; // sort start time
|
||||
SArray* sortSourceParams;
|
||||
|
||||
SFileBlockLoadRecorder readRecorder;
|
||||
int64_t numOfRows;
|
||||
SScanInfo scanInfo;
|
||||
int32_t scanTimes;
|
||||
SNode* pFilterNode; // filter info, which is push down by optimizer
|
||||
SqlFunctionCtx* pCtx; // which belongs to the direct upstream operator operator query context
|
||||
SResultRowInfo* pResultRowInfo;
|
||||
int32_t* rowEntryInfoOffset;
|
||||
SExprInfo* pExpr;
|
||||
SSDataBlock* pResBlock;
|
||||
SArray* pColMatchInfo;
|
||||
int32_t numOfOutput;
|
||||
int64_t numOfRows;
|
||||
SScanInfo scanInfo;
|
||||
int32_t scanTimes;
|
||||
SNode* pFilterNode; // filter info, which is push down by optimizer
|
||||
SqlFunctionCtx* pCtx; // which belongs to the direct upstream operator operator query context
|
||||
SResultRowInfo* pResultRowInfo;
|
||||
int32_t* rowEntryInfoOffset;
|
||||
SExprInfo* pExpr;
|
||||
SSDataBlock* pResBlock;
|
||||
SArray* pColMatchInfo;
|
||||
int32_t numOfOutput;
|
||||
|
||||
SExprInfo* pPseudoExpr;
|
||||
int32_t numOfPseudoExpr;
|
||||
SqlFunctionCtx* pPseudoCtx;
|
||||
|
||||
SQueryTableDataCond cond;
|
||||
int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan
|
||||
int32_t dataBlockLoadFlag;
|
||||
int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan
|
||||
int32_t dataBlockLoadFlag;
|
||||
// if the upstream is an interval operator, the interval info is also kept here to get the time
|
||||
// window to check if current data block needs to be loaded.
|
||||
SInterval interval;
|
||||
|
@ -2589,7 +2613,8 @@ typedef struct STableMergeScanInfo {
|
|||
} STableMergeScanInfo;
|
||||
|
||||
int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags, bool groupSort, SReadHandle* pHandle,
|
||||
STableListInfo* pTableListInfo, SNode* pTagCond, SNode* pTagIndexCond, const char* idStr) {
|
||||
STableListInfo* pTableListInfo, SNode* pTagCond, SNode* pTagIndexCond,
|
||||
const char* idStr) {
|
||||
int32_t code = getTableList(pHandle->meta, pHandle->vnode, pScanNode, pTagCond, pTagIndexCond, pTableListInfo);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
|
@ -3074,7 +3099,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
|
|||
pOperator->info = pInfo;
|
||||
pOperator->exprSupp.numOfExprs = numOfCols;
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
initResultSizeInfo(pOperator, 1024);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 1024);
|
||||
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(operatorDummyOpenFn, doTableMergeScan, NULL, NULL, destroyTableMergeScanOperatorInfo, NULL,
|
||||
|
|
|
@ -26,7 +26,7 @@ static void destroyOrderOperatorInfo(void* param, int32_t numOfOutput);
|
|||
SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* pSortNode, SExecTaskInfo* pTaskInfo) {
|
||||
SSortOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SSortOperatorInfo));
|
||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||
if (pInfo == NULL || pOperator == NULL /* || rowSize > 100 * 1024 * 1024*/) {
|
||||
if (pInfo == NULL || pOperator == NULL) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
|
@ -41,13 +41,15 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode*
|
|||
extractColMatchInfo(pSortNode->pTargets, pDescNode, &numOfOutputCols, COL_MATCH_FROM_SLOT_ID);
|
||||
|
||||
pOperator->exprSupp.pCtx = createSqlFunctionCtx(pExprInfo, numOfCols, &pOperator->exprSupp.rowEntryInfoOffset);
|
||||
|
||||
initResultSizeInfo(&pOperator->resultInfo, 1024);
|
||||
|
||||
pInfo->binfo.pRes = pResBlock;
|
||||
|
||||
initResultSizeInfo(pOperator, 1024);
|
||||
|
||||
pInfo->pSortInfo = createSortInfo(pSortNode->pSortKeys);
|
||||
pInfo->pSortInfo = createSortInfo(pSortNode->pSortKeys);
|
||||
pInfo->pCondition = pSortNode->node.pConditions;
|
||||
pInfo->pColMatchInfo = pColMatchColInfo;
|
||||
initLimitInfo(pSortNode->node.pLimit, pSortNode->node.pSlimit, &pInfo->limitInfo);
|
||||
|
||||
pOperator->name = "SortOperator";
|
||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_SORT;
|
||||
pOperator->blocking = true;
|
||||
|
@ -208,26 +210,44 @@ SSDataBlock* doSort(SOperatorInfo* pOperator) {
|
|||
SSDataBlock* pBlock = NULL;
|
||||
while (1) {
|
||||
pBlock = getSortedBlockData(pInfo->pSortHandle, pInfo->binfo.pRes, pOperator->resultInfo.capacity,
|
||||
pInfo->pColMatchInfo, pInfo);
|
||||
if (pBlock != NULL) {
|
||||
doFilter(pInfo->pCondition, pBlock);
|
||||
}
|
||||
|
||||
pInfo->pColMatchInfo, pInfo);
|
||||
if (pBlock == NULL) {
|
||||
doSetOperatorCompleted(pOperator);
|
||||
break;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (blockDataGetNumOfRows(pBlock) > 0) {
|
||||
doFilter(pInfo->pCondition, pBlock);
|
||||
if (blockDataGetNumOfRows(pBlock) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// todo add the limit/offset info
|
||||
if (pInfo->limitInfo.remainOffset > 0) {
|
||||
if (pInfo->limitInfo.remainOffset >= blockDataGetNumOfRows(pBlock)) {
|
||||
pInfo->limitInfo.remainOffset -= pBlock->info.rows;
|
||||
continue;
|
||||
}
|
||||
|
||||
blockDataTrimFirstNRows(pBlock, pInfo->limitInfo.remainOffset);
|
||||
pInfo->limitInfo.remainOffset = 0;
|
||||
}
|
||||
|
||||
if (pInfo->limitInfo.limit.limit > 0 &&
|
||||
pInfo->limitInfo.limit.limit <= pInfo->limitInfo.numOfOutputRows + blockDataGetNumOfRows(pBlock)) {
|
||||
int32_t remain = pInfo->limitInfo.limit.limit - pInfo->limitInfo.numOfOutputRows;
|
||||
blockDataKeepFirstNRows(pBlock, remain);
|
||||
}
|
||||
|
||||
size_t numOfRows = blockDataGetNumOfRows(pBlock);
|
||||
pInfo->limitInfo.numOfOutputRows += numOfRows;
|
||||
pOperator->resultInfo.totalRows += numOfRows;
|
||||
|
||||
if (numOfRows > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pBlock != NULL) {
|
||||
pOperator->resultInfo.totalRows += pBlock->info.rows;
|
||||
}
|
||||
|
||||
return pBlock;
|
||||
return blockDataGetNumOfRows(pBlock) > 0? pBlock:NULL;
|
||||
}
|
||||
|
||||
void destroyOrderOperatorInfo(void* param, int32_t numOfOutput) {
|
||||
|
@ -479,7 +499,7 @@ SOperatorInfo* createGroupSortOperatorInfo(SOperatorInfo* downstream, SGroupSort
|
|||
pOperator->exprSupp.pCtx = createSqlFunctionCtx(pExprInfo, numOfCols, &pOperator->exprSupp.rowEntryInfoOffset);
|
||||
pInfo->binfo.pRes = pResBlock;
|
||||
|
||||
initResultSizeInfo(pOperator, 1024);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 1024);
|
||||
|
||||
pInfo->pSortInfo = createSortInfo(pSortPhyNode->pSortKeys);
|
||||
;
|
||||
|
@ -711,7 +731,7 @@ SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** downStreams, size
|
|||
extractColMatchInfo(pMergePhyNode->pTargets, pDescNode, &numOfOutputCols, COL_MATCH_FROM_SLOT_ID);
|
||||
SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, 0);
|
||||
SSDataBlock* pInputBlock = createResDataBlock(pChildNode->pOutputDataBlockDesc);
|
||||
initResultSizeInfo(pOperator, 1024);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 1024);
|
||||
|
||||
pInfo->groupSort = pMergePhyNode->groupSort;
|
||||
pInfo->binfo.pRes = pResBlock;
|
||||
|
|
|
@ -544,8 +544,9 @@ bool taosFillHasMoreResults(SFillInfo* pFillInfo) {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (pFillInfo->numOfTotal > 0 && (((pFillInfo->end > pFillInfo->start) && FILL_IS_ASC_FILL(pFillInfo)) ||
|
||||
(pFillInfo->end < pFillInfo->start && !FILL_IS_ASC_FILL(pFillInfo)))) {
|
||||
bool ascFill = FILL_IS_ASC_FILL(pFillInfo);
|
||||
if (pFillInfo->numOfTotal > 0 &&
|
||||
(((pFillInfo->end > pFillInfo->start) && ascFill) || (pFillInfo->end < pFillInfo->start && !ascFill))) {
|
||||
return getNumOfResultsAfterFillGap(pFillInfo, pFillInfo->end, 4096) > 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -652,7 +652,7 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num
|
|||
|
||||
void printDataBlock(SSDataBlock* pBlock, const char* flag) {
|
||||
if (!pBlock || pBlock->info.rows == 0) {
|
||||
qDebug("======printDataBlock: Block is Null or Empty");
|
||||
qDebug("===stream===printDataBlock: Block is Null or Empty");
|
||||
return;
|
||||
}
|
||||
char* pBuf = NULL;
|
||||
|
@ -660,6 +660,62 @@ void printDataBlock(SSDataBlock* pBlock, const char* flag) {
|
|||
taosMemoryFree(pBuf);
|
||||
}
|
||||
|
||||
typedef int32_t (*__compare_fn_t)(void* pKey, void* data, int32_t index);
|
||||
|
||||
int32_t binarySearchCom(void* keyList, int num, void* pKey, int order, __compare_fn_t comparefn) {
|
||||
int firstPos = 0, lastPos = num - 1, midPos = -1;
|
||||
int numOfRows = 0;
|
||||
|
||||
if (num <= 0) return -1;
|
||||
if (order == TSDB_ORDER_DESC) {
|
||||
// find the first position which is smaller or equal than the key
|
||||
while (1) {
|
||||
if (comparefn(pKey, keyList, lastPos) >= 0) return lastPos;
|
||||
if (comparefn(pKey, keyList, firstPos) == 0) return firstPos;
|
||||
if (comparefn(pKey, keyList, firstPos) < 0) return firstPos - 1;
|
||||
|
||||
numOfRows = lastPos - firstPos + 1;
|
||||
midPos = (numOfRows >> 1) + firstPos;
|
||||
|
||||
if (comparefn(pKey, keyList, midPos) < 0) {
|
||||
lastPos = midPos - 1;
|
||||
} else if (comparefn(pKey, keyList, midPos) > 0) {
|
||||
firstPos = midPos + 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// find the first position which is bigger or equal than the key
|
||||
while (1) {
|
||||
if (comparefn(pKey, keyList, firstPos) <= 0) return firstPos;
|
||||
if (comparefn(pKey, keyList, lastPos) == 0) return lastPos;
|
||||
|
||||
if (comparefn(pKey, keyList, lastPos) > 0) {
|
||||
lastPos = lastPos + 1;
|
||||
if (lastPos >= num)
|
||||
return -1;
|
||||
else
|
||||
return lastPos;
|
||||
}
|
||||
|
||||
numOfRows = lastPos - firstPos + 1;
|
||||
midPos = (numOfRows >> 1) + firstPos;
|
||||
|
||||
if (comparefn(pKey, keyList, midPos) < 0) {
|
||||
lastPos = midPos - 1;
|
||||
} else if (comparefn(pKey, keyList, midPos) > 0) {
|
||||
firstPos = midPos + 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return midPos;
|
||||
}
|
||||
|
||||
typedef int64_t (*__get_value_fn_t)(void* data, int32_t index);
|
||||
|
||||
int32_t binarySearch(void* keyList, int num, TSKEY key, int order, __get_value_fn_t getValuefn) {
|
||||
|
@ -716,20 +772,31 @@ int32_t binarySearch(void* keyList, int num, TSKEY key, int order, __get_value_f
|
|||
return midPos;
|
||||
}
|
||||
|
||||
int64_t getReskey(void* data, int32_t index) {
|
||||
int32_t compareResKey(void* pKey, void* data, int32_t index) {
|
||||
SArray* res = (SArray*)data;
|
||||
SResKeyPos* pos = taosArrayGetP(res, index);
|
||||
return *(int64_t*)pos->key;
|
||||
SWinRes* pData = (SWinRes*) pKey;
|
||||
if (pData->ts == *(int64_t*)pos->key) {
|
||||
if (pData->groupId > pos->groupId) {
|
||||
return 1;
|
||||
} else if (pData->groupId < pos->groupId) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
} else if (pData->ts > *(int64_t*)pos->key) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int32_t saveResult(int64_t ts, int32_t pageId, int32_t offset, uint64_t groupId, SArray* pUpdated) {
|
||||
int32_t size = taosArrayGetSize(pUpdated);
|
||||
int32_t index = binarySearch(pUpdated, size, ts, TSDB_ORDER_DESC, getReskey);
|
||||
SWinRes data = {.ts = ts, .groupId = groupId};
|
||||
int32_t index = binarySearchCom(pUpdated, size, &data, TSDB_ORDER_DESC, compareResKey);
|
||||
if (index == -1) {
|
||||
index = 0;
|
||||
} else {
|
||||
TSKEY resTs = getReskey(pUpdated, index);
|
||||
if (resTs < ts) {
|
||||
if (compareResKey(&data, pUpdated, index) > 0) {
|
||||
index++;
|
||||
} else {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -753,10 +820,10 @@ static int32_t saveResultRow(SResultRow* result, uint64_t groupId, SArray* pUpda
|
|||
return saveResult(result->win.skey, result->pageId, result->offset, groupId, pUpdated);
|
||||
}
|
||||
|
||||
static void removeResult(SArray* pUpdated, TSKEY key) {
|
||||
static void removeResult(SArray* pUpdated, SWinRes* pKey) {
|
||||
int32_t size = taosArrayGetSize(pUpdated);
|
||||
int32_t index = binarySearch(pUpdated, size, key, TSDB_ORDER_DESC, getReskey);
|
||||
if (index >= 0 && key == getReskey(pUpdated, index)) {
|
||||
int32_t index = binarySearchCom(pUpdated, size, pKey, TSDB_ORDER_DESC, compareResKey);
|
||||
if (index >= 0 && 0 == compareResKey(pKey, pUpdated, index)) {
|
||||
taosArrayRemove(pUpdated, index);
|
||||
}
|
||||
}
|
||||
|
@ -765,7 +832,7 @@ static void removeResults(SArray* pWins, SArray* pUpdated) {
|
|||
int32_t size = taosArrayGetSize(pWins);
|
||||
for (int32_t i = 0; i < size; i++) {
|
||||
SWinRes* pW = taosArrayGet(pWins, i);
|
||||
removeResult(pUpdated, pW->ts);
|
||||
removeResult(pUpdated, pW);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -775,14 +842,30 @@ int64_t getWinReskey(void* data, int32_t index) {
|
|||
return pos->ts;
|
||||
}
|
||||
|
||||
int32_t compareWinRes(void* pKey, void* data, int32_t index) {
|
||||
SArray* res = (SArray*)data;
|
||||
SWinRes* pos = taosArrayGetP(res, index);
|
||||
SResKeyPos* pData = (SResKeyPos*) pKey;
|
||||
if (*(int64_t*)pData->key == pos->ts) {
|
||||
if (pData->groupId > pos->groupId) {
|
||||
return 1;
|
||||
} else if (pData->groupId < pos->groupId) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
} else if (*(int64_t*)pData->key > pos->ts) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void removeDeleteResults(SArray* pUpdated, SArray* pDelWins) {
|
||||
int32_t upSize = taosArrayGetSize(pUpdated);
|
||||
int32_t delSize = taosArrayGetSize(pDelWins);
|
||||
for (int32_t i = 0; i < upSize; i++) {
|
||||
SResKeyPos* pResKey = taosArrayGetP(pUpdated, i);
|
||||
int64_t key = *(int64_t*)pResKey->key;
|
||||
int32_t index = binarySearch(pDelWins, delSize, key, TSDB_ORDER_DESC, getWinReskey);
|
||||
if (index >= 0 && key == getWinReskey(pDelWins, index)) {
|
||||
int32_t index = binarySearchCom(pDelWins, delSize, pResKey, TSDB_ORDER_DESC, compareWinRes);
|
||||
if (index >= 0 && 0 == compareWinRes(pResKey, pDelWins, index)) {
|
||||
taosArrayRemove(pDelWins, index);
|
||||
}
|
||||
}
|
||||
|
@ -924,11 +1007,17 @@ SResultRowPosition addToOpenWindowList(SResultRowInfo* pResultRowInfo, const SRe
|
|||
|
||||
int64_t* extractTsCol(SSDataBlock* pBlock, const SIntervalAggOperatorInfo* pInfo) {
|
||||
TSKEY* tsCols = NULL;
|
||||
|
||||
if (pBlock->pDataBlock != NULL) {
|
||||
SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, pInfo->primaryTsIndex);
|
||||
tsCols = (int64_t*)pColDataInfo->pData;
|
||||
|
||||
if (tsCols != NULL) {
|
||||
// no data in primary ts
|
||||
if (tsCols[0] == 0 && tsCols[pBlock->info.rows - 1] == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (tsCols[0] != 0 && (pBlock->info.window.skey == 0 && pBlock->info.window.ekey == 0)) {
|
||||
blockDataUpdateTsWindow(pBlock, pInfo->primaryTsIndex);
|
||||
}
|
||||
}
|
||||
|
@ -1442,8 +1531,10 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
|||
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||
if (pInfo->binfo.pRes->info.rows == 0 || !hasDataInGroupInfo(&pInfo->groupResInfo)) {
|
||||
pOperator->status = OP_EXEC_DONE;
|
||||
qDebug("===stream===single interval is done");
|
||||
freeAllPages(pInfo->pRecycledPages, pInfo->aggSup.pResultBuf);
|
||||
}
|
||||
printDataBlock(pInfo->binfo.pRes, "single interval");
|
||||
return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes;
|
||||
}
|
||||
|
||||
|
@ -1543,6 +1634,7 @@ void destroyStreamFinalIntervalOperatorInfo(void* param, int32_t numOfOutput) {
|
|||
taosArrayDestroy(pInfo->pPullWins);
|
||||
blockDataDestroy(pInfo->pPullDataRes);
|
||||
taosArrayDestroy(pInfo->pRecycledPages);
|
||||
blockDataDestroy(pInfo->pUpdateRes);
|
||||
|
||||
if (pInfo->pChildren) {
|
||||
int32_t size = taosArrayGetSize(pInfo->pChildren);
|
||||
|
@ -1676,7 +1768,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
|||
SExprSupp* pSup = &pOperator->exprSupp;
|
||||
|
||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||
initResultSizeInfo(pOperator, 4096);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
|
||||
int32_t code = initAggInfo(pSup, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str);
|
||||
initBasicInfo(&pInfo->binfo, pResBlock);
|
||||
|
@ -1757,7 +1849,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExpr
|
|||
int32_t numOfRows = 4096;
|
||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||
|
||||
initResultSizeInfo(pOperator, numOfRows);
|
||||
initResultSizeInfo(&pOperator->resultInfo, numOfRows);
|
||||
int32_t code = initAggInfo(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str);
|
||||
initBasicInfo(&pInfo->binfo, pResBlock);
|
||||
initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pInfo->win);
|
||||
|
@ -2217,7 +2309,7 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode
|
|||
|
||||
pInfo->tsCol = extractColumnFromColumnNode((SColumnNode*)pInterpPhyNode->pTimeSeries);
|
||||
pInfo->fillType = convertFillType(pInterpPhyNode->fillMode);
|
||||
initResultSizeInfo(pOperator, 4096);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
|
||||
pInfo->pFillColInfo = createFillColInfo(pExprInfo, numOfExprs, (SNodeListNode*)pInterpPhyNode->pFillValues);
|
||||
pInfo->pRes = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
||||
|
@ -2265,7 +2357,7 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInf
|
|||
|
||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||
|
||||
initResultSizeInfo(pOperator, 4096);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
initAggInfo(&pOperator->exprSupp, &pInfo->aggSup, pExpr, numOfCols, keyBufSize, pTaskInfo->id.str);
|
||||
initBasicInfo(&pInfo->binfo, pResBlock);
|
||||
|
||||
|
@ -2313,7 +2405,7 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo
|
|||
}
|
||||
|
||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||
initResultSizeInfo(pOperator, 4096);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
|
||||
int32_t code = initAggInfo(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -2889,7 +2981,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
|
|||
ASSERT(pInfo->twAggSup.calTrigger != STREAM_TRIGGER_MAX_DELAY);
|
||||
pInfo->primaryTsIndex = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId;
|
||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||
initResultSizeInfo(pOperator, 4096);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
if (pIntervalPhyNode->window.pExprs != NULL) {
|
||||
int32_t numOfScalar = 0;
|
||||
SExprInfo* pScalarExprInfo = createExprInfo(pIntervalPhyNode->window.pExprs, NULL, &numOfScalar);
|
||||
|
@ -3065,7 +3157,7 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh
|
|||
goto _error;
|
||||
}
|
||||
|
||||
initResultSizeInfo(pOperator, 4096);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
if (pSessionNode->window.pExprs != NULL) {
|
||||
int32_t numOfScalar = 0;
|
||||
SExprInfo* pScalarExprInfo = createExprInfo(pSessionNode->window.pExprs, NULL, &numOfScalar);
|
||||
|
@ -4329,7 +4421,7 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys
|
|||
SExprInfo* pExprInfo = createExprInfo(pStateNode->window.pFuncs, NULL, &numOfCols);
|
||||
|
||||
pInfo->stateCol = extractColumnFromColumnNode(pColNode);
|
||||
initResultSizeInfo(pOperator, 4096);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
if (pStateNode->window.pExprs != NULL) {
|
||||
int32_t numOfScalar = 0;
|
||||
SExprInfo* pScalarExprInfo = createExprInfo(pStateNode->window.pExprs, NULL, &numOfScalar);
|
||||
|
@ -4579,7 +4671,7 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream,
|
|||
iaInfo->primaryTsIndex = primaryTsSlotId;
|
||||
|
||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||
initResultSizeInfo(pOperator, 4096);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
|
||||
int32_t code =
|
||||
initAggInfo(&pOperator->exprSupp, &iaInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str);
|
||||
|
@ -4885,7 +4977,7 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SExprI
|
|||
SExprSupp* pExprSupp = &pOperator->exprSupp;
|
||||
|
||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||
initResultSizeInfo(pOperator, 4096);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
|
||||
int32_t code = initAggInfo(pExprSupp, &iaInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str);
|
||||
initBasicInfo(&iaInfo->binfo, pResBlock);
|
||||
|
|
|
@ -192,9 +192,9 @@ static bool validateTimezoneFormat(const SValueNode* pVal) {
|
|||
}
|
||||
|
||||
void static addTimezoneParam(SNodeList* pList) {
|
||||
char buf[6] = {0};
|
||||
time_t t = taosTime(NULL);
|
||||
struct tm tmInfo;
|
||||
char buf[6] = {0};
|
||||
time_t t = taosTime(NULL);
|
||||
struct tm tmInfo;
|
||||
taosLocalTime(&t, &tmInfo);
|
||||
strftime(buf, sizeof(buf), "%z", &tmInfo);
|
||||
int32_t len = (int32_t)strlen(buf);
|
||||
|
@ -958,6 +958,7 @@ static bool validateHistogramBinDesc(char* binDescStr, int8_t binType, char* err
|
|||
return false;
|
||||
}
|
||||
|
||||
cJSON_Delete(binDesc);
|
||||
taosMemoryFree(intervals);
|
||||
return true;
|
||||
}
|
||||
|
@ -976,7 +977,7 @@ static int32_t translateHistogram(SFunctionNode* pFunc, char* pErrBuf, int32_t l
|
|||
// param1 ~ param3
|
||||
if (((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type != TSDB_DATA_TYPE_BINARY ||
|
||||
((SExprNode*)nodesListGetNode(pFunc->pParameterList, 2))->resType.type != TSDB_DATA_TYPE_BINARY ||
|
||||
((SExprNode*)nodesListGetNode(pFunc->pParameterList, 3))->resType.type != TSDB_DATA_TYPE_BIGINT) {
|
||||
!IS_INTEGER_TYPE(((SExprNode*)nodesListGetNode(pFunc->pParameterList, 3))->resType.type)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
|
@ -1034,7 +1035,7 @@ static int32_t translateHistogramImpl(SFunctionNode* pFunc, char* pErrBuf, int32
|
|||
// param1 ~ param3
|
||||
if (((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type != TSDB_DATA_TYPE_BINARY ||
|
||||
((SExprNode*)nodesListGetNode(pFunc->pParameterList, 2))->resType.type != TSDB_DATA_TYPE_BINARY ||
|
||||
((SExprNode*)nodesListGetNode(pFunc->pParameterList, 3))->resType.type != TSDB_DATA_TYPE_BIGINT) {
|
||||
!IS_INTEGER_TYPE(((SExprNode*)nodesListGetNode(pFunc->pParameterList, 3))->resType.type)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
|
@ -1133,9 +1134,10 @@ static bool validateStateOper(const SValueNode* pVal) {
|
|||
if (TSDB_DATA_TYPE_BINARY != pVal->node.resType.type) {
|
||||
return false;
|
||||
}
|
||||
return (0 == strncasecmp(varDataVal(pVal->datum.p), "GT", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "GE", 2) ||
|
||||
0 == strncasecmp(varDataVal(pVal->datum.p), "LT", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "LE", 2) ||
|
||||
0 == strncasecmp(varDataVal(pVal->datum.p), "EQ", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "NE", 2));
|
||||
return (
|
||||
0 == strncasecmp(varDataVal(pVal->datum.p), "GT", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "GE", 2) ||
|
||||
0 == strncasecmp(varDataVal(pVal->datum.p), "LT", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "LE", 2) ||
|
||||
0 == strncasecmp(varDataVal(pVal->datum.p), "EQ", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "NE", 2));
|
||||
}
|
||||
|
||||
static int32_t translateStateCount(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
|
@ -1348,7 +1350,8 @@ static int32_t translateTail(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
|||
|
||||
SValueNode* pValue = (SValueNode*)pParamNode;
|
||||
|
||||
if (pValue->datum.i < ((i > 1) ? 0 : 1) || pValue->datum.i > 100) {
|
||||
if ((IS_SIGNED_NUMERIC_TYPE(pValue->node.resType.type) ? pValue->datum.i : pValue->datum.u) < ((i > 1) ? 0 : 1) ||
|
||||
(IS_SIGNED_NUMERIC_TYPE(pValue->node.resType.type) ? pValue->datum.i : pValue->datum.u) > 100) {
|
||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||
"TAIL function second parameter should be in range [1, 100], "
|
||||
"third parameter should be in range [0, 100]");
|
||||
|
@ -1423,6 +1426,17 @@ static int32_t translateIrate(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
|
|||
}
|
||||
|
||||
static int32_t translateFirstLast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
// forbid null as first/last input, since first(c0, null, 1) may have different number of input
|
||||
int32_t numOfParams = LIST_LENGTH(pFunc->pParameterList);
|
||||
|
||||
for (int32_t i = 0; i < numOfParams; ++i) {
|
||||
uint8_t nodeType = nodeType(nodesListGetNode(pFunc->pParameterList, i));
|
||||
uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, i))->resType.type;
|
||||
if (IS_NULL_TYPE(paraType) && QUERY_NODE_VALUE == nodeType) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
}
|
||||
|
||||
pFunc->node.resType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -1433,6 +1447,15 @@ static int32_t translateFirstLastImpl(SFunctionNode* pFunc, char* pErrBuf, int32
|
|||
uint8_t paraType = ((SExprNode*)pPara)->resType.type;
|
||||
int32_t paraBytes = ((SExprNode*)pPara)->resType.bytes;
|
||||
if (isPartial) {
|
||||
int32_t numOfParams = LIST_LENGTH(pFunc->pParameterList);
|
||||
for (int32_t i = 0; i < numOfParams; ++i) {
|
||||
uint8_t nodeType = nodeType(nodesListGetNode(pFunc->pParameterList, i));
|
||||
uint8_t pType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, i))->resType.type;
|
||||
if (IS_NULL_TYPE(pType) && QUERY_NODE_VALUE == nodeType) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
}
|
||||
|
||||
pFunc->node.resType =
|
||||
(SDataType){.bytes = getFirstLastInfoSize(paraBytes) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY};
|
||||
} else {
|
||||
|
@ -1646,9 +1669,9 @@ static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
|||
if (IS_VAR_DATA_TYPE(para2Type)) {
|
||||
para2Bytes -= VARSTR_HEADER_SIZE;
|
||||
}
|
||||
if (para2Bytes <= 0 || para2Bytes > 1000) { // cast dst var type length limits to 1000
|
||||
if (para2Bytes <= 0 || para2Bytes > 4096) { // cast dst var type length limits to 4096 bytes
|
||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||
"CAST function converted length should be in range [0, 1000]");
|
||||
"CAST function converted length should be in range [0, 4096] bytes");
|
||||
}
|
||||
|
||||
// add database precision as param
|
||||
|
|
|
@ -80,7 +80,7 @@ typedef struct STopBotRes {
|
|||
} STopBotRes;
|
||||
|
||||
typedef struct SFirstLastRes {
|
||||
bool hasResult;
|
||||
bool hasResult;
|
||||
// used for last_row function only, isNullRes in SResultRowEntry can not be passed to downstream.So,
|
||||
// this attribute is required
|
||||
bool isNull;
|
||||
|
@ -165,6 +165,7 @@ typedef struct SElapsedInfo {
|
|||
|
||||
typedef struct STwaInfo {
|
||||
double dOutput;
|
||||
bool isNull;
|
||||
SPoint1 p;
|
||||
STimeWindow win;
|
||||
} STwaInfo;
|
||||
|
@ -2380,7 +2381,8 @@ int32_t percentileFunction(SqlFunctionCtx* pCtx) {
|
|||
|
||||
int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||
SVariant* pVal = &pCtx->param[1].param;
|
||||
double v = (pVal->nType == TSDB_DATA_TYPE_BIGINT) ? pVal->i : pVal->d;
|
||||
double v =
|
||||
(IS_SIGNED_NUMERIC_TYPE(pVal->nType) ? pVal->i : (IS_UNSIGNED_NUMERIC_TYPE(pVal->nType) ? pVal->u : pVal->d));
|
||||
|
||||
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||
SPercentileInfo* ppInfo = (SPercentileInfo*)GET_ROWCELL_INTERBUF(pResInfo);
|
||||
|
@ -2439,7 +2441,8 @@ bool apercentileFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResult
|
|||
SAPercentileInfo* pInfo = GET_ROWCELL_INTERBUF(pResultInfo);
|
||||
|
||||
SVariant* pVal = &pCtx->param[1].param;
|
||||
pInfo->percent = (pVal->nType == TSDB_DATA_TYPE_BIGINT) ? pVal->i : pVal->d;
|
||||
pInfo->percent =
|
||||
(IS_SIGNED_NUMERIC_TYPE(pVal->nType) ? pVal->i : (IS_UNSIGNED_NUMERIC_TYPE(pVal->nType) ? pVal->u : pVal->d));
|
||||
|
||||
if (pCtx->numOfParams == 2) {
|
||||
pInfo->algo = APERCT_ALGO_DEFAULT;
|
||||
|
@ -2640,9 +2643,7 @@ int32_t apercentileCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx)
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t getFirstLastInfoSize(int32_t resBytes) {
|
||||
return sizeof(SFirstLastRes) + resBytes;
|
||||
}
|
||||
int32_t getFirstLastInfoSize(int32_t resBytes) { return sizeof(SFirstLastRes) + resBytes; }
|
||||
|
||||
bool getFirstLastFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) {
|
||||
SColumnNode* pNode = (SColumnNode*)nodesListGetNode(pFunc->pParameterList, 0);
|
||||
|
@ -2968,7 +2969,7 @@ int32_t firstLastPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
//todo rewrite:
|
||||
// todo rewrite:
|
||||
int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
|
||||
SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx);
|
||||
char* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo);
|
||||
|
@ -2986,7 +2987,7 @@ int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void doSaveLastrow(SqlFunctionCtx *pCtx, char* pData, int32_t rowIndex, int64_t cts, SFirstLastRes* pInfo) {
|
||||
static void doSaveLastrow(SqlFunctionCtx* pCtx, char* pData, int32_t rowIndex, int64_t cts, SFirstLastRes* pInfo) {
|
||||
SInputColumnInfoData* pInput = &pCtx->input;
|
||||
SColumnInfoData* pInputCol = pInput->pData[0];
|
||||
|
||||
|
@ -5098,12 +5099,7 @@ bool modeFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static void doModeAdd(SModeInfo* pInfo, char* data, bool isNull) {
|
||||
// ignore null elements
|
||||
if (isNull) {
|
||||
return;
|
||||
}
|
||||
|
||||
static void doModeAdd(SModeInfo* pInfo, char* data) {
|
||||
int32_t hashKeyBytes = IS_VAR_DATA_TYPE(pInfo->colType) ? varDataTLen(data) : pInfo->colBytes;
|
||||
SModeItem** pHashItem = taosHashGet(pInfo->pHash, data, hashKeyBytes);
|
||||
if (pHashItem == NULL) {
|
||||
|
@ -5128,10 +5124,16 @@ int32_t modeFunction(SqlFunctionCtx* pCtx) {
|
|||
SColumnInfoData* pInputCol = pInput->pData[0];
|
||||
SColumnInfoData* pOutput = (SColumnInfoData*)pCtx->pOutput;
|
||||
|
||||
int32_t numOfElems = 0;
|
||||
int32_t startOffset = pCtx->offset;
|
||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||
char* data = colDataGetData(pInputCol, i);
|
||||
doModeAdd(pInfo, data, colDataIsNull_s(pInputCol, i));
|
||||
if (colDataIsNull_s(pInputCol, i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
numOfElems++;
|
||||
doModeAdd(pInfo, data);
|
||||
|
||||
if (sizeof(SModeInfo) + pInfo->numOfPoints * (sizeof(SModeItem) + pInfo->colBytes) >= MODE_MAX_RESULT_SIZE) {
|
||||
taosHashCleanup(pInfo->pHash);
|
||||
|
@ -5139,7 +5141,7 @@ int32_t modeFunction(SqlFunctionCtx* pCtx) {
|
|||
}
|
||||
}
|
||||
|
||||
SET_VAL(pResInfo, 1, 1);
|
||||
SET_VAL(pResInfo, numOfElems, 1);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -5180,8 +5182,9 @@ bool twaFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) {
|
|||
}
|
||||
|
||||
STwaInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||
pInfo->p.key = INT64_MIN;
|
||||
pInfo->win = TSWINDOW_INITIALIZER;
|
||||
pInfo->isNull = false;
|
||||
pInfo->p.key = INT64_MIN;
|
||||
pInfo->win = TSWINDOW_INITIALIZER;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -5207,27 +5210,47 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
|||
SPoint1* last = &pInfo->p;
|
||||
int32_t numOfElems = 0;
|
||||
|
||||
if (IS_NULL_TYPE(pInputCol->info.type)) {
|
||||
pInfo->isNull = true;
|
||||
goto _twa_over;
|
||||
}
|
||||
|
||||
int32_t i = pInput->startRowIndex;
|
||||
if (pCtx->start.key != INT64_MIN) {
|
||||
ASSERT((pCtx->start.key < tsList[i] && pCtx->order == TSDB_ORDER_ASC) ||
|
||||
(pCtx->start.key > tsList[i] && pCtx->order == TSDB_ORDER_DESC));
|
||||
|
||||
ASSERT(last->key == INT64_MIN);
|
||||
last->key = tsList[i];
|
||||
for (; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
GET_TYPED_DATA(last->val, double, pInputCol->info.type, colDataGetData(pInputCol, i));
|
||||
last->key = tsList[i];
|
||||
|
||||
pInfo->dOutput += twa_get_area(pCtx->start, *last);
|
||||
pInfo->win.skey = pCtx->start.key;
|
||||
numOfElems++;
|
||||
i += 1;
|
||||
GET_TYPED_DATA(last->val, double, pInputCol->info.type, colDataGetData(pInputCol, i));
|
||||
|
||||
pInfo->dOutput += twa_get_area(pCtx->start, *last);
|
||||
pInfo->win.skey = pCtx->start.key;
|
||||
numOfElems++;
|
||||
i += 1;
|
||||
break;
|
||||
}
|
||||
} else if (pInfo->p.key == INT64_MIN) {
|
||||
last->key = tsList[i];
|
||||
GET_TYPED_DATA(last->val, double, pInputCol->info.type, colDataGetData(pInputCol, i));
|
||||
for (; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
pInfo->win.skey = last->key;
|
||||
numOfElems++;
|
||||
i += 1;
|
||||
last->key = tsList[i];
|
||||
|
||||
GET_TYPED_DATA(last->val, double, pInputCol->info.type, colDataGetData(pInputCol, i));
|
||||
|
||||
pInfo->win.skey = last->key;
|
||||
numOfElems++;
|
||||
i += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SPoint1 st = {0};
|
||||
|
@ -5240,6 +5263,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
|||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||
continue;
|
||||
}
|
||||
numOfElems++;
|
||||
|
||||
INIT_INTP_POINT(st, tsList[i], val[i]);
|
||||
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
||||
|
@ -5254,6 +5278,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
|||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||
continue;
|
||||
}
|
||||
numOfElems++;
|
||||
|
||||
INIT_INTP_POINT(st, tsList[i], val[i]);
|
||||
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
||||
|
@ -5267,6 +5292,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
|||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||
continue;
|
||||
}
|
||||
numOfElems++;
|
||||
|
||||
INIT_INTP_POINT(st, tsList[i], val[i]);
|
||||
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
||||
|
@ -5280,6 +5306,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
|||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||
continue;
|
||||
}
|
||||
numOfElems++;
|
||||
|
||||
INIT_INTP_POINT(st, tsList[i], val[i]);
|
||||
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
||||
|
@ -5293,6 +5320,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
|||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||
continue;
|
||||
}
|
||||
numOfElems++;
|
||||
|
||||
INIT_INTP_POINT(st, tsList[i], val[i]);
|
||||
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
||||
|
@ -5306,6 +5334,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
|||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||
continue;
|
||||
}
|
||||
numOfElems++;
|
||||
|
||||
INIT_INTP_POINT(st, tsList[i], val[i]);
|
||||
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
||||
|
@ -5319,6 +5348,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
|||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||
continue;
|
||||
}
|
||||
numOfElems++;
|
||||
|
||||
INIT_INTP_POINT(st, tsList[i], val[i]);
|
||||
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
||||
|
@ -5332,6 +5362,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
|||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||
continue;
|
||||
}
|
||||
numOfElems++;
|
||||
|
||||
INIT_INTP_POINT(st, tsList[i], val[i]);
|
||||
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
||||
|
@ -5345,6 +5376,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
|||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||
continue;
|
||||
}
|
||||
numOfElems++;
|
||||
|
||||
INIT_INTP_POINT(st, tsList[i], val[i]);
|
||||
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
||||
|
@ -5358,6 +5390,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
|||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||
continue;
|
||||
}
|
||||
numOfElems++;
|
||||
|
||||
INIT_INTP_POINT(st, tsList[i], val[i]);
|
||||
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
||||
|
@ -5378,7 +5411,12 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
|||
|
||||
pInfo->win.ekey = pInfo->p.key;
|
||||
|
||||
SET_VAL(pResInfo, numOfElems, 1);
|
||||
_twa_over:
|
||||
if (numOfElems == 0) {
|
||||
pInfo->isNull = true;
|
||||
}
|
||||
|
||||
SET_VAL(pResInfo, 1, 1);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -5399,8 +5437,8 @@ int32_t twaFinalize(struct SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||
|
||||
STwaInfo* pInfo = (STwaInfo*)GET_ROWCELL_INTERBUF(pResInfo);
|
||||
if (pResInfo->numOfRes == 0) {
|
||||
pResInfo->isNullRes = 1;
|
||||
if (pInfo->isNull == true) {
|
||||
pResInfo->numOfRes = 0;
|
||||
} else {
|
||||
if (pInfo->win.ekey == pInfo->win.skey) {
|
||||
pInfo->dOutput = pInfo->p.val;
|
||||
|
@ -5661,7 +5699,12 @@ int32_t derivativeFunction(SqlFunctionCtx* pCtx) {
|
|||
double r = ((v - pDerivInfo->prevValue) * pDerivInfo->tsWindow) / (tsList[i] - pDerivInfo->prevTs);
|
||||
if (pDerivInfo->ignoreNegative && r < 0) {
|
||||
} else {
|
||||
colDataAppend(pOutput, pos, (const char*)&r, false);
|
||||
if (isinf(r) || isnan(r)) {
|
||||
colDataAppendNULL(pOutput, pos);
|
||||
} else {
|
||||
colDataAppend(pOutput, pos, (const char*)&r, false);
|
||||
}
|
||||
|
||||
if (pTsOutput != NULL) {
|
||||
colDataAppendInt64(pTsOutput, pos, &tsList[i]);
|
||||
}
|
||||
|
@ -5688,7 +5731,12 @@ int32_t derivativeFunction(SqlFunctionCtx* pCtx) {
|
|||
double r = ((pDerivInfo->prevValue - v) * pDerivInfo->tsWindow) / (pDerivInfo->prevTs - tsList[i]);
|
||||
if (pDerivInfo->ignoreNegative && r < 0) {
|
||||
} else {
|
||||
colDataAppend(pOutput, pos, (const char*)&r, false);
|
||||
if (isinf(r) || isnan(r)) {
|
||||
colDataAppendNULL(pOutput, pos);
|
||||
} else {
|
||||
colDataAppend(pOutput, pos, (const char*)&r, false);
|
||||
}
|
||||
|
||||
if (pTsOutput != NULL) {
|
||||
colDataAppendInt64(pTsOutput, pos, &pDerivInfo->prevTs);
|
||||
}
|
||||
|
|
|
@ -159,6 +159,8 @@ const char* nodesNodeName(ENodeType type) {
|
|||
return "ShowStreamsStmt";
|
||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||
return "ShowTablesStmt";
|
||||
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||
return "ShowTagsStmt";
|
||||
case QUERY_NODE_SHOW_USERS_STMT:
|
||||
return "ShowUsersStmt";
|
||||
case QUERY_NODE_SHOW_LICENCE_STMT:
|
||||
|
@ -4295,6 +4297,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
|||
return alterDnodeStmtToJson(pObj, pJson);
|
||||
case QUERY_NODE_SHOW_DATABASES_STMT:
|
||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||
break;
|
||||
case QUERY_NODE_CREATE_TOPIC_STMT:
|
||||
return createTopicStmtToJson(pObj, pJson);
|
||||
|
|
|
@ -216,6 +216,7 @@ SNode* nodesMakeNode(ENodeType type) {
|
|||
case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT:
|
||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||
return makeNode(type, sizeof(SShowStmt));
|
||||
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
||||
return makeNode(type, sizeof(SShowDnodeVariablesStmt));
|
||||
|
@ -678,7 +679,8 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
||||
case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT:
|
||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: {
|
||||
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_TAGS_STMT: {
|
||||
SShowStmt* pStmt = (SShowStmt*)pNode;
|
||||
nodesDestroyNode(pStmt->pDbName);
|
||||
nodesDestroyNode(pStmt->pTbName);
|
||||
|
@ -1923,15 +1925,18 @@ int32_t nodesPartitionCond(SNode** pCondition, SNode** pPrimaryKeyCond, SNode**
|
|||
return partitionLogicCond(pCondition, pPrimaryKeyCond, pTagIndexCond, pTagCond, pOtherCond);
|
||||
}
|
||||
|
||||
bool needOutput = false;
|
||||
switch (classifyCondition(*pCondition)) {
|
||||
case COND_TYPE_PRIMARY_KEY:
|
||||
if (NULL != pPrimaryKeyCond) {
|
||||
*pPrimaryKeyCond = *pCondition;
|
||||
needOutput = true;
|
||||
}
|
||||
break;
|
||||
case COND_TYPE_TAG_INDEX:
|
||||
if (NULL != pTagIndexCond) {
|
||||
*pTagIndexCond = *pCondition;
|
||||
needOutput = true;
|
||||
}
|
||||
if (NULL != pTagCond) {
|
||||
SNode* pTempCond = *pCondition;
|
||||
|
@ -1942,21 +1947,26 @@ int32_t nodesPartitionCond(SNode** pCondition, SNode** pPrimaryKeyCond, SNode**
|
|||
}
|
||||
}
|
||||
*pTagCond = pTempCond;
|
||||
needOutput = true;
|
||||
}
|
||||
break;
|
||||
case COND_TYPE_TAG:
|
||||
if (NULL != pTagCond) {
|
||||
*pTagCond = *pCondition;
|
||||
needOutput = true;
|
||||
}
|
||||
break;
|
||||
case COND_TYPE_NORMAL:
|
||||
default:
|
||||
if (NULL != pOtherCond) {
|
||||
*pOtherCond = *pCondition;
|
||||
needOutput = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
*pCondition = NULL;
|
||||
if (needOutput) {
|
||||
*pCondition = NULL;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -82,7 +82,6 @@ alter_account_option ::= STATE literal.
|
|||
/************************************************ create/alter/drop user **********************************************/
|
||||
cmd ::= CREATE USER user_name(A) PASS NK_STRING(B) sysinfo_opt(C). { pCxt->pRootNode = createCreateUserStmt(pCxt, &A, &B, C); }
|
||||
cmd ::= ALTER USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PASSWD, &B); }
|
||||
//cmd ::= ALTER USER user_name(A) PRIVILEGE NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PRIVILEGES, &B); }
|
||||
cmd ::= ALTER USER user_name(A) ENABLE NK_INTEGER(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_ENABLE, &B); }
|
||||
cmd ::= ALTER USER user_name(A) SYSINFO NK_INTEGER(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_SYSINFO, &B); }
|
||||
cmd ::= DROP USER user_name(A). { pCxt->pRootNode = createDropUserStmt(pCxt, &A); }
|
||||
|
@ -198,15 +197,15 @@ alter_db_options(A) ::= alter_db_options(B) alter_db_option(C).
|
|||
|
||||
%type alter_db_option { SAlterOption }
|
||||
%destructor alter_db_option { }
|
||||
alter_db_option(A) ::= BUFFER NK_INTEGER(B). { A.type = DB_OPTION_BUFFER; A.val = B; }
|
||||
//alter_db_option(A) ::= BUFFER NK_INTEGER(B). { A.type = DB_OPTION_BUFFER; A.val = B; }
|
||||
alter_db_option(A) ::= CACHEMODEL NK_STRING(B). { A.type = DB_OPTION_CACHEMODEL; A.val = B; }
|
||||
alter_db_option(A) ::= CACHESIZE NK_INTEGER(B). { A.type = DB_OPTION_CACHESIZE; A.val = B; }
|
||||
alter_db_option(A) ::= FSYNC NK_INTEGER(B). { A.type = DB_OPTION_FSYNC; A.val = B; }
|
||||
alter_db_option(A) ::= KEEP integer_list(B). { A.type = DB_OPTION_KEEP; A.pList = B; }
|
||||
alter_db_option(A) ::= KEEP variable_list(B). { A.type = DB_OPTION_KEEP; A.pList = B; }
|
||||
alter_db_option(A) ::= PAGES NK_INTEGER(B). { A.type = DB_OPTION_PAGES; A.val = B; }
|
||||
alter_db_option(A) ::= REPLICA NK_INTEGER(B). { A.type = DB_OPTION_REPLICA; A.val = B; }
|
||||
alter_db_option(A) ::= STRICT NK_INTEGER(B). { A.type = DB_OPTION_STRICT; A.val = B; }
|
||||
//alter_db_option(A) ::= PAGES NK_INTEGER(B). { A.type = DB_OPTION_PAGES; A.val = B; }
|
||||
//alter_db_option(A) ::= REPLICA NK_INTEGER(B). { A.type = DB_OPTION_REPLICA; A.val = B; }
|
||||
//alter_db_option(A) ::= STRICT NK_STRING(B). { A.type = DB_OPTION_STRICT; A.val = B; }
|
||||
alter_db_option(A) ::= WAL NK_INTEGER(B). { A.type = DB_OPTION_WAL; A.val = B; }
|
||||
|
||||
%type integer_list { SNodeList* }
|
||||
|
@ -394,6 +393,7 @@ cmd ::= SHOW TRANSACTIONS.
|
|||
cmd ::= SHOW TABLE DISTRIBUTED full_table_name(A). { pCxt->pRootNode = createShowTableDistributedStmt(pCxt, A); }
|
||||
cmd ::= SHOW CONSUMERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); }
|
||||
cmd ::= SHOW SUBSCRIPTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); }
|
||||
cmd ::= SHOW TAGS FROM table_name_cond(A) from_db_opt(B). { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, B, A, OP_TYPE_EQUAL); }
|
||||
|
||||
db_name_cond_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); }
|
||||
db_name_cond_opt(A) ::= db_name(B) NK_DOT. { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); }
|
||||
|
@ -525,7 +525,7 @@ cmd ::= INSERT INTO full_table_name(A)
|
|||
cmd ::= INSERT INTO full_table_name(A) query_expression(B). { pCxt->pRootNode = createInsertStmt(pCxt, A, NULL, B); }
|
||||
|
||||
/************************************************ literal *************************************************************/
|
||||
literal(A) ::= NK_INTEGER(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B)); }
|
||||
literal(A) ::= NK_INTEGER(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B)); }
|
||||
literal(A) ::= NK_FLOAT(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &B)); }
|
||||
literal(A) ::= NK_STRING(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B)); }
|
||||
literal(A) ::= NK_BOOL(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &B)); }
|
||||
|
@ -536,8 +536,8 @@ literal(A) ::= NK_QUESTION(B).
|
|||
|
||||
duration_literal(A) ::= NK_VARIABLE(B). { A = createRawExprNode(pCxt, &B, createDurationValueNode(pCxt, &B)); }
|
||||
|
||||
signed(A) ::= NK_INTEGER(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B); }
|
||||
signed(A) ::= NK_PLUS NK_INTEGER(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B); }
|
||||
signed(A) ::= NK_INTEGER(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B); }
|
||||
signed(A) ::= NK_PLUS NK_INTEGER(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B); }
|
||||
signed(A) ::= NK_MINUS(B) NK_INTEGER(C). {
|
||||
SToken t = B;
|
||||
t.n = (C.z + C.n) - B.z;
|
||||
|
|
|
@ -393,9 +393,16 @@ SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pL
|
|||
SValueNode* pVal = (SValueNode*)pLeft;
|
||||
char* pNewLiteral = taosMemoryCalloc(1, strlen(pVal->literal) + 2);
|
||||
CHECK_OUT_OF_MEM(pNewLiteral);
|
||||
sprintf(pNewLiteral, "-%s", pVal->literal);
|
||||
if ('+' == pVal->literal[0]) {
|
||||
sprintf(pNewLiteral, "-%s", pVal->literal + 1);
|
||||
} else if ('-' == pVal->literal[0]) {
|
||||
sprintf(pNewLiteral, "%s", pVal->literal + 1);
|
||||
} else {
|
||||
sprintf(pNewLiteral, "-%s", pVal->literal);
|
||||
}
|
||||
taosMemoryFree(pVal->literal);
|
||||
pVal->literal = pNewLiteral;
|
||||
pVal->node.resType.type = TSDB_DATA_TYPE_BIGINT;
|
||||
return pLeft;
|
||||
}
|
||||
SOperatorNode* op = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
|
@ -1343,7 +1350,11 @@ SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const
|
|||
CHECK_PARSER_STATUS(pCxt);
|
||||
SAlterDnodeStmt* pStmt = (SAlterDnodeStmt*)nodesMakeNode(QUERY_NODE_ALTER_DNODE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->dnodeId = taosStr2Int32(pDnode->z, NULL, 10);
|
||||
if (NULL != pDnode) {
|
||||
pStmt->dnodeId = taosStr2Int32(pDnode->z, NULL, 10);
|
||||
} else {
|
||||
pStmt->dnodeId = -1;
|
||||
}
|
||||
trimString(pConfig->z, pConfig->n, pStmt->config, sizeof(pStmt->config));
|
||||
if (NULL != pValue) {
|
||||
trimString(pValue->z, pValue->n, pStmt->value, sizeof(pStmt->value));
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue