Merge branch 'develop' into feature/2.0tsdb
This commit is contained in:
commit
131be7b0da
231
.travis.yml
231
.travis.yml
|
@ -316,218 +316,19 @@ matrix:
|
||||||
fi
|
fi
|
||||||
- make > /dev/null
|
- make > /dev/null
|
||||||
|
|
||||||
- os: linux
|
# - os: osx
|
||||||
arch: arm64
|
# language: c
|
||||||
dist: bionic
|
# compiler: clang
|
||||||
language: c
|
# env: DESC="mac/clang build"
|
||||||
compiler: gcc
|
# git:
|
||||||
env: ENV_COVER=true
|
# - depth: 1
|
||||||
|
# addons:
|
||||||
git:
|
# homebrew:
|
||||||
- depth: 1
|
# - cmake
|
||||||
|
#
|
||||||
addons:
|
# script:
|
||||||
apt:
|
# - cd ${TRAVIS_BUILD_DIR}
|
||||||
packages:
|
# - mkdir debug
|
||||||
- build-essential
|
# - cd debug
|
||||||
- cmake
|
# - cmake .. > /dev/null
|
||||||
- net-tools
|
# - make > /dev/null
|
||||||
- python-pip
|
|
||||||
- python-setuptools
|
|
||||||
- python3-pip
|
|
||||||
- python3-setuptools
|
|
||||||
- lcov
|
|
||||||
- psmisc
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- cd ${TRAVIS_BUILD_DIR}
|
|
||||||
- mkdir debug
|
|
||||||
- cd debug
|
|
||||||
|
|
||||||
script:
|
|
||||||
- if [ "${TRAVIS_CPU_ARCH}" == "arm64" ];
|
|
||||||
then cmake -DCOVER=true .. -DCPUTYPE=aarch64 > /dev/null;
|
|
||||||
else cmake -DCOVER=true .. > /dev/null;
|
|
||||||
fi
|
|
||||||
- make > /dev/null
|
|
||||||
|
|
||||||
after_success:
|
|
||||||
- |-
|
|
||||||
case $TRAVIS_OS_NAME in
|
|
||||||
linux)
|
|
||||||
cd ${TRAVIS_BUILD_DIR}/debug
|
|
||||||
make install > /dev/null || travis_terminate $?
|
|
||||||
pip install numpy
|
|
||||||
pip install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python2/
|
|
||||||
pip3 install numpy
|
|
||||||
pip3 install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python3/
|
|
||||||
cd ${TRAVIS_BUILD_DIR}/tests
|
|
||||||
./test-all.sh smoke COVER
|
|
||||||
TEST_RESULT=$?
|
|
||||||
pkill taosd
|
|
||||||
sleep 1
|
|
||||||
cd ${TRAVIS_BUILD_DIR}
|
|
||||||
lcov -d . --capture --rc lcov_branch_coverage=1 -o coverage.info
|
|
||||||
lcov --remove coverage.info '*/tests/*' '*/test/*' '*/deps/*' '*/plugins/*' -o coverage.info
|
|
||||||
lcov -l --rc lcov_branch_coverage=1 coverage.info || travis_terminate $?
|
|
||||||
gem install coveralls-lcov
|
|
||||||
# Color setting
|
|
||||||
RED='\033[0;31m'
|
|
||||||
GREEN='\033[1;32m'
|
|
||||||
GREEN_DARK='\033[0;32m'
|
|
||||||
GREEN_UNDERLINE='\033[4;32m'
|
|
||||||
NC='\033[0m'
|
|
||||||
coveralls-lcov coverage.info
|
|
||||||
if [ "$?" -eq "0" ]; then
|
|
||||||
echo -e "${GREEN} ## Uploaded to Coveralls.io! ## ${NC}"
|
|
||||||
else
|
|
||||||
echo -e "${RED} ## Coveralls.io not collect coverage report! ## ${NC} "
|
|
||||||
fi
|
|
||||||
bash <(curl -s https://codecov.io/bash) -y .codecov.yml -f coverage.info
|
|
||||||
if [ "$?" -eq "0" ]; then
|
|
||||||
echo -e "${GREEN} ## Uploaded to Codecov! ## ${NC} "
|
|
||||||
else
|
|
||||||
echo -e "${RED} ## Codecov did not collect coverage report! ## ${NC} "
|
|
||||||
fi
|
|
||||||
if [ "$TEST_RESULT" -ne "0" ]; then
|
|
||||||
travis_terminate $?
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
arch: arm64
|
|
||||||
dist: bionic
|
|
||||||
language: c
|
|
||||||
|
|
||||||
git:
|
|
||||||
- depth: 1
|
|
||||||
|
|
||||||
compiler: gcc
|
|
||||||
env: DESC="linux/gcc build and test"
|
|
||||||
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- build-essential
|
|
||||||
- cmake
|
|
||||||
- net-tools
|
|
||||||
- python-pip
|
|
||||||
- python-setuptools
|
|
||||||
- python3-pip
|
|
||||||
- python3-setuptools
|
|
||||||
- valgrind
|
|
||||||
- psmisc
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- cd ${TRAVIS_BUILD_DIR}
|
|
||||||
- mkdir debug
|
|
||||||
- cd debug
|
|
||||||
|
|
||||||
script:
|
|
||||||
- if [ "${TRAVIS_CPU_ARCH}" == "arm64" ];
|
|
||||||
then cmake .. -DCPUTYPE=aarch64 > /dev/null;
|
|
||||||
else cmake .. > /dev/null;
|
|
||||||
fi
|
|
||||||
- make > /dev/null
|
|
||||||
|
|
||||||
after_success:
|
|
||||||
- travis_wait 20
|
|
||||||
- |-
|
|
||||||
case $TRAVIS_OS_NAME in
|
|
||||||
linux)
|
|
||||||
cd ${TRAVIS_BUILD_DIR}/debug
|
|
||||||
make install > /dev/null || travis_terminate $?
|
|
||||||
pip install numpy
|
|
||||||
pip install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python2/
|
|
||||||
pip3 install numpy
|
|
||||||
pip3 install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python3/
|
|
||||||
cd ${TRAVIS_BUILD_DIR}/tests
|
|
||||||
./test-all.sh smoke || travis_terminate $?
|
|
||||||
cd ${TRAVIS_BUILD_DIR}/tests/pytest
|
|
||||||
./valgrind-test.sh 2>&1 > mem-error-out.log
|
|
||||||
sleep 1
|
|
||||||
# Color setting
|
|
||||||
RED='\033[0;31m'
|
|
||||||
GREEN='\033[1;32m'
|
|
||||||
GREEN_DARK='\033[0;32m'
|
|
||||||
GREEN_UNDERLINE='\033[4;32m'
|
|
||||||
NC='\033[0m'
|
|
||||||
grep 'start to execute\|ERROR SUMMARY' mem-error-out.log|grep -v 'grep'|uniq|tee uniq-mem-error-out.log
|
|
||||||
for memError in `grep 'ERROR SUMMARY' uniq-mem-error-out.log | awk '{print $4}'`
|
|
||||||
do
|
|
||||||
if [ -n "$memError" ]; then
|
|
||||||
if [ "$memError" -gt 12 ]; then
|
|
||||||
echo -e "${RED} ## Memory errors number valgrind reports is $memError.\
|
|
||||||
More than our threshold! ## ${NC}"
|
|
||||||
travis_terminate $memError
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
grep 'start to execute\|definitely lost:' mem-error-out.log|grep -v 'grep'|uniq|tee uniq-definitely-lost-out.log
|
|
||||||
for defiMemError in `grep 'definitely lost:' uniq-definitely-lost-out.log | awk '{print $7}'`
|
|
||||||
do
|
|
||||||
if [ -n "$defiMemError" ]; then
|
|
||||||
if [ "$defiMemError" -gt 13 ]; then
|
|
||||||
echo -e "${RED} ## Memory errors number valgrind reports \
|
|
||||||
Definitely lost is $defiMemError. More than our threshold! ## ${NC}"
|
|
||||||
travis_terminate $defiMemError
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
arch: arm64
|
|
||||||
dist: bionic
|
|
||||||
language: c
|
|
||||||
compiler: gcc
|
|
||||||
env: COVERITY_SCAN=true
|
|
||||||
git:
|
|
||||||
- depth: 1
|
|
||||||
|
|
||||||
script:
|
|
||||||
- echo "this job is for coverity scan"
|
|
||||||
|
|
||||||
addons:
|
|
||||||
coverity_scan:
|
|
||||||
# GitHub project metadata
|
|
||||||
# ** specific to your project **
|
|
||||||
project:
|
|
||||||
name: TDengine
|
|
||||||
version: 2.x
|
|
||||||
description: TDengine
|
|
||||||
|
|
||||||
# Where email notification of build analysis results will be sent
|
|
||||||
notification_email: sdsang@taosdata.com, slguan@taosdata.com
|
|
||||||
|
|
||||||
# Commands to prepare for build_command
|
|
||||||
# ** likely specific to your build **
|
|
||||||
build_command_prepend: cmake . > /dev/null
|
|
||||||
|
|
||||||
# The command that will be added as an argument to "cov-build" to compile your project for analysis,
|
|
||||||
# ** likely specific to your build **
|
|
||||||
build_command: make
|
|
||||||
|
|
||||||
# Pattern to match selecting branches that will run analysis. We recommend leaving this set to 'coverity_scan'.
|
|
||||||
# Take care in resource usage, and consider the build frequency allowances per
|
|
||||||
# https://scan.coverity.com/faq#frequency
|
|
||||||
branch_pattern: coverity_scan
|
|
||||||
|
|
||||||
# - os: osx
|
|
||||||
# language: c
|
|
||||||
# compiler: clang
|
|
||||||
# env: DESC="mac/clang build"
|
|
||||||
# git:
|
|
||||||
# - depth: 1
|
|
||||||
# addons:
|
|
||||||
# homebrew:
|
|
||||||
# - cmake
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - cd ${TRAVIS_BUILD_DIR}
|
|
||||||
# - mkdir debug
|
|
||||||
# - cd debug
|
|
||||||
# - cmake .. > /dev/null
|
|
||||||
# - make > /dev/null
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ STable从属于库,一个STable只属于一个库,但一个库可以有一
|
||||||
|
|
||||||
说明:
|
说明:
|
||||||
|
|
||||||
1. TAGS列总长度不能超过64k bytes;
|
1. TAGS列总长度不能超过16k bytes;
|
||||||
2. TAGS列的数据类型不能是timestamp;
|
2. TAGS列的数据类型不能是timestamp;
|
||||||
3. TAGS列名不能与其他列名相同;
|
3. TAGS列名不能与其他列名相同;
|
||||||
4. TAGS列名不能为预留关键字.
|
4. TAGS列名不能为预留关键字.
|
||||||
|
|
|
@ -22,7 +22,7 @@ New keyword "tags" is introduced, where tag_name is the tag name, and tag_type i
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
|
|
||||||
1. The bytes of all tags together shall be less than 64k
|
1. The bytes of all tags together shall be less than 16k
|
||||||
2. Tag's data type can not be time stamp
|
2. Tag's data type can not be time stamp
|
||||||
3. Tag name shall be different from the field name
|
3. Tag name shall be different from the field name
|
||||||
4. Tag name shall not be the same as system keywords
|
4. Tag name shall not be the same as system keywords
|
||||||
|
|
|
@ -63,7 +63,7 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic
|
||||||
| 3 | BIGINT | 8 | 长整型,范围 [-2^63+1, 2^63-1], -2^63用于NULL |
|
| 3 | BIGINT | 8 | 长整型,范围 [-2^63+1, 2^63-1], -2^63用于NULL |
|
||||||
| 4 | FLOAT | 4 | 浮点型,有效位数6-7,范围 [-3.4E38, 3.4E38] |
|
| 4 | FLOAT | 4 | 浮点型,有效位数6-7,范围 [-3.4E38, 3.4E38] |
|
||||||
| 5 | DOUBLE | 8 | 双精度浮点型,有效位数15-16,范围 [-1.7E308, 1.7E308] |
|
| 5 | DOUBLE | 8 | 双精度浮点型,有效位数15-16,范围 [-1.7E308, 1.7E308] |
|
||||||
| 6 | BINARY | 自定义 | 用于记录字符串,理论上,最长可以有65526字节,但由于每行数据最多64K字节,实际上限一般小于理论值。 binary仅支持字符串输入,字符串两端使用单引号引用,否则英文全部自动转化为小写。使用时须指定大小,如binary(20)定义了最长为20个字符的字符串,每个字符占1byte的存储空间。如果用户字符串超出20字节将会报错。对于字符串内的单引号,可以用转义字符反斜线加单引号来表示, 即 **\’**。 |
|
| 6 | BINARY | 自定义 | 用于记录字符串,理论上,最长可以有16374字节,但由于每行数据最多16K字节,实际上限一般小于理论值。 binary仅支持字符串输入,字符串两端使用单引号引用,否则英文全部自动转化为小写。使用时须指定大小,如binary(20)定义了最长为20个字符的字符串,每个字符占1byte的存储空间。如果用户字符串超出20字节将会报错。对于字符串内的单引号,可以用转义字符反斜线加单引号来表示, 即 **\’**。 |
|
||||||
| 7 | SMALLINT | 2 | 短整型, 范围 [-32767, 32767], -32768用于NULL |
|
| 7 | SMALLINT | 2 | 短整型, 范围 [-32767, 32767], -32768用于NULL |
|
||||||
| 8 | TINYINT | 1 | 单字节整型,范围 [-127, 127], -128用于NULL |
|
| 8 | TINYINT | 1 | 单字节整型,范围 [-127, 127], -128用于NULL |
|
||||||
| 9 | BOOL | 1 | 布尔型,{true, false} |
|
| 9 | BOOL | 1 | 布尔型,{true, false} |
|
||||||
|
@ -106,7 +106,7 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic
|
||||||
```mysql
|
```mysql
|
||||||
CREATE TABLE [IF NOT EXISTS] tb_name (timestamp_field_name TIMESTAMP, field1_name data_type1 [, field2_name data_type2 ...])
|
CREATE TABLE [IF NOT EXISTS] tb_name (timestamp_field_name TIMESTAMP, field1_name data_type1 [, field2_name data_type2 ...])
|
||||||
```
|
```
|
||||||
说明:1)表的第一个字段必须是TIMESTAMP,并且系统自动将其设为主键;2)表的每行长度不能超过64K字节;3)使用数据类型binary或nchar,需指定其最长的字节数,如binary(20),表示20字节。
|
说明:1)表的第一个字段必须是TIMESTAMP,并且系统自动将其设为主键;2)表的每行长度不能超过16K字节;3)使用数据类型binary或nchar,需指定其最长的字节数,如binary(20),表示20字节。
|
||||||
|
|
||||||
|
|
||||||
- **删除数据表**
|
- **删除数据表**
|
||||||
|
|
|
@ -39,7 +39,7 @@ The full list of data types is listed below. For string types of data, we will
|
||||||
| 6 | DOUBLE | 8 | A standard nullable double float type with 15-16 significant digits and a range of [-1.7E308, 1.7E308] |
|
| 6 | DOUBLE | 8 | A standard nullable double float type with 15-16 significant digits and a range of [-1.7E308, 1.7E308] |
|
||||||
| 7 | BOOL | 1 | A nullable boolean type, [**`true`**, **`false`**] |
|
| 7 | BOOL | 1 | A nullable boolean type, [**`true`**, **`false`**] |
|
||||||
| 8 | TIMESTAMP | 8 | A nullable timestamp type with the same usage as the primary column timestamp |
|
| 8 | TIMESTAMP | 8 | A nullable timestamp type with the same usage as the primary column timestamp |
|
||||||
| 9 | BINARY(*M*) | *M* | A nullable string type whose length is *M*, error should be threw with exceeded chars, the maximum length of *M* is 65526, but as maximum row size is 64K bytes, the actual upper limit will generally less than 65526. This type of string only supports ASCii encoded chars. |
|
| 9 | BINARY(*M*) | *M* | A nullable string type whose length is *M*, error should be threw with exceeded chars, the maximum length of *M* is 16374, but as maximum row size is 16K bytes, the actual upper limit will generally less than 16374. This type of string only supports ASCii encoded chars. |
|
||||||
| 10 | NCHAR(*M*) | 4 * *M* | A nullable string type whose length is *M*, error should be threw with exceeded chars. The **`NCHAR`** type supports Unicode encoded chars. |
|
| 10 | NCHAR(*M*) | 4 * *M* | A nullable string type whose length is *M*, error should be threw with exceeded chars. The **`NCHAR`** type supports Unicode encoded chars. |
|
||||||
|
|
||||||
All the keywords in a SQL statement are case-insensitive, but strings values are case-sensitive and must be quoted by a pair of `'` or `"`. To quote a `'` or a `"` , you can use the escape character `\`.
|
All the keywords in a SQL statement are case-insensitive, but strings values are case-sensitive and must be quoted by a pair of `'` or `"`. To quote a `'` or a `"` , you can use the escape character `\`.
|
||||||
|
@ -86,7 +86,7 @@ All the keywords in a SQL statement are case-insensitive, but strings values are
|
||||||
|
|
||||||
1) The first column must be a `timestamp`, and the system will set it as the primary key.
|
1) The first column must be a `timestamp`, and the system will set it as the primary key.
|
||||||
|
|
||||||
2) The record size is limited to 64k bytes
|
2) The record size is limited to 16k bytes
|
||||||
|
|
||||||
3) For `binary` or `nchar` data types, the length must be specified. For example, binary(20) means a binary data type with 20 bytes.
|
3) For `binary` or `nchar` data types, the length must be specified. For example, binary(20) means a binary data type with 20 bytes.
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TDENGINE_TSCSECONARYMERGE_H
|
#ifndef TDENGINE_TSCLOCALMERGE_H
|
||||||
#define TDENGINE_TSCSECONARYMERGE_H
|
#define TDENGINE_TSCLOCALMERGE_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -28,13 +28,6 @@ extern "C" {
|
||||||
|
|
||||||
#define MAX_NUM_OF_SUBQUERY_RETRY 3
|
#define MAX_NUM_OF_SUBQUERY_RETRY 3
|
||||||
|
|
||||||
/*
|
|
||||||
* @version 0.1
|
|
||||||
* @date 2018/01/05
|
|
||||||
* @author liaohj
|
|
||||||
* management of client-side reducer for metric query
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct SQLFunctionCtx;
|
struct SQLFunctionCtx;
|
||||||
|
|
||||||
typedef struct SLocalDataSource {
|
typedef struct SLocalDataSource {
|
||||||
|
@ -60,7 +53,6 @@ typedef struct SLocalReducer {
|
||||||
char * prevRowOfInput;
|
char * prevRowOfInput;
|
||||||
tFilePage * pResultBuf;
|
tFilePage * pResultBuf;
|
||||||
int32_t nResultBufSize;
|
int32_t nResultBufSize;
|
||||||
// char * pBufForInterpo; // intermediate buffer for interpolation
|
|
||||||
tFilePage * pTempBuffer;
|
tFilePage * pTempBuffer;
|
||||||
struct SQLFunctionCtx *pCtx;
|
struct SQLFunctionCtx *pCtx;
|
||||||
int32_t rowSize; // size of each intermediate result.
|
int32_t rowSize; // size of each intermediate result.
|
||||||
|
@ -81,13 +73,8 @@ typedef struct SLocalReducer {
|
||||||
} SLocalReducer;
|
} SLocalReducer;
|
||||||
|
|
||||||
typedef struct SSubqueryState {
|
typedef struct SSubqueryState {
|
||||||
/*
|
int32_t numOfRemain; // the number of remain unfinished subquery
|
||||||
* the number of completed retrieval subquery, once this value equals to numOfVnodes,
|
int32_t numOfTotal; // the number of total sub-queries
|
||||||
* all retrieval are completed.Local merge is launched.
|
|
||||||
*/
|
|
||||||
int32_t numOfCompleted;
|
|
||||||
int32_t numOfTotal; // number of total sub-queries
|
|
||||||
int32_t code; // code from subqueries
|
|
||||||
uint64_t numOfRetrievedRows; // total number of points in this query
|
uint64_t numOfRetrievedRows; // total number of points in this query
|
||||||
} SSubqueryState;
|
} SSubqueryState;
|
||||||
|
|
||||||
|
@ -128,4 +115,4 @@ int32_t tscDoLocalMerge(SSqlObj *pSql);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // TDENGINE_TSCSECONARYMERGE_H
|
#endif // TDENGINE_TSCLOCALMERGE_H
|
||||||
|
|
|
@ -26,11 +26,9 @@ extern "C" {
|
||||||
void tscFetchDatablockFromSubquery(SSqlObj* pSql);
|
void tscFetchDatablockFromSubquery(SSqlObj* pSql);
|
||||||
|
|
||||||
void tscSetupOutputColumnIndex(SSqlObj* pSql);
|
void tscSetupOutputColumnIndex(SSqlObj* pSql);
|
||||||
int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql);
|
|
||||||
void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code);
|
void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code);
|
||||||
|
|
||||||
SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, SSubqueryState* pState, int32_t index);
|
SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, SSubqueryState* pState, int32_t index);
|
||||||
void tscDestroyJoinSupporter(SJoinSupporter* pSupporter);
|
|
||||||
|
|
||||||
int32_t tscHandleMasterJoinQuery(SSqlObj* pSql);
|
int32_t tscHandleMasterJoinQuery(SSqlObj* pSql);
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,8 @@ typedef struct SJoinSupporter {
|
||||||
SSubqueryState* pState;
|
SSubqueryState* pState;
|
||||||
SSqlObj* pObj; // parent SqlObj
|
SSqlObj* pObj; // parent SqlObj
|
||||||
int32_t subqueryIndex; // index of sub query
|
int32_t subqueryIndex; // index of sub query
|
||||||
int64_t interval; // interval time
|
int64_t intervalTime; // interval time
|
||||||
|
int64_t slidingTime; // sliding time
|
||||||
SLimitVal limit; // limit info
|
SLimitVal limit; // limit info
|
||||||
uint64_t uid; // query meter uid
|
uint64_t uid; // query meter uid
|
||||||
SArray* colList; // previous query information, no need to use this attribute, and the corresponding attribution
|
SArray* colList; // previous query information, no need to use this attribute, and the corresponding attribution
|
||||||
|
|
|
@ -192,7 +192,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setOptions(JNIEnv
|
||||||
const char *tz1 = (*env)->GetStringUTFChars(env, optionValue, NULL);
|
const char *tz1 = (*env)->GetStringUTFChars(env, optionValue, NULL);
|
||||||
if (tz1 && strlen(tz1) != 0) {
|
if (tz1 && strlen(tz1) != 0) {
|
||||||
res = taos_options(TSDB_OPTION_TIMEZONE, tz1);
|
res = taos_options(TSDB_OPTION_TIMEZONE, tz1);
|
||||||
jniTrace("set timezone to %s, result:%d", timezone, res);
|
jniTrace("set timezone to %s, result:%d", tz1, res);
|
||||||
} else {
|
} else {
|
||||||
jniTrace("input timezone is empty");
|
jniTrace("input timezone is empty");
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ int32_t tscGetNumOfTags(const STableMeta* pTableMeta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTableMeta->tableType == TSDB_SUPER_TABLE || pTableMeta->tableType == TSDB_CHILD_TABLE) {
|
if (pTableMeta->tableType == TSDB_SUPER_TABLE || pTableMeta->tableType == TSDB_CHILD_TABLE) {
|
||||||
assert(tinfo.numOfTags >= 0);
|
|
||||||
return tinfo.numOfTags;
|
return tinfo.numOfTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -646,10 +646,6 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
size_t numOfOutput = tscSqlExprNumOfExprs(pQueryInfo);
|
size_t numOfOutput = tscSqlExprNumOfExprs(pQueryInfo);
|
||||||
pQueryMsg->numOfOutput = htons(numOfOutput);
|
pQueryMsg->numOfOutput = htons(numOfOutput);
|
||||||
if (numOfOutput < 0) {
|
|
||||||
tscError("%p illegal value of number of output columns in query msg: %d", pSql, numOfOutput);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set column list ids
|
// set column list ids
|
||||||
size_t numOfCols = taosArrayGetSize(pQueryInfo->colList);
|
size_t numOfCols = taosArrayGetSize(pQueryInfo->colList);
|
||||||
|
@ -663,7 +659,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
if (pCol->colIndex.columnIndex >= tscGetNumOfColumns(pTableMeta) || pColSchema->type < TSDB_DATA_TYPE_BOOL ||
|
if (pCol->colIndex.columnIndex >= tscGetNumOfColumns(pTableMeta) || pColSchema->type < TSDB_DATA_TYPE_BOOL ||
|
||||||
pColSchema->type > TSDB_DATA_TYPE_NCHAR) {
|
pColSchema->type > TSDB_DATA_TYPE_NCHAR) {
|
||||||
tscError("%p sid:%d uid:%" PRIu64" id:%s, column index out of range, numOfColumns:%d, index:%d, column name:%s",
|
tscError("%p sid:%d uid:%" PRIu64" id:%s, column index out of range, numOfColumns:%d, index:%d, column name:%s",
|
||||||
pSql, pTableMeta->sid, pTableMeta->uid, pTableMetaInfo->name, tscGetNumOfColumns(pTableMeta), pCol->colIndex,
|
pSql, pTableMeta->sid, pTableMeta->uid, pTableMetaInfo->name, tscGetNumOfColumns(pTableMeta), pCol->colIndex.columnIndex,
|
||||||
pColSchema->name);
|
pColSchema->name);
|
||||||
|
|
||||||
return TSDB_CODE_TSC_INVALID_SQL;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
|
@ -783,7 +779,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
(pColSchema->type < TSDB_DATA_TYPE_BOOL || pColSchema->type > TSDB_DATA_TYPE_NCHAR)) {
|
(pColSchema->type < TSDB_DATA_TYPE_BOOL || pColSchema->type > TSDB_DATA_TYPE_NCHAR)) {
|
||||||
tscError("%p sid:%d uid:%" PRIu64 " id:%s, tag index out of range, totalCols:%d, numOfTags:%d, index:%d, column name:%s",
|
tscError("%p sid:%d uid:%" PRIu64 " id:%s, tag index out of range, totalCols:%d, numOfTags:%d, index:%d, column name:%s",
|
||||||
pSql, pTableMeta->sid, pTableMeta->uid, pTableMetaInfo->name, total, numOfTagColumns,
|
pSql, pTableMeta->sid, pTableMeta->uid, pTableMetaInfo->name, total, numOfTagColumns,
|
||||||
pCol->colIndex, pColSchema->name);
|
pCol->colIndex.columnIndex, pColSchema->name);
|
||||||
|
|
||||||
return TSDB_CODE_TSC_INVALID_SQL;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
|
@ -982,7 +978,7 @@ int32_t tscBuildDropDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SCMDropDbMsg *pDropDbMsg = (SCMDropDbMsg*)pCmd->payload;
|
SCMDropDbMsg *pDropDbMsg = (SCMDropDbMsg*)pCmd->payload;
|
||||||
|
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
||||||
strncpy(pDropDbMsg->db, pTableMetaInfo->name, tListLen(pDropDbMsg->db));
|
tstrncpy(pDropDbMsg->db, pTableMetaInfo->name, sizeof(pDropDbMsg->db));
|
||||||
pDropDbMsg->ignoreNotExists = pInfo->pDCLInfo->existsCheck ? 1 : 0;
|
pDropDbMsg->ignoreNotExists = pInfo->pDCLInfo->existsCheck ? 1 : 0;
|
||||||
|
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_CM_DROP_DB;
|
pCmd->msgType = TSDB_MSG_TYPE_CM_DROP_DB;
|
||||||
|
@ -1052,7 +1048,7 @@ int32_t tscBuildDropAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
SCMDropUserMsg *pDropMsg = (SCMDropUserMsg*)pCmd->payload;
|
SCMDropUserMsg *pDropMsg = (SCMDropUserMsg*)pCmd->payload;
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
||||||
strcpy(pDropMsg->user, pTableMetaInfo->name);
|
tstrncpy(pDropMsg->user, pTableMetaInfo->name, sizeof(pDropMsg->user));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1812,6 +1808,7 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
|
||||||
|
|
||||||
// todo handle out of memory case
|
// todo handle out of memory case
|
||||||
if (pTableMetaInfo->pTableMeta == NULL) {
|
if (pTableMetaInfo->pTableMeta == NULL) {
|
||||||
|
free(pTableMeta);
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2324,6 +2321,7 @@ int tscGetSTableVgroupInfo(SSqlObj *pSql, int32_t clauseIndex) {
|
||||||
|
|
||||||
SQueryInfo *pNewQueryInfo = NULL;
|
SQueryInfo *pNewQueryInfo = NULL;
|
||||||
if ((code = tscGetQueryInfoDetailSafely(&pNew->cmd, 0, &pNewQueryInfo)) != TSDB_CODE_SUCCESS) {
|
if ((code = tscGetQueryInfoDetailSafely(&pNew->cmd, 0, &pNewQueryInfo)) != TSDB_CODE_SUCCESS) {
|
||||||
|
tscFreeSqlObj(pNew);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -584,7 +584,7 @@ char *taos_errstr(TAOS_RES *tres) {
|
||||||
|
|
||||||
void taos_config(int debug, char *log_path) {
|
void taos_config(int debug, char *log_path) {
|
||||||
uDebugFlag = debug;
|
uDebugFlag = debug;
|
||||||
strcpy(tsLogDir, log_path);
|
tstrncpy(tsLogDir, log_path, TSDB_FILENAME_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *taos_get_server_info(TAOS *taos) {
|
char *taos_get_server_info(TAOS *taos) {
|
||||||
|
@ -719,6 +719,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) {
|
||||||
if (sqlLen > tsMaxSQLStringLen) {
|
if (sqlLen > tsMaxSQLStringLen) {
|
||||||
tscError("%p sql too long", pSql);
|
tscError("%p sql too long", pSql);
|
||||||
pRes->code = TSDB_CODE_TSC_INVALID_SQL;
|
pRes->code = TSDB_CODE_TSC_INVALID_SQL;
|
||||||
|
tfree(pSql);
|
||||||
return pRes->code;
|
return pRes->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -727,6 +728,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) {
|
||||||
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
tscError("%p failed to malloc sql string buffer", pSql);
|
tscError("%p failed to malloc sql string buffer", pSql);
|
||||||
tscTrace("%p Valid SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(taos), pObj);
|
tscTrace("%p Valid SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(taos), pObj);
|
||||||
|
tfree(pSql);
|
||||||
return pRes->code;
|
return pRes->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -851,6 +853,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
|
||||||
if (tblListLen > MAX_TABLE_NAME_LENGTH) {
|
if (tblListLen > MAX_TABLE_NAME_LENGTH) {
|
||||||
tscError("%p tableNameList too long, length:%d, maximum allowed:%d", pSql, tblListLen, MAX_TABLE_NAME_LENGTH);
|
tscError("%p tableNameList too long, length:%d, maximum allowed:%d", pSql, tblListLen, MAX_TABLE_NAME_LENGTH);
|
||||||
pRes->code = TSDB_CODE_TSC_INVALID_SQL;
|
pRes->code = TSDB_CODE_TSC_INVALID_SQL;
|
||||||
|
tfree(pSql);
|
||||||
return pRes->code;
|
return pRes->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -858,6 +861,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
tscError("%p failed to malloc sql string buffer", pSql);
|
tscError("%p failed to malloc sql string buffer", pSql);
|
||||||
|
tfree(pSql);
|
||||||
return pRes->code;
|
return pRes->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -873,6 +877,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
|
||||||
free(str);
|
free(str);
|
||||||
|
|
||||||
if (pRes->code != TSDB_CODE_SUCCESS) {
|
if (pRes->code != TSDB_CODE_SUCCESS) {
|
||||||
|
tscFreeSqlObj(pSql);
|
||||||
return pRes->code;
|
return pRes->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// launch stream computing in a new thread
|
// launch stream computing in a new thread
|
||||||
SSchedMsg schedMsg;
|
SSchedMsg schedMsg = { 0 };
|
||||||
schedMsg.fp = tscProcessStreamLaunchQuery;
|
schedMsg.fp = tscProcessStreamLaunchQuery;
|
||||||
schedMsg.ahandle = pStream;
|
schedMsg.ahandle = pStream;
|
||||||
schedMsg.thandle = (void *)1;
|
schedMsg.thandle = (void *)1;
|
||||||
|
@ -239,7 +239,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
|
||||||
/* no resuls in the query range, retry */
|
/* no resuls in the query range, retry */
|
||||||
// todo set retry dynamic time
|
// todo set retry dynamic time
|
||||||
int32_t retry = tsProjectExecInterval;
|
int32_t retry = tsProjectExecInterval;
|
||||||
tscError("%p stream:%p, retrieve no data, code:%d, retry in %" PRId64 "ms", pSql, pStream, numOfRows, retry);
|
tscError("%p stream:%p, retrieve no data, code:%d, retry in %" PRId32 "ms", pSql, pStream, numOfRows, retry);
|
||||||
|
|
||||||
tscSetRetryTimer(pStream, pStream->pSql, retry);
|
tscSetRetryTimer(pStream, pStream->pSql, retry);
|
||||||
return;
|
return;
|
||||||
|
@ -250,7 +250,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tscTrace("%p stream:%p, query on:%s, fetch result completed, fetched rows:%d", pSql, pStream, pTableMetaInfo->name,
|
tscTrace("%p stream:%p, query on:%s, fetch result completed, fetched rows:%" PRId64, pSql, pStream, pTableMetaInfo->name,
|
||||||
pStream->numOfRes);
|
pStream->numOfRes);
|
||||||
|
|
||||||
// release the metric/meter meta information reference, so data in cache can be updated
|
// release the metric/meter meta information reference, so data in cache can be updated
|
||||||
|
|
|
@ -291,7 +291,7 @@ static int tscLoadSubscriptionProgress(SSub* pSub) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
taosArraySort(progress, tscCompareSubscriptionProgress);
|
taosArraySort(progress, tscCompareSubscriptionProgress);
|
||||||
tscTrace("subscription progress loaded, %d tables: %s", taosArrayGetSize(progress), pSub->topic);
|
tscTrace("subscription progress loaded, %z tables: %s", taosArrayGetSize(progress), pSub->topic);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,7 +350,7 @@ TAOS_SUB *taos_subscribe(TAOS *taos, int restart, const char* topic, const char
|
||||||
|
|
||||||
pSub->interval = interval;
|
pSub->interval = interval;
|
||||||
if (fp != NULL) {
|
if (fp != NULL) {
|
||||||
tscTrace("asynchronize subscription, create new timer", topic);
|
tscTrace("asynchronize subscription, create new timer: %s", topic);
|
||||||
pSub->fp = fp;
|
pSub->fp = fp;
|
||||||
pSub->param = param;
|
pSub->param = param;
|
||||||
taosTmrReset(tscProcessSubscriptionTimer, interval, pSub, tscTmr, &pSub->pTimer);
|
taosTmrReset(tscProcessSubscriptionTimer, interval, pSub, tscTmr, &pSub->pTimer);
|
||||||
|
@ -435,7 +435,9 @@ void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress) {
|
||||||
} else {
|
} else {
|
||||||
char path[256];
|
char path[256];
|
||||||
sprintf(path, "%s/subscribe/%s", tsDataDir, pSub->topic);
|
sprintf(path, "%s/subscribe/%s", tsDataDir, pSub->topic);
|
||||||
remove(path);
|
if (remove(path) != 0) {
|
||||||
|
tscError("failed to remove progress file, topic = %s, error = %s", pSub->topic, strerror(errno));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tscFreeSqlObj(pSub->pSql);
|
tscFreeSqlObj(pSub->pSql);
|
||||||
|
|
|
@ -12,12 +12,12 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
#include "os.h"
|
||||||
|
|
||||||
#include "tscSubquery.h"
|
#include "tscSubquery.h"
|
||||||
#include <qast.h>
|
#include "qast.h"
|
||||||
#include <tcompare.h>
|
#include "tcompare.h"
|
||||||
#include <tschemautil.h>
|
#include "tschemautil.h"
|
||||||
#include "os.h"
|
|
||||||
#include "qtsbuf.h"
|
#include "qtsbuf.h"
|
||||||
#include "tscLog.h"
|
#include "tscLog.h"
|
||||||
#include "tsclient.h"
|
#include "tsclient.h"
|
||||||
|
@ -169,7 +169,8 @@ SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, SSubqueryState* pState, in
|
||||||
pSupporter->subqueryIndex = index;
|
pSupporter->subqueryIndex = index;
|
||||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, pSql->cmd.clauseIndex);
|
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, pSql->cmd.clauseIndex);
|
||||||
|
|
||||||
pSupporter->interval = pQueryInfo->intervalTime;
|
pSupporter->intervalTime = pQueryInfo->intervalTime;
|
||||||
|
pSupporter->slidingTime = pQueryInfo->slidingTime;
|
||||||
pSupporter->limit = pQueryInfo->limit;
|
pSupporter->limit = pQueryInfo->limit;
|
||||||
|
|
||||||
STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, pSql->cmd.clauseIndex, index);
|
STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, pSql->cmd.clauseIndex, index);
|
||||||
|
@ -186,7 +187,7 @@ SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, SSubqueryState* pState, in
|
||||||
return pSupporter;
|
return pSupporter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscDestroyJoinSupporter(SJoinSupporter* pSupporter) {
|
static void tscDestroyJoinSupporter(SJoinSupporter* pSupporter) {
|
||||||
if (pSupporter == NULL) {
|
if (pSupporter == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -217,7 +218,7 @@ void tscDestroyJoinSupporter(SJoinSupporter* pSupporter) {
|
||||||
* primary timestamp column , the secondary query is not necessary
|
* primary timestamp column , the secondary query is not necessary
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
bool needSecondaryQuery(SQueryInfo* pQueryInfo) {
|
static UNUSED_FUNC bool needSecondaryQuery(SQueryInfo* pQueryInfo) {
|
||||||
size_t numOfCols = taosArrayGetSize(pQueryInfo->colList);
|
size_t numOfCols = taosArrayGetSize(pQueryInfo->colList);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
@ -233,14 +234,11 @@ bool needSecondaryQuery(SQueryInfo* pQueryInfo) {
|
||||||
/*
|
/*
|
||||||
* launch secondary stage query to fetch the result that contains timestamp in set
|
* launch secondary stage query to fetch the result that contains timestamp in set
|
||||||
*/
|
*/
|
||||||
int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
|
static int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
|
||||||
int32_t numOfSub = 0;
|
int32_t numOfSub = 0;
|
||||||
SJoinSupporter* pSupporter = NULL;
|
SJoinSupporter* pSupporter = NULL;
|
||||||
|
|
||||||
/*
|
//If the columns are not involved in the final select clause, the corresponding query will not be issued.
|
||||||
* If the columns are not involved in the final select clause,
|
|
||||||
* the corresponding query will not be issued.
|
|
||||||
*/
|
|
||||||
for (int32_t i = 0; i < pSql->numOfSubs; ++i) {
|
for (int32_t i = 0; i < pSql->numOfSubs; ++i) {
|
||||||
pSupporter = pSql->pSubs[i]->param;
|
pSupporter = pSql->pSubs[i]->param;
|
||||||
if (taosArrayGetSize(pSupporter->exprList) > 0) {
|
if (taosArrayGetSize(pSupporter->exprList) > 0) {
|
||||||
|
@ -251,13 +249,12 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
|
||||||
assert(numOfSub > 0);
|
assert(numOfSub > 0);
|
||||||
|
|
||||||
// scan all subquery, if one sub query has only ts, ignore it
|
// scan all subquery, if one sub query has only ts, ignore it
|
||||||
tscTrace("%p start to launch secondary subquery, total:%d, only:%d needs to query, others are not retrieve in "
|
tscTrace("%p start to launch secondary subquery, total:%d, only:%d needs to query", pSql, pSql->numOfSubs, numOfSub);
|
||||||
"select clause", pSql, pSql->numOfSubs, numOfSub);
|
|
||||||
|
|
||||||
//the subqueries that do not actually launch the secondary query to virtual node is set as completed.
|
//the subqueries that do not actually launch the secondary query to virtual node is set as completed.
|
||||||
SSubqueryState* pState = pSupporter->pState;
|
SSubqueryState* pState = pSupporter->pState;
|
||||||
pState->numOfTotal = pSql->numOfSubs;
|
pState->numOfTotal = pSql->numOfSubs;
|
||||||
pState->numOfCompleted = (pSql->numOfSubs - numOfSub);
|
pState->numOfRemain = numOfSub;
|
||||||
|
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
|
@ -301,7 +298,8 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
|
||||||
// set the second stage sub query for join process
|
// set the second stage sub query for join process
|
||||||
TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_SEC_STAGE);
|
TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_SEC_STAGE);
|
||||||
|
|
||||||
pQueryInfo->intervalTime = pSupporter->interval;
|
pQueryInfo->intervalTime = pSupporter->intervalTime;
|
||||||
|
pQueryInfo->slidingTime = pSupporter->slidingTime;
|
||||||
pQueryInfo->groupbyExpr = pSupporter->groupbyExpr;
|
pQueryInfo->groupbyExpr = pSupporter->groupbyExpr;
|
||||||
|
|
||||||
tscTagCondCopy(&pQueryInfo->tagCond, &pSupporter->tagCond);
|
tscTagCondCopy(&pQueryInfo->tagCond, &pSupporter->tagCond);
|
||||||
|
@ -356,7 +354,7 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t numOfCols = taosArrayGetSize(pNewQueryInfo->colList);
|
size_t numOfCols = taosArrayGetSize(pNewQueryInfo->colList);
|
||||||
tscTrace("%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%d, colList:%d, fieldsInfo:%d, name:%s",
|
tscTrace("%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%z, colList:%z, fieldsInfo:%d, name:%s",
|
||||||
pSql, pNew, 0, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, taosArrayGetSize(pNewQueryInfo->exprList),
|
pSql, pNew, 0, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, taosArrayGetSize(pNewQueryInfo->exprList),
|
||||||
numOfCols, pNewQueryInfo->fieldsInfo.numOfOutput, pTableMetaInfo->name);
|
numOfCols, pNewQueryInfo->fieldsInfo.numOfOutput, pTableMetaInfo->name);
|
||||||
}
|
}
|
||||||
|
@ -375,6 +373,7 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
|
||||||
if (pSql->pSubs[i] == NULL) {
|
if (pSql->pSubs[i] == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tscDoQuery(pSql->pSubs[i]);
|
tscDoQuery(pSql->pSubs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,11 +404,9 @@ void freeJoinSubqueryObj(SSqlObj* pSql) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void quitAllSubquery(SSqlObj* pSqlObj, SJoinSupporter* pSupporter) {
|
static void quitAllSubquery(SSqlObj* pSqlObj, SJoinSupporter* pSupporter) {
|
||||||
int32_t numOfTotal = pSupporter->pState->numOfTotal;
|
assert(pSupporter->pState->numOfRemain > 0);
|
||||||
int32_t finished = atomic_add_fetch_32(&pSupporter->pState->numOfCompleted, 1);
|
|
||||||
|
|
||||||
pSqlObj->res.code = pSupporter->pState->code;
|
if (atomic_sub_fetch_32(&pSupporter->pState->numOfRemain, 1) <= 0) {
|
||||||
if (finished >= numOfTotal) {
|
|
||||||
tscError("%p all subquery return and query failed, global code:%d", pSqlObj, pSqlObj->res.code);
|
tscError("%p all subquery return and query failed, global code:%d", pSqlObj, pSqlObj->res.code);
|
||||||
freeJoinSubqueryObj(pSqlObj);
|
freeJoinSubqueryObj(pSqlObj);
|
||||||
}
|
}
|
||||||
|
@ -421,7 +418,7 @@ static void updateQueryTimeRange(SQueryInfo* pQueryInfo, STimeWindow* win) {
|
||||||
pQueryInfo->window = *win;
|
pQueryInfo->window = *win;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tSIntersectionAndLaunchSecQuery(SJoinSupporter* pSupporter, SSqlObj* pSql) {
|
static UNUSED_FUNC void tSIntersectionAndLaunchSecQuery(SJoinSupporter* pSupporter, SSqlObj* pSql) {
|
||||||
SSqlObj* pParentSql = pSupporter->pObj;
|
SSqlObj* pParentSql = pSupporter->pObj;
|
||||||
SQueryInfo* pParentQueryInfo = tscGetQueryInfoDetail(&pParentSql->cmd, pParentSql->cmd.clauseIndex);
|
SQueryInfo* pParentQueryInfo = tscGetQueryInfoDetail(&pParentSql->cmd, pParentSql->cmd.clauseIndex);
|
||||||
|
|
||||||
|
@ -444,21 +441,6 @@ static void tSIntersectionAndLaunchSecQuery(SJoinSupporter* pSupporter, SSqlObj*
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
int32_t numOfTotal = pSupporter->pState->numOfTotal;
|
|
||||||
int32_t finished = atomic_add_fetch_32(&pSupporter->pState->numOfCompleted, 1);
|
|
||||||
|
|
||||||
if (finished >= numOfTotal) {
|
|
||||||
assert(finished == numOfTotal);
|
|
||||||
|
|
||||||
if (pSupporter->pState->code != TSDB_CODE_SUCCESS) {
|
|
||||||
tscTrace("%p sub:%p, numOfSub:%d, quit from further procedure due to other queries failure", pParentSql, pSql,
|
|
||||||
pSupporter->subqueryIndex);
|
|
||||||
freeJoinSubqueryObj(pParentSql);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
tscTrace("%p all subqueries retrieve ts complete, do ts block intersect", pParentSql);
|
|
||||||
|
|
||||||
SJoinSupporter* p1 = pParentSql->pSubs[0]->param;
|
SJoinSupporter* p1 = pParentSql->pSubs[0]->param;
|
||||||
SJoinSupporter* p2 = pParentSql->pSubs[1]->param;
|
SJoinSupporter* p2 = pParentSql->pSubs[1]->param;
|
||||||
|
|
||||||
|
@ -471,7 +453,6 @@ static void tSIntersectionAndLaunchSecQuery(SJoinSupporter* pSupporter, SSqlObj*
|
||||||
updateQueryTimeRange(pParentQueryInfo, &win);
|
updateQueryTimeRange(pParentQueryInfo, &win);
|
||||||
tscLaunchSecondPhaseSubqueries(pParentSql);
|
tscLaunchSecondPhaseSubqueries(pParentSql);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscCompareTidTags(const void* p1, const void* p2) {
|
int32_t tscCompareTidTags(const void* p1, const void* p2) {
|
||||||
|
@ -545,10 +526,12 @@ static void issueTSCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj*
|
||||||
tscAddSpecialColumnForSelect(pQueryInfo, 0, TSDB_FUNC_TS_COMP, &index, &colSchema, TSDB_COL_NORMAL);
|
tscAddSpecialColumnForSelect(pQueryInfo, 0, TSDB_FUNC_TS_COMP, &index, &colSchema, TSDB_COL_NORMAL);
|
||||||
|
|
||||||
// set the tags value for ts_comp function
|
// set the tags value for ts_comp function
|
||||||
|
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
|
||||||
SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, 0);
|
SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, 0);
|
||||||
int16_t tagColId = tscGetJoinTagColIdByUid(&pSupporter->tagCond, pTableMetaInfo->pTableMeta->uid);
|
int16_t tagColId = tscGetJoinTagColIdByUid(&pSupporter->tagCond, pTableMetaInfo->pTableMeta->uid);
|
||||||
pExpr->param->i64Key = tagColId;
|
pExpr->param->i64Key = tagColId;
|
||||||
pExpr->numOfParams = 1;
|
pExpr->numOfParams = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// add the filter tag column
|
// add the filter tag column
|
||||||
if (pSupporter->colList != NULL) {
|
if (pSupporter->colList != NULL) {
|
||||||
|
@ -568,14 +551,14 @@ static void issueTSCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj*
|
||||||
|
|
||||||
tscTrace(
|
tscTrace(
|
||||||
"%p subquery:%p tableIndex:%d, vgroupIndex:%d, numOfVgroups:%d, type:%d, ts_comp query to retrieve timestamps, "
|
"%p subquery:%p tableIndex:%d, vgroupIndex:%d, numOfVgroups:%d, type:%d, ts_comp query to retrieve timestamps, "
|
||||||
"numOfExpr:%d, colList:%d, numOfOutputFields:%d, name:%s",
|
"numOfExpr:%z, colList:%z, numOfOutputFields:%d, name:%s",
|
||||||
pParent, pSql, 0, pTableMetaInfo->vgroupIndex, pTableMetaInfo->vgroupList->numOfVgroups, pQueryInfo->type,
|
pParent, pSql, 0, pTableMetaInfo->vgroupIndex, pTableMetaInfo->vgroupList->numOfVgroups, pQueryInfo->type,
|
||||||
tscSqlExprNumOfExprs(pQueryInfo), numOfCols, pQueryInfo->fieldsInfo.numOfOutput, pTableMetaInfo->name);
|
tscSqlExprNumOfExprs(pQueryInfo), numOfCols, pQueryInfo->fieldsInfo.numOfOutput, pTableMetaInfo->name);
|
||||||
|
|
||||||
tscProcessSql(pSql);
|
tscProcessSql(pSql);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool checkForIdenticalTagVal(SQueryInfo* pQueryInfo, SJoinSupporter* p1, void* pSql) {
|
static bool checkForDuplicateTagVal(SQueryInfo* pQueryInfo, SJoinSupporter* p1, SSqlObj* pPSqlObj) {
|
||||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||||
|
|
||||||
SSchema* pSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta);// todo: tags mismatch, tags not completed
|
SSchema* pSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta);// todo: tags mismatch, tags not completed
|
||||||
|
@ -587,8 +570,8 @@ static bool checkForIdenticalTagVal(SQueryInfo* pQueryInfo, SJoinSupporter* p1,
|
||||||
STidTags* p = (STidTags*) varDataVal(p1->pIdTagList + i * p1->tagSize);
|
STidTags* p = (STidTags*) varDataVal(p1->pIdTagList + i * p1->tagSize);
|
||||||
|
|
||||||
if (doCompare(prev->tag, p->tag, pColSchema->type, pColSchema->bytes) == 0) {
|
if (doCompare(prev->tag, p->tag, pColSchema->type, pColSchema->bytes) == 0) {
|
||||||
tscError("%p join tags have same value for different table, free all sub SqlObj and quit", pSql);
|
tscError("%p join tags have same value for different table, free all sub SqlObj and quit", pPSqlObj);
|
||||||
p1->pState->code = TSDB_CODE_QRY_DUP_JOIN_KEY;
|
pPSqlObj->res.code = TSDB_CODE_QRY_DUP_JOIN_KEY;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -596,8 +579,8 @@ static bool checkForIdenticalTagVal(SQueryInfo* pQueryInfo, SJoinSupporter* p1,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getIntersectionOfTagVal(SQueryInfo* pQueryInfo, SSqlObj* pParentSql, SArray** s1, SArray** s2) {
|
static void getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pParentSql, SArray** s1, SArray** s2) {
|
||||||
tscTrace("%p all subqueries retrieve tags complete, do tags match", pParentSql);
|
tscTrace("%p all subqueries retrieve <tid, tags> complete, do tags match", pParentSql);
|
||||||
|
|
||||||
SJoinSupporter* p1 = pParentSql->pSubs[0]->param;
|
SJoinSupporter* p1 = pParentSql->pSubs[0]->param;
|
||||||
SJoinSupporter* p2 = pParentSql->pSubs[1]->param;
|
SJoinSupporter* p2 = pParentSql->pSubs[1]->param;
|
||||||
|
@ -613,7 +596,7 @@ static void getIntersectionOfTagVal(SQueryInfo* pQueryInfo, SSqlObj* pParentSql,
|
||||||
*s1 = taosArrayInit(p1->num, p1->tagSize);
|
*s1 = taosArrayInit(p1->num, p1->tagSize);
|
||||||
*s2 = taosArrayInit(p2->num, p2->tagSize);
|
*s2 = taosArrayInit(p2->num, p2->tagSize);
|
||||||
|
|
||||||
if (!(checkForIdenticalTagVal(pQueryInfo, p1, pParentSql) && checkForIdenticalTagVal(pQueryInfo, p2, pParentSql))) {
|
if (!(checkForDuplicateTagVal(pQueryInfo, p1, pParentSql) && checkForDuplicateTagVal(pQueryInfo, p2, pParentSql))) {
|
||||||
freeJoinSubqueryObj(pParentSql);
|
freeJoinSubqueryObj(pParentSql);
|
||||||
pParentSql->res.code = TSDB_CODE_QRY_DUP_JOIN_KEY;
|
pParentSql->res.code = TSDB_CODE_QRY_DUP_JOIN_KEY;
|
||||||
tscQueueAsyncRes(pParentSql);
|
tscQueueAsyncRes(pParentSql);
|
||||||
|
@ -642,7 +625,7 @@ static void getIntersectionOfTagVal(SQueryInfo* pQueryInfo, SSqlObj* pParentSql,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
|
static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRows) {
|
||||||
SJoinSupporter* pSupporter = (SJoinSupporter*)param;
|
SJoinSupporter* pSupporter = (SJoinSupporter*)param;
|
||||||
|
|
||||||
SSqlObj* pParentSql = pSupporter->pObj;
|
SSqlObj* pParentSql = pSupporter->pObj;
|
||||||
|
@ -652,25 +635,53 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
|
||||||
SSqlRes* pRes = &pSql->res;
|
SSqlRes* pRes = &pSql->res;
|
||||||
|
|
||||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
|
assert(TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_TAG_FILTER_QUERY));
|
||||||
|
|
||||||
// response of tag retrieve
|
// check for the error code firstly
|
||||||
if (TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_TAG_FILTER_QUERY)) {
|
if (taos_errno(pSql) != TSDB_CODE_SUCCESS) {
|
||||||
// todo handle error
|
// todo retry if other subqueries are not failed
|
||||||
|
|
||||||
if (numOfRows == 0 || pRes->completed) {
|
assert(numOfRows < 0 && numOfRows == taos_errno(pSql));
|
||||||
if (numOfRows > 0) {
|
tscError("%p sub query failed, code:%s, index:%d", pSql, tstrerror(numOfRows), pSupporter->subqueryIndex);
|
||||||
size_t validLen = pSupporter->tagSize * pRes->numOfRows;
|
|
||||||
|
|
||||||
size_t length = pSupporter->totalLen + validLen;
|
pParentSql->res.code = numOfRows;
|
||||||
char* tmp = realloc(pSupporter->pIdTagList, length);
|
quitAllSubquery(pParentSql, pSupporter);
|
||||||
assert(tmp != NULL);
|
|
||||||
pSupporter->pIdTagList = tmp;
|
|
||||||
|
|
||||||
memcpy(pSupporter->pIdTagList + pSupporter->totalLen,pRes->data, validLen);
|
tscQueueAsyncRes(pParentSql);
|
||||||
pSupporter->totalLen += validLen;
|
return;
|
||||||
pSupporter->num += pRes->numOfRows;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// keep the results in memory
|
||||||
|
if (numOfRows > 0) {
|
||||||
|
size_t validLen = pSupporter->tagSize * pRes->numOfRows;
|
||||||
|
size_t length = pSupporter->totalLen + validLen;
|
||||||
|
|
||||||
|
// todo handle memory error
|
||||||
|
char* tmp = realloc(pSupporter->pIdTagList, length);
|
||||||
|
if (tmp == NULL) {
|
||||||
|
tscError("%p failed to malloc memory", pSql);
|
||||||
|
|
||||||
|
pParentSql->res.code = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
quitAllSubquery(pParentSql, pSupporter);
|
||||||
|
|
||||||
|
tscQueueAsyncRes(pParentSql);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pSupporter->pIdTagList = tmp;
|
||||||
|
|
||||||
|
memcpy(pSupporter->pIdTagList + pSupporter->totalLen, pRes->data, validLen);
|
||||||
|
pSupporter->totalLen += validLen;
|
||||||
|
pSupporter->num += pRes->numOfRows;
|
||||||
|
|
||||||
|
// query not completed, continue to retrieve tid + tag tuples
|
||||||
|
if (!pRes->completed) {
|
||||||
|
taos_fetch_rows_a(tres, tidTagRetrieveCallback, param);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// data in current vnode has all returned to client, try next vnode if exits
|
||||||
// <tid + tag> tuples have been retrieved to client, try <tid + tag> tuples from the next vnode
|
// <tid + tag> tuples have been retrieved to client, try <tid + tag> tuples from the next vnode
|
||||||
if (hasMoreVnodesToTry(pSql)) {
|
if (hasMoreVnodesToTry(pSql)) {
|
||||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||||
|
@ -680,8 +691,7 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
|
||||||
assert(pTableMetaInfo->vgroupIndex < totalVgroups);
|
assert(pTableMetaInfo->vgroupIndex < totalVgroups);
|
||||||
|
|
||||||
tscTrace("%p tid_tag from vgroup index:%d completed, try next vgroup:%d. total vgroups:%d. current numOfRes:%d",
|
tscTrace("%p tid_tag from vgroup index:%d completed, try next vgroup:%d. total vgroups:%d. current numOfRes:%d",
|
||||||
pSql, pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups,
|
pSql, pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups, pSupporter->num);
|
||||||
pSupporter->num);
|
|
||||||
|
|
||||||
pCmd->command = TSDB_SQL_SELECT;
|
pCmd->command = TSDB_SQL_SELECT;
|
||||||
tscResetForNextRetrieve(&pSql->res);
|
tscResetForNextRetrieve(&pSql->res);
|
||||||
|
@ -692,23 +702,20 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfTotal = pSupporter->pState->numOfTotal;
|
// no data exists in next vnode, mark the <tid, tags> query completed
|
||||||
int32_t finished = atomic_add_fetch_32(&pSupporter->pState->numOfCompleted, 1);
|
// only when there is no subquery exits any more, proceeds to get the intersect of the <tid, tags> tuple sets.
|
||||||
if (finished < numOfTotal) {
|
if (atomic_sub_fetch_32(&pSupporter->pState->numOfRemain, 1) > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// all subquery are returned, start to compare the tags
|
|
||||||
assert(finished == numOfTotal);
|
|
||||||
|
|
||||||
SArray *s1 = NULL, *s2 = NULL;
|
SArray *s1 = NULL, *s2 = NULL;
|
||||||
getIntersectionOfTagVal(pQueryInfo, pParentSql, &s1, &s2);
|
getIntersectionOfTableTuple(pQueryInfo, pParentSql, &s1, &s2);
|
||||||
|
|
||||||
if (taosArrayGetSize(s1) == 0 || taosArrayGetSize(s2) == 0) { // no results,return.
|
if (taosArrayGetSize(s1) == 0 || taosArrayGetSize(s2) == 0) { // no results,return.
|
||||||
tscTrace("%p free all sub SqlObj and quit", pParentSql);
|
tscTrace("%p free all sub SqlObj and quit", pParentSql);
|
||||||
freeJoinSubqueryObj(pParentSql);
|
freeJoinSubqueryObj(pParentSql);
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
|
// proceed to for ts_comp query
|
||||||
SSqlCmd* pSubCmd1 = &pParentSql->pSubs[0]->cmd;
|
SSqlCmd* pSubCmd1 = &pParentSql->pSubs[0]->cmd;
|
||||||
SSqlCmd* pSubCmd2 = &pParentSql->pSubs[1]->cmd;
|
SSqlCmd* pSubCmd2 = &pParentSql->pSubs[1]->cmd;
|
||||||
|
|
||||||
|
@ -720,50 +727,41 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
|
||||||
STableMetaInfo* pTableMetaInfo2 = tscGetMetaInfo(pQueryInfo2, 0);
|
STableMetaInfo* pTableMetaInfo2 = tscGetMetaInfo(pQueryInfo2, 0);
|
||||||
tscBuildVgroupTableInfo(pParentSql, pTableMetaInfo2, s2);
|
tscBuildVgroupTableInfo(pParentSql, pTableMetaInfo2, s2);
|
||||||
|
|
||||||
pSupporter->pState->numOfCompleted = 0;
|
|
||||||
pSupporter->pState->code = 0;
|
|
||||||
pSupporter->pState->numOfTotal = 2;
|
pSupporter->pState->numOfTotal = 2;
|
||||||
|
pSupporter->pState->numOfRemain = pSupporter->pState->numOfTotal;
|
||||||
|
|
||||||
for (int32_t m = 0; m < pParentSql->numOfSubs; ++m) {
|
for (int32_t m = 0; m < pParentSql->numOfSubs; ++m) {
|
||||||
SSqlObj* psub = pParentSql->pSubs[m];
|
SSqlObj* sub = pParentSql->pSubs[m];
|
||||||
issueTSCompQuery(psub, psub->param, pParentSql);
|
issueTSCompQuery(sub, sub->param, pParentSql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
taosArrayDestroy(s1);
|
||||||
if (numOfRows < 0) { // error
|
taosArrayDestroy(s2);
|
||||||
pSupporter->pState->code = numOfRows;
|
}
|
||||||
quitAllSubquery(pParentSql, pSupporter);
|
|
||||||
|
static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRows) {
|
||||||
|
SJoinSupporter* pSupporter = (SJoinSupporter*)param;
|
||||||
|
|
||||||
|
SSqlObj* pParentSql = pSupporter->pObj;
|
||||||
|
|
||||||
|
SSqlObj* pSql = (SSqlObj*)tres;
|
||||||
|
SSqlCmd* pCmd = &pSql->cmd;
|
||||||
|
SSqlRes* pRes = &pSql->res;
|
||||||
|
|
||||||
|
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
|
assert(!TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_SEC_STAGE));
|
||||||
|
|
||||||
|
// check for the error code firstly
|
||||||
|
if (taos_errno(pSql) != TSDB_CODE_SUCCESS) {
|
||||||
|
// todo retry if other subqueries are not failed yet
|
||||||
|
assert(numOfRows < 0 && numOfRows == taos_errno(pSql));
|
||||||
|
tscError("%p sub query failed, code:%s, index:%d", pSql, tstrerror(numOfRows), pSupporter->subqueryIndex);
|
||||||
|
|
||||||
pParentSql->res.code = numOfRows;
|
pParentSql->res.code = numOfRows;
|
||||||
tscQueueAsyncRes(pParentSql);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t length = pSupporter->totalLen + pRes->rspLen;
|
|
||||||
assert(length > 0);
|
|
||||||
|
|
||||||
char* tmp = realloc(pSupporter->pIdTagList, length);
|
|
||||||
assert(tmp != NULL);
|
|
||||||
|
|
||||||
pSupporter->pIdTagList = tmp;
|
|
||||||
|
|
||||||
memcpy(pSupporter->pIdTagList, pRes->data, pRes->rspLen);
|
|
||||||
pSupporter->totalLen += pRes->rspLen;
|
|
||||||
pSupporter->num += pRes->numOfRows;
|
|
||||||
|
|
||||||
// continue retrieve data from vnode
|
|
||||||
taos_fetch_rows_a(tres, joinRetrieveCallback, param);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_SEC_STAGE)) {
|
|
||||||
if (numOfRows < 0) {
|
|
||||||
tscError("%p sub query failed, code:%s, index:%d", pSql, tstrerror(numOfRows), pSupporter->subqueryIndex);
|
|
||||||
pSupporter->pState->code = numOfRows;
|
|
||||||
quitAllSubquery(pParentSql, pSupporter);
|
quitAllSubquery(pParentSql, pSupporter);
|
||||||
|
|
||||||
|
tscQueueAsyncRes(pParentSql);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -776,8 +774,9 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
|
||||||
if (pBuf == NULL) { // in error process, close the fd
|
if (pBuf == NULL) { // in error process, close the fd
|
||||||
tscError("%p invalid ts comp file from vnode, abort subquery, file size:%d", pSql, numOfRows);
|
tscError("%p invalid ts comp file from vnode, abort subquery, file size:%d", pSql, numOfRows);
|
||||||
|
|
||||||
pSupporter->pState->code = TSDB_CODE_TSC_APP_ERROR; // todo set the informative code
|
pParentSql->res.code = TAOS_SYSTEM_ERROR(errno);
|
||||||
quitAllSubquery(pParentSql, pSupporter);
|
tscQueueAsyncRes(pParentSql);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -791,9 +790,18 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
|
||||||
tsBufMerge(pSupporter->pTSBuf, pBuf, pTableMetaInfo->vgroupIndex);
|
tsBufMerge(pSupporter->pTSBuf, pBuf, pTableMetaInfo->vgroupIndex);
|
||||||
tsBufDestory(pBuf);
|
tsBufDestory(pBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// continue to retrieve ts-comp data from vnode
|
||||||
|
if (!pRes->completed) {
|
||||||
|
getTmpfilePath("ts-join", pSupporter->path);
|
||||||
|
pSupporter->f = fopen(pSupporter->path, "w");
|
||||||
|
pRes->row = pRes->numOfRows;
|
||||||
|
|
||||||
|
taos_fetch_rows_a(tres, tsCompRetrieveCallback, param);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pRes->completed) {
|
|
||||||
if (hasMoreVnodesToTry(pSql)) {
|
if (hasMoreVnodesToTry(pSql)) {
|
||||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||||
|
|
||||||
|
@ -810,6 +818,8 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
|
||||||
|
|
||||||
assert(pSupporter->f == NULL);
|
assert(pSupporter->f == NULL);
|
||||||
getTmpfilePath("ts-join", pSupporter->path);
|
getTmpfilePath("ts-join", pSupporter->path);
|
||||||
|
|
||||||
|
// TODO check for failure
|
||||||
pSupporter->f = fopen(pSupporter->path, "w");
|
pSupporter->f = fopen(pSupporter->path, "w");
|
||||||
pRes->row = pRes->numOfRows;
|
pRes->row = pRes->numOfRows;
|
||||||
|
|
||||||
|
@ -817,21 +827,51 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
|
||||||
pSql->fp = tscJoinQueryCallback;
|
pSql->fp = tscJoinQueryCallback;
|
||||||
tscProcessSql(pSql);
|
tscProcessSql(pSql);
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
tSIntersectionAndLaunchSecQuery(pSupporter, pSql);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { // open a new file to save the incoming result
|
if (atomic_sub_fetch_32(&pSupporter->pState->numOfRemain, 1) > 0) {
|
||||||
getTmpfilePath("ts-join", pSupporter->path);
|
return;
|
||||||
pSupporter->f = fopen(pSupporter->path, "w");
|
|
||||||
pRes->row = pRes->numOfRows;
|
|
||||||
|
|
||||||
taos_fetch_rows_a(tres, joinRetrieveCallback, param);
|
|
||||||
}
|
}
|
||||||
} else { // secondary stage retrieve, driven by taos_fetch_row or other functions
|
|
||||||
if (numOfRows < 0) {
|
tscTrace("%p all subquery retrieve ts complete, do ts block intersect", pParentSql);
|
||||||
pSupporter->pState->code = numOfRows;
|
|
||||||
tscError("%p retrieve failed, code:%s, index:%d", pSql, tstrerror(numOfRows), pSupporter->subqueryIndex);
|
// proceeds to launched secondary query to retrieve final data
|
||||||
|
SJoinSupporter* p1 = pParentSql->pSubs[0]->param;
|
||||||
|
SJoinSupporter* p2 = pParentSql->pSubs[1]->param;
|
||||||
|
|
||||||
|
STimeWindow win = TSWINDOW_INITIALIZER;
|
||||||
|
int64_t num = doTSBlockIntersect(pParentSql, p1, p2, &win);
|
||||||
|
if (num <= 0) { // no result during ts intersect
|
||||||
|
tscTrace("%p no results generated in ts intersection, free all sub SqlObj and quit", pParentSql);
|
||||||
|
freeJoinSubqueryObj(pParentSql);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// launch the query the retrieve actual results from vnode along with the filtered timestamp
|
||||||
|
SQueryInfo* pPQueryInfo = tscGetQueryInfoDetail(&pParentSql->cmd, pParentSql->cmd.clauseIndex);
|
||||||
|
updateQueryTimeRange(pPQueryInfo, &win);
|
||||||
|
tscLaunchSecondPhaseSubqueries(pParentSql);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfRows) {
|
||||||
|
SJoinSupporter* pSupporter = (SJoinSupporter*)param;
|
||||||
|
|
||||||
|
SSqlObj* pParentSql = pSupporter->pObj;
|
||||||
|
SSubqueryState* pState = pSupporter->pState;
|
||||||
|
|
||||||
|
SSqlObj* pSql = (SSqlObj*)tres;
|
||||||
|
SSqlCmd* pCmd = &pSql->cmd;
|
||||||
|
SSqlRes* pRes = &pSql->res;
|
||||||
|
|
||||||
|
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
|
|
||||||
|
// TODO put to async res?
|
||||||
|
if (taos_errno(pSql) != TSDB_CODE_SUCCESS) {
|
||||||
|
assert(numOfRows == taos_errno(pSql));
|
||||||
|
|
||||||
|
pParentSql->res.code = numOfRows;
|
||||||
|
tscError("%p retrieve failed, index:%d, code:%s", pSql, pSupporter->subqueryIndex, tstrerror(numOfRows));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numOfRows >= 0) {
|
if (numOfRows >= 0) {
|
||||||
|
@ -844,8 +884,8 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
|
||||||
|
|
||||||
// for projection query, need to try next vnode if current vnode is exhausted
|
// for projection query, need to try next vnode if current vnode is exhausted
|
||||||
if ((++pTableMetaInfo->vgroupIndex) < pTableMetaInfo->vgroupList->numOfVgroups) {
|
if ((++pTableMetaInfo->vgroupIndex) < pTableMetaInfo->vgroupList->numOfVgroups) {
|
||||||
pSupporter->pState->numOfCompleted = 0;
|
pState->numOfRemain = 1;
|
||||||
pSupporter->pState->numOfTotal = 1;
|
pState->numOfTotal = 1;
|
||||||
|
|
||||||
pSql->cmd.command = TSDB_SQL_SELECT;
|
pSql->cmd.command = TSDB_SQL_SELECT;
|
||||||
pSql->fp = tscJoinQueryCallback;
|
pSql->fp = tscJoinQueryCallback;
|
||||||
|
@ -855,16 +895,14 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfTotal = pSupporter->pState->numOfTotal;
|
if (atomic_sub_fetch_32(&pState->numOfRemain, 1) > 0) {
|
||||||
int32_t finished = atomic_add_fetch_32(&pSupporter->pState->numOfCompleted, 1);
|
tscTrace("%p sub:%p completed, remain:%d, total:%d", pParentSql, tres, pState->numOfRemain, pState->numOfTotal);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (finished >= numOfTotal) {
|
tscTrace("%p all %d secondary subqueries retrieval completed, code:%d", tres, pState->numOfTotal, pParentSql->res.code);
|
||||||
assert(finished == numOfTotal);
|
|
||||||
tscTrace("%p all %d secondary subquery retrieves completed, global code:%d", tres, numOfTotal,
|
|
||||||
pParentSql->res.code);
|
|
||||||
|
|
||||||
if (pSupporter->pState->code != TSDB_CODE_SUCCESS) {
|
if (pParentSql->res.code != TSDB_CODE_SUCCESS) {
|
||||||
pParentSql->res.code = pSupporter->pState->code;
|
|
||||||
freeJoinSubqueryObj(pParentSql);
|
freeJoinSubqueryObj(pParentSql);
|
||||||
pParentSql->res.completed = true;
|
pParentSql->res.completed = true;
|
||||||
}
|
}
|
||||||
|
@ -881,10 +919,6 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
|
||||||
|
|
||||||
// data has retrieved to client, build the join results
|
// data has retrieved to client, build the join results
|
||||||
tscBuildResFromSubqueries(pParentSql);
|
tscBuildResFromSubqueries(pParentSql);
|
||||||
} else {
|
|
||||||
tscTrace("%p sub:%p completed, completed:%d, total:%d", pParentSql, tres, finished, numOfTotal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static SJoinSupporter* tscUpdateSubqueryStatus(SSqlObj* pSql, int32_t numOfFetch) {
|
static SJoinSupporter* tscUpdateSubqueryStatus(SSqlObj* pSql, int32_t numOfFetch) {
|
||||||
|
@ -902,7 +936,7 @@ static SJoinSupporter* tscUpdateSubqueryStatus(SSqlObj* pSql, int32_t numOfFetch
|
||||||
}
|
}
|
||||||
|
|
||||||
pState->numOfTotal = pSql->numOfSubs;
|
pState->numOfTotal = pSql->numOfSubs;
|
||||||
pState->numOfCompleted = pSql->numOfSubs - numOfFetch;
|
pState->numOfRemain = numOfFetch;
|
||||||
|
|
||||||
return pSupporter;
|
return pSupporter;
|
||||||
}
|
}
|
||||||
|
@ -990,7 +1024,7 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql) {
|
||||||
pSupporter->subqueryIndex, pTableMetaInfo->vgroupIndex);
|
pSupporter->subqueryIndex, pTableMetaInfo->vgroupIndex);
|
||||||
|
|
||||||
tscResetForNextRetrieve(pRes1);
|
tscResetForNextRetrieve(pRes1);
|
||||||
pSql1->fp = joinRetrieveCallback;
|
pSql1->fp = joinRetrieveFinalResCallback;
|
||||||
|
|
||||||
if (pCmd1->command < TSDB_SQL_LOCAL) {
|
if (pCmd1->command < TSDB_SQL_LOCAL) {
|
||||||
pCmd1->command = (pCmd1->command > TSDB_SQL_MGMT) ? TSDB_SQL_RETRIEVE : TSDB_SQL_FETCH;
|
pCmd1->command = (pCmd1->command > TSDB_SQL_MGMT) ? TSDB_SQL_RETRIEVE : TSDB_SQL_FETCH;
|
||||||
|
@ -1008,8 +1042,9 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
|
||||||
|
|
||||||
tscTrace("%p all subquery response, retrieve data", pSql);
|
tscTrace("%p all subquery response, retrieve data", pSql);
|
||||||
|
|
||||||
|
// the column transfer support struct has been built
|
||||||
if (pRes->pColumnIndex != NULL) {
|
if (pRes->pColumnIndex != NULL) {
|
||||||
return; // the column transfer support struct has been built
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
|
@ -1047,43 +1082,54 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
|
||||||
SSqlObj* pSql = (SSqlObj*)tres;
|
SSqlObj* pSql = (SSqlObj*)tres;
|
||||||
|
|
||||||
SJoinSupporter* pSupporter = (SJoinSupporter*)param;
|
SJoinSupporter* pSupporter = (SJoinSupporter*)param;
|
||||||
|
SSqlObj* pParentSql = pSupporter->pObj;
|
||||||
|
|
||||||
// There is only one subquery and table for each subquery.
|
// There is only one subquery and table for each subquery.
|
||||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
||||||
assert(pQueryInfo->numOfTables == 1 && pSql->cmd.numOfClause == 1);
|
assert(pQueryInfo->numOfTables == 1 && pSql->cmd.numOfClause == 1);
|
||||||
|
|
||||||
if (!TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_SEC_STAGE)) {
|
// retrieve actual query results from vnode during the second stage join subquery
|
||||||
if (code != TSDB_CODE_SUCCESS) { // direct call joinRetrieveCallback and set the error code
|
if (pParentSql->res.code != TSDB_CODE_SUCCESS) {
|
||||||
joinRetrieveCallback(param, pSql, code);
|
tscError("%p abort query due to other subquery failure. code:%d, global code:%d", pSql, code, pParentSql->res.code);
|
||||||
} else { // first stage query, continue to retrieve compressed time stamp data
|
|
||||||
pSql->fp = joinRetrieveCallback;
|
|
||||||
pSql->cmd.command = TSDB_SQL_FETCH;
|
|
||||||
tscProcessSql(pSql);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else { // second stage join subquery
|
|
||||||
SSqlObj* pParentSql = pSupporter->pObj;
|
|
||||||
|
|
||||||
if (pSupporter->pState->code != TSDB_CODE_SUCCESS) {
|
|
||||||
tscError("%p abort query due to other subquery failure. code:%d, global code:%d", pSql, code,
|
|
||||||
pSupporter->pState->code);
|
|
||||||
quitAllSubquery(pParentSql, pSupporter);
|
quitAllSubquery(pParentSql, pSupporter);
|
||||||
|
tscQueueAsyncRes(pParentSql);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
// TODO here retry is required, not directly returns to client
|
||||||
tscError("%p sub query failed, code:%s, set global code:%s, index:%d", pSql, tstrerror(code), tstrerror(code),
|
if (taos_errno(pSql) != TSDB_CODE_SUCCESS) {
|
||||||
pSupporter->subqueryIndex);
|
assert(taos_errno(pSql) == code);
|
||||||
|
|
||||||
|
tscError("%p abort query, code:%d, global code:%d", pSql, code, pParentSql->res.code);
|
||||||
|
pParentSql->res.code = code;
|
||||||
|
|
||||||
pSupporter->pState->code = code;
|
|
||||||
quitAllSubquery(pParentSql, pSupporter);
|
quitAllSubquery(pParentSql, pSupporter);
|
||||||
} else {
|
tscQueueAsyncRes(pParentSql);
|
||||||
int32_t numOfTotal = pSupporter->pState->numOfTotal;
|
|
||||||
int32_t finished = atomic_add_fetch_32(&pSupporter->pState->numOfCompleted, 1);
|
|
||||||
|
|
||||||
if (finished >= numOfTotal) {
|
return;
|
||||||
assert(finished == numOfTotal);
|
}
|
||||||
|
|
||||||
|
// retrieve <tid, tag> tuples from vnode
|
||||||
|
if (TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_TAG_FILTER_QUERY)) {
|
||||||
|
pSql->fp = tidTagRetrieveCallback;
|
||||||
|
pSql->cmd.command = TSDB_SQL_FETCH;
|
||||||
|
tscProcessSql(pSql);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// retrieve ts_comp info from vnode
|
||||||
|
if (!TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_SEC_STAGE)) {
|
||||||
|
pSql->fp = tsCompRetrieveCallback;
|
||||||
|
pSql->cmd.command = TSDB_SQL_FETCH;
|
||||||
|
tscProcessSql(pSql);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// wait for the other subqueries response from vnode
|
||||||
|
if (atomic_sub_fetch_32(&pSupporter->pState->numOfRemain, 1) > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tscSetupOutputColumnIndex(pParentSql);
|
tscSetupOutputColumnIndex(pParentSql);
|
||||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||||
|
@ -1093,9 +1139,9 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
|
||||||
* data instead of returning to its invoker
|
* data instead of returning to its invoker
|
||||||
*/
|
*/
|
||||||
if (pTableMetaInfo->vgroupIndex > 0 && tscNonOrderedProjectionQueryOnSTable(pQueryInfo, 0)) {
|
if (pTableMetaInfo->vgroupIndex > 0 && tscNonOrderedProjectionQueryOnSTable(pQueryInfo, 0)) {
|
||||||
pSupporter->pState->numOfCompleted = 0; // reset the record value
|
pSupporter->pState->numOfRemain = pSupporter->pState->numOfTotal; // reset the record value
|
||||||
|
|
||||||
pSql->fp = joinRetrieveCallback; // continue retrieve data
|
pSql->fp = joinRetrieveFinalResCallback; // continue retrieve data
|
||||||
pSql->cmd.command = TSDB_SQL_FETCH;
|
pSql->cmd.command = TSDB_SQL_FETCH;
|
||||||
tscProcessSql(pSql);
|
tscProcessSql(pSql);
|
||||||
} else { // first retrieve from vnode during the secondary stage sub-query
|
} else { // first retrieve from vnode during the secondary stage sub-query
|
||||||
|
@ -1106,9 +1152,6 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
|
||||||
tscQueueAsyncRes(pParentSql);
|
tscQueueAsyncRes(pParentSql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1202,7 +1245,7 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
|
||||||
|
|
||||||
tscTrace(
|
tscTrace(
|
||||||
"%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, transfer to tid_tag query to retrieve (tableId, tags), "
|
"%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, transfer to tid_tag query to retrieve (tableId, tags), "
|
||||||
"exprInfo:%d, colList:%d, fieldsInfo:%d, tagIndex:%d, name:%s",
|
"exprInfo:%z, colList:%z, fieldsInfo:%d, tagIndex:%d, name:%s",
|
||||||
pSql, pNew, tableIndex, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, tscSqlExprNumOfExprs(pNewQueryInfo),
|
pSql, pNew, tableIndex, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, tscSqlExprNumOfExprs(pNewQueryInfo),
|
||||||
numOfCols, pNewQueryInfo->fieldsInfo.numOfOutput, index.columnIndex, pNewQueryInfo->pTableMetaInfo[0]->name);
|
numOfCols, pNewQueryInfo->fieldsInfo.numOfOutput, index.columnIndex, pNewQueryInfo->pTableMetaInfo[0]->name);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1236,8 +1279,8 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
|
||||||
size_t numOfCols = taosArrayGetSize(pNewQueryInfo->colList);
|
size_t numOfCols = taosArrayGetSize(pNewQueryInfo->colList);
|
||||||
|
|
||||||
tscTrace(
|
tscTrace(
|
||||||
"%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, transfer to ts_comp query to retrieve timestamps, "
|
"%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%u, transfer to ts_comp query to retrieve timestamps, "
|
||||||
"exprInfo:%d, colList:%d, fieldsInfo:%d, name:%s",
|
"exprInfo:%z, colList:%z, fieldsInfo:%d, name:%s",
|
||||||
pSql, pNew, tableIndex, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, tscSqlExprNumOfExprs(pNewQueryInfo),
|
pSql, pNew, tableIndex, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, tscSqlExprNumOfExprs(pNewQueryInfo),
|
||||||
numOfCols, pNewQueryInfo->fieldsInfo.numOfOutput, pNewQueryInfo->pTableMetaInfo[0]->name);
|
numOfCols, pNewQueryInfo->fieldsInfo.numOfOutput, pNewQueryInfo->pTableMetaInfo[0]->name);
|
||||||
}
|
}
|
||||||
|
@ -1257,6 +1300,7 @@ int32_t tscHandleMasterJoinQuery(SSqlObj* pSql) {
|
||||||
|
|
||||||
SSubqueryState *pState = calloc(1, sizeof(SSubqueryState));
|
SSubqueryState *pState = calloc(1, sizeof(SSubqueryState));
|
||||||
pState->numOfTotal = pQueryInfo->numOfTables;
|
pState->numOfTotal = pQueryInfo->numOfTables;
|
||||||
|
pState->numOfRemain = pState->numOfTotal;
|
||||||
|
|
||||||
tscTrace("%p start launch subquery, total:%d", pSql, pQueryInfo->numOfTables);
|
tscTrace("%p start launch subquery, total:%d", pSql, pQueryInfo->numOfTables);
|
||||||
for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
|
for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
|
||||||
|
@ -1264,7 +1308,7 @@ int32_t tscHandleMasterJoinQuery(SSqlObj* pSql) {
|
||||||
|
|
||||||
if (pSupporter == NULL) { // failed to create support struct, abort current query
|
if (pSupporter == NULL) { // failed to create support struct, abort current query
|
||||||
tscError("%p tableIndex:%d, failed to allocate join support object, abort further query", pSql, i);
|
tscError("%p tableIndex:%d, failed to allocate join support object, abort further query", pSql, i);
|
||||||
pState->numOfCompleted = pQueryInfo->numOfTables - i - 1;
|
pState->numOfRemain = i;
|
||||||
pSql->res.code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
pSql->res.code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
|
||||||
return pSql->res.code;
|
return pSql->res.code;
|
||||||
|
@ -1342,6 +1386,8 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
|
||||||
tscTrace("%p retrieved query data from %d vnode(s)", pSql, pSql->numOfSubs);
|
tscTrace("%p retrieved query data from %d vnode(s)", pSql, pSql->numOfSubs);
|
||||||
SSubqueryState *pState = calloc(1, sizeof(SSubqueryState));
|
SSubqueryState *pState = calloc(1, sizeof(SSubqueryState));
|
||||||
pState->numOfTotal = pSql->numOfSubs;
|
pState->numOfTotal = pSql->numOfSubs;
|
||||||
|
pState->numOfRemain = pSql->numOfSubs;
|
||||||
|
|
||||||
pRes->code = TSDB_CODE_SUCCESS;
|
pRes->code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
|
@ -1436,7 +1482,7 @@ static void tscFreeSubSqlObj(SRetrieveSupport *trsupport, SSqlObj *pSql) {
|
||||||
static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfRows);
|
static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfRows);
|
||||||
static void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numOfRows);
|
static void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numOfRows);
|
||||||
|
|
||||||
static void tscAbortFurtherRetryRetrieval(SRetrieveSupport *trsupport, TAOS_RES *tres, int32_t errCode) {
|
static void tscAbortFurtherRetryRetrieval(SRetrieveSupport *trsupport, TAOS_RES *tres, int32_t code) {
|
||||||
// set no disk space error info
|
// set no disk space error info
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
LPVOID lpMsgBuf;
|
LPVOID lpMsgBuf;
|
||||||
|
@ -1449,26 +1495,26 @@ static void tscAbortFurtherRetryRetrieval(SRetrieveSupport *trsupport, TAOS_RES
|
||||||
tscError("sub:%p failed to flush data to disk:reason:%s", tres, strerror(errno));
|
tscError("sub:%p failed to flush data to disk:reason:%s", tres, strerror(errno));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
trsupport->pState->code = -errCode;
|
SSqlObj* pParentSql = trsupport->pParentSqlObj;
|
||||||
|
|
||||||
|
pParentSql->res.code = code;
|
||||||
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
||||||
|
|
||||||
pthread_mutex_unlock(&trsupport->queryMutex);
|
pthread_mutex_unlock(&trsupport->queryMutex);
|
||||||
|
|
||||||
tscHandleSubqueryError(trsupport, tres, trsupport->pState->code);
|
tscHandleSubqueryError(trsupport, tres, pParentSql->res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numOfRows) {
|
void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numOfRows) {
|
||||||
SSqlObj *pPObj = trsupport->pParentSqlObj;
|
SSqlObj *pParentSql = trsupport->pParentSqlObj;
|
||||||
int32_t subqueryIndex = trsupport->subqueryIndex;
|
int32_t subqueryIndex = trsupport->subqueryIndex;
|
||||||
|
|
||||||
assert(pSql != NULL);
|
assert(pSql != NULL);
|
||||||
SSubqueryState* pState = trsupport->pState;
|
SSubqueryState* pState = trsupport->pState;
|
||||||
assert(pState->numOfCompleted < pState->numOfTotal && pState->numOfCompleted >= 0 &&
|
assert(pState->numOfRemain <= pState->numOfTotal && pState->numOfRemain >= 0 && pParentSql->numOfSubs == pState->numOfTotal);
|
||||||
pPObj->numOfSubs == pState->numOfTotal);
|
|
||||||
|
|
||||||
// retrieved in subquery failed. OR query cancelled in retrieve phase.
|
// retrieved in subquery failed. OR query cancelled in retrieve phase.
|
||||||
if (pState->code == TSDB_CODE_SUCCESS && pPObj->res.code != TSDB_CODE_SUCCESS) {
|
if (taos_errno(pSql) == TSDB_CODE_SUCCESS && pParentSql->res.code != TSDB_CODE_SUCCESS) {
|
||||||
pState->code = pPObj->res.code;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* kill current sub-query connection, which may retrieve data from vnodes;
|
* kill current sub-query connection, which may retrieve data from vnodes;
|
||||||
|
@ -1476,16 +1522,16 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
|
||||||
*/
|
*/
|
||||||
pSql->res.numOfRows = 0;
|
pSql->res.numOfRows = 0;
|
||||||
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY; // disable retry efforts
|
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY; // disable retry efforts
|
||||||
tscTrace("%p query is cancelled, sub:%p, orderOfSub:%d abort retrieve, code:%d", trsupport->pParentSqlObj, pSql,
|
tscTrace("%p query is cancelled, sub:%p, orderOfSub:%d abort retrieve, code:%d", pParentSql, pSql,
|
||||||
subqueryIndex, pState->code);
|
subqueryIndex, pParentSql->res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numOfRows >= 0) { // current query is successful, but other sub query failed, still abort current query.
|
if (numOfRows >= 0) { // current query is successful, but other sub query failed, still abort current query.
|
||||||
tscTrace("%p sub:%p retrieve numOfRows:%d,orderOfSub:%d", pPObj, pSql, numOfRows, subqueryIndex);
|
tscTrace("%p sub:%p retrieve numOfRows:%d,orderOfSub:%d", pParentSql, pSql, numOfRows, subqueryIndex);
|
||||||
tscError("%p sub:%p abort further retrieval due to other queries failure,orderOfSub:%d,code:%d", pPObj, pSql,
|
tscError("%p sub:%p abort further retrieval due to other queries failure,orderOfSub:%d,code:%d", pParentSql, pSql,
|
||||||
subqueryIndex, pState->code);
|
subqueryIndex, pParentSql->res.code);
|
||||||
} else {
|
} else {
|
||||||
if (trsupport->numOfRetry++ < MAX_NUM_OF_SUBQUERY_RETRY && pState->code == TSDB_CODE_SUCCESS) {
|
if (trsupport->numOfRetry++ < MAX_NUM_OF_SUBQUERY_RETRY && pParentSql->res.code == TSDB_CODE_SUCCESS) {
|
||||||
/*
|
/*
|
||||||
* current query failed, and the retry count is less than the available
|
* current query failed, and the retry count is less than the available
|
||||||
* count, retry query clear previous retrieved data, then launch a new sub query
|
* count, retry query clear previous retrieved data, then launch a new sub query
|
||||||
|
@ -1504,7 +1550,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
|
||||||
tscError("%p sub:%p failed to create new subquery sqlObj due to out of memory, abort retry",
|
tscError("%p sub:%p failed to create new subquery sqlObj due to out of memory, abort retry",
|
||||||
trsupport->pParentSqlObj, pSql);
|
trsupport->pParentSqlObj, pSql);
|
||||||
|
|
||||||
pState->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
pParentSql->res.code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1512,23 +1558,23 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
|
||||||
tscProcessSql(pNew);
|
tscProcessSql(pNew);
|
||||||
return;
|
return;
|
||||||
} else { // reach the maximum retry count, abort
|
} else { // reach the maximum retry count, abort
|
||||||
atomic_val_compare_exchange_32(&pState->code, TSDB_CODE_SUCCESS, numOfRows);
|
atomic_val_compare_exchange_32(&pParentSql->res.code, TSDB_CODE_SUCCESS, numOfRows);
|
||||||
tscError("%p sub:%p retrieve failed,code:%s,orderOfSub:%d failed.no more retry,set global code:%s", pPObj, pSql,
|
tscError("%p sub:%p retrieve failed,code:%s,orderOfSub:%d failed.no more retry,set global code:%s", pParentSql, pSql,
|
||||||
tstrerror(numOfRows), subqueryIndex, tstrerror(pState->code));
|
tstrerror(numOfRows), subqueryIndex, tstrerror(pParentSql->res.code));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfTotal = pState->numOfTotal;
|
int32_t remain = -1;
|
||||||
|
if ((remain = atomic_sub_fetch_32(&pState->numOfRemain, 1)) > 0) {
|
||||||
|
tscTrace("%p sub:%p orderOfSub:%d freed, finished subqueries:%d", pParentSql, pSql, trsupport->subqueryIndex,
|
||||||
|
pState->numOfTotal - remain);
|
||||||
|
|
||||||
int32_t finished = atomic_add_fetch_32(&pState->numOfCompleted, 1);
|
|
||||||
if (finished < numOfTotal) {
|
|
||||||
tscTrace("%p sub:%p orderOfSub:%d freed, finished subqueries:%d", pPObj, pSql, trsupport->subqueryIndex, finished);
|
|
||||||
return tscFreeSubSqlObj(trsupport, pSql);
|
return tscFreeSubSqlObj(trsupport, pSql);
|
||||||
}
|
}
|
||||||
|
|
||||||
// all subqueries are failed
|
// all subqueries are failed
|
||||||
tscError("%p retrieve from %d vnode(s) completed,code:%s.FAILED.", pPObj, pState->numOfTotal, tstrerror(pState->code));
|
tscError("%p retrieve from %d vnode(s) completed,code:%s.FAILED.", pParentSql, pState->numOfTotal,
|
||||||
pPObj->res.code = pState->code;
|
tstrerror(pParentSql->res.code));
|
||||||
|
|
||||||
// release allocated resource
|
// release allocated resource
|
||||||
tscLocalReducerEnvDestroy(trsupport->pExtMemBuffer, trsupport->pOrderDescriptor, trsupport->pFinalColModel,
|
tscLocalReducerEnvDestroy(trsupport->pExtMemBuffer, trsupport->pOrderDescriptor, trsupport->pFinalColModel,
|
||||||
|
@ -1538,13 +1584,13 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
|
||||||
tscFreeSubSqlObj(trsupport, pSql);
|
tscFreeSubSqlObj(trsupport, pSql);
|
||||||
|
|
||||||
// in case of second stage join subquery, invoke its callback function instead of regular QueueAsyncRes
|
// in case of second stage join subquery, invoke its callback function instead of regular QueueAsyncRes
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pPObj->cmd, 0);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pParentSql->cmd, 0);
|
||||||
|
|
||||||
if (!TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_SEC_STAGE)) {
|
if (!TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_SEC_STAGE)) {
|
||||||
(*pPObj->fp)(pPObj->param, pPObj, pPObj->res.code);
|
(*pParentSql->fp)(pParentSql->param, pParentSql, pParentSql->res.code);
|
||||||
} else { // regular super table query
|
} else { // regular super table query
|
||||||
if (pPObj->res.code != TSDB_CODE_SUCCESS) {
|
if (pParentSql->res.code != TSDB_CODE_SUCCESS) {
|
||||||
tscQueueAsyncRes(pPObj);
|
tscQueueAsyncRes(pParentSql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1590,14 +1636,11 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
|
||||||
return tscAbortFurtherRetryRetrieval(trsupport, pSql, TSDB_CODE_TSC_NO_DISKSPACE);
|
return tscAbortFurtherRetryRetrieval(trsupport, pSql, TSDB_CODE_TSC_NO_DISKSPACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep this value local variable, since the pState variable may be released by other threads, if atomic_add opertion
|
int32_t remain = -1;
|
||||||
// increases the finished value up to pState->numOfTotal value, which means all subqueries are completed.
|
if ((remain = atomic_sub_fetch_32(&pState->numOfRemain, 1)) > 0) {
|
||||||
// In this case, the comparsion between finished value and released pState->numOfTotal is not safe.
|
tscTrace("%p sub:%p orderOfSub:%d freed, finished subqueries:%d", pPObj, pSql, trsupport->subqueryIndex,
|
||||||
int32_t numOfTotal = pState->numOfTotal;
|
pState->numOfTotal - remain);
|
||||||
|
|
||||||
int32_t finished = atomic_add_fetch_32(&pState->numOfCompleted, 1);
|
|
||||||
if (finished < numOfTotal) {
|
|
||||||
tscTrace("%p sub:%p orderOfSub:%d freed, finished subqueries:%d", pPObj, pSql, trsupport->subqueryIndex, finished);
|
|
||||||
return tscFreeSubSqlObj(trsupport, pSql);
|
return tscFreeSubSqlObj(trsupport, pSql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1632,9 +1675,9 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
|
||||||
|
|
||||||
static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfRows) {
|
static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfRows) {
|
||||||
SRetrieveSupport *trsupport = (SRetrieveSupport *)param;
|
SRetrieveSupport *trsupport = (SRetrieveSupport *)param;
|
||||||
|
tOrderDescriptor *pDesc = trsupport->pOrderDescriptor;
|
||||||
int32_t idx = trsupport->subqueryIndex;
|
int32_t idx = trsupport->subqueryIndex;
|
||||||
SSqlObj * pPObj = trsupport->pParentSqlObj;
|
SSqlObj * pPObj = trsupport->pParentSqlObj;
|
||||||
tOrderDescriptor *pDesc = trsupport->pOrderDescriptor;
|
|
||||||
|
|
||||||
SSqlObj *pSql = (SSqlObj *)tres;
|
SSqlObj *pSql = (SSqlObj *)tres;
|
||||||
if (pSql == NULL) { // sql object has been released in error process, return immediately
|
if (pSql == NULL) { // sql object has been released in error process, return immediately
|
||||||
|
@ -1643,13 +1686,12 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
|
||||||
}
|
}
|
||||||
|
|
||||||
SSubqueryState* pState = trsupport->pState;
|
SSubqueryState* pState = trsupport->pState;
|
||||||
assert(pState->numOfCompleted < pState->numOfTotal && pState->numOfCompleted >= 0 &&
|
assert(pState->numOfRemain <= pState->numOfTotal && pState->numOfRemain >= 0 && pPObj->numOfSubs == pState->numOfTotal);
|
||||||
pPObj->numOfSubs == pState->numOfTotal);
|
|
||||||
|
|
||||||
// query process and cancel query process may execute at the same time
|
// query process and cancel query process may execute at the same time
|
||||||
pthread_mutex_lock(&trsupport->queryMutex);
|
pthread_mutex_lock(&trsupport->queryMutex);
|
||||||
|
|
||||||
if (numOfRows < 0 || pState->code < 0 || pPObj->res.code != TSDB_CODE_SUCCESS) {
|
if (numOfRows < 0 || pPObj->res.code != TSDB_CODE_SUCCESS) {
|
||||||
return tscHandleSubqueryError(trsupport, pSql, numOfRows);
|
return tscHandleSubqueryError(trsupport, pSql, numOfRows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1660,11 +1702,11 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
|
||||||
assert(pRes->numOfRows == numOfRows);
|
assert(pRes->numOfRows == numOfRows);
|
||||||
int64_t num = atomic_add_fetch_64(&pState->numOfRetrievedRows, numOfRows);
|
int64_t num = atomic_add_fetch_64(&pState->numOfRetrievedRows, numOfRows);
|
||||||
|
|
||||||
tscTrace("%p sub:%p retrieve numOfRows:%d totalNumOfRows:%d from ip:%s, orderOfSub:%d", pPObj, pSql,
|
tscTrace("%p sub:%p retrieve numOfRows:%" PRId64 " totalNumOfRows:%" PRIu64 " from ip:%s, orderOfSub:%d", pPObj, pSql,
|
||||||
pRes->numOfRows, pState->numOfRetrievedRows, pSql->ipList.fqdn[pSql->ipList.inUse], idx);
|
pRes->numOfRows, pState->numOfRetrievedRows, pSql->ipList.fqdn[pSql->ipList.inUse], idx);
|
||||||
|
|
||||||
if (num > tsMaxNumOfOrderedResults && tscIsProjectionQueryOnSTable(pQueryInfo, 0)) {
|
if (num > tsMaxNumOfOrderedResults && tscIsProjectionQueryOnSTable(pQueryInfo, 0)) {
|
||||||
tscError("%p sub:%p num of OrderedRes is too many, max allowed:%" PRId64 " , current:%" PRId64,
|
tscError("%p sub:%p num of OrderedRes is too many, max allowed:%" PRId32 " , current:%" PRId64,
|
||||||
pPObj, pSql, tsMaxNumOfOrderedResults, num);
|
pPObj, pSql, tsMaxNumOfOrderedResults, num);
|
||||||
tscAbortFurtherRetryRetrieval(trsupport, tres, TSDB_CODE_TSC_SORTED_RES_TOO_MANY);
|
tscAbortFurtherRetryRetrieval(trsupport, tres, TSDB_CODE_TSC_SORTED_RES_TOO_MANY);
|
||||||
return;
|
return;
|
||||||
|
@ -1689,6 +1731,7 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
|
||||||
pRes->numOfRows, pQueryInfo->groupbyExpr.orderType);
|
pRes->numOfRows, pQueryInfo->groupbyExpr.orderType);
|
||||||
if (ret < 0) { // set no disk space error info, and abort retry
|
if (ret < 0) { // set no disk space error info, and abort retry
|
||||||
tscAbortFurtherRetryRetrieval(trsupport, tres, TSDB_CODE_TSC_NO_DISKSPACE);
|
tscAbortFurtherRetryRetrieval(trsupport, tres, TSDB_CODE_TSC_NO_DISKSPACE);
|
||||||
|
pthread_mutex_unlock(&trsupport->queryMutex);
|
||||||
|
|
||||||
} else if (pRes->completed) {
|
} else if (pRes->completed) {
|
||||||
tscAllDataRetrievedFromDnode(trsupport, pSql);
|
tscAllDataRetrievedFromDnode(trsupport, pSql);
|
||||||
|
@ -1699,7 +1742,6 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
|
||||||
taos_fetch_rows_a(tres, tscRetrieveFromDnodeCallBack, param);
|
taos_fetch_rows_a(tres, tscRetrieveFromDnodeCallBack, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&trsupport->queryMutex);
|
|
||||||
} else { // all data has been retrieved to client
|
} else { // all data has been retrieved to client
|
||||||
tscAllDataRetrievedFromDnode(trsupport, pSql);
|
tscAllDataRetrievedFromDnode(trsupport, pSql);
|
||||||
}
|
}
|
||||||
|
@ -1738,18 +1780,16 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
|
||||||
SCMVgroupInfo* pVgroup = &pTableMetaInfo->vgroupList->vgroups[0];
|
SCMVgroupInfo* pVgroup = &pTableMetaInfo->vgroupList->vgroups[0];
|
||||||
|
|
||||||
SSubqueryState* pState = trsupport->pState;
|
SSubqueryState* pState = trsupport->pState;
|
||||||
assert(pState->numOfCompleted < pState->numOfTotal && pState->numOfCompleted >= 0 &&
|
assert(pState->numOfRemain <= pState->numOfTotal && pState->numOfRemain >= 0 && pParentSql->numOfSubs == pState->numOfTotal);
|
||||||
pParentSql->numOfSubs == pState->numOfTotal);
|
|
||||||
|
|
||||||
if (pParentSql->res.code != TSDB_CODE_SUCCESS || pState->code != TSDB_CODE_SUCCESS) {
|
// todo set error code
|
||||||
|
if (pParentSql->res.code != TSDB_CODE_SUCCESS) {
|
||||||
|
|
||||||
// stable query is killed, abort further retry
|
// stable query is killed, abort further retry
|
||||||
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
||||||
|
|
||||||
if (pParentSql->res.code != TSDB_CODE_SUCCESS) {
|
if (pParentSql->res.code != TSDB_CODE_SUCCESS) {
|
||||||
code = pParentSql->res.code;
|
code = pParentSql->res.code;
|
||||||
} else {
|
|
||||||
code = pState->code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tscTrace("%p query cancelled or failed, sub:%p, orderOfSub:%d abort, code:%s", pParentSql, pSql,
|
tscTrace("%p query cancelled or failed, sub:%p, orderOfSub:%d abort, code:%s", pParentSql, pSql,
|
||||||
|
@ -1766,7 +1806,7 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
if (trsupport->numOfRetry++ >= MAX_NUM_OF_SUBQUERY_RETRY) {
|
if (trsupport->numOfRetry++ >= MAX_NUM_OF_SUBQUERY_RETRY) {
|
||||||
tscTrace("%p sub:%p reach the max retry times, set global code:%s", pParentSql, pSql, tstrerror(code));
|
tscTrace("%p sub:%p reach the max retry times, set global code:%s", pParentSql, pSql, tstrerror(code));
|
||||||
atomic_val_compare_exchange_32(&pState->code, 0, code);
|
atomic_val_compare_exchange_32(&pParentSql->res.code, TSDB_CODE_SUCCESS, code);
|
||||||
} else { // does not reach the maximum retry time, go on
|
} else { // does not reach the maximum retry time, go on
|
||||||
tscTrace("%p sub:%p failed code:%s, retry:%d", pParentSql, pSql, tstrerror(code), trsupport->numOfRetry);
|
tscTrace("%p sub:%p failed code:%s, retry:%d", pParentSql, pSql, tstrerror(code), trsupport->numOfRetry);
|
||||||
|
|
||||||
|
@ -1776,7 +1816,7 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
|
||||||
tscError("%p sub:%p failed to create new subquery due to out of memory, abort retry, vgId:%d, orderOfSub:%d",
|
tscError("%p sub:%p failed to create new subquery due to out of memory, abort retry, vgId:%d, orderOfSub:%d",
|
||||||
trsupport->pParentSqlObj, pSql, pVgroup->vgId, trsupport->subqueryIndex);
|
trsupport->pParentSqlObj, pSql, pVgroup->vgId, trsupport->subqueryIndex);
|
||||||
|
|
||||||
pState->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
pParentSql->res.code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
||||||
} else {
|
} else {
|
||||||
SQueryInfo *pNewQueryInfo = tscGetQueryInfoDetail(&pNew->cmd, 0);
|
SQueryInfo *pNewQueryInfo = tscGetQueryInfoDetail(&pNew->cmd, 0);
|
||||||
|
@ -1789,11 +1829,11 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pState->code != TSDB_CODE_SUCCESS) { // at least one peer subquery failed, abort current query
|
if (pParentSql->res.code != TSDB_CODE_SUCCESS) { // at least one peer subquery failed, abort current query
|
||||||
tscTrace("%p sub:%p query failed,ip:%u,vgId:%d,orderOfSub:%d,global code:%d", pParentSql, pSql,
|
tscTrace("%p sub:%p query failed,ip:%s,vgId:%d,orderOfSub:%d,global code:%d", pParentSql, pSql,
|
||||||
pVgroup->ipAddr[0].fqdn, pVgroup->vgId, trsupport->subqueryIndex, pState->code);
|
pVgroup->ipAddr[0].fqdn, pVgroup->vgId, trsupport->subqueryIndex, pParentSql->res.code);
|
||||||
|
|
||||||
tscHandleSubqueryError(param, tres, pState->code);
|
tscHandleSubqueryError(param, tres, pParentSql->res.code);
|
||||||
} else { // success, proceed to retrieve data from dnode
|
} else { // success, proceed to retrieve data from dnode
|
||||||
tscTrace("%p sub:%p query complete, ip:%s, vgId:%d, orderOfSub:%d, retrieve data", trsupport->pParentSqlObj, pSql,
|
tscTrace("%p sub:%p query complete, ip:%s, vgId:%d, orderOfSub:%d, retrieve data", trsupport->pParentSqlObj, pSql,
|
||||||
pVgroup->ipAddr[0].fqdn, pVgroup->vgId, trsupport->subqueryIndex);
|
pVgroup->ipAddr[0].fqdn, pVgroup->vgId, trsupport->subqueryIndex);
|
||||||
|
@ -1813,7 +1853,6 @@ static void multiVnodeInsertMerge(void* param, TAOS_RES* tres, int numOfRows) {
|
||||||
SSqlCmd* pParentCmd = &pParentObj->cmd;
|
SSqlCmd* pParentCmd = &pParentObj->cmd;
|
||||||
|
|
||||||
SSubqueryState* pState = pSupporter->pState;
|
SSubqueryState* pState = pSupporter->pState;
|
||||||
int32_t total = pState->numOfTotal;
|
|
||||||
|
|
||||||
// increase the total inserted rows
|
// increase the total inserted rows
|
||||||
if (numOfRows > 0) {
|
if (numOfRows > 0) {
|
||||||
|
@ -1826,8 +1865,7 @@ static void multiVnodeInsertMerge(void* param, TAOS_RES* tres, int numOfRows) {
|
||||||
}
|
}
|
||||||
|
|
||||||
taos_free_result(tres);
|
taos_free_result(tres);
|
||||||
int32_t completed = atomic_add_fetch_32(&pState->numOfCompleted, 1);
|
if (atomic_sub_fetch_32(&pState->numOfRemain, 1) > 0) {
|
||||||
if (completed < total) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2157,5 +2195,3 @@ static bool tscHasRemainDataInSubqueryResultSet(SSqlObj *pSql) {
|
||||||
|
|
||||||
return hasData;
|
return hasData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -220,7 +220,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
|
||||||
|
|
||||||
if (strlen(tsLocale) == 0) { // locale does not set yet
|
if (strlen(tsLocale) == 0) { // locale does not set yet
|
||||||
char* defaultLocale = setlocale(LC_CTYPE, "");
|
char* defaultLocale = setlocale(LC_CTYPE, "");
|
||||||
strcpy(tsLocale, defaultLocale);
|
tstrncpy(tsLocale, defaultLocale, sizeof(tsLocale));
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the user specified locale
|
// set the user specified locale
|
||||||
|
@ -304,7 +304,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
|
||||||
assert(cfg != NULL);
|
assert(cfg != NULL);
|
||||||
|
|
||||||
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
|
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
|
||||||
strcpy(tsTimezone, pStr);
|
tstrncpy(tsTimezone, pStr, sizeof(tsTimezone));
|
||||||
tsSetTimeZone();
|
tsSetTimeZone();
|
||||||
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
|
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
|
||||||
tscTrace("timezone set:%s, input:%s by taos_options", tsTimezone, pStr);
|
tscTrace("timezone set:%s, input:%s by taos_options", tsTimezone, pStr);
|
||||||
|
|
|
@ -1840,7 +1840,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
|
||||||
size_t size = taosArrayGetSize(pNewQueryInfo->colList);
|
size_t size = taosArrayGetSize(pNewQueryInfo->colList);
|
||||||
|
|
||||||
tscTrace(
|
tscTrace(
|
||||||
"%p new subquery:%p, tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%d, colList:%d,"
|
"%p new subquery:%p, tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%z, colList:%z,"
|
||||||
"fieldInfo:%d, name:%s, qrang:%" PRId64 " - %" PRId64 " order:%d, limit:%" PRId64,
|
"fieldInfo:%d, name:%s, qrang:%" PRId64 " - %" PRId64 " order:%d, limit:%" PRId64,
|
||||||
pSql, pNew, tableIndex, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, tscSqlExprNumOfExprs(pNewQueryInfo),
|
pSql, pNew, tableIndex, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, tscSqlExprNumOfExprs(pNewQueryInfo),
|
||||||
size, pNewQueryInfo->fieldsInfo.numOfOutput, pFinalInfo->name, pNewQueryInfo->window.skey,
|
size, pNewQueryInfo->fieldsInfo.numOfOutput, pFinalInfo->name, pNewQueryInfo->window.skey,
|
||||||
|
@ -2002,7 +2002,7 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) {
|
||||||
|
|
||||||
int32_t totalVgroups = pTableMetaInfo->vgroupList->numOfVgroups;
|
int32_t totalVgroups = pTableMetaInfo->vgroupList->numOfVgroups;
|
||||||
while (++pTableMetaInfo->vgroupIndex < totalVgroups) {
|
while (++pTableMetaInfo->vgroupIndex < totalVgroups) {
|
||||||
tscTrace("%p results from vgroup index:%d completed, try next:%d. total vgroups:%d. current numOfRes:%d", pSql,
|
tscTrace("%p results from vgroup index:%d completed, try next:%d. total vgroups:%d. current numOfRes:%" PRId64, pSql,
|
||||||
pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups, pRes->numOfClauseTotal);
|
pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups, pRes->numOfClauseTotal);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -407,11 +407,7 @@ static void dnodeProcessStatusRsp(SRpcMsg *pMsg) {
|
||||||
pMnodeInfo->nodeId = htonl(pMnodeInfo->nodeId);
|
pMnodeInfo->nodeId = htonl(pMnodeInfo->nodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDMVgroupAccess *pVgAcccess = pStatusRsp->vgAccess;
|
vnodeSetAccess(pStatusRsp->vgAccess, pCfg->numOfVnodes);
|
||||||
for (int32_t i = 0; i < pCfg->numOfVnodes; ++i) {
|
|
||||||
pVgAcccess[i].vgId = htonl(pVgAcccess[i].vgId);
|
|
||||||
}
|
|
||||||
|
|
||||||
dnodeProcessModuleStatus(pCfg->moduleStatus);
|
dnodeProcessModuleStatus(pCfg->moduleStatus);
|
||||||
dnodeUpdateDnodeCfg(pCfg);
|
dnodeUpdateDnodeCfg(pCfg);
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ typedef enum {
|
||||||
typedef struct taosField {
|
typedef struct taosField {
|
||||||
char name[65];
|
char name[65];
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
uint16_t bytes;
|
int16_t bytes;
|
||||||
} TAOS_FIELD;
|
} TAOS_FIELD;
|
||||||
|
|
||||||
#ifdef _TD_GO_DLL_
|
#ifdef _TD_GO_DLL_
|
||||||
|
|
|
@ -209,8 +209,8 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
|
||||||
#define TSDB_MAX_SQL_SHOW_LEN 256
|
#define TSDB_MAX_SQL_SHOW_LEN 256
|
||||||
#define TSDB_MAX_ALLOWED_SQL_LEN (8*1024*1024U) // sql length should be less than 8mb
|
#define TSDB_MAX_ALLOWED_SQL_LEN (8*1024*1024U) // sql length should be less than 8mb
|
||||||
|
|
||||||
#define TSDB_MAX_BYTES_PER_ROW 65535
|
#define TSDB_MAX_BYTES_PER_ROW 16384
|
||||||
#define TSDB_MAX_TAGS_LEN 65535
|
#define TSDB_MAX_TAGS_LEN 16384
|
||||||
#define TSDB_MAX_TAGS 128
|
#define TSDB_MAX_TAGS 128
|
||||||
|
|
||||||
#define TSDB_AUTH_LEN 16
|
#define TSDB_AUTH_LEN 16
|
||||||
|
|
|
@ -113,12 +113,12 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_QUERY_ID, 0, 0x030C, "mnode inva
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_STREAM_ID, 0, 0x030D, "mnode invalid stream id")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_STREAM_ID, 0, 0x030D, "mnode invalid stream id")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_CONN_ID, 0, 0x030E, "mnode invalid connection")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_CONN_ID, 0, 0x030E, "mnode invalid connection")
|
||||||
|
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_OBJ_ALREADY_THERE, 0, 0x0320, "[sdb] object already there")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_OBJ_ALREADY_THERE, 0, 0x0320, "sdb object already there")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_ERROR, 0, 0x0321, "[sdb] app error")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_ERROR, 0, 0x0321, "sdb app error")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE, 0, 0x0322, "[sdb] invalid table type")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE, 0, 0x0322, "sdb invalid table type")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_OBJ_NOT_THERE, 0, 0x0323, "[sdb] object not there")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_OBJ_NOT_THERE, 0, 0x0323, "sdb object not there")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_INVAID_META_ROW, 0, 0x0324, "[sdb] invalid meta row")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_INVAID_META_ROW, 0, 0x0324, "sdb invalid meta row")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_INVAID_KEY_TYPE, 0, 0x0325, "[sdb] invalid key type")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_INVAID_KEY_TYPE, 0, 0x0325, "sdb invalid key type")
|
||||||
|
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_ALREADY_EXIST, 0, 0x0330, "mnode dnode already exist")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_ALREADY_EXIST, 0, 0x0330, "mnode dnode already exist")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_NOT_EXIST, 0, 0x0331, "mnode dnode not exist")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_NOT_EXIST, 0, 0x0331, "mnode dnode not exist")
|
||||||
|
@ -179,6 +179,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_DISK_PERMISSIONS, 0, 0x0506, "vnode no d
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_SUCH_FILE_OR_DIR, 0, 0x0507, "vnode no such file or directory")
|
TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_SUCH_FILE_OR_DIR, 0, 0x0507, "vnode no such file or directory")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_OUT_OF_MEMORY, 0, 0x0508, "vnode out of memory")
|
TAOS_DEFINE_ERROR(TSDB_CODE_VND_OUT_OF_MEMORY, 0, 0x0508, "vnode out of memory")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_APP_ERROR, 0, 0x0509, "vnode app error")
|
TAOS_DEFINE_ERROR(TSDB_CODE_VND_APP_ERROR, 0, 0x0509, "vnode app error")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_WRITE_AUTH, 0, 0x0214, "vnode no write auth")
|
||||||
|
|
||||||
// tsdb
|
// tsdb
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_TABLE_ID, 0, 0x0600, "tsdb invalid table id")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_TABLE_ID, 0, 0x0600, "tsdb invalid table id")
|
||||||
|
|
|
@ -543,6 +543,7 @@ typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
uint32_t moduleStatus;
|
uint32_t moduleStatus;
|
||||||
uint32_t numOfVnodes;
|
uint32_t numOfVnodes;
|
||||||
|
uint32_t reserved;
|
||||||
} SDMDnodeCfg;
|
} SDMDnodeCfg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -58,6 +58,7 @@ void* vnodeGetWal(void *pVnode);
|
||||||
|
|
||||||
int32_t vnodeProcessWrite(void *pVnode, int qtype, void *pHead, void *item);
|
int32_t vnodeProcessWrite(void *pVnode, int qtype, void *pHead, void *item);
|
||||||
void vnodeBuildStatusMsg(void * param);
|
void vnodeBuildStatusMsg(void * param);
|
||||||
|
void vnodeSetAccess(SDMVgroupAccess *pAccess, int32_t numOfVnodes);
|
||||||
|
|
||||||
int32_t vnodeProcessRead(void *pVnode, SReadMsg *pReadMsg);
|
int32_t vnodeProcessRead(void *pVnode, SReadMsg *pReadMsg);
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,8 @@ typedef struct SVgObj {
|
||||||
int32_t lbDnodeId;
|
int32_t lbDnodeId;
|
||||||
int32_t lbTime;
|
int32_t lbTime;
|
||||||
int8_t inUse;
|
int8_t inUse;
|
||||||
int8_t reserved[13];
|
int8_t accessState;
|
||||||
|
int8_t reserved[12];
|
||||||
int8_t updateEnd[1];
|
int8_t updateEnd[1];
|
||||||
int32_t refCount;
|
int32_t refCount;
|
||||||
struct SVgObj *prev, *next;
|
struct SVgObj *prev, *next;
|
||||||
|
|
|
@ -34,7 +34,8 @@ void mnodeUpdateAllDbVgroups(SDbObj *pAlterDb);
|
||||||
|
|
||||||
void * mnodeGetNextVgroup(void *pIter, SVgObj **pVgroup);
|
void * mnodeGetNextVgroup(void *pIter, SVgObj **pVgroup);
|
||||||
void mnodeUpdateVgroup(SVgObj *pVgroup);
|
void mnodeUpdateVgroup(SVgObj *pVgroup);
|
||||||
void mnodeUpdateVgroupStatus(SVgObj *pVgroup, SDnodeObj *dnodeId, SVnodeLoad *pVload);
|
void mnodeUpdateVgroupStatus(SVgObj *pVgroup, SDnodeObj *pDnode, SVnodeLoad *pVload);
|
||||||
|
void mnodeCheckUnCreatedVgroup(SDnodeObj *pDnode, SVnodeLoad *pVloads, int32_t openVnodes);
|
||||||
|
|
||||||
int32_t mnodeCreateVgroup(struct SMnodeMsg *pMsg, SDbObj *pDb);
|
int32_t mnodeCreateVgroup(struct SMnodeMsg *pMsg, SDbObj *pDb);
|
||||||
void mnodeDropVgroup(SVgObj *pVgroup, void *ahandle);
|
void mnodeDropVgroup(SVgObj *pVgroup, void *ahandle);
|
||||||
|
|
|
@ -39,6 +39,7 @@ static int32_t mnodeAcctActionDestroy(SSdbOper *pOper) {
|
||||||
static int32_t mnodeAcctActionInsert(SSdbOper *pOper) {
|
static int32_t mnodeAcctActionInsert(SSdbOper *pOper) {
|
||||||
SAcctObj *pAcct = pOper->pObj;
|
SAcctObj *pAcct = pOper->pObj;
|
||||||
memset(&pAcct->acctInfo, 0, sizeof(SAcctInfo));
|
memset(&pAcct->acctInfo, 0, sizeof(SAcctInfo));
|
||||||
|
pAcct->acctInfo.accessState = TSDB_VN_ALL_ACCCESS;
|
||||||
pthread_mutex_init(&pAcct->mutex, NULL);
|
pthread_mutex_init(&pAcct->mutex, NULL);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,6 +335,19 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t openVnodes = htons(pStatus->openVnodes);
|
int32_t openVnodes = htons(pStatus->openVnodes);
|
||||||
|
int32_t contLen = sizeof(SDMStatusRsp) + openVnodes * sizeof(SDMVgroupAccess);
|
||||||
|
SDMStatusRsp *pRsp = rpcMallocCont(contLen);
|
||||||
|
if (pRsp == NULL) {
|
||||||
|
mnodeDecDnodeRef(pDnode);
|
||||||
|
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
pRsp->dnodeCfg.dnodeId = htonl(pDnode->dnodeId);
|
||||||
|
pRsp->dnodeCfg.moduleStatus = htonl((int32_t)pDnode->isMgmt);
|
||||||
|
pRsp->dnodeCfg.numOfVnodes = htonl(openVnodes);
|
||||||
|
mnodeGetMnodeInfos(&pRsp->mnodes);
|
||||||
|
SDMVgroupAccess *pAccess = (SDMVgroupAccess *)((char *)pRsp + sizeof(SDMStatusRsp));
|
||||||
|
|
||||||
for (int32_t j = 0; j < openVnodes; ++j) {
|
for (int32_t j = 0; j < openVnodes; ++j) {
|
||||||
SVnodeLoad *pVload = &pStatus->load[j];
|
SVnodeLoad *pVload = &pStatus->load[j];
|
||||||
pVload->vgId = htonl(pVload->vgId);
|
pVload->vgId = htonl(pVload->vgId);
|
||||||
|
@ -347,6 +360,8 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) {
|
||||||
mnodeSendDropVnodeMsg(pVload->vgId, &ipSet, NULL);
|
mnodeSendDropVnodeMsg(pVload->vgId, &ipSet, NULL);
|
||||||
} else {
|
} else {
|
||||||
mnodeUpdateVgroupStatus(pVgroup, pDnode, pVload);
|
mnodeUpdateVgroupStatus(pVgroup, pDnode, pVload);
|
||||||
|
pAccess->vgId = htonl(pVload->vgId);
|
||||||
|
pAccess->accessState = pVgroup->accessState;
|
||||||
mnodeDecVgroupRef(pVgroup);
|
mnodeDecVgroupRef(pVgroup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -366,25 +381,12 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) {
|
||||||
balanceNotify();
|
balanceNotify();
|
||||||
}
|
}
|
||||||
|
|
||||||
mnodeDecDnodeRef(pDnode);
|
if (openVnodes != pDnode->openVnodes) {
|
||||||
|
mnodeCheckUnCreatedVgroup(pDnode, pStatus->load, openVnodes);
|
||||||
int32_t contLen = sizeof(SDMStatusRsp) + TSDB_MAX_VNODES * sizeof(SDMVgroupAccess);
|
|
||||||
SDMStatusRsp *pRsp = rpcMallocCont(contLen);
|
|
||||||
if (pRsp == NULL) {
|
|
||||||
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pDnode->lastAccess = tsAccessSquence;
|
pDnode->lastAccess = tsAccessSquence;
|
||||||
|
mnodeDecDnodeRef(pDnode);
|
||||||
mnodeGetMnodeInfos(&pRsp->mnodes);
|
|
||||||
|
|
||||||
pRsp->dnodeCfg.dnodeId = htonl(pDnode->dnodeId);
|
|
||||||
pRsp->dnodeCfg.moduleStatus = htonl((int32_t)pDnode->isMgmt);
|
|
||||||
pRsp->dnodeCfg.numOfVnodes = 0;
|
|
||||||
|
|
||||||
contLen = sizeof(SDMStatusRsp);
|
|
||||||
|
|
||||||
//TODO: set vnode access
|
|
||||||
|
|
||||||
pMsg->rpcRsp.len = contLen;
|
pMsg->rpcRsp.len = contLen;
|
||||||
pMsg->rpcRsp.rsp = pRsp;
|
pMsg->rpcRsp.rsp = pRsp;
|
||||||
|
|
|
@ -74,6 +74,7 @@ static int32_t mnodeVgroupActionInsert(SSdbOper *pOper) {
|
||||||
pVgroup->pDb = pDb;
|
pVgroup->pDb = pDb;
|
||||||
pVgroup->prev = NULL;
|
pVgroup->prev = NULL;
|
||||||
pVgroup->next = NULL;
|
pVgroup->next = NULL;
|
||||||
|
pVgroup->accessState = TSDB_VN_ALL_ACCCESS;
|
||||||
|
|
||||||
int32_t size = sizeof(SChildTableObj *) * pDb->cfg.maxTables;
|
int32_t size = sizeof(SChildTableObj *) * pDb->cfg.maxTables;
|
||||||
pVgroup->tableList = calloc(pDb->cfg.maxTables, sizeof(SChildTableObj *));
|
pVgroup->tableList = calloc(pDb->cfg.maxTables, sizeof(SChildTableObj *));
|
||||||
|
@ -255,6 +256,8 @@ void mnodeUpdateVgroup(SVgObj *pVgroup) {
|
||||||
mnodeSendCreateVgroupMsg(pVgroup, NULL);
|
mnodeSendCreateVgroupMsg(pVgroup, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mnodeCheckUnCreatedVgroup(SDnodeObj *pDnode, SVnodeLoad *pVloads, int32_t openVnodes) {}
|
||||||
|
|
||||||
void mnodeUpdateVgroupStatus(SVgObj *pVgroup, SDnodeObj *pDnode, SVnodeLoad *pVload) {
|
void mnodeUpdateVgroupStatus(SVgObj *pVgroup, SDnodeObj *pDnode, SVnodeLoad *pVload) {
|
||||||
bool dnodeExist = false;
|
bool dnodeExist = false;
|
||||||
for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) {
|
for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) {
|
||||||
|
@ -324,6 +327,7 @@ int32_t mnodeCreateVgroup(SMnodeMsg *pMsg, SDbObj *pDb) {
|
||||||
strcpy(pVgroup->dbName, pDb->name);
|
strcpy(pVgroup->dbName, pDb->name);
|
||||||
pVgroup->numOfVnodes = pDb->cfg.replications;
|
pVgroup->numOfVnodes = pDb->cfg.replications;
|
||||||
pVgroup->createdTime = taosGetTimestampMs();
|
pVgroup->createdTime = taosGetTimestampMs();
|
||||||
|
pVgroup->accessState = TSDB_VN_ALL_ACCCESS;
|
||||||
if (balanceAllocVnodes(pVgroup) != 0) {
|
if (balanceAllocVnodes(pVgroup) != 0) {
|
||||||
mError("db:%s, no enough dnode to alloc %d vnodes to vgroup", pDb->name, pVgroup->numOfVnodes);
|
mError("db:%s, no enough dnode to alloc %d vnodes to vgroup", pDb->name, pVgroup->numOfVnodes);
|
||||||
free(pVgroup);
|
free(pVgroup);
|
||||||
|
|
|
@ -1216,7 +1216,6 @@ static int32_t tableApplyFunctionsOnBlock(SQueryRuntimeEnv *pRuntimeEnv, SDataBl
|
||||||
|
|
||||||
// interval query with limit applied
|
// interval query with limit applied
|
||||||
int32_t numOfRes = 0;
|
int32_t numOfRes = 0;
|
||||||
|
|
||||||
if (isIntervalQuery(pQuery)) {
|
if (isIntervalQuery(pQuery)) {
|
||||||
numOfRes = doCheckQueryCompleted(pRuntimeEnv, lastKey, pWindowResInfo);
|
numOfRes = doCheckQueryCompleted(pRuntimeEnv, lastKey, pWindowResInfo);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -120,6 +120,7 @@ static FORCE_INLINE int32_t isValidNumber(const SSQLToken* pToken) {
|
||||||
|
|
||||||
type = TK_FLOAT;
|
type = TK_FLOAT;
|
||||||
goto _end;
|
goto _end;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '0': {
|
case '0': {
|
||||||
|
|
|
@ -117,6 +117,8 @@ extern "C" {
|
||||||
|
|
||||||
#define POW2(x) ((x) * (x))
|
#define POW2(x) ((x) * (x))
|
||||||
|
|
||||||
|
int taosRand(void);
|
||||||
|
|
||||||
int32_t strdequote(char *src);
|
int32_t strdequote(char *src);
|
||||||
|
|
||||||
size_t strtrim(char *src);
|
size_t strtrim(char *src);
|
||||||
|
|
|
@ -95,9 +95,6 @@ void* taosArrayGetP(const SArray* pArray, size_t index) {
|
||||||
assert(index < pArray->size);
|
assert(index < pArray->size);
|
||||||
|
|
||||||
void* d = TARRAY_GET_ELEM(pArray, index);
|
void* d = TARRAY_GET_ELEM(pArray, index);
|
||||||
if (d == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return *(void**)d;
|
return *(void**)d;
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ static FORCE_INLINE void taosCacheReleaseNode(SCacheObj *pCacheObj, SCacheDataNo
|
||||||
int32_t size = pNode->size;
|
int32_t size = pNode->size;
|
||||||
taosHashRemove(pCacheObj->pHashTable, pNode->key, pNode->keySize);
|
taosHashRemove(pCacheObj->pHashTable, pNode->key, pNode->keySize);
|
||||||
|
|
||||||
uTrace("key:%s is removed from cache,total:%d,size:%ldbytes", pNode->key, pCacheObj->totalSize, size);
|
uTrace("key:%s is removed from cache,total:%" PRId64 ",size:%dbytes", pNode->key, pCacheObj->totalSize, size);
|
||||||
if (pCacheObj->freeFp) pCacheObj->freeFp(pNode->data);
|
if (pCacheObj->freeFp) pCacheObj->freeFp(pNode->data);
|
||||||
free(pNode);
|
free(pNode);
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ void *taosCachePut(SCacheObj *pCacheObj, const char *key, const void *pData, siz
|
||||||
if (NULL != pNode) {
|
if (NULL != pNode) {
|
||||||
pCacheObj->totalSize += pNode->size;
|
pCacheObj->totalSize += pNode->size;
|
||||||
|
|
||||||
uTrace("key:%s %p added into cache, added:%" PRIu64 ", expire:%" PRIu64 ", total:%d, size:%" PRId64 " bytes",
|
uTrace("key:%s %p added into cache, added:%" PRIu64 ", expire:%" PRIu64 ", total:%" PRId64 ", size:%" PRId64 " bytes",
|
||||||
key, pNode, pNode->addedTime, pNode->expiredTime, pCacheObj->totalSize, dataSize);
|
key, pNode, pNode->addedTime, pNode->expiredTime, pCacheObj->totalSize, dataSize);
|
||||||
} else {
|
} else {
|
||||||
uError("key:%s failed to added into cache, out of memory", key);
|
uError("key:%s failed to added into cache, out of memory", key);
|
||||||
|
@ -433,7 +433,6 @@ void taosCacheEmpty(SCacheObj *pCacheObj) {
|
||||||
__cache_wr_lock(pCacheObj);
|
__cache_wr_lock(pCacheObj);
|
||||||
while (taosHashIterNext(pIter)) {
|
while (taosHashIterNext(pIter)) {
|
||||||
if (pCacheObj->deleting == 1) {
|
if (pCacheObj->deleting == 1) {
|
||||||
taosHashDestroyIter(pIter);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,7 +506,7 @@ void taosAddToTrash(SCacheObj *pCacheObj, SCacheDataNode *pNode) {
|
||||||
|
|
||||||
void taosRemoveFromTrashCan(SCacheObj *pCacheObj, STrashElem *pElem) {
|
void taosRemoveFromTrashCan(SCacheObj *pCacheObj, STrashElem *pElem) {
|
||||||
if (pElem->pData->signature != (uint64_t)pElem->pData) {
|
if (pElem->pData->signature != (uint64_t)pElem->pData) {
|
||||||
uError("key:sig:%d %p data has been released, ignore", pElem->pData->signature, pElem->pData);
|
uError("key:sig:0x%" PRIx64 " %p data has been released, ignore", pElem->pData->signature, pElem->pData);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -561,7 +560,6 @@ void taosTrashCanEmpty(SCacheObj *pCacheObj, bool force) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(pCacheObj->numOfElemsInTrash >= 0);
|
|
||||||
__cache_unlock(pCacheObj);
|
__cache_unlock(pCacheObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -551,7 +551,7 @@ int tsDecompressTimestampImp(const char *const input, const int nelements, char
|
||||||
delta_of_delta = 0;
|
delta_of_delta = 0;
|
||||||
} else {
|
} else {
|
||||||
if (is_bigendian()) {
|
if (is_bigendian()) {
|
||||||
memcpy(&dd1 + LONG_BYTES - nbytes, input + ipos, nbytes);
|
memcpy(((char *)(&dd1)) + LONG_BYTES - nbytes, input + ipos, nbytes);
|
||||||
} else {
|
} else {
|
||||||
memcpy(&dd1, input + ipos, nbytes);
|
memcpy(&dd1, input + ipos, nbytes);
|
||||||
}
|
}
|
||||||
|
@ -576,7 +576,7 @@ int tsDecompressTimestampImp(const char *const input, const int nelements, char
|
||||||
delta_of_delta = 0;
|
delta_of_delta = 0;
|
||||||
} else {
|
} else {
|
||||||
if (is_bigendian()) {
|
if (is_bigendian()) {
|
||||||
memcpy(&dd2 + LONG_BYTES - nbytes, input + ipos, nbytes);
|
memcpy(((char *)(&dd2)) + LONG_BYTES - nbytes, input + ipos, nbytes);
|
||||||
} else {
|
} else {
|
||||||
memcpy(&dd2, input + ipos, nbytes);
|
memcpy(&dd2, input + ipos, nbytes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ static void taosReadInt32Config(SGlobalCfg *cfg, char *input_value) {
|
||||||
*option = value;
|
*option = value;
|
||||||
cfg->cfgStatus = TAOS_CFG_CSTATUS_FILE;
|
cfg->cfgStatus = TAOS_CFG_CSTATUS_FILE;
|
||||||
} else {
|
} else {
|
||||||
uWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, input_value,
|
uWarn("config option:%s, input value:%s, is configured by %s, use %d", cfg->option, input_value,
|
||||||
tsCfgStatusStr[cfg->cfgStatus], *option);
|
tsCfgStatusStr[cfg->cfgStatus], *option);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,11 @@ static void taosReadDirectoryConfig(SGlobalCfg *cfg, char *input_value) {
|
||||||
} else {
|
} else {
|
||||||
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_FILE) {
|
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_FILE) {
|
||||||
wordexp_t full_path;
|
wordexp_t full_path;
|
||||||
wordexp(input_value, &full_path, 0);
|
if (0 != wordexp(input_value, &full_path, 0)) {
|
||||||
|
printf("\nconfig dir: %s wordexp fail! reason:%s\n", input_value, strerror(errno));
|
||||||
|
wordfree(&full_path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (full_path.we_wordv != NULL && full_path.we_wordv[0] != NULL) {
|
if (full_path.we_wordv != NULL && full_path.we_wordv[0] != NULL) {
|
||||||
strcpy(option, full_path.we_wordv[0]);
|
strcpy(option, full_path.we_wordv[0]);
|
||||||
}
|
}
|
||||||
|
@ -115,9 +119,14 @@ static void taosReadDirectoryConfig(SGlobalCfg *cfg, char *input_value) {
|
||||||
struct stat dirstat;
|
struct stat dirstat;
|
||||||
if (stat(option, &dirstat) < 0) {
|
if (stat(option, &dirstat) < 0) {
|
||||||
int code = mkdir(option, 0755);
|
int code = mkdir(option, 0755);
|
||||||
|
if (code < 0) {
|
||||||
|
uError("config option:%s, input value:%s, directory not exist, create fail with return code:%d",
|
||||||
|
cfg->option, input_value, code);
|
||||||
|
} else {
|
||||||
uPrint("config option:%s, input value:%s, directory not exist, create with return code:%d",
|
uPrint("config option:%s, input value:%s, directory not exist, create with return code:%d",
|
||||||
cfg->option, input_value, code);
|
cfg->option, input_value, code);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
cfg->cfgStatus = TAOS_CFG_CSTATUS_FILE;
|
cfg->cfgStatus = TAOS_CFG_CSTATUS_FILE;
|
||||||
} else {
|
} else {
|
||||||
uWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, input_value,
|
uWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, input_value,
|
||||||
|
@ -240,7 +249,12 @@ void taosReadGlobalLogCfg() {
|
||||||
sdbDebugFlag = 135;
|
sdbDebugFlag = 135;
|
||||||
|
|
||||||
wordexp_t full_path;
|
wordexp_t full_path;
|
||||||
wordexp(configDir, &full_path, 0);
|
if ( 0 != wordexp(configDir, &full_path, 0)) {
|
||||||
|
printf("\nconfig file: %s wordexp fail! reason:%s\n", configDir, strerror(errno));
|
||||||
|
wordfree(&full_path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (full_path.we_wordv != NULL && full_path.we_wordv[0] != NULL) {
|
if (full_path.we_wordv != NULL && full_path.we_wordv[0] != NULL) {
|
||||||
if (strlen(full_path.we_wordv[0]) >= TSDB_FILENAME_LEN) {
|
if (strlen(full_path.we_wordv[0]) >= TSDB_FILENAME_LEN) {
|
||||||
printf("\nconfig file: %s path overflow max len %d, all variables are set to default\n", full_path.we_wordv[0], TSDB_FILENAME_LEN - 1);
|
printf("\nconfig file: %s path overflow max len %d, all variables are set to default\n", full_path.we_wordv[0], TSDB_FILENAME_LEN - 1);
|
||||||
|
|
|
@ -140,7 +140,7 @@ void print_char_as_binary(char input) {
|
||||||
void generate_key(unsigned char* key) {
|
void generate_key(unsigned char* key) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
key[i] = rand() % 255;
|
key[i] = taosRand() % 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
|
@ -566,5 +566,6 @@ static int tdRestoreKVStore(SKVStore *pStore) {
|
||||||
_err:
|
_err:
|
||||||
taosHashDestroyIter(pIter);
|
taosHashDestroyIter(pIter);
|
||||||
tfree(buf);
|
tfree(buf);
|
||||||
|
taosHashDestroyIter(pIter);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
|
@ -142,6 +142,10 @@ static void *taosThreadToOpenNewFile(void *param) {
|
||||||
umask(0);
|
umask(0);
|
||||||
|
|
||||||
int32_t fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO);
|
int32_t fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO);
|
||||||
|
if (fd < 0) {
|
||||||
|
uError("open new log file fail! fd:%d reason:%s", fd, strerror(errno));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
taosLockFile(fd);
|
taosLockFile(fd);
|
||||||
lseek(fd, 0, SEEK_SET);
|
lseek(fd, 0, SEEK_SET);
|
||||||
|
|
||||||
|
@ -184,7 +188,7 @@ void taosResetLog() {
|
||||||
tsLogObj.lines = tsLogObj.maxLines + 10;
|
tsLogObj.lines = tsLogObj.maxLines + 10;
|
||||||
|
|
||||||
taosOpenNewLogFile();
|
taosOpenNewLogFile();
|
||||||
remove(lastName);
|
(void)remove(lastName);
|
||||||
|
|
||||||
uPrint("==================================");
|
uPrint("==================================");
|
||||||
uPrint(" reset log file ");
|
uPrint(" reset log file ");
|
||||||
|
@ -229,7 +233,9 @@ static void taosGetLogFileName(char *fn) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strlen(fn) < LOG_FILE_NAME_LEN) {
|
||||||
strcpy(tsLogObj.logName, fn);
|
strcpy(tsLogObj.logName, fn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
|
static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
|
||||||
|
@ -249,15 +255,20 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
|
||||||
tsLogObj.fileNum = maxFileNum;
|
tsLogObj.fileNum = maxFileNum;
|
||||||
taosGetLogFileName(fn);
|
taosGetLogFileName(fn);
|
||||||
|
|
||||||
|
if (strlen(fn) < LOG_FILE_NAME_LEN + 50 - 2) {
|
||||||
strcpy(name, fn);
|
strcpy(name, fn);
|
||||||
strcat(name, ".0");
|
strcat(name, ".0");
|
||||||
|
}
|
||||||
|
|
||||||
// if none of the log files exist, open 0, if both exists, open the old one
|
// if none of the log files exist, open 0, if both exists, open the old one
|
||||||
if (stat(name, &logstat0) < 0) {
|
if (stat(name, &logstat0) < 0) {
|
||||||
tsLogObj.flag = 0;
|
tsLogObj.flag = 0;
|
||||||
} else {
|
} else {
|
||||||
|
if (strlen(fn) < LOG_FILE_NAME_LEN + 50 - 2) {
|
||||||
strcpy(name, fn);
|
strcpy(name, fn);
|
||||||
strcat(name, ".1");
|
strcat(name, ".1");
|
||||||
|
}
|
||||||
|
|
||||||
if (stat(name, &logstat1) < 0) {
|
if (stat(name, &logstat1) < 0) {
|
||||||
tsLogObj.flag = 1;
|
tsLogObj.flag = 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -279,7 +290,10 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
|
||||||
|
|
||||||
// only an estimate for number of lines
|
// only an estimate for number of lines
|
||||||
struct stat filestat;
|
struct stat filestat;
|
||||||
fstat(tsLogObj.logHandle->fd, &filestat);
|
if (fstat(tsLogObj.logHandle->fd, &filestat) < 0) {
|
||||||
|
printf("\nfailed to fstat log file:%s, reason:%s\n", name, strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
size = (int32_t)filestat.st_size;
|
size = (int32_t)filestat.st_size;
|
||||||
tsLogObj.lines = size / 60;
|
tsLogObj.lines = size / 60;
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,9 @@ void taosGetNoteName(char *fn, taosNoteInfo * pNote)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strlen(fn) < NOTE_FILE_NAME_LEN) {
|
||||||
strcpy(pNote->taosNoteName, fn);
|
strcpy(pNote->taosNoteName, fn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int taosOpenNoteWithMaxLines(char *fn, int maxLines, int maxNoteNum, taosNoteInfo * pNote)
|
int taosOpenNoteWithMaxLines(char *fn, int maxLines, int maxNoteNum, taosNoteInfo * pNote)
|
||||||
|
@ -182,14 +184,18 @@ int taosOpenNoteWithMaxLines(char *fn, int maxLines, int maxNoteNum, taosNoteInf
|
||||||
pNote->taosNoteFileNum = maxNoteNum;
|
pNote->taosNoteFileNum = maxNoteNum;
|
||||||
taosGetNoteName(fn, pNote);
|
taosGetNoteName(fn, pNote);
|
||||||
|
|
||||||
|
if (strlen(fn) > NOTE_FILE_NAME_LEN * 2 - 2) {
|
||||||
|
fprintf(stderr, "the len of file name overflow:%s\n", fn);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
strcpy(name, fn);
|
strcpy(name, fn);
|
||||||
strcat(name, ".0");
|
strcat(name, ".0");
|
||||||
|
|
||||||
// if none of the note files exist, open 0, if both exists, open the old one
|
// if none of the note files exist, open 0, if both exists, open the old one
|
||||||
if (stat(name, ¬estat0) < 0) {
|
if (stat(name, ¬estat0) < 0) {
|
||||||
pNote->taosNoteFlag = 0;
|
pNote->taosNoteFlag = 0;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
strcpy(name, fn);
|
strcpy(name, fn);
|
||||||
strcat(name, ".1");
|
strcat(name, ".1");
|
||||||
if (stat(name, ¬estat1) < 0) {
|
if (stat(name, ¬estat1) < 0) {
|
||||||
|
@ -214,7 +220,10 @@ int taosOpenNoteWithMaxLines(char *fn, int maxLines, int maxNoteNum, taosNoteInf
|
||||||
|
|
||||||
// only an estimate for number of lines
|
// only an estimate for number of lines
|
||||||
struct stat filestat;
|
struct stat filestat;
|
||||||
fstat(pNote->taosNoteFd, &filestat);
|
if (fstat(pNote->taosNoteFd, &filestat) < 0) {
|
||||||
|
fprintf(stderr, "failed to fstat note file:%s reason:%s\n", name, strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
size = (int)filestat.st_size;
|
size = (int)filestat.st_size;
|
||||||
pNote->taosNoteLines = size / 60;
|
pNote->taosNoteLines = size / 60;
|
||||||
|
|
||||||
|
@ -226,7 +235,7 @@ int taosOpenNoteWithMaxLines(char *fn, int maxLines, int maxNoteNum, taosNoteInf
|
||||||
void taosNotePrint(taosNoteInfo * pNote, const char * const format, ...)
|
void taosNotePrint(taosNoteInfo * pNote, const char * const format, ...)
|
||||||
{
|
{
|
||||||
va_list argpointer;
|
va_list argpointer;
|
||||||
char buffer[MAX_NOTE_LINE_SIZE];
|
char buffer[MAX_NOTE_LINE_SIZE+2];
|
||||||
int len;
|
int len;
|
||||||
struct tm Tm, *ptm;
|
struct tm Tm, *ptm;
|
||||||
struct timeval timeSecs;
|
struct timeval timeSecs;
|
||||||
|
|
|
@ -38,7 +38,7 @@ static FORCE_INLINE int32_t getSkipListNodeRandomHeight(SSkipList *pSkipList) {
|
||||||
const uint32_t factor = 4;
|
const uint32_t factor = 4;
|
||||||
|
|
||||||
int32_t n = 1;
|
int32_t n = 1;
|
||||||
while ((rand() % factor) == 0 && n <= pSkipList->maxLevel) {
|
while ((taosRand() % factor) == 0 && n <= pSkipList->maxLevel) {
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -278,7 +278,7 @@ int taosOpenUdpSocket(uint32_t ip, uint16_t port) {
|
||||||
/* bind socket to local address */
|
/* bind socket to local address */
|
||||||
if (bind(sockFd, (struct sockaddr *)&localAddr, sizeof(localAddr)) < 0) {
|
if (bind(sockFd, (struct sockaddr *)&localAddr, sizeof(localAddr)) < 0) {
|
||||||
uError("failed to bind udp socket: %d (%s), 0x%x:%hu", errno, strerror(errno), ip, port);
|
uError("failed to bind udp socket: %d (%s), 0x%x:%hu", errno, strerror(errno), ip, port);
|
||||||
taosCloseSocket(sockFd);
|
close(sockFd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ int taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clientI
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
//uError("failed to connect socket, ip:0x%x, port:%hu(%s)", destIp, destPort, strerror(errno));
|
//uError("failed to connect socket, ip:0x%x, port:%hu(%s)", destIp, destPort, strerror(errno));
|
||||||
taosCloseSocket(sockFd);
|
close(sockFd);
|
||||||
sockFd = -1;
|
sockFd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,49 +72,6 @@ void deltaToUtcInitOnce() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t user_mktime(struct tm * tm)
|
|
||||||
{
|
|
||||||
#define TAOS_MINUTE 60
|
|
||||||
#define TAOS_HOUR (60*TAOS_MINUTE)
|
|
||||||
#define TAOS_DAY (24*TAOS_HOUR)
|
|
||||||
#define TAOS_YEAR (365*TAOS_DAY)
|
|
||||||
|
|
||||||
static int month[12] = {
|
|
||||||
0,
|
|
||||||
TAOS_DAY*(31),
|
|
||||||
TAOS_DAY*(31+29),
|
|
||||||
TAOS_DAY*(31+29+31),
|
|
||||||
TAOS_DAY*(31+29+31+30),
|
|
||||||
TAOS_DAY*(31+29+31+30+31),
|
|
||||||
TAOS_DAY*(31+29+31+30+31+30),
|
|
||||||
TAOS_DAY*(31+29+31+30+31+30+31),
|
|
||||||
TAOS_DAY*(31+29+31+30+31+30+31+31),
|
|
||||||
TAOS_DAY*(31+29+31+30+31+30+31+31+30),
|
|
||||||
TAOS_DAY*(31+29+31+30+31+30+31+31+30+31),
|
|
||||||
TAOS_DAY*(31+29+31+30+31+30+31+31+30+31+30)
|
|
||||||
};
|
|
||||||
|
|
||||||
int64_t res;
|
|
||||||
int year;
|
|
||||||
|
|
||||||
year= tm->tm_year - 70;
|
|
||||||
res= TAOS_YEAR*year + TAOS_DAY*((year+1)/4);
|
|
||||||
res+= month[tm->tm_mon];
|
|
||||||
|
|
||||||
if(tm->tm_mon > 1 && ((year+2)%4)) {
|
|
||||||
res-= TAOS_DAY;
|
|
||||||
}
|
|
||||||
|
|
||||||
res+= TAOS_DAY*(tm->tm_mday-1);
|
|
||||||
res+= TAOS_HOUR*tm->tm_hour;
|
|
||||||
res+= TAOS_MINUTE*tm->tm_min;
|
|
||||||
res+= tm->tm_sec;
|
|
||||||
|
|
||||||
return res + m_deltaUtc;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int64_t parseFraction(char* str, char** end, int32_t timePrec);
|
static int64_t parseFraction(char* str, char** end, int32_t timePrec);
|
||||||
static int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec);
|
static int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec);
|
||||||
static int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec);
|
static int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec);
|
||||||
|
|
|
@ -139,7 +139,7 @@ static void unlockTimerList(timer_list_t* list) {
|
||||||
int64_t tid = taosGetPthreadId();
|
int64_t tid = taosGetPthreadId();
|
||||||
if (atomic_val_compare_exchange_64(&(list->lockedBy), tid, 0) != tid) {
|
if (atomic_val_compare_exchange_64(&(list->lockedBy), tid, 0) != tid) {
|
||||||
assert(false);
|
assert(false);
|
||||||
tmrError("%d trying to unlock a timer list not locked by current thread.", tid);
|
tmrError("%" PRId64 " trying to unlock a timer list not locked by current thread.", tid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,6 +290,7 @@ static void addToExpired(tmr_obj_t* head) {
|
||||||
SSchedMsg schedMsg;
|
SSchedMsg schedMsg;
|
||||||
schedMsg.fp = NULL;
|
schedMsg.fp = NULL;
|
||||||
schedMsg.tfp = processExpiredTimer;
|
schedMsg.tfp = processExpiredTimer;
|
||||||
|
schedMsg.msg = NULL;
|
||||||
schedMsg.ahandle = head;
|
schedMsg.ahandle = head;
|
||||||
schedMsg.thandle = NULL;
|
schedMsg.thandle = NULL;
|
||||||
taosScheduleTask(tmrQhandle, &schedMsg);
|
taosScheduleTask(tmrQhandle, &schedMsg);
|
||||||
|
@ -513,14 +514,17 @@ static void taosTmrModuleInit(void) {
|
||||||
tmrError("failed to create the mutex for wheel, reason:%s", strerror(errno));
|
tmrError("failed to create the mutex for wheel, reason:%s", strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
pthread_mutex_lock(&wheel->mutex);
|
||||||
wheel->nextScanAt = now + wheel->resolution;
|
wheel->nextScanAt = now + wheel->resolution;
|
||||||
wheel->index = 0;
|
wheel->index = 0;
|
||||||
wheel->slots = (tmr_obj_t**)calloc(wheel->size, sizeof(tmr_obj_t*));
|
wheel->slots = (tmr_obj_t**)calloc(wheel->size, sizeof(tmr_obj_t*));
|
||||||
if (wheel->slots == NULL) {
|
if (wheel->slots == NULL) {
|
||||||
tmrError("failed to allocate wheel slots");
|
tmrError("failed to allocate wheel slots");
|
||||||
|
pthread_mutex_unlock(&wheel->mutex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
timerMap.size += wheel->size;
|
timerMap.size += wheel->size;
|
||||||
|
pthread_mutex_unlock(&wheel->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
timerMap.count = 0;
|
timerMap.count = 0;
|
||||||
|
|
|
@ -27,6 +27,33 @@
|
||||||
#include "tulog.h"
|
#include "tulog.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WINDOWS
|
||||||
|
int taosRand(void)
|
||||||
|
{
|
||||||
|
return rand();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
int taosRand(void)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
int seed;
|
||||||
|
|
||||||
|
fd = open("/dev/urandom", 0);
|
||||||
|
if (fd < 0) {
|
||||||
|
seed = time(0);
|
||||||
|
} else {
|
||||||
|
int len = read(fd, &seed, sizeof(seed));
|
||||||
|
if (len < 0) {
|
||||||
|
seed = time(0);
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t strdequote(char *z) {
|
int32_t strdequote(char *z) {
|
||||||
if (z == NULL) {
|
if (z == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -434,8 +461,10 @@ void getTmpfilePath(const char *fileNamePrefix, char *dstPath) {
|
||||||
|
|
||||||
strcpy(tmpPath, tmpDir);
|
strcpy(tmpPath, tmpDir);
|
||||||
strcat(tmpPath, tdengineTmpFileNamePrefix);
|
strcat(tmpPath, tdengineTmpFileNamePrefix);
|
||||||
|
if (strlen(tmpPath) + strlen(fileNamePrefix) + strlen("-%d-%s") < PATH_MAX) {
|
||||||
strcat(tmpPath, fileNamePrefix);
|
strcat(tmpPath, fileNamePrefix);
|
||||||
strcat(tmpPath, "-%d-%s");
|
strcat(tmpPath, "-%d-%s");
|
||||||
|
}
|
||||||
|
|
||||||
char rand[8] = {0};
|
char rand[8] = {0};
|
||||||
taosRandStr(rand, tListLen(rand) - 1);
|
taosRandStr(rand, tListLen(rand) - 1);
|
||||||
|
@ -447,7 +476,7 @@ void taosRandStr(char* str, int32_t size) {
|
||||||
int32_t len = 39;
|
int32_t len = 39;
|
||||||
|
|
||||||
for(int32_t i = 0; i < size; ++i) {
|
for(int32_t i = 0; i < size; ++i) {
|
||||||
str[i] = set[rand()%len];
|
str[i] = set[taosRand()%len];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,7 +586,7 @@ bool taosGetVersionNumber(char *versionStr, int *versionNubmer) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int versionNumberPos[4] = {0};
|
int versionNumberPos[5] = {0};
|
||||||
int len = strlen(versionStr);
|
int len = strlen(versionStr);
|
||||||
int dot = 0;
|
int dot = 0;
|
||||||
for (int pos = 0; pos < len && dot < 4; ++pos) {
|
for (int pos = 0; pos < len && dot < 4; ++pos) {
|
||||||
|
@ -709,7 +738,7 @@ void taosRemoveDir(char *rootDir) {
|
||||||
if (de->d_type & DT_DIR) {
|
if (de->d_type & DT_DIR) {
|
||||||
taosRemoveDir(filename);
|
taosRemoveDir(filename);
|
||||||
} else {
|
} else {
|
||||||
remove(filename);
|
(void)remove(filename);
|
||||||
uPrint("file:%s is removed", filename);
|
uPrint("file:%s is removed", filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ typedef struct {
|
||||||
int32_t refCount; // reference count
|
int32_t refCount; // reference count
|
||||||
int status;
|
int status;
|
||||||
int8_t role;
|
int8_t role;
|
||||||
|
int8_t accessState;
|
||||||
int64_t version; // current version
|
int64_t version; // current version
|
||||||
int64_t fversion; // version on saved data file
|
int64_t fversion; // version on saved data file
|
||||||
void *wqueue;
|
void *wqueue;
|
||||||
|
|
|
@ -195,6 +195,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
|
||||||
pVnode->version = 0;
|
pVnode->version = 0;
|
||||||
pVnode->tsdbCfg.tsdbId = pVnode->vgId;
|
pVnode->tsdbCfg.tsdbId = pVnode->vgId;
|
||||||
pVnode->rootDir = strdup(rootDir);
|
pVnode->rootDir = strdup(rootDir);
|
||||||
|
pVnode->accessState = TSDB_VN_ALL_ACCCESS;
|
||||||
|
|
||||||
int32_t code = vnodeReadCfg(pVnode);
|
int32_t code = vnodeReadCfg(pVnode);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -431,6 +432,20 @@ void vnodeBuildStatusMsg(void *param) {
|
||||||
taosHashDestroyIter(pIter);
|
taosHashDestroyIter(pIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vnodeSetAccess(SDMVgroupAccess *pAccess, int32_t numOfVnodes) {
|
||||||
|
for (int32_t i = 0; i < numOfVnodes; ++i) {
|
||||||
|
pAccess[i].vgId = htonl(pAccess[i].vgId);
|
||||||
|
SVnodeObj *pVnode = vnodeAccquireVnode(pAccess[i].vgId);
|
||||||
|
if (pVnode != NULL) {
|
||||||
|
pVnode->accessState = pAccess[i].accessState;
|
||||||
|
if (pVnode->accessState != TSDB_VN_ALL_ACCCESS) {
|
||||||
|
vTrace("vgId:%d, access state is set to %d", pAccess[i].vgId)
|
||||||
|
}
|
||||||
|
vnodeRelease(pVnode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void vnodeCleanUp(SVnodeObj *pVnode) {
|
static void vnodeCleanUp(SVnodeObj *pVnode) {
|
||||||
// remove from hash, so new messages wont be consumed
|
// remove from hash, so new messages wont be consumed
|
||||||
taosHashRemove(tsDnodeVnodesHash, (const char *)&pVnode->vgId, sizeof(int32_t));
|
taosHashRemove(tsDnodeVnodesHash, (const char *)&pVnode->vgId, sizeof(int32_t));
|
||||||
|
|
|
@ -53,6 +53,10 @@ int32_t vnodeProcessWrite(void *param1, int qtype, void *param2, void *item) {
|
||||||
if (vnodeProcessWriteMsgFp[pHead->msgType] == NULL)
|
if (vnodeProcessWriteMsgFp[pHead->msgType] == NULL)
|
||||||
return TSDB_CODE_VND_MSG_NOT_PROCESSED;
|
return TSDB_CODE_VND_MSG_NOT_PROCESSED;
|
||||||
|
|
||||||
|
if (!(pVnode->accessState & TSDB_VN_WRITE_ACCCESS)) {
|
||||||
|
return TSDB_CODE_VND_NO_WRITE_AUTH;
|
||||||
|
}
|
||||||
|
|
||||||
if (pHead->version == 0) { // from client or CQ
|
if (pHead->version == 0) { // from client or CQ
|
||||||
if (pVnode->status != TAOS_VN_STATUS_READY)
|
if (pVnode->status != TAOS_VN_STATUS_READY)
|
||||||
return TSDB_CODE_VND_INVALID_VGROUP_ID; // it may be in deleting or closing state
|
return TSDB_CODE_VND_INVALID_VGROUP_ID; // it may be in deleting or closing state
|
||||||
|
|
|
@ -114,46 +114,46 @@ sql drop table tb
|
||||||
sql drop table mt
|
sql drop table mt
|
||||||
|
|
||||||
sleep 3000
|
sleep 3000
|
||||||
## ALTER TABLE WHILE STREAMING [TBASE271]
|
### ALTER TABLE WHILE STREAMING [TBASE271]
|
||||||
sql create table tb1 (ts timestamp, c1 int, c2 nchar(5), c3 int)
|
#sql create table tb1 (ts timestamp, c1 int, c2 nchar(5), c3 int)
|
||||||
sql create table strm as select count(*), avg(c1), first(c2), sum(c3) from tb1 interval(2s)
|
#sql create table strm as select count(*), avg(c1), first(c2), sum(c3) from tb1 interval(2s)
|
||||||
sql select * from strm
|
#sql select * from strm
|
||||||
if $rows != 0 then
|
#if $rows != 0 then
|
||||||
return -1
|
# return -1
|
||||||
endi
|
#endi
|
||||||
#sleep 12000
|
##sleep 12000
|
||||||
sql insert into tb1 values (now, 1, 'taos', 1)
|
#sql insert into tb1 values (now, 1, 'taos', 1)
|
||||||
sleep 20000
|
#sleep 20000
|
||||||
sql select * from strm
|
#sql select * from strm
|
||||||
print rows = $rows
|
#print rows = $rows
|
||||||
if $rows != 1 then
|
#if $rows != 1 then
|
||||||
return -1
|
# return -1
|
||||||
endi
|
#endi
|
||||||
if $data04 != 1 then
|
#if $data04 != 1 then
|
||||||
return -1
|
# return -1
|
||||||
endi
|
#endi
|
||||||
sql alter table tb1 drop column c3
|
#sql alter table tb1 drop column c3
|
||||||
sleep 6000
|
#sleep 6000
|
||||||
sql insert into tb1 values (now, 2, 'taos')
|
#sql insert into tb1 values (now, 2, 'taos')
|
||||||
sleep 30000
|
#sleep 30000
|
||||||
sql select * from strm
|
#sql select * from strm
|
||||||
if $rows != 2 then
|
#if $rows != 2 then
|
||||||
return -1
|
# return -1
|
||||||
endi
|
#endi
|
||||||
if $data04 != 1 then
|
#if $data04 != 1 then
|
||||||
return -1
|
# return -1
|
||||||
endi
|
#endi
|
||||||
sql alter table tb1 add column c3 int
|
#sql alter table tb1 add column c3 int
|
||||||
sleep 6000
|
#sleep 6000
|
||||||
sql insert into tb1 values (now, 3, 'taos', 3);
|
#sql insert into tb1 values (now, 3, 'taos', 3);
|
||||||
sleep 3000
|
#sleep 3000
|
||||||
sql select * from strm
|
#sql select * from strm
|
||||||
if $rows != 3 then
|
#if $rows != 3 then
|
||||||
return -1
|
# return -1
|
||||||
endi
|
#endi
|
||||||
if $data04 != 1 then
|
#if $data04 != 1 then
|
||||||
return -1
|
# return -1
|
||||||
endi
|
#endi
|
||||||
|
|
||||||
## ALTER TABLE AND INSERT BY COLUMNS
|
## ALTER TABLE AND INSERT BY COLUMNS
|
||||||
sql create table mt (ts timestamp, c1 int, c2 int) tags(t1 int)
|
sql create table mt (ts timestamp, c1 int, c2 int) tags(t1 int)
|
||||||
|
|
|
@ -61,6 +61,7 @@ run general/parser/limit1_stb.sim
|
||||||
|
|
||||||
print ================== restart server to commit data into disk
|
print ================== restart server to commit data into disk
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
|
sleep 5000
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
print ================== server restart completed
|
print ================== server restart completed
|
||||||
|
|
||||||
|
|
|
@ -206,68 +206,70 @@ endi
|
||||||
|
|
||||||
################# binary
|
################# binary
|
||||||
sql alter table st41 set tag tag_binary = "shanghai"
|
sql alter table st41 set tag tag_binary = "shanghai"
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data23 != shanghai then
|
if $data00 != shanghai then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
##### test 'space' case
|
##### test 'space' case
|
||||||
#$tagvalue = '
|
system_content echo ' ' | sed 's/ //g' | tr -d '\n' # Construct an empty result for later result checking
|
||||||
#$tagvalue = $tagvalue '
|
|
||||||
#sql alter table st41 set tag tag_binary = $tagvalue
|
|
||||||
sql alter table st41 set tag tag_binary = ""
|
sql alter table st41 set tag tag_binary = ""
|
||||||
#sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
#if $data23 != $tagvalue then
|
if $data00 != $system_content then
|
||||||
# return -1
|
print expect [ $system_content ], actual [ $data00 ]
|
||||||
#endi
|
|
||||||
sql alter table st41 set tag tag_binary = "NULL"
|
|
||||||
sql describe st41
|
|
||||||
if $data23 != NULL then
|
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
sql alter table st41 set tag tag_binary = "NULL"
|
||||||
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
|
if $data00 != NULL then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
sql alter table st41 set tag tag_binary = NULL
|
sql alter table st41 set tag tag_binary = NULL
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data23 != NULL then
|
if $data00 != NULL then
|
||||||
print ==8== expect: NULL, actually: $data23
|
print ==8== expect: NULL, actually: $data23
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
################### nchar
|
################### nchar
|
||||||
sql alter table st41 set tag tag_nchar = "<22><>˼<EFBFBD><CBBC><EFBFBD><EFBFBD>"
|
sql alter table st41 set tag tag_nchar = "<22><>˼<EFBFBD><CBBC><EFBFBD><EFBFBD>"
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
#sleep 1000
|
#sleep 1000
|
||||||
#if $data33 != <20><>˼<EFBFBD><CBBC><EFBFBD><EFBFBD> then
|
#if $data01 != <20><>˼<EFBFBD><CBBC><EFBFBD><EFBFBD> then
|
||||||
# print ==== expect <20><>˼<EFBFBD><CBBC><EFBFBD><EFBFBD>, actually $data33
|
# print ==== expect <20><>˼<EFBFBD><CBBC><EFBFBD><EFBFBD>, actually $data01
|
||||||
# return -1
|
# return -1
|
||||||
#endi
|
#endi
|
||||||
##### test 'space' case
|
##### test 'space' case
|
||||||
#$tagvalue = '
|
#$tagvalue = '
|
||||||
#$tagvalue = $tagvalue '
|
#$tagvalue = $tagvalue '
|
||||||
sql alter table st41 set tag tag_nchar = ''
|
sql alter table st41 set tag tag_nchar = ''
|
||||||
#sql describe st41
|
#sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
#if $data33 != $tagvalue then
|
#if $data01 != $tagvalue then
|
||||||
# return -1
|
# return -1
|
||||||
#endi
|
#endi
|
||||||
sql alter table st41 set tag tag_nchar = "NULL"
|
sql alter table st41 set tag tag_nchar = "NULL"
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data33 != NULL then
|
if $data01 != NULL then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st41 set tag tag_nchar = NULL
|
sql alter table st41 set tag tag_nchar = NULL
|
||||||
#sql describe st41
|
#sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
#if $data33 != then
|
#if $data01 != then
|
||||||
# print ==9== expect , actually $data33
|
# print ==9== expect , actually $data01
|
||||||
# return -1
|
# return -1
|
||||||
#endi
|
#endi
|
||||||
|
|
||||||
################### int
|
################### int
|
||||||
sql alter table st41 set tag tag_int = -2147483647
|
sql alter table st41 set tag tag_int = -2147483647
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data43 != -2147483647 then
|
if $data02 != -2147483647 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st41 set tag tag_int = 2147483647
|
sql alter table st41 set tag tag_int = 2147483647
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data43 != 2147483647 then
|
if $data02 != 2147483647 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
@ -275,19 +277,19 @@ sql_error alter table st41 set tag tag_int = -2147483648
|
||||||
sql_error alter table st41 set tag tag_int = 2147483648
|
sql_error alter table st41 set tag tag_int = 2147483648
|
||||||
|
|
||||||
sql alter table st41 set tag tag_int = '-379'
|
sql alter table st41 set tag tag_int = '-379'
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data43 != -379 then
|
if $data02 != -379 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st41 set tag tag_int = -2000
|
sql alter table st41 set tag tag_int = -2000
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data43 != -2000 then
|
if $data02 != -2000 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st41 set tag tag_int = NULL
|
sql alter table st41 set tag tag_int = NULL
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data43 != NULL then
|
if $data02 != NULL then
|
||||||
print ==10== expect: NULL, actually: $data43
|
print ==10== expect: NULL, actually: $data02
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st41 set tag tag_int = 'NULL'
|
sql alter table st41 set tag tag_int = 'NULL'
|
||||||
|
@ -296,34 +298,34 @@ sql_error alter table st41 set tag tag_int = abc379
|
||||||
|
|
||||||
################### bool
|
################### bool
|
||||||
sql alter table st41 set tag tag_bool = 'true'
|
sql alter table st41 set tag tag_bool = 'true'
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data53 != true then
|
if $data03 != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st41 set tag tag_bool = 'false'
|
sql alter table st41 set tag tag_bool = 'false'
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data53 != false then
|
if $data03 != 0 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st41 set tag tag_bool = 0
|
sql alter table st41 set tag tag_bool = 0
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data53 != false then
|
if $data03 != 0 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st41 set tag tag_bool = 123
|
sql alter table st41 set tag tag_bool = 123
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data53 != true then
|
if $data03 != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st41 set tag tag_bool = 'NULL'
|
sql alter table st41 set tag tag_bool = 'NULL'
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data53 != NULL then
|
if $data03 != NULL then
|
||||||
print ==14== expect: NULL, actually: $data53
|
print ==14== expect: NULL, actually: $data03
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st41 set tag tag_bool = NULL
|
sql alter table st41 set tag tag_bool = NULL
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data53 != NULL then
|
if $data03 != NULL then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
@ -333,50 +335,51 @@ sql_error alter table st41 set tag tag_bool = abc379
|
||||||
|
|
||||||
################### float
|
################### float
|
||||||
sql alter table st41 set tag tag_float = -32
|
sql alter table st41 set tag tag_float = -32
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data63 != -32.000000 then
|
if $data04 != -32.00000 then
|
||||||
|
print expect -32.00000 actual $data04
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st41 set tag tag_float = 54.123456
|
sql alter table st41 set tag tag_float = 54.123456
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data63 != 54.123455 then
|
if $data04 != 54.123455 then
|
||||||
print ==15== expect: 54.123455, actually: $data63
|
print ==15== expect: 54.123455, actually: $data04
|
||||||
# return -1
|
# return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st41 set tag tag_float = 54.12345
|
sql alter table st41 set tag tag_float = 54.12345
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data63 != 54.123451 then
|
if $data04 != 54.12345 then
|
||||||
print ==16== expect: 54.123451, actually: $data63
|
print ==16== expect: 54.12345, actually: $data04
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st41 set tag tag_float = 54.12345678
|
sql alter table st41 set tag tag_float = 54.12345678
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data63 != 54.123455 then
|
if $data04 != 54.12346 then
|
||||||
print ==11== expect: 54.123455, actually : $data63
|
print ==11== expect: 54.12346, actually : $data04
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st41 set tag tag_float = NULL
|
sql alter table st41 set tag tag_float = NULL
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data63 != NULL then
|
if $data04 != NULL then
|
||||||
print ==12== expect: NULL, actually : $data63
|
print ==12== expect: NULL, actually : $data04
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st41 set tag tag_float = 'NULL'
|
sql alter table st41 set tag tag_float = 'NULL'
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data63 != NULL then
|
if $data04 != NULL then
|
||||||
print ==17== expect: NULL, actually : $data63
|
print ==17== expect: NULL, actually : $data04
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st41 set tag tag_float = '54.123456'
|
sql alter table st41 set tag tag_float = '54.123456'
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data63 != 54.123455 then
|
if $data04 != 54.12346 then
|
||||||
print ==18== expect: 54.123455, actually : $data63
|
print ==18== expect: 54.12346, actually : $data04
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st41 set tag tag_float = '-54.123456'
|
sql alter table st41 set tag tag_float = '-54.123456'
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data63 != -54.123455 then
|
if $data04 != -54.12346 then
|
||||||
print ==19== expect: -54.123455, actually : $data63
|
print ==19== expect: -54.12346, actually : $data04
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql_error alter table st41 set tag tag_float = ''
|
sql_error alter table st41 set tag tag_float = ''
|
||||||
|
@ -387,30 +390,32 @@ sql_error alter table st41 set tag tag_float = abc
|
||||||
|
|
||||||
################### double
|
################### double
|
||||||
sql alter table st41 set tag tag_double = -92
|
sql alter table st41 set tag tag_double = -92
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data73 != -92.000000 then
|
if $data05 != -92.000000000 then
|
||||||
|
print expect -92.000000000 actual $data05
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st41 set tag tag_double = 184
|
sql alter table st41 set tag tag_double = 184
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data73 != 184.000000 then
|
if $data05 != 184.000000000 then
|
||||||
|
print expect 184.000000000 actual $data05
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st41 set tag tag_double = '-2456'
|
sql alter table st41 set tag tag_double = '-2456'
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data73 != -2456.000000 then
|
if $data05 != -2456.000000000 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st41 set tag tag_double = NULL
|
sql alter table st41 set tag tag_double = NULL
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data73 != NULL then
|
if $data05 != NULL then
|
||||||
print ==13== expect: NULL, actually : $data73
|
print ==13== expect: NULL, actually : $data05
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st41 set tag tag_double = 'NULL'
|
sql alter table st41 set tag tag_double = 'NULL'
|
||||||
sql describe st41
|
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
|
||||||
if $data73 != NULL then
|
if $data05 != NULL then
|
||||||
print ==20== expect: NULL, actually : $data73
|
print ==20== expect: NULL, actually : $data05
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql_error alter table st41 set tag tag_double = ''
|
sql_error alter table st41 set tag tag_double = ''
|
||||||
|
@ -427,23 +432,22 @@ sql alter table st51 set tag tag_bigint = '-379'
|
||||||
sql alter table st51 set tag tag_bigint = -2000
|
sql alter table st51 set tag tag_bigint = -2000
|
||||||
sql alter table st51 set tag tag_bigint = NULL
|
sql alter table st51 set tag tag_bigint = NULL
|
||||||
sql alter table st51 set tag tag_bigint = 9223372036854775807
|
sql alter table st51 set tag tag_bigint = 9223372036854775807
|
||||||
sql describe st51
|
sql select tag_bigint, tag_smallint, tag_tinyint from st51
|
||||||
if $data23 != 9223372036854775807 then
|
if $data00 != 9223372036854775807 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st51 set tag tag_bigint = 9223372036854775808
|
sql alter table st51 set tag tag_bigint = 9223372036854775808
|
||||||
sql describe st51
|
sql select tag_bigint, tag_smallint, tag_tinyint from st51
|
||||||
if $data23 != 9223372036854775807 then
|
if $data00 != 9223372036854775807 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st51 set tag tag_bigint = -9223372036854775807
|
sql alter table st51 set tag tag_bigint = -9223372036854775807
|
||||||
sql describe st51
|
sql select tag_bigint, tag_smallint, tag_tinyint from st51
|
||||||
if $data23 != -9223372036854775807 then
|
if $data00 != -9223372036854775807 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql_error alter table st51 set tag tag_bigint = -9223372036854775808
|
sql_error alter table st51 set tag tag_bigint = -9223372036854775808
|
||||||
|
|
||||||
|
|
||||||
sql alter table st51 set tag tag_bigint = 'NULL'
|
sql alter table st51 set tag tag_bigint = 'NULL'
|
||||||
sql_error alter table st51 set tag tag_bigint = ''
|
sql_error alter table st51 set tag tag_bigint = ''
|
||||||
sql_error alter table st51 set tag tag_bigint = abc379
|
sql_error alter table st51 set tag tag_bigint = abc379
|
||||||
|
@ -452,15 +456,15 @@ sql_error alter table st51 set tag tag_bigint = abc379
|
||||||
sql alter table st51 set tag tag_smallint = -2000
|
sql alter table st51 set tag tag_smallint = -2000
|
||||||
sql alter table st51 set tag tag_smallint = NULL
|
sql alter table st51 set tag tag_smallint = NULL
|
||||||
sql alter table st51 set tag tag_smallint = 32767
|
sql alter table st51 set tag tag_smallint = 32767
|
||||||
sql describe st51
|
sql select tag_bigint, tag_smallint, tag_tinyint from st51
|
||||||
if $data33 != 32767 then
|
if $data01 != 32767 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql_error alter table st51 set tag tag_smallint = 32768
|
sql_error alter table st51 set tag tag_smallint = 32768
|
||||||
|
|
||||||
sql alter table st51 set tag tag_smallint = -32767
|
sql alter table st51 set tag tag_smallint = -32767
|
||||||
sql describe st51
|
sql select tag_bigint, tag_smallint, tag_tinyint from st51
|
||||||
if $data33 != -32767 then
|
if $data01 != -32767 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql_error alter table st51 set tag tag_smallint = -32768
|
sql_error alter table st51 set tag tag_smallint = -32768
|
||||||
|
@ -473,13 +477,13 @@ sql_error alter table st51 set tag tag_smallint = abc379
|
||||||
sql alter table st51 set tag tag_tinyint = -127
|
sql alter table st51 set tag tag_tinyint = -127
|
||||||
sql alter table st51 set tag tag_tinyint = NULL
|
sql alter table st51 set tag tag_tinyint = NULL
|
||||||
sql alter table st51 set tag tag_tinyint = 127
|
sql alter table st51 set tag tag_tinyint = 127
|
||||||
sql describe st51
|
sql select tag_bigint, tag_smallint, tag_tinyint from st51
|
||||||
if $data43 != 127 then
|
if $data02 != 127 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql alter table st51 set tag tag_tinyint = -127
|
sql alter table st51 set tag tag_tinyint = -127
|
||||||
sql describe st51
|
sql select tag_bigint, tag_smallint, tag_tinyint from st51
|
||||||
if $data43 != -127 then
|
if $data02 != -127 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql_error alter table st51 set tag tag_tinyint = '-128'
|
sql_error alter table st51 set tag tag_tinyint = '-128'
|
||||||
|
|
|
@ -82,26 +82,22 @@ sleep 2000
|
||||||
run general/parser/groupby.sim
|
run general/parser/groupby.sim
|
||||||
sleep 2000
|
sleep 2000
|
||||||
run general/parser/set_tag_vals.sim
|
run general/parser/set_tag_vals.sim
|
||||||
|
|
||||||
sleep 2000
|
sleep 2000
|
||||||
run general/parser/slimit_alter_tags.sim # persistent failed
|
run general/parser/slimit_alter_tags.sim # persistent failed
|
||||||
|
|
||||||
sleep 2000
|
sleep 2000
|
||||||
run general/parser/join.sim
|
run general/parser/join.sim
|
||||||
sleep 2000
|
sleep 2000
|
||||||
run general/parser/join_multivnode.sim
|
run general/parser/join_multivnode.sim
|
||||||
|
|
||||||
sleep 2000
|
sleep 2000
|
||||||
#run general/parser/repeatAlter.sim
|
run general/parser/repeatAlter.sim
|
||||||
sleep 2000
|
|
||||||
#run general/parser/repeatStream.sim
|
|
||||||
|
|
||||||
sleep 2000
|
sleep 2000
|
||||||
run general/parser/binary_escapeCharacter.sim
|
run general/parser/binary_escapeCharacter.sim
|
||||||
sleep 2000
|
sleep 2000
|
||||||
run general/parser/bug.sim
|
run general/parser/bug.sim
|
||||||
|
|
||||||
sleep 2000
|
#sleep 2000
|
||||||
run general/parser/stream_on_sys.sim
|
#run general/parser/repeatStream.sim
|
||||||
sleep 2000
|
#sleep 2000
|
||||||
run general/parser/stream.sim
|
#run general/parser/stream_on_sys.sim
|
||||||
|
#sleep 2000
|
||||||
|
#run general/parser/stream.sim
|
|
@ -100,7 +100,7 @@ cd ../../../debug; make
|
||||||
./test.sh -f general/insert/query_multi_file.sim
|
./test.sh -f general/insert/query_multi_file.sim
|
||||||
./test.sh -f general/insert/tcp.sim
|
./test.sh -f general/insert/tcp.sim
|
||||||
|
|
||||||
#./test.sh -f general/parser/alter.sim
|
./test.sh -f general/parser/alter.sim
|
||||||
./test.sh -f general/parser/alter1.sim
|
./test.sh -f general/parser/alter1.sim
|
||||||
./test.sh -f general/parser/alter_stable.sim
|
./test.sh -f general/parser/alter_stable.sim
|
||||||
./test.sh -f general/parser/auto_create_tb.sim
|
./test.sh -f general/parser/auto_create_tb.sim
|
||||||
|
@ -117,10 +117,10 @@ cd ../../../debug; make
|
||||||
./test.sh -f general/parser/import_commit3.sim
|
./test.sh -f general/parser/import_commit3.sim
|
||||||
./test.sh -f general/parser/insert_tb.sim
|
./test.sh -f general/parser/insert_tb.sim
|
||||||
./test.sh -f general/parser/first_last.sim
|
./test.sh -f general/parser/first_last.sim
|
||||||
#unsupport ./test.sh -f general/parser/import_file.sim
|
#./test.sh -f general/parser/import_file.sim
|
||||||
./test.sh -f general/parser/lastrow.sim
|
./test.sh -f general/parser/lastrow.sim
|
||||||
./test.sh -f general/parser/nchar.sim
|
./test.sh -f general/parser/nchar.sim
|
||||||
#unsupport ./test.sh -f general/parser/null_char.sim
|
#./test.sh -f general/parser/null_char.sim
|
||||||
./test.sh -f general/parser/single_row_in_tb.sim
|
./test.sh -f general/parser/single_row_in_tb.sim
|
||||||
./test.sh -f general/parser/select_from_cache_disk.sim
|
./test.sh -f general/parser/select_from_cache_disk.sim
|
||||||
./test.sh -f general/parser/mixed_blocks.sim
|
./test.sh -f general/parser/mixed_blocks.sim
|
||||||
|
@ -147,10 +147,10 @@ cd ../../../debug; make
|
||||||
./test.sh -f general/parser/join_multivnode.sim
|
./test.sh -f general/parser/join_multivnode.sim
|
||||||
./test.sh -f general/parser/binary_escapeCharacter.sim
|
./test.sh -f general/parser/binary_escapeCharacter.sim
|
||||||
./test.sh -f general/parser/bug.sim
|
./test.sh -f general/parser/bug.sim
|
||||||
#unsupport ./test.sh -f general/parser/stream_on_sys.sim
|
#./test.sh -f general/parser/stream_on_sys.sim
|
||||||
./test.sh -f general/parser/stream.sim
|
./test.sh -f general/parser/stream.sim
|
||||||
#unsupport ./test.sh -f general/parser/repeatAlter.sim
|
./test.sh -f general/parser/repeatAlter.sim
|
||||||
#unsupport ./test.sh -f general/parser/repeatStream.sim
|
#./test.sh -f general/parser/repeatStream.sim
|
||||||
|
|
||||||
./test.sh -f general/stable/disk.sim
|
./test.sh -f general/stable/disk.sim
|
||||||
./test.sh -f general/stable/dnode3.sim
|
./test.sh -f general/stable/dnode3.sim
|
||||||
|
@ -159,20 +159,20 @@ cd ../../../debug; make
|
||||||
./test.sh -f general/stable/values.sim
|
./test.sh -f general/stable/values.sim
|
||||||
./test.sh -f general/stable/vnode3.sim
|
./test.sh -f general/stable/vnode3.sim
|
||||||
|
|
||||||
#./test.sh -f general/stream/metrics_1.sim
|
./test.sh general/stream/stream_1.sim
|
||||||
#./test.sh -f general/stream/metrics_del.sim
|
./test.sh general/stream/stream_2.sim
|
||||||
#./test.sh -f general/stream/metrics_n.sim
|
./test.sh general/stream/stream_3.sim
|
||||||
#./test.sh -f general/stream/metrics_replica1_vnoden.sim
|
./test.sh general/stream/stream_restart.sim
|
||||||
|
./test.sh general/stream/table_1.sim
|
||||||
|
./test.sh general/stream/metrics_1.sim
|
||||||
|
./test.sh general/stream/table_n.sim
|
||||||
|
./test.sh general/stream/metrics_n.sim
|
||||||
|
./test.sh general/stream/table_del.sim
|
||||||
|
./test.sh general/stream/metrics_del.sim
|
||||||
|
./test.sh general/stream/table_replica1_vnoden.sim
|
||||||
|
./test.sh general/stream/metrics_replica1_vnoden.sim
|
||||||
#./test.sh -f general/stream/new_stream.sim
|
#./test.sh -f general/stream/new_stream.sim
|
||||||
#./test.sh -f general/stream/restart_stream.sim
|
#./test.sh -f general/stream/restart_stream.sim
|
||||||
#./test.sh -f general/stream/stream_1.sim
|
|
||||||
#./test.sh -f general/stream/stream_2.sim
|
|
||||||
#./test.sh -f general/stream/stream_3.sim
|
|
||||||
#./test.sh -f general/stream/stream_restart.sim
|
|
||||||
#./test.sh -f general/stream/table_1.sim
|
|
||||||
#./test.sh -f general/stream/table_del.sim
|
|
||||||
#./test.sh -f general/stream/table_n.sim
|
|
||||||
#./test.sh -f general/stream/table_replica1_vnoden.sim
|
|
||||||
|
|
||||||
./test.sh -f general/table/autocreate.sim
|
./test.sh -f general/table/autocreate.sim
|
||||||
./test.sh -f general/table/basic1.sim
|
./test.sh -f general/table/basic1.sim
|
||||||
|
@ -337,7 +337,7 @@ cd ../../../debug; make
|
||||||
./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim
|
./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim
|
||||||
./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim
|
./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim
|
||||||
./test.sh -f unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim
|
./test.sh -f unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim
|
||||||
#./test.sh -f unique/arbitrator/dn3_mn1_vnode_delDir.sim # unsupport
|
#./test.sh -f unique/arbitrator/dn3_mn1_vnode_delDir.sim
|
||||||
./test.sh -f unique/arbitrator/dn3_mn1_vnode_nomaster.sim
|
./test.sh -f unique/arbitrator/dn3_mn1_vnode_nomaster.sim
|
||||||
./test.sh -f unique/arbitrator/dn3_mn2_killDnode.sim
|
./test.sh -f unique/arbitrator/dn3_mn2_killDnode.sim
|
||||||
./test.sh -f unique/arbitrator/insert_duplicationTs.sim
|
./test.sh -f unique/arbitrator/insert_duplicationTs.sim
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
#system sh/exec.sh -n monitor -s 1
|
||||||
|
system sh/exec.sh -n monitorInterval -s 1
|
||||||
sleep 3000
|
sleep 3000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
|
@ -25,13 +27,16 @@ endi
|
||||||
if $data05 != 0/10 then
|
if $data05 != 0/10 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
if $data06 != 0.000/unlimited then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
print =============== check usage account
|
print =============== check usage account
|
||||||
sql create database d1
|
sql create database d1 wal 2
|
||||||
sql create database d2
|
sql create database d2 wal 2
|
||||||
sql create database d3
|
sql create database d3 wal 2
|
||||||
sql create database d4
|
sql create database d4 wal 2
|
||||||
sql create database d5
|
sql create database d5 wal 2
|
||||||
|
|
||||||
sql create table d1.t1 (ts timestamp, i int);
|
sql create table d1.t1 (ts timestamp, i int);
|
||||||
sql create user u1 pass "u1"
|
sql create user u1 pass "u1"
|
||||||
|
@ -53,6 +58,75 @@ endi
|
||||||
if $data05 != 0/10 then
|
if $data05 != 0/10 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
if $data06 != 0.000/unlimited then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print =============== step2
|
||||||
|
sql alter account root pass "taosdata" tseries 10 storage 1073741824 streams 10 dbs 5 users 5
|
||||||
|
sql show accounts
|
||||||
|
print $data00 $data01 $data02 $data03 $data04 $data05 $data06
|
||||||
|
if $data00 != root then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data02 != 4/5 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data03 != 5/5 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data04 != 1/10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data05 != 0/10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data06 != 0.000/1.000 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print =============== step3
|
||||||
|
sql alter account root pass "taosdata" tseries 10 storage 16 streams 10 dbs 5 users 5
|
||||||
|
sql show accounts
|
||||||
|
print $data00 $data01 $data02 $data03 $data04 $data05 $data06
|
||||||
|
if $data00 != root then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data02 != 4/5 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data03 != 5/5 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data04 != 1/10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data05 != 0/10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data06 != 0.000/0.000 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print =============== step4
|
||||||
|
sql insert into d1.t1 values(now + 1s, 1)
|
||||||
|
sql insert into d1.t1 values(now + 2s, 2)
|
||||||
|
|
||||||
|
# no write auth
|
||||||
|
sleep 3000
|
||||||
|
sql_error insert into d1.t1 values(now + 3s, 2)
|
||||||
|
sql_error insert into d1.t1 values(now + 4s, 2)
|
||||||
|
|
||||||
|
sql alter account root pass "taosdata" tseries 10 storage 36 streams 10 dbs 5 users 5
|
||||||
|
sleep 3000
|
||||||
|
sql insert into d1.t1 values(now + 5s, 1)
|
||||||
|
sql insert into d1.t1 values(now + 6s, 2)
|
||||||
|
|
||||||
|
# no write auth
|
||||||
|
sleep 3000
|
||||||
|
sql_error insert into d1.t1 values(now + 7s, 2)
|
||||||
|
sql_error insert into d1.t1 values(now + 8s, 2)
|
||||||
|
|
||||||
|
|
||||||
print =============== check grant
|
print =============== check grant
|
||||||
sql_error create database d6
|
sql_error create database d6
|
||||||
|
|
Loading…
Reference in New Issue