Merge branch '3.0' of https://github.com/taosdata/TDengine into feature/3.0_mhli
This commit is contained in:
commit
13532f318d
|
@ -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.
|
- 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.
|
- 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.
|
- 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.
|
**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.
|
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_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_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_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_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_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.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).
|
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
|
### Priority of configuration parameters
|
||||||
|
@ -812,11 +820,12 @@ Please refer to: [JDBC example](https://github.com/taosdata/TDengine/tree/develo
|
||||||
|
|
||||||
## Recent update logs
|
## Recent update logs
|
||||||
|
|
||||||
| taos-jdbcdriver version | major changes |
|
| taos-jdbcdriver version | major changes |
|
||||||
| :---------------------: | :------------------------------------------: |
|
| :---------------------: | :--------------------------------------------: |
|
||||||
| 2.0.38 | JDBC REST connections add bulk pull function |
|
| 2.0.39 - 2.0.40 | Add REST connection/request timeout parameters |
|
||||||
| 2.0.37 | Added support for json tags |
|
| 2.0.38 | JDBC REST connections add bulk pull function |
|
||||||
| 2.0.36 | Add support for schemaless writing |
|
| 2.0.37 | Support json tags |
|
||||||
|
| 2.0.36 | Support schemaless writing |
|
||||||
|
|
||||||
## Frequently Asked Questions
|
## 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 连接支持大数据量查询,并提升查询性能。
|
- 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: 当开启批量拉取数据时,指定解析字符串数据的字符集。
|
- charset: 当开启批量拉取数据时,指定解析字符串数据的字符集。
|
||||||
- batchErrorIgnore:true:在执行 Statement 的 executeBatch 时,如果中间有一条 SQL 执行失败,继续执行下面的 SQL 了。false:不再执行失败 SQL 后的任何语句。默认值为:false。
|
- 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 连接中不生效。
|
**注意**:部分配置项(比如:locale、timezone)在 REST 连接中不生效。
|
||||||
|
|
||||||
|
@ -264,7 +268,11 @@ properties 中的配置参数如下:
|
||||||
- TSDBDriver.PROPERTY_KEY_CHARSET:客户端使用的字符集,默认值为系统字符集。
|
- TSDBDriver.PROPERTY_KEY_CHARSET:客户端使用的字符集,默认值为系统字符集。
|
||||||
- TSDBDriver.PROPERTY_KEY_LOCALE:仅在使用 JDBC 原生连接时生效。 客户端语言环境,默认值系统当前 locale。
|
- TSDBDriver.PROPERTY_KEY_LOCALE:仅在使用 JDBC 原生连接时生效。 客户端语言环境,默认值系统当前 locale。
|
||||||
- TSDBDriver.PROPERTY_KEY_TIME_ZONE:仅在使用 JDBC 原生连接时生效。 客户端使用的时区,默认值为系统当前时区。
|
- 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 版本 | 主要变化 |
|
| taos-jdbcdriver 版本 | 主要变化 |
|
||||||
| :------------------: | :----------------------------: |
|
| :------------------: | :----------------------------: |
|
||||||
|
| 2.0.39 - 2.0.40 | 增加 REST 连接/请求 超时设置 |
|
||||||
| 2.0.38 | JDBC REST 连接增加批量拉取功能 |
|
| 2.0.38 | JDBC REST 连接增加批量拉取功能 |
|
||||||
| 2.0.37 | 增加对 json tag 支持 |
|
| 2.0.37 | 增加对 json tag 支持 |
|
||||||
| 2.0.36 | 增加对 schemaless 写入支持 |
|
| 2.0.36 | 增加对 schemaless 写入支持 |
|
||||||
|
|
|
@ -259,7 +259,7 @@ enum tmq_res_t {
|
||||||
TMQ_RES_TABLE_META = 2,
|
TMQ_RES_TABLE_META = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct tmq_raw_data{
|
||||||
void* raw_meta;
|
void* raw_meta;
|
||||||
uint32_t raw_meta_len;
|
uint32_t raw_meta_len;
|
||||||
uint16_t raw_meta_type;
|
uint16_t raw_meta_type;
|
||||||
|
|
|
@ -54,12 +54,12 @@ enum {
|
||||||
enum {
|
enum {
|
||||||
STREAM_INPUT__DATA_SUBMIT = 1,
|
STREAM_INPUT__DATA_SUBMIT = 1,
|
||||||
STREAM_INPUT__DATA_BLOCK,
|
STREAM_INPUT__DATA_BLOCK,
|
||||||
|
STREAM_INPUT__MERGED_SUBMIT,
|
||||||
// STREAM_INPUT__TABLE_SCAN,
|
// STREAM_INPUT__TABLE_SCAN,
|
||||||
STREAM_INPUT__TQ_SCAN,
|
STREAM_INPUT__TQ_SCAN,
|
||||||
STREAM_INPUT__DATA_RETRIEVE,
|
STREAM_INPUT__DATA_RETRIEVE,
|
||||||
STREAM_INPUT__GET_RES,
|
STREAM_INPUT__GET_RES,
|
||||||
STREAM_INPUT__CHECKPOINT,
|
STREAM_INPUT__CHECKPOINT,
|
||||||
STREAM_INPUT__DROP,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum EStreamType {
|
typedef enum EStreamType {
|
||||||
|
|
|
@ -40,6 +40,7 @@ typedef struct SReadHandle {
|
||||||
bool initMetaReader;
|
bool initMetaReader;
|
||||||
bool initTableReader;
|
bool initTableReader;
|
||||||
bool initTqReader;
|
bool initTqReader;
|
||||||
|
int32_t numOfVgroups;
|
||||||
} SReadHandle;
|
} SReadHandle;
|
||||||
|
|
||||||
// in queue mode, data streams are seperated by msg
|
// in queue mode, data streams are seperated by msg
|
||||||
|
@ -63,7 +64,7 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers);
|
||||||
* @param SReadHandle
|
* @param SReadHandle
|
||||||
* @return
|
* @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.
|
* Set the input data block for the stream scan.
|
||||||
|
|
|
@ -162,9 +162,12 @@ typedef struct SRequestConnInfo {
|
||||||
SEpSet mgmtEps;
|
SEpSet mgmtEps;
|
||||||
} SRequestConnInfo;
|
} SRequestConnInfo;
|
||||||
|
|
||||||
|
typedef void (*__freeFunc)(void *param);
|
||||||
|
|
||||||
typedef struct SMsgSendInfo {
|
typedef struct SMsgSendInfo {
|
||||||
__async_send_cb_fn_t fp; // async callback function
|
__async_send_cb_fn_t fp; // async callback function
|
||||||
STargetInfo target; // for update epset
|
STargetInfo target; // for update epset
|
||||||
|
__freeFunc paramFreeFp;
|
||||||
void* param;
|
void* param;
|
||||||
uint64_t requestId;
|
uint64_t requestId;
|
||||||
uint64_t requestObjRefId;
|
uint64_t requestObjRefId;
|
||||||
|
@ -188,6 +191,8 @@ int32_t cleanupTaskQueue();
|
||||||
*/
|
*/
|
||||||
int32_t taosAsyncExec(__async_exec_fn_t execFn, void* execParam, int32_t* code);
|
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,
|
int32_t asyncSendMsgToServerExt(void* pTransporter, SEpSet* epSet, int64_t* pTransporterId, const SMsgSendInfo* pInfo,
|
||||||
bool persistHandle, void* ctx);
|
bool persistHandle, void* ctx);
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,13 @@ typedef struct {
|
||||||
SSubmitReq* data;
|
SSubmitReq* data;
|
||||||
} SStreamDataSubmit;
|
} SStreamDataSubmit;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t type;
|
||||||
|
int64_t ver;
|
||||||
|
SArray* dataRefs; // SArray<int32_t*>
|
||||||
|
SArray* reqs; // SArray<SSubmitReq*>
|
||||||
|
} SStreamMergedSubmit;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t type;
|
int8_t type;
|
||||||
|
|
||||||
|
@ -262,6 +269,7 @@ typedef struct SStreamTask {
|
||||||
int64_t startVer;
|
int64_t startVer;
|
||||||
int64_t checkpointVer;
|
int64_t checkpointVer;
|
||||||
int64_t processedVer;
|
int64_t processedVer;
|
||||||
|
int32_t numOfVgroups;
|
||||||
|
|
||||||
// children info
|
// children info
|
||||||
SArray* childEpInfo; // SArray<SStreamChildEpInfo*>
|
SArray* childEpInfo; // SArray<SStreamChildEpInfo*>
|
||||||
|
|
|
@ -64,6 +64,7 @@ typedef struct {
|
||||||
int64_t verInSnapshotting;
|
int64_t verInSnapshotting;
|
||||||
int64_t snapshotVer;
|
int64_t snapshotVer;
|
||||||
int64_t commitVer;
|
int64_t commitVer;
|
||||||
|
int64_t appliedVer;
|
||||||
int64_t lastVer;
|
int64_t lastVer;
|
||||||
} SWalVer;
|
} SWalVer;
|
||||||
|
|
||||||
|
@ -172,6 +173,9 @@ int32_t walRollback(SWal *, int64_t ver);
|
||||||
int32_t walBeginSnapshot(SWal *, int64_t ver);
|
int32_t walBeginSnapshot(SWal *, int64_t ver);
|
||||||
int32_t walEndSnapshot(SWal *);
|
int32_t walEndSnapshot(SWal *);
|
||||||
int32_t walRestoreFromSnapshot(SWal *, int64_t ver);
|
int32_t walRestoreFromSnapshot(SWal *, int64_t ver);
|
||||||
|
// for tq
|
||||||
|
int32_t walApplyVer(SWal *, int64_t ver);
|
||||||
|
|
||||||
// int32_t walDataCorrupted(SWal*);
|
// int32_t walDataCorrupted(SWal*);
|
||||||
|
|
||||||
// read
|
// read
|
||||||
|
@ -186,7 +190,6 @@ void walSetReaderCapacity(SWalReader *pRead, int32_t capacity);
|
||||||
int32_t walFetchHead(SWalReader *pRead, int64_t ver, SWalCkHead *pHead);
|
int32_t walFetchHead(SWalReader *pRead, int64_t ver, SWalCkHead *pHead);
|
||||||
int32_t walFetchBody(SWalReader *pRead, SWalCkHead **ppHead);
|
int32_t walFetchBody(SWalReader *pRead, SWalCkHead **ppHead);
|
||||||
int32_t walSkipFetchBody(SWalReader *pRead, const SWalCkHead *pHead);
|
int32_t walSkipFetchBody(SWalReader *pRead, const SWalCkHead *pHead);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t refId;
|
int64_t refId;
|
||||||
int64_t ver;
|
int64_t ver;
|
||||||
|
@ -206,6 +209,7 @@ int64_t walGetFirstVer(SWal *);
|
||||||
int64_t walGetSnapshotVer(SWal *);
|
int64_t walGetSnapshotVer(SWal *);
|
||||||
int64_t walGetLastVer(SWal *);
|
int64_t walGetLastVer(SWal *);
|
||||||
int64_t walGetCommittedVer(SWal *);
|
int64_t walGetCommittedVer(SWal *);
|
||||||
|
int64_t walGetAppliedVer(SWal *);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -493,10 +493,11 @@ int32_t* taosGetErrno();
|
||||||
|
|
||||||
//parser
|
//parser
|
||||||
#define TSDB_CODE_PAR_SYNTAX_ERROR TAOS_DEF_ERROR_CODE(0, 0x2600)
|
#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_INCOMPLETE_SQL TAOS_DEF_ERROR_CODE(0, 0x2601)
|
||||||
#define TSDB_CODE_PAR_TABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x2602)
|
#define TSDB_CODE_PAR_INVALID_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2602)
|
||||||
#define TSDB_CODE_PAR_AMBIGUOUS_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2603)
|
#define TSDB_CODE_PAR_TABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x2603)
|
||||||
#define TSDB_CODE_PAR_WRONG_VALUE_TYPE TAOS_DEF_ERROR_CODE(0, 0x2604)
|
#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_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_WRONG_NUMBER_OF_SELECT TAOS_DEF_ERROR_CODE(0, 0x2609)
|
||||||
#define TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION TAOS_DEF_ERROR_CODE(0, 0x260A)
|
#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_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_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_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_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_PASSWD_EMPTY TAOS_DEF_ERROR_CODE(0, 0x2611)
|
||||||
#define TSDB_CODE_PAR_INVALID_PORT TAOS_DEF_ERROR_CODE(0, 0x2612)
|
#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_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_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_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_DB_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_TABLE_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_GROUPBY_WINDOW_COEXIST TAOS_DEF_ERROR_CODE(0, 0x2624)
|
#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_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_TYPE TAOS_DEF_ERROR_CODE(0, 0x2628)
|
||||||
#define TSDB_CODE_PAR_INVALID_STATE_WIN_COL TAOS_DEF_ERROR_CODE(0, 0x2629)
|
#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_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_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_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_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_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)
|
#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*));
|
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
|
* add all element from the source array list into the destination
|
||||||
* @param pArray
|
* @param pArray
|
||||||
|
|
|
@ -38,4 +38,4 @@ fi
|
||||||
|
|
||||||
# there can not libtaos.so*, otherwise ln -s error
|
# there can not libtaos.so*, otherwise ln -s error
|
||||||
${csudo}rm -f ${install_main_dir}/driver/libtaos.* || :
|
${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}/taosdef.h || :
|
||||||
${csudo}rm -f ${inc_link_dir}/taoserror.h || :
|
${csudo}rm -f ${inc_link_dir}/taoserror.h || :
|
||||||
${csudo}rm -f ${inc_link_dir}/taosudf.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}/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 ${log_link_dir} || :
|
||||||
${csudo}rm -f ${data_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/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/${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/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/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/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}/../include/libs/function/taosudf.h ${pkg_dir}${install_home_path}/include
|
||||||
cp ${compile_dir}/build/include/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}/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/python ${pkg_dir}${install_home_path}/connector
|
||||||
#cp -r ${top_dir}/src/connector/go ${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 ||:
|
cp %{_compiledir}/build/bin/taosadapter %{buildroot}%{homepath}/bin ||:
|
||||||
fi
|
fi
|
||||||
cp %{_compiledir}/build/lib/${libfile} %{buildroot}%{homepath}/driver
|
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/client/taos.h %{buildroot}%{homepath}/include
|
||||||
cp %{_compiledir}/../include/common/taosdef.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/util/taoserror.h %{buildroot}%{homepath}/include
|
||||||
cp %{_compiledir}/../include/libs/function/taosudf.h %{buildroot}%{homepath}/include
|
cp %{_compiledir}/../include/libs/function/taosudf.h %{buildroot}%{homepath}/include
|
||||||
cp %{_compiledir}/build/include/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/python %{buildroot}%{homepath}/connector
|
||||||
#cp -r %{_compiledir}/../src/connector/go %{buildroot}%{homepath}/connector
|
#cp -r %{_compiledir}/../src/connector/go %{buildroot}%{homepath}/connector
|
||||||
#cp -r %{_compiledir}/../src/connector/nodejs %{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 ${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}/libtaos.so.1 ${lib_link_dir}/libtaos.so
|
||||||
|
|
||||||
[ -f ${install_main_dir}/driver/libtaosws.so ] && ${csudo}ln -s ${install_main_dir}/driver/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
|
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 ${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}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || :
|
||||||
|
|
||||||
${csudo}ln -s ${install_main_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
|
fi
|
||||||
|
|
||||||
${csudo}ldconfig
|
${csudo}ldconfig
|
||||||
|
@ -320,7 +320,7 @@ function install_jemalloc() {
|
||||||
function install_header() {
|
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}/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}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
|
${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/taoserror.h ${inc_link_dir}/taoserror.h
|
||||||
${csudo}ln -s ${install_main_dir}/include/taosudf.h ${inc_link_dir}/taosudf.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() {
|
function add_newHostname_to_hosts() {
|
||||||
|
|
|
@ -116,7 +116,8 @@ function install_bin() {
|
||||||
|
|
||||||
function clean_lib() {
|
function clean_lib() {
|
||||||
sudo rm -f /usr/lib/libtaos.* || :
|
sudo rm -f /usr/lib/libtaos.* || :
|
||||||
sudo rm -f /usr/lib/libtaosws.* || :
|
[ -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} || :
|
sudo rm -rf ${lib_dir} || :
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,8 +126,9 @@ function install_lib() {
|
||||||
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
|
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
|
||||||
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
|
${csudo}rm -f ${lib64_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}/libtaosws.* || :
|
[ -f ${lib64_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.so || :
|
||||||
|
|
||||||
#${csudo}rm -rf ${v15_java_app_dir} || :
|
#${csudo}rm -rf ${v15_java_app_dir} || :
|
||||||
|
|
||||||
${csudo}cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/*
|
${csudo}cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/*
|
||||||
|
@ -135,19 +137,19 @@ function install_lib() {
|
||||||
${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1
|
${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}/libtaos.so.1 ${lib_link_dir}/libtaos.so
|
||||||
|
|
||||||
[ -f ${install_main_dir}/driver/libtaosws.so ] && ${csudo}ln -s ${install_main_dir}/driver/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}" ]; then
|
if [ -d "${lib64_link_dir}" ]; then
|
||||||
${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || :
|
${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}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || :
|
||||||
|
|
||||||
[ -f ${install_main_dir}/driver/libtaosws.so ] && ${csudo}ln -s ${install_main_dir}/driver/libtaosws.so ${lib64_link_dir}/libtaosws.so || :
|
[ -f ${install_main_dir}/driver/libtaosws.so ] && ${csudo}ln -sf ${install_main_dir}/driver/libtaosws.so ${lib64_link_dir}/libtaosws.so || :
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.1.dylib
|
${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
|
${csudo}ln -s ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib
|
||||||
|
|
||||||
[ -f ${install_main_dir}/driver/libtaosws.dylib ] && ${csudo}ln -s ${install_main_dir}/driver/libtaosws.dylib ${lib_link_dir}/libtaosws.dylib
|
[ -f ${install_main_dir}/driver/libtaosws.dylib ] && ${csudo}ln -sf ${install_main_dir}/driver/libtaosws.dylib ${lib_link_dir}/libtaosws.dylib ||:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$osType" != "Darwin" ]; then
|
if [ "$osType" != "Darwin" ]; then
|
||||||
|
@ -165,7 +167,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/taoserror.h ${inc_link_dir}/taoserror.h
|
||||||
${csudo}ln -s ${install_main_dir}/include/taosudf.h ${inc_link_dir}/taosudf.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}/taos.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() {
|
function install_jemalloc() {
|
||||||
|
|
|
@ -294,10 +294,10 @@ function install_avro() {
|
||||||
function install_lib() {
|
function install_lib() {
|
||||||
# Remove links
|
# Remove links
|
||||||
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
|
${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
|
if [ "$osType" != "Darwin" ]; then
|
||||||
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
|
${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
|
fi
|
||||||
|
|
||||||
if [ "$osType" != "Darwin" ]; then
|
if [ "$osType" != "Darwin" ]; then
|
||||||
|
@ -362,13 +362,13 @@ function install_header() {
|
||||||
|
|
||||||
if [ "$osType" != "Darwin" ]; then
|
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}/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 \
|
${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/*
|
${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/*
|
||||||
|
|
||||||
if [ -f ${binary_dir}/build/include/taosws.h ]; then
|
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}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
|
fi
|
||||||
|
|
||||||
${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h
|
${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h
|
||||||
|
|
|
@ -93,7 +93,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
lib_files="${build_dir}/lib/libtaos.so.${version}"
|
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"
|
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"
|
wsheader_files="${build_dir}/include/taosws.h"
|
||||||
|
|
|
@ -82,33 +82,33 @@ function kill_taosd() {
|
||||||
|
|
||||||
function install_include() {
|
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 || :
|
${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}ln -s ${inc_dir}/taos.h ${inc_link_dir}/taos.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}/taosdef.h ${inc_link_dir}/taosdef.h
|
||||||
${csudo}ln -s ${inc_dir}/taoserror.h ${inc_link_dir}/taoserror.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 -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() {
|
function install_lib() {
|
||||||
${csudo}rm -f ${lib_link_dir}/libtaos* || :
|
${csudo}rm -f ${lib_link_dir}/libtaos* || :
|
||||||
${csudo}rm -f ${lib64_link_dir}/libtaos* || :
|
${csudo}rm -f ${lib64_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}/libtaosws* || :
|
[ -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_dir}/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}/libtaos.so.1 ${lib_link_dir}/libtaos.so
|
||||||
|
|
||||||
[ -f ${lib_dir}/libtaosws.so ]${csudo}ln -s ${lib_dir}/libtaosws.so ${lib_link_dir}/libtaosws.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
|
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 ${lib_dir}/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}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || :
|
||||||
|
|
||||||
[ -ff ${lib_dir}/libtaosws.so ] && ${csudo}ln -s ${lib_dir}/libtaosws.so ${lib64_link_dir}/libtaosws.so || :
|
[ -f ${lib_dir}/libtaosws.so ] && ${csudo}ln -sf ${lib_dir}/libtaosws.so ${lib64_link_dir}/libtaosws.so || :
|
||||||
fi
|
fi
|
||||||
|
|
||||||
${csudo}ldconfig
|
${csudo}ldconfig
|
||||||
|
|
|
@ -102,10 +102,10 @@ function clean_local_bin() {
|
||||||
function clean_lib() {
|
function clean_lib() {
|
||||||
# Remove link
|
# Remove link
|
||||||
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
|
${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}/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} || :
|
#${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}/taoserror.h || :
|
||||||
${csudo}rm -f ${inc_link_dir}/taosudf.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() {
|
function clean_config() {
|
||||||
|
|
|
@ -286,13 +286,10 @@ static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
if (pInst == NULL || NULL == *pInst) {
|
if (pInst == NULL || NULL == *pInst) {
|
||||||
taosThreadMutexUnlock(&appInfo.mutex);
|
taosThreadMutexUnlock(&appInfo.mutex);
|
||||||
tscError("cluster not exist, key:%s", key);
|
tscError("cluster not exist, key:%s", key);
|
||||||
taosMemoryFreeClear(param);
|
|
||||||
tFreeClientHbBatchRsp(&pRsp);
|
tFreeClientHbBatchRsp(&pRsp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFreeClear(param);
|
|
||||||
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
(*pInst)->onlineDnodes = ((*pInst)->totalDnodes ? 0 : -1);
|
(*pInst)->onlineDnodes = ((*pInst)->totalDnodes ? 0 : -1);
|
||||||
tscDebug("hb rsp error %s, update server status %d/%d", tstrerror(code), (*pInst)->onlineDnodes, (*pInst)->totalDnodes);
|
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->msgInfo.len = tlen;
|
||||||
pInfo->msgType = TDMT_MND_HEARTBEAT;
|
pInfo->msgType = TDMT_MND_HEARTBEAT;
|
||||||
pInfo->param = strdup(pAppHbMgr->key);
|
pInfo->param = strdup(pAppHbMgr->key);
|
||||||
|
pInfo->paramFreeFp = taosMemoryFree;
|
||||||
pInfo->requestId = generateRequestId();
|
pInfo->requestId = generateRequestId();
|
||||||
pInfo->requestObjRefId = 0;
|
pInfo->requestObjRefId = 0;
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
|
|
||||||
static int32_t initEpSetFromCfg(const char* firstEp, const char* secondEp, SCorEpSet* pEpSet);
|
static int32_t initEpSetFromCfg(const char* firstEp, const char* secondEp, SCorEpSet* pEpSet);
|
||||||
static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest);
|
static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest);
|
||||||
static void destroySendMsgInfo(SMsgSendInfo* pMsgBody);
|
|
||||||
|
|
||||||
static bool stringLengthCheck(const char* str, size_t maxsize) {
|
static bool stringLengthCheck(const char* str, size_t maxsize) {
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
|
@ -1215,13 +1214,6 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) {
|
||||||
return pMsgSendInfo;
|
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) {
|
void updateTargetEpSet(SMsgSendInfo* pSendInfo, STscObj* pTscObj, SRpcMsg* pMsg, SEpSet* pEpSet) {
|
||||||
if (NULL == pEpSet) {
|
if (NULL == pEpSet) {
|
||||||
return;
|
return;
|
||||||
|
@ -2101,8 +2093,9 @@ TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly) {
|
||||||
|
|
||||||
taosAsyncQueryImpl(*(int64_t*)taos, sql, syncQueryFn, param, validateOnly);
|
taosAsyncQueryImpl(*(int64_t*)taos, sql, syncQueryFn, param, validateOnly);
|
||||||
tsem_wait(¶m->sem);
|
tsem_wait(¶m->sem);
|
||||||
|
if (param->pRequest != NULL) {
|
||||||
param->pRequest->syncQuery = true;
|
param->pRequest->syncQuery = true;
|
||||||
|
}
|
||||||
return param->pRequest;
|
return param->pRequest;
|
||||||
#else
|
#else
|
||||||
size_t sqlLen = strlen(sql);
|
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);
|
catalogRemoveDB(pCatalog, dropdbRsp.db, dropdbRsp.uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosMemoryFree(pMsg->pData);
|
||||||
|
|
||||||
if (pRequest->body.queryFp != NULL) {
|
if (pRequest->body.queryFp != NULL) {
|
||||||
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
||||||
} else {
|
} else {
|
||||||
|
@ -278,6 +280,8 @@ int32_t processAlterStbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
pRequest->body.resInfo.execRes.res = alterRsp.pMeta;
|
pRequest->body.resInfo.execRes.res = alterRsp.pMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosMemoryFree(pMsg->pData);
|
||||||
|
|
||||||
if (pRequest->body.queryFp != NULL) {
|
if (pRequest->body.queryFp != NULL) {
|
||||||
SExecResult* pRes = &pRequest->body.resInfo.execRes;
|
SExecResult* pRes = &pRequest->body.resInfo.execRes;
|
||||||
|
|
||||||
|
@ -387,6 +391,8 @@ int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
tFreeSShowVariablesRsp(&rsp);
|
tFreeSShowVariablesRsp(&rsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosMemoryFree(pMsg->pData);
|
||||||
|
|
||||||
if (pRequest->body.queryFp != NULL) {
|
if (pRequest->body.queryFp != NULL) {
|
||||||
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1217,6 +1217,9 @@ static int32_t smlParseCols(const char *data, int32_t len, SArray *cols, char *c
|
||||||
kv->value = value;
|
kv->value = value;
|
||||||
kv->length = valueLen;
|
kv->length = valueLen;
|
||||||
if (isTag) {
|
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;
|
kv->type = TSDB_DATA_TYPE_NCHAR;
|
||||||
} else {
|
} else {
|
||||||
int32_t ret = smlParseValue(kv, msg);
|
int32_t ret = smlParseValue(kv, msg);
|
||||||
|
|
|
@ -504,6 +504,7 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT
|
||||||
pMsgSendInfo->requestId = generateRequestId();
|
pMsgSendInfo->requestId = generateRequestId();
|
||||||
pMsgSendInfo->requestObjRefId = 0;
|
pMsgSendInfo->requestObjRefId = 0;
|
||||||
pMsgSendInfo->param = pParam;
|
pMsgSendInfo->param = pParam;
|
||||||
|
pMsgSendInfo->paramFreeFp = taosMemoryFree;
|
||||||
pMsgSendInfo->fp = tmqCommitCb2;
|
pMsgSendInfo->fp = tmqCommitCb2;
|
||||||
pMsgSendInfo->msgType = TDMT_VND_MQ_COMMIT_OFFSET;
|
pMsgSendInfo->msgType = TDMT_VND_MQ_COMMIT_OFFSET;
|
||||||
// send msg
|
// send msg
|
||||||
|
@ -2192,17 +2193,19 @@ static char* buildCreateCTableJson(STag* pTag, char* sname, char* name, SArray*
|
||||||
cJSON* ttype = cJSON_CreateNumber(pTagVal->type);
|
cJSON* ttype = cJSON_CreateNumber(pTagVal->type);
|
||||||
cJSON_AddItemToObject(tag, "type", ttype);
|
cJSON_AddItemToObject(tag, "type", ttype);
|
||||||
|
|
||||||
char* buf = NULL;
|
cJSON* tvalue = NULL;
|
||||||
if (IS_VAR_DATA_TYPE(pTagVal->type)) {
|
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);
|
dataConverToStr(buf, pTagVal->type, pTagVal->pData, pTagVal->nData, NULL);
|
||||||
|
tvalue = cJSON_CreateString(buf);
|
||||||
|
taosMemoryFree(buf);
|
||||||
} else {
|
} else {
|
||||||
buf = taosMemoryCalloc(32, 1);
|
double val = 0;
|
||||||
dataConverToStr(buf, pTagVal->type, &pTagVal->i64, tDataTypes[pTagVal->type].bytes, NULL);
|
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_AddItemToObject(tag, "value", tvalue);
|
||||||
cJSON_AddItemToArray(tags, tag);
|
cJSON_AddItemToArray(tags, tag);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -556,7 +556,7 @@ static void taosSetSystemCfg(SConfig *pCfg) {
|
||||||
osSetSystemLocale(locale, charset);
|
osSetSystemLocale(locale, charset);
|
||||||
|
|
||||||
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
|
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
|
||||||
taosSetConsoleEcho(enableCore);
|
taosSetCoreDump(enableCore);
|
||||||
|
|
||||||
// todo
|
// todo
|
||||||
tsVersion = 30000000;
|
tsVersion = 30000000;
|
||||||
|
@ -675,7 +675,7 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
|
||||||
case 'e': {
|
case 'e': {
|
||||||
if (strcasecmp("enableCoreFile", name) == 0) {
|
if (strcasecmp("enableCoreFile", name) == 0) {
|
||||||
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
|
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
|
||||||
taosSetConsoleEcho(enableCore);
|
taosSetCoreDump(enableCore);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -265,6 +265,10 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) {
|
||||||
int64_t consumerId = be64toh(pReq->consumerId);
|
int64_t consumerId = be64toh(pReq->consumerId);
|
||||||
|
|
||||||
SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, consumerId);
|
SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, consumerId);
|
||||||
|
if (pConsumer == NULL) {
|
||||||
|
terrno = TSDB_CODE_MND_CONSUMER_NOT_EXIST;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
atomic_store_32(&pConsumer->hbStatus, 0);
|
atomic_store_32(&pConsumer->hbStatus, 0);
|
||||||
|
|
||||||
|
@ -452,7 +456,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SArray *newSub = subscribe.topicNames;
|
SArray *newSub = subscribe.topicNames;
|
||||||
taosArraySortString(newSub, taosArrayCompareString);
|
taosArraySortString(newSub, taosArrayCompareString);
|
||||||
taosArrayRemoveDuplicate(newSub, taosArrayCompareString, taosMemoryFree);
|
taosArrayRemoveDuplicateP(newSub, taosArrayCompareString, taosMemoryFree);
|
||||||
|
|
||||||
int32_t newTopicNum = taosArrayGetSize(newSub);
|
int32_t newTopicNum = taosArrayGetSize(newSub);
|
||||||
// check topic existance
|
// check topic existance
|
||||||
|
|
|
@ -383,6 +383,11 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) {
|
||||||
// exec
|
// exec
|
||||||
pInnerTask->execType = TASK_EXEC__PIPE;
|
pInnerTask->execType = TASK_EXEC__PIPE;
|
||||||
|
|
||||||
|
SDbObj* pSourceDb = mndAcquireDb(pMnode, pStream->sourceDb);
|
||||||
|
ASSERT(pDbObj != NULL);
|
||||||
|
sdbRelease(pSdb, pSourceDb);
|
||||||
|
pInnerTask->numOfVgroups = pSourceDb->cfg.numOfVgroups;
|
||||||
|
|
||||||
if (tsSchedStreamToSnode) {
|
if (tsSchedStreamToSnode) {
|
||||||
SSnodeObj* pSnode = mndSchedFetchOneSnode(pMnode);
|
SSnodeObj* pSnode = mndSchedFetchOneSnode(pMnode);
|
||||||
if (pSnode == NULL) {
|
if (pSnode == NULL) {
|
||||||
|
|
|
@ -148,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) {
|
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;
|
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) {
|
int32_t mndSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) {
|
||||||
|
@ -161,7 +163,7 @@ int32_t mndSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *pBuf, int
|
||||||
void mndLeaderTransfer(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
void mndLeaderTransfer(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
||||||
SMnode *pMnode = pFsm->data;
|
SMnode *pMnode = pFsm->data;
|
||||||
atomic_store_8(&(pMnode->syncMgmt.leaderTransferFinish), 1);
|
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) {
|
SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) {
|
||||||
|
|
|
@ -708,9 +708,13 @@ int32_t mndSetRpcInfoForDbTrans(SMnode *pMnode, SRpcMsg *pMsg, EOperType oper, c
|
||||||
if (pTrans->oper == oper) {
|
if (pTrans->oper == oper) {
|
||||||
if (strcasecmp(dbname, pTrans->dbname1) == 0) {
|
if (strcasecmp(dbname, pTrans->dbname1) == 0) {
|
||||||
mDebug("trans:%d, db:%s oper:%d matched with input", pTrans->id, dbname, oper);
|
mDebug("trans:%d, db:%s oper:%d matched with input", pTrans->id, dbname, oper);
|
||||||
if (taosArrayPush(pTrans->pRpcArray, &pMsg->info) != NULL) {
|
if (pTrans->pRpcArray == NULL) {
|
||||||
|
pTrans->pRpcArray = taosArrayInit(1, sizeof(SRpcHandleInfo));
|
||||||
|
}
|
||||||
|
if (pTrans->pRpcArray != NULL && taosArrayPush(pTrans->pRpcArray, &pMsg->info) != NULL) {
|
||||||
code = 0;
|
code = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sdbRelease(pMnode->pSdb, pTrans);
|
sdbRelease(pMnode->pSdb, pTrans);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -925,7 +925,7 @@ TEST_F(MndTestSdb, 01_Read_Str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sdbStopRead(pSdb, pReader);
|
sdbStopRead(pSdb, pReader);
|
||||||
sdbStopWrite(pSdb, pWritter, true);
|
sdbStopWrite(pSdb, pWritter, true, -1, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT_EQ(sdbGetSize(pSdb, SDB_CONSUMER), 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 sdbDoRead(SSdb *pSdb, SSdbIter *pIter, void **ppBuf, int32_t *len);
|
||||||
|
|
||||||
int32_t sdbStartWrite(SSdb *pSdb, SSdbIter **ppIter);
|
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);
|
int32_t sdbDoWrite(SSdb *pSdb, SSdbIter *pIter, void *pBuf, int32_t len);
|
||||||
|
|
||||||
const char *sdbTableName(ESdbType type);
|
const char *sdbTableName(ESdbType type);
|
||||||
|
|
|
@ -613,7 +613,7 @@ int32_t sdbStartWrite(SSdb *pSdb, SSdbIter **ppIter) {
|
||||||
return 0;
|
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;
|
int32_t code = 0;
|
||||||
|
|
||||||
if (!isApply) {
|
if (!isApply) {
|
||||||
|
@ -641,6 +641,19 @@ int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply) {
|
||||||
return -1;
|
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);
|
mDebug("sdbiter:%p, successfully applyed to sdb", pIter);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,23 +153,22 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosThreadRwlockUnlock(pLock);
|
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SdbInsertFp insertFp = pSdb->insertFps[pRow->type];
|
SdbInsertFp insertFp = pSdb->insertFps[pRow->type];
|
||||||
if (insertFp != NULL) {
|
if (insertFp != NULL) {
|
||||||
code = (*insertFp)(pSdb, pRow->pObj);
|
code = (*insertFp)(pSdb, pRow->pObj);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
taosThreadRwlockWrlock(pLock);
|
|
||||||
taosHashRemove(hash, pRow->pObj, keySize);
|
taosHashRemove(hash, pRow->pObj, keySize);
|
||||||
taosThreadRwlockUnlock(pLock);
|
|
||||||
sdbFreeRow(pSdb, pRow, false);
|
sdbFreeRow(pSdb, pRow, false);
|
||||||
terrno = code;
|
terrno = code;
|
||||||
|
taosThreadRwlockUnlock(pLock);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosThreadRwlockUnlock(pLock);
|
||||||
|
|
||||||
if (pSdb->keyTypes[pRow->type] == SDB_KEY_INT32) {
|
if (pSdb->keyTypes[pRow->type] == SDB_KEY_INT32) {
|
||||||
pSdb->maxId[pRow->type] = TMAX(pSdb->maxId[pRow->type], *((int32_t *)pRow->pObj));
|
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;
|
SSdbRow *pOldRow = *ppOldRow;
|
||||||
pOldRow->status = pRaw->status;
|
pOldRow->status = pRaw->status;
|
||||||
sdbPrintOper(pSdb, pOldRow, "update");
|
sdbPrintOper(pSdb, pOldRow, "update");
|
||||||
taosThreadRwlockUnlock(pLock);
|
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SdbUpdateFp updateFp = pSdb->updateFps[pNewRow->type];
|
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);
|
code = (*updateFp)(pSdb, pOldRow->pObj, pNewRow->pObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosThreadRwlockUnlock(pLock);
|
||||||
sdbFreeRow(pSdb, pNewRow, false);
|
sdbFreeRow(pSdb, pNewRow, false);
|
||||||
|
|
||||||
pSdb->tableVer[pOldRow->type]++;
|
pSdb->tableVer[pOldRow->type]++;
|
||||||
|
|
|
@ -88,7 +88,7 @@ typedef struct {
|
||||||
STqExecTb execTb;
|
STqExecTb execTb;
|
||||||
STqExecDb execDb;
|
STqExecDb execDb;
|
||||||
};
|
};
|
||||||
|
int32_t numOfCols; // number of out pout column, temporarily used
|
||||||
} STqExecHandle;
|
} STqExecHandle;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -174,6 +174,10 @@ void tsdbCalcColDataSMA(SColData *pColData, SColumnDataAgg *pColAgg);
|
||||||
int32_t tsdbMemTableCreate(STsdb *pTsdb, SMemTable **ppMemTable);
|
int32_t tsdbMemTableCreate(STsdb *pTsdb, SMemTable **ppMemTable);
|
||||||
void tsdbMemTableDestroy(SMemTable *pMemTable);
|
void tsdbMemTableDestroy(SMemTable *pMemTable);
|
||||||
void tsdbGetTbDataFromMemTable(SMemTable *pMemTable, tb_uid_t suid, tb_uid_t uid, STbData **ppTbData);
|
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
|
// STbDataIter
|
||||||
int32_t tsdbTbDataIterCreate(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDataIter **ppIter);
|
int32_t tsdbTbDataIterCreate(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDataIter **ppIter);
|
||||||
void *tsdbTbDataIterDestroy(STbDataIter *pIter);
|
void *tsdbTbDataIterDestroy(STbDataIter *pIter);
|
||||||
|
@ -273,23 +277,14 @@ typedef struct {
|
||||||
} SRtn;
|
} SRtn;
|
||||||
|
|
||||||
struct STsdb {
|
struct STsdb {
|
||||||
char *path;
|
char *path;
|
||||||
SVnode *pVnode;
|
SVnode *pVnode;
|
||||||
TdThreadMutex mutex;
|
STsdbKeepCfg keepCfg;
|
||||||
bool repoLocked;
|
TdThreadRwlock rwLock;
|
||||||
STsdbKeepCfg keepCfg;
|
SMemTable *mem;
|
||||||
SMemTable *mem;
|
SMemTable *imem;
|
||||||
SMemTable *imem;
|
STsdbFS *pFS;
|
||||||
SRtn rtn;
|
SLRUCache *lruCache;
|
||||||
STsdbFS *fs;
|
|
||||||
SLRUCache *lruCache;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct STable {
|
|
||||||
uint64_t suid;
|
|
||||||
uint64_t uid;
|
|
||||||
STSchema *pSchema; // latest schema
|
|
||||||
STSchema *pCacheSchema; // cached cache
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TSDBKEY {
|
struct TSDBKEY {
|
||||||
|
@ -330,21 +325,19 @@ struct STbData {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SMemTable {
|
struct SMemTable {
|
||||||
SRWLatch latch;
|
SRWLatch latch;
|
||||||
STsdb *pTsdb;
|
STsdb *pTsdb;
|
||||||
int32_t nRef;
|
SVBufPool *pPool;
|
||||||
TSKEY minKey;
|
volatile int32_t nRef;
|
||||||
TSKEY maxKey;
|
TSKEY minKey;
|
||||||
int64_t minVersion;
|
TSKEY maxKey;
|
||||||
int64_t maxVersion;
|
int64_t minVersion;
|
||||||
int64_t nRow;
|
int64_t maxVersion;
|
||||||
int64_t nDel;
|
int64_t nRow;
|
||||||
SArray *aTbData; // SArray<STbData*>
|
int64_t nDel;
|
||||||
|
SArray *aTbData; // SArray<STbData*>
|
||||||
};
|
};
|
||||||
|
|
||||||
int tsdbLockRepo(STsdb *pTsdb);
|
|
||||||
int tsdbUnlockRepo(STsdb *pTsdb);
|
|
||||||
|
|
||||||
struct TSDBROW {
|
struct TSDBROW {
|
||||||
int8_t type; // 0 for row from tsRow, 1 for row from block data
|
int8_t type; // 0 for row from tsRow, 1 for row from block data
|
||||||
union {
|
union {
|
||||||
|
|
|
@ -62,12 +62,13 @@ struct SVBufPoolNode {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SVBufPool {
|
struct SVBufPool {
|
||||||
SVBufPool* next;
|
SVBufPool* next;
|
||||||
int64_t nRef;
|
SVnode* pVnode;
|
||||||
int64_t size;
|
volatile int32_t nRef;
|
||||||
uint8_t* ptr;
|
int64_t size;
|
||||||
SVBufPoolNode* pTail;
|
uint8_t* ptr;
|
||||||
SVBufPoolNode node;
|
SVBufPoolNode* pTail;
|
||||||
|
SVBufPoolNode node;
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t vnodeOpenBufPool(SVnode* pVnode, int64_t size);
|
int32_t vnodeOpenBufPool(SVnode* pVnode, int64_t size);
|
||||||
|
@ -78,7 +79,7 @@ void vnodeBufPoolReset(SVBufPool* pPool);
|
||||||
int32_t vnodeQueryOpen(SVnode* pVnode);
|
int32_t vnodeQueryOpen(SVnode* pVnode);
|
||||||
void vnodeQueryClose(SVnode* pVnode);
|
void vnodeQueryClose(SVnode* pVnode);
|
||||||
int32_t vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg);
|
int32_t vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg);
|
||||||
int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg);
|
int vnodeGetTableCfg(SVnode* pVnode, SRpcMsg* pMsg);
|
||||||
|
|
||||||
// vnodeCommit.c
|
// vnodeCommit.c
|
||||||
int32_t vnodeBegin(SVnode* pVnode);
|
int32_t vnodeBegin(SVnode* pVnode);
|
||||||
|
|
|
@ -77,6 +77,8 @@ typedef struct SSnapDataHdr SSnapDataHdr;
|
||||||
// vnd.h
|
// vnd.h
|
||||||
void* vnodeBufPoolMalloc(SVBufPool* pPool, int size);
|
void* vnodeBufPoolMalloc(SVBufPool* pPool, int size);
|
||||||
void vnodeBufPoolFree(SVBufPool* pPool, void* p);
|
void vnodeBufPoolFree(SVBufPool* pPool, void* p);
|
||||||
|
void vnodeBufPoolRef(SVBufPool* pPool);
|
||||||
|
void vnodeBufPoolUnRef(SVBufPool* pPool);
|
||||||
|
|
||||||
// meta
|
// meta
|
||||||
typedef struct SMCtbCursor SMCtbCursor;
|
typedef struct SMCtbCursor SMCtbCursor;
|
||||||
|
@ -89,7 +91,7 @@ int metaBegin(SMeta* pMeta);
|
||||||
int metaCommit(SMeta* pMeta);
|
int metaCommit(SMeta* pMeta);
|
||||||
int metaCreateSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
int metaCreateSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
||||||
int metaAlterSTable(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 metaCreateTable(SMeta* pMeta, int64_t version, SVCreateTbReq* pReq);
|
||||||
int metaDropTable(SMeta* pMeta, int64_t version, SVDropTbReq* pReq, SArray* tbUids);
|
int metaDropTable(SMeta* pMeta, int64_t version, SVDropTbReq* pReq, SArray* tbUids);
|
||||||
int metaTtlDropTable(SMeta* pMeta, int64_t ttl, SArray* tbUids);
|
int metaTtlDropTable(SMeta* pMeta, int64_t ttl, SArray* tbUids);
|
||||||
|
@ -247,34 +249,34 @@ struct STsdbKeepCfg {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SVnode {
|
struct SVnode {
|
||||||
char* path;
|
char* path;
|
||||||
SVnodeCfg config;
|
SVnodeCfg config;
|
||||||
SVState state;
|
SVState state;
|
||||||
STfs* pTfs;
|
STfs* pTfs;
|
||||||
SMsgCb msgCb;
|
SMsgCb msgCb;
|
||||||
SVBufPool* pPool;
|
TdThreadMutex mutex;
|
||||||
SVBufPool* inUse;
|
TdThreadCond poolNotEmpty;
|
||||||
SVBufPool* onCommit;
|
SVBufPool* pPool;
|
||||||
SVBufPool* onRecycle;
|
SVBufPool* inUse;
|
||||||
SMeta* pMeta;
|
SMeta* pMeta;
|
||||||
SSma* pSma;
|
SSma* pSma;
|
||||||
STsdb* pTsdb;
|
STsdb* pTsdb;
|
||||||
SWal* pWal;
|
SWal* pWal;
|
||||||
STQ* pTq;
|
STQ* pTq;
|
||||||
SSink* pSink;
|
SSink* pSink;
|
||||||
tsem_t canCommit;
|
tsem_t canCommit;
|
||||||
int64_t sync;
|
int64_t sync;
|
||||||
int32_t blockCount;
|
int32_t blockCount;
|
||||||
tsem_t syncSem;
|
tsem_t syncSem;
|
||||||
SQHandle* pQuery;
|
SQHandle* pQuery;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TD_VID(PVNODE) ((PVNODE)->config.vgId)
|
#define TD_VID(PVNODE) ((PVNODE)->config.vgId)
|
||||||
|
|
||||||
#define VND_TSDB(vnd) ((vnd)->pTsdb)
|
#define VND_TSDB(vnd) ((vnd)->pTsdb)
|
||||||
#define VND_RSMA0(vnd) ((vnd)->pTsdb)
|
#define VND_RSMA0(vnd) ((vnd)->pTsdb)
|
||||||
#define VND_RSMA1(vnd) ((vnd)->pSma->pRSmaTsdb1)
|
#define VND_RSMA1(vnd) ((vnd)->pSma->pRSmaTsdb[TSDB_RETENTION_L0])
|
||||||
#define VND_RSMA2(vnd) ((vnd)->pSma->pRSmaTsdb2)
|
#define VND_RSMA2(vnd) ((vnd)->pSma->pRSmaTsdb[TSDB_RETENTION_L1])
|
||||||
#define VND_RETENTIONS(vnd) (&(vnd)->config.tsdbCfg.retentions)
|
#define VND_RETENTIONS(vnd) (&(vnd)->config.tsdbCfg.retentions)
|
||||||
#define VND_IS_RSMA(v) ((v)->config.isRsma == 1)
|
#define VND_IS_RSMA(v) ((v)->config.isRsma == 1)
|
||||||
#define VND_IS_TSMA(v) ((v)->config.isTsma == 1)
|
#define VND_IS_TSMA(v) ((v)->config.isTsma == 1)
|
||||||
|
@ -289,8 +291,7 @@ struct SSma {
|
||||||
bool locked;
|
bool locked;
|
||||||
TdThreadMutex mutex;
|
TdThreadMutex mutex;
|
||||||
SVnode* pVnode;
|
SVnode* pVnode;
|
||||||
STsdb* pRSmaTsdb1;
|
STsdb* pRSmaTsdb[TSDB_RETENTION_L2];
|
||||||
STsdb* pRSmaTsdb2;
|
|
||||||
void* pTSmaEnv;
|
void* pTSmaEnv;
|
||||||
void* pRSmaEnv;
|
void* pRSmaEnv;
|
||||||
};
|
};
|
||||||
|
@ -305,8 +306,8 @@ struct SSma {
|
||||||
#define SMA_TSMA_ENV(s) ((s)->pTSmaEnv)
|
#define SMA_TSMA_ENV(s) ((s)->pTSmaEnv)
|
||||||
#define SMA_RSMA_ENV(s) ((s)->pRSmaEnv)
|
#define SMA_RSMA_ENV(s) ((s)->pRSmaEnv)
|
||||||
#define SMA_RSMA_TSDB0(s) ((s)->pVnode->pTsdb)
|
#define SMA_RSMA_TSDB0(s) ((s)->pVnode->pTsdb)
|
||||||
#define SMA_RSMA_TSDB1(s) ((s)->pRSmaTsdb1)
|
#define SMA_RSMA_TSDB1(s) ((s)->pRSmaTsdb[TSDB_RETENTION_L0])
|
||||||
#define SMA_RSMA_TSDB2(s) ((s)->pRSmaTsdb2)
|
#define SMA_RSMA_TSDB2(s) ((s)->pRSmaTsdb[TSDB_RETENTION_L1])
|
||||||
|
|
||||||
// sma
|
// sma
|
||||||
void smaHandleRes(void* pVnode, int64_t smaId, const SArray* data);
|
void smaHandleRes(void* pVnode, int64_t smaId, const SArray* data);
|
||||||
|
|
|
@ -212,7 +212,7 @@ _err:
|
||||||
return -1;
|
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;
|
void *pKey = NULL;
|
||||||
int nKey = 0;
|
int nKey = 0;
|
||||||
void *pData = NULL;
|
void *pData = NULL;
|
||||||
|
@ -228,8 +228,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// drop all child tables
|
// drop all child tables
|
||||||
TBC *pCtbIdxc = NULL;
|
TBC *pCtbIdxc = NULL;
|
||||||
SArray *pArray = taosArrayInit(8, sizeof(tb_uid_t));
|
|
||||||
|
|
||||||
tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, &pMeta->txn);
|
tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, &pMeta->txn);
|
||||||
rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = pReq->suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayPush(pArray, &(((SCtbIdxKey *)pKey)->uid));
|
taosArrayPush(tbUidList, &(((SCtbIdxKey *)pKey)->uid));
|
||||||
}
|
}
|
||||||
|
|
||||||
tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
|
|
||||||
metaWLock(pMeta);
|
metaWLock(pMeta);
|
||||||
|
|
||||||
for (int32_t iChild = 0; iChild < taosArrayGetSize(pArray); iChild++) {
|
for (int32_t iChild = 0; iChild < taosArrayGetSize(tbUidList); iChild++) {
|
||||||
tb_uid_t uid = *(tb_uid_t *)taosArrayGet(pArray, iChild);
|
tb_uid_t uid = *(tb_uid_t *)taosArrayGet(tbUidList, iChild);
|
||||||
metaDropTableByUid(pMeta, uid, NULL);
|
metaDropTableByUid(pMeta, uid, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pArray);
|
|
||||||
|
|
||||||
// drop super table
|
// drop super table
|
||||||
_drop_super_table:
|
_drop_super_table:
|
||||||
tdbTbGet(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), &pData, &nData);
|
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);
|
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
|
// build SMetaEntry
|
||||||
me.version = version;
|
me.version = version;
|
||||||
me.type = pReq->type;
|
me.type = pReq->type;
|
||||||
|
|
|
@ -123,11 +123,9 @@ int32_t smaOpen(SVnode *pVnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore the rsma
|
// restore the rsma
|
||||||
#if 1
|
|
||||||
if (rsmaRestore(pSma) < 0) {
|
if (rsmaRestore(pSma) < 0) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -605,7 +605,7 @@ static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSche
|
||||||
snprintf(flag, 10, "level %" PRIi8, pItem->level);
|
snprintf(flag, 10, "level %" PRIi8, pItem->level);
|
||||||
blockDebugShowDataBlocks(pResult, flag);
|
blockDebugShowDataBlocks(pResult, flag);
|
||||||
#endif
|
#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;
|
SSubmitReq *pReq = NULL;
|
||||||
// TODO: the schema update should be handled
|
// TODO: the schema update should be handled
|
||||||
if (buildSubmitReqFromDataBlock(&pReq, pResult, pTSchema, SMA_VID(pSma), suid) < 0) {
|
if (buildSubmitReqFromDataBlock(&pReq, pResult, pTSchema, SMA_VID(pSma), suid) < 0) {
|
||||||
|
@ -949,13 +949,8 @@ _err:
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
static int32_t tdRSmaRestoreTSDataReload(SSma *pSma, int64_t committed) {
|
static int32_t tdRSmaRestoreTSDataReload(SSma *pSma, int64_t committed) {
|
||||||
// TODO
|
// NOTHING TODO: the data would be restored from the unified WAL replay procedure
|
||||||
smaDebug("vgId:%d, rsma restore from %" PRIi64 ", ts data reload success", SMA_VID(pSma), committed);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
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) {
|
int32_t tdProcessRSmaRestoreImpl(SSma *pSma) {
|
||||||
|
|
|
@ -506,7 +506,7 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
.initTqReader = true,
|
.initTqReader = true,
|
||||||
.version = ver,
|
.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]);
|
ASSERT(pHandle->execHandle.execCol.task[i]);
|
||||||
void* scanner = NULL;
|
void* scanner = NULL;
|
||||||
qExtractStreamScanner(pHandle->execHandle.execCol.task[i], &scanner);
|
qExtractStreamScanner(pHandle->execHandle.execCol.task[i], &scanner);
|
||||||
|
@ -591,7 +591,11 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
};
|
};
|
||||||
pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle);
|
pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle);
|
||||||
} else {
|
} 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);
|
ASSERT(pTask->exec.executor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include "tq.h"
|
#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);
|
int32_t dataStrLen = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock);
|
||||||
void* buf = taosMemoryCalloc(1, dataStrLen);
|
void* buf = taosMemoryCalloc(1, dataStrLen);
|
||||||
if (buf == NULL) return -1;
|
if (buf == NULL) return -1;
|
||||||
|
@ -29,7 +29,7 @@ static int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp)
|
||||||
|
|
||||||
// TODO enable compress
|
// TODO enable compress
|
||||||
int32_t actualLen = 0;
|
int32_t actualLen = 0;
|
||||||
blockEncode(pBlock, pRetrieve->data, &actualLen, taosArrayGetSize(pBlock->pDataBlock), false);
|
blockEncode(pBlock, pRetrieve->data, &actualLen, numOfCols, false);
|
||||||
actualLen += sizeof(SRetrieveTableRsp);
|
actualLen += sizeof(SRetrieveTableRsp);
|
||||||
ASSERT(actualLen <= dataStrLen);
|
ASSERT(actualLen <= dataStrLen);
|
||||||
taosArrayPush(pRsp->blockDataLen, &actualLen);
|
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) {
|
static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, SMqDataRsp* pRsp) {
|
||||||
SMetaReader mr = {0};
|
SMetaReader mr = {0};
|
||||||
metaReaderInit(&mr, pTq->pVnode->pMeta, 0);
|
metaReaderInit(&mr, pTq->pVnode->pMeta, 0);
|
||||||
|
// TODO add reference to gurantee success
|
||||||
if (metaGetTableEntryByUid(&mr, uid) < 0) {
|
if (metaGetTableEntryByUid(&mr, uid) < 0) {
|
||||||
ASSERT(0);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
char* tbName = strdup(mr.me.name);
|
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);
|
tqDebug("task execute end, get %p", pDataBlock);
|
||||||
|
|
||||||
if (pDataBlock != NULL) {
|
if (pDataBlock != NULL) {
|
||||||
tqAddBlockDataToRsp(pDataBlock, pRsp);
|
|
||||||
pRsp->blockNum++;
|
|
||||||
if (pRsp->withTbName) {
|
if (pRsp->withTbName) {
|
||||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||||
int64_t uid = pExec->pExecReader[0]->msgIter.uid;
|
int64_t uid = pExec->pExecReader[0]->msgIter.uid;
|
||||||
tqAddTbNameToRsp(pTq, uid, pRsp);
|
if (tqAddTbNameToRsp(pTq, uid, pRsp) < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
pRsp->withTbName = 0;
|
pRsp->withTbName = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols);
|
||||||
|
pRsp->blockNum++;
|
||||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
@ -193,13 +195,14 @@ int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataR
|
||||||
SSDataBlock block = {0};
|
SSDataBlock block = {0};
|
||||||
if (tqRetrieveDataBlock(&block, pReader) < 0) {
|
if (tqRetrieveDataBlock(&block, pReader) < 0) {
|
||||||
if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) continue;
|
if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) continue;
|
||||||
ASSERT(0);
|
|
||||||
}
|
}
|
||||||
tqAddBlockDataToRsp(&block, pRsp);
|
|
||||||
if (pRsp->withTbName) {
|
if (pRsp->withTbName) {
|
||||||
int64_t uid = pExec->pExecReader[workerId]->msgIter.uid;
|
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);
|
tqAddBlockSchemaToRsp(pExec, workerId, pRsp);
|
||||||
pRsp->blockNum++;
|
pRsp->blockNum++;
|
||||||
}
|
}
|
||||||
|
@ -211,13 +214,14 @@ int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataR
|
||||||
SSDataBlock block = {0};
|
SSDataBlock block = {0};
|
||||||
if (tqRetrieveDataBlock(&block, pReader) < 0) {
|
if (tqRetrieveDataBlock(&block, pReader) < 0) {
|
||||||
if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) continue;
|
if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) continue;
|
||||||
ASSERT(0);
|
|
||||||
}
|
}
|
||||||
tqAddBlockDataToRsp(&block, pRsp);
|
|
||||||
if (pRsp->withTbName) {
|
if (pRsp->withTbName) {
|
||||||
int64_t uid = pExec->pExecReader[workerId]->msgIter.uid;
|
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);
|
tqAddBlockSchemaToRsp(pExec, workerId, pRsp);
|
||||||
pRsp->blockNum++;
|
pRsp->blockNum++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,8 @@ int32_t tqMetaOpen(STQ* pTq) {
|
||||||
.initTqReader = true,
|
.initTqReader = true,
|
||||||
.version = handle.snapshotVer,
|
.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]);
|
ASSERT(handle.execHandle.execCol.task[i]);
|
||||||
void* scanner = NULL;
|
void* scanner = NULL;
|
||||||
qExtractStreamScanner(handle.execHandle.execCol.task[i], &scanner);
|
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
|
#endif
|
||||||
|
|
||||||
int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) {
|
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 (msgType == TDMT_VND_SUBMIT) {
|
||||||
if (taosHashGetSize(pTq->pStreamTasks) == 0) return 0;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -299,6 +299,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReader* pReader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockDataEnsureCapacity(pBlock, pReader->msgIter.numOfRows) < 0) {
|
if (blockDataEnsureCapacity(pBlock, pReader->msgIter.numOfRows) < 0) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,11 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo
|
||||||
}
|
}
|
||||||
|
|
||||||
SVCreateTbReq createTbReq = {0};
|
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.name = buildCtbNameByGroupId(stbFullName, pDataBlock->info.groupId);
|
||||||
createTbReq.ctb.name = strdup(stbFullName);
|
createTbReq.ctb.name = strdup((char*)tNameGetTableName(&name)); // strdup(stbFullName);
|
||||||
createTbReq.flags = 0;
|
createTbReq.flags = 0;
|
||||||
createTbReq.type = TSDB_CHILD_TABLE;
|
createTbReq.type = TSDB_CHILD_TABLE;
|
||||||
createTbReq.ctb.suid = suid;
|
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;
|
const SArray* pRes = (const SArray*)data;
|
||||||
SVnode* pVnode = (SVnode*)vnode;
|
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);
|
ASSERT(pTask->tbSink.pTSchema);
|
||||||
SSubmitReq* pReq = tdBlockToSubmit(pRes, pTask->tbSink.pTSchema, true, pTask->tbSink.stbUid,
|
SSubmitReq* pReq = tdBlockToSubmit(pRes, pTask->tbSink.pTSchema, true, pTask->tbSink.stbUid,
|
||||||
pTask->tbSink.stbFullName, pVnode->config.vgId);
|
pTask->tbSink.stbFullName, pVnode->config.vgId);
|
||||||
|
|
|
@ -464,7 +464,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) {
|
||||||
|
|
||||||
switch (state->state) {
|
switch (state->state) {
|
||||||
case SFSNEXTROW_FS:
|
case SFSNEXTROW_FS:
|
||||||
state->aDFileSet = state->pTsdb->fs->cState->aDFileSet;
|
state->aDFileSet = state->pTsdb->pFS->cState->aDFileSet;
|
||||||
state->nFileSet = taosArrayGetSize(state->aDFileSet);
|
state->nFileSet = taosArrayGetSize(state->aDFileSet);
|
||||||
state->iFileSet = state->nFileSet;
|
state->iFileSet = state->nFileSet;
|
||||||
|
|
||||||
|
@ -793,6 +793,9 @@ typedef struct {
|
||||||
TSDBROW memRow, imemRow, fsRow;
|
TSDBROW memRow, imemRow, fsRow;
|
||||||
|
|
||||||
TsdbNextRowState input[3];
|
TsdbNextRowState input[3];
|
||||||
|
SMemTable *pMemTable;
|
||||||
|
SMemTable *pIMemTable;
|
||||||
|
STsdb *pTsdb;
|
||||||
} CacheNextRowIter;
|
} CacheNextRowIter;
|
||||||
|
|
||||||
static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTsdb) {
|
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);
|
tb_uid_t suid = getTableSuidByUid(uid, pTsdb);
|
||||||
|
|
||||||
|
tsdbTakeMemSnapshot(pTsdb, &pIter->pMemTable, &pIter->pIMemTable);
|
||||||
|
|
||||||
STbData *pMem = NULL;
|
STbData *pMem = NULL;
|
||||||
if (pTsdb->mem) {
|
if (pIter->pMemTable) {
|
||||||
tsdbGetTbDataFromMemTable(pTsdb->mem, suid, uid, &pMem);
|
tsdbGetTbDataFromMemTable(pIter->pMemTable, suid, uid, &pMem);
|
||||||
}
|
}
|
||||||
|
|
||||||
STbData *pIMem = NULL;
|
STbData *pIMem = NULL;
|
||||||
if (pTsdb->imem) {
|
if (pIter->pIMemTable) {
|
||||||
tsdbGetTbDataFromMemTable(pTsdb->imem, suid, uid, &pIMem);
|
tsdbGetTbDataFromMemTable(pIter->pIMemTable, suid, uid, &pIMem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pIter->pTsdb = pTsdb;
|
||||||
|
|
||||||
pIter->pSkyline = taosArrayInit(32, sizeof(TSDBKEY));
|
pIter->pSkyline = taosArrayInit(32, sizeof(TSDBKEY));
|
||||||
|
|
||||||
SDelIdx delIdx;
|
SDelIdx delIdx;
|
||||||
|
|
||||||
SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->fs->cState);
|
SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState);
|
||||||
if (pDelFile) {
|
if (pDelFile) {
|
||||||
SDelFReader *pDelFReader;
|
SDelFReader *pDelFReader;
|
||||||
|
|
||||||
|
@ -878,6 +885,8 @@ static int32_t nextRowIterClose(CacheNextRowIter *pIter) {
|
||||||
taosArrayDestroy(pIter->pSkyline);
|
taosArrayDestroy(pIter->pSkyline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tsdbUntakeMemSnapshot(pIter->pTsdb, pIter->pMemTable, pIter->pIMemTable);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
_err:
|
_err:
|
||||||
return code;
|
return code;
|
||||||
|
@ -1189,7 +1198,7 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRo
|
||||||
|
|
||||||
SDelIdx delIdx;
|
SDelIdx delIdx;
|
||||||
|
|
||||||
SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->fs->cState);
|
SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState);
|
||||||
if (pDelFile) {
|
if (pDelFile) {
|
||||||
SDelFReader *pDelFReader;
|
SDelFReader *pDelFReader;
|
||||||
|
|
||||||
|
@ -1377,7 +1386,7 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) {
|
||||||
|
|
||||||
SDelIdx delIdx;
|
SDelIdx delIdx;
|
||||||
|
|
||||||
SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->fs->cState);
|
SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState);
|
||||||
if (pDelFile) {
|
if (pDelFile) {
|
||||||
SDelFReader *pDelFReader;
|
SDelFReader *pDelFReader;
|
||||||
|
|
||||||
|
|
|
@ -64,9 +64,26 @@ int32_t tsdbBegin(STsdb *pTsdb) {
|
||||||
|
|
||||||
if (!pTsdb) return code;
|
if (!pTsdb) return code;
|
||||||
|
|
||||||
code = tsdbMemTableCreate(pTsdb, &pTsdb->mem);
|
SMemTable *pMemTable;
|
||||||
|
code = tsdbMemTableCreate(pTsdb, &pMemTable);
|
||||||
if (code) goto _err;
|
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;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
|
@ -83,9 +100,11 @@ int32_t tsdbCommit(STsdb *pTsdb) {
|
||||||
|
|
||||||
// check
|
// check
|
||||||
if (pMemTable->nRow == 0 && pMemTable->nDel == 0) {
|
if (pMemTable->nRow == 0 && pMemTable->nDel == 0) {
|
||||||
// TODO: lock?
|
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
||||||
pTsdb->mem = NULL;
|
pTsdb->mem = NULL;
|
||||||
tsdbMemTableDestroy(pMemTable);
|
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||||
|
|
||||||
|
tsdbUnrefMemTable(pMemTable);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +158,7 @@ static int32_t tsdbCommitDelStart(SCommitter *pCommitter) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDelFile *pDelFileR = pTsdb->fs->nState->pDelFile;
|
SDelFile *pDelFileR = pTsdb->pFS->nState->pDelFile;
|
||||||
if (pDelFileR) {
|
if (pDelFileR) {
|
||||||
code = tsdbDelFReaderOpen(&pCommitter->pDelFReader, pDelFileR, pTsdb, NULL);
|
code = tsdbDelFReaderOpen(&pCommitter->pDelFReader, pDelFileR, pTsdb, NULL);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
@ -228,7 +247,7 @@ static int32_t tsdbCommitDelEnd(SCommitter *pCommitter) {
|
||||||
code = tsdbUpdateDelFileHdr(pCommitter->pDelFWriter);
|
code = tsdbUpdateDelFileHdr(pCommitter->pDelFWriter);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
code = tsdbFSStateUpsertDelFile(pTsdb->fs->nState, &pCommitter->pDelFWriter->fDel);
|
code = tsdbFSStateUpsertDelFile(pTsdb->pFS->nState, &pCommitter->pDelFWriter->fDel);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
code = tsdbDelFWriterClose(&pCommitter->pDelFWriter, 1);
|
code = tsdbDelFWriterClose(&pCommitter->pDelFWriter, 1);
|
||||||
|
@ -263,7 +282,7 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
|
||||||
taosArrayClear(pCommitter->aBlockIdx);
|
taosArrayClear(pCommitter->aBlockIdx);
|
||||||
tMapDataReset(&pCommitter->oBlockMap);
|
tMapDataReset(&pCommitter->oBlockMap);
|
||||||
tBlockDataReset(&pCommitter->oBlockData);
|
tBlockDataReset(&pCommitter->oBlockData);
|
||||||
pRSet = tsdbFSStateGetDFileSet(pTsdb->fs->nState, pCommitter->commitFid, TD_EQ);
|
pRSet = tsdbFSStateGetDFileSet(pTsdb->pFS->nState, pCommitter->commitFid, TD_EQ);
|
||||||
if (pRSet) {
|
if (pRSet) {
|
||||||
code = tsdbDataFReaderOpen(&pCommitter->pReader, pTsdb, pRSet);
|
code = tsdbDataFReaderOpen(&pCommitter->pReader, pTsdb, pRSet);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
@ -836,7 +855,7 @@ static int32_t tsdbCommitFileDataEnd(SCommitter *pCommitter) {
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
// upsert SDFileSet
|
// upsert SDFileSet
|
||||||
code = tsdbFSStateUpsertDFileSet(pCommitter->pTsdb->fs->nState, tsdbDataFWriterGetWSet(pCommitter->pWriter));
|
code = tsdbFSStateUpsertDFileSet(pCommitter->pTsdb->pFS->nState, tsdbDataFWriterGetWSet(pCommitter->pWriter));
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
// close and sync
|
// close and sync
|
||||||
|
@ -941,10 +960,10 @@ static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter) {
|
||||||
memset(pCommitter, 0, sizeof(*pCommitter));
|
memset(pCommitter, 0, sizeof(*pCommitter));
|
||||||
ASSERT(pTsdb->mem && pTsdb->imem == NULL);
|
ASSERT(pTsdb->mem && pTsdb->imem == NULL);
|
||||||
|
|
||||||
// lock();
|
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
||||||
pTsdb->imem = pTsdb->mem;
|
pTsdb->imem = pTsdb->mem;
|
||||||
pTsdb->mem = NULL;
|
pTsdb->mem = NULL;
|
||||||
// unlock();
|
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||||
|
|
||||||
pCommitter->pTsdb = pTsdb;
|
pCommitter->pTsdb = pTsdb;
|
||||||
pCommitter->commitID = pTsdb->pVnode->state.commitID;
|
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->maxRow = pTsdb->pVnode->config.tsdbCfg.maxRows;
|
||||||
pCommitter->cmprAlg = pTsdb->pVnode->config.tsdbCfg.compression;
|
pCommitter->cmprAlg = pTsdb->pVnode->config.tsdbCfg.compression;
|
||||||
|
|
||||||
code = tsdbFSBegin(pTsdb->fs);
|
code = tsdbFSBegin(pTsdb->pFS);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -1135,13 +1154,16 @@ static int32_t tsdbEndCommit(SCommitter *pCommitter, int32_t eno) {
|
||||||
SMemTable *pMemTable = pTsdb->imem;
|
SMemTable *pMemTable = pTsdb->imem;
|
||||||
|
|
||||||
if (eno == 0) {
|
if (eno == 0) {
|
||||||
code = tsdbFSCommit(pTsdb->fs);
|
code = tsdbFSCommit(pTsdb->pFS);
|
||||||
} else {
|
} else {
|
||||||
code = tsdbFSRollback(pTsdb->fs);
|
code = tsdbFSRollback(pTsdb->pFS);
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbMemTableDestroy(pMemTable);
|
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
||||||
pTsdb->imem = NULL;
|
pTsdb->imem = NULL;
|
||||||
|
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||||
|
|
||||||
|
tsdbUnrefMemTable(pMemTable);
|
||||||
|
|
||||||
tsdbInfo("vgId:%d tsdb end commit", TD_VID(pTsdb->pVnode));
|
tsdbInfo("vgId:%d tsdb end commit", TD_VID(pTsdb->pVnode));
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -41,6 +41,7 @@ int32_t tsdbMemTableCreate(STsdb *pTsdb, SMemTable **ppMemTable) {
|
||||||
}
|
}
|
||||||
taosInitRWLatch(&pMemTable->latch);
|
taosInitRWLatch(&pMemTable->latch);
|
||||||
pMemTable->pTsdb = pTsdb;
|
pMemTable->pTsdb = pTsdb;
|
||||||
|
pMemTable->pPool = pTsdb->pVnode->inUse;
|
||||||
pMemTable->nRef = 1;
|
pMemTable->nRef = 1;
|
||||||
pMemTable->minKey = TSKEY_MAX;
|
pMemTable->minKey = TSKEY_MAX;
|
||||||
pMemTable->maxKey = TSKEY_MIN;
|
pMemTable->maxKey = TSKEY_MIN;
|
||||||
|
@ -54,6 +55,7 @@ int32_t tsdbMemTableCreate(STsdb *pTsdb, SMemTable **ppMemTable) {
|
||||||
taosMemoryFree(pMemTable);
|
taosMemoryFree(pMemTable);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
vnodeBufPoolRef(pMemTable->pPool);
|
||||||
|
|
||||||
*ppMemTable = pMemTable;
|
*ppMemTable = pMemTable;
|
||||||
return code;
|
return code;
|
||||||
|
@ -65,6 +67,7 @@ _err:
|
||||||
|
|
||||||
void tsdbMemTableDestroy(SMemTable *pMemTable) {
|
void tsdbMemTableDestroy(SMemTable *pMemTable) {
|
||||||
if (pMemTable) {
|
if (pMemTable) {
|
||||||
|
vnodeBufPoolUnRef(pMemTable->pPool);
|
||||||
taosArrayDestroy(pMemTable->aTbData);
|
taosArrayDestroy(pMemTable->aTbData);
|
||||||
taosMemoryFree(pMemTable);
|
taosMemoryFree(pMemTable);
|
||||||
}
|
}
|
||||||
|
@ -590,3 +593,58 @@ _err:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbGetNRowsInTbData(STbData *pTbData) { return pTbData->sl.size; }
|
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);
|
sprintf(pTsdb->path, "%s%s%s", pVnode->path, TD_DIRSEP, dir);
|
||||||
taosRealPath(pTsdb->path, NULL, slen);
|
taosRealPath(pTsdb->path, NULL, slen);
|
||||||
pTsdb->pVnode = pVnode;
|
pTsdb->pVnode = pVnode;
|
||||||
pTsdb->repoLocked = false;
|
taosThreadRwlockInit(&pTsdb->rwLock, NULL);
|
||||||
taosThreadMutexInit(&pTsdb->mutex, NULL);
|
|
||||||
if (!pKeepCfg) {
|
if (!pKeepCfg) {
|
||||||
tsdbSetKeepCfg(&pTsdb->keepCfg, &pVnode->config.tsdbCfg);
|
tsdbSetKeepCfg(&pTsdb->keepCfg, &pVnode->config.tsdbCfg);
|
||||||
} else {
|
} else {
|
||||||
|
@ -67,7 +66,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee
|
||||||
tfsMkdir(pVnode->pTfs, pTsdb->path);
|
tfsMkdir(pVnode->pTfs, pTsdb->path);
|
||||||
|
|
||||||
// open tsdb
|
// open tsdb
|
||||||
if (tsdbFSOpen(pTsdb, &pTsdb->fs) < 0) {
|
if (tsdbFSOpen(pTsdb, &pTsdb->pFS) < 0) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,33 +87,10 @@ _err:
|
||||||
|
|
||||||
int tsdbClose(STsdb **pTsdb) {
|
int tsdbClose(STsdb **pTsdb) {
|
||||||
if (*pTsdb) {
|
if (*pTsdb) {
|
||||||
taosThreadMutexDestroy(&(*pTsdb)->mutex);
|
taosThreadRwlockDestroy(&(*pTsdb)->rwLock);
|
||||||
tsdbFSClose((*pTsdb)->fs);
|
tsdbFSClose((*pTsdb)->pFS);
|
||||||
tsdbCloseCache((*pTsdb)->lruCache);
|
tsdbCloseCache((*pTsdb)->lruCache);
|
||||||
taosMemoryFreeClear(*pTsdb);
|
taosMemoryFreeClear(*pTsdb);
|
||||||
}
|
}
|
||||||
return 0;
|
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
|
char* idStr; // query info handle, for debug purpose
|
||||||
int32_t type; // query type: 1. retrieve all data blocks, 2. retrieve direct prev|next rows
|
int32_t type; // query type: 1. retrieve all data blocks, 2. retrieve direct prev|next rows
|
||||||
SBlockLoadSuppInfo suppInfo;
|
SBlockLoadSuppInfo suppInfo;
|
||||||
|
SMemTable* pMem;
|
||||||
|
SMemTable* pIMem;
|
||||||
|
|
||||||
SIOCostSummary cost;
|
SIOCostSummary cost;
|
||||||
STSchema* pSchema;
|
STSchema* pSchema;
|
||||||
|
@ -1453,38 +1455,70 @@ static bool keyOverlapFileBlock(TSDBKEY key, SBlock* pBlock, SVersionRange* pVer
|
||||||
(pBlock->minVersion <= pVerRange->maxVer);
|
(pBlock->minVersion <= pVerRange->maxVer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool overlapWithDelSkyline(STableBlockScanInfo* pBlockScanInfo, const SBlock* pBlock, int32_t order) {
|
static bool doCheckforDatablockOverlap(STableBlockScanInfo* pBlockScanInfo, const SBlock* pBlock) {
|
||||||
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
|
|
||||||
size_t num = taosArrayGetSize(pBlockScanInfo->delSkyline);
|
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);
|
TSDBKEY* p = taosArrayGet(pBlockScanInfo->delSkyline, i);
|
||||||
if (p->ts >= pBlock->minKey.ts && p->ts <= pBlock->maxKey.ts) {
|
if (p->ts >= pBlock->minKey.ts && p->ts <= pBlock->maxKey.ts) {
|
||||||
if (p->version >= pBlock->minVersion) {
|
if (p->version >= pBlock->minVersion) {
|
||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(0);
|
|
||||||
return false;
|
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
|
// 1. the version of all rows should be less than the endVersion
|
||||||
// 2. current block should not overlap with next neighbor block
|
// 2. current block should not overlap with next neighbor block
|
||||||
// 3. current timestamp should not be overlap with each other
|
// 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));
|
int32_t backward = (!ASCENDING_TRAVERSE(pReader->order));
|
||||||
|
|
||||||
STbData* d = NULL;
|
STbData* d = NULL;
|
||||||
if (pReader->pTsdb->mem != NULL) {
|
if (pReader->pMem != NULL) {
|
||||||
tsdbGetTbDataFromMemTable(pReader->pTsdb->mem, pReader->suid, pBlockScanInfo->uid, &d);
|
tsdbGetTbDataFromMemTable(pReader->pMem, pReader->suid, pBlockScanInfo->uid, &d);
|
||||||
if (d != NULL) {
|
if (d != NULL) {
|
||||||
code = tsdbTbDataIterCreate(d, &startKey, backward, &pBlockScanInfo->iter.iter);
|
code = tsdbTbDataIterCreate(d, &startKey, backward, &pBlockScanInfo->iter.iter);
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
@ -1868,8 +1902,8 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
|
||||||
}
|
}
|
||||||
|
|
||||||
STbData* di = NULL;
|
STbData* di = NULL;
|
||||||
if (pReader->pTsdb->imem != NULL) {
|
if (pReader->pIMem != NULL) {
|
||||||
tsdbGetTbDataFromMemTable(pReader->pTsdb->imem, pReader->suid, pBlockScanInfo->uid, &di);
|
tsdbGetTbDataFromMemTable(pReader->pIMem, pReader->suid, pBlockScanInfo->uid, &di);
|
||||||
if (di != NULL) {
|
if (di != NULL) {
|
||||||
code = tsdbTbDataIterCreate(di, &startKey, backward, &pBlockScanInfo->iiter.iter);
|
code = tsdbTbDataIterCreate(di, &startKey, backward, &pBlockScanInfo->iiter.iter);
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
@ -1905,7 +1939,7 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader*
|
||||||
|
|
||||||
SArray* pDelData = taosArrayInit(4, sizeof(SDelData));
|
SArray* pDelData = taosArrayInit(4, sizeof(SDelData));
|
||||||
|
|
||||||
SDelFile* pDelFile = tsdbFSStateGetDelFile(pTsdb->fs->cState);
|
SDelFile* pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState);
|
||||||
if (pDelFile) {
|
if (pDelFile) {
|
||||||
SDelFReader* pDelFReader = NULL;
|
SDelFReader* pDelFReader = NULL;
|
||||||
code = tsdbDelFReaderOpen(&pDelFReader, pDelFile, pTsdb, 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 idx = {.suid = pReader->suid, .uid = pBlockScanInfo->uid};
|
||||||
SDelIdx* pIdx = taosArraySearch(aDelIdx, &idx, tCmprDelIdx, TD_EQ);
|
SDelIdx* pIdx = taosArraySearch(aDelIdx, &idx, tCmprDelIdx, TD_EQ);
|
||||||
|
|
||||||
code = tsdbReadDelData(pDelFReader, pIdx, pDelData, NULL);
|
if (pIdx != NULL) {
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
code = tsdbReadDelData(pDelFReader, pIdx, pDelData, NULL);
|
||||||
goto _err;
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2771,7 +2807,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
|
||||||
|
|
||||||
if (pCond->suid != 0) {
|
if (pCond->suid != 0) {
|
||||||
(*ppReader)->pSchema = metaGetTbTSchema((*ppReader)->pTsdb->pVnode->pMeta, (*ppReader)->suid, -1);
|
(*ppReader)->pSchema = metaGetTbTSchema((*ppReader)->pTsdb->pVnode->pMeta, (*ppReader)->suid, -1);
|
||||||
ASSERT((*ppReader)->pSchema);
|
// ASSERT((*ppReader)->pSchema);
|
||||||
} else if (taosArrayGetSize(pTableList) > 0) {
|
} else if (taosArrayGetSize(pTableList) > 0) {
|
||||||
STableKeyInfo* pKey = taosArrayGet(pTableList, 0);
|
STableKeyInfo* pKey = taosArrayGet(pTableList, 0);
|
||||||
(*ppReader)->pSchema = metaGetTbTSchema((*ppReader)->pTsdb->pVnode->pMeta, pKey->uid, -1);
|
(*ppReader)->pSchema = metaGetTbTSchema((*ppReader)->pTsdb->pVnode->pMeta, pKey->uid, -1);
|
||||||
|
@ -2795,7 +2831,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
|
||||||
|
|
||||||
SDataBlockIter* pBlockIter = &pReader->status.blockIter;
|
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);
|
initFilesetIterator(&pReader->status.fileIter, pFState, pReader->order, pReader->idStr);
|
||||||
resetDataBlockIterator(&pReader->status.blockIter, pReader->order);
|
resetDataBlockIterator(&pReader->status.blockIter, pReader->order);
|
||||||
|
|
||||||
|
@ -2809,6 +2845,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);
|
tsdbDebug("%p total numOfTable:%d in this query %s", pReader, numOfTables, pReader->idStr);
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
|
@ -2824,6 +2862,8 @@ void tsdbReaderClose(STsdbReader* pReader) {
|
||||||
|
|
||||||
SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo;
|
SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo;
|
||||||
|
|
||||||
|
tsdbUntakeMemSnapshot(pReader->pTsdb, pReader->pMem, pReader->pIMem);
|
||||||
|
|
||||||
taosMemoryFreeClear(pSupInfo->plist);
|
taosMemoryFreeClear(pSupInfo->plist);
|
||||||
taosMemoryFree(pSupInfo->colIds);
|
taosMemoryFree(pSupInfo->colIds);
|
||||||
|
|
||||||
|
@ -3042,7 +3082,7 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
|
||||||
|
|
||||||
tsdbDataFReaderClose(&pReader->pFileReader);
|
tsdbDataFReaderClose(&pReader->pFileReader);
|
||||||
|
|
||||||
STsdbFSState* pFState = pReader->pTsdb->fs->cState;
|
STsdbFSState* pFState = pReader->pTsdb->pFS->cState;
|
||||||
initFilesetIterator(&pReader->status.fileIter, pFState, pReader->order, pReader->idStr);
|
initFilesetIterator(&pReader->status.fileIter, pFState, pReader->order, pReader->idStr);
|
||||||
resetDataBlockIterator(&pReader->status.blockIter, pReader->order);
|
resetDataBlockIterator(&pReader->status.blockIter, pReader->order);
|
||||||
resetDataBlockScanInfo(pReader->status.pTableMap);
|
resetDataBlockScanInfo(pReader->status.pTableMap);
|
||||||
|
|
|
@ -20,10 +20,10 @@ static int32_t tsdbDoRetentionImpl(STsdb *pTsdb, int64_t now, int8_t try, int8_t
|
||||||
STsdbFSState *pState;
|
STsdbFSState *pState;
|
||||||
|
|
||||||
if (try) {
|
if (try) {
|
||||||
pState = pTsdb->fs->cState;
|
pState = pTsdb->pFS->cState;
|
||||||
*canDo = 0;
|
*canDo = 0;
|
||||||
} else {
|
} else {
|
||||||
pState = pTsdb->fs->nState;
|
pState = pTsdb->pFS->nState;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t iSet = 0; iSet < taosArrayGetSize(pState->aDFileSet); iSet++) {
|
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;
|
if (!canDo) goto _exit;
|
||||||
|
|
||||||
// begin
|
// begin
|
||||||
code = tsdbFSBegin(pTsdb->fs);
|
code = tsdbFSBegin(pTsdb->pFS);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
// do retention
|
// do retention
|
||||||
|
@ -91,7 +91,7 @@ int32_t tsdbDoRetention(STsdb *pTsdb, int64_t now) {
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
// commit
|
// commit
|
||||||
code = tsdbFSCommit(pTsdb->fs);
|
code = tsdbFSCommit(pTsdb->pFS);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -99,6 +99,6 @@ _exit:
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tsdbError("vgId:%d tsdb do retention failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
|
tsdbError("vgId:%d tsdb do retention failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
|
||||||
tsdbFSRollback(pTsdb->fs);
|
tsdbFSRollback(pTsdb->pFS);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
|
@ -45,7 +45,7 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) {
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (pReader->pDataFReader == NULL) {
|
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;
|
if (pSet == NULL) goto _exit;
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ _err:
|
||||||
static int32_t tsdbSnapReadDel(STsdbSnapReader* pReader, uint8_t** ppData) {
|
static int32_t tsdbSnapReadDel(STsdbSnapReader* pReader, uint8_t** ppData) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
STsdb* pTsdb = pReader->pTsdb;
|
STsdb* pTsdb = pReader->pTsdb;
|
||||||
SDelFile* pDelFile = pTsdb->fs->cState->pDelFile;
|
SDelFile* pDelFile = pTsdb->pFS->cState->pDelFile;
|
||||||
|
|
||||||
if (pReader->pDelFReader == NULL) {
|
if (pReader->pDelFReader == NULL) {
|
||||||
if (pDelFile == NULL) {
|
if (pDelFile == NULL) {
|
||||||
|
@ -798,7 +798,7 @@ static int32_t tsdbSnapWriteDataEnd(STsdbSnapWriter* pWriter) {
|
||||||
code = tsdbWriteBlockIdx(pWriter->pDataFWriter, pWriter->aBlockIdxW, NULL);
|
code = tsdbWriteBlockIdx(pWriter->pDataFWriter, pWriter->aBlockIdxW, NULL);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
code = tsdbFSStateUpsertDFileSet(pTsdb->fs->nState, tsdbDataFWriterGetWSet(pWriter->pDataFWriter));
|
code = tsdbFSStateUpsertDFileSet(pTsdb->pFS->nState, tsdbDataFWriterGetWSet(pWriter->pDataFWriter));
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
code = tsdbDataFWriterClose(&pWriter->pDataFWriter, 1);
|
code = tsdbDataFWriterClose(&pWriter->pDataFWriter, 1);
|
||||||
|
@ -843,7 +843,7 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3
|
||||||
pWriter->fid = fid;
|
pWriter->fid = fid;
|
||||||
|
|
||||||
// read
|
// read
|
||||||
SDFileSet* pSet = tsdbFSStateGetDFileSet(pTsdb->fs->nState, fid, TD_EQ);
|
SDFileSet* pSet = tsdbFSStateGetDFileSet(pTsdb->pFS->nState, fid, TD_EQ);
|
||||||
if (pSet) {
|
if (pSet) {
|
||||||
code = tsdbDataFReaderOpen(&pWriter->pDataFReader, pTsdb, pSet);
|
code = tsdbDataFReaderOpen(&pWriter->pDataFReader, pTsdb, pSet);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
@ -907,7 +907,7 @@ static int32_t tsdbSnapWriteDel(STsdbSnapWriter* pWriter, uint8_t* pData, uint32
|
||||||
STsdb* pTsdb = pWriter->pTsdb;
|
STsdb* pTsdb = pWriter->pTsdb;
|
||||||
|
|
||||||
if (pWriter->pDelFWriter == NULL) {
|
if (pWriter->pDelFWriter == NULL) {
|
||||||
SDelFile* pDelFile = tsdbFSStateGetDelFile(pTsdb->fs->nState);
|
SDelFile* pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->nState);
|
||||||
|
|
||||||
// reader
|
// reader
|
||||||
if (pDelFile) {
|
if (pDelFile) {
|
||||||
|
@ -1017,7 +1017,7 @@ static int32_t tsdbSnapWriteDelEnd(STsdbSnapWriter* pWriter) {
|
||||||
code = tsdbUpdateDelFileHdr(pWriter->pDelFWriter);
|
code = tsdbUpdateDelFileHdr(pWriter->pDelFWriter);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
code = tsdbFSStateUpsertDelFile(pTsdb->fs->nState, &pWriter->pDelFWriter->fDel);
|
code = tsdbFSStateUpsertDelFile(pTsdb->pFS->nState, &pWriter->pDelFWriter->fDel);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
code = tsdbDelFWriterClose(&pWriter->pDelFWriter, 1);
|
code = tsdbDelFWriterClose(&pWriter->pDelFWriter, 1);
|
||||||
|
@ -1096,7 +1096,7 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tsdbFSBegin(pTsdb->fs);
|
code = tsdbFSBegin(pTsdb->pFS);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
*ppWriter = pWriter;
|
*ppWriter = pWriter;
|
||||||
|
@ -1113,7 +1113,7 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) {
|
||||||
STsdbSnapWriter* pWriter = *ppWriter;
|
STsdbSnapWriter* pWriter = *ppWriter;
|
||||||
|
|
||||||
if (rollback) {
|
if (rollback) {
|
||||||
code = tsdbFSRollback(pWriter->pTsdb->fs);
|
code = tsdbFSRollback(pWriter->pTsdb->pFS);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
} else {
|
} else {
|
||||||
code = tsdbSnapWriteDataEnd(pWriter);
|
code = tsdbSnapWriteDataEnd(pWriter);
|
||||||
|
@ -1122,7 +1122,7 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) {
|
||||||
code = tsdbSnapWriteDelEnd(pWriter);
|
code = tsdbSnapWriteDelEnd(pWriter);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
code = tsdbFSCommit(pWriter->pTsdb->fs);
|
code = tsdbFSCommit(pWriter->pTsdb->pFS);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
/* ------------------------ STRUCTURES ------------------------ */
|
/* ------------------------ STRUCTURES ------------------------ */
|
||||||
|
|
||||||
static int vnodeBufPoolCreate(int64_t size, SVBufPool **ppPool);
|
static int vnodeBufPoolCreate(SVnode *pVnode, int64_t size, SVBufPool **ppPool);
|
||||||
static int vnodeBufPoolDestroy(SVBufPool *pPool);
|
static int vnodeBufPoolDestroy(SVBufPool *pPool);
|
||||||
|
|
||||||
int vnodeOpenBufPool(SVnode *pVnode, int64_t size) {
|
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++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
// create pool
|
// create pool
|
||||||
ret = vnodeBufPoolCreate(size, &pPool);
|
ret = vnodeBufPoolCreate(pVnode, size, &pPool);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
vError("vgId:%d, failed to open vnode buffer pool since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d, failed to open vnode buffer pool since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
vnodeCloseBufPool(pVnode);
|
vnodeCloseBufPool(pVnode);
|
||||||
|
@ -120,7 +120,7 @@ void vnodeBufPoolFree(SVBufPool *pPool, void *p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// STATIC METHODS -------------------
|
// STATIC METHODS -------------------
|
||||||
static int vnodeBufPoolCreate(int64_t size, SVBufPool **ppPool) {
|
static int vnodeBufPoolCreate(SVnode *pVnode, int64_t size, SVBufPool **ppPool) {
|
||||||
SVBufPool *pPool;
|
SVBufPool *pPool;
|
||||||
|
|
||||||
pPool = taosMemoryMalloc(sizeof(SVBufPool) + size);
|
pPool = taosMemoryMalloc(sizeof(SVBufPool) + size);
|
||||||
|
@ -130,6 +130,7 @@ static int vnodeBufPoolCreate(int64_t size, SVBufPool **ppPool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pPool->next = NULL;
|
pPool->next = NULL;
|
||||||
|
pPool->pVnode = pVnode;
|
||||||
pPool->nRef = 0;
|
pPool->nRef = 0;
|
||||||
pPool->size = 0;
|
pPool->size = 0;
|
||||||
pPool->ptr = pPool->node.data;
|
pPool->ptr = pPool->node.data;
|
||||||
|
@ -146,4 +147,26 @@ static int vnodeBufPoolDestroy(SVBufPool *pPool) {
|
||||||
vnodeBufPoolReset(pPool);
|
vnodeBufPoolReset(pPool);
|
||||||
taosMemoryFree(pPool);
|
taosMemoryFree(pPool);
|
||||||
return 0;
|
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"
|
#include "vnd.h"
|
||||||
|
|
||||||
#define VND_INFO_FNAME "vnode.json"
|
#define VND_INFO_FNAME "vnode.json"
|
||||||
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
|
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
|
||||||
|
|
||||||
static int vnodeEncodeInfo(const SVnodeInfo *pInfo, char **ppData);
|
static int vnodeEncodeInfo(const SVnodeInfo *pInfo, char **ppData);
|
||||||
|
@ -27,18 +27,18 @@ static void vnodeWaitCommit(SVnode *pVnode);
|
||||||
|
|
||||||
int vnodeBegin(SVnode *pVnode) {
|
int vnodeBegin(SVnode *pVnode) {
|
||||||
// alloc buffer pool
|
// alloc buffer pool
|
||||||
/* pthread_mutex_lock(); */
|
taosThreadMutexLock(&pVnode->mutex);
|
||||||
|
|
||||||
while (pVnode->pPool == NULL) {
|
while (pVnode->pPool == NULL) {
|
||||||
/* pthread_cond_wait(); */
|
taosThreadCondWait(&pVnode->poolNotEmpty, &pVnode->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
pVnode->inUse = pVnode->pPool;
|
pVnode->inUse = pVnode->pPool;
|
||||||
|
pVnode->inUse->nRef = 1;
|
||||||
pVnode->pPool = pVnode->inUse->next;
|
pVnode->pPool = pVnode->inUse->next;
|
||||||
pVnode->inUse->next = NULL;
|
pVnode->inUse->next = NULL;
|
||||||
/* ref pVnode->inUse buffer pool */
|
|
||||||
|
|
||||||
/* pthread_mutex_unlock(); */
|
taosThreadMutexUnlock(&pVnode->mutex);
|
||||||
|
|
||||||
pVnode->state.commitID++;
|
pVnode->state.commitID++;
|
||||||
// begin meta
|
// 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,
|
vInfo("vgId:%d, start to commit, commit ID:%" PRId64 " version:%" PRId64, TD_VID(pVnode), pVnode->state.commitID,
|
||||||
pVnode->state.applied);
|
pVnode->state.applied);
|
||||||
|
|
||||||
pVnode->onCommit = pVnode->inUse;
|
vnodeBufPoolUnRef(pVnode->inUse);
|
||||||
pVnode->inUse = NULL;
|
pVnode->inUse = NULL;
|
||||||
|
|
||||||
// save info
|
// save info
|
||||||
|
@ -284,10 +284,6 @@ int vnodeCommit(SVnode *pVnode) {
|
||||||
|
|
||||||
// apply the commit (TODO)
|
// apply the commit (TODO)
|
||||||
walEndSnapshot(pVnode->pWal);
|
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));
|
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->syncSem, 0, 0);
|
||||||
tsem_init(&(pVnode->canCommit), 0, 1);
|
tsem_init(&(pVnode->canCommit), 0, 1);
|
||||||
|
taosThreadMutexInit(&pVnode->mutex, NULL);
|
||||||
|
taosThreadCondInit(&pVnode->poolNotEmpty, NULL);
|
||||||
|
|
||||||
// open buffer pool
|
// open buffer pool
|
||||||
if (vnodeOpenBufPool(pVnode, pVnode->config.isHeap ? 0 : pVnode->config.szBuf / 3) < 0) {
|
if (vnodeOpenBufPool(pVnode, pVnode->config.isHeap ? 0 : pVnode->config.szBuf / 3) < 0) {
|
||||||
|
@ -195,6 +197,8 @@ void vnodeClose(SVnode *pVnode) {
|
||||||
// destroy handle
|
// destroy handle
|
||||||
tsem_destroy(&(pVnode->canCommit));
|
tsem_destroy(&(pVnode->canCommit));
|
||||||
tsem_destroy(&pVnode->syncSem);
|
tsem_destroy(&pVnode->syncSem);
|
||||||
|
taosThreadCondDestroy(&pVnode->poolNotEmpty);
|
||||||
|
taosThreadMutexDestroy(&pVnode->mutex);
|
||||||
taosMemoryFree(pVnode);
|
taosMemoryFree(pVnode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@ struct SVSnapReader {
|
||||||
// tsdb
|
// tsdb
|
||||||
int8_t tsdbDone;
|
int8_t tsdbDone;
|
||||||
STsdbSnapReader *pTsdbReader;
|
STsdbSnapReader *pTsdbReader;
|
||||||
|
// rsma
|
||||||
|
int8_t rsmaDone[TSDB_RETENTION_L2];
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t vnodeSnapReaderOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapReader **ppReader) {
|
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;
|
*ppData = NULL;
|
||||||
*nData = 0;
|
*nData = 0;
|
||||||
|
|
||||||
|
|
|
@ -557,6 +557,7 @@ static int32_t vnodeProcessDropStbReq(SVnode *pVnode, int64_t version, void *pRe
|
||||||
SVDropStbReq req = {0};
|
SVDropStbReq req = {0};
|
||||||
int32_t rcode = TSDB_CODE_SUCCESS;
|
int32_t rcode = TSDB_CODE_SUCCESS;
|
||||||
SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
|
SArray *tbUidList = NULL;
|
||||||
|
|
||||||
pRsp->msgType = TDMT_VND_CREATE_STB_RSP;
|
pRsp->msgType = TDMT_VND_CREATE_STB_RSP;
|
||||||
pRsp->pCont = NULL;
|
pRsp->pCont = NULL;
|
||||||
|
@ -570,7 +571,14 @@ static int32_t vnodeProcessDropStbReq(SVnode *pVnode, int64_t version, void *pRe
|
||||||
}
|
}
|
||||||
|
|
||||||
// process request
|
// 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;
|
rcode = terrno;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
@ -582,6 +590,7 @@ static int32_t vnodeProcessDropStbReq(SVnode *pVnode, int64_t version, void *pRe
|
||||||
|
|
||||||
// return rsp
|
// return rsp
|
||||||
_exit:
|
_exit:
|
||||||
|
if (tbUidList) taosArrayDestroy(tbUidList);
|
||||||
pRsp->code = rcode;
|
pRsp->code = rcode;
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -869,6 +878,8 @@ _exit:
|
||||||
tdProcessRSmaSubmit(pVnode->pSma, pReq, STREAM_INPUT__DATA_SUBMIT);
|
tdProcessRSmaSubmit(pVnode->pSma, pReq, STREAM_INPUT__DATA_SUBMIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vDebug("successful submit in vg %d version %ld", pVnode->config.vgId, version);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -532,6 +532,14 @@ typedef struct SCtgOperation {
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} 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 { \
|
#define CTG_API_LEAVE_NOLOCK(c) do { \
|
||||||
int32_t __code = c; \
|
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) {
|
int32_t ctgHandleMsgCallback(void *param, SDataBuf *pMsg, int32_t rspCode) {
|
||||||
SCtgTaskCallbackParam* cbParam = (SCtgTaskCallbackParam*)param;
|
SCtgTaskCallbackParam* cbParam = (SCtgTaskCallbackParam*)param;
|
||||||
int32_t code = 0;
|
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) {
|
if (NULL == pJob) {
|
||||||
qDebug("ctg job refId 0x%" PRIx64 " already dropped", cbParam->refId);
|
qDebug("ctg job refId 0x%" PRIx64 " already dropped", cbParam->refId);
|
||||||
goto _return;
|
goto _return;
|
||||||
|
@ -266,8 +267,6 @@ _return:
|
||||||
if (pJob) {
|
if (pJob) {
|
||||||
taosReleaseRef(gCtgMgmt.jobPool, cbParam->refId);
|
taosReleaseRef(gCtgMgmt.jobPool, cbParam->refId);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(param);
|
|
||||||
|
|
||||||
CTG_API_LEAVE(code);
|
CTG_API_LEAVE(code);
|
||||||
}
|
}
|
||||||
|
@ -293,6 +292,7 @@ int32_t ctgMakeMsgSendInfo(SCtgTask* pTask, int32_t msgType, SMsgSendInfo **pMsg
|
||||||
param->taskId = pTask->taskId;
|
param->taskId = pTask->taskId;
|
||||||
|
|
||||||
msgSendInfo->param = param;
|
msgSendInfo->param = param;
|
||||||
|
msgSendInfo->paramFreeFp = taosMemoryFree;
|
||||||
msgSendInfo->fp = ctgHandleMsgCallback;
|
msgSendInfo->fp = ctgHandleMsgCallback;
|
||||||
|
|
||||||
*pMsgSendInfo = msgSendInfo;
|
*pMsgSendInfo = msgSendInfo;
|
||||||
|
|
|
@ -159,27 +159,28 @@ typedef struct {
|
||||||
int64_t recoverEndVer;
|
int64_t recoverEndVer;
|
||||||
} SStreamTaskInfo;
|
} SStreamTaskInfo;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char* tablename;
|
||||||
|
char* dbname;
|
||||||
|
int32_t tversion;
|
||||||
|
SSchemaWrapper* sw;
|
||||||
|
} SSchemaInfo;
|
||||||
|
|
||||||
typedef struct SExecTaskInfo {
|
typedef struct SExecTaskInfo {
|
||||||
STaskIdInfo id;
|
STaskIdInfo id;
|
||||||
uint32_t status;
|
uint32_t status;
|
||||||
STimeWindow window;
|
STimeWindow window;
|
||||||
STaskCostInfo cost;
|
STaskCostInfo cost;
|
||||||
int64_t owner; // if it is in execution
|
int64_t owner; // if it is in execution
|
||||||
int32_t code;
|
int32_t code;
|
||||||
|
|
||||||
SStreamTaskInfo streamInfo;
|
SStreamTaskInfo streamInfo;
|
||||||
|
SSchemaInfo schemaInfo;
|
||||||
struct {
|
STableListInfo tableqinfoList; // this is a table list
|
||||||
char* tablename;
|
const char* sql; // query sql string
|
||||||
char* dbname;
|
jmp_buf env; // jump to this position when error happens.
|
||||||
int32_t tversion;
|
EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model]
|
||||||
SSchemaWrapper* sw;
|
SSubplan* pSubplan;
|
||||||
} 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]
|
|
||||||
struct SOperatorInfo* pRoot;
|
struct SOperatorInfo* pRoot;
|
||||||
} SExecTaskInfo;
|
} SExecTaskInfo;
|
||||||
|
|
||||||
|
@ -248,13 +249,13 @@ typedef struct SLoadRemoteDataInfo {
|
||||||
} SLoadRemoteDataInfo;
|
} SLoadRemoteDataInfo;
|
||||||
|
|
||||||
typedef struct SLimitInfo {
|
typedef struct SLimitInfo {
|
||||||
SLimit limit;
|
SLimit limit;
|
||||||
SLimit slimit;
|
SLimit slimit;
|
||||||
uint64_t currentGroupId;
|
uint64_t currentGroupId;
|
||||||
int64_t remainGroupOffset;
|
int64_t remainGroupOffset;
|
||||||
int64_t numOfOutputGroups;
|
int64_t numOfOutputGroups;
|
||||||
int64_t remainOffset;
|
int64_t remainOffset;
|
||||||
int64_t numOfOutputRows;
|
int64_t numOfOutputRows;
|
||||||
} SLimitInfo;
|
} SLimitInfo;
|
||||||
|
|
||||||
typedef struct SExchangeInfo {
|
typedef struct SExchangeInfo {
|
||||||
|
|
|
@ -227,14 +227,14 @@ int32_t extractTargetSlotId(const SArray* pColMatchInfo, SExecTaskInfo* pTaskInf
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SColMatchInfo* pColMatch = taosArrayGet(pColMatchInfo, i);
|
SColMatchInfo* pColMatch = taosArrayGet(pColMatchInfo, i);
|
||||||
for (int32_t j = 0; j < pTaskInfo->schemaVer.sw->nCols; ++j) {
|
for (int32_t j = 0; j < pTaskInfo->schemaInfo.sw->nCols; ++j) {
|
||||||
if (pColMatch->colId == pTaskInfo->schemaVer.sw->pSchema[j].colId &&
|
if (pColMatch->colId == pTaskInfo->schemaInfo.sw->pSchema[j].colId &&
|
||||||
pColMatch->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
pColMatch->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||||
(*pSlotIds)[pColMatch->targetSlotId] = -1;
|
(*pSlotIds)[pColMatch->targetSlotId] = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pColMatch->colId == pTaskInfo->schemaVer.sw->pSchema[j].colId) {
|
if (pColMatch->colId == pTaskInfo->schemaInfo.sw->pSchema[j].colId) {
|
||||||
(*pSlotIds)[pColMatch->targetSlotId] = j;
|
(*pSlotIds)[pColMatch->targetSlotId] = j;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,15 +67,15 @@ static bool needCompress(const SSDataBlock* pData, int32_t numOfCols) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
// data format:
|
// data format:
|
||||||
// +----------------+--------------+----------+--------------------------------------------+--------------------------------------+-------------+-----------+-------------+-----------+
|
// +----------------+--------------+-----------------+--------------------------------------------+------------------------------------+-------------+-----------+-------------+-----------+
|
||||||
// |SDataCacheEntry | total length | group id | col1_schema | col2_schema | col3_schema ...| column#1 length, column#2
|
// |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)
|
||||||
// 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 | |
|
||||||
// |(sizeof(int16_t)+sizeof(int32_t))*numOfCols | sizeof(int32_t) * numOfCols | actual size | |
|
// +----------------+--------------+-----------------+--------------------------------------------+------------------------------------+-------------+-----------+-------------+-----------+
|
||||||
// actual size | |
|
|
||||||
// +----------------+--------------+----------+--------------------------------------------+--------------------------------------+-------------+-----------+-------------+-----------+
|
|
||||||
// The length of bitmap is decided by number of rows of this data block, and the length of each column data is
|
// 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
|
// recorded in the first segment, next to the struct header
|
||||||
|
// clang-format on
|
||||||
static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pInput, SDataDispatchBuf* pBuf) {
|
static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pInput, SDataDispatchBuf* pBuf) {
|
||||||
int32_t numOfCols = 0;
|
int32_t numOfCols = 0;
|
||||||
SNode* pNode;
|
SNode* pNode;
|
||||||
|
|
|
@ -91,7 +91,6 @@ _return:
|
||||||
tsem_post(&pInserter->ready);
|
tsem_post(&pInserter->ready);
|
||||||
|
|
||||||
taosMemoryFree(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
taosMemoryFree(param);
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -110,6 +109,7 @@ static int32_t sendSubmitRequest(SDataInserterHandle* pInserter, SSubmitReq* pMs
|
||||||
pParam->pInserter = pInserter;
|
pParam->pInserter = pInserter;
|
||||||
|
|
||||||
pMsgSendInfo->param = pParam;
|
pMsgSendInfo->param = pParam;
|
||||||
|
pMsgSendInfo->paramFreeFp = taosMemoryFree;
|
||||||
pMsgSendInfo->msgInfo.pData = pMsg;
|
pMsgSendInfo->msgInfo.pData = pMsg;
|
||||||
pMsgSendInfo->msgInfo.len = ntohl(pMsg->length);
|
pMsgSendInfo->msgInfo.len = ntohl(pMsg->length);
|
||||||
pMsgSendInfo->msgType = TDMT_VND_SUBMIT;
|
pMsgSendInfo->msgType = TDMT_VND_SUBMIT;
|
||||||
|
|
|
@ -842,30 +842,10 @@ static void getInitialStartTimeWindow(SInterval* pInterval, TSKEY ts, STimeWindo
|
||||||
}
|
}
|
||||||
|
|
||||||
static STimeWindow doCalculateTimeWindow(int64_t ts, SInterval* pInterval) {
|
static STimeWindow doCalculateTimeWindow(int64_t ts, SInterval* pInterval) {
|
||||||
STimeWindow w = {0};
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
w.skey = taosTimeTruncate(ts, pInterval, pInterval->precision);
|
||||||
|
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
|
||||||
return w;
|
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,
|
// TODO: if a block was set but not consumed,
|
||||||
// prevent setting a different type of block
|
// prevent setting a different type of block
|
||||||
pInfo->blockType = type;
|
pInfo->validBlockIndex = 0;
|
||||||
|
taosArrayClear(pInfo->pBlockLists);
|
||||||
|
|
||||||
if (type == STREAM_INPUT__DATA_SUBMIT) {
|
if (type == STREAM_INPUT__MERGED_SUBMIT) {
|
||||||
if (tqReaderSetDataMsg(pInfo->tqReader, input, 0) < 0) {
|
ASSERT(numOfBlocks > 1);
|
||||||
qError("submit msg messed up when initing stream block, %s" PRIx64, id);
|
for (int32_t i = 0; i < numOfBlocks; i++) {
|
||||||
return TSDB_CODE_QRY_APP_ERROR;
|
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) {
|
} else if (type == STREAM_INPUT__DATA_BLOCK) {
|
||||||
for (int32_t i = 0; i < numOfBlocks; ++i) {
|
for (int32_t i = 0; i < numOfBlocks; ++i) {
|
||||||
SSDataBlock* pDataBlock = &((SSDataBlock*)input)[i];
|
SSDataBlock* pDataBlock = &((SSDataBlock*)input)[i];
|
||||||
|
|
||||||
|
// TODO optimize
|
||||||
SSDataBlock* p = createOneDataBlock(pDataBlock, false);
|
SSDataBlock* p = createOneDataBlock(pDataBlock, false);
|
||||||
p->info = pDataBlock->info;
|
p->info = pDataBlock->info;
|
||||||
|
|
||||||
|
@ -60,6 +75,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
||||||
taosArrayAddAll(p->pDataBlock, pDataBlock->pDataBlock);
|
taosArrayAddAll(p->pDataBlock, pDataBlock->pDataBlock);
|
||||||
taosArrayPush(pInfo->pBlockLists, &p);
|
taosArrayPush(pInfo->pBlockLists, &p);
|
||||||
}
|
}
|
||||||
|
pInfo->blockType = STREAM_INPUT__DATA_BLOCK;
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
@ -104,27 +120,40 @@ int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numO
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers) {
|
qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* numOfCols) {
|
||||||
if (msg == NULL) {
|
if (msg == NULL) {
|
||||||
// TODO create raw scan
|
// TODO create raw scan
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SSubplan* plan = NULL;
|
struct SSubplan* pPlan = NULL;
|
||||||
int32_t code = qStringToSubplan(msg, &plan);
|
int32_t code = qStringToSubplan(msg, &pPlan);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
qTaskInfo_t pTaskInfo = 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) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
// TODO: destroy SSubplan & pTaskInfo
|
nodesDestroyNode((SNode*)pPlan);
|
||||||
|
qDestroyTask(pTaskInfo);
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return NULL;
|
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;
|
return pTaskInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,17 +164,18 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers) {
|
||||||
|
|
||||||
/*qDebugL("stream task string %s", (const char*)msg);*/
|
/*qDebugL("stream task string %s", (const char*)msg);*/
|
||||||
|
|
||||||
struct SSubplan* plan = NULL;
|
struct SSubplan* pPlan = NULL;
|
||||||
int32_t code = qStringToSubplan(msg, &plan);
|
int32_t code = qStringToSubplan(msg, &pPlan);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
qTaskInfo_t pTaskInfo = 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) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
// TODO: destroy SSubplan & pTaskInfo
|
nodesDestroyNode((SNode*)pPlan);
|
||||||
|
qDestroyTask(pTaskInfo);
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -153,7 +183,8 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers) {
|
||||||
return pTaskInfo;
|
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));
|
SArray* qa = taosArrayInit(4, sizeof(tb_uid_t));
|
||||||
|
|
||||||
// let's discard the tables those are not created according to the queried super table.
|
// 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);
|
ASSERT(tinfo != NULL && dbName != NULL && tableName != NULL);
|
||||||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
||||||
|
|
||||||
if (pTaskInfo->schemaVer.sw == NULL) {
|
if (pTaskInfo->schemaInfo.sw == NULL) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
*sversion = pTaskInfo->schemaVer.sw->version;
|
*sversion = pTaskInfo->schemaInfo.sw->version;
|
||||||
*tversion = pTaskInfo->schemaVer.tversion;
|
*tversion = pTaskInfo->schemaInfo.tversion;
|
||||||
if (pTaskInfo->schemaVer.dbname) {
|
if (pTaskInfo->schemaInfo.dbname) {
|
||||||
strcpy(dbName, pTaskInfo->schemaVer.dbname);
|
strcpy(dbName, pTaskInfo->schemaInfo.dbname);
|
||||||
} else {
|
} else {
|
||||||
dbName[0] = 0;
|
dbName[0] = 0;
|
||||||
}
|
}
|
||||||
if (pTaskInfo->schemaVer.tablename) {
|
if (pTaskInfo->schemaInfo.tablename) {
|
||||||
strcpy(tableName, pTaskInfo->schemaVer.tablename);
|
strcpy(tableName, pTaskInfo->schemaInfo.tablename);
|
||||||
} else {
|
} else {
|
||||||
tableName[0] = 0;
|
tableName[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId,
|
||||||
|
|
||||||
taosThreadOnce(&initPoolOnce, initRefPool);
|
taosThreadOnce(&initPoolOnce, initRefPool);
|
||||||
atexit(cleanupRefPool);
|
atexit(cleanupRefPool);
|
||||||
|
|
||||||
int32_t code = createExecTaskInfoImpl(pSubplan, pTask, readHandle, taskId, sql, model);
|
int32_t code = createExecTaskInfoImpl(pSubplan, pTask, readHandle, taskId, sql, model);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
|
|
|
@ -1337,7 +1337,9 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock) {
|
||||||
if (pFilterNode == NULL) {
|
if (pFilterNode == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (pBlock->info.rows == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
SFilterInfo* filter = NULL;
|
SFilterInfo* filter = NULL;
|
||||||
|
|
||||||
// todo move to the initialization function
|
// todo move to the initialization function
|
||||||
|
@ -1994,16 +1996,9 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
tsem_post(&pExchangeInfo->ready);
|
tsem_post(&pExchangeInfo->ready);
|
||||||
taosReleaseRef(exchangeObjRefPool, pWrapper->exchangeId);
|
taosReleaseRef(exchangeObjRefPool, pWrapper->exchangeId);
|
||||||
|
|
||||||
taosMemoryFree(pWrapper);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
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) {
|
void qProcessRspMsg(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
|
||||||
SMsgSendInfo* pSendInfo = (SMsgSendInfo*)pMsg->info.ahandle;
|
SMsgSendInfo* pSendInfo = (SMsgSendInfo*)pMsg->info.ahandle;
|
||||||
assert(pMsg->info.ahandle != NULL);
|
assert(pMsg->info.ahandle != NULL);
|
||||||
|
@ -2063,6 +2058,7 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf
|
||||||
pWrapper->sourceIndex = sourceIndex;
|
pWrapper->sourceIndex = sourceIndex;
|
||||||
|
|
||||||
pMsgSendInfo->param = pWrapper;
|
pMsgSendInfo->param = pWrapper;
|
||||||
|
pMsgSendInfo->paramFreeFp = taosMemoryFree;
|
||||||
pMsgSendInfo->msgInfo.pData = pMsg;
|
pMsgSendInfo->msgInfo.pData = pMsg;
|
||||||
pMsgSendInfo->msgInfo.len = sizeof(SResFetchReq);
|
pMsgSendInfo->msgInfo.len = sizeof(SResFetchReq);
|
||||||
pMsgSendInfo->msgType = pSource->fetchMsgType;
|
pMsgSendInfo->msgType = pSource->fetchMsgType;
|
||||||
|
@ -4127,7 +4123,7 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId, EOPT
|
||||||
SExecTaskInfo* pTaskInfo = taosMemoryCalloc(1, sizeof(SExecTaskInfo));
|
SExecTaskInfo* pTaskInfo = taosMemoryCalloc(1, sizeof(SExecTaskInfo));
|
||||||
setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED);
|
setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED);
|
||||||
|
|
||||||
pTaskInfo->schemaVer.dbname = strdup(dbFName);
|
pTaskInfo->schemaInfo.dbname = strdup(dbFName);
|
||||||
pTaskInfo->cost.created = taosGetTimestampMs();
|
pTaskInfo->cost.created = taosGetTimestampMs();
|
||||||
pTaskInfo->id.queryId = queryId;
|
pTaskInfo->id.queryId = queryId;
|
||||||
pTaskInfo->execModel = model;
|
pTaskInfo->execModel = model;
|
||||||
|
@ -4153,35 +4149,35 @@ int32_t extractTableSchemaInfo(SReadHandle* pHandle, uint64_t uid, SExecTaskInfo
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTaskInfo->schemaVer.tablename = strdup(mr.me.name);
|
pTaskInfo->schemaInfo.tablename = strdup(mr.me.name);
|
||||||
|
|
||||||
if (mr.me.type == TSDB_SUPER_TABLE) {
|
if (mr.me.type == TSDB_SUPER_TABLE) {
|
||||||
pTaskInfo->schemaVer.sw = tCloneSSchemaWrapper(&mr.me.stbEntry.schemaRow);
|
pTaskInfo->schemaInfo.sw = tCloneSSchemaWrapper(&mr.me.stbEntry.schemaRow);
|
||||||
pTaskInfo->schemaVer.tversion = mr.me.stbEntry.schemaTag.version;
|
pTaskInfo->schemaInfo.tversion = mr.me.stbEntry.schemaTag.version;
|
||||||
} else if (mr.me.type == TSDB_CHILD_TABLE) {
|
} else if (mr.me.type == TSDB_CHILD_TABLE) {
|
||||||
tDecoderClear(&mr.coder);
|
tDecoderClear(&mr.coder);
|
||||||
|
|
||||||
tb_uid_t suid = mr.me.ctbEntry.suid;
|
tb_uid_t suid = mr.me.ctbEntry.suid;
|
||||||
metaGetTableEntryByUid(&mr, suid);
|
metaGetTableEntryByUid(&mr, suid);
|
||||||
pTaskInfo->schemaVer.sw = tCloneSSchemaWrapper(&mr.me.stbEntry.schemaRow);
|
pTaskInfo->schemaInfo.sw = tCloneSSchemaWrapper(&mr.me.stbEntry.schemaRow);
|
||||||
pTaskInfo->schemaVer.tversion = mr.me.stbEntry.schemaTag.version;
|
pTaskInfo->schemaInfo.tversion = mr.me.stbEntry.schemaTag.version;
|
||||||
} else {
|
} else {
|
||||||
pTaskInfo->schemaVer.sw = tCloneSSchemaWrapper(&mr.me.ntbEntry.schemaRow);
|
pTaskInfo->schemaInfo.sw = tCloneSSchemaWrapper(&mr.me.ntbEntry.schemaRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
metaReaderClear(&mr);
|
metaReaderClear(&mr);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cleanupTableSchemaInfo(SExecTaskInfo* pTaskInfo) {
|
static void cleanupTableSchemaInfo(SSchemaInfo* pSchemaInfo) {
|
||||||
taosMemoryFreeClear(pTaskInfo->schemaVer.dbname);
|
taosMemoryFreeClear(pSchemaInfo->dbname);
|
||||||
if (pTaskInfo->schemaVer.sw == NULL) {
|
if (pSchemaInfo->sw == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(pTaskInfo->schemaVer.sw->pSchema);
|
taosMemoryFree(pSchemaInfo->tablename);
|
||||||
taosMemoryFree(pTaskInfo->schemaVer.sw);
|
taosMemoryFree(pSchemaInfo->sw->pSchema);
|
||||||
taosMemoryFree(pTaskInfo->schemaVer.tablename);
|
taosMemoryFree(pSchemaInfo->sw);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sortTableGroup(STableListInfo* pTableListInfo, int32_t groupNum) {
|
static int32_t sortTableGroup(STableListInfo* pTableListInfo, int32_t groupNum) {
|
||||||
|
@ -4424,7 +4420,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
.calTrigger = pTableScanNode->triggerType,
|
.calTrigger = pTableScanNode->triggerType,
|
||||||
.maxTs = INT64_MIN,
|
.maxTs = INT64_MIN,
|
||||||
};
|
};
|
||||||
if (pHandle) {
|
if (pHandle->vnode) {
|
||||||
int32_t code = createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags,
|
int32_t code = createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags,
|
||||||
pTableScanNode->groupSort, pHandle, pTableListInfo, pTagCond, pTagIndexCond, GET_TASKID(pTaskInfo));
|
pTableScanNode->groupSort, pHandle, pTableListInfo, pTagCond, pTagIndexCond, GET_TASKID(pTaskInfo));
|
||||||
if (code) {
|
if (code) {
|
||||||
|
@ -4590,7 +4586,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
int32_t children = 0;
|
int32_t children = 0;
|
||||||
pOptr = createStreamFinalIntervalOperatorInfo(ops[0], pPhyNode, pTaskInfo, children);
|
pOptr = createStreamFinalIntervalOperatorInfo(ops[0], pPhyNode, pTaskInfo, children);
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL == type) {
|
} 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);
|
pOptr = createStreamFinalIntervalOperatorInfo(ops[0], pPhyNode, pTaskInfo, children);
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_SORT == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_SORT == type) {
|
||||||
pOptr = createSortOperatorInfo(ops[0], (SSortPhysiNode*)pPhyNode, pTaskInfo);
|
pOptr = createSortOperatorInfo(ops[0], (SSortPhysiNode*)pPhyNode, pTaskInfo);
|
||||||
|
@ -4939,6 +4935,7 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead
|
||||||
}
|
}
|
||||||
|
|
||||||
(*pTaskInfo)->sql = sql;
|
(*pTaskInfo)->sql = sql;
|
||||||
|
(*pTaskInfo)->pSubplan = pPlan;
|
||||||
(*pTaskInfo)->pRoot = createOperatorTree(pPlan->pNode, *pTaskInfo, pHandle, &(*pTaskInfo)->tableqinfoList, pPlan->pTagCond, pPlan->pTagIndexCond, pPlan->user);
|
(*pTaskInfo)->pRoot = createOperatorTree(pPlan->pNode, *pTaskInfo, pHandle, &(*pTaskInfo)->tableqinfoList, pPlan->pTagCond, pPlan->pTagIndexCond, pPlan->user);
|
||||||
|
|
||||||
if (NULL == (*pTaskInfo)->pRoot) {
|
if (NULL == (*pTaskInfo)->pRoot) {
|
||||||
|
@ -4977,7 +4974,9 @@ void doDestroyTask(SExecTaskInfo* pTaskInfo) {
|
||||||
|
|
||||||
doDestroyTableList(&pTaskInfo->tableqinfoList);
|
doDestroyTableList(&pTaskInfo->tableqinfoList);
|
||||||
destroyOperatorInfo(pTaskInfo->pRoot);
|
destroyOperatorInfo(pTaskInfo->pRoot);
|
||||||
cleanupTableSchemaInfo(pTaskInfo);
|
cleanupTableSchemaInfo(&pTaskInfo->schemaInfo);
|
||||||
|
|
||||||
|
nodesDestroyNode((SNode*)pTaskInfo->pSubplan);
|
||||||
|
|
||||||
taosMemoryFreeClear(pTaskInfo->sql);
|
taosMemoryFreeClear(pTaskInfo->sql);
|
||||||
taosMemoryFreeClear(pTaskInfo->id.str);
|
taosMemoryFreeClear(pTaskInfo->id.str);
|
||||||
|
|
|
@ -1196,7 +1196,6 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
||||||
if (pResCol->info.colId == pColMatchInfo->colId) {
|
if (pResCol->info.colId == pColMatchInfo->colId) {
|
||||||
SColumnInfoData* pDst = taosArrayGet(pInfo->pRes->pDataBlock, pColMatchInfo->targetSlotId);
|
SColumnInfoData* pDst = taosArrayGet(pInfo->pRes->pDataBlock, pColMatchInfo->targetSlotId);
|
||||||
colDataAssign(pDst, pResCol, pBlock->info.rows, &pInfo->pRes->info);
|
colDataAssign(pDst, pResCol, pBlock->info.rows, &pInfo->pRes->info);
|
||||||
// taosArraySet(pInfo->pRes->pDataBlock, pColMatchInfo->targetSlotId, pResCol);
|
|
||||||
colExists = true;
|
colExists = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1393,24 +1392,49 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SDataBlockInfo* pBlockInfo = &pInfo->pRes->info;
|
SDataBlockInfo* pBlockInfo = &pInfo->pRes->info;
|
||||||
blockDataCleanup(pInfo->pRes);
|
|
||||||
|
|
||||||
while (tqNextDataBlock(pInfo->tqReader)) {
|
int32_t totBlockNum = taosArrayGetSize(pInfo->pBlockLists);
|
||||||
SSDataBlock block = {0};
|
|
||||||
|
|
||||||
// todo refactor
|
while (1) {
|
||||||
int32_t code = tqRetrieveDataBlock(&block, pInfo->tqReader);
|
if (pInfo->tqReader->pMsg == NULL) {
|
||||||
|
if (pInfo->validBlockIndex >= totBlockNum) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS || block.info.rows == 0) {
|
int32_t current = pInfo->validBlockIndex++;
|
||||||
pTaskInfo->code = code;
|
SSubmitReq* pSubmit = taosArrayGetP(pInfo->pBlockLists, current);
|
||||||
return NULL;
|
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) {
|
if (pBlockInfo->rows > 0) {
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
pInfo->tqReader->pMsg = NULL;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
/*blockDataCleanup(pInfo->pRes);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// record the scan action.
|
// record the scan action.
|
||||||
|
@ -1435,6 +1459,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("scan rows: %d", pBlockInfo->rows);
|
qDebug("scan rows: %d", pBlockInfo->rows);
|
||||||
return (pBlockInfo->rows == 0) ? NULL : pInfo->pRes;
|
return (pBlockInfo->rows == 0) ? NULL : pInfo->pRes;
|
||||||
|
|
||||||
|
@ -1507,8 +1532,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
SScanPhysiNode* pScanPhyNode = &pTableScanNode->scan;
|
SScanPhysiNode* pScanPhyNode = &pTableScanNode->scan;
|
||||||
|
|
||||||
SDataBlockDescNode* pDescNode = pScanPhyNode->node.pOutputDataBlockDesc;
|
SDataBlockDescNode* pDescNode = pScanPhyNode->node.pOutputDataBlockDesc;
|
||||||
|
|
||||||
pInfo->pTagCond = pTagCond;
|
pInfo->pTagCond = pTagCond;
|
||||||
|
@ -1539,7 +1563,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pHandle) {
|
if (pHandle->vnode) {
|
||||||
SOperatorInfo* pTableScanOp = createTableScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo);
|
SOperatorInfo* pTableScanOp = createTableScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo);
|
||||||
STableScanInfo* pTSInfo = (STableScanInfo*)pTableScanOp->info;
|
STableScanInfo* pTSInfo = (STableScanInfo*)pTableScanOp->info;
|
||||||
if (pHandle->version > 0) {
|
if (pHandle->version > 0) {
|
||||||
|
@ -2558,30 +2582,30 @@ typedef struct STableMergeScanInfo {
|
||||||
SArray* pSortInfo;
|
SArray* pSortInfo;
|
||||||
SSortHandle* pSortHandle;
|
SSortHandle* pSortHandle;
|
||||||
|
|
||||||
SSDataBlock* pSortInputBlock;
|
SSDataBlock* pSortInputBlock;
|
||||||
int64_t startTs; // sort start time
|
int64_t startTs; // sort start time
|
||||||
SArray* sortSourceParams;
|
SArray* sortSourceParams;
|
||||||
|
|
||||||
SFileBlockLoadRecorder readRecorder;
|
SFileBlockLoadRecorder readRecorder;
|
||||||
int64_t numOfRows;
|
int64_t numOfRows;
|
||||||
SScanInfo scanInfo;
|
SScanInfo scanInfo;
|
||||||
int32_t scanTimes;
|
int32_t scanTimes;
|
||||||
SNode* pFilterNode; // filter info, which is push down by optimizer
|
SNode* pFilterNode; // filter info, which is push down by optimizer
|
||||||
SqlFunctionCtx* pCtx; // which belongs to the direct upstream operator operator query context
|
SqlFunctionCtx* pCtx; // which belongs to the direct upstream operator operator query context
|
||||||
SResultRowInfo* pResultRowInfo;
|
SResultRowInfo* pResultRowInfo;
|
||||||
int32_t* rowEntryInfoOffset;
|
int32_t* rowEntryInfoOffset;
|
||||||
SExprInfo* pExpr;
|
SExprInfo* pExpr;
|
||||||
SSDataBlock* pResBlock;
|
SSDataBlock* pResBlock;
|
||||||
SArray* pColMatchInfo;
|
SArray* pColMatchInfo;
|
||||||
int32_t numOfOutput;
|
int32_t numOfOutput;
|
||||||
|
|
||||||
SExprInfo* pPseudoExpr;
|
SExprInfo* pPseudoExpr;
|
||||||
int32_t numOfPseudoExpr;
|
int32_t numOfPseudoExpr;
|
||||||
SqlFunctionCtx* pPseudoCtx;
|
SqlFunctionCtx* pPseudoCtx;
|
||||||
|
|
||||||
SQueryTableDataCond cond;
|
SQueryTableDataCond cond;
|
||||||
int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan
|
int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan
|
||||||
int32_t dataBlockLoadFlag;
|
int32_t dataBlockLoadFlag;
|
||||||
// if the upstream is an interval operator, the interval info is also kept here to get the time
|
// 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.
|
// window to check if current data block needs to be loaded.
|
||||||
SInterval interval;
|
SInterval interval;
|
||||||
|
@ -2589,7 +2613,8 @@ typedef struct STableMergeScanInfo {
|
||||||
} STableMergeScanInfo;
|
} STableMergeScanInfo;
|
||||||
|
|
||||||
int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags, bool groupSort, SReadHandle* pHandle,
|
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);
|
int32_t code = getTableList(pHandle->meta, pHandle->vnode, pScanNode, pTagCond, pTagIndexCond, pTableListInfo);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -544,8 +544,9 @@ bool taosFillHasMoreResults(SFillInfo* pFillInfo) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pFillInfo->numOfTotal > 0 && (((pFillInfo->end > pFillInfo->start) && FILL_IS_ASC_FILL(pFillInfo)) ||
|
bool ascFill = FILL_IS_ASC_FILL(pFillInfo);
|
||||||
(pFillInfo->end < pFillInfo->start && !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;
|
return getNumOfResultsAfterFillGap(pFillInfo, pFillInfo->end, 4096) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1543,6 +1543,7 @@ void destroyStreamFinalIntervalOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
taosArrayDestroy(pInfo->pPullWins);
|
taosArrayDestroy(pInfo->pPullWins);
|
||||||
blockDataDestroy(pInfo->pPullDataRes);
|
blockDataDestroy(pInfo->pPullDataRes);
|
||||||
taosArrayDestroy(pInfo->pRecycledPages);
|
taosArrayDestroy(pInfo->pRecycledPages);
|
||||||
|
blockDataDestroy(pInfo->pUpdateRes);
|
||||||
|
|
||||||
if (pInfo->pChildren) {
|
if (pInfo->pChildren) {
|
||||||
int32_t size = taosArrayGetSize(pInfo->pChildren);
|
int32_t size = taosArrayGetSize(pInfo->pChildren);
|
||||||
|
|
|
@ -192,9 +192,9 @@ static bool validateTimezoneFormat(const SValueNode* pVal) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void static addTimezoneParam(SNodeList* pList) {
|
void static addTimezoneParam(SNodeList* pList) {
|
||||||
char buf[6] = {0};
|
char buf[6] = {0};
|
||||||
time_t t = taosTime(NULL);
|
time_t t = taosTime(NULL);
|
||||||
struct tm tmInfo;
|
struct tm tmInfo;
|
||||||
taosLocalTime(&t, &tmInfo);
|
taosLocalTime(&t, &tmInfo);
|
||||||
strftime(buf, sizeof(buf), "%z", &tmInfo);
|
strftime(buf, sizeof(buf), "%z", &tmInfo);
|
||||||
int32_t len = (int32_t)strlen(buf);
|
int32_t len = (int32_t)strlen(buf);
|
||||||
|
@ -976,7 +976,7 @@ static int32_t translateHistogram(SFunctionNode* pFunc, char* pErrBuf, int32_t l
|
||||||
// param1 ~ param3
|
// param1 ~ param3
|
||||||
if (((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type != TSDB_DATA_TYPE_BINARY ||
|
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, 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);
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1034,7 +1034,7 @@ static int32_t translateHistogramImpl(SFunctionNode* pFunc, char* pErrBuf, int32
|
||||||
// param1 ~ param3
|
// param1 ~ param3
|
||||||
if (((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type != TSDB_DATA_TYPE_BINARY ||
|
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, 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);
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1133,9 +1133,10 @@ static bool validateStateOper(const SValueNode* pVal) {
|
||||||
if (TSDB_DATA_TYPE_BINARY != pVal->node.resType.type) {
|
if (TSDB_DATA_TYPE_BINARY != pVal->node.resType.type) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (0 == strncasecmp(varDataVal(pVal->datum.p), "GT", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "GE", 2) ||
|
return (
|
||||||
0 == strncasecmp(varDataVal(pVal->datum.p), "LT", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "LE", 2) ||
|
0 == strncasecmp(varDataVal(pVal->datum.p), "GT", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "GE", 2) ||
|
||||||
0 == strncasecmp(varDataVal(pVal->datum.p), "EQ", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "NE", 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) {
|
static int32_t translateStateCount(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
|
@ -1348,7 +1349,8 @@ static int32_t translateTail(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
|
|
||||||
SValueNode* pValue = (SValueNode*)pParamNode;
|
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,
|
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||||
"TAIL function second parameter should be in range [1, 100], "
|
"TAIL function second parameter should be in range [1, 100], "
|
||||||
"third parameter should be in range [0, 100]");
|
"third parameter should be in range [0, 100]");
|
||||||
|
@ -1423,6 +1425,17 @@ static int32_t translateIrate(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateFirstLast(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;
|
pFunc->node.resType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1433,6 +1446,15 @@ static int32_t translateFirstLastImpl(SFunctionNode* pFunc, char* pErrBuf, int32
|
||||||
uint8_t paraType = ((SExprNode*)pPara)->resType.type;
|
uint8_t paraType = ((SExprNode*)pPara)->resType.type;
|
||||||
int32_t paraBytes = ((SExprNode*)pPara)->resType.bytes;
|
int32_t paraBytes = ((SExprNode*)pPara)->resType.bytes;
|
||||||
if (isPartial) {
|
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 =
|
pFunc->node.resType =
|
||||||
(SDataType){.bytes = getFirstLastInfoSize(paraBytes) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY};
|
(SDataType){.bytes = getFirstLastInfoSize(paraBytes) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY};
|
||||||
} else {
|
} else {
|
||||||
|
@ -1646,9 +1668,9 @@ static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
if (IS_VAR_DATA_TYPE(para2Type)) {
|
if (IS_VAR_DATA_TYPE(para2Type)) {
|
||||||
para2Bytes -= VARSTR_HEADER_SIZE;
|
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,
|
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
|
// add database precision as param
|
||||||
|
|
|
@ -80,7 +80,7 @@ typedef struct STopBotRes {
|
||||||
} STopBotRes;
|
} STopBotRes;
|
||||||
|
|
||||||
typedef struct SFirstLastRes {
|
typedef struct SFirstLastRes {
|
||||||
bool hasResult;
|
bool hasResult;
|
||||||
// used for last_row function only, isNullRes in SResultRowEntry can not be passed to downstream.So,
|
// used for last_row function only, isNullRes in SResultRowEntry can not be passed to downstream.So,
|
||||||
// this attribute is required
|
// this attribute is required
|
||||||
bool isNull;
|
bool isNull;
|
||||||
|
@ -2380,7 +2380,8 @@ int32_t percentileFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
SVariant* pVal = &pCtx->param[1].param;
|
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);
|
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||||
SPercentileInfo* ppInfo = (SPercentileInfo*)GET_ROWCELL_INTERBUF(pResInfo);
|
SPercentileInfo* ppInfo = (SPercentileInfo*)GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
@ -2439,7 +2440,8 @@ bool apercentileFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResult
|
||||||
SAPercentileInfo* pInfo = GET_ROWCELL_INTERBUF(pResultInfo);
|
SAPercentileInfo* pInfo = GET_ROWCELL_INTERBUF(pResultInfo);
|
||||||
|
|
||||||
SVariant* pVal = &pCtx->param[1].param;
|
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) {
|
if (pCtx->numOfParams == 2) {
|
||||||
pInfo->algo = APERCT_ALGO_DEFAULT;
|
pInfo->algo = APERCT_ALGO_DEFAULT;
|
||||||
|
@ -2640,9 +2642,7 @@ int32_t apercentileCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx)
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t getFirstLastInfoSize(int32_t resBytes) {
|
int32_t getFirstLastInfoSize(int32_t resBytes) { return sizeof(SFirstLastRes) + resBytes; }
|
||||||
return sizeof(SFirstLastRes) + resBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool getFirstLastFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) {
|
bool getFirstLastFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) {
|
||||||
SColumnNode* pNode = (SColumnNode*)nodesListGetNode(pFunc->pParameterList, 0);
|
SColumnNode* pNode = (SColumnNode*)nodesListGetNode(pFunc->pParameterList, 0);
|
||||||
|
@ -2968,7 +2968,7 @@ int32_t firstLastPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo rewrite:
|
// todo rewrite:
|
||||||
int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
|
int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
|
||||||
SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx);
|
SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx);
|
||||||
char* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo);
|
char* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo);
|
||||||
|
@ -2986,7 +2986,7 @@ int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
|
||||||
return TSDB_CODE_SUCCESS;
|
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;
|
SInputColumnInfoData* pInput = &pCtx->input;
|
||||||
SColumnInfoData* pInputCol = pInput->pData[0];
|
SColumnInfoData* pInputCol = pInput->pData[0];
|
||||||
|
|
||||||
|
@ -5098,12 +5098,7 @@ bool modeFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doModeAdd(SModeInfo* pInfo, char* data, bool isNull) {
|
static void doModeAdd(SModeInfo* pInfo, char* data) {
|
||||||
// ignore null elements
|
|
||||||
if (isNull) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t hashKeyBytes = IS_VAR_DATA_TYPE(pInfo->colType) ? varDataTLen(data) : pInfo->colBytes;
|
int32_t hashKeyBytes = IS_VAR_DATA_TYPE(pInfo->colType) ? varDataTLen(data) : pInfo->colBytes;
|
||||||
SModeItem** pHashItem = taosHashGet(pInfo->pHash, data, hashKeyBytes);
|
SModeItem** pHashItem = taosHashGet(pInfo->pHash, data, hashKeyBytes);
|
||||||
if (pHashItem == NULL) {
|
if (pHashItem == NULL) {
|
||||||
|
@ -5128,10 +5123,16 @@ int32_t modeFunction(SqlFunctionCtx* pCtx) {
|
||||||
SColumnInfoData* pInputCol = pInput->pData[0];
|
SColumnInfoData* pInputCol = pInput->pData[0];
|
||||||
SColumnInfoData* pOutput = (SColumnInfoData*)pCtx->pOutput;
|
SColumnInfoData* pOutput = (SColumnInfoData*)pCtx->pOutput;
|
||||||
|
|
||||||
|
int32_t numOfElems = 0;
|
||||||
int32_t startOffset = pCtx->offset;
|
int32_t startOffset = pCtx->offset;
|
||||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||||
char* data = colDataGetData(pInputCol, 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) {
|
if (sizeof(SModeInfo) + pInfo->numOfPoints * (sizeof(SModeItem) + pInfo->colBytes) >= MODE_MAX_RESULT_SIZE) {
|
||||||
taosHashCleanup(pInfo->pHash);
|
taosHashCleanup(pInfo->pHash);
|
||||||
|
@ -5139,7 +5140,7 @@ int32_t modeFunction(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SET_VAL(pResInfo, 1, 1);
|
SET_VAL(pResInfo, numOfElems, 1);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,6 +159,8 @@ const char* nodesNodeName(ENodeType type) {
|
||||||
return "ShowStreamsStmt";
|
return "ShowStreamsStmt";
|
||||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||||
return "ShowTablesStmt";
|
return "ShowTablesStmt";
|
||||||
|
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||||
|
return "ShowTagsStmt";
|
||||||
case QUERY_NODE_SHOW_USERS_STMT:
|
case QUERY_NODE_SHOW_USERS_STMT:
|
||||||
return "ShowUsersStmt";
|
return "ShowUsersStmt";
|
||||||
case QUERY_NODE_SHOW_LICENCE_STMT:
|
case QUERY_NODE_SHOW_LICENCE_STMT:
|
||||||
|
@ -4295,6 +4297,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
return alterDnodeStmtToJson(pObj, pJson);
|
return alterDnodeStmtToJson(pObj, pJson);
|
||||||
case QUERY_NODE_SHOW_DATABASES_STMT:
|
case QUERY_NODE_SHOW_DATABASES_STMT:
|
||||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||||
|
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_CREATE_TOPIC_STMT:
|
case QUERY_NODE_CREATE_TOPIC_STMT:
|
||||||
return createTopicStmtToJson(pObj, pJson);
|
return createTopicStmtToJson(pObj, pJson);
|
||||||
|
|
|
@ -216,6 +216,7 @@ SNode* nodesMakeNode(ENodeType type) {
|
||||||
case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT:
|
||||||
case QUERY_NODE_SHOW_TRANSACTIONS_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:
|
||||||
return makeNode(type, sizeof(SShowStmt));
|
return makeNode(type, sizeof(SShowStmt));
|
||||||
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
||||||
return makeNode(type, sizeof(SShowDnodeVariablesStmt));
|
return makeNode(type, sizeof(SShowDnodeVariablesStmt));
|
||||||
|
@ -678,7 +679,8 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
||||||
case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT:
|
||||||
case QUERY_NODE_SHOW_TRANSACTIONS_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;
|
SShowStmt* pStmt = (SShowStmt*)pNode;
|
||||||
nodesDestroyNode(pStmt->pDbName);
|
nodesDestroyNode(pStmt->pDbName);
|
||||||
nodesDestroyNode(pStmt->pTbName);
|
nodesDestroyNode(pStmt->pTbName);
|
||||||
|
@ -1923,15 +1925,18 @@ int32_t nodesPartitionCond(SNode** pCondition, SNode** pPrimaryKeyCond, SNode**
|
||||||
return partitionLogicCond(pCondition, pPrimaryKeyCond, pTagIndexCond, pTagCond, pOtherCond);
|
return partitionLogicCond(pCondition, pPrimaryKeyCond, pTagIndexCond, pTagCond, pOtherCond);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool needOutput = false;
|
||||||
switch (classifyCondition(*pCondition)) {
|
switch (classifyCondition(*pCondition)) {
|
||||||
case COND_TYPE_PRIMARY_KEY:
|
case COND_TYPE_PRIMARY_KEY:
|
||||||
if (NULL != pPrimaryKeyCond) {
|
if (NULL != pPrimaryKeyCond) {
|
||||||
*pPrimaryKeyCond = *pCondition;
|
*pPrimaryKeyCond = *pCondition;
|
||||||
|
needOutput = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COND_TYPE_TAG_INDEX:
|
case COND_TYPE_TAG_INDEX:
|
||||||
if (NULL != pTagIndexCond) {
|
if (NULL != pTagIndexCond) {
|
||||||
*pTagIndexCond = *pCondition;
|
*pTagIndexCond = *pCondition;
|
||||||
|
needOutput = true;
|
||||||
}
|
}
|
||||||
if (NULL != pTagCond) {
|
if (NULL != pTagCond) {
|
||||||
SNode* pTempCond = *pCondition;
|
SNode* pTempCond = *pCondition;
|
||||||
|
@ -1942,21 +1947,26 @@ int32_t nodesPartitionCond(SNode** pCondition, SNode** pPrimaryKeyCond, SNode**
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*pTagCond = pTempCond;
|
*pTagCond = pTempCond;
|
||||||
|
needOutput = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COND_TYPE_TAG:
|
case COND_TYPE_TAG:
|
||||||
if (NULL != pTagCond) {
|
if (NULL != pTagCond) {
|
||||||
*pTagCond = *pCondition;
|
*pTagCond = *pCondition;
|
||||||
|
needOutput = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COND_TYPE_NORMAL:
|
case COND_TYPE_NORMAL:
|
||||||
default:
|
default:
|
||||||
if (NULL != pOtherCond) {
|
if (NULL != pOtherCond) {
|
||||||
*pOtherCond = *pCondition;
|
*pOtherCond = *pCondition;
|
||||||
|
needOutput = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*pCondition = NULL;
|
if (needOutput) {
|
||||||
|
*pCondition = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,6 @@ alter_account_option ::= STATE literal.
|
||||||
/************************************************ create/alter/drop user **********************************************/
|
/************************************************ 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 ::= 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) 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) 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 ::= 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); }
|
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 }
|
%type alter_db_option { SAlterOption }
|
||||||
%destructor alter_db_option { }
|
%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) ::= 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) ::= 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) ::= 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 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) ::= 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) ::= 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) ::= 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) ::= 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; }
|
alter_db_option(A) ::= WAL NK_INTEGER(B). { A.type = DB_OPTION_WAL; A.val = B; }
|
||||||
|
|
||||||
%type integer_list { SNodeList* }
|
%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 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 CONSUMERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); }
|
||||||
cmd ::= SHOW SUBSCRIPTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_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) ::= . { A = createDefaultDatabaseCondValue(pCxt); }
|
||||||
db_name_cond_opt(A) ::= db_name(B) NK_DOT. { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); }
|
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); }
|
cmd ::= INSERT INTO full_table_name(A) query_expression(B). { pCxt->pRootNode = createInsertStmt(pCxt, A, NULL, B); }
|
||||||
|
|
||||||
/************************************************ literal *************************************************************/
|
/************************************************ 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_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_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)); }
|
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)); }
|
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_INTEGER(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B); }
|
||||||
signed(A) ::= NK_PLUS NK_INTEGER(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B); }
|
signed(A) ::= NK_PLUS NK_INTEGER(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B); }
|
||||||
signed(A) ::= NK_MINUS(B) NK_INTEGER(C). {
|
signed(A) ::= NK_MINUS(B) NK_INTEGER(C). {
|
||||||
SToken t = B;
|
SToken t = B;
|
||||||
t.n = (C.z + C.n) - B.z;
|
t.n = (C.z + C.n) - B.z;
|
||||||
|
|
|
@ -393,9 +393,16 @@ SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pL
|
||||||
SValueNode* pVal = (SValueNode*)pLeft;
|
SValueNode* pVal = (SValueNode*)pLeft;
|
||||||
char* pNewLiteral = taosMemoryCalloc(1, strlen(pVal->literal) + 2);
|
char* pNewLiteral = taosMemoryCalloc(1, strlen(pVal->literal) + 2);
|
||||||
CHECK_OUT_OF_MEM(pNewLiteral);
|
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);
|
taosMemoryFree(pVal->literal);
|
||||||
pVal->literal = pNewLiteral;
|
pVal->literal = pNewLiteral;
|
||||||
|
pVal->node.resType.type = TSDB_DATA_TYPE_BIGINT;
|
||||||
return pLeft;
|
return pLeft;
|
||||||
}
|
}
|
||||||
SOperatorNode* op = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
SOperatorNode* op = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||||
|
@ -1343,7 +1350,11 @@ SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
SAlterDnodeStmt* pStmt = (SAlterDnodeStmt*)nodesMakeNode(QUERY_NODE_ALTER_DNODE_STMT);
|
SAlterDnodeStmt* pStmt = (SAlterDnodeStmt*)nodesMakeNode(QUERY_NODE_ALTER_DNODE_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
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));
|
trimString(pConfig->z, pConfig->n, pStmt->config, sizeof(pStmt->config));
|
||||||
if (NULL != pValue) {
|
if (NULL != pValue) {
|
||||||
trimString(pValue->z, pValue->n, pStmt->value, sizeof(pStmt->value));
|
trimString(pValue->z, pValue->n, pStmt->value, sizeof(pStmt->value));
|
||||||
|
|
|
@ -372,8 +372,8 @@ static int32_t collectMetaKeyFromShowTables(SCollectMetaKeyCxt* pCxt, SShowStmt*
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromShowTags(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
static int32_t collectMetaKeyFromShowTags(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB,
|
int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_TAGS,
|
||||||
TSDB_INS_TABLE_USER_TAGS, pCxt->pMetaCache);
|
pCxt->pMetaCache);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
if (NULL != pStmt->pDbName) {
|
if (NULL != pStmt->pDbName) {
|
||||||
code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
|
code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
|
||||||
|
|
|
@ -2385,7 +2385,7 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols
|
||||||
if (format) {
|
if (format) {
|
||||||
if (j < rowDataSize) {
|
if (j < rowDataSize) {
|
||||||
kv = taosArrayGetP(rowData, j);
|
kv = taosArrayGetP(rowData, j);
|
||||||
if (rowDataSize != spd->numOfBound &&
|
if (rowDataSize != spd->numOfBound && j != 0 &&
|
||||||
(kv->keyLen != strlen(pColSchema->name) || strncmp(kv->key, pColSchema->name, kv->keyLen) != 0)) {
|
(kv->keyLen != strlen(pColSchema->name) || strncmp(kv->key, pColSchema->name, kv->keyLen) != 0)) {
|
||||||
kv = NULL;
|
kv = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -826,7 +826,7 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal,
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_UTINYINT: {
|
case TSDB_DATA_TYPE_UTINYINT: {
|
||||||
code = toUInteger(pVal->literal, strlen(pVal->literal), 10, &pVal->datum.u);
|
code = toUInteger(pVal->literal, strlen(pVal->literal), 10, &pVal->datum.u);
|
||||||
if (strict && (TSDB_CODE_SUCCESS != code || !IS_VALID_UTINYINT(pVal->datum.i))) {
|
if (strict && (TSDB_CODE_SUCCESS != code || !IS_VALID_UTINYINT(pVal->datum.u))) {
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
||||||
}
|
}
|
||||||
*(uint8_t*)&pVal->typeData = pVal->datum.u;
|
*(uint8_t*)&pVal->typeData = pVal->datum.u;
|
||||||
|
@ -834,7 +834,7 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal,
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_USMALLINT: {
|
case TSDB_DATA_TYPE_USMALLINT: {
|
||||||
code = toUInteger(pVal->literal, strlen(pVal->literal), 10, &pVal->datum.u);
|
code = toUInteger(pVal->literal, strlen(pVal->literal), 10, &pVal->datum.u);
|
||||||
if (strict && (TSDB_CODE_SUCCESS != code || !IS_VALID_USMALLINT(pVal->datum.i))) {
|
if (strict && (TSDB_CODE_SUCCESS != code || !IS_VALID_USMALLINT(pVal->datum.u))) {
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
||||||
}
|
}
|
||||||
*(uint16_t*)&pVal->typeData = pVal->datum.u;
|
*(uint16_t*)&pVal->typeData = pVal->datum.u;
|
||||||
|
@ -842,7 +842,7 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal,
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_UINT: {
|
case TSDB_DATA_TYPE_UINT: {
|
||||||
code = toUInteger(pVal->literal, strlen(pVal->literal), 10, &pVal->datum.u);
|
code = toUInteger(pVal->literal, strlen(pVal->literal), 10, &pVal->datum.u);
|
||||||
if (strict && (TSDB_CODE_SUCCESS != code || !IS_VALID_UINT(pVal->datum.i))) {
|
if (strict && (TSDB_CODE_SUCCESS != code || !IS_VALID_UINT(pVal->datum.u))) {
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
||||||
}
|
}
|
||||||
*(uint32_t*)&pVal->typeData = pVal->datum.u;
|
*(uint32_t*)&pVal->typeData = pVal->datum.u;
|
||||||
|
@ -850,7 +850,7 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal,
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_UBIGINT: {
|
case TSDB_DATA_TYPE_UBIGINT: {
|
||||||
code = toUInteger(pVal->literal, strlen(pVal->literal), 10, &pVal->datum.u);
|
code = toUInteger(pVal->literal, strlen(pVal->literal), 10, &pVal->datum.u);
|
||||||
if (strict && (TSDB_CODE_SUCCESS != code || !IS_VALID_UBIGINT(pVal->datum.i))) {
|
if (strict && (TSDB_CODE_SUCCESS != code || !IS_VALID_UBIGINT(pVal->datum.u))) {
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
||||||
}
|
}
|
||||||
*(uint64_t*)&pVal->typeData = pVal->datum.u;
|
*(uint64_t*)&pVal->typeData = pVal->datum.u;
|
||||||
|
@ -858,11 +858,18 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal,
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_FLOAT: {
|
case TSDB_DATA_TYPE_FLOAT: {
|
||||||
pVal->datum.d = taosStr2Double(pVal->literal, NULL);
|
pVal->datum.d = taosStr2Double(pVal->literal, NULL);
|
||||||
|
if (strict && !IS_VALID_FLOAT(pVal->datum.d)) {
|
||||||
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
||||||
|
}
|
||||||
*(float*)&pVal->typeData = pVal->datum.d;
|
*(float*)&pVal->typeData = pVal->datum.d;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_DOUBLE: {
|
case TSDB_DATA_TYPE_DOUBLE: {
|
||||||
pVal->datum.d = taosStr2Double(pVal->literal, NULL);
|
pVal->datum.d = taosStr2Double(pVal->literal, NULL);
|
||||||
|
if (strict && (((pVal->datum.d == HUGE_VAL || pVal->datum.d == -HUGE_VAL) && errno == ERANGE) ||
|
||||||
|
isinf(pVal->datum.d) || isnan(pVal->datum.d))) {
|
||||||
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
||||||
|
}
|
||||||
*(double*)&pVal->typeData = pVal->datum.d;
|
*(double*)&pVal->typeData = pVal->datum.d;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -936,6 +943,9 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD
|
||||||
pVal->node.resType = targetDt;
|
pVal->node.resType = targetDt;
|
||||||
pVal->node.resType.scale = pVal->unit;
|
pVal->node.resType.scale = pVal->unit;
|
||||||
pVal->translate = true;
|
pVal->translate = true;
|
||||||
|
if (!strict && TSDB_DATA_TYPE_UBIGINT == pVal->node.resType.type && pVal->datum.u <= INT64_MAX) {
|
||||||
|
pVal->node.resType.type = TSDB_DATA_TYPE_BIGINT;
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2955,14 +2965,25 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS
|
||||||
return buildCreateDbRetentions(pStmt->pOptions->pRetentions, pReq);
|
return buildCreateDbRetentions(pStmt->pOptions->pRetentions, pReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkRangeOption(STranslateContext* pCxt, const char* pName, int32_t val, int32_t minVal,
|
static int32_t checkRangeOption(STranslateContext* pCxt, int32_t code, const char* pName, int32_t val, int32_t minVal,
|
||||||
int32_t maxVal) {
|
int32_t maxVal) {
|
||||||
if (val >= 0 && (val < minVal || val > maxVal)) {
|
if (val >= 0 && (val < minVal || val > maxVal)) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_RANGE_OPTION, pName, val, minVal, maxVal);
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, code, "Invalid option %s: %" PRId64 " valid range: [%d, %d]", pName,
|
||||||
|
val, minVal, maxVal);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t checkDbRangeOption(STranslateContext* pCxt, const char* pName, int32_t val, int32_t minVal,
|
||||||
|
int32_t maxVal) {
|
||||||
|
return checkRangeOption(pCxt, TSDB_CODE_PAR_INVALID_DB_OPTION, pName, val, minVal, maxVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t checkTableRangeOption(STranslateContext* pCxt, const char* pName, int32_t val, int32_t minVal,
|
||||||
|
int32_t maxVal) {
|
||||||
|
return checkRangeOption(pCxt, TSDB_CODE_PAR_INVALID_TABLE_OPTION, pName, val, minVal, maxVal);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t checkDbDaysOption(STranslateContext* pCxt, SDatabaseOptions* pOptions) {
|
static int32_t checkDbDaysOption(STranslateContext* pCxt, SDatabaseOptions* pOptions) {
|
||||||
if (NULL != pOptions->pDaysPerFile) {
|
if (NULL != pOptions->pDaysPerFile) {
|
||||||
if (DEAL_RES_ERROR == translateValue(pCxt, pOptions->pDaysPerFile)) {
|
if (DEAL_RES_ERROR == translateValue(pCxt, pOptions->pDaysPerFile)) {
|
||||||
|
@ -2970,12 +2991,13 @@ static int32_t checkDbDaysOption(STranslateContext* pCxt, SDatabaseOptions* pOpt
|
||||||
}
|
}
|
||||||
if (TIME_UNIT_MINUTE != pOptions->pDaysPerFile->unit && TIME_UNIT_HOUR != pOptions->pDaysPerFile->unit &&
|
if (TIME_UNIT_MINUTE != pOptions->pDaysPerFile->unit && TIME_UNIT_HOUR != pOptions->pDaysPerFile->unit &&
|
||||||
TIME_UNIT_DAY != pOptions->pDaysPerFile->unit) {
|
TIME_UNIT_DAY != pOptions->pDaysPerFile->unit) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_OPTION_UNIT, "daysPerFile",
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION,
|
||||||
pOptions->pDaysPerFile->unit, TIME_UNIT_MINUTE, TIME_UNIT_HOUR, TIME_UNIT_DAY);
|
"Invalid option duration unit: %c, only %c, %c, %c allowed",
|
||||||
|
pOptions->pDaysPerFile->unit, TIME_UNIT_MINUTE, TIME_UNIT_HOUR, TIME_UNIT_DAY);
|
||||||
}
|
}
|
||||||
pOptions->daysPerFile = getBigintFromValueNode(pOptions->pDaysPerFile);
|
pOptions->daysPerFile = getBigintFromValueNode(pOptions->pDaysPerFile);
|
||||||
}
|
}
|
||||||
return checkRangeOption(pCxt, "daysPerFile", pOptions->daysPerFile, TSDB_MIN_DAYS_PER_FILE, TSDB_MAX_DAYS_PER_FILE);
|
return checkDbRangeOption(pCxt, "daysPerFile", pOptions->daysPerFile, TSDB_MIN_DAYS_PER_FILE, TSDB_MAX_DAYS_PER_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkDbKeepOption(STranslateContext* pCxt, SDatabaseOptions* pOptions) {
|
static int32_t checkDbKeepOption(STranslateContext* pCxt, SDatabaseOptions* pOptions) {
|
||||||
|
@ -2985,7 +3007,7 @@ static int32_t checkDbKeepOption(STranslateContext* pCxt, SDatabaseOptions* pOpt
|
||||||
|
|
||||||
int32_t numOfKeep = LIST_LENGTH(pOptions->pKeep);
|
int32_t numOfKeep = LIST_LENGTH(pOptions->pKeep);
|
||||||
if (numOfKeep > 3 || numOfKeep < 1) {
|
if (numOfKeep > 3 || numOfKeep < 1) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_KEEP_NUM);
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION, "Invalid number of keep options");
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
|
@ -2996,7 +3018,8 @@ static int32_t checkDbKeepOption(STranslateContext* pCxt, SDatabaseOptions* pOpt
|
||||||
}
|
}
|
||||||
if (pVal->isDuration && TIME_UNIT_MINUTE != pVal->unit && TIME_UNIT_HOUR != pVal->unit &&
|
if (pVal->isDuration && TIME_UNIT_MINUTE != pVal->unit && TIME_UNIT_HOUR != pVal->unit &&
|
||||||
TIME_UNIT_DAY != pVal->unit) {
|
TIME_UNIT_DAY != pVal->unit) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_KEEP_UNIT, pVal->unit);
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION,
|
||||||
|
"Invalid option keep unit: %c, only m, h, d allowed", pVal->unit);
|
||||||
}
|
}
|
||||||
if (!pVal->isDuration) {
|
if (!pVal->isDuration) {
|
||||||
pVal->datum.i = pVal->datum.i * 1440;
|
pVal->datum.i = pVal->datum.i * 1440;
|
||||||
|
@ -3018,12 +3041,15 @@ static int32_t checkDbKeepOption(STranslateContext* pCxt, SDatabaseOptions* pOpt
|
||||||
|
|
||||||
if (pOptions->keep[0] < TSDB_MIN_KEEP || pOptions->keep[1] < TSDB_MIN_KEEP || pOptions->keep[2] < TSDB_MIN_KEEP ||
|
if (pOptions->keep[0] < TSDB_MIN_KEEP || pOptions->keep[1] < TSDB_MIN_KEEP || pOptions->keep[2] < TSDB_MIN_KEEP ||
|
||||||
pOptions->keep[0] > TSDB_MAX_KEEP || pOptions->keep[1] > TSDB_MAX_KEEP || pOptions->keep[2] > TSDB_MAX_KEEP) {
|
pOptions->keep[0] > TSDB_MAX_KEEP || pOptions->keep[1] > TSDB_MAX_KEEP || pOptions->keep[2] > TSDB_MAX_KEEP) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_KEEP_VALUE, pOptions->keep[0], pOptions->keep[1],
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION,
|
||||||
pOptions->keep[2], TSDB_MIN_KEEP, TSDB_MAX_KEEP);
|
"Invalid option keep: %" PRId64 ", %" PRId64 ", %" PRId64 " valid range: [%dm, %dm]",
|
||||||
|
pOptions->keep[0], pOptions->keep[1], pOptions->keep[2], TSDB_MIN_KEEP,
|
||||||
|
TSDB_MAX_KEEP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!((pOptions->keep[0] <= pOptions->keep[1]) && (pOptions->keep[1] <= pOptions->keep[2]))) {
|
if (!((pOptions->keep[0] <= pOptions->keep[1]) && (pOptions->keep[1] <= pOptions->keep[2]))) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_KEEP_ORDER);
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION,
|
||||||
|
"Invalid keep value, should be keep0 <= keep1 <= keep2");
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -3040,8 +3066,8 @@ static int32_t checkDbCacheModelOption(STranslateContext* pCxt, SDatabaseOptions
|
||||||
} else if (0 == strcasecmp(pOptions->cacheModelStr, TSDB_CACHE_MODEL_BOTH_STR)) {
|
} else if (0 == strcasecmp(pOptions->cacheModelStr, TSDB_CACHE_MODEL_BOTH_STR)) {
|
||||||
pOptions->cacheModel = TSDB_CACHE_MODEL_BOTH;
|
pOptions->cacheModel = TSDB_CACHE_MODEL_BOTH;
|
||||||
} else {
|
} else {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STR_OPTION, "cacheModel",
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION, "Invalid option cacheModel: %s",
|
||||||
pOptions->cacheModelStr);
|
pOptions->cacheModelStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -3056,7 +3082,8 @@ static int32_t checkDbPrecisionOption(STranslateContext* pCxt, SDatabaseOptions*
|
||||||
} else if (0 == strcasecmp(pOptions->precisionStr, TSDB_TIME_PRECISION_NANO_STR)) {
|
} else if (0 == strcasecmp(pOptions->precisionStr, TSDB_TIME_PRECISION_NANO_STR)) {
|
||||||
pOptions->precision = TSDB_TIME_PRECISION_NANO;
|
pOptions->precision = TSDB_TIME_PRECISION_NANO;
|
||||||
} else {
|
} else {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STR_OPTION, "precision", pOptions->precisionStr);
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION, "Invalid option precision: %s",
|
||||||
|
pOptions->precisionStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -3069,7 +3096,8 @@ static int32_t checkDbStrictOption(STranslateContext* pCxt, SDatabaseOptions* pO
|
||||||
} else if (0 == strcasecmp(pOptions->strictStr, TSDB_DB_STRICT_ON_STR)) {
|
} else if (0 == strcasecmp(pOptions->strictStr, TSDB_DB_STRICT_ON_STR)) {
|
||||||
pOptions->strict = TSDB_DB_STRICT_ON;
|
pOptions->strict = TSDB_DB_STRICT_ON;
|
||||||
} else {
|
} else {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STR_OPTION, "strict", pOptions->strictStr);
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION, "Invalid option strict: %s",
|
||||||
|
pOptions->strictStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -3077,7 +3105,8 @@ static int32_t checkDbStrictOption(STranslateContext* pCxt, SDatabaseOptions* pO
|
||||||
|
|
||||||
static int32_t checkDbEnumOption(STranslateContext* pCxt, const char* pName, int32_t val, int32_t v1, int32_t v2) {
|
static int32_t checkDbEnumOption(STranslateContext* pCxt, const char* pName, int32_t val, int32_t v1, int32_t v2) {
|
||||||
if (val >= 0 && val != v1 && val != v2) {
|
if (val >= 0 && val != v1 && val != v2) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ENUM_OPTION, pName, val, v1, v2);
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION,
|
||||||
|
"Invalid option %s: %" PRId64 ", only %d, %d allowed", pName, val, v1, v2);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -3088,7 +3117,7 @@ static int32_t checkDbRetentionsOption(STranslateContext* pCxt, SNodeList* pRete
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LIST_LENGTH(pRetentions) > 3) {
|
if (LIST_LENGTH(pRetentions) > 3) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION);
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION, "Invalid option retentions");
|
||||||
}
|
}
|
||||||
|
|
||||||
SValueNode* pPrevFreq = NULL;
|
SValueNode* pPrevFreq = NULL;
|
||||||
|
@ -3108,7 +3137,7 @@ static int32_t checkDbRetentionsOption(STranslateContext* pCxt, SNodeList* pRete
|
||||||
if (pFreq->datum.i <= 0 || 'n' == pFreq->unit || 'y' == pFreq->unit || pFreq->datum.i >= pKeep->datum.i ||
|
if (pFreq->datum.i <= 0 || 'n' == pFreq->unit || 'y' == pFreq->unit || pFreq->datum.i >= pKeep->datum.i ||
|
||||||
(NULL != pPrevFreq && pPrevFreq->datum.i >= pFreq->datum.i) ||
|
(NULL != pPrevFreq && pPrevFreq->datum.i >= pFreq->datum.i) ||
|
||||||
(NULL != pPrevKeep && pPrevKeep->datum.i > pKeep->datum.i)) {
|
(NULL != pPrevKeep && pPrevKeep->datum.i > pKeep->datum.i)) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION);
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION, "Invalid option retentions");
|
||||||
}
|
}
|
||||||
pPrevFreq = pFreq;
|
pPrevFreq = pFreq;
|
||||||
pPrevKeep = pKeep;
|
pPrevKeep = pKeep;
|
||||||
|
@ -3139,39 +3168,41 @@ static int32_t checkOptionsDependency(STranslateContext* pCxt, const char* pDbNa
|
||||||
|
|
||||||
static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName, SDatabaseOptions* pOptions) {
|
static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName, SDatabaseOptions* pOptions) {
|
||||||
int32_t code =
|
int32_t code =
|
||||||
checkRangeOption(pCxt, "buffer", pOptions->buffer, TSDB_MIN_BUFFER_PER_VNODE, TSDB_MAX_BUFFER_PER_VNODE);
|
checkDbRangeOption(pCxt, "buffer", pOptions->buffer, TSDB_MIN_BUFFER_PER_VNODE, TSDB_MAX_BUFFER_PER_VNODE);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkDbCacheModelOption(pCxt, pOptions);
|
code = checkDbCacheModelOption(pCxt, pOptions);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkRangeOption(pCxt, "cacheSize", pOptions->cacheLastSize, TSDB_MIN_DB_CACHE_SIZE, TSDB_MAX_DB_CACHE_SIZE);
|
code =
|
||||||
|
checkDbRangeOption(pCxt, "cacheSize", pOptions->cacheLastSize, TSDB_MIN_DB_CACHE_SIZE, TSDB_MAX_DB_CACHE_SIZE);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkRangeOption(pCxt, "compression", pOptions->compressionLevel, TSDB_MIN_COMP_LEVEL, TSDB_MAX_COMP_LEVEL);
|
code =
|
||||||
|
checkDbRangeOption(pCxt, "compression", pOptions->compressionLevel, TSDB_MIN_COMP_LEVEL, TSDB_MAX_COMP_LEVEL);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkDbDaysOption(pCxt, pOptions);
|
code = checkDbDaysOption(pCxt, pOptions);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkRangeOption(pCxt, "fsyncPeriod", pOptions->fsyncPeriod, TSDB_MIN_FSYNC_PERIOD, TSDB_MAX_FSYNC_PERIOD);
|
code = checkDbRangeOption(pCxt, "fsyncPeriod", pOptions->fsyncPeriod, TSDB_MIN_FSYNC_PERIOD, TSDB_MAX_FSYNC_PERIOD);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkRangeOption(pCxt, "maxRowsPerBlock", pOptions->maxRowsPerBlock, TSDB_MIN_MAXROWS_FBLOCK,
|
code = checkDbRangeOption(pCxt, "maxRowsPerBlock", pOptions->maxRowsPerBlock, TSDB_MIN_MAXROWS_FBLOCK,
|
||||||
TSDB_MAX_MAXROWS_FBLOCK);
|
TSDB_MAX_MAXROWS_FBLOCK);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkRangeOption(pCxt, "minRowsPerBlock", pOptions->minRowsPerBlock, TSDB_MIN_MINROWS_FBLOCK,
|
code = checkDbRangeOption(pCxt, "minRowsPerBlock", pOptions->minRowsPerBlock, TSDB_MIN_MINROWS_FBLOCK,
|
||||||
TSDB_MAX_MINROWS_FBLOCK);
|
TSDB_MAX_MINROWS_FBLOCK);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkDbKeepOption(pCxt, pOptions);
|
code = checkDbKeepOption(pCxt, pOptions);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkRangeOption(pCxt, "pages", pOptions->pages, TSDB_MIN_PAGES_PER_VNODE, TSDB_MAX_PAGES_PER_VNODE);
|
code = checkDbRangeOption(pCxt, "pages", pOptions->pages, TSDB_MIN_PAGES_PER_VNODE, TSDB_MAX_PAGES_PER_VNODE);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkRangeOption(pCxt, "pagesize", pOptions->pagesize, TSDB_MIN_PAGESIZE_PER_VNODE,
|
code = checkDbRangeOption(pCxt, "pagesize", pOptions->pagesize, TSDB_MIN_PAGESIZE_PER_VNODE,
|
||||||
TSDB_MAX_PAGESIZE_PER_VNODE);
|
TSDB_MAX_PAGESIZE_PER_VNODE);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkDbPrecisionOption(pCxt, pOptions);
|
code = checkDbPrecisionOption(pCxt, pOptions);
|
||||||
|
@ -3186,7 +3217,7 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName
|
||||||
code = checkDbEnumOption(pCxt, "walLevel", pOptions->walLevel, TSDB_MIN_WAL_LEVEL, TSDB_MAX_WAL_LEVEL);
|
code = checkDbEnumOption(pCxt, "walLevel", pOptions->walLevel, TSDB_MIN_WAL_LEVEL, TSDB_MAX_WAL_LEVEL);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkRangeOption(pCxt, "vgroups", pOptions->numOfVgroups, TSDB_MIN_VNODES_PER_DB, TSDB_MAX_VNODES_PER_DB);
|
code = checkDbRangeOption(pCxt, "vgroups", pOptions->numOfVgroups, TSDB_MIN_VNODES_PER_DB, TSDB_MAX_VNODES_PER_DB);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkDbEnumOption(pCxt, "singleStable", pOptions->singleStable, TSDB_DB_SINGLE_STABLE_ON,
|
code = checkDbEnumOption(pCxt, "singleStable", pOptions->singleStable, TSDB_DB_SINGLE_STABLE_ON,
|
||||||
|
@ -3257,7 +3288,6 @@ static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt,
|
||||||
pReq->buffer = pStmt->pOptions->buffer;
|
pReq->buffer = pStmt->pOptions->buffer;
|
||||||
pReq->pageSize = -1;
|
pReq->pageSize = -1;
|
||||||
pReq->pages = pStmt->pOptions->pages;
|
pReq->pages = pStmt->pOptions->pages;
|
||||||
pReq->cacheLastSize = -1;
|
|
||||||
pReq->daysPerFile = -1;
|
pReq->daysPerFile = -1;
|
||||||
pReq->daysToKeep0 = pStmt->pOptions->keep[0];
|
pReq->daysToKeep0 = pStmt->pOptions->keep[0];
|
||||||
pReq->daysToKeep1 = pStmt->pOptions->keep[1];
|
pReq->daysToKeep1 = pStmt->pOptions->keep[1];
|
||||||
|
@ -3361,12 +3391,12 @@ static int32_t checkTableRollupOption(STranslateContext* pCxt, SNodeList* pFuncs
|
||||||
"configured with the 'RETENTIONS' option");
|
"configured with the 'RETENTIONS' option");
|
||||||
}
|
}
|
||||||
if (1 != LIST_LENGTH(pFuncs)) {
|
if (1 != LIST_LENGTH(pFuncs)) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ROLLUP_OPTION,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TABLE_OPTION,
|
||||||
"Invalid option rollup: only one function is allowed");
|
"Invalid option rollup: only one function is allowed");
|
||||||
}
|
}
|
||||||
const char* pFunc = ((SFunctionNode*)nodesListGetNode(pFuncs, 0))->functionName;
|
const char* pFunc = ((SFunctionNode*)nodesListGetNode(pFuncs, 0))->functionName;
|
||||||
if (!validRollupFunc(pFunc)) {
|
if (!validRollupFunc(pFunc)) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ROLLUP_OPTION,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TABLE_OPTION,
|
||||||
"Invalid option rollup: %s function is not supported", pFunc);
|
"Invalid option rollup: %s function is not supported", pFunc);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -3487,11 +3517,12 @@ static int32_t getTableDelayOrWatermarkOption(STranslateContext* pCxt, const cha
|
||||||
int32_t code = (DEAL_RES_ERROR == translateValue(pCxt, pVal) ? pCxt->errCode : TSDB_CODE_SUCCESS);
|
int32_t code = (DEAL_RES_ERROR == translateValue(pCxt, pVal) ? pCxt->errCode : TSDB_CODE_SUCCESS);
|
||||||
if (TSDB_CODE_SUCCESS == code && TIME_UNIT_MILLISECOND != pVal->unit && TIME_UNIT_SECOND != pVal->unit &&
|
if (TSDB_CODE_SUCCESS == code && TIME_UNIT_MILLISECOND != pVal->unit && TIME_UNIT_SECOND != pVal->unit &&
|
||||||
TIME_UNIT_MINUTE != pVal->unit) {
|
TIME_UNIT_MINUTE != pVal->unit) {
|
||||||
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_OPTION_UNIT, pName, pVal->unit,
|
code = generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TABLE_OPTION,
|
||||||
TIME_UNIT_MILLISECOND, TIME_UNIT_SECOND, TIME_UNIT_MINUTE);
|
"Invalid option %s unit: %c, only %c, %c, %c allowed", pName, pVal->unit,
|
||||||
|
TIME_UNIT_MILLISECOND, TIME_UNIT_SECOND, TIME_UNIT_MINUTE);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkRangeOption(pCxt, pName, pVal->datum.i, minVal, maxVal);
|
code = checkTableRangeOption(pCxt, pName, pVal->datum.i, minVal, maxVal);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
*pMaxDelay = pVal->datum.i;
|
*pMaxDelay = pVal->datum.i;
|
||||||
|
@ -3517,7 +3548,7 @@ static int32_t checkTableMaxDelayOption(STranslateContext* pCxt, STableOptions*
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LIST_LENGTH(pOptions->pMaxDelay) > 2) {
|
if (LIST_LENGTH(pOptions->pMaxDelay) > 2) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TABLE_OPTION, "maxdelay");
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TABLE_OPTION, "Invalid option maxdelay");
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code =
|
int32_t code =
|
||||||
|
@ -3547,7 +3578,7 @@ static int32_t checkTableWatermarkOption(STranslateContext* pCxt, STableOptions*
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LIST_LENGTH(pOptions->pWatermark) > 2) {
|
if (LIST_LENGTH(pOptions->pWatermark) > 2) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TABLE_OPTION, "watermark");
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TABLE_OPTION, "Invalid option watermark");
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code =
|
int32_t code =
|
||||||
|
@ -3604,6 +3635,7 @@ typedef struct SSampleAstInfo {
|
||||||
SNode* pInterval;
|
SNode* pInterval;
|
||||||
SNode* pOffset;
|
SNode* pOffset;
|
||||||
SNode* pSliding;
|
SNode* pSliding;
|
||||||
|
SNodeList* pPartitionByList;
|
||||||
STableMeta* pRollupTableMeta;
|
STableMeta* pRollupTableMeta;
|
||||||
} SSampleAstInfo;
|
} SSampleAstInfo;
|
||||||
|
|
||||||
|
@ -3636,6 +3668,8 @@ static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, ch
|
||||||
SNode* pProject = NULL;
|
SNode* pProject = NULL;
|
||||||
FOREACH(pProject, pSelect->pProjectionList) { sprintf(((SExprNode*)pProject)->aliasName, "#%p", pProject); }
|
FOREACH(pProject, pSelect->pProjectionList) { sprintf(((SExprNode*)pProject)->aliasName, "#%p", pProject); }
|
||||||
|
|
||||||
|
TSWAP(pSelect->pPartitionByList, pInfo->pPartitionByList);
|
||||||
|
|
||||||
SIntervalWindowNode* pInterval = (SIntervalWindowNode*)nodesMakeNode(QUERY_NODE_INTERVAL_WINDOW);
|
SIntervalWindowNode* pInterval = (SIntervalWindowNode*)nodesMakeNode(QUERY_NODE_INTERVAL_WINDOW);
|
||||||
if (NULL == pInterval) {
|
if (NULL == pInterval) {
|
||||||
nodesDestroyNode((SNode*)pSelect);
|
nodesDestroyNode((SNode*)pSelect);
|
||||||
|
@ -3764,6 +3798,15 @@ static STableMeta* createRollupTableMeta(SCreateTableStmt* pStmt, int8_t precisi
|
||||||
return pMeta;
|
return pMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SNode* createTbnameFunction() {
|
||||||
|
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||||
|
if (NULL == pFunc) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
strcpy(pFunc->functionName, "tbname");
|
||||||
|
return (SNode*)pFunc;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t buildSampleAstInfoByTable(STranslateContext* pCxt, SCreateTableStmt* pStmt, SRetention* pRetension,
|
static int32_t buildSampleAstInfoByTable(STranslateContext* pCxt, SCreateTableStmt* pStmt, SRetention* pRetension,
|
||||||
int8_t precision, SSampleAstInfo* pInfo) {
|
int8_t precision, SSampleAstInfo* pInfo) {
|
||||||
pInfo->pDbName = pStmt->dbName;
|
pInfo->pDbName = pStmt->dbName;
|
||||||
|
@ -3774,7 +3817,7 @@ static int32_t buildSampleAstInfoByTable(STranslateContext* pCxt, SCreateTableSt
|
||||||
if (NULL == pInfo->pFuncs || NULL == pInfo->pInterval || NULL == pInfo->pRollupTableMeta) {
|
if (NULL == pInfo->pFuncs || NULL == pInfo->pInterval || NULL == pInfo->pRollupTableMeta) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return nodesListMakeStrictAppend(&pInfo->pPartitionByList, createTbnameFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t getRollupAst(STranslateContext* pCxt, SCreateTableStmt* pStmt, SRetention* pRetension, int8_t precision,
|
static int32_t getRollupAst(STranslateContext* pCxt, SCreateTableStmt* pStmt, SRetention* pRetension, int8_t precision,
|
||||||
|
@ -5043,6 +5086,7 @@ static const char* getSysDbName(ENodeType type) {
|
||||||
case QUERY_NODE_SHOW_CLUSTER_STMT:
|
case QUERY_NODE_SHOW_CLUSTER_STMT:
|
||||||
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
||||||
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
||||||
|
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||||
return TSDB_INFORMATION_SCHEMA_DB;
|
return TSDB_INFORMATION_SCHEMA_DB;
|
||||||
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
||||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||||
|
@ -6346,6 +6390,7 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
case QUERY_NODE_SHOW_APPS_STMT:
|
case QUERY_NODE_SHOW_APPS_STMT:
|
||||||
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
||||||
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||||
code = rewriteShow(pCxt, pQuery);
|
code = rewriteShow(pCxt, pQuery);
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
||||||
|
|
|
@ -67,32 +67,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
||||||
return "Invalid identifier name: %s";
|
return "Invalid identifier name: %s";
|
||||||
case TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR:
|
case TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR:
|
||||||
return "Corresponding super table not in this db";
|
return "Corresponding super table not in this db";
|
||||||
case TSDB_CODE_PAR_INVALID_RANGE_OPTION:
|
|
||||||
return "Invalid option %s: %" PRId64 " valid range: [%d, %d]";
|
|
||||||
case TSDB_CODE_PAR_INVALID_STR_OPTION:
|
|
||||||
return "Invalid option %s: %s";
|
|
||||||
case TSDB_CODE_PAR_INVALID_ENUM_OPTION:
|
|
||||||
return "Invalid option %s: %" PRId64 ", only %d, %d allowed";
|
|
||||||
case TSDB_CODE_PAR_INVALID_KEEP_NUM:
|
|
||||||
return "Invalid number of keep options";
|
|
||||||
case TSDB_CODE_PAR_INVALID_KEEP_ORDER:
|
|
||||||
return "Invalid keep value, should be keep0 <= keep1 <= keep2";
|
|
||||||
case TSDB_CODE_PAR_INVALID_KEEP_VALUE:
|
|
||||||
return "Invalid option keep: %" PRId64 ", %" PRId64 ", %" PRId64 " valid range: [%dm, %dm]";
|
|
||||||
case TSDB_CODE_PAR_INVALID_COMMENT_OPTION:
|
|
||||||
return "Invalid option comment, length cannot exceed %d";
|
|
||||||
case TSDB_CODE_PAR_INVALID_F_RANGE_OPTION:
|
|
||||||
return "Invalid option %s: %f valid range: [%d, %d]";
|
|
||||||
case TSDB_CODE_PAR_INVALID_ROLLUP_OPTION:
|
|
||||||
return "Invalid option rollup: only one function is allowed";
|
|
||||||
case TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION:
|
|
||||||
return "Invalid option retentions";
|
|
||||||
case TSDB_CODE_PAR_GROUPBY_WINDOW_COEXIST:
|
case TSDB_CODE_PAR_GROUPBY_WINDOW_COEXIST:
|
||||||
return "GROUP BY and WINDOW-clause can't be used together";
|
return "GROUP BY and WINDOW-clause can't be used together";
|
||||||
case TSDB_CODE_PAR_INVALID_OPTION_UNIT:
|
|
||||||
return "Invalid option %s unit: %c, only %c, %c, %c allowed";
|
|
||||||
case TSDB_CODE_PAR_INVALID_KEEP_UNIT:
|
|
||||||
return "Invalid option keep unit: %c, only m, h, d allowed";
|
|
||||||
case TSDB_CODE_PAR_AGG_FUNC_NESTING:
|
case TSDB_CODE_PAR_AGG_FUNC_NESTING:
|
||||||
return "Aggregate functions do not support nesting";
|
return "Aggregate functions do not support nesting";
|
||||||
case TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE:
|
case TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE:
|
||||||
|
@ -194,8 +170,6 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
||||||
return "%s function is not supported in stream query";
|
return "%s function is not supported in stream query";
|
||||||
case TSDB_CODE_PAR_GROUP_BY_NOT_ALLOWED_FUNC:
|
case TSDB_CODE_PAR_GROUP_BY_NOT_ALLOWED_FUNC:
|
||||||
return "%s function is not supported in group query";
|
return "%s function is not supported in group query";
|
||||||
case TSDB_CODE_PAR_INVALID_TABLE_OPTION:
|
|
||||||
return "Invalid option %s";
|
|
||||||
case TSDB_CODE_PAR_INVALID_INTERP_CLAUSE:
|
case TSDB_CODE_PAR_INVALID_INTERP_CLAUSE:
|
||||||
return "Invalid usage of RANGE clause, EVERY clause or FILL clause";
|
return "Invalid usage of RANGE clause, EVERY clause or FILL clause";
|
||||||
case TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN:
|
case TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN:
|
||||||
|
@ -389,7 +363,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, voi
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
STagVal val = {0};
|
STagVal val = {0};
|
||||||
// strcpy(val.colName, colName);
|
// strcpy(val.colName, colName);
|
||||||
val.pKey = jsonKey;
|
val.pKey = jsonKey;
|
||||||
taosHashPut(keyHash, jsonKey, keyLen, &keyLen,
|
taosHashPut(keyHash, jsonKey, keyLen, &keyLen,
|
||||||
CHAR_BYTES); // add key to hash to remove dumplicate, value is useless
|
CHAR_BYTES); // add key to hash to remove dumplicate, value is useless
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -328,46 +328,6 @@ void initMetaDataEnv() {
|
||||||
stub.set(catalogGetTableIndex, __catalogGetTableIndex);
|
stub.set(catalogGetTableIndex, __catalogGetTableIndex);
|
||||||
stub.set(catalogGetDnodeList, __catalogGetDnodeList);
|
stub.set(catalogGetDnodeList, __catalogGetDnodeList);
|
||||||
stub.set(catalogRefreshGetTableCfg, __catalogRefreshGetTableCfg);
|
stub.set(catalogRefreshGetTableCfg, __catalogRefreshGetTableCfg);
|
||||||
// {
|
|
||||||
// AddrAny any("libcatalog.so");
|
|
||||||
// std::map<std::string,void*> result;
|
|
||||||
// any.get_global_func_addr_dynsym("^catalogGetHandle$", result);
|
|
||||||
// for (const auto& f : result) {
|
|
||||||
// stub.set(f.second, __catalogGetHandle);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// {
|
|
||||||
// AddrAny any("libcatalog.so");
|
|
||||||
// std::map<std::string,void*> result;
|
|
||||||
// any.get_global_func_addr_dynsym("^catalogGetTableMeta$", result);
|
|
||||||
// for (const auto& f : result) {
|
|
||||||
// stub.set(f.second, __catalogGetTableMeta);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// {
|
|
||||||
// AddrAny any("libcatalog.so");
|
|
||||||
// std::map<std::string,void*> result;
|
|
||||||
// any.get_global_func_addr_dynsym("^catalogGetTableHashVgroup$", result);
|
|
||||||
// for (const auto& f : result) {
|
|
||||||
// stub.set(f.second, __catalogGetTableHashVgroup);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// {
|
|
||||||
// AddrAny any("libcatalog.so");
|
|
||||||
// std::map<std::string,void*> result;
|
|
||||||
// any.get_global_func_addr_dynsym("^catalogGetTableDistVgInfo$", result);
|
|
||||||
// for (const auto& f : result) {
|
|
||||||
// stub.set(f.second, __catalogGetTableDistVgInfo);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// {
|
|
||||||
// AddrAny any("libcatalog.so");
|
|
||||||
// std::map<std::string,void*> result;
|
|
||||||
// any.get_global_func_addr_dynsym("^catalogGetDBVgVersion$", result);
|
|
||||||
// for (const auto& f : result) {
|
|
||||||
// stub.set(f.second, __catalogGetDBVgVersion);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void generateMetaData() {
|
void generateMetaData() {
|
||||||
|
|
|
@ -27,22 +27,217 @@ TEST_F(ParserInitialATest, alterAccount) {
|
||||||
run("ALTER ACCOUNT ac_wxy PASS '123456'", TSDB_CODE_PAR_EXPRIE_STATEMENT, PARSER_STAGE_PARSE);
|
run("ALTER ACCOUNT ac_wxy PASS '123456'", TSDB_CODE_PAR_EXPRIE_STATEMENT, PARSER_STAGE_PARSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ALTER DNODE dnode_id 'config' ['value']
|
||||||
|
* ALTER ALL DNODES 'config' ['value']
|
||||||
|
*/
|
||||||
TEST_F(ParserInitialATest, alterDnode) {
|
TEST_F(ParserInitialATest, alterDnode) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("ALTER DNODE 1 'resetLog'");
|
SMCfgDnodeReq expect = {0};
|
||||||
|
|
||||||
run("ALTER DNODE 1 'debugFlag' '134'");
|
auto clearCfgDnodeReq = [&]() { memset(&expect, 0, sizeof(SMCfgDnodeReq)); };
|
||||||
|
|
||||||
|
auto setCfgDnodeReq = [&](int32_t dnodeId, const char* pConfig, const char* pValue = nullptr) {
|
||||||
|
expect.dnodeId = dnodeId;
|
||||||
|
strcpy(expect.config, pConfig);
|
||||||
|
if (nullptr != pValue) {
|
||||||
|
strcpy(expect.value, pValue);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
||||||
|
ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_ALTER_DNODE_STMT);
|
||||||
|
SMCfgDnodeReq req = {0};
|
||||||
|
ASSERT_EQ(tDeserializeSMCfgDnodeReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req), TSDB_CODE_SUCCESS);
|
||||||
|
ASSERT_EQ(req.dnodeId, expect.dnodeId);
|
||||||
|
ASSERT_EQ(std::string(req.config), std::string(expect.config));
|
||||||
|
ASSERT_EQ(std::string(req.value), std::string(expect.value));
|
||||||
|
});
|
||||||
|
|
||||||
|
setCfgDnodeReq(1, "resetLog");
|
||||||
|
run("ALTER DNODE 1 'resetLog'");
|
||||||
|
clearCfgDnodeReq();
|
||||||
|
|
||||||
|
setCfgDnodeReq(2, "debugFlag", "134");
|
||||||
|
run("ALTER DNODE 2 'debugFlag' '134'");
|
||||||
|
clearCfgDnodeReq();
|
||||||
|
|
||||||
|
setCfgDnodeReq(-1, "resetQueryCache");
|
||||||
|
run("ALTER ALL DNODES 'resetQueryCache'");
|
||||||
|
clearCfgDnodeReq();
|
||||||
|
|
||||||
|
setCfgDnodeReq(-1, "qDebugflag", "135");
|
||||||
|
run("ALTER ALL DNODES 'qDebugflag' '135'");
|
||||||
|
clearCfgDnodeReq();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ALTER DATABASE db_name [alter_database_options]
|
||||||
|
*
|
||||||
|
* alter_database_options:
|
||||||
|
* alter_database_option ...
|
||||||
|
*
|
||||||
|
* alter_database_option: {
|
||||||
|
* BUFFER int_value -- todo: range [3, 16384], default 96, unit MB
|
||||||
|
* | CACHEMODEL {'none' | 'last_row' | 'last_value' | 'both'} -- default 'none'
|
||||||
|
* | CACHESIZE int_value -- range [1, 65536], default 1, unit MB
|
||||||
|
* | FSYNC int_value -- rang [0, 180000], default 3000, unit ms
|
||||||
|
* | KEEP {int_value | duration_value} -- rang [1, 365000], default 3650, unit day
|
||||||
|
* | PAGES int_value -- todo: rang [64, +oo), default 256, unit page
|
||||||
|
* | REPLICA int_value -- todo: enum 1, 3, default 1, unit replica
|
||||||
|
* | STRICT {'off' | 'on'} -- todo: default 'off'
|
||||||
|
* | WAL int_value -- enum 1, 2, default 1
|
||||||
|
* }
|
||||||
|
*/
|
||||||
TEST_F(ParserInitialATest, alterDatabase) {
|
TEST_F(ParserInitialATest, alterDatabase) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("ALTER DATABASE test CACHEMODEL 'last_row' FSYNC 200 WAL 1");
|
SAlterDbReq expect = {0};
|
||||||
|
|
||||||
run("ALTER DATABASE test KEEP 2400");
|
auto clearAlterDbReq = [&]() { memset(&expect, 0, sizeof(SAlterDbReq)); };
|
||||||
|
|
||||||
|
auto initAlterDb = [&](const char* pDb) {
|
||||||
|
snprintf(expect.db, sizeof(expect.db), "0.%s", pDb);
|
||||||
|
expect.buffer = -1;
|
||||||
|
expect.pageSize = -1;
|
||||||
|
expect.pages = -1;
|
||||||
|
expect.daysPerFile = -1;
|
||||||
|
expect.daysToKeep0 = -1;
|
||||||
|
expect.daysToKeep1 = -1;
|
||||||
|
expect.daysToKeep2 = -1;
|
||||||
|
expect.fsyncPeriod = -1;
|
||||||
|
expect.walLevel = -1;
|
||||||
|
expect.strict = -1;
|
||||||
|
expect.cacheLast = -1;
|
||||||
|
expect.cacheLastSize = -1;
|
||||||
|
expect.replications = -1;
|
||||||
|
};
|
||||||
|
auto setAlterDbBuffer = [&](int32_t buffer) { expect.buffer = buffer; };
|
||||||
|
auto setAlterDbPageSize = [&](int32_t pageSize) { expect.pageSize = pageSize; };
|
||||||
|
auto setAlterDbPages = [&](int32_t pages) { expect.pages = pages; };
|
||||||
|
auto setAlterDbCacheSize = [&](int32_t cacheSize) { expect.cacheLastSize = cacheSize; };
|
||||||
|
auto setAlterDbDuration = [&](int32_t duration) { expect.daysPerFile = duration; };
|
||||||
|
auto setAlterDbKeep = [&](int32_t daysToKeep0, int32_t daysToKeep1 = -1, int32_t daysToKeep2 = -1) {
|
||||||
|
expect.daysToKeep0 = daysToKeep0;
|
||||||
|
expect.daysToKeep1 = (-1 == daysToKeep1 ? expect.daysToKeep0 : daysToKeep1);
|
||||||
|
expect.daysToKeep2 = (-1 == daysToKeep1 ? expect.daysToKeep1 : daysToKeep2);
|
||||||
|
};
|
||||||
|
auto setAlterDbFsync = [&](int32_t fsync) { expect.fsyncPeriod = fsync; };
|
||||||
|
auto setAlterDbWal = [&](int8_t wal) { expect.walLevel = wal; };
|
||||||
|
auto setAlterDbStrict = [&](int8_t strict) { expect.strict = strict; };
|
||||||
|
auto setAlterDbCacheModel = [&](int8_t cacheModel) { expect.cacheLast = cacheModel; };
|
||||||
|
auto setAlterDbReplica = [&](int8_t replications) { expect.replications = replications; };
|
||||||
|
|
||||||
|
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
||||||
|
ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_ALTER_DATABASE_STMT);
|
||||||
|
SAlterDbReq req = {0};
|
||||||
|
ASSERT_EQ(tDeserializeSAlterDbReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req), TSDB_CODE_SUCCESS);
|
||||||
|
ASSERT_EQ(std::string(req.db), std::string(expect.db));
|
||||||
|
ASSERT_EQ(req.buffer, expect.buffer);
|
||||||
|
ASSERT_EQ(req.pageSize, expect.pageSize);
|
||||||
|
ASSERT_EQ(req.pages, expect.pages);
|
||||||
|
ASSERT_EQ(req.cacheLastSize, expect.cacheLastSize);
|
||||||
|
ASSERT_EQ(req.daysToKeep0, expect.daysToKeep0);
|
||||||
|
ASSERT_EQ(req.daysToKeep1, expect.daysToKeep1);
|
||||||
|
ASSERT_EQ(req.daysToKeep2, expect.daysToKeep2);
|
||||||
|
ASSERT_EQ(req.fsyncPeriod, expect.fsyncPeriod);
|
||||||
|
ASSERT_EQ(req.walLevel, expect.walLevel);
|
||||||
|
ASSERT_EQ(req.strict, expect.strict);
|
||||||
|
ASSERT_EQ(req.cacheLast, expect.cacheLast);
|
||||||
|
ASSERT_EQ(req.replications, expect.replications);
|
||||||
|
});
|
||||||
|
|
||||||
|
const int32_t MINUTE_PER_DAY = MILLISECOND_PER_DAY / MILLISECOND_PER_MINUTE;
|
||||||
|
const int32_t MINUTE_PER_HOUR = MILLISECOND_PER_HOUR / MILLISECOND_PER_MINUTE;
|
||||||
|
|
||||||
|
initAlterDb("test");
|
||||||
|
setAlterDbCacheSize(32);
|
||||||
|
setAlterDbKeep(10 * MINUTE_PER_DAY);
|
||||||
|
setAlterDbFsync(200);
|
||||||
|
setAlterDbWal(1);
|
||||||
|
setAlterDbCacheModel(TSDB_CACHE_MODEL_LAST_ROW);
|
||||||
|
run("ALTER DATABASE test CACHEMODEL 'last_row' CACHESIZE 32 FSYNC 200 KEEP 10 WAL 1");
|
||||||
|
clearAlterDbReq();
|
||||||
|
|
||||||
|
initAlterDb("test");
|
||||||
|
setAlterDbCacheModel(TSDB_CACHE_MODEL_NONE);
|
||||||
|
run("ALTER DATABASE test CACHEMODEL 'none'");
|
||||||
|
setAlterDbCacheModel(TSDB_CACHE_MODEL_LAST_ROW);
|
||||||
|
run("ALTER DATABASE test CACHEMODEL 'last_row'");
|
||||||
|
setAlterDbCacheModel(TSDB_CACHE_MODEL_LAST_VALUE);
|
||||||
|
run("ALTER DATABASE test CACHEMODEL 'last_value'");
|
||||||
|
setAlterDbCacheModel(TSDB_CACHE_MODEL_BOTH);
|
||||||
|
run("ALTER DATABASE test CACHEMODEL 'both'");
|
||||||
|
clearAlterDbReq();
|
||||||
|
|
||||||
|
initAlterDb("test");
|
||||||
|
setAlterDbCacheSize(1);
|
||||||
|
run("ALTER DATABASE test CACHESIZE 1");
|
||||||
|
setAlterDbCacheSize(64);
|
||||||
|
run("ALTER DATABASE test CACHESIZE 64");
|
||||||
|
setAlterDbCacheSize(65536);
|
||||||
|
run("ALTER DATABASE test CACHESIZE 65536");
|
||||||
|
clearAlterDbReq();
|
||||||
|
|
||||||
|
initAlterDb("test");
|
||||||
|
setAlterDbFsync(0);
|
||||||
|
run("ALTER DATABASE test FSYNC 0");
|
||||||
|
setAlterDbFsync(1000);
|
||||||
|
run("ALTER DATABASE test FSYNC 1000");
|
||||||
|
setAlterDbFsync(180000);
|
||||||
|
run("ALTER DATABASE test FSYNC 180000");
|
||||||
|
clearAlterDbReq();
|
||||||
|
|
||||||
|
initAlterDb("test");
|
||||||
|
setAlterDbKeep(1 * MINUTE_PER_DAY);
|
||||||
|
run("ALTER DATABASE test KEEP 1");
|
||||||
|
setAlterDbKeep(30 * MINUTE_PER_DAY);
|
||||||
|
run("ALTER DATABASE test KEEP 30");
|
||||||
|
setAlterDbKeep(365000 * MINUTE_PER_DAY);
|
||||||
|
run("ALTER DATABASE test KEEP 365000");
|
||||||
|
setAlterDbKeep(1440);
|
||||||
|
run("ALTER DATABASE test KEEP 1440m");
|
||||||
|
setAlterDbKeep(14400);
|
||||||
|
run("ALTER DATABASE test KEEP 14400m");
|
||||||
|
setAlterDbKeep(525600000);
|
||||||
|
run("ALTER DATABASE test KEEP 525600000m");
|
||||||
|
setAlterDbKeep(5 * MINUTE_PER_DAY, 35 * MINUTE_PER_DAY, 500 * MINUTE_PER_DAY);
|
||||||
|
run("ALTER DATABASE test KEEP 5,35,500");
|
||||||
|
setAlterDbKeep(14400, 2400 * MINUTE_PER_HOUR, 1500 * MINUTE_PER_DAY);
|
||||||
|
run("ALTER DATABASE test KEEP 14400m,2400h,1500d");
|
||||||
|
clearAlterDbReq();
|
||||||
|
|
||||||
|
initAlterDb("test");
|
||||||
|
setAlterDbWal(1);
|
||||||
|
run("ALTER DATABASE test WAL 1");
|
||||||
|
setAlterDbWal(2);
|
||||||
|
run("ALTER DATABASE test WAL 2");
|
||||||
|
clearAlterDbReq();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ParserInitialATest, alterDatabaseSemanticCheck) {
|
||||||
|
useDb("root", "test");
|
||||||
|
|
||||||
|
run("ALTER DATABASE test CACHEMODEL 'other'", TSDB_CODE_PAR_INVALID_DB_OPTION);
|
||||||
|
run("ALTER DATABASE test CACHESIZE 0", TSDB_CODE_PAR_INVALID_DB_OPTION);
|
||||||
|
run("ALTER DATABASE test CACHESIZE 65537", TSDB_CODE_PAR_INVALID_DB_OPTION);
|
||||||
|
// The syntax limits it to only positive numbers
|
||||||
|
run("ALTER DATABASE test FSYNC -1", TSDB_CODE_PAR_SYNTAX_ERROR, PARSER_STAGE_PARSE);
|
||||||
|
run("ALTER DATABASE test FSYNC 180001", TSDB_CODE_PAR_INVALID_DB_OPTION);
|
||||||
|
run("ALTER DATABASE test KEEP 0", TSDB_CODE_PAR_INVALID_DB_OPTION);
|
||||||
|
run("ALTER DATABASE test KEEP 365001", TSDB_CODE_PAR_INVALID_DB_OPTION);
|
||||||
|
run("ALTER DATABASE test KEEP 1000000000s", TSDB_CODE_PAR_INVALID_DB_OPTION);
|
||||||
|
run("ALTER DATABASE test KEEP 1w", TSDB_CODE_PAR_INVALID_DB_OPTION);
|
||||||
|
run("ALTER DATABASE test WAL 0", TSDB_CODE_PAR_INVALID_DB_OPTION);
|
||||||
|
run("ALTER DATABASE test WAL 3", TSDB_CODE_PAR_INVALID_DB_OPTION);
|
||||||
|
// Regardless of the specific sentence
|
||||||
|
run("ALTER DATABASE db WAL 0 # td-14436", TSDB_CODE_PAR_SYNTAX_ERROR, PARSER_STAGE_PARSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ALTER LOCAL dnode_id 'config' ['value']
|
||||||
|
*/
|
||||||
TEST_F(ParserInitialATest, alterLocal) {
|
TEST_F(ParserInitialATest, alterLocal) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
|
@ -53,7 +248,7 @@ TEST_F(ParserInitialATest, alterLocal) {
|
||||||
expect.second.clear();
|
expect.second.clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
auto setAlterLocalFunc = [&](const char* pConfig, const char* pValue = nullptr) {
|
auto setAlterLocal = [&](const char* pConfig, const char* pValue = nullptr) {
|
||||||
expect.first.assign(pConfig);
|
expect.first.assign(pConfig);
|
||||||
if (nullptr != pValue) {
|
if (nullptr != pValue) {
|
||||||
expect.second.assign(pValue);
|
expect.second.assign(pValue);
|
||||||
|
@ -68,38 +263,37 @@ TEST_F(ParserInitialATest, alterLocal) {
|
||||||
ASSERT_EQ(string(pStmt->value), expect.second);
|
ASSERT_EQ(string(pStmt->value), expect.second);
|
||||||
});
|
});
|
||||||
|
|
||||||
setAlterLocalFunc("resetlog");
|
setAlterLocal("resetlog");
|
||||||
run("ALTER LOCAL 'resetlog'");
|
run("ALTER LOCAL 'resetlog'");
|
||||||
clearAlterLocal();
|
clearAlterLocal();
|
||||||
|
|
||||||
setAlterLocalFunc("querypolicy", "2");
|
setAlterLocal("querypolicy", "2");
|
||||||
run("ALTER LOCAL 'querypolicy' '2'");
|
run("ALTER LOCAL 'querypolicy' '2'");
|
||||||
clearAlterLocal();
|
clearAlterLocal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ALTER TABLE [db_name.]tb_name alter_table_clause
|
* ALTER STABLE [db_name.]tb_name alter_table_clause
|
||||||
*
|
*
|
||||||
* alter_table_clause: {
|
* alter_table_clause: {
|
||||||
* alter_table_options
|
* alter_table_options
|
||||||
* | ADD COLUMN col_name column_type
|
* | ADD COLUMN col_name column_type
|
||||||
* | DROP COLUMN col_name
|
* | DROP COLUMN col_name
|
||||||
* | MODIFY COLUMN col_name column_type
|
* | MODIFY COLUMN col_name column_type
|
||||||
* | RENAME COLUMN old_col_name new_col_name
|
* | RENAME COLUMN old_col_name new_col_name -- normal table
|
||||||
* | ADD TAG tag_name tag_type
|
* | ADD TAG tag_name tag_type -- super table
|
||||||
* | DROP TAG tag_name
|
* | DROP TAG tag_name -- super table
|
||||||
* | MODIFY TAG tag_name tag_type
|
* | MODIFY TAG tag_name tag_type -- super table
|
||||||
* | RENAME TAG old_tag_name new_tag_name
|
* | RENAME TAG old_tag_name new_tag_name -- super table
|
||||||
* | SET TAG tag_name = new_tag_value
|
* | SET TAG tag_name = new_tag_value -- child table
|
||||||
* | ADD {FULLTEXT | SMA} INDEX index_name (col_name [, col_name] ...) [index_option]
|
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* alter_table_options:
|
* alter_table_options:
|
||||||
* alter_table_option ...
|
* alter_table_option ...
|
||||||
*
|
*
|
||||||
* alter_table_option: {
|
* alter_table_option: {
|
||||||
* TTL value
|
* TTL int_value -- child/normal table
|
||||||
* | COMMENT 'string_value'
|
* | COMMENT 'string_value'
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
TEST_F(ParserInitialATest, alterSTable) {
|
TEST_F(ParserInitialATest, alterSTable) {
|
||||||
|
@ -112,14 +306,12 @@ TEST_F(ParserInitialATest, alterSTable) {
|
||||||
memset(&expect, 0, sizeof(SMAlterStbReq));
|
memset(&expect, 0, sizeof(SMAlterStbReq));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto setAlterStbReqFunc = [&](const char* pTbname, int8_t alterType, int32_t numOfFields = 0,
|
auto setAlterStbReq = [&](const char* pTbname, int8_t alterType, int32_t numOfFields = 0,
|
||||||
const char* pField1Name = nullptr, int8_t field1Type = 0, int32_t field1Bytes = 0,
|
const char* pField1Name = nullptr, int8_t field1Type = 0, int32_t field1Bytes = 0,
|
||||||
const char* pField2Name = nullptr, const char* pComment = nullptr,
|
const char* pField2Name = nullptr, const char* pComment = nullptr) {
|
||||||
int32_t ttl = TSDB_DEFAULT_TABLE_TTL) {
|
|
||||||
int32_t len = snprintf(expect.name, sizeof(expect.name), "0.test.%s", pTbname);
|
int32_t len = snprintf(expect.name, sizeof(expect.name), "0.test.%s", pTbname);
|
||||||
expect.name[len] = '\0';
|
expect.name[len] = '\0';
|
||||||
expect.alterType = alterType;
|
expect.alterType = alterType;
|
||||||
// expect.ttl = ttl;
|
|
||||||
if (nullptr != pComment) {
|
if (nullptr != pComment) {
|
||||||
expect.comment = strdup(pComment);
|
expect.comment = strdup(pComment);
|
||||||
expect.commentLen = strlen(pComment);
|
expect.commentLen = strlen(pComment);
|
||||||
|
@ -178,59 +370,47 @@ TEST_F(ParserInitialATest, alterSTable) {
|
||||||
tFreeSMAltertbReq(&req);
|
tFreeSMAltertbReq(&req);
|
||||||
});
|
});
|
||||||
|
|
||||||
// setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_OPTIONS, 0, nullptr, 0, 0, nullptr, nullptr, 10);
|
setAlterStbReq("st1", TSDB_ALTER_TABLE_UPDATE_OPTIONS, 0, nullptr, 0, 0, nullptr, "test");
|
||||||
// run("ALTER STABLE st1 TTL 10");
|
|
||||||
// clearAlterStbReq();
|
|
||||||
|
|
||||||
setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_OPTIONS, 0, nullptr, 0, 0, nullptr, "test");
|
|
||||||
run("ALTER STABLE st1 COMMENT 'test'");
|
run("ALTER STABLE st1 COMMENT 'test'");
|
||||||
clearAlterStbReq();
|
clearAlterStbReq();
|
||||||
|
|
||||||
setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_ADD_COLUMN, 1, "cc1", TSDB_DATA_TYPE_BIGINT);
|
setAlterStbReq("st1", TSDB_ALTER_TABLE_ADD_COLUMN, 1, "cc1", TSDB_DATA_TYPE_BIGINT);
|
||||||
run("ALTER STABLE st1 ADD COLUMN cc1 BIGINT");
|
run("ALTER STABLE st1 ADD COLUMN cc1 BIGINT");
|
||||||
clearAlterStbReq();
|
clearAlterStbReq();
|
||||||
|
|
||||||
setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_DROP_COLUMN, 1, "c1");
|
setAlterStbReq("st1", TSDB_ALTER_TABLE_DROP_COLUMN, 1, "c1");
|
||||||
run("ALTER STABLE st1 DROP COLUMN c1");
|
run("ALTER STABLE st1 DROP COLUMN c1");
|
||||||
clearAlterStbReq();
|
clearAlterStbReq();
|
||||||
|
|
||||||
setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, 1, "c2", TSDB_DATA_TYPE_VARCHAR,
|
setAlterStbReq("st1", TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, 1, "c2", TSDB_DATA_TYPE_VARCHAR, 30 + VARSTR_HEADER_SIZE);
|
||||||
30 + VARSTR_HEADER_SIZE);
|
|
||||||
run("ALTER STABLE st1 MODIFY COLUMN c2 VARCHAR(30)");
|
run("ALTER STABLE st1 MODIFY COLUMN c2 VARCHAR(30)");
|
||||||
clearAlterStbReq();
|
clearAlterStbReq();
|
||||||
|
|
||||||
// setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, 2, "c1", 0, 0, "cc1");
|
setAlterStbReq("st1", TSDB_ALTER_TABLE_ADD_TAG, 1, "tag11", TSDB_DATA_TYPE_BIGINT);
|
||||||
// run("ALTER STABLE st1 RENAME COLUMN c1 cc1");
|
|
||||||
|
|
||||||
setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_ADD_TAG, 1, "tag11", TSDB_DATA_TYPE_BIGINT);
|
|
||||||
run("ALTER STABLE st1 ADD TAG tag11 BIGINT");
|
run("ALTER STABLE st1 ADD TAG tag11 BIGINT");
|
||||||
clearAlterStbReq();
|
clearAlterStbReq();
|
||||||
|
|
||||||
setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_DROP_TAG, 1, "tag1");
|
setAlterStbReq("st1", TSDB_ALTER_TABLE_DROP_TAG, 1, "tag1");
|
||||||
run("ALTER STABLE st1 DROP TAG tag1");
|
run("ALTER STABLE st1 DROP TAG tag1");
|
||||||
clearAlterStbReq();
|
clearAlterStbReq();
|
||||||
|
|
||||||
setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, 1, "tag2", TSDB_DATA_TYPE_VARCHAR,
|
setAlterStbReq("st1", TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, 1, "tag2", TSDB_DATA_TYPE_VARCHAR, 30 + VARSTR_HEADER_SIZE);
|
||||||
30 + VARSTR_HEADER_SIZE);
|
|
||||||
run("ALTER STABLE st1 MODIFY TAG tag2 VARCHAR(30)");
|
run("ALTER STABLE st1 MODIFY TAG tag2 VARCHAR(30)");
|
||||||
clearAlterStbReq();
|
clearAlterStbReq();
|
||||||
|
|
||||||
setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_TAG_NAME, 2, "tag1", 0, 0, "tag11");
|
setAlterStbReq("st1", TSDB_ALTER_TABLE_UPDATE_TAG_NAME, 2, "tag1", 0, 0, "tag11");
|
||||||
run("ALTER STABLE st1 RENAME TAG tag1 tag11");
|
run("ALTER STABLE st1 RENAME TAG tag1 tag11");
|
||||||
clearAlterStbReq();
|
clearAlterStbReq();
|
||||||
|
|
||||||
// todo
|
|
||||||
// ADD {FULLTEXT | SMA} INDEX index_name (col_name [, col_name] ...) [index_option]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialATest, alterSTableSemanticCheck) {
|
TEST_F(ParserInitialATest, alterSTableSemanticCheck) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("ALTER STABLE st1 RENAME COLUMN c1 cc1", TSDB_CODE_PAR_INVALID_ALTER_TABLE);
|
run("ALTER STABLE st1 RENAME COLUMN c1 cc1", TSDB_CODE_PAR_INVALID_ALTER_TABLE);
|
||||||
|
|
||||||
run("ALTER STABLE st1 MODIFY COLUMN c2 NCHAR(10)", TSDB_CODE_PAR_INVALID_MODIFY_COL);
|
run("ALTER STABLE st1 MODIFY COLUMN c2 NCHAR(10)", TSDB_CODE_PAR_INVALID_MODIFY_COL);
|
||||||
|
|
||||||
run("ALTER STABLE st1 MODIFY TAG tag2 NCHAR(10)", TSDB_CODE_PAR_INVALID_MODIFY_COL);
|
run("ALTER STABLE st1 MODIFY TAG tag2 NCHAR(10)", TSDB_CODE_PAR_INVALID_MODIFY_COL);
|
||||||
|
run("ALTER STABLE st1 SET TAG tag1 = 10", TSDB_CODE_PAR_INVALID_ALTER_TABLE);
|
||||||
|
run("ALTER STABLE st1 TTL 10", TSDB_CODE_PAR_INVALID_ALTER_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialATest, alterTable) {
|
TEST_F(ParserInitialATest, alterTable) {
|
||||||
|
@ -246,8 +426,8 @@ TEST_F(ParserInitialATest, alterTable) {
|
||||||
memset(&expect, 0, sizeof(SVAlterTbReq));
|
memset(&expect, 0, sizeof(SVAlterTbReq));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto setAlterColFunc = [&](const char* pTbname, int8_t alterType, const char* pColName, int8_t dataType = 0,
|
auto setAlterTableCol = [&](const char* pTbname, int8_t alterType, const char* pColName, int8_t dataType = 0,
|
||||||
int32_t dataBytes = 0, const char* pNewColName = nullptr) {
|
int32_t dataBytes = 0, const char* pNewColName = nullptr) {
|
||||||
expect.tbName = strdup(pTbname);
|
expect.tbName = strdup(pTbname);
|
||||||
expect.action = alterType;
|
expect.action = alterType;
|
||||||
expect.colName = strdup(pColName);
|
expect.colName = strdup(pColName);
|
||||||
|
@ -269,7 +449,7 @@ TEST_F(ParserInitialATest, alterTable) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
auto setAlterTagFunc = [&](const char* pTbname, const char* pTagName, uint8_t* pNewVal, uint32_t bytes) {
|
auto setAlterTableTag = [&](const char* pTbname, const char* pTagName, uint8_t* pNewVal, uint32_t bytes) {
|
||||||
expect.tbName = strdup(pTbname);
|
expect.tbName = strdup(pTbname);
|
||||||
expect.action = TSDB_ALTER_TABLE_UPDATE_TAG_VAL;
|
expect.action = TSDB_ALTER_TABLE_UPDATE_TAG_VAL;
|
||||||
expect.tagName = strdup(pTagName);
|
expect.tagName = strdup(pTagName);
|
||||||
|
@ -279,7 +459,7 @@ TEST_F(ParserInitialATest, alterTable) {
|
||||||
expect.pTagVal = pNewVal;
|
expect.pTagVal = pNewVal;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto setAlterOptionsFunc = [&](const char* pTbname, int32_t ttl, char* pComment = nullptr) {
|
auto setAlterTableOptions = [&](const char* pTbname, int32_t ttl, char* pComment = nullptr) {
|
||||||
expect.tbName = strdup(pTbname);
|
expect.tbName = strdup(pTbname);
|
||||||
expect.action = TSDB_ALTER_TABLE_UPDATE_OPTIONS;
|
expect.action = TSDB_ALTER_TABLE_UPDATE_OPTIONS;
|
||||||
if (-1 != ttl) {
|
if (-1 != ttl) {
|
||||||
|
@ -335,47 +515,56 @@ TEST_F(ParserInitialATest, alterTable) {
|
||||||
tDecoderClear(&coder);
|
tDecoderClear(&coder);
|
||||||
});
|
});
|
||||||
|
|
||||||
setAlterOptionsFunc("t1", 10, nullptr);
|
setAlterTableOptions("t1", 10, nullptr);
|
||||||
run("ALTER TABLE t1 TTL 10");
|
run("ALTER TABLE t1 TTL 10");
|
||||||
clearAlterTbReq();
|
clearAlterTbReq();
|
||||||
|
|
||||||
setAlterOptionsFunc("t1", -1, (char*)"test");
|
setAlterTableOptions("t1", -1, (char*)"test");
|
||||||
run("ALTER TABLE t1 COMMENT 'test'");
|
run("ALTER TABLE t1 COMMENT 'test'");
|
||||||
clearAlterTbReq();
|
clearAlterTbReq();
|
||||||
|
|
||||||
setAlterColFunc("t1", TSDB_ALTER_TABLE_ADD_COLUMN, "cc1", TSDB_DATA_TYPE_BIGINT);
|
setAlterTableCol("t1", TSDB_ALTER_TABLE_ADD_COLUMN, "cc1", TSDB_DATA_TYPE_BIGINT);
|
||||||
run("ALTER TABLE t1 ADD COLUMN cc1 BIGINT");
|
run("ALTER TABLE t1 ADD COLUMN cc1 BIGINT");
|
||||||
clearAlterTbReq();
|
clearAlterTbReq();
|
||||||
|
|
||||||
setAlterColFunc("t1", TSDB_ALTER_TABLE_DROP_COLUMN, "c1");
|
setAlterTableCol("t1", TSDB_ALTER_TABLE_DROP_COLUMN, "c1");
|
||||||
run("ALTER TABLE t1 DROP COLUMN c1");
|
run("ALTER TABLE t1 DROP COLUMN c1");
|
||||||
clearAlterTbReq();
|
clearAlterTbReq();
|
||||||
|
|
||||||
setAlterColFunc("t1", TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, "c2", TSDB_DATA_TYPE_VARCHAR, 30 + VARSTR_HEADER_SIZE);
|
setAlterTableCol("t1", TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, "c2", TSDB_DATA_TYPE_VARCHAR, 30 + VARSTR_HEADER_SIZE);
|
||||||
run("ALTER TABLE t1 MODIFY COLUMN c2 VARCHAR(30)");
|
run("ALTER TABLE t1 MODIFY COLUMN c2 VARCHAR(30)");
|
||||||
clearAlterTbReq();
|
clearAlterTbReq();
|
||||||
|
|
||||||
setAlterColFunc("t1", TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, "c1", 0, 0, "cc1");
|
setAlterTableCol("t1", TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, "c1", 0, 0, "cc1");
|
||||||
run("ALTER TABLE t1 RENAME COLUMN c1 cc1");
|
run("ALTER TABLE t1 RENAME COLUMN c1 cc1");
|
||||||
clearAlterTbReq();
|
clearAlterTbReq();
|
||||||
|
|
||||||
int32_t val = 10;
|
int32_t val = 10;
|
||||||
setAlterTagFunc("st1s1", "tag1", (uint8_t*)&val, sizeof(val));
|
setAlterTableTag("st1s1", "tag1", (uint8_t*)&val, sizeof(val));
|
||||||
run("ALTER TABLE st1s1 SET TAG tag1=10");
|
run("ALTER TABLE st1s1 SET TAG tag1=10");
|
||||||
clearAlterTbReq();
|
clearAlterTbReq();
|
||||||
|
|
||||||
// todo
|
|
||||||
// ADD {FULLTEXT | SMA} INDEX index_name (col_name [, col_name] ...) [index_option]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialATest, alterTableSemanticCheck) {
|
TEST_F(ParserInitialATest, alterTableSemanticCheck) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("ALTER TABLE st1s1 RENAME COLUMN c1 cc1", TSDB_CODE_PAR_INVALID_ALTER_TABLE);
|
run("ALTER TABLE st1s1 RENAME COLUMN c1 cc1", TSDB_CODE_PAR_INVALID_ALTER_TABLE);
|
||||||
|
run("ALTER TABLE st1s1 ADD TAG tag11 BIGINT", TSDB_CODE_PAR_INVALID_ALTER_TABLE);
|
||||||
|
run("ALTER TABLE st1s1 DROP TAG tag1", TSDB_CODE_PAR_INVALID_ALTER_TABLE);
|
||||||
|
run("ALTER TABLE st1s1 MODIFY TAG tag2 VARCHAR(30)", TSDB_CODE_PAR_INVALID_ALTER_TABLE);
|
||||||
|
run("ALTER TABLE st1s1 RENAME TAG tag1 tag11", TSDB_CODE_PAR_INVALID_ALTER_TABLE);
|
||||||
run("ALTER TABLE st1s1 SET TAG tag2 = '123456789012345678901'", TSDB_CODE_PAR_WRONG_VALUE_TYPE);
|
run("ALTER TABLE st1s1 SET TAG tag2 = '123456789012345678901'", TSDB_CODE_PAR_WRONG_VALUE_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ALTER USER user_name PASS str_value
|
||||||
|
*
|
||||||
|
* alter_user_clause: {
|
||||||
|
* PASS str_value
|
||||||
|
* | ENABLE int_value
|
||||||
|
* | SYSINFO int_value
|
||||||
|
* }
|
||||||
|
*/
|
||||||
TEST_F(ParserInitialATest, alterUser) {
|
TEST_F(ParserInitialATest, alterUser) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
|
@ -423,6 +612,9 @@ TEST_F(ParserInitialATest, alterUser) {
|
||||||
clearAlterUserReq();
|
clearAlterUserReq();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* BALANCE VGROUP
|
||||||
|
*/
|
||||||
TEST_F(ParserInitialATest, balanceVgroup) {
|
TEST_F(ParserInitialATest, balanceVgroup) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
|
@ -436,10 +628,4 @@ TEST_F(ParserInitialATest, balanceVgroup) {
|
||||||
run("BALANCE VGROUP");
|
run("BALANCE VGROUP");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialATest, bug001) {
|
|
||||||
useDb("root", "test");
|
|
||||||
|
|
||||||
run("ALTER DATABASE db WAL 0 # td-14436", TSDB_CODE_PAR_SYNTAX_ERROR, PARSER_STAGE_PARSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ParserTest
|
} // namespace ParserTest
|
|
@ -236,12 +236,12 @@ TEST_F(ParserInitialCTest, createDatabase) {
|
||||||
TEST_F(ParserInitialCTest, createDatabaseSemanticCheck) {
|
TEST_F(ParserInitialCTest, createDatabaseSemanticCheck) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("create database db2 retentions 0s:1d", TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION);
|
run("create database db2 retentions 0s:1d", TSDB_CODE_PAR_INVALID_DB_OPTION);
|
||||||
run("create database db2 retentions 10s:0d", TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION);
|
run("create database db2 retentions 10s:0d", TSDB_CODE_PAR_INVALID_DB_OPTION);
|
||||||
run("create database db2 retentions 1w:1d", TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION);
|
run("create database db2 retentions 1w:1d", TSDB_CODE_PAR_INVALID_DB_OPTION);
|
||||||
run("create database db2 retentions 1w:1n", TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION);
|
run("create database db2 retentions 1w:1n", TSDB_CODE_PAR_INVALID_DB_OPTION);
|
||||||
run("create database db2 retentions 15s:7d,15m:21d,10m:500d", TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION);
|
run("create database db2 retentions 15s:7d,15m:21d,10m:500d", TSDB_CODE_PAR_INVALID_DB_OPTION);
|
||||||
run("create database db2 retentions 15s:7d,5m:21d,10m:10d", TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION);
|
run("create database db2 retentions 15s:7d,5m:21d,10m:10d", TSDB_CODE_PAR_INVALID_DB_OPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialCTest, createDnode) {
|
TEST_F(ParserInitialCTest, createDnode) {
|
||||||
|
@ -514,13 +514,13 @@ TEST_F(ParserInitialCTest, createStableSemanticCheck) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("CREATE STABLE rollup_db.stb2 (ts TIMESTAMP, c1 INT) TAGS (tag1 INT) ROLLUP(CEIL)",
|
run("CREATE STABLE rollup_db.stb2 (ts TIMESTAMP, c1 INT) TAGS (tag1 INT) ROLLUP(CEIL)",
|
||||||
TSDB_CODE_PAR_INVALID_ROLLUP_OPTION);
|
TSDB_CODE_PAR_INVALID_TABLE_OPTION);
|
||||||
|
|
||||||
run("CREATE STABLE rollup_db.stb2 (ts TIMESTAMP, c1 INT) TAGS (tag1 INT) ROLLUP(MAX) MAX_DELAY 0s WATERMARK 1m",
|
run("CREATE STABLE rollup_db.stb2 (ts TIMESTAMP, c1 INT) TAGS (tag1 INT) ROLLUP(MAX) MAX_DELAY 0s WATERMARK 1m",
|
||||||
TSDB_CODE_PAR_INVALID_RANGE_OPTION);
|
TSDB_CODE_PAR_INVALID_TABLE_OPTION);
|
||||||
|
|
||||||
run("CREATE STABLE rollup_db.stb2 (ts TIMESTAMP, c1 INT) TAGS (tag1 INT) ROLLUP(MAX) MAX_DELAY 10s WATERMARK 18m",
|
run("CREATE STABLE rollup_db.stb2 (ts TIMESTAMP, c1 INT) TAGS (tag1 INT) ROLLUP(MAX) MAX_DELAY 10s WATERMARK 18m",
|
||||||
TSDB_CODE_PAR_INVALID_RANGE_OPTION);
|
TSDB_CODE_PAR_INVALID_TABLE_OPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialCTest, createStream) {
|
TEST_F(ParserInitialCTest, createStream) {
|
||||||
|
|
|
@ -192,7 +192,7 @@ class ParserTestBaseImpl {
|
||||||
|
|
||||||
void setParseContext(const string& sql, SParseContext* pCxt, bool async = false) {
|
void setParseContext(const string& sql, SParseContext* pCxt, bool async = false) {
|
||||||
stmtEnv_.sql_ = sql;
|
stmtEnv_.sql_ = sql;
|
||||||
transform(stmtEnv_.sql_.begin(), stmtEnv_.sql_.end(), stmtEnv_.sql_.begin(), ::tolower);
|
strtolower((char*)stmtEnv_.sql_.c_str(), sql.c_str());
|
||||||
|
|
||||||
pCxt->acctId = atoi(caseEnv_.acctId_.c_str());
|
pCxt->acctId = atoi(caseEnv_.acctId_.c_str());
|
||||||
pCxt->db = caseEnv_.db_.c_str();
|
pCxt->db = caseEnv_.db_.c_str();
|
||||||
|
|
|
@ -1378,6 +1378,22 @@ static bool planOptNodeListHasCol(SNodeList* pKeys) {
|
||||||
return hasCol;
|
return hasCol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static EDealRes partTagsOptHasTbname(SNode* pNode, void* pContext) {
|
||||||
|
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||||
|
if (COLUMN_TYPE_TBNAME == ((SColumnNode*)pNode)->colType) {
|
||||||
|
*(bool*)pContext = true;
|
||||||
|
return DEAL_RES_END;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool planOptNodeListHasTbname(SNodeList* pKeys) {
|
||||||
|
bool hasCol = false;
|
||||||
|
nodesWalkExprs(pKeys, partTagsOptHasTbname, &hasCol);
|
||||||
|
return hasCol;
|
||||||
|
}
|
||||||
|
|
||||||
static bool partTagsIsOptimizableNode(SLogicNode* pNode) {
|
static bool partTagsIsOptimizableNode(SLogicNode* pNode) {
|
||||||
return ((QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pNode) ||
|
return ((QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pNode) ||
|
||||||
(QUERY_NODE_LOGIC_PLAN_AGG == nodeType(pNode) && NULL != ((SAggLogicNode*)pNode)->pGroupKeys &&
|
(QUERY_NODE_LOGIC_PLAN_AGG == nodeType(pNode) && NULL != ((SAggLogicNode*)pNode)->pGroupKeys &&
|
||||||
|
@ -2129,7 +2145,8 @@ static bool tagScanMayBeOptimized(SLogicNode* pNode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SAggLogicNode* pAgg = (SAggLogicNode*)(pNode->pParent);
|
SAggLogicNode* pAgg = (SAggLogicNode*)(pNode->pParent);
|
||||||
if (NULL == pAgg->pGroupKeys || NULL != pAgg->pAggFuncs || planOptNodeListHasCol(pAgg->pGroupKeys)) {
|
if (NULL == pAgg->pGroupKeys || NULL != pAgg->pAggFuncs ||
|
||||||
|
planOptNodeListHasCol(pAgg->pGroupKeys) || !planOptNodeListHasTbname(pAgg->pGroupKeys)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2143,6 +2160,22 @@ static int32_t tagScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubp
|
||||||
}
|
}
|
||||||
|
|
||||||
pScanNode->scanType = SCAN_TYPE_TAG;
|
pScanNode->scanType = SCAN_TYPE_TAG;
|
||||||
|
SNode* pTarget = NULL;
|
||||||
|
FOREACH(pTarget, pScanNode->node.pTargets) {
|
||||||
|
if (PRIMARYKEY_TIMESTAMP_COL_ID == ((SColumnNode*)(pTarget))->colId) {
|
||||||
|
ERASE_NODE(pScanNode->node.pTargets);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NODES_DESTORY_LIST(pScanNode->pScanCols);
|
||||||
|
|
||||||
|
SLogicNode* pAgg = pScanNode->node.pParent;
|
||||||
|
int32_t code = replaceLogicNode(pLogicSubplan, pAgg, (SLogicNode*)pScanNode);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
NODES_CLEAR_LIST(pAgg->pChildren);
|
||||||
|
}
|
||||||
|
nodesDestroyNode((SNode*)pAgg);
|
||||||
pCxt->optimized = true;
|
pCxt->optimized = true;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,6 +138,16 @@ int32_t taosAsyncExec(__async_exec_fn_t execFn, void* execParam, int32_t* code)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void destroySendMsgInfo(SMsgSendInfo* pMsgBody) {
|
||||||
|
assert(pMsgBody != NULL);
|
||||||
|
taosMemoryFreeClear(pMsgBody->target.dbFName);
|
||||||
|
taosMemoryFreeClear(pMsgBody->msgInfo.pData);
|
||||||
|
if (pMsgBody->paramFreeFp) {
|
||||||
|
(*pMsgBody->paramFreeFp)(pMsgBody->param);
|
||||||
|
}
|
||||||
|
taosMemoryFreeClear(pMsgBody);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t asyncSendMsgToServerExt(void* pTransporter, SEpSet* epSet, int64_t* pTransporterId, const SMsgSendInfo* pInfo,
|
int32_t asyncSendMsgToServerExt(void* pTransporter, SEpSet* epSet, int64_t* pTransporterId, const SMsgSendInfo* pInfo,
|
||||||
bool persistHandle, void* rpcCtx) {
|
bool persistHandle, void* rpcCtx) {
|
||||||
char* pMsg = rpcMallocCont(pInfo->msgInfo.len);
|
char* pMsg = rpcMallocCont(pInfo->msgInfo.len);
|
||||||
|
|
|
@ -150,7 +150,6 @@ typedef struct SQWTaskCtx {
|
||||||
|
|
||||||
void *taskHandle;
|
void *taskHandle;
|
||||||
void *sinkHandle;
|
void *sinkHandle;
|
||||||
SSubplan *plan;
|
|
||||||
STbVerInfo tbInfo;
|
STbVerInfo tbInfo;
|
||||||
} SQWTaskCtx;
|
} SQWTaskCtx;
|
||||||
|
|
||||||
|
|
|
@ -306,11 +306,6 @@ void qwFreeTaskCtx(SQWTaskCtx *ctx) {
|
||||||
dsDestroyDataSinker(ctx->sinkHandle);
|
dsDestroyDataSinker(ctx->sinkHandle);
|
||||||
ctx->sinkHandle = NULL;
|
ctx->sinkHandle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->plan) {
|
|
||||||
nodesDestroyNode((SNode*)ctx->plan);
|
|
||||||
ctx->plan = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwDropTaskCtx(QW_FPARAMS_DEF) {
|
int32_t qwDropTaskCtx(QW_FPARAMS_DEF) {
|
||||||
|
@ -327,7 +322,6 @@ int32_t qwDropTaskCtx(QW_FPARAMS_DEF) {
|
||||||
|
|
||||||
atomic_store_ptr(&ctx->taskHandle, NULL);
|
atomic_store_ptr(&ctx->taskHandle, NULL);
|
||||||
atomic_store_ptr(&ctx->sinkHandle, NULL);
|
atomic_store_ptr(&ctx->sinkHandle, NULL);
|
||||||
atomic_store_ptr(&ctx->plan, NULL);
|
|
||||||
|
|
||||||
QW_SET_EVENT_PROCESSED(ctx, QW_EVENT_DROP);
|
QW_SET_EVENT_PROCESSED(ctx, QW_EVENT_DROP);
|
||||||
|
|
||||||
|
|
|
@ -522,8 +522,6 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, const char* sql) {
|
||||||
QW_ERR_JRET(code);
|
QW_ERR_JRET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->plan = plan;
|
|
||||||
|
|
||||||
code = qCreateExecTask(qwMsg->node, mgmt->nodeId, tId, plan, &pTaskInfo, &sinkHandle, sql, OPTR_EXEC_MODEL_BATCH);
|
code = qCreateExecTask(qwMsg->node, mgmt->nodeId, tId, plan, &pTaskInfo, &sinkHandle, sql, OPTR_EXEC_MODEL_BATCH);
|
||||||
if (code) {
|
if (code) {
|
||||||
QW_TASK_ELOG("qCreateExecTask failed, code:%x - %s", code, tstrerror(code));
|
QW_TASK_ELOG("qCreateExecTask failed, code:%x - %s", code, tstrerror(code));
|
||||||
|
@ -928,8 +926,6 @@ int32_t qwProcessDelete(QW_FPARAMS_DEF, SQWMsg *qwMsg, SDeleteRes *pRes) {
|
||||||
QW_ERR_JRET(code);
|
QW_ERR_JRET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.plan = plan;
|
|
||||||
|
|
||||||
code = qCreateExecTask(qwMsg->node, mgmt->nodeId, tId, plan, &pTaskInfo, &sinkHandle, NULL, OPTR_EXEC_MODEL_BATCH);
|
code = qCreateExecTask(qwMsg->node, mgmt->nodeId, tId, plan, &pTaskInfo, &sinkHandle, NULL, OPTR_EXEC_MODEL_BATCH);
|
||||||
if (code) {
|
if (code) {
|
||||||
QW_TASK_ELOG("qCreateExecTask failed, code:%x - %s", code, tstrerror(code));
|
QW_TASK_ELOG("qCreateExecTask failed, code:%x - %s", code, tstrerror(code));
|
||||||
|
|
|
@ -3682,6 +3682,10 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
|
||||||
if (OP_TYPE_IN != node->opType) {
|
if (OP_TYPE_IN != node->opType) {
|
||||||
SColumnNode *refNode = (SColumnNode *)node->pLeft;
|
SColumnNode *refNode = (SColumnNode *)node->pLeft;
|
||||||
SValueNode *valueNode = (SValueNode *)node->pRight;
|
SValueNode *valueNode = (SValueNode *)node->pRight;
|
||||||
|
if (FILTER_GET_FLAG(stat->info->options, FLT_OPTION_TIMESTAMP)
|
||||||
|
&& TSDB_DATA_TYPE_UBIGINT == valueNode->node.resType.type && valueNode->datum.u <= INT64_MAX) {
|
||||||
|
valueNode->node.resType.type = TSDB_DATA_TYPE_BIGINT;
|
||||||
|
}
|
||||||
int32_t type = vectorGetConvertType(refNode->node.resType.type, valueNode->node.resType.type);
|
int32_t type = vectorGetConvertType(refNode->node.resType.type, valueNode->node.resType.type);
|
||||||
if (0 != type && type != refNode->node.resType.type) {
|
if (0 != type && type != refNode->node.resType.type) {
|
||||||
stat->scalarMode = true;
|
stat->scalarMode = true;
|
||||||
|
|
|
@ -277,7 +277,7 @@ typedef struct SSchJob {
|
||||||
bool fetched;
|
bool fetched;
|
||||||
int32_t resNumOfRows;
|
int32_t resNumOfRows;
|
||||||
SSchResInfo userRes;
|
SSchResInfo userRes;
|
||||||
const char *sql;
|
char *sql;
|
||||||
SQueryProfileSummary summary;
|
SQueryProfileSummary summary;
|
||||||
} SSchJob;
|
} SSchJob;
|
||||||
|
|
||||||
|
@ -461,7 +461,6 @@ int32_t schJobFetchRows(SSchJob *pJob);
|
||||||
int32_t schJobFetchRowsA(SSchJob *pJob);
|
int32_t schJobFetchRowsA(SSchJob *pJob);
|
||||||
int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, void *handle, int32_t execId);
|
int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, void *handle, int32_t execId);
|
||||||
int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId* pEpId, SArray* pStatusList);
|
int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId* pEpId, SArray* pStatusList);
|
||||||
void schFreeSMsgSendInfo(SMsgSendInfo *msgSendInfo);
|
|
||||||
char* schGetOpStr(SCH_OP_TYPE type);
|
char* schGetOpStr(SCH_OP_TYPE type);
|
||||||
int32_t schBeginOperation(SSchJob *pJob, SCH_OP_TYPE type, bool sync);
|
int32_t schBeginOperation(SSchJob *pJob, SCH_OP_TYPE type, bool sync);
|
||||||
int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq);
|
int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq);
|
||||||
|
|
|
@ -675,6 +675,7 @@ void schFreeJobImpl(void *job) {
|
||||||
|
|
||||||
taosMemoryFreeClear(pJob->userRes.execRes);
|
taosMemoryFreeClear(pJob->userRes.execRes);
|
||||||
taosMemoryFreeClear(pJob->fetchRes);
|
taosMemoryFreeClear(pJob->fetchRes);
|
||||||
|
taosMemoryFreeClear(pJob->sql);
|
||||||
taosMemoryFree(pJob);
|
taosMemoryFree(pJob);
|
||||||
|
|
||||||
int32_t jobNum = atomic_sub_fetch_32(&schMgmt.jobNum, 1);
|
int32_t jobNum = atomic_sub_fetch_32(&schMgmt.jobNum, 1);
|
||||||
|
@ -718,7 +719,9 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq) {
|
||||||
|
|
||||||
pJob->attr.explainMode = pReq->pDag->explainInfo.mode;
|
pJob->attr.explainMode = pReq->pDag->explainInfo.mode;
|
||||||
pJob->conn = *pReq->pConn;
|
pJob->conn = *pReq->pConn;
|
||||||
pJob->sql = pReq->sql;
|
if (pReq->sql) {
|
||||||
|
pJob->sql = strdup(pReq->sql);
|
||||||
|
}
|
||||||
pJob->pDag = pReq->pDag;
|
pJob->pDag = pReq->pDag;
|
||||||
pJob->chkKillFp = pReq->chkKillFp;
|
pJob->chkKillFp = pReq->chkKillFp;
|
||||||
pJob->chkKillParam = pReq->chkKillParam;
|
pJob->chkKillParam = pReq->chkKillParam;
|
||||||
|
|
|
@ -386,7 +386,6 @@ int32_t schHandleCallback(void *param, SDataBuf *pMsg, int32_t rspCode) {
|
||||||
schProcessOnCbEnd(pJob, pTask, code);
|
schProcessOnCbEnd(pJob, pTask, code);
|
||||||
|
|
||||||
taosMemoryFreeClear(pMsg->pData);
|
taosMemoryFreeClear(pMsg->pData);
|
||||||
taosMemoryFreeClear(param);
|
|
||||||
|
|
||||||
qDebug("end to handle rsp msg, type:%s, handle:%p, code:%s", TMSG_INFO(pMsg->msgType), pMsg->handle,
|
qDebug("end to handle rsp msg, type:%s, handle:%p, code:%s", TMSG_INFO(pMsg->msgType), pMsg->handle,
|
||||||
tstrerror(rspCode));
|
tstrerror(rspCode));
|
||||||
|
@ -398,7 +397,6 @@ int32_t schHandleDropCallback(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param;
|
SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param;
|
||||||
qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 " drop task rsp received, code:0x%x", pParam->queryId, pParam->taskId,
|
qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 " drop task rsp received, code:0x%x", pParam->queryId, pParam->taskId,
|
||||||
code);
|
code);
|
||||||
taosMemoryFreeClear(param);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,8 +445,8 @@ int32_t schHandleHbCallback(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
SCH_ERR_JRET(schProcessOnTaskStatusRsp(&rsp.epId, rsp.taskStatus));
|
SCH_ERR_JRET(schProcessOnTaskStatusRsp(&rsp.epId, rsp.taskStatus));
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
tFreeSSchedulerHbRsp(&rsp);
|
tFreeSSchedulerHbRsp(&rsp);
|
||||||
taosMemoryFree(param);
|
|
||||||
taosMemoryFree(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
SCH_RET(code);
|
SCH_RET(code);
|
||||||
}
|
}
|
||||||
|
@ -514,7 +512,9 @@ int32_t schGenerateCallBackInfo(SSchJob *pJob, SSchTask *pTask, void *msg, uint3
|
||||||
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
msgSendInfo->paramFreeFp = taosMemoryFree;
|
||||||
SCH_ERR_JRET(schMakeCallbackParam(pJob, pTask, msgType, isHb, trans, &msgSendInfo->param));
|
SCH_ERR_JRET(schMakeCallbackParam(pJob, pTask, msgType, isHb, trans, &msgSendInfo->param));
|
||||||
|
|
||||||
SCH_ERR_JRET(schGetCallbackFp(msgType, &msgSendInfo->fp));
|
SCH_ERR_JRET(schGetCallbackFp(msgType, &msgSendInfo->fp));
|
||||||
|
|
||||||
if (pJob) {
|
if (pJob) {
|
||||||
|
@ -535,7 +535,7 @@ int32_t schGenerateCallBackInfo(SSchJob *pJob, SSchTask *pTask, void *msg, uint3
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
schFreeSMsgSendInfo(msgSendInfo);
|
destroySendMsgInfo(msgSendInfo);
|
||||||
|
|
||||||
SCH_RET(code);
|
SCH_RET(code);
|
||||||
}
|
}
|
||||||
|
@ -676,6 +676,7 @@ int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) {
|
||||||
param->pTrans = pJob->conn.pTrans;
|
param->pTrans = pJob->conn.pTrans;
|
||||||
|
|
||||||
pMsgSendInfo->param = param;
|
pMsgSendInfo->param = param;
|
||||||
|
pMsgSendInfo->paramFreeFp = taosMemoryFree;
|
||||||
pMsgSendInfo->fp = fp;
|
pMsgSendInfo->fp = fp;
|
||||||
|
|
||||||
SRpcCtxVal ctxVal = {.val = pMsgSendInfo, .clone = schCloneSMsgSendInfo};
|
SRpcCtxVal ctxVal = {.val = pMsgSendInfo, .clone = schCloneSMsgSendInfo};
|
||||||
|
@ -795,6 +796,7 @@ int32_t schCloneSMsgSendInfo(void *src, void **dst) {
|
||||||
pDst->param = NULL;
|
pDst->param = NULL;
|
||||||
|
|
||||||
SCH_ERR_JRET(schCloneCallbackParam(pSrc->param, (SSchCallbackParamHeader **)&pDst->param));
|
SCH_ERR_JRET(schCloneCallbackParam(pSrc->param, (SSchCallbackParamHeader **)&pDst->param));
|
||||||
|
pDst->paramFreeFp = taosMemoryFree;
|
||||||
|
|
||||||
*dst = pDst;
|
*dst = pDst;
|
||||||
|
|
||||||
|
@ -861,8 +863,7 @@ _return:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pMsgSendInfo) {
|
if (pMsgSendInfo) {
|
||||||
taosMemoryFreeClear(pMsgSendInfo->param);
|
destroySendMsgInfo(pMsgSendInfo);
|
||||||
taosMemoryFreeClear(pMsgSendInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SCH_RET(code);
|
SCH_RET(code);
|
||||||
|
|
|
@ -50,6 +50,12 @@ char* schGetOpStr(SCH_OP_TYPE type) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void schFreeHbTrans(SSchHbTrans *pTrans) {
|
||||||
|
rpcReleaseHandle(pTrans->trans.pHandle, TAOS_CONN_CLIENT);
|
||||||
|
|
||||||
|
schFreeRpcCtx(&pTrans->rpcCtx);
|
||||||
|
}
|
||||||
|
|
||||||
void schCleanClusterHb(void* pTrans) {
|
void schCleanClusterHb(void* pTrans) {
|
||||||
SCH_LOCK(SCH_WRITE, &schMgmt.hbLock);
|
SCH_LOCK(SCH_WRITE, &schMgmt.hbLock);
|
||||||
|
|
||||||
|
@ -57,7 +63,7 @@ void schCleanClusterHb(void* pTrans) {
|
||||||
while (hb) {
|
while (hb) {
|
||||||
if (hb->trans.pTrans == pTrans) {
|
if (hb->trans.pTrans == pTrans) {
|
||||||
SQueryNodeEpId* pEpId = taosHashGetKey(hb, NULL);
|
SQueryNodeEpId* pEpId = taosHashGetKey(hb, NULL);
|
||||||
rpcReleaseHandle(hb->trans.pHandle, TAOS_CONN_CLIENT);
|
schFreeHbTrans(hb);
|
||||||
taosHashRemove(schMgmt.hbConnections, pEpId, sizeof(SQueryNodeEpId));
|
taosHashRemove(schMgmt.hbConnections, pEpId, sizeof(SQueryNodeEpId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +74,6 @@ void schCleanClusterHb(void* pTrans) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schRemoveHbConnection(SSchJob *pJob, SSchTask *pTask, SQueryNodeEpId *epId) {
|
int32_t schRemoveHbConnection(SSchJob *pJob, SSchTask *pTask, SQueryNodeEpId *epId) {
|
||||||
return TSDB_CODE_SUCCESS; // TODO ENABLE IT WHEN RPC IS READY
|
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
SCH_LOCK(SCH_WRITE, &schMgmt.hbLock);
|
SCH_LOCK(SCH_WRITE, &schMgmt.hbLock);
|
||||||
|
@ -82,7 +86,7 @@ int32_t schRemoveHbConnection(SSchJob *pJob, SSchTask *pTask, SQueryNodeEpId *ep
|
||||||
|
|
||||||
int64_t taskNum = atomic_load_64(&hb->taskNum);
|
int64_t taskNum = atomic_load_64(&hb->taskNum);
|
||||||
if (taskNum <= 0) {
|
if (taskNum <= 0) {
|
||||||
rpcReleaseHandle(hb->trans.pHandle, TAOS_CONN_CLIENT);
|
schFreeHbTrans(hb);
|
||||||
taosHashRemove(schMgmt.hbConnections, epId, sizeof(SQueryNodeEpId));
|
taosHashRemove(schMgmt.hbConnections, epId, sizeof(SQueryNodeEpId));
|
||||||
}
|
}
|
||||||
SCH_UNLOCK(SCH_WRITE, &schMgmt.hbLock);
|
SCH_UNLOCK(SCH_WRITE, &schMgmt.hbLock);
|
||||||
|
@ -265,9 +269,7 @@ void schFreeRpcCtxVal(const void *arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SMsgSendInfo *pMsgSendInfo = (SMsgSendInfo *)arg;
|
SMsgSendInfo *pMsgSendInfo = (SMsgSendInfo *)arg;
|
||||||
taosMemoryFreeClear(pMsgSendInfo->param);
|
destroySendMsgInfo(pMsgSendInfo);
|
||||||
taosMemoryFreeClear(pMsgSendInfo->msgInfo.pData);
|
|
||||||
taosMemoryFreeClear(pMsgSendInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void schFreeRpcCtx(SRpcCtx *pCtx) {
|
void schFreeRpcCtx(SRpcCtx *pCtx) {
|
||||||
|
@ -290,15 +292,6 @@ void schFreeRpcCtx(SRpcCtx *pCtx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void schFreeSMsgSendInfo(SMsgSendInfo *msgSendInfo) {
|
|
||||||
if (NULL == msgSendInfo) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosMemoryFree(msgSendInfo->param);
|
|
||||||
taosMemoryFree(msgSendInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t schGetTaskFromList(SHashObj *pTaskList, uint64_t taskId, SSchTask **pTask) {
|
int32_t schGetTaskFromList(SHashObj *pTaskList, uint64_t taskId, SSchTask **pTask) {
|
||||||
int32_t s = taosHashGetSize(pTaskList);
|
int32_t s = taosHashGetSize(pTaskList);
|
||||||
if (s <= 0) {
|
if (s <= 0) {
|
||||||
|
|
|
@ -44,7 +44,7 @@ int32_t streamBroadcastToChildren(SStreamTask* pTask, const SSDataBlock* pBlock)
|
||||||
|
|
||||||
int32_t tEncodeStreamRetrieveReq(SEncoder* pEncoder, const SStreamRetrieveReq* pReq);
|
int32_t tEncodeStreamRetrieveReq(SEncoder* pEncoder, const SStreamRetrieveReq* pReq);
|
||||||
|
|
||||||
int32_t streamAppendQueueItem(SStreamQueueItem* dst, SStreamQueueItem* elem);
|
SStreamQueueItem* streamAppendQueueItem(SStreamQueueItem* dst, SStreamQueueItem* elem);
|
||||||
void streamFreeQitem(SStreamQueueItem* data);
|
void streamFreeQitem(SStreamQueueItem* data);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -77,6 +77,28 @@ FAIL:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SStreamMergedSubmit* streamMergedSubmitNew() {
|
||||||
|
SStreamMergedSubmit* pMerged = (SStreamMergedSubmit*)taosAllocateQitem(sizeof(SStreamMergedSubmit), DEF_QITEM);
|
||||||
|
if (pMerged == NULL) return NULL;
|
||||||
|
pMerged->reqs = taosArrayInit(0, sizeof(void*));
|
||||||
|
pMerged->dataRefs = taosArrayInit(0, sizeof(void*));
|
||||||
|
if (pMerged->dataRefs == NULL || pMerged->reqs == NULL) goto FAIL;
|
||||||
|
pMerged->type = STREAM_INPUT__MERGED_SUBMIT;
|
||||||
|
return pMerged;
|
||||||
|
FAIL:
|
||||||
|
if (pMerged->reqs) taosArrayDestroy(pMerged->reqs);
|
||||||
|
if (pMerged->dataRefs) taosArrayDestroy(pMerged->dataRefs);
|
||||||
|
taosFreeQitem(pMerged);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t streamMergeSubmit(SStreamMergedSubmit* pMerged, SStreamDataSubmit* pSubmit) {
|
||||||
|
taosArrayPush(pMerged->dataRefs, &pSubmit->dataRef);
|
||||||
|
taosArrayPush(pMerged->reqs, &pSubmit->data);
|
||||||
|
pMerged->ver = pSubmit->ver;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static FORCE_INLINE void streamDataSubmitRefInc(SStreamDataSubmit* pDataSubmit) {
|
static FORCE_INLINE void streamDataSubmitRefInc(SStreamDataSubmit* pDataSubmit) {
|
||||||
atomic_add_fetch_32(pDataSubmit->dataRef, 1);
|
atomic_add_fetch_32(pDataSubmit->dataRef, 1);
|
||||||
}
|
}
|
||||||
|
@ -100,15 +122,31 @@ void streamDataSubmitRefDec(SStreamDataSubmit* pDataSubmit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t streamAppendQueueItem(SStreamQueueItem* dst, SStreamQueueItem* elem) {
|
SStreamQueueItem* streamAppendQueueItem(SStreamQueueItem* dst, SStreamQueueItem* elem) {
|
||||||
ASSERT(elem);
|
ASSERT(elem);
|
||||||
if (dst->type == elem->type && dst->type == STREAM_INPUT__DATA_BLOCK) {
|
if (dst->type == STREAM_INPUT__DATA_BLOCK && elem->type == STREAM_INPUT__DATA_BLOCK) {
|
||||||
SStreamDataBlock* pBlock = (SStreamDataBlock*)dst;
|
SStreamDataBlock* pBlock = (SStreamDataBlock*)dst;
|
||||||
SStreamDataBlock* pBlockSrc = (SStreamDataBlock*)elem;
|
SStreamDataBlock* pBlockSrc = (SStreamDataBlock*)elem;
|
||||||
taosArrayAddAll(pBlock->blocks, pBlockSrc->blocks);
|
taosArrayAddAll(pBlock->blocks, pBlockSrc->blocks);
|
||||||
return 0;
|
taosArrayDestroy(pBlockSrc->blocks);
|
||||||
|
taosFreeQitem(elem);
|
||||||
|
return dst;
|
||||||
|
} else if (dst->type == STREAM_INPUT__MERGED_SUBMIT && elem->type == STREAM_INPUT__DATA_SUBMIT) {
|
||||||
|
SStreamMergedSubmit* pMerged = (SStreamMergedSubmit*)dst;
|
||||||
|
SStreamDataSubmit* pBlockSrc = (SStreamDataSubmit*)elem;
|
||||||
|
streamMergeSubmit(pMerged, pBlockSrc);
|
||||||
|
taosFreeQitem(elem);
|
||||||
|
return dst;
|
||||||
|
} else if (dst->type == STREAM_INPUT__DATA_SUBMIT && elem->type == STREAM_INPUT__DATA_SUBMIT) {
|
||||||
|
SStreamMergedSubmit* pMerged = streamMergedSubmitNew();
|
||||||
|
ASSERT(pMerged);
|
||||||
|
streamMergeSubmit(pMerged, (SStreamDataSubmit*)dst);
|
||||||
|
streamMergeSubmit(pMerged, (SStreamDataSubmit*)elem);
|
||||||
|
taosFreeQitem(dst);
|
||||||
|
taosFreeQitem(elem);
|
||||||
|
return (SStreamQueueItem*)pMerged;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,5 +161,20 @@ void streamFreeQitem(SStreamQueueItem* data) {
|
||||||
} else if (type == STREAM_INPUT__DATA_SUBMIT) {
|
} else if (type == STREAM_INPUT__DATA_SUBMIT) {
|
||||||
streamDataSubmitRefDec((SStreamDataSubmit*)data);
|
streamDataSubmitRefDec((SStreamDataSubmit*)data);
|
||||||
taosFreeQitem(data);
|
taosFreeQitem(data);
|
||||||
|
} else if (type == STREAM_INPUT__MERGED_SUBMIT) {
|
||||||
|
SStreamMergedSubmit* pMerge = (SStreamMergedSubmit*)data;
|
||||||
|
int32_t sz = taosArrayGetSize(pMerge->reqs);
|
||||||
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
|
int32_t* ref = taosArrayGetP(pMerge->dataRefs, i);
|
||||||
|
(*ref)--;
|
||||||
|
if (*ref == 0) {
|
||||||
|
void* data = taosArrayGetP(pMerge->reqs, i);
|
||||||
|
taosMemoryFree(data);
|
||||||
|
taosMemoryFree(ref);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
taosArrayDestroy(pMerge->reqs);
|
||||||
|
taosArrayDestroy(pMerge->dataRefs);
|
||||||
|
taosFreeQitem(pMerge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue