提交 7522fb75 编写于 作者: Z zyyang-taosdata

Merge branch 'master' into release/TS-453

...@@ -181,7 +181,76 @@ def pre_test_noinstall(){ ...@@ -181,7 +181,76 @@ def pre_test_noinstall(){
''' '''
return 1 return 1
} }
def pre_test_ningsi(){
sh'hostname'
sh'''
cd ${WKC}
git reset --hard HEAD~10 >/dev/null
'''
script {
if (env.CHANGE_TARGET == 'master') {
sh '''
cd ${WKC}
git checkout master
'''
}
else if(env.CHANGE_TARGET == '2.0'){
sh '''
cd ${WKC}
git checkout 2.0
'''
}
else{
sh '''
cd ${WKC}
git checkout develop
'''
}
}
sh'''
cd ${WKC}
git pull >/dev/null
git fetch origin +refs/pull/${CHANGE_ID}/merge
git checkout -qf FETCH_HEAD
git clean -dfx
git submodule update --init --recursive
cd ${WK}
git reset --hard HEAD~10
'''
script {
if (env.CHANGE_TARGET == 'master') {
sh '''
cd ${WK}
git checkout master
'''
}
else if(env.CHANGE_TARGET == '2.0'){
sh '''
cd ${WK}
git checkout 2.0
'''
}
else{
sh '''
cd ${WK}
git checkout develop
'''
}
}
sh '''
cd ${WK}
git pull >/dev/null
export TZ=Asia/Harbin
date
git clean -dfx
mkdir debug
cd debug
cmake .. -DOSTYPE=Ningsi60 > /dev/null
make
'''
return 1
}
def pre_test_win(){ def pre_test_win(){
bat ''' bat '''
taskkill /f /t /im python.exe taskkill /f /t /im python.exe
...@@ -578,6 +647,13 @@ pipeline { ...@@ -578,6 +647,13 @@ pipeline {
pre_test_noinstall() pre_test_noinstall()
} }
} }
stage('ningsi') {
agent{label "ningsi"}
steps {
pre_test_ningsi()
}
}
stage('build'){ stage('build'){
agent{label " wintest "} agent{label " wintest "}
......
...@@ -4,7 +4,7 @@ PROJECT(TDengine) ...@@ -4,7 +4,7 @@ PROJECT(TDengine)
IF (DEFINED VERNUMBER) IF (DEFINED VERNUMBER)
SET(TD_VER_NUMBER ${VERNUMBER}) SET(TD_VER_NUMBER ${VERNUMBER})
ELSE () ELSE ()
SET(TD_VER_NUMBER "2.2.1.3") SET(TD_VER_NUMBER "2.2.2.0")
ENDIF () ENDIF ()
IF (DEFINED VERCOMPATIBLE) IF (DEFINED VERCOMPATIBLE)
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
A Unix time_t is the number of 1-second intervals since January 1, 1970. A Unix time_t is the number of 1-second intervals since January 1, 1970.
time_ts are expressed in the GMT time zone. DOS times in the current local time. time_ts are expressed in the GMT time zone. DOS times in the current local time.
*/ */
time_t Filetime2Timet(uint16_t date, uint16_t time) { time_t Filetime2Timet(uint16_t date, uint16_t deps_time) {
unsigned int year, month, day, hour, minute, second; unsigned int year, month, day, hour, minute, second;
struct tm stm; struct tm stm;
...@@ -37,9 +37,9 @@ time_t Filetime2Timet(uint16_t date, uint16_t time) { ...@@ -37,9 +37,9 @@ time_t Filetime2Timet(uint16_t date, uint16_t time) {
year = 1980 + ((date & 0xFE00) >> 9); year = 1980 + ((date & 0xFE00) >> 9);
month = (date & 0x1E0) >> 5; month = (date & 0x1E0) >> 5;
day = date & 0x1F; day = date & 0x1F;
hour = (time & 0xF800) >> 11; hour = (deps_time & 0xF800) >> 11;
minute = (time & 0x7E0) >> 5; minute = (deps_time & 0x7E0) >> 5;
second = 2 * (time & 0x1F); second = 2 * (deps_time & 0x1F);
stm.tm_year = (int)year - 1900; stm.tm_year = (int)year - 1900;
stm.tm_mon = (int)month - 1; stm.tm_mon = (int)month - 1;
...@@ -55,7 +55,7 @@ time_t Filetime2Timet(uint16_t date, uint16_t time) { ...@@ -55,7 +55,7 @@ time_t Filetime2Timet(uint16_t date, uint16_t time) {
#if 0 #if 0
/* Older version of the same, trying to generate the time_t manually. /* Older version of the same, trying to generate the time_t manually.
Did not handle DST well */ Did not handle DST well */
time_t Filetime2Timet(uint16_t date, uint16_t time) { time_t Filetime2Timet(uint16_t date, uint16_t deps_time) {
unsigned int year, month, day, hour, minute, second; unsigned int year, month, day, hour, minute, second;
unsigned int olympiads; /* 4-year periods */ unsigned int olympiads; /* 4-year periods */
unsigned long t = 0; unsigned long t = 0;
...@@ -64,9 +64,9 @@ time_t Filetime2Timet(uint16_t date, uint16_t time) { ...@@ -64,9 +64,9 @@ time_t Filetime2Timet(uint16_t date, uint16_t time) {
year = 1980 + ((date & 0xFE00) >> 9); year = 1980 + ((date & 0xFE00) >> 9);
month = (date & 0x1E0) >> 5; month = (date & 0x1E0) >> 5;
day = date & 0x1F; day = date & 0x1F;
hour = (time & 0xF800) >> 11; hour = (deps_time & 0xF800) >> 11;
minute = (time & 0x7E0) >> 5; minute = (deps_time & 0x7E0) >> 5;
second = 2 * (time & 0x1F); second = 2 * (deps_time & 0x1F);
/* Count days */ /* Count days */
year -= 1970; /* Start of Unix time_t epoch */ year -= 1970; /* Start of Unix time_t epoch */
...@@ -111,16 +111,16 @@ time_t Filetime2Timet(uint16_t date, uint16_t time) { ...@@ -111,16 +111,16 @@ time_t Filetime2Timet(uint16_t date, uint16_t time) {
#endif #endif
/* Generate a string with the local file time, in the ISO 8601 date/time format */ /* Generate a string with the local file time, in the ISO 8601 date/time format */
char *Filetime2String(uint16_t date, uint16_t time, char *pBuf, size_t nBufSize) { char *Filetime2String(uint16_t date, uint16_t deps_time, char *pBuf, size_t nBufSize) {
unsigned int year, month, day, hour, minute, second; unsigned int year, month, day, hour, minute, second;
/* Decode fields */ /* Decode fields */
year = 1980 + ((date & 0xFE00) >> 9); year = 1980 + ((date & 0xFE00) >> 9);
month = (date & 0x1E0) >> 5; month = (date & 0x1E0) >> 5;
day = date & 0x1F; day = date & 0x1F;
hour = (time & 0xF800) >> 11; hour = (deps_time & 0xF800) >> 11;
minute = (time & 0x7E0) >> 5; minute = (deps_time & 0x7E0) >> 5;
second = 2 * (time & 0x1F); second = 2 * (deps_time & 0x1F);
if (nBufSize >= 20) { if (nBufSize >= 20) {
sprintf(pBuf, "%04d-%02d-%02d %02d:%02d:%02d", year, month, day, hour, minute, second); sprintf(pBuf, "%04d-%02d-%02d %02d:%02d:%02d", year, month, day, hour, minute, second);
......
...@@ -49,8 +49,8 @@ ...@@ -49,8 +49,8 @@
typedef struct { typedef struct {
const unsigned char *json; const unsigned char *json;
size_t position; size_t position;
} error; } deps_error;
static error global_error = { NULL, 0 }; static deps_error global_error = { NULL, 0 };
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void) CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void)
{ {
...@@ -210,8 +210,8 @@ typedef struct ...@@ -210,8 +210,8 @@ typedef struct
#define can_read(buffer, size) ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length)) #define can_read(buffer, size) ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length))
#define cannot_read(buffer, size) (!can_read(buffer, size)) #define cannot_read(buffer, size) (!can_read(buffer, size))
/* check if the buffer can be accessed at the given index (starting with 0) */ /* check if the buffer can be accessed at the given index (starting with 0) */
#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length)) #define can_access_at_index(buffer, deps_index) ((buffer != NULL) && (((buffer)->offset + deps_index) < (buffer)->length))
#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index)) #define cannot_access_at_index(buffer, deps_index) (!can_access_at_index(buffer, deps_index))
/* get a pointer to the buffer at the position */ /* get a pointer to the buffer at the position */
#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset) #define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
...@@ -992,7 +992,7 @@ fail: ...@@ -992,7 +992,7 @@ fail:
if (value != NULL) if (value != NULL)
{ {
error local_error; deps_error local_error;
local_error.json = (const unsigned char*)value; local_error.json = (const unsigned char*)value;
local_error.position = 0; local_error.position = 0;
...@@ -1683,7 +1683,7 @@ CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array) ...@@ -1683,7 +1683,7 @@ CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array)
return (int)size; return (int)size;
} }
static cJSON* get_array_item(const cJSON *array, size_t index) static cJSON* get_array_item(const cJSON *array, size_t deps_index)
{ {
cJSON *current_child = NULL; cJSON *current_child = NULL;
...@@ -1693,23 +1693,23 @@ static cJSON* get_array_item(const cJSON *array, size_t index) ...@@ -1693,23 +1693,23 @@ static cJSON* get_array_item(const cJSON *array, size_t index)
} }
current_child = array->child; current_child = array->child;
while ((current_child != NULL) && (index > 0)) while ((current_child != NULL) && (deps_index > 0))
{ {
index--; deps_index--;
current_child = current_child->next; current_child = current_child->next;
} }
return current_child; return current_child;
} }
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index) CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int deps_index)
{ {
if (index < 0) if (deps_index < 0)
{ {
return NULL; return NULL;
} }
return get_array_item(array, (size_t)index); return get_array_item(array, (size_t)deps_index);
} }
static cJSON *get_object_item(const cJSON * const object, const char * const name, const cJSON_bool case_sensitive) static cJSON *get_object_item(const cJSON * const object, const char * const name, const cJSON_bool case_sensitive)
......
...@@ -30,7 +30,7 @@ int main (int argc, char *argv[]) ...@@ -30,7 +30,7 @@ int main (int argc, char *argv[])
{ {
unsigned int data[0x100000]; unsigned int data[0x100000];
int uni2index[0x110000]; int uni2index[0x110000];
int index; int deps_index;
if (argc != 1) if (argc != 1)
exit(1); exit(1);
...@@ -64,7 +64,7 @@ int main (int argc, char *argv[]) ...@@ -64,7 +64,7 @@ int main (int argc, char *argv[])
int j; int j;
for (j = 0; j < 0x110000; j++) for (j = 0; j < 0x110000; j++)
uni2index[j] = -1; uni2index[j] = -1;
index = 0; deps_index = 0;
for (;;) { for (;;) {
c = getc(stdin); c = getc(stdin);
if (c == EOF) if (c == EOF)
...@@ -86,8 +86,8 @@ int main (int argc, char *argv[]) ...@@ -86,8 +86,8 @@ int main (int argc, char *argv[])
if (c == '\t') if (c == '\t')
break; break;
if (uni2index[j] < 0) { if (uni2index[j] < 0) {
uni2index[j] = index; uni2index[j] = deps_index;
data[index++] = 0; data[deps_index++] = 0;
} }
if (c >= 0x80) { if (c >= 0x80) {
/* Finish reading an UTF-8 character. */ /* Finish reading an UTF-8 character. */
...@@ -104,17 +104,17 @@ int main (int argc, char *argv[]) ...@@ -104,17 +104,17 @@ int main (int argc, char *argv[])
} }
} }
} }
data[index++] = (unsigned int) c; data[deps_index++] = (unsigned int) c;
} }
if (uni2index[j] >= 0) if (uni2index[j] >= 0)
data[uni2index[j]] = index - uni2index[j] - 1; data[uni2index[j]] = deps_index - uni2index[j] - 1;
do { c = getc(stdin); } while (!(c == EOF || c == '\n')); do { c = getc(stdin); } while (!(c == EOF || c == '\n'));
} }
} }
printf("static const unsigned int translit_data[%d] = {",index); printf("static const unsigned int translit_data[%d] = {",deps_index);
{ {
int i; int i;
for (i = 0; i < index; i++) { for (i = 0; i < deps_index; i++) {
if (data[i] < 32) if (data[i] < 32)
printf("\n %3d,",data[i]); printf("\n %3d,",data[i]);
else if (data[i] == '\'') else if (data[i] == '\'')
......
...@@ -491,7 +491,7 @@ const char * iconv_canonicalize (const char * name) ...@@ -491,7 +491,7 @@ const char * iconv_canonicalize (const char * name)
char* bp; char* bp;
const struct alias * ap; const struct alias * ap;
unsigned int count; unsigned int count;
unsigned int index; unsigned int deps_index;
const char* pool; const char* pool;
/* Before calling aliases_lookup, convert the input string to upper case, /* Before calling aliases_lookup, convert the input string to upper case,
...@@ -555,23 +555,23 @@ const char * iconv_canonicalize (const char * name) ...@@ -555,23 +555,23 @@ const char * iconv_canonicalize (const char * name)
This is also the case on native Woe32 systems. */ This is also the case on native Woe32 systems. */
#if __STDC_ISO_10646__ || ((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) #if __STDC_ISO_10646__ || ((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__)
if (sizeof(wchar_t) == 4) { if (sizeof(wchar_t) == 4) {
index = ei_ucs4internal; deps_index = ei_ucs4internal;
break; break;
} }
if (sizeof(wchar_t) == 2) { if (sizeof(wchar_t) == 2) {
index = ei_ucs2internal; deps_index = ei_ucs2internal;
break; break;
} }
if (sizeof(wchar_t) == 1) { if (sizeof(wchar_t) == 1) {
index = ei_iso8859_1; deps_index = ei_iso8859_1;
break; break;
} }
#endif #endif
} }
index = ap->encoding_index; deps_index = ap->encoding_index;
break; break;
} }
return all_canonical[index] + pool; return all_canonical[deps_index] + pool;
invalid: invalid:
return name; return name;
} }
......
...@@ -569,9 +569,9 @@ extern "C" { ...@@ -569,9 +569,9 @@ extern "C" {
return FALSE; return FALSE;
} }
AccessibleContext GetAccessibleChildFromContext(long vmID, AccessibleContext ac, jint index) { AccessibleContext GetAccessibleChildFromContext(long vmID, AccessibleContext ac, jint deps_index) {
if (theAccessBridgeInitializedFlag == TRUE) { if (theAccessBridgeInitializedFlag == TRUE) {
return theAccessBridge.GetAccessibleChildFromContext(vmID, ac, index); return theAccessBridge.GetAccessibleChildFromContext(vmID, ac, deps_index);
} }
return (AccessibleContext) 0; return (AccessibleContext) 0;
} }
...@@ -711,9 +711,9 @@ extern "C" { ...@@ -711,9 +711,9 @@ extern "C" {
* return the row number for a cell at a given index * return the row number for a cell at a given index
*/ */
jint jint
getAccessibleTableRow(long vmID, AccessibleTable table, jint index) { getAccessibleTableRow(long vmID, AccessibleTable table, jint deps_index) {
if (theAccessBridgeInitializedFlag == TRUE) { if (theAccessBridgeInitializedFlag == TRUE) {
return theAccessBridge.getAccessibleTableRow(vmID, table, index); return theAccessBridge.getAccessibleTableRow(vmID, table, deps_index);
} }
return -1; return -1;
} }
...@@ -722,9 +722,9 @@ extern "C" { ...@@ -722,9 +722,9 @@ extern "C" {
* return the column number for a cell at a given index * return the column number for a cell at a given index
*/ */
jint jint
getAccessibleTableColumn(long vmID, AccessibleTable table, jint index) { getAccessibleTableColumn(long vmID, AccessibleTable table, jint deps_index) {
if (theAccessBridgeInitializedFlag == TRUE) { if (theAccessBridgeInitializedFlag == TRUE) {
return theAccessBridge.getAccessibleTableColumn(vmID, table, index); return theAccessBridge.getAccessibleTableColumn(vmID, table, deps_index);
} }
return -1; return -1;
} }
...@@ -753,9 +753,9 @@ extern "C" { ...@@ -753,9 +753,9 @@ extern "C" {
return FALSE; return FALSE;
} }
BOOL GetAccessibleTextItems(long vmID, AccessibleText at, AccessibleTextItemsInfo *textItems, jint index) { BOOL GetAccessibleTextItems(long vmID, AccessibleText at, AccessibleTextItemsInfo *textItems, jint deps_index) {
if (theAccessBridgeInitializedFlag == TRUE) { if (theAccessBridgeInitializedFlag == TRUE) {
return theAccessBridge.GetAccessibleTextItems(vmID, at, textItems, index); return theAccessBridge.GetAccessibleTextItems(vmID, at, textItems, deps_index);
} }
return FALSE; return FALSE;
} }
...@@ -767,23 +767,23 @@ extern "C" { ...@@ -767,23 +767,23 @@ extern "C" {
return FALSE; return FALSE;
} }
BOOL GetAccessibleTextAttributes(long vmID, AccessibleText at, jint index, AccessibleTextAttributesInfo *attributes) { BOOL GetAccessibleTextAttributes(long vmID, AccessibleText at, jint deps_index, AccessibleTextAttributesInfo *attributes) {
if (theAccessBridgeInitializedFlag == TRUE) { if (theAccessBridgeInitializedFlag == TRUE) {
return theAccessBridge.GetAccessibleTextAttributes(vmID, at, index, attributes); return theAccessBridge.GetAccessibleTextAttributes(vmID, at, deps_index, attributes);
} }
return FALSE; return FALSE;
} }
BOOL GetAccessibleTextRect(long vmID, AccessibleText at, AccessibleTextRectInfo *rectInfo, jint index) { BOOL GetAccessibleTextRect(long vmID, AccessibleText at, AccessibleTextRectInfo *rectInfo, jint deps_index) {
if (theAccessBridgeInitializedFlag == TRUE) { if (theAccessBridgeInitializedFlag == TRUE) {
return theAccessBridge.GetAccessibleTextRect(vmID, at, rectInfo, index); return theAccessBridge.GetAccessibleTextRect(vmID, at, rectInfo, deps_index);
} }
return FALSE; return FALSE;
} }
BOOL GetAccessibleTextLineBounds(long vmID, AccessibleText at, jint index, jint *startIndex, jint *endIndex) { BOOL GetAccessibleTextLineBounds(long vmID, AccessibleText at, jint deps_index, jint *startIndex, jint *endIndex) {
if (theAccessBridgeInitializedFlag == TRUE) { if (theAccessBridgeInitializedFlag == TRUE) {
return theAccessBridge.GetAccessibleTextLineBounds(vmID, at, index, startIndex, endIndex); return theAccessBridge.GetAccessibleTextLineBounds(vmID, at, deps_index, startIndex, endIndex);
} }
return FALSE; return FALSE;
} }
...@@ -844,7 +844,7 @@ extern "C" { ...@@ -844,7 +844,7 @@ extern "C" {
/* /*
* This method is used to iterate through the hyperlinks in a component. It * This method is used to iterate through the hyperlinks in a component. It
* returns hypertext information for a component starting at hyperlink index * returns hypertext information for a component starting at hyperlink deps_index
* nStartIndex. No more than MAX_HYPERLINKS AccessibleHypertextInfo objects will * nStartIndex. No more than MAX_HYPERLINKS AccessibleHypertextInfo objects will
* be returned for each call to this method. * be returned for each call to this method.
* returns FALSE on error. * returns FALSE on error.
...@@ -1109,9 +1109,9 @@ extern "C" { ...@@ -1109,9 +1109,9 @@ extern "C" {
/** /**
* Gets the text caret location * Gets the text caret location
*/ */
BOOL getCaretLocation(long vmID, AccessibleContext ac, AccessibleTextRectInfo *rectInfo, jint index) { BOOL getCaretLocation(long vmID, AccessibleContext ac, AccessibleTextRectInfo *rectInfo, jint deps_index) {
if (theAccessBridgeInitializedFlag == TRUE) { if (theAccessBridgeInitializedFlag == TRUE) {
return theAccessBridge.getCaretLocation(vmID, ac, rectInfo, index); return theAccessBridge.getCaretLocation(vmID, ac, rectInfo, deps_index);
} }
return FALSE; return FALSE;
} }
......
...@@ -114,13 +114,13 @@ static void setprogdir (lua_State *L) { ...@@ -114,13 +114,13 @@ static void setprogdir (lua_State *L) {
static void pusherror (lua_State *L) { static void pusherror (lua_State *L) {
int error = GetLastError(); int lua_error = GetLastError();
char buffer[128]; char buffer[128];
if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
NULL, error, 0, buffer, sizeof(buffer), NULL)) NULL, lua_error, 0, buffer, sizeof(buffer), NULL))
lua_pushstring(L, buffer); lua_pushstring(L, buffer);
else else
lua_pushfstring(L, "system error %d\n", error); lua_pushfstring(L, "system error %d\n", lua_error);
} }
static void ll_unloadlib (void *lib) { static void ll_unloadlib (void *lib) {
......
...@@ -120,7 +120,7 @@ static reg_errcode_t build_charclass (re_bitset_ptr_t sbcset, ...@@ -120,7 +120,7 @@ static reg_errcode_t build_charclass (re_bitset_ptr_t sbcset,
static bin_tree_t *build_word_op (re_dfa_t *dfa, int not, reg_errcode_t *err); static bin_tree_t *build_word_op (re_dfa_t *dfa, int not, reg_errcode_t *err);
static void free_bin_tree (bin_tree_t *tree); static void free_bin_tree (bin_tree_t *tree);
static bin_tree_t *create_tree (bin_tree_t *left, bin_tree_t *right, static bin_tree_t *create_tree (bin_tree_t *left, bin_tree_t *right,
re_token_type_t type, int index); re_token_type_t type, int deps_index);
static bin_tree_t *duplicate_tree (const bin_tree_t *src, re_dfa_t *dfa); static bin_tree_t *duplicate_tree (const bin_tree_t *src, re_dfa_t *dfa);
/* This table gives an error message for each of the error codes listed /* This table gives an error message for each of the error codes listed
...@@ -3447,11 +3447,11 @@ free_charset (re_charset_t *cset) ...@@ -3447,11 +3447,11 @@ free_charset (re_charset_t *cset)
Note: This function automatically free left and right if malloc fails. */ Note: This function automatically free left and right if malloc fails. */
static bin_tree_t * static bin_tree_t *
create_tree (left, right, type, index) create_tree (left, right, type, deps_index)
bin_tree_t *left; bin_tree_t *left;
bin_tree_t *right; bin_tree_t *right;
re_token_type_t type; re_token_type_t type;
int index; int deps_index;
{ {
bin_tree_t *tree; bin_tree_t *tree;
tree = re_malloc (bin_tree_t, 1); tree = re_malloc (bin_tree_t, 1);
...@@ -3465,7 +3465,7 @@ create_tree (left, right, type, index) ...@@ -3465,7 +3465,7 @@ create_tree (left, right, type, index)
tree->left = left; tree->left = left;
tree->right = right; tree->right = right;
tree->type = type; tree->type = type;
tree->node_idx = index; tree->node_idx = deps_index;
tree->first = -1; tree->first = -1;
tree->next = -1; tree->next = -1;
re_node_set_init_empty (&tree->eclosure); re_node_set_init_empty (&tree->eclosure);
......
name: tdengine name: tdengine
base: core18 base: core18
version: '2.2.1.3' version: '2.2.2.0'
icon: snap/gui/t-dengine.svg icon: snap/gui/t-dengine.svg
summary: an open-source big data platform designed and optimized for IoT. summary: an open-source big data platform designed and optimized for IoT.
description: | description: |
...@@ -72,7 +72,7 @@ parts: ...@@ -72,7 +72,7 @@ parts:
- usr/bin/taosd - usr/bin/taosd
- usr/bin/taos - usr/bin/taos
- usr/bin/taosdemo - usr/bin/taosdemo
- usr/lib/libtaos.so.2.2.1.3 - usr/lib/libtaos.so.2.2.2.0
- usr/lib/libtaos.so.1 - usr/lib/libtaos.so.1
- usr/lib/libtaos.so - usr/lib/libtaos.so
......
...@@ -32,7 +32,9 @@ IF (TD_LINUX) ...@@ -32,7 +32,9 @@ IF (TD_LINUX)
#MESSAGE(STATUS "build version ${TD_VER_NUMBER}") #MESSAGE(STATUS "build version ${TD_VER_NUMBER}")
SET_TARGET_PROPERTIES(taos PROPERTIES VERSION ${TD_VER_NUMBER} SOVERSION 1) SET_TARGET_PROPERTIES(taos PROPERTIES VERSION ${TD_VER_NUMBER} SOVERSION 1)
ADD_SUBDIRECTORY(tests) IF (NOT TD_NINGSI_60)
ADD_SUBDIRECTORY(tests)
ENDIF ()
ELSEIF (TD_DARWIN) ELSEIF (TD_DARWIN)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/linux) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/linux)
...@@ -53,8 +55,9 @@ ELSEIF (TD_DARWIN) ...@@ -53,8 +55,9 @@ ELSEIF (TD_DARWIN)
#SOVERSION dylib version #SOVERSION dylib version
#MESSAGE(STATUS "build version ${TD_VER_NUMBER}") #MESSAGE(STATUS "build version ${TD_VER_NUMBER}")
SET_TARGET_PROPERTIES(taos PROPERTIES VERSION ${TD_VER_NUMBER} SOVERSION 1) SET_TARGET_PROPERTIES(taos PROPERTIES VERSION ${TD_VER_NUMBER} SOVERSION 1)
IF (NOT TD_NINGSI_60)
ADD_SUBDIRECTORY(tests) ADD_SUBDIRECTORY(tests)
ENDIF ()
ELSEIF (TD_WINDOWS) ELSEIF (TD_WINDOWS)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows)
......
...@@ -236,7 +236,7 @@ void taos_fetch_rows_a(TAOS_RES *tres, __async_cb_func_t fp, void *param) { ...@@ -236,7 +236,7 @@ void taos_fetch_rows_a(TAOS_RES *tres, __async_cb_func_t fp, void *param) {
return; return;
} }
if (pRes->qId == 0) { if (pRes->qId == 0 && pSql->cmd.command != TSDB_SQL_RETRIEVE_EMPTY_RESULT) {
tscError("qhandle is invalid"); tscError("qhandle is invalid");
pRes->code = TSDB_CODE_TSC_INVALID_QHANDLE; pRes->code = TSDB_CODE_TSC_INVALID_QHANDLE;
tscAsyncResultOnError(pSql); tscAsyncResultOnError(pSql);
......
...@@ -33,12 +33,12 @@ typedef struct SCompareParam { ...@@ -33,12 +33,12 @@ typedef struct SCompareParam {
int32_t groupOrderType; int32_t groupOrderType;
} SCompareParam; } SCompareParam;
static bool needToMerge(SSDataBlock* pBlock, SArray* columnIndexList, int32_t index, char **buf) { static bool needToMerge(SSDataBlock* pBlock, SArray* columnIndexList, int32_t tsc_index, char **buf) {
int32_t ret = 0; int32_t ret = 0;
size_t size = taosArrayGetSize(columnIndexList); size_t size = taosArrayGetSize(columnIndexList);
if (size > 0) { if (size > 0) {
ret = compare_aRv(pBlock, columnIndexList, (int32_t) size, index, buf, TSDB_ORDER_ASC); ret = compare_aRv(pBlock, columnIndexList, (int32_t) size, tsc_index, buf, TSDB_ORDER_ASC);
} }
// if ret == 0, means the result belongs to the same group // if ret == 0, means the result belongs to the same group
...@@ -555,9 +555,9 @@ static void savePrevOrderColumns(char** prevRow, SArray* pColumnList, SSDataBloc ...@@ -555,9 +555,9 @@ static void savePrevOrderColumns(char** prevRow, SArray* pColumnList, SSDataBloc
int32_t size = (int32_t) taosArrayGetSize(pColumnList); int32_t size = (int32_t) taosArrayGetSize(pColumnList);
for(int32_t i = 0; i < size; ++i) { for(int32_t i = 0; i < size; ++i) {
SColIndex* index = taosArrayGet(pColumnList, i); SColIndex* tsc_index = taosArrayGet(pColumnList, i);
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, index->colIndex); SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, tsc_index->colIndex);
assert(index->colId == pColInfo->info.colId); assert(tsc_index->colId == pColInfo->info.colId);
memcpy(prevRow[i], pColInfo->pData + pColInfo->info.bytes * rowIndex, pColInfo->info.bytes); memcpy(prevRow[i], pColInfo->pData + pColInfo->info.bytes * rowIndex, pColInfo->info.bytes);
} }
...@@ -967,7 +967,6 @@ SSDataBlock* doGlobalAggregate(void* param, bool* newgroup) { ...@@ -967,7 +967,6 @@ SSDataBlock* doGlobalAggregate(void* param, bool* newgroup) {
if (pOperator->pRuntimeEnv->pQueryAttr->order.order == TSDB_ORDER_DESC) { if (pOperator->pRuntimeEnv->pQueryAttr->order.order == TSDB_ORDER_DESC) {
SWAP(w->skey, w->ekey, TSKEY); SWAP(w->skey, w->ekey, TSKEY);
assert(w->skey <= w->ekey);
} }
} }
} }
......
...@@ -152,7 +152,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) { ...@@ -152,7 +152,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols, int32_t typeColLength, static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols, int32_t typeColLength,
int32_t noteColLength) { int32_t noteColLength) {
int32_t rowLen = 0; int32_t rowLen = 0;
SColumnIndex index = {0}; SColumnIndex tsc_index = {0};
pSql->cmd.numOfCols = numOfCols; pSql->cmd.numOfCols = numOfCols;
...@@ -163,7 +163,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols, ...@@ -163,7 +163,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
tstrncpy(f.name, "Field", sizeof(f.name)); tstrncpy(f.name, "Field", sizeof(f.name));
SInternalField* pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f); SInternalField* pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &tsc_index, TSDB_DATA_TYPE_BINARY,
(TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE, -1000, (TSDB_COL_NAME_LEN - 1), false); (TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE, -1000, (TSDB_COL_NAME_LEN - 1), false);
rowLen += ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE); rowLen += ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE);
...@@ -173,7 +173,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols, ...@@ -173,7 +173,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
tstrncpy(f.name, "Type", sizeof(f.name)); tstrncpy(f.name, "Type", sizeof(f.name));
pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f); pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, (int16_t)(typeColLength + VARSTR_HEADER_SIZE), pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &tsc_index, TSDB_DATA_TYPE_BINARY, (int16_t)(typeColLength + VARSTR_HEADER_SIZE),
-1000, typeColLength, false); -1000, typeColLength, false);
rowLen += typeColLength + VARSTR_HEADER_SIZE; rowLen += typeColLength + VARSTR_HEADER_SIZE;
...@@ -183,7 +183,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols, ...@@ -183,7 +183,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
tstrncpy(f.name, "Length", sizeof(f.name)); tstrncpy(f.name, "Length", sizeof(f.name));
pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f); pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_INT, sizeof(int32_t), pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &tsc_index, TSDB_DATA_TYPE_INT, sizeof(int32_t),
-1000, sizeof(int32_t), false); -1000, sizeof(int32_t), false);
rowLen += sizeof(int32_t); rowLen += sizeof(int32_t);
...@@ -193,7 +193,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols, ...@@ -193,7 +193,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
tstrncpy(f.name, "Note", sizeof(f.name)); tstrncpy(f.name, "Note", sizeof(f.name));
pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f); pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, (int16_t)(noteColLength + VARSTR_HEADER_SIZE), pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &tsc_index, TSDB_DATA_TYPE_BINARY, (int16_t)(noteColLength + VARSTR_HEADER_SIZE),
-1000, noteColLength, false); -1000, noteColLength, false);
rowLen += noteColLength + VARSTR_HEADER_SIZE; rowLen += noteColLength + VARSTR_HEADER_SIZE;
...@@ -396,7 +396,7 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) { ...@@ -396,7 +396,7 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) {
static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const char *ddl) { static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const char *ddl) {
int32_t rowLen = 0; int32_t rowLen = 0;
int16_t ddlLen = (int16_t)strlen(ddl); int16_t ddlLen = (int16_t)strlen(ddl);
SColumnIndex index = {0}; SColumnIndex tsc_index = {0};
pSql->cmd.numOfCols = 2; pSql->cmd.numOfCols = 2;
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd); SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd);
...@@ -414,7 +414,7 @@ static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const ...@@ -414,7 +414,7 @@ static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const
} }
SInternalField* pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f); SInternalField* pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, f.bytes, -1000, f.bytes - VARSTR_HEADER_SIZE, false); pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &tsc_index, TSDB_DATA_TYPE_BINARY, f.bytes, -1000, f.bytes - VARSTR_HEADER_SIZE, false);
rowLen += f.bytes; rowLen += f.bytes;
...@@ -427,7 +427,7 @@ static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const ...@@ -427,7 +427,7 @@ static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const
} }
pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f); pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &tsc_index, TSDB_DATA_TYPE_BINARY,
(int16_t)(ddlLen + VARSTR_HEADER_SIZE), -1000, ddlLen, false); (int16_t)(ddlLen + VARSTR_HEADER_SIZE), -1000, ddlLen, false);
rowLen += ddlLen + VARSTR_HEADER_SIZE; rowLen += ddlLen + VARSTR_HEADER_SIZE;
......
...@@ -91,8 +91,8 @@ int initMemRowBuilder(SMemRowBuilder *pBuilder, uint32_t nRows, uint3 ...@@ -91,8 +91,8 @@ int initMemRowBuilder(SMemRowBuilder *pBuilder, uint32_t nRows, uint3
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int16_t timePrec) { int tsParseTime(SStrToken *pToken, int64_t *tsc_time, char **next, char *tsc_error, int16_t timePrec) {
int32_t index = 0; int32_t tsc_index = 0;
SStrToken sToken; SStrToken sToken;
int64_t interval; int64_t interval;
int64_t useconds = 0; int64_t useconds = 0;
...@@ -106,8 +106,8 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1 ...@@ -106,8 +106,8 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
useconds = taosStr2int64(pToken->z); useconds = taosStr2int64(pToken->z);
} else { } else {
// strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm); // strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm);
if (taosParseTime(pToken->z, time, pToken->n, timePrec, tsDaylight) != TSDB_CODE_SUCCESS) { if (taosParseTime(pToken->z, tsc_time, pToken->n, timePrec, tsDaylight) != TSDB_CODE_SUCCESS) {
return tscInvalidOperationMsg(error, "invalid timestamp format", pToken->z); return tscInvalidOperationMsg(tsc_error, "invalid timestamp format", pToken->z);
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
...@@ -117,7 +117,7 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1 ...@@ -117,7 +117,7 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
if (isspace(pToken->z[k])) continue; if (isspace(pToken->z[k])) continue;
if (pToken->z[k] == ',') { if (pToken->z[k] == ',') {
*next = pTokenEnd; *next = pTokenEnd;
*time = useconds; *tsc_time = useconds;
return 0; return 0;
} }
...@@ -125,21 +125,21 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1 ...@@ -125,21 +125,21 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
} }
/* /*
* time expression: * tsc_time expression:
* e.g., now+12a, now-5h * e.g., now+12a, now-5h
*/ */
SStrToken valueToken; SStrToken valueToken;
index = 0; tsc_index = 0;
sToken = tStrGetToken(pTokenEnd, &index, false); sToken = tStrGetToken(pTokenEnd, &tsc_index, false);
pTokenEnd += index; pTokenEnd += tsc_index;
if (sToken.type == TK_MINUS || sToken.type == TK_PLUS) { if (sToken.type == TK_MINUS || sToken.type == TK_PLUS) {
index = 0; tsc_index = 0;
valueToken = tStrGetToken(pTokenEnd, &index, false); valueToken = tStrGetToken(pTokenEnd, &tsc_index, false);
pTokenEnd += index; pTokenEnd += tsc_index;
if (valueToken.n < 2) { if (valueToken.n < 2) {
return tscInvalidOperationMsg(error, "value expected in timestamp", sToken.z); return tscInvalidOperationMsg(tsc_error, "value expected in timestamp", sToken.z);
} }
char unit = 0; char unit = 0;
...@@ -156,7 +156,7 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1 ...@@ -156,7 +156,7 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
*next = pTokenEnd; *next = pTokenEnd;
} }
*time = useconds; *tsc_time = useconds;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -448,7 +448,7 @@ int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start) { ...@@ -448,7 +448,7 @@ int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start) {
int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, int32_t *len, char *tmpTokenBuf, int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, int32_t *len, char *tmpTokenBuf,
SInsertStatementParam *pInsertParam) { SInsertStatementParam *pInsertParam) {
int32_t index = 0; int32_t tsc_index = 0;
SStrToken sToken = {0}; SStrToken sToken = {0};
char *row = pDataBlocks->pData + pDataBlocks->size; // skip the SSubmitBlk header char *row = pDataBlocks->pData + pDataBlocks->size; // skip the SSubmitBlk header
...@@ -472,9 +472,9 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i ...@@ -472,9 +472,9 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i
SSchema *pSchema = &schema[colIndex]; // get colId here SSchema *pSchema = &schema[colIndex]; // get colId here
index = 0; tsc_index = 0;
sToken = tStrGetToken(*str, &index, true); sToken = tStrGetToken(*str, &tsc_index, true);
*str += index; *str += tsc_index;
if (sToken.type == TK_QUESTION) { if (sToken.type == TK_QUESTION) {
if (!isParseBindParam) { if (!isParseBindParam) {
...@@ -606,7 +606,7 @@ int32_t boundIdxCompar(const void *lhs, const void *rhs) { ...@@ -606,7 +606,7 @@ int32_t boundIdxCompar(const void *lhs, const void *rhs) {
int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SInsertStatementParam *pInsertParam, int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SInsertStatementParam *pInsertParam,
int32_t* numOfRows, char *tmpTokenBuf) { int32_t* numOfRows, char *tmpTokenBuf) {
int32_t index = 0; int32_t tsc_index = 0;
int32_t code = 0; int32_t code = 0;
(*numOfRows) = 0; (*numOfRows) = 0;
...@@ -626,11 +626,11 @@ int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SIn ...@@ -626,11 +626,11 @@ int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SIn
return code; return code;
} }
while (1) { while (1) {
index = 0; tsc_index = 0;
sToken = tStrGetToken(*str, &index, false); sToken = tStrGetToken(*str, &tsc_index, false);
if (sToken.n == 0 || sToken.type != TK_LP) break; if (sToken.n == 0 || sToken.type != TK_LP) break;
*str += index; *str += tsc_index;
if ((*numOfRows) >= maxRows || pDataBlock->size + extendedRowSize >= pDataBlock->nAllocSize) { if ((*numOfRows) >= maxRows || pDataBlock->size + extendedRowSize >= pDataBlock->nAllocSize) {
int32_t tSize; int32_t tSize;
code = tscAllocateMemIfNeed(pDataBlock, extendedRowSize, &tSize); code = tscAllocateMemIfNeed(pDataBlock, extendedRowSize, &tSize);
...@@ -651,13 +651,13 @@ int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SIn ...@@ -651,13 +651,13 @@ int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SIn
pDataBlock->size += len; pDataBlock->size += len;
index = 0; tsc_index = 0;
sToken = tStrGetToken(*str, &index, false); sToken = tStrGetToken(*str, &tsc_index, false);
if (sToken.n == 0 || sToken.type != TK_RP) { if (sToken.n == 0 || sToken.type != TK_RP) {
return tscSQLSyntaxErrMsg(pInsertParam->msg, ") expected", *str); return tscSQLSyntaxErrMsg(pInsertParam->msg, ") expected", *str);
} }
*str += index; *str += tsc_index;
(*numOfRows)++; (*numOfRows)++;
} }
...@@ -905,7 +905,7 @@ static int32_t doParseInsertStatement(SInsertStatementParam *pInsertParam, char ...@@ -905,7 +905,7 @@ static int32_t doParseInsertStatement(SInsertStatementParam *pInsertParam, char
} }
static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundColumn) { static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundColumn) {
int32_t index = 0; int32_t tsc_index = 0;
SStrToken sToken = {0}; SStrToken sToken = {0};
SStrToken tableToken = {0}; SStrToken tableToken = {0};
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
...@@ -920,14 +920,14 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC ...@@ -920,14 +920,14 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
char *sql = *sqlstr; char *sql = *sqlstr;
// get the token of specified table // get the token of specified table
index = 0; tsc_index = 0;
tableToken = tStrGetToken(sql, &index, false); tableToken = tStrGetToken(sql, &tsc_index, false);
sql += index; sql += tsc_index;
// skip possibly exists column list // skip possibly exists column list
index = 0; tsc_index = 0;
sToken = tStrGetToken(sql, &index, false); sToken = tStrGetToken(sql, &tsc_index, false);
sql += index; sql += tsc_index;
int32_t numOfColList = 0; int32_t numOfColList = 0;
...@@ -936,8 +936,8 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC ...@@ -936,8 +936,8 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
*boundColumn = &sToken.z[0]; *boundColumn = &sToken.z[0];
while (1) { while (1) {
index = 0; tsc_index = 0;
sToken = tStrGetToken(sql, &index, false); sToken = tStrGetToken(sql, &tsc_index, false);
if (sToken.type == TK_ILLEGAL) { if (sToken.type == TK_ILLEGAL) {
return tscSQLSyntaxErrMsg(pCmd->payload, "unrecognized token", sToken.z); return tscSQLSyntaxErrMsg(pCmd->payload, "unrecognized token", sToken.z);
...@@ -947,12 +947,12 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC ...@@ -947,12 +947,12 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
break; break;
} }
sql += index; sql += tsc_index;
++numOfColList; ++numOfColList;
} }
sToken = tStrGetToken(sql, &index, false); sToken = tStrGetToken(sql, &tsc_index, false);
sql += index; sql += tsc_index;
} }
if (numOfColList == 0 && (*boundColumn) != NULL) { if (numOfColList == 0 && (*boundColumn) != NULL) {
...@@ -962,9 +962,9 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC ...@@ -962,9 +962,9 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, TABLE_INDEX); STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, TABLE_INDEX);
if (sToken.type == TK_USING) { // create table if not exists according to the super table if (sToken.type == TK_USING) { // create table if not exists according to the super table
index = 0; tsc_index = 0;
sToken = tStrGetToken(sql, &index, false); sToken = tStrGetToken(sql, &tsc_index, false);
sql += index; sql += tsc_index;
//the source super table is moved to the secondary position of the pTableMetaInfo list //the source super table is moved to the secondary position of the pTableMetaInfo list
if (pQueryInfo->numOfTables < 2) { if (pQueryInfo->numOfTables < 2) {
...@@ -995,8 +995,8 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC ...@@ -995,8 +995,8 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
SParsedDataColInfo spd = {0}; SParsedDataColInfo spd = {0};
tscSetBoundColumnInfo(&spd, pTagSchema, tscGetNumOfTags(pSTableMetaInfo->pTableMeta)); tscSetBoundColumnInfo(&spd, pTagSchema, tscGetNumOfTags(pSTableMetaInfo->pTableMeta));
index = 0; tsc_index = 0;
sToken = tStrGetToken(sql, &index, false); sToken = tStrGetToken(sql, &tsc_index, false);
if (sToken.type != TK_TAGS && sToken.type != TK_LP) { if (sToken.type != TK_TAGS && sToken.type != TK_LP) {
tscDestroyBoundColumnInfo(&spd); tscDestroyBoundColumnInfo(&spd);
return tscSQLSyntaxErrMsg(pInsertParam->msg, "keyword TAGS expected", sToken.z); return tscSQLSyntaxErrMsg(pInsertParam->msg, "keyword TAGS expected", sToken.z);
...@@ -1017,16 +1017,16 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC ...@@ -1017,16 +1017,16 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
sql = end; sql = end;
index = 0; // keywords of "TAGS" tsc_index = 0; // keywords of "TAGS"
sToken = tStrGetToken(sql, &index, false); sToken = tStrGetToken(sql, &tsc_index, false);
sql += index; sql += tsc_index;
} else { } else {
sql += index; sql += tsc_index;
} }
index = 0; tsc_index = 0;
sToken = tStrGetToken(sql, &index, false); sToken = tStrGetToken(sql, &tsc_index, false);
sql += index; sql += tsc_index;
if (sToken.type != TK_LP) { if (sToken.type != TK_LP) {
tscDestroyBoundColumnInfo(&spd); tscDestroyBoundColumnInfo(&spd);
...@@ -1042,9 +1042,9 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC ...@@ -1042,9 +1042,9 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
for (int i = 0; i < spd.numOfBound; ++i) { for (int i = 0; i < spd.numOfBound; ++i) {
SSchema* pSchema = &pTagSchema[spd.boundedColumns[i]]; SSchema* pSchema = &pTagSchema[spd.boundedColumns[i]];
index = 0; tsc_index = 0;
sToken = tStrGetToken(sql, &index, true); sToken = tStrGetToken(sql, &tsc_index, true);
sql += index; sql += tsc_index;
if (TK_ILLEGAL == sToken.type) { if (TK_ILLEGAL == sToken.type) {
tdDestroyKVRowBuilder(&kvRowBuilder); tdDestroyKVRowBuilder(&kvRowBuilder);
...@@ -1096,9 +1096,9 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC ...@@ -1096,9 +1096,9 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
free(row); free(row);
pInsertParam->tagData.data = pTag; pInsertParam->tagData.data = pTag;
index = 0; tsc_index = 0;
sToken = tStrGetToken(sql, &index, false); sToken = tStrGetToken(sql, &tsc_index, false);
sql += index; sql += tsc_index;
if (sToken.n == 0 || sToken.type != TK_RP) { if (sToken.n == 0 || sToken.type != TK_RP) {
return tscSQLSyntaxErrMsg(pInsertParam->msg, ") expected", sToken.z); return tscSQLSyntaxErrMsg(pInsertParam->msg, ") expected", sToken.z);
} }
...@@ -1107,9 +1107,9 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC ...@@ -1107,9 +1107,9 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
* insert into table_name using super_table(tag_name1, tag_name2) tags(tag_val1, tag_val2) * insert into table_name using super_table(tag_name1, tag_name2) tags(tag_val1, tag_val2)
* (normal_col1, normal_col2) values(normal_col1_val, normal_col2_val); * (normal_col1, normal_col2) values(normal_col1_val, normal_col2_val);
* */ * */
index = 0; tsc_index = 0;
sToken = tStrGetToken(sql, &index, false); sToken = tStrGetToken(sql, &tsc_index, false);
sql += index; sql += tsc_index;
int numOfColsAfterTags = 0; int numOfColsAfterTags = 0;
if (sToken.type == TK_LP) { if (sToken.type == TK_LP) {
if (*boundColumn != NULL) { if (*boundColumn != NULL) {
...@@ -1119,18 +1119,18 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC ...@@ -1119,18 +1119,18 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
} }
while (1) { while (1) {
index = 0; tsc_index = 0;
sToken = tStrGetToken(sql, &index, false); sToken = tStrGetToken(sql, &tsc_index, false);
if (sToken.type == TK_RP) { if (sToken.type == TK_RP) {
break; break;
} }
if (sToken.n == 0 || sToken.type == TK_SEMI || index == 0) { if (sToken.n == 0 || sToken.type == TK_SEMI || tsc_index == 0) {
return tscSQLSyntaxErrMsg(pCmd->payload, "unexpected token", sql); return tscSQLSyntaxErrMsg(pCmd->payload, "unexpected token", sql);
} }
sql += index; sql += tsc_index;
++numOfColsAfterTags; ++numOfColsAfterTags;
} }
...@@ -1138,7 +1138,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC ...@@ -1138,7 +1138,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
return TSDB_CODE_TSC_SQL_SYNTAX_ERROR; return TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
} }
sToken = tStrGetToken(sql, &index, false); sToken = tStrGetToken(sql, &tsc_index, false);
} }
sql = sToken.z; sql = sToken.z;
...@@ -1213,9 +1213,9 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat ...@@ -1213,9 +1213,9 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
int32_t index = 0; int32_t tsc_index = 0;
SStrToken sToken = tStrGetToken(str, &index, false); SStrToken sToken = tStrGetToken(str, &tsc_index, false);
str += index; str += tsc_index;
if (sToken.type != TK_LP) { if (sToken.type != TK_LP) {
code = tscSQLSyntaxErrMsg(pInsertParam->msg, "( is expected", sToken.z); code = tscSQLSyntaxErrMsg(pInsertParam->msg, "( is expected", sToken.z);
...@@ -1225,9 +1225,9 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat ...@@ -1225,9 +1225,9 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
bool isOrdered = true; bool isOrdered = true;
int32_t lastColIdx = -1; // last column found int32_t lastColIdx = -1; // last column found
while (1) { while (1) {
index = 0; tsc_index = 0;
sToken = tStrGetToken(str, &index, false); sToken = tStrGetToken(str, &tsc_index, false);
str += index; str += tsc_index;
if (TK_STRING == sToken.type) { if (TK_STRING == sToken.type) {
tscDequoteAndTrimToken(&sToken); tscDequoteAndTrimToken(&sToken);
...@@ -1378,8 +1378,8 @@ int tsParseInsertSql(SSqlObj *pSql) { ...@@ -1378,8 +1378,8 @@ int tsParseInsertSql(SSqlObj *pSql) {
tscDebug("0x%"PRIx64" create data block list hashList:%p", pSql->self, pInsertParam->pTableBlockHashList); tscDebug("0x%"PRIx64" create data block list hashList:%p", pSql->self, pInsertParam->pTableBlockHashList);
while (1) { while (1) {
int32_t index = 0; int32_t tsc_index = 0;
SStrToken sToken = tStrGetToken(str, &index, false); SStrToken sToken = tStrGetToken(str, &tsc_index, false);
// no data in the sql string anymore. // no data in the sql string anymore.
if (sToken.n == 0) { if (sToken.n == 0) {
...@@ -1437,9 +1437,9 @@ int tsParseInsertSql(SSqlObj *pSql) { ...@@ -1437,9 +1437,9 @@ int tsParseInsertSql(SSqlObj *pSql) {
goto _clean; goto _clean;
} }
index = 0; tsc_index = 0;
sToken = tStrGetToken(str, &index, false); sToken = tStrGetToken(str, &tsc_index, false);
str += index; str += tsc_index;
if (sToken.n == 0 || (sToken.type != TK_FILE && sToken.type != TK_VALUES)) { if (sToken.n == 0 || (sToken.type != TK_FILE && sToken.type != TK_VALUES)) {
code = tscSQLSyntaxErrMsg(pInsertParam->msg, "keyword VALUES or FILE required", sToken.z); code = tscSQLSyntaxErrMsg(pInsertParam->msg, "keyword VALUES or FILE required", sToken.z);
...@@ -1452,13 +1452,13 @@ int tsParseInsertSql(SSqlObj *pSql) { ...@@ -1452,13 +1452,13 @@ int tsParseInsertSql(SSqlObj *pSql) {
goto _clean; goto _clean;
} }
index = 0; tsc_index = 0;
sToken = tStrGetToken(str, &index, false); sToken = tStrGetToken(str, &tsc_index, false);
if (sToken.type != TK_STRING && sToken.type != TK_ID) { if (sToken.type != TK_STRING && sToken.type != TK_ID) {
code = tscSQLSyntaxErrMsg(pInsertParam->msg, "file path is required following keyword FILE", sToken.z); code = tscSQLSyntaxErrMsg(pInsertParam->msg, "file path is required following keyword FILE", sToken.z);
goto _clean; goto _clean;
} }
str += index; str += tsc_index;
if (sToken.n == 0) { if (sToken.n == 0) {
code = tscSQLSyntaxErrMsg(pInsertParam->msg, "file path is required following keyword FILE", sToken.z); code = tscSQLSyntaxErrMsg(pInsertParam->msg, "file path is required following keyword FILE", sToken.z);
goto _clean; goto _clean;
...@@ -1553,10 +1553,10 @@ int tsInsertInitialCheck(SSqlObj *pSql) { ...@@ -1553,10 +1553,10 @@ int tsInsertInitialCheck(SSqlObj *pSql) {
return TSDB_CODE_TSC_NO_WRITE_AUTH; return TSDB_CODE_TSC_NO_WRITE_AUTH;
} }
int32_t index = 0; int32_t tsc_index = 0;
SSqlCmd *pCmd = &pSql->cmd; SSqlCmd *pCmd = &pSql->cmd;
SStrToken sToken = tStrGetToken(pSql->sqlstr, &index, false); SStrToken sToken = tStrGetToken(pSql->sqlstr, &tsc_index, false);
assert(sToken.type == TK_INSERT || sToken.type == TK_IMPORT); assert(sToken.type == TK_INSERT || sToken.type == TK_IMPORT);
pCmd->count = 0; pCmd->count = 0;
...@@ -1566,7 +1566,7 @@ int tsInsertInitialCheck(SSqlObj *pSql) { ...@@ -1566,7 +1566,7 @@ int tsInsertInitialCheck(SSqlObj *pSql) {
SQueryInfo *pQueryInfo = tscGetQueryInfoS(pCmd); SQueryInfo *pQueryInfo = tscGetQueryInfoS(pCmd);
TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_INSERT); TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_INSERT);
sToken = tStrGetToken(pSql->sqlstr, &index, false); sToken = tStrGetToken(pSql->sqlstr, &tsc_index, false);
if (sToken.type != TK_INTO) { if (sToken.type != TK_INTO) {
return tscSQLSyntaxErrMsg(pInsertParam->msg, "keyword INTO is expected", sToken.z); return tscSQLSyntaxErrMsg(pInsertParam->msg, "keyword INTO is expected", sToken.z);
} }
......
...@@ -970,25 +970,25 @@ static int32_t applyChildTableTags(TAOS* taos, char* cTableName, char* sTableNam ...@@ -970,25 +970,25 @@ static int32_t applyChildTableTags(TAOS* taos, char* cTableName, char* sTableNam
taosArraySetSize(tagBinds, numTags); taosArraySetSize(tagBinds, numTags);
int isNullColBind = TSDB_TRUE; int isNullColBind = TSDB_TRUE;
for (int j = 0; j < numTags; ++j) { for (int j = 0; j < numTags; ++j) {
TAOS_BIND* bind = taosArrayGet(tagBinds, j); TAOS_BIND* tsc_bind = taosArrayGet(tagBinds, j);
bind->is_null = &isNullColBind; tsc_bind->is_null = &isNullColBind;
} }
for (int j = 0; j < numTags; ++j) { for (int j = 0; j < numTags; ++j) {
if (tagKVs[j] == NULL) continue; if (tagKVs[j] == NULL) continue;
TAOS_SML_KV* kv = tagKVs[j]; TAOS_SML_KV* kv = tagKVs[j];
TAOS_BIND* bind = taosArrayGet(tagBinds, kv->fieldSchemaIdx); TAOS_BIND* tsc_bind = taosArrayGet(tagBinds, kv->fieldSchemaIdx);
bind->buffer_type = kv->type; tsc_bind->buffer_type = kv->type;
bind->length = malloc(sizeof(uintptr_t*)); tsc_bind->length = malloc(sizeof(uintptr_t*));
*bind->length = kv->length; *tsc_bind->length = kv->length;
bind->buffer = kv->value; tsc_bind->buffer = kv->value;
bind->is_null = NULL; tsc_bind->is_null = NULL;
} }
int32_t code = creatChildTableIfNotExists(taos, cTableName, sTableName, sTableSchema->tags, tagBinds, info); int32_t code = creatChildTableIfNotExists(taos, cTableName, sTableName, sTableSchema->tags, tagBinds, info);
for (int i = 0; i < taosArrayGetSize(tagBinds); ++i) { for (int i = 0; i < taosArrayGetSize(tagBinds); ++i) {
TAOS_BIND* bind = taosArrayGet(tagBinds, i); TAOS_BIND* tsc_bind = taosArrayGet(tagBinds, i);
free(bind->length); free(tsc_bind->length);
} }
taosArrayDestroy(tagBinds); taosArrayDestroy(tagBinds);
return code; return code;
...@@ -1014,17 +1014,17 @@ static int32_t applyChildTableFields(TAOS* taos, SSmlSTableSchema* sTableSchema, ...@@ -1014,17 +1014,17 @@ static int32_t applyChildTableFields(TAOS* taos, SSmlSTableSchema* sTableSchema,
} }
for (int j = 0; j < numCols; ++j) { for (int j = 0; j < numCols; ++j) {
TAOS_BIND* bind = colBinds + j; TAOS_BIND* tsc_bind = colBinds + j;
bind->is_null = &isNullColBind; tsc_bind->is_null = &isNullColBind;
} }
for (int j = 0; j < point->fieldNum; ++j) { for (int j = 0; j < point->fieldNum; ++j) {
TAOS_SML_KV* kv = point->fields + j; TAOS_SML_KV* kv = point->fields + j;
TAOS_BIND* bind = colBinds + kv->fieldSchemaIdx; TAOS_BIND* tsc_bind = colBinds + kv->fieldSchemaIdx;
bind->buffer_type = kv->type; tsc_bind->buffer_type = kv->type;
bind->length = malloc(sizeof(uintptr_t*)); tsc_bind->length = malloc(sizeof(uintptr_t*));
*bind->length = kv->length; *tsc_bind->length = kv->length;
bind->buffer = kv->value; tsc_bind->buffer = kv->value;
bind->is_null = NULL; tsc_bind->is_null = NULL;
} }
taosArrayPush(rowsBind, &colBinds); taosArrayPush(rowsBind, &colBinds);
} }
...@@ -1037,8 +1037,8 @@ static int32_t applyChildTableFields(TAOS* taos, SSmlSTableSchema* sTableSchema, ...@@ -1037,8 +1037,8 @@ static int32_t applyChildTableFields(TAOS* taos, SSmlSTableSchema* sTableSchema,
for (int i = 0; i < rows; ++i) { for (int i = 0; i < rows; ++i) {
TAOS_BIND* colBinds = taosArrayGetP(rowsBind, i); TAOS_BIND* colBinds = taosArrayGetP(rowsBind, i);
for (int j = 0; j < numCols; ++j) { for (int j = 0; j < numCols; ++j) {
TAOS_BIND* bind = colBinds + j; TAOS_BIND* tsc_bind = colBinds + j;
free(bind->length); free(tsc_bind->length);
} }
free(colBinds); free(colBinds);
} }
...@@ -1794,14 +1794,14 @@ static int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value, ...@@ -1794,14 +1794,14 @@ static int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value,
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static int32_t parseSmlTimeStamp(TAOS_SML_KV **pTS, const char **index, SSmlLinesInfo* info) { static int32_t parseSmlTimeStamp(TAOS_SML_KV **pTS, const char **tsc_index, SSmlLinesInfo* info) {
const char *start, *cur; const char *start, *cur;
int32_t ret = TSDB_CODE_SUCCESS; int32_t ret = TSDB_CODE_SUCCESS;
int len = 0; int len = 0;
char key[] = "_ts"; char key[] = "_ts";
char *value = NULL; char *value = NULL;
start = cur = *index; start = cur = *tsc_index;
*pTS = calloc(1, sizeof(TAOS_SML_KV)); *pTS = calloc(1, sizeof(TAOS_SML_KV));
while(*cur != '\0') { while(*cur != '\0') {
...@@ -1851,8 +1851,8 @@ static bool checkDuplicateKey(char *key, SHashObj *pHash, SSmlLinesInfo* info) { ...@@ -1851,8 +1851,8 @@ static bool checkDuplicateKey(char *key, SHashObj *pHash, SSmlLinesInfo* info) {
return false; return false;
} }
static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash, SSmlLinesInfo* info) { static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **tsc_index, SHashObj *pHash, SSmlLinesInfo* info) {
const char *cur = *index; const char *cur = *tsc_index;
char key[TSDB_COL_NAME_LEN + 1]; // +1 to avoid key[len] over write char key[TSDB_COL_NAME_LEN + 1]; // +1 to avoid key[len] over write
uint16_t len = 0; uint16_t len = 0;
...@@ -1887,17 +1887,17 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash ...@@ -1887,17 +1887,17 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash
pKV->key = calloc(len + 1, 1); pKV->key = calloc(len + 1, 1);
memcpy(pKV->key, key, len + 1); memcpy(pKV->key, key, len + 1);
//tscDebug("SML:0x%"PRIx64" Key:%s|len:%d", info->id, pKV->key, len); //tscDebug("SML:0x%"PRIx64" Key:%s|len:%d", info->id, pKV->key, len);
*index = cur + 1; *tsc_index = cur + 1;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static bool parseSmlValue(TAOS_SML_KV *pKV, const char **index, static bool parseSmlValue(TAOS_SML_KV *pKV, const char **tsc_index,
bool *is_last_kv, SSmlLinesInfo* info) { bool *is_last_kv, SSmlLinesInfo* info) {
const char *start, *cur; const char *start, *cur;
char *value = NULL; char *value = NULL;
uint16_t len = 0; uint16_t len = 0;
start = cur = *index; start = cur = *tsc_index;
while (1) { while (1) {
// unescaped ',' or ' ' or '\0' identifies a value // unescaped ',' or ' ' or '\0' identifies a value
...@@ -1928,13 +1928,13 @@ static bool parseSmlValue(TAOS_SML_KV *pKV, const char **index, ...@@ -1928,13 +1928,13 @@ static bool parseSmlValue(TAOS_SML_KV *pKV, const char **index,
} }
free(value); free(value);
*index = (*cur == '\0') ? cur : cur + 1; *tsc_index = (*cur == '\0') ? cur : cur + 1;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index, static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **tsc_index,
uint8_t *has_tags, SSmlLinesInfo* info) { uint8_t *has_tags, SSmlLinesInfo* info) {
const char *cur = *index; const char *cur = *tsc_index;
uint16_t len = 0; uint16_t len = 0;
pSml->stableName = calloc(TSDB_TABLE_NAME_LEN + 1, 1); // +1 to avoid 1772 line over write pSml->stableName = calloc(TSDB_TABLE_NAME_LEN + 1, 1); // +1 to avoid 1772 line over write
...@@ -1973,7 +1973,7 @@ static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index ...@@ -1973,7 +1973,7 @@ static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index
len++; len++;
} }
pSml->stableName[len] = '\0'; pSml->stableName[len] = '\0';
*index = cur + 1; *tsc_index = cur + 1;
tscDebug("SML:0x%"PRIx64" Stable name in measurement:%s|len:%d", info->id, pSml->stableName, len); tscDebug("SML:0x%"PRIx64" Stable name in measurement:%s|len:%d", info->id, pSml->stableName, len);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
...@@ -1992,10 +1992,10 @@ static int32_t isValidChildTableName(const char *pTbName, int16_t len) { ...@@ -1992,10 +1992,10 @@ static int32_t isValidChildTableName(const char *pTbName, int16_t len) {
static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs, static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs,
const char **index, bool isField, const char **tsc_index, bool isField,
TAOS_SML_DATA_POINT* smlData, SHashObj *pHash, TAOS_SML_DATA_POINT* smlData, SHashObj *pHash,
SSmlLinesInfo* info) { SSmlLinesInfo* info) {
const char *cur = *index; const char *cur = *tsc_index;
int32_t ret = TSDB_CODE_SUCCESS; int32_t ret = TSDB_CODE_SUCCESS;
TAOS_SML_KV *pkv; TAOS_SML_KV *pkv;
bool is_last_kv = false; bool is_last_kv = false;
...@@ -2077,7 +2077,7 @@ static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs, ...@@ -2077,7 +2077,7 @@ static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs,
error: error:
return ret; return ret;
done: done:
*index = cur; *tsc_index = cur;
return ret; return ret;
} }
...@@ -2097,13 +2097,13 @@ static void moveTimeStampToFirstKv(TAOS_SML_DATA_POINT** smlData, TAOS_SML_KV *t ...@@ -2097,13 +2097,13 @@ static void moveTimeStampToFirstKv(TAOS_SML_DATA_POINT** smlData, TAOS_SML_KV *t
} }
int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData, SSmlLinesInfo* info) { int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData, SSmlLinesInfo* info) {
const char* index = sql; const char* tsc_index = sql;
int32_t ret = TSDB_CODE_SUCCESS; int32_t ret = TSDB_CODE_SUCCESS;
uint8_t has_tags = 0; uint8_t has_tags = 0;
TAOS_SML_KV *timestamp = NULL; TAOS_SML_KV *timestamp = NULL;
SHashObj *keyHashTable = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); SHashObj *keyHashTable = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false);
ret = parseSmlMeasurement(smlData, &index, &has_tags, info); ret = parseSmlMeasurement(smlData, &tsc_index, &has_tags, info);
if (ret) { if (ret) {
tscError("SML:0x%"PRIx64" Unable to parse measurement", info->id); tscError("SML:0x%"PRIx64" Unable to parse measurement", info->id);
taosHashCleanup(keyHashTable); taosHashCleanup(keyHashTable);
...@@ -2113,7 +2113,7 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData, SSmlLinesInf ...@@ -2113,7 +2113,7 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData, SSmlLinesInf
//Parse Tags //Parse Tags
if (has_tags) { if (has_tags) {
ret = parseSmlKvPairs(&smlData->tags, &smlData->tagNum, &index, false, smlData, keyHashTable, info); ret = parseSmlKvPairs(&smlData->tags, &smlData->tagNum, &tsc_index, false, smlData, keyHashTable, info);
if (ret) { if (ret) {
tscError("SML:0x%"PRIx64" Unable to parse tag", info->id); tscError("SML:0x%"PRIx64" Unable to parse tag", info->id);
taosHashCleanup(keyHashTable); taosHashCleanup(keyHashTable);
...@@ -2123,7 +2123,7 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData, SSmlLinesInf ...@@ -2123,7 +2123,7 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData, SSmlLinesInf
tscDebug("SML:0x%"PRIx64" Parse tags finished, num of tags:%d", info->id, smlData->tagNum); tscDebug("SML:0x%"PRIx64" Parse tags finished, num of tags:%d", info->id, smlData->tagNum);
//Parse fields //Parse fields
ret = parseSmlKvPairs(&smlData->fields, &smlData->fieldNum, &index, true, smlData, keyHashTable, info); ret = parseSmlKvPairs(&smlData->fields, &smlData->fieldNum, &tsc_index, true, smlData, keyHashTable, info);
if (ret) { if (ret) {
tscError("SML:0x%"PRIx64" Unable to parse field", info->id); tscError("SML:0x%"PRIx64" Unable to parse field", info->id);
taosHashCleanup(keyHashTable); taosHashCleanup(keyHashTable);
...@@ -2133,7 +2133,7 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData, SSmlLinesInf ...@@ -2133,7 +2133,7 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData, SSmlLinesInf
taosHashCleanup(keyHashTable); taosHashCleanup(keyHashTable);
//Parse timestamp //Parse timestamp
ret = parseSmlTimeStamp(&timestamp, &index, info); ret = parseSmlTimeStamp(&timestamp, &tsc_index, info);
if (ret) { if (ret) {
tscError("SML:0x%"PRIx64" Unable to parse timestamp", info->id); tscError("SML:0x%"PRIx64" Unable to parse timestamp", info->id);
return ret; return ret;
......
此差异已折叠。
此差异已折叠。
...@@ -860,13 +860,13 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab ...@@ -860,13 +860,13 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab
int32_t vgId = -1; int32_t vgId = -1;
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
int32_t index = pTableMetaInfo->vgroupIndex; int32_t tsc_index = pTableMetaInfo->vgroupIndex;
assert(index >= 0); assert(tsc_index >= 0);
SVgroupInfo* pVgroupInfo = NULL; SVgroupInfo* pVgroupInfo = NULL;
if (pTableMetaInfo->vgroupList && pTableMetaInfo->vgroupList->numOfVgroups > 0) { if (pTableMetaInfo->vgroupList && pTableMetaInfo->vgroupList->numOfVgroups > 0) {
assert(index < pTableMetaInfo->vgroupList->numOfVgroups); assert(tsc_index < pTableMetaInfo->vgroupList->numOfVgroups);
pVgroupInfo = &pTableMetaInfo->vgroupList->vgroups[index]; pVgroupInfo = &pTableMetaInfo->vgroupList->vgroups[tsc_index];
} else { } else {
tscError("0x%"PRIx64" No vgroup info found", pSql->self); tscError("0x%"PRIx64" No vgroup info found", pSql->self);
...@@ -876,7 +876,7 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab ...@@ -876,7 +876,7 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab
vgId = pVgroupInfo->vgId; vgId = pVgroupInfo->vgId;
tscSetDnodeEpSet(&pSql->epSet, pVgroupInfo); tscSetDnodeEpSet(&pSql->epSet, pVgroupInfo);
tscDebug("0x%"PRIx64" query on stable, vgIndex:%d, numOfVgroups:%d", pSql->self, index, pTableMetaInfo->vgroupList->numOfVgroups); tscDebug("0x%"PRIx64" query on stable, vgIndex:%d, numOfVgroups:%d", pSql->self, tsc_index, pTableMetaInfo->vgroupList->numOfVgroups);
} else { } else {
vgId = pTableMeta->vgId; vgId = pTableMeta->vgId;
...@@ -898,11 +898,11 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab ...@@ -898,11 +898,11 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab
pQueryMsg->numOfTables = htonl(1); // set the number of tables pQueryMsg->numOfTables = htonl(1); // set the number of tables
pMsg += sizeof(STableIdInfo); pMsg += sizeof(STableIdInfo);
} else { // it is a subquery of the super table query, this EP info is acquired from vgroupInfo } else { // it is a subquery of the super table query, this EP info is acquired from vgroupInfo
int32_t index = pTableMetaInfo->vgroupIndex; int32_t tsc_index = pTableMetaInfo->vgroupIndex;
int32_t numOfVgroups = (int32_t)taosArrayGetSize(pTableMetaInfo->pVgroupTables); int32_t numOfVgroups = (int32_t)taosArrayGetSize(pTableMetaInfo->pVgroupTables);
assert(index >= 0 && index < numOfVgroups); assert(tsc_index >= 0 && tsc_index < numOfVgroups);
SVgroupTableInfo* pTableIdList = taosArrayGet(pTableMetaInfo->pVgroupTables, index); SVgroupTableInfo* pTableIdList = taosArrayGet(pTableMetaInfo->pVgroupTables, tsc_index);
// set the vgroup info // set the vgroup info
tscSetDnodeEpSet(&pSql->epSet, &pTableIdList->vgInfo); tscSetDnodeEpSet(&pSql->epSet, &pTableIdList->vgInfo);
...@@ -912,7 +912,7 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab ...@@ -912,7 +912,7 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab
pQueryMsg->numOfTables = htonl(numOfTables); // set the number of tables pQueryMsg->numOfTables = htonl(numOfTables); // set the number of tables
tscDebug("0x%"PRIx64" query on stable, vgId:%d, numOfTables:%d, vgIndex:%d, numOfVgroups:%d", pSql->self, tscDebug("0x%"PRIx64" query on stable, vgId:%d, numOfTables:%d, vgIndex:%d, numOfVgroups:%d", pSql->self,
pTableIdList->vgInfo.vgId, numOfTables, index, numOfVgroups); pTableIdList->vgInfo.vgId, numOfTables, tsc_index, numOfVgroups);
// serialize each table id info // serialize each table id info
for(int32_t i = 0; i < numOfTables; ++i) { for(int32_t i = 0; i < numOfTables; ++i) {
...@@ -2621,18 +2621,18 @@ int tscProcessShowRsp(SSqlObj *pSql) { ...@@ -2621,18 +2621,18 @@ int tscProcessShowRsp(SSqlObj *pSql) {
SFieldInfo* pFieldInfo = &pQueryInfo->fieldsInfo; SFieldInfo* pFieldInfo = &pQueryInfo->fieldsInfo;
SColumnIndex index = {0}; SColumnIndex tsc_index = {0};
pSchema = pMetaMsg->schema; pSchema = pMetaMsg->schema;
uint64_t uid = pTableMetaInfo->pTableMeta->id.uid; uint64_t uid = pTableMetaInfo->pTableMeta->id.uid;
for (int16_t i = 0; i < pMetaMsg->numOfColumns; ++i, ++pSchema) { for (int16_t i = 0; i < pMetaMsg->numOfColumns; ++i, ++pSchema) {
index.columnIndex = i; tsc_index.columnIndex = i;
tscColumnListInsert(pQueryInfo->colList, i, uid, pSchema); tscColumnListInsert(pQueryInfo->colList, i, uid, pSchema);
TAOS_FIELD f = tscCreateField(pSchema->type, pSchema->name, pSchema->bytes); TAOS_FIELD f = tscCreateField(pSchema->type, pSchema->name, pSchema->bytes);
SInternalField* pInfo = tscFieldInfoAppend(pFieldInfo, &f); SInternalField* pInfo = tscFieldInfoAppend(pFieldInfo, &f);
pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &tsc_index,
pTableSchema[i].type, pTableSchema[i].bytes, getNewResColId(pCmd), pTableSchema[i].bytes, false); pTableSchema[i].type, pTableSchema[i].bytes, getNewResColId(pCmd), pTableSchema[i].bytes, false);
} }
......
...@@ -417,8 +417,8 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) { ...@@ -417,8 +417,8 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) {
return; return;
} }
} else { } else {
int64_t stime = taosTimeTruncate(pStream->stime - 1, &pStream->interval, pStream->precision); int64_t tsc_stime = taosTimeTruncate(pStream->stime - 1, &pStream->interval, pStream->precision);
if (stime >= pStream->etime) { if (tsc_stime >= pStream->etime) {
tscDebug("0x%"PRIx64" stream:%p, stime:%" PRId64 " is larger than end time: %" PRId64 ", stop the stream", pStream->pSql->self, pStream, tscDebug("0x%"PRIx64" stream:%p, stime:%" PRId64 " is larger than end time: %" PRId64 ", stop the stream", pStream->pSql->self, pStream,
pStream->stime, pStream->etime); pStream->stime, pStream->etime);
// TODO : How to terminate stream here // TODO : How to terminate stream here
...@@ -498,7 +498,7 @@ static int32_t tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) { ...@@ -498,7 +498,7 @@ static int32_t tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, int64_t stime) { static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, int64_t tsc_stime) {
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd); SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd);
if (pStream->isProject) { if (pStream->isProject) {
...@@ -506,31 +506,31 @@ static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, in ...@@ -506,31 +506,31 @@ static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, in
pStream->interval.interval = tsProjectExecInterval; pStream->interval.interval = tsProjectExecInterval;
pStream->interval.sliding = tsProjectExecInterval; pStream->interval.sliding = tsProjectExecInterval;
if (stime != INT64_MIN) { // first projection start from the latest event timestamp if (tsc_stime != INT64_MIN) { // first projection start from the latest event timestamp
assert(stime >= pQueryInfo->window.skey); assert(tsc_stime >= pQueryInfo->window.skey);
stime += 1; // exclude the last records from table tsc_stime += 1; // exclude the last records from table
} else { } else {
stime = pQueryInfo->window.skey; tsc_stime = pQueryInfo->window.skey;
} }
} else { // timewindow based aggregation stream } else { // timewindow based aggregation stream
if (stime == INT64_MIN) { // no data in meter till now if (tsc_stime == INT64_MIN) { // no data in meter till now
if (pQueryInfo->window.skey != INT64_MIN) { if (pQueryInfo->window.skey != INT64_MIN) {
stime = pQueryInfo->window.skey; tsc_stime = pQueryInfo->window.skey;
} else { } else {
return stime; return tsc_stime;
} }
stime = taosTimeTruncate(stime, &pStream->interval, pStream->precision); tsc_stime = taosTimeTruncate(tsc_stime, &pStream->interval, pStream->precision);
} else { } else {
int64_t newStime = taosTimeTruncate(stime, &pStream->interval, pStream->precision); int64_t newStime = taosTimeTruncate(tsc_stime, &pStream->interval, pStream->precision);
if (newStime != stime) { if (newStime != tsc_stime) {
tscWarn("0x%"PRIx64" stream:%p, last timestamp:%" PRId64 ", reset to:%" PRId64, pSql->self, pStream, stime, newStime); tscWarn("0x%"PRIx64" stream:%p, last timestamp:%" PRId64 ", reset to:%" PRId64, pSql->self, pStream, tsc_stime, newStime);
stime = newStime; tsc_stime = newStime;
} }
} }
} }
return stime; return tsc_stime;
} }
static int64_t tscGetLaunchTimestamp(const SSqlStream *pStream) { static int64_t tscGetLaunchTimestamp(const SSqlStream *pStream) {
...@@ -663,7 +663,7 @@ void cbParseSql(void* param, TAOS_RES* res, int code) { ...@@ -663,7 +663,7 @@ void cbParseSql(void* param, TAOS_RES* res, int code) {
} }
TAOS_STREAM *taos_open_stream_withname(TAOS *taos, const char* dstTable, const char *sqlstr, void (*fp)(void *param, TAOS_RES *, TAOS_ROW row), TAOS_STREAM *taos_open_stream_withname(TAOS *taos, const char* dstTable, const char *sqlstr, void (*fp)(void *param, TAOS_RES *, TAOS_ROW row),
int64_t stime, void *param, void (*callback)(void *), void* cqhandle) { int64_t tsc_stime, void *param, void (*callback)(void *), void* cqhandle) {
STscObj *pObj = (STscObj *)taos; STscObj *pObj = (STscObj *)taos;
if (pObj == NULL || pObj->signature != pObj) return NULL; if (pObj == NULL || pObj->signature != pObj) return NULL;
...@@ -692,7 +692,7 @@ TAOS_STREAM *taos_open_stream_withname(TAOS *taos, const char* dstTable, const c ...@@ -692,7 +692,7 @@ TAOS_STREAM *taos_open_stream_withname(TAOS *taos, const char* dstTable, const c
} }
pStream->ltime = INT64_MIN; pStream->ltime = INT64_MIN;
pStream->stime = stime; pStream->stime = tsc_stime;
pStream->fp = fp; pStream->fp = fp;
pStream->callback = callback; pStream->callback = callback;
pStream->param = param; pStream->param = param;
...@@ -745,8 +745,8 @@ TAOS_STREAM *taos_open_stream_withname(TAOS *taos, const char* dstTable, const c ...@@ -745,8 +745,8 @@ TAOS_STREAM *taos_open_stream_withname(TAOS *taos, const char* dstTable, const c
} }
TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *param, TAOS_RES *, TAOS_ROW row), TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *param, TAOS_RES *, TAOS_ROW row),
int64_t stime, void *param, void (*callback)(void *)) { int64_t tsc_stime, void *param, void (*callback)(void *)) {
return taos_open_stream_withname(taos, "", sqlstr, fp, stime, param, callback, NULL); return taos_open_stream_withname(taos, "", sqlstr, fp, tsc_stime, param, callback, NULL);
} }
void taos_close_stream(TAOS_STREAM *handle) { void taos_close_stream(TAOS_STREAM *handle) {
......
...@@ -380,7 +380,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, STimeWindow * win) { ...@@ -380,7 +380,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, STimeWindow * win) {
// todo handle failed to create sub query // todo handle failed to create sub query
SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t index) { SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t tsc_index) {
SJoinSupporter* pSupporter = calloc(1, sizeof(SJoinSupporter)); SJoinSupporter* pSupporter = calloc(1, sizeof(SJoinSupporter));
if (pSupporter == NULL) { if (pSupporter == NULL) {
return NULL; return NULL;
...@@ -388,13 +388,13 @@ SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t index) { ...@@ -388,13 +388,13 @@ SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t index) {
pSupporter->pObj = pSql->self; pSupporter->pObj = pSql->self;
pSupporter->subqueryIndex = index; pSupporter->subqueryIndex = tsc_index;
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd); SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd);
memcpy(&pSupporter->interval, &pQueryInfo->interval, sizeof(pSupporter->interval)); memcpy(&pSupporter->interval, &pQueryInfo->interval, sizeof(pSupporter->interval));
pSupporter->limit = pQueryInfo->limit; pSupporter->limit = pQueryInfo->limit;
STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, index); STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, tsc_index);
pSupporter->uid = pTableMetaInfo->pTableMeta->id.uid; pSupporter->uid = pTableMetaInfo->pTableMeta->id.uid;
assert (pSupporter->uid != 0); assert (pSupporter->uid != 0);
...@@ -598,7 +598,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) { ...@@ -598,7 +598,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
* during the timestamp intersection. * during the timestamp intersection.
*/ */
pSupporter->limit = pQueryInfo->limit; pSupporter->limit = pQueryInfo->limit;
SColumnIndex index = {.tableIndex = 0, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX}; SColumnIndex tsc_index = {.tableIndex = 0, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX};
SSchema* s = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, 0); SSchema* s = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, 0);
SExprInfo* pExpr = tscExprGet(pQueryInfo, 0); SExprInfo* pExpr = tscExprGet(pQueryInfo, 0);
...@@ -610,7 +610,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) { ...@@ -610,7 +610,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
int16_t functionId = tscIsProjectionQuery(pQueryInfo)? TSDB_FUNC_PRJ : TSDB_FUNC_TS; int16_t functionId = tscIsProjectionQuery(pQueryInfo)? TSDB_FUNC_PRJ : TSDB_FUNC_TS;
tscAddFuncInSelectClause(pQueryInfo, 0, functionId, &index, s, TSDB_COL_NORMAL, getNewResColId(&pNew->cmd)); tscAddFuncInSelectClause(pQueryInfo, 0, functionId, &tsc_index, s, TSDB_COL_NORMAL, getNewResColId(&pNew->cmd));
tscPrintSelNodeList(pNew, 0); tscPrintSelNodeList(pNew, 0);
tscFieldInfoUpdateOffset(pQueryInfo); tscFieldInfoUpdateOffset(pQueryInfo);
...@@ -806,8 +806,8 @@ static void issueTsCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj* ...@@ -806,8 +806,8 @@ static void issueTsCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj*
SSchema colSchema = {.type = TSDB_DATA_TYPE_BINARY, .bytes = 1}; SSchema colSchema = {.type = TSDB_DATA_TYPE_BINARY, .bytes = 1};
SColumnIndex index = {0, PRIMARYKEY_TIMESTAMP_COL_INDEX}; SColumnIndex tsc_index = {0, PRIMARYKEY_TIMESTAMP_COL_INDEX};
tscAddFuncInSelectClause(pQueryInfo, 0, TSDB_FUNC_TS_COMP, &index, &colSchema, TSDB_COL_NORMAL, getNewResColId(pCmd)); tscAddFuncInSelectClause(pQueryInfo, 0, TSDB_FUNC_TS_COMP, &tsc_index, &colSchema, TSDB_COL_NORMAL, getNewResColId(pCmd));
// set the tags value for ts_comp function // set the tags value for ts_comp function
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
...@@ -2424,7 +2424,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) { ...@@ -2424,7 +2424,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
int32_t numOfExprs = (int32_t) tscNumOfExprs(pQueryInfo); int32_t numOfExprs = (int32_t) tscNumOfExprs(pQueryInfo);
int32_t index = 0; int32_t tsc_index = 0;
for(int32_t i = 0; i < numOfExprs; ++i) { for(int32_t i = 0; i < numOfExprs; ++i) {
SExprInfo* pExpr = tscExprGet(pQueryInfo, i); SExprInfo* pExpr = tscExprGet(pQueryInfo, i);
if (pExpr->base.functionId == TSDB_FUNC_TS && pQueryInfo->interval.interval > 0) { if (pExpr->base.functionId == TSDB_FUNC_TS && pQueryInfo->interval.interval > 0) {
...@@ -2433,7 +2433,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) { ...@@ -2433,7 +2433,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
SColumnIndex colIndex = {.tableIndex = 0, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX}; SColumnIndex colIndex = {.tableIndex = 0, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX};
SSchema* schema = tscGetColumnSchemaById(pTableMetaInfo1->pTableMeta, pExpr->base.colInfo.colId); SSchema* schema = tscGetColumnSchemaById(pTableMetaInfo1->pTableMeta, pExpr->base.colInfo.colId);
SExprInfo* p = tscAddFuncInSelectClause(pNewQueryInfo, index++, TSDB_FUNC_TS, &colIndex, schema, TSDB_COL_NORMAL, getNewResColId(pCmd)); SExprInfo* p = tscAddFuncInSelectClause(pNewQueryInfo, tsc_index++, TSDB_FUNC_TS, &colIndex, schema, TSDB_COL_NORMAL, getNewResColId(pCmd));
p->base.resColId = pExpr->base.resColId; // update the result column id p->base.resColId = pExpr->base.resColId; // update the result column id
} else if (pExpr->base.functionId == TSDB_FUNC_STDDEV_DST) { } else if (pExpr->base.functionId == TSDB_FUNC_STDDEV_DST) {
taosArrayPush(pSup->pColsInfo, &pExpr->base.resColId); taosArrayPush(pSup->pColsInfo, &pExpr->base.resColId);
...@@ -2442,7 +2442,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) { ...@@ -2442,7 +2442,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
SSchema schema = {.type = TSDB_DATA_TYPE_DOUBLE, .bytes = sizeof(double)}; SSchema schema = {.type = TSDB_DATA_TYPE_DOUBLE, .bytes = sizeof(double)};
tstrncpy(schema.name, pExpr->base.aliasName, tListLen(schema.name)); tstrncpy(schema.name, pExpr->base.aliasName, tListLen(schema.name));
SExprInfo* p = tscAddFuncInSelectClause(pNewQueryInfo, index++, TSDB_FUNC_AVG, &colIndex, &schema, TSDB_COL_NORMAL, getNewResColId(pCmd)); SExprInfo* p = tscAddFuncInSelectClause(pNewQueryInfo, tsc_index++, TSDB_FUNC_AVG, &colIndex, &schema, TSDB_COL_NORMAL, getNewResColId(pCmd));
p->base.resColId = pExpr->base.resColId; // update the result column id p->base.resColId = pExpr->base.resColId; // update the result column id
} else if (pExpr->base.functionId == TSDB_FUNC_TAG) { } else if (pExpr->base.functionId == TSDB_FUNC_TAG) {
pSup->tagLen += pExpr->base.resBytes; pSup->tagLen += pExpr->base.resBytes;
...@@ -2455,7 +2455,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) { ...@@ -2455,7 +2455,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
schema = tGetTbnameColumnSchema(); schema = tGetTbnameColumnSchema();
} }
SExprInfo* p = tscAddFuncInSelectClause(pNewQueryInfo, index++, TSDB_FUNC_TAG, &colIndex, schema, TSDB_COL_TAG, getNewResColId(pCmd)); SExprInfo* p = tscAddFuncInSelectClause(pNewQueryInfo, tsc_index++, TSDB_FUNC_TAG, &colIndex, schema, TSDB_COL_TAG, getNewResColId(pCmd));
p->base.resColId = pExpr->base.resColId; p->base.resColId = pExpr->base.resColId;
} else if (pExpr->base.functionId == TSDB_FUNC_PRJ) { } else if (pExpr->base.functionId == TSDB_FUNC_PRJ) {
int32_t num = (int32_t) taosArrayGetSize(pNewQueryInfo->groupbyExpr.columnInfo); int32_t num = (int32_t) taosArrayGetSize(pNewQueryInfo->groupbyExpr.columnInfo);
...@@ -2469,7 +2469,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) { ...@@ -2469,7 +2469,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
SSchema* schema = tscGetColumnSchemaById(pTableMetaInfo1->pTableMeta, pExpr->base.colInfo.colId); SSchema* schema = tscGetColumnSchemaById(pTableMetaInfo1->pTableMeta, pExpr->base.colInfo.colId);
//doLimitOutputNormalColOfGroupby //doLimitOutputNormalColOfGroupby
SExprInfo* p = tscAddFuncInSelectClause(pNewQueryInfo, index++, TSDB_FUNC_PRJ, &colIndex, schema, TSDB_COL_NORMAL, getNewResColId(pCmd)); SExprInfo* p = tscAddFuncInSelectClause(pNewQueryInfo, tsc_index++, TSDB_FUNC_PRJ, &colIndex, schema, TSDB_COL_NORMAL, getNewResColId(pCmd));
p->base.numOfParams = 1; p->base.numOfParams = 1;
p->base.param[0].i64 = 1; p->base.param[0].i64 = 1;
p->base.param[0].nType = TSDB_DATA_TYPE_INT; p->base.param[0].nType = TSDB_DATA_TYPE_INT;
...@@ -2511,7 +2511,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) { ...@@ -2511,7 +2511,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
"0x%"PRIx64" first round subquery:0x%"PRIx64" tableIndex:%d, vgroupIndex:%d, numOfVgroups:%d, type:%d, query to retrieve timestamps, " "0x%"PRIx64" first round subquery:0x%"PRIx64" tableIndex:%d, vgroupIndex:%d, numOfVgroups:%d, type:%d, query to retrieve timestamps, "
"numOfExpr:%" PRIzu ", colList:%d, numOfOutputFields:%d, name:%s", "numOfExpr:%" PRIzu ", colList:%d, numOfOutputFields:%d, name:%s",
pSql->self, pNew->self, 0, pTableMetaInfo->vgroupIndex, pTableMetaInfo->vgroupList->numOfVgroups, pNewQueryInfo->type, pSql->self, pNew->self, 0, pTableMetaInfo->vgroupIndex, pTableMetaInfo->vgroupList->numOfVgroups, pNewQueryInfo->type,
tscNumOfExprs(pNewQueryInfo), index+1, pNewQueryInfo->fieldsInfo.numOfOutput, tNameGetTableName(&pTableMetaInfo->name)); tscNumOfExprs(pNewQueryInfo), tsc_index+1, pNewQueryInfo->fieldsInfo.numOfOutput, tNameGetTableName(&pTableMetaInfo->name));
pSql->pSubs = calloc(1, POINTER_BYTES); pSql->pSubs = calloc(1, POINTER_BYTES);
if (pSql->pSubs == NULL) { if (pSql->pSubs == NULL) {
...@@ -3145,7 +3145,7 @@ static SSqlObj *tscCreateSTableSubquery(SSqlObj *pSql, SRetrieveSupport *trsuppo ...@@ -3145,7 +3145,7 @@ static SSqlObj *tscCreateSTableSubquery(SSqlObj *pSql, SRetrieveSupport *trsuppo
assert(trsupport->subqueryIndex < pSql->subState.numOfSub); assert(trsupport->subqueryIndex < pSql->subState.numOfSub);
// launch subquery for each vnode, so the subquery index equals to the vgroupIndex. // launch subquery for each vnode, so the subquery tsc_index equals to the vgroupIndex.
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, table_index); STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, table_index);
pTableMetaInfo->vgroupIndex = trsupport->subqueryIndex; pTableMetaInfo->vgroupIndex = trsupport->subqueryIndex;
...@@ -3628,19 +3628,19 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) { ...@@ -3628,19 +3628,19 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) {
char *getArithmeticInputSrc(void *param, const char *name, int32_t colId) { char *getArithmeticInputSrc(void *param, const char *name, int32_t colId) {
SArithmeticSupport *pSupport = (SArithmeticSupport *) param; SArithmeticSupport *pSupport = (SArithmeticSupport *) param;
int32_t index = -1; int32_t tsc_index = -1;
SExprInfo* pExpr = NULL; SExprInfo* pExpr = NULL;
for (int32_t i = 0; i < pSupport->numOfCols; ++i) { for (int32_t i = 0; i < pSupport->numOfCols; ++i) {
pExpr = taosArrayGetP(pSupport->exprList, i); pExpr = taosArrayGetP(pSupport->exprList, i);
if (strncmp(name, pExpr->base.aliasName, sizeof(pExpr->base.aliasName) - 1) == 0) { if (strncmp(name, pExpr->base.aliasName, sizeof(pExpr->base.aliasName) - 1) == 0) {
index = i; tsc_index = i;
break; break;
} }
} }
assert(index >= 0 && index < pSupport->numOfCols); assert(tsc_index >= 0 && tsc_index < pSupport->numOfCols);
return pSupport->data[index] + pSupport->offset * pExpr->base.resBytes; return pSupport->data[tsc_index] + pSupport->offset * pExpr->base.resBytes;
} }
TAOS_ROW doSetResultRowData(SSqlObj *pSql) { TAOS_ROW doSetResultRowData(SSqlObj *pSql) {
...@@ -3819,7 +3819,7 @@ void* createQInfoFromQueryNode(SQueryInfo* pQueryInfo, STableGroupInfo* pTableGr ...@@ -3819,7 +3819,7 @@ void* createQInfoFromQueryNode(SQueryInfo* pQueryInfo, STableGroupInfo* pTableGr
pthread_mutex_init(&pQInfo->lock, NULL); pthread_mutex_init(&pQInfo->lock, NULL);
tsem_init(&pQInfo->ready, 0, 0); tsem_init(&pQInfo->ready, 0, 0);
int32_t index = 0; int32_t tsc_index = 0;
for(int32_t i = 0; i < numOfGroups; ++i) { for(int32_t i = 0; i < numOfGroups; ++i) {
SArray* pa = taosArrayGetP(pQueryAttr->tableGroupInfo.pGroupList, i); SArray* pa = taosArrayGetP(pQueryAttr->tableGroupInfo.pGroupList, i);
...@@ -3836,7 +3836,7 @@ void* createQInfoFromQueryNode(SQueryInfo* pQueryInfo, STableGroupInfo* pTableGr ...@@ -3836,7 +3836,7 @@ void* createQInfoFromQueryNode(SQueryInfo* pQueryInfo, STableGroupInfo* pTableGr
STableKeyInfo* info = taosArrayGet(pa, j); STableKeyInfo* info = taosArrayGet(pa, j);
window.skey = info->lastKey; window.skey = info->lastKey;
void* buf = (char*) pQInfo->pBuf + index * sizeof(STableQueryInfo); void* buf = (char*) pQInfo->pBuf + tsc_index * sizeof(STableQueryInfo);
STableQueryInfo* item = createTableQueryInfo(pQueryAttr, info->pTable, pQueryAttr->groupbyColumn, window, buf); STableQueryInfo* item = createTableQueryInfo(pQueryAttr, info->pTable, pQueryAttr->groupbyColumn, window, buf);
if (item == NULL) { if (item == NULL) {
goto _cleanup; goto _cleanup;
...@@ -3847,7 +3847,7 @@ void* createQInfoFromQueryNode(SQueryInfo* pQueryInfo, STableGroupInfo* pTableGr ...@@ -3847,7 +3847,7 @@ void* createQInfoFromQueryNode(SQueryInfo* pQueryInfo, STableGroupInfo* pTableGr
STableId id = {.tid = 0, .uid = 0}; STableId id = {.tid = 0, .uid = 0};
taosHashPut(pRuntimeEnv->tableqinfoGroupInfo.map, &id.tid, sizeof(id.tid), &item, POINTER_BYTES); taosHashPut(pRuntimeEnv->tableqinfoGroupInfo.map, &id.tid, sizeof(id.tid), &item, POINTER_BYTES);
index += 1; tsc_index += 1;
} }
} }
......
...@@ -84,24 +84,24 @@ int32_t tscAcquireRpc(const char *key, const char *user, const char *secretEncry ...@@ -84,24 +84,24 @@ int32_t tscAcquireRpc(const char *key, const char *user, const char *secretEncry
return 0; return 0;
} }
SRpcInit rpcInit; SRpcInit tsc_rpcInit;
memset(&rpcInit, 0, sizeof(rpcInit)); memset(&tsc_rpcInit, 0, sizeof(tsc_rpcInit));
rpcInit.localPort = 0; tsc_rpcInit.localPort = 0;
rpcInit.label = "TSC"; tsc_rpcInit.label = "TSC";
rpcInit.numOfThreads = tscNumOfThreads; tsc_rpcInit.numOfThreads = tscNumOfThreads;
rpcInit.cfp = tscProcessMsgFromServer; tsc_rpcInit.cfp = tscProcessMsgFromServer;
rpcInit.sessions = tsMaxConnections; tsc_rpcInit.sessions = tsMaxConnections;
rpcInit.connType = TAOS_CONN_CLIENT; tsc_rpcInit.connType = TAOS_CONN_CLIENT;
rpcInit.user = (char *)user; tsc_rpcInit.user = (char *)user;
rpcInit.idleTime = tsShellActivityTimer * 1000; tsc_rpcInit.idleTime = tsShellActivityTimer * 1000;
rpcInit.ckey = "key"; tsc_rpcInit.ckey = "key";
rpcInit.spi = 1; tsc_rpcInit.spi = 1;
rpcInit.secret = (char *)secretEncrypt; tsc_rpcInit.secret = (char *)secretEncrypt;
SRpcObj rpcObj; SRpcObj rpcObj;
memset(&rpcObj, 0, sizeof(rpcObj)); memset(&rpcObj, 0, sizeof(rpcObj));
strncpy(rpcObj.key, key, strlen(key)); strncpy(rpcObj.key, key, strlen(key));
rpcObj.pDnodeConn = rpcOpen(&rpcInit); rpcObj.pDnodeConn = rpcOpen(&tsc_rpcInit);
if (rpcObj.pDnodeConn == NULL) { if (rpcObj.pDnodeConn == NULL) {
pthread_mutex_unlock(&rpcObjMutex); pthread_mutex_unlock(&rpcObjMutex);
tscError("failed to init connection to TDengine"); tscError("failed to init connection to TDengine");
......
...@@ -2132,10 +2132,10 @@ void tscCloseTscObj(void *param) { ...@@ -2132,10 +2132,10 @@ void tscCloseTscObj(void *param) {
} }
bool tscIsInsertData(char* sqlstr) { bool tscIsInsertData(char* sqlstr) {
int32_t index = 0; int32_t tsc_index = 0;
do { do {
SStrToken t0 = tStrGetToken(sqlstr, &index, false); SStrToken t0 = tStrGetToken(sqlstr, &tsc_index, false);
if (t0.type != TK_LP) { if (t0.type != TK_LP) {
return t0.type == TK_INSERT || t0.type == TK_IMPORT; return t0.type == TK_INSERT || t0.type == TK_IMPORT;
} }
...@@ -2202,12 +2202,12 @@ SInternalField* tscFieldInfoAppend(SFieldInfo* pFieldInfo, TAOS_FIELD* pField) { ...@@ -2202,12 +2202,12 @@ SInternalField* tscFieldInfoAppend(SFieldInfo* pFieldInfo, TAOS_FIELD* pField) {
return taosArrayPush(pFieldInfo->internalField, &info); return taosArrayPush(pFieldInfo->internalField, &info);
} }
SInternalField* tscFieldInfoInsert(SFieldInfo* pFieldInfo, int32_t index, TAOS_FIELD* field) { SInternalField* tscFieldInfoInsert(SFieldInfo* pFieldInfo, int32_t tsc_index, TAOS_FIELD* field) {
pFieldInfo->numOfOutput++; pFieldInfo->numOfOutput++;
struct SInternalField info = { .pExpr = NULL, .visible = true }; struct SInternalField info = { .pExpr = NULL, .visible = true };
info.field = *field; info.field = *field;
return taosArrayInsert(pFieldInfo->internalField, index, &info); return taosArrayInsert(pFieldInfo->internalField, tsc_index, &info);
} }
void tscFieldInfoUpdateOffset(SQueryInfo* pQueryInfo) { void tscFieldInfoUpdateOffset(SQueryInfo* pQueryInfo) {
...@@ -2222,18 +2222,18 @@ void tscFieldInfoUpdateOffset(SQueryInfo* pQueryInfo) { ...@@ -2222,18 +2222,18 @@ void tscFieldInfoUpdateOffset(SQueryInfo* pQueryInfo) {
} }
} }
SInternalField* tscFieldInfoGetInternalField(SFieldInfo* pFieldInfo, int32_t index) { SInternalField* tscFieldInfoGetInternalField(SFieldInfo* pFieldInfo, int32_t tsc_index) {
assert(index < pFieldInfo->numOfOutput); assert(tsc_index < pFieldInfo->numOfOutput);
return TARRAY_GET_ELEM(pFieldInfo->internalField, index); return TARRAY_GET_ELEM(pFieldInfo->internalField, tsc_index);
} }
TAOS_FIELD* tscFieldInfoGetField(SFieldInfo* pFieldInfo, int32_t index) { TAOS_FIELD* tscFieldInfoGetField(SFieldInfo* pFieldInfo, int32_t tsc_index) {
assert(index < pFieldInfo->numOfOutput); assert(tsc_index < pFieldInfo->numOfOutput);
return &((SInternalField*)TARRAY_GET_ELEM(pFieldInfo->internalField, index))->field; return &((SInternalField*)TARRAY_GET_ELEM(pFieldInfo->internalField, tsc_index))->field;
} }
int16_t tscFieldInfoGetOffset(SQueryInfo* pQueryInfo, int32_t index) { int16_t tscFieldInfoGetOffset(SQueryInfo* pQueryInfo, int32_t tsc_index) {
SInternalField* pInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, index); SInternalField* pInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, tsc_index);
assert(pInfo != NULL && pInfo->pExpr->pExpr == NULL); assert(pInfo != NULL && pInfo->pExpr->pExpr == NULL);
return pInfo->pExpr->base.offset; return pInfo->pExpr->base.offset;
...@@ -2402,7 +2402,7 @@ SExprInfo* tscExprCreate(STableMetaInfo* pTableMetaInfo, int16_t functionId, SCo ...@@ -2402,7 +2402,7 @@ SExprInfo* tscExprCreate(STableMetaInfo* pTableMetaInfo, int16_t functionId, SCo
SSqlExpr* p = &pExpr->base; SSqlExpr* p = &pExpr->base;
p->functionId = functionId; p->functionId = functionId;
// set the correct columnIndex index // set the correct columnIndex tsc_index
if (pColIndex->columnIndex == TSDB_TBNAME_COLUMN_INDEX) { if (pColIndex->columnIndex == TSDB_TBNAME_COLUMN_INDEX) {
SSchema* s = tGetTbnameColumnSchema(); SSchema* s = tGetTbnameColumnSchema();
p->colInfo.colId = TSDB_TBNAME_COLUMN_INDEX; p->colInfo.colId = TSDB_TBNAME_COLUMN_INDEX;
...@@ -2449,16 +2449,16 @@ SExprInfo* tscExprCreate(STableMetaInfo* pTableMetaInfo, int16_t functionId, SCo ...@@ -2449,16 +2449,16 @@ SExprInfo* tscExprCreate(STableMetaInfo* pTableMetaInfo, int16_t functionId, SCo
return pExpr; return pExpr;
} }
SExprInfo* tscExprInsert(SQueryInfo* pQueryInfo, int32_t index, int16_t functionId, SColumnIndex* pColIndex, int16_t type, SExprInfo* tscExprInsert(SQueryInfo* pQueryInfo, int32_t tsc_index, int16_t functionId, SColumnIndex* pColIndex, int16_t type,
int16_t size, int16_t resColId, int16_t interSize, bool isTagCol) { int16_t size, int16_t resColId, int16_t interSize, bool isTagCol) {
int32_t num = (int32_t)taosArrayGetSize(pQueryInfo->exprList); int32_t num = (int32_t)taosArrayGetSize(pQueryInfo->exprList);
if (index == num) { if (tsc_index == num) {
return tscExprAppend(pQueryInfo, functionId, pColIndex, type, size, resColId, interSize, isTagCol); return tscExprAppend(pQueryInfo, functionId, pColIndex, type, size, resColId, interSize, isTagCol);
} }
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, pColIndex->tableIndex); STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, pColIndex->tableIndex);
SExprInfo* pExpr = tscExprCreate(pTableMetaInfo, functionId, pColIndex, type, size, resColId, interSize, isTagCol); SExprInfo* pExpr = tscExprCreate(pTableMetaInfo, functionId, pColIndex, type, size, resColId, interSize, isTagCol);
taosArrayInsert(pQueryInfo->exprList, index, &pExpr); taosArrayInsert(pQueryInfo->exprList, tsc_index, &pExpr);
return pExpr; return pExpr;
} }
...@@ -2470,10 +2470,10 @@ SExprInfo* tscExprAppend(SQueryInfo* pQueryInfo, int16_t functionId, SColumnInde ...@@ -2470,10 +2470,10 @@ SExprInfo* tscExprAppend(SQueryInfo* pQueryInfo, int16_t functionId, SColumnInde
return pExpr; return pExpr;
} }
SExprInfo* tscExprUpdate(SQueryInfo* pQueryInfo, int32_t index, int16_t functionId, int16_t srcColumnIndex, SExprInfo* tscExprUpdate(SQueryInfo* pQueryInfo, int32_t tsc_index, int16_t functionId, int16_t srcColumnIndex,
int16_t type, int16_t size) { int16_t type, int16_t size) {
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
SExprInfo* pExpr = tscExprGet(pQueryInfo, index); SExprInfo* pExpr = tscExprGet(pQueryInfo, tsc_index);
if (pExpr == NULL) { if (pExpr == NULL) {
return NULL; return NULL;
} }
...@@ -2490,8 +2490,8 @@ SExprInfo* tscExprUpdate(SQueryInfo* pQueryInfo, int32_t index, int16_t function ...@@ -2490,8 +2490,8 @@ SExprInfo* tscExprUpdate(SQueryInfo* pQueryInfo, int32_t index, int16_t function
return pExpr; return pExpr;
} }
bool tscMultiRoundQuery(SQueryInfo* pQueryInfo, int32_t index) { bool tscMultiRoundQuery(SQueryInfo* pQueryInfo, int32_t tsc_index) {
if (!UTIL_TABLE_IS_SUPER_TABLE(pQueryInfo->pTableMetaInfo[index])) { if (!UTIL_TABLE_IS_SUPER_TABLE(pQueryInfo->pTableMetaInfo[tsc_index])) {
return false; return false;
} }
...@@ -2522,8 +2522,8 @@ void tscExprAddParams(SSqlExpr* pExpr, char* argument, int32_t type, int32_t byt ...@@ -2522,8 +2522,8 @@ void tscExprAddParams(SSqlExpr* pExpr, char* argument, int32_t type, int32_t byt
assert(pExpr->numOfParams <= 3); assert(pExpr->numOfParams <= 3);
} }
SExprInfo* tscExprGet(SQueryInfo* pQueryInfo, int32_t index) { SExprInfo* tscExprGet(SQueryInfo* pQueryInfo, int32_t tsc_index) {
return taosArrayGetP(pQueryInfo->exprList, index); return taosArrayGetP(pQueryInfo->exprList, tsc_index);
} }
/* /*
...@@ -3045,8 +3045,8 @@ void tscGetSrcColumnInfo(SSrcColumnInfo* pColInfo, SQueryInfo* pQueryInfo) { ...@@ -3045,8 +3045,8 @@ void tscGetSrcColumnInfo(SSrcColumnInfo* pColInfo, SQueryInfo* pQueryInfo) {
if (TSDB_COL_IS_TAG(pExpr->base.colInfo.flag)) { if (TSDB_COL_IS_TAG(pExpr->base.colInfo.flag)) {
SSchema* pTagSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta); SSchema* pTagSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta);
int16_t index = pExpr->base.colInfo.colIndex; int16_t tsc_index = pExpr->base.colInfo.colIndex;
pColInfo[i].type = (index != -1) ? pTagSchema[index].type : TSDB_DATA_TYPE_BINARY; pColInfo[i].type = (tsc_index != -1) ? pTagSchema[tsc_index].type : TSDB_DATA_TYPE_BINARY;
} else { } else {
pColInfo[i].type = pSchema[pExpr->base.colInfo.colIndex].type; pColInfo[i].type = pSchema[pExpr->base.colInfo.colIndex].type;
} }
...@@ -3126,7 +3126,7 @@ SQueryInfo* tscGetQueryInfoS(SSqlCmd* pCmd) { ...@@ -3126,7 +3126,7 @@ SQueryInfo* tscGetQueryInfoS(SSqlCmd* pCmd) {
return pQueryInfo; return pQueryInfo;
} }
STableMetaInfo* tscGetTableMetaInfoByUid(SQueryInfo* pQueryInfo, uint64_t uid, int32_t* index) { STableMetaInfo* tscGetTableMetaInfoByUid(SQueryInfo* pQueryInfo, uint64_t uid, int32_t* tsc_index) {
int32_t k = -1; int32_t k = -1;
for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) { for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
...@@ -3136,8 +3136,8 @@ STableMetaInfo* tscGetTableMetaInfoByUid(SQueryInfo* pQueryInfo, uint64_t uid, i ...@@ -3136,8 +3136,8 @@ STableMetaInfo* tscGetTableMetaInfoByUid(SQueryInfo* pQueryInfo, uint64_t uid, i
} }
} }
if (index != NULL) { if (tsc_index != NULL) {
*index = k; *tsc_index = k;
} }
assert(k != -1); assert(k != -1);
...@@ -3347,15 +3347,15 @@ void tscFreeVgroupTableInfo(SArray* pVgroupTables) { ...@@ -3347,15 +3347,15 @@ void tscFreeVgroupTableInfo(SArray* pVgroupTables) {
taosArrayDestroy(pVgroupTables); taosArrayDestroy(pVgroupTables);
} }
void tscRemoveVgroupTableGroup(SArray* pVgroupTable, int32_t index) { void tscRemoveVgroupTableGroup(SArray* pVgroupTable, int32_t tsc_index) {
assert(pVgroupTable != NULL && index >= 0); assert(pVgroupTable != NULL && tsc_index >= 0);
size_t size = taosArrayGetSize(pVgroupTable); size_t size = taosArrayGetSize(pVgroupTable);
assert(size > index); assert(size > tsc_index);
SVgroupTableInfo* pInfo = taosArrayGet(pVgroupTable, index); SVgroupTableInfo* pInfo = taosArrayGet(pVgroupTable, tsc_index);
taosArrayDestroy(pInfo->itemList); taosArrayDestroy(pInfo->itemList);
taosArrayRemove(pVgroupTable, index); taosArrayRemove(pVgroupTable, tsc_index);
} }
void tscVgroupTableCopy(SVgroupTableInfo* info, SVgroupTableInfo* pInfo) { void tscVgroupTableCopy(SVgroupTableInfo* info, SVgroupTableInfo* pInfo) {
...@@ -3825,15 +3825,15 @@ static void tscSubqueryRetrieveCallback(void* param, TAOS_RES* tres, int code) { ...@@ -3825,15 +3825,15 @@ static void tscSubqueryRetrieveCallback(void* param, TAOS_RES* tres, int code) {
SSqlObj* pParentSql = ps->pParentSql; SSqlObj* pParentSql = ps->pParentSql;
SSqlObj* pSql = tres; SSqlObj* pSql = tres;
int32_t index = ps->subqueryIndex; int32_t tsc_index = ps->subqueryIndex;
bool ret = subAndCheckDone(pSql, pParentSql, index); bool ret = subAndCheckDone(pSql, pParentSql, tsc_index);
// TODO refactor // TODO refactor
tfree(ps); tfree(ps);
pSql->param = NULL; pSql->param = NULL;
if (!ret) { if (!ret) {
tscDebug("0x%"PRIx64" sub:0x%"PRIx64" orderOfSub:%d completed, not all subquery finished", pParentSql->self, pSql->self, index); tscDebug("0x%"PRIx64" sub:0x%"PRIx64" orderOfSub:%d completed, not all subquery finished", pParentSql->self, pSql->self, tsc_index);
return; return;
} }
...@@ -3854,13 +3854,13 @@ static void tscSubqueryCompleteCallback(void* param, TAOS_RES* tres, int code) { ...@@ -3854,13 +3854,13 @@ static void tscSubqueryCompleteCallback(void* param, TAOS_RES* tres, int code) {
if (pSql->res.code != TSDB_CODE_SUCCESS) { if (pSql->res.code != TSDB_CODE_SUCCESS) {
SSqlObj* pParentSql = ps->pParentSql; SSqlObj* pParentSql = ps->pParentSql;
int32_t index = ps->subqueryIndex; int32_t tsc_index = ps->subqueryIndex;
bool ret = subAndCheckDone(pSql, pParentSql, index); bool ret = subAndCheckDone(pSql, pParentSql, tsc_index);
tscFreeRetrieveSup(&pSql->param); tscFreeRetrieveSup(&pSql->param);
if (!ret) { if (!ret) {
tscDebug("0x%"PRIx64" sub:0x%"PRIx64" orderOfSub:%d completed, not all subquery finished", pParentSql->self, pSql->self, index); tscDebug("0x%"PRIx64" sub:0x%"PRIx64" orderOfSub:%d completed, not all subquery finished", pParentSql->self, pSql->self, tsc_index);
return; return;
} }
......
...@@ -304,14 +304,14 @@ bool isNEleNull(SDataCol *pCol, int nEle) { ...@@ -304,14 +304,14 @@ bool isNEleNull(SDataCol *pCol, int nEle) {
return true; return true;
} }
static FORCE_INLINE void dataColSetNullAt(SDataCol *pCol, int index) { static FORCE_INLINE void dataColSetNullAt(SDataCol *pCol, int utl_index) {
if (IS_VAR_DATA_TYPE(pCol->type)) { if (IS_VAR_DATA_TYPE(pCol->type)) {
pCol->dataOff[index] = pCol->len; pCol->dataOff[utl_index] = pCol->len;
char *ptr = POINTER_SHIFT(pCol->pData, pCol->len); char *ptr = POINTER_SHIFT(pCol->pData, pCol->len);
setVardataNull(ptr, pCol->type); setVardataNull(ptr, pCol->type);
pCol->len += varDataTLen(ptr); pCol->len += varDataTLen(ptr);
} else { } else {
setNull(POINTER_SHIFT(pCol->pData, TYPE_BYTES[pCol->type] * index), pCol->type, pCol->bytes); setNull(POINTER_SHIFT(pCol->pData, TYPE_BYTES[pCol->type] * utl_index), pCol->type, pCol->bytes);
pCol->len += TYPE_BYTES[pCol->type]; pCol->len += TYPE_BYTES[pCol->type];
} }
} }
......
...@@ -75,7 +75,7 @@ int32_t tsMaxBinaryDisplayWidth = 30; ...@@ -75,7 +75,7 @@ int32_t tsMaxBinaryDisplayWidth = 30;
* -1: all data are not compressed * -1: all data are not compressed
* other values: if the message payload size is greater than the tsCompressMsgSize, the message will be compressed. * other values: if the message payload size is greater than the tsCompressMsgSize, the message will be compressed.
*/ */
int32_t tsCompressMsgSize = -1; int32_t tsCompressMsgSize = 512 * 1024;
// client // client
int32_t tsMaxSQLStringLen = TSDB_MAX_ALLOWED_SQL_LEN; int32_t tsMaxSQLStringLen = TSDB_MAX_ALLOWED_SQL_LEN;
...@@ -376,10 +376,10 @@ bool taosCfgDynamicOptions(char *msg) { ...@@ -376,10 +376,10 @@ bool taosCfgDynamicOptions(char *msg) {
return false; return false;
} }
void taosAddDataDir(int index, char *v1, int level, int primary) { void taosAddDataDir(int utl_index, char *v1, int level, int primary) {
tstrncpy(tsDiskCfg[index].dir, v1, TSDB_FILENAME_LEN); tstrncpy(tsDiskCfg[utl_index].dir, v1, TSDB_FILENAME_LEN);
tsDiskCfg[index].level = level; tsDiskCfg[utl_index].level = level;
tsDiskCfg[index].primary = primary; tsDiskCfg[utl_index].primary = primary;
uTrace("dataDir:%s, level:%d primary:%d is configured", v1, level, primary); uTrace("dataDir:%s, level:%d primary:%d is configured", v1, level, primary);
} }
......
...@@ -338,29 +338,29 @@ void tNameAssign(SName* dst, const SName* src) { ...@@ -338,29 +338,29 @@ void tNameAssign(SName* dst, const SName* src) {
memcpy(dst, src, sizeof(SName)); memcpy(dst, src, sizeof(SName));
} }
int32_t tNameSetDbName(SName* dst, const char* acct, SStrToken* dbToken) { int32_t tNameSetDbName(SName* dst, const char* utl_acct, SStrToken* dbToken) {
assert(dst != NULL && dbToken != NULL && acct != NULL); assert(dst != NULL && dbToken != NULL && utl_acct != NULL);
// too long account id or too long db name // too long account id or too long db name
if (strlen(acct) >= tListLen(dst->acctId) || dbToken->n >= tListLen(dst->dbname)) { if (strlen(utl_acct) >= tListLen(dst->acctId) || dbToken->n >= tListLen(dst->dbname)) {
return -1; return -1;
} }
dst->type = TSDB_DB_NAME_T; dst->type = TSDB_DB_NAME_T;
tstrncpy(dst->acctId, acct, tListLen(dst->acctId)); tstrncpy(dst->acctId, utl_acct, tListLen(dst->acctId));
tstrncpy(dst->dbname, dbToken->z, dbToken->n + 1); tstrncpy(dst->dbname, dbToken->z, dbToken->n + 1);
return 0; return 0;
} }
int32_t tNameSetAcctId(SName* dst, const char* acct) { int32_t tNameSetAcctId(SName* dst, const char* utl_acct) {
assert(dst != NULL && acct != NULL); assert(dst != NULL && utl_acct != NULL);
// too long account id or too long db name // too long account id or too long db name
if (strlen(acct) >= tListLen(dst->acctId)) { if (strlen(utl_acct) >= tListLen(dst->acctId)) {
return -1; return -1;
} }
tstrncpy(dst->acctId, acct, tListLen(dst->acctId)); tstrncpy(dst->acctId, utl_acct, tListLen(dst->acctId));
assert(strlen(dst->acctId) > 0); assert(strlen(dst->acctId) > 0);
......
...@@ -258,8 +258,8 @@ static void getStatics_u64(const void *pData, int32_t numOfRow, int64_t *min, in ...@@ -258,8 +258,8 @@ static void getStatics_u64(const void *pData, int32_t numOfRow, int64_t *min, in
static void getStatics_f(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, static void getStatics_f(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max,
int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
float *data = (float *)pData; float *data = (float *)pData;
float fmin = FLT_MAX; float utl_fmin = FLT_MAX;
float fmax = -FLT_MAX; float utl_fmax = -FLT_MAX;
double dsum = 0; double dsum = 0;
*minIndex = 0; *minIndex = 0;
*maxIndex = 0; *maxIndex = 0;
...@@ -275,20 +275,20 @@ static void getStatics_f(const void *pData, int32_t numOfRow, int64_t *min, int6 ...@@ -275,20 +275,20 @@ static void getStatics_f(const void *pData, int32_t numOfRow, int64_t *min, int6
float fv = GET_FLOAT_VAL((const char*)&(data[i])); float fv = GET_FLOAT_VAL((const char*)&(data[i]));
dsum += fv; dsum += fv;
if (fmin > fv) { if (utl_fmin > fv) {
fmin = fv; utl_fmin = fv;
*minIndex = i; *minIndex = i;
} }
if (fmax < fv) { if (utl_fmax < fv) {
fmax = fv; utl_fmax = fv;
*maxIndex = i; *maxIndex = i;
} }
} }
SET_DOUBLE_VAL(sum, dsum); SET_DOUBLE_VAL(sum, dsum);
SET_DOUBLE_VAL(max, fmax); SET_DOUBLE_VAL(max, utl_fmax);
SET_DOUBLE_VAL(min, fmin); SET_DOUBLE_VAL(min, utl_fmin);
} }
static void getStatics_d(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, static void getStatics_d(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max,
......
...@@ -424,7 +424,7 @@ static void cqProcessCreateTimer(void *param, void *tmrId) { ...@@ -424,7 +424,7 @@ static void cqProcessCreateTimer(void *param, void *tmrId) {
// inner implement in tscStream.c // inner implement in tscStream.c
TAOS_STREAM *taos_open_stream_withname(TAOS *taos, const char* desName, const char *sqlstr, void (*fp)(void *param, TAOS_RES *, TAOS_ROW row), TAOS_STREAM *taos_open_stream_withname(TAOS *taos, const char* desName, const char *sqlstr, void (*fp)(void *param, TAOS_RES *, TAOS_ROW row),
int64_t stime, void *param, void (*callback)(void *), void* cqhandle); int64_t tsc_stime, void *param, void (*callback)(void *), void* cqhandle);
static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) { static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) {
pObj->pContext = pContext; pObj->pContext = pContext;
......
...@@ -229,12 +229,12 @@ static void dnodeAllocCheckItem() { ...@@ -229,12 +229,12 @@ static void dnodeAllocCheckItem() {
} }
void dnodeCleanupCheck() { void dnodeCleanupCheck() {
for (ECheckItemType index = 0; index < TSDB_CHECK_ITEM_MAX; ++index) { for (ECheckItemType dnd_index = 0; dnd_index < TSDB_CHECK_ITEM_MAX; ++dnd_index) {
if (tsCheckItem[index].enable && tsCheckItem[index].stopFp) { if (tsCheckItem[dnd_index].enable && tsCheckItem[dnd_index].stopFp) {
(*tsCheckItem[index].stopFp)(); (*tsCheckItem[dnd_index].stopFp)();
} }
if (tsCheckItem[index].cleanUpFp) { if (tsCheckItem[dnd_index].cleanUpFp) {
(*tsCheckItem[index].cleanUpFp)(); (*tsCheckItem[dnd_index].cleanUpFp)();
} }
} }
} }
...@@ -242,19 +242,19 @@ void dnodeCleanupCheck() { ...@@ -242,19 +242,19 @@ void dnodeCleanupCheck() {
int32_t dnodeInitCheck() { int32_t dnodeInitCheck() {
dnodeAllocCheckItem(); dnodeAllocCheckItem();
for (ECheckItemType index = 0; index < TSDB_CHECK_ITEM_MAX; ++index) { for (ECheckItemType dnd_index = 0; dnd_index < TSDB_CHECK_ITEM_MAX; ++dnd_index) {
if (tsCheckItem[index].initFp) { if (tsCheckItem[dnd_index].initFp) {
if ((*tsCheckItem[index].initFp)() != 0) { if ((*tsCheckItem[dnd_index].initFp)() != 0) {
dError("failed to init check item:%s", tsCheckItem[index].name); dError("failed to init check item:%s", tsCheckItem[dnd_index].name);
return -1; return -1;
} }
} }
} }
for (ECheckItemType index = 0; index < TSDB_CHECK_ITEM_MAX; ++index) { for (ECheckItemType dnd_index = 0; dnd_index < TSDB_CHECK_ITEM_MAX; ++dnd_index) {
if (tsCheckItem[index].enable && tsCheckItem[index].startFp) { if (tsCheckItem[dnd_index].enable && tsCheckItem[dnd_index].startFp) {
if ((*tsCheckItem[index].startFp)() != 0) { if ((*tsCheckItem[dnd_index].startFp)() != 0) {
dError("failed to check item:%s", tsCheckItem[index].name); dError("failed to check item:%s", tsCheckItem[dnd_index].name);
exit(-1); exit(-1);
} }
} }
......
...@@ -56,17 +56,17 @@ int32_t dnodeInitServer() { ...@@ -56,17 +56,17 @@ int32_t dnodeInitServer() {
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_GRANT] = dnodeDispatchToMPeerQueue; dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_GRANT] = dnodeDispatchToMPeerQueue;
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_STATUS] = dnodeDispatchToMPeerQueue; dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_STATUS] = dnodeDispatchToMPeerQueue;
SRpcInit rpcInit; SRpcInit dnd_rpcInit;
memset(&rpcInit, 0, sizeof(rpcInit)); memset(&dnd_rpcInit, 0, sizeof(dnd_rpcInit));
rpcInit.localPort = tsDnodeDnodePort; dnd_rpcInit.localPort = tsDnodeDnodePort;
rpcInit.label = "DND-S"; dnd_rpcInit.label = "DND-S";
rpcInit.numOfThreads = 1; dnd_rpcInit.numOfThreads = 1;
rpcInit.cfp = dnodeProcessReqMsgFromDnode; dnd_rpcInit.cfp = dnodeProcessReqMsgFromDnode;
rpcInit.sessions = TSDB_MAX_VNODES << 4; dnd_rpcInit.sessions = TSDB_MAX_VNODES << 4;
rpcInit.connType = TAOS_CONN_SERVER; dnd_rpcInit.connType = TAOS_CONN_SERVER;
rpcInit.idleTime = tsShellActivityTimer * 1000; dnd_rpcInit.idleTime = tsShellActivityTimer * 1000;
tsServerRpc = rpcOpen(&rpcInit); tsServerRpc = rpcOpen(&dnd_rpcInit);
if (tsServerRpc == NULL) { if (tsServerRpc == NULL) {
dError("failed to init inter-dnodes RPC server"); dError("failed to init inter-dnodes RPC server");
return -1; return -1;
...@@ -123,19 +123,19 @@ static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcEpSet *pEpSet) { ...@@ -123,19 +123,19 @@ static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
int32_t dnodeInitClient() { int32_t dnodeInitClient() {
char secret[TSDB_KEY_LEN] = "secret"; char secret[TSDB_KEY_LEN] = "secret";
SRpcInit rpcInit; SRpcInit dnd_rpcInit;
memset(&rpcInit, 0, sizeof(rpcInit)); memset(&dnd_rpcInit, 0, sizeof(dnd_rpcInit));
rpcInit.label = "DND-C"; dnd_rpcInit.label = "DND-C";
rpcInit.numOfThreads = 1; dnd_rpcInit.numOfThreads = 1;
rpcInit.cfp = dnodeProcessRspFromDnode; dnd_rpcInit.cfp = dnodeProcessRspFromDnode;
rpcInit.sessions = TSDB_MAX_VNODES << 4; dnd_rpcInit.sessions = TSDB_MAX_VNODES << 4;
rpcInit.connType = TAOS_CONN_CLIENT; dnd_rpcInit.connType = TAOS_CONN_CLIENT;
rpcInit.idleTime = tsShellActivityTimer * 1000; dnd_rpcInit.idleTime = tsShellActivityTimer * 1000;
rpcInit.user = "t"; dnd_rpcInit.user = "t";
rpcInit.ckey = "key"; dnd_rpcInit.ckey = "key";
rpcInit.secret = secret; dnd_rpcInit.secret = secret;
tsClientRpc = rpcOpen(&rpcInit); tsClientRpc = rpcOpen(&dnd_rpcInit);
if (tsClientRpc == NULL) { if (tsClientRpc == NULL) {
dError("failed to init mnode rpc client"); dError("failed to init mnode rpc client");
return -1; return -1;
......
...@@ -83,18 +83,18 @@ int32_t dnodeInitShell() { ...@@ -83,18 +83,18 @@ int32_t dnodeInitShell() {
numOfThreads = 1; numOfThreads = 1;
} }
SRpcInit rpcInit; SRpcInit dnd_rpcInit;
memset(&rpcInit, 0, sizeof(rpcInit)); memset(&dnd_rpcInit, 0, sizeof(dnd_rpcInit));
rpcInit.localPort = tsDnodeShellPort; dnd_rpcInit.localPort = tsDnodeShellPort;
rpcInit.label = "SHELL"; dnd_rpcInit.label = "SHELL";
rpcInit.numOfThreads = numOfThreads; dnd_rpcInit.numOfThreads = numOfThreads;
rpcInit.cfp = dnodeProcessMsgFromShell; dnd_rpcInit.cfp = dnodeProcessMsgFromShell;
rpcInit.sessions = tsMaxShellConns; dnd_rpcInit.sessions = tsMaxShellConns;
rpcInit.connType = TAOS_CONN_SERVER; dnd_rpcInit.connType = TAOS_CONN_SERVER;
rpcInit.idleTime = tsShellActivityTimer * 1000; dnd_rpcInit.idleTime = tsShellActivityTimer * 1000;
rpcInit.afp = dnodeRetrieveUserAuthInfo; dnd_rpcInit.afp = dnodeRetrieveUserAuthInfo;
tsShellRpc = rpcOpen(&rpcInit); tsShellRpc = rpcOpen(&dnd_rpcInit);
if (tsShellRpc == NULL) { if (tsShellRpc == NULL) {
dError("failed to init shell rpc server"); dError("failed to init shell rpc server");
return -1; return -1;
......
...@@ -93,8 +93,8 @@ static void shellCheckTablesSQLFile(const char *directoryName) ...@@ -93,8 +93,8 @@ static void shellCheckTablesSQLFile(const char *directoryName)
{ {
sprintf(shellTablesSQLFile, "%s/tables.sql", directoryName); sprintf(shellTablesSQLFile, "%s/tables.sql", directoryName);
struct stat fstat; struct stat kit_fstat;
if (stat(shellTablesSQLFile, &fstat) < 0) { if (stat(shellTablesSQLFile, &kit_fstat) < 0) {
shellTablesSQLFile[0] = 0; shellTablesSQLFile[0] = 0;
} }
} }
......
此差异已折叠。
...@@ -145,8 +145,8 @@ static int32_t mnodeCreateCluster() { ...@@ -145,8 +145,8 @@ static int32_t mnodeCreateCluster() {
SClusterObj *pCluster = malloc(sizeof(SClusterObj)); SClusterObj *pCluster = malloc(sizeof(SClusterObj));
memset(pCluster, 0, sizeof(SClusterObj)); memset(pCluster, 0, sizeof(SClusterObj));
pCluster->createdTime = taosGetTimestampMs(); pCluster->createdTime = taosGetTimestampMs();
bool getuid = taosGetSystemUid(pCluster->uid); bool mnd_getuid = taosGetSystemUid(pCluster->uid);
if (!getuid) { if (!mnd_getuid) {
strcpy(pCluster->uid, "tdengine2.0"); strcpy(pCluster->uid, "tdengine2.0");
mError("failed to get uid from system, set to default val %s", pCluster->uid); mError("failed to get uid from system, set to default val %s", pCluster->uid);
} else { } else {
......
...@@ -209,7 +209,7 @@ void mnodeUpdateMnodeEpSet(SMInfos *pMinfos) { ...@@ -209,7 +209,7 @@ void mnodeUpdateMnodeEpSet(SMInfos *pMinfos) {
mInfos = *pMinfos; mInfos = *pMinfos;
} else { } else {
mInfo("vgId:1, update mnodes epSet, numOfMnodes:%d", mnodeGetMnodesNum()); mInfo("vgId:1, update mnodes epSet, numOfMnodes:%d", mnodeGetMnodesNum());
int32_t index = 0; int32_t mnd_index = 0;
void * pIter = NULL; void * pIter = NULL;
while (1) { while (1) {
SMnodeObj *pMnode = NULL; SMnodeObj *pMnode = NULL;
...@@ -219,10 +219,10 @@ void mnodeUpdateMnodeEpSet(SMInfos *pMinfos) { ...@@ -219,10 +219,10 @@ void mnodeUpdateMnodeEpSet(SMInfos *pMinfos) {
SDnodeObj *pDnode = mnodeGetDnode(pMnode->mnodeId); SDnodeObj *pDnode = mnodeGetDnode(pMnode->mnodeId);
if (pDnode != NULL) { if (pDnode != NULL) {
set = true; set = true;
mInfos.mnodeInfos[index].mnodeId = pMnode->mnodeId; mInfos.mnodeInfos[mnd_index].mnodeId = pMnode->mnodeId;
strcpy(mInfos.mnodeInfos[index].mnodeEp, pDnode->dnodeEp); strcpy(mInfos.mnodeInfos[mnd_index].mnodeEp, pDnode->dnodeEp);
if (pMnode->role == TAOS_SYNC_ROLE_MASTER) mInfos.inUse = index; if (pMnode->role == TAOS_SYNC_ROLE_MASTER) mInfos.inUse = mnd_index;
index++; mnd_index++;
} else { } else {
set = false; set = false;
} }
...@@ -231,7 +231,7 @@ void mnodeUpdateMnodeEpSet(SMInfos *pMinfos) { ...@@ -231,7 +231,7 @@ void mnodeUpdateMnodeEpSet(SMInfos *pMinfos) {
mnodeDecMnodeRef(pMnode); mnodeDecMnodeRef(pMnode);
} }
mInfos.mnodeNum = index; mInfos.mnodeNum = mnd_index;
if (mInfos.mnodeNum < sdbGetReplicaNum()) { if (mInfos.mnodeNum < sdbGetReplicaNum()) {
set = false; set = false;
mDebug("vgId:1, mnodes info not synced, current:%d syncCfgNum:%d", mInfos.mnodeNum, sdbGetReplicaNum()); mDebug("vgId:1, mnodes info not synced, current:%d syncCfgNum:%d", mInfos.mnodeNum, sdbGetReplicaNum());
...@@ -250,23 +250,23 @@ void mnodeUpdateMnodeEpSet(SMInfos *pMinfos) { ...@@ -250,23 +250,23 @@ void mnodeUpdateMnodeEpSet(SMInfos *pMinfos) {
tsMEpForPeer.numOfEps = tsMInfos.mnodeNum; tsMEpForPeer.numOfEps = tsMInfos.mnodeNum;
mInfo("vgId:1, mnodes epSet is set, num:%d inUse:%d", tsMInfos.mnodeNum, tsMInfos.inUse); mInfo("vgId:1, mnodes epSet is set, num:%d inUse:%d", tsMInfos.mnodeNum, tsMInfos.inUse);
for (int index = 0; index < mInfos.mnodeNum; ++index) { for (int mnd_index = 0; mnd_index < mInfos.mnodeNum; ++mnd_index) {
SMInfo *pInfo = &tsMInfos.mnodeInfos[index]; SMInfo *pInfo = &tsMInfos.mnodeInfos[mnd_index];
taosGetFqdnPortFromEp(pInfo->mnodeEp, tsMEpForShell.fqdn[index], &tsMEpForShell.port[index]); taosGetFqdnPortFromEp(pInfo->mnodeEp, tsMEpForShell.fqdn[mnd_index], &tsMEpForShell.port[mnd_index]);
taosGetFqdnPortFromEp(pInfo->mnodeEp, tsMEpForPeer.fqdn[index], &tsMEpForPeer.port[index]); taosGetFqdnPortFromEp(pInfo->mnodeEp, tsMEpForPeer.fqdn[mnd_index], &tsMEpForPeer.port[mnd_index]);
tsMEpForPeer.port[index] = tsMEpForPeer.port[index] + TSDB_PORT_DNODEDNODE; tsMEpForPeer.port[mnd_index] = tsMEpForPeer.port[mnd_index] + TSDB_PORT_DNODEDNODE;
mInfo("vgId:1, mnode:%d, fqdn:%s shell:%u peer:%u", pInfo->mnodeId, tsMEpForShell.fqdn[index], mInfo("vgId:1, mnode:%d, fqdn:%s shell:%u peer:%u", pInfo->mnodeId, tsMEpForShell.fqdn[mnd_index],
tsMEpForShell.port[index], tsMEpForPeer.port[index]); tsMEpForShell.port[mnd_index], tsMEpForPeer.port[mnd_index]);
tsMEpForShell.port[index] = htons(tsMEpForShell.port[index]); tsMEpForShell.port[mnd_index] = htons(tsMEpForShell.port[mnd_index]);
tsMEpForPeer.port[index] = htons(tsMEpForPeer.port[index]); tsMEpForPeer.port[mnd_index] = htons(tsMEpForPeer.port[mnd_index]);
pInfo->mnodeId = htonl(pInfo->mnodeId); pInfo->mnodeId = htonl(pInfo->mnodeId);
} }
} else { } else {
mInfo("vgId:1, mnodes epSet not set, num:%d inUse:%d", tsMInfos.mnodeNum, tsMInfos.inUse); mInfo("vgId:1, mnodes epSet not set, num:%d inUse:%d", tsMInfos.mnodeNum, tsMInfos.inUse);
for (int index = 0; index < tsMInfos.mnodeNum; ++index) { for (int mnd_index = 0; mnd_index < tsMInfos.mnodeNum; ++mnd_index) {
mInfo("vgId:1, index:%d, ep:%s:%u", index, tsMEpForShell.fqdn[index], htons(tsMEpForShell.port[index])); mInfo("vgId:1, index:%d, ep:%s:%u", mnd_index, tsMEpForShell.fqdn[mnd_index], htons(tsMEpForShell.port[mnd_index]));
} }
} }
......
...@@ -330,7 +330,7 @@ int32_t sdbUpdateSync(void *pMnodes) { ...@@ -330,7 +330,7 @@ int32_t sdbUpdateSync(void *pMnodes) {
mDebug("vgId:1, update sync config, pMnodes:%p", pMnodes); mDebug("vgId:1, update sync config, pMnodes:%p", pMnodes);
SSyncCfg syncCfg = {0}; SSyncCfg syncCfg = {0};
int32_t index = 0; int32_t mnd_index = 0;
if (pMinfos == NULL) { if (pMinfos == NULL) {
mDebug("vgId:1, mInfos not input, use mInfos in sdb, numOfMnodes:%d", syncCfg.replica); mDebug("vgId:1, mInfos not input, use mInfos in sdb, numOfMnodes:%d", syncCfg.replica);
...@@ -341,29 +341,29 @@ int32_t sdbUpdateSync(void *pMnodes) { ...@@ -341,29 +341,29 @@ int32_t sdbUpdateSync(void *pMnodes) {
pIter = mnodeGetNextMnode(pIter, &pMnode); pIter = mnodeGetNextMnode(pIter, &pMnode);
if (pMnode == NULL) break; if (pMnode == NULL) break;
syncCfg.nodeInfo[index].nodeId = pMnode->mnodeId; syncCfg.nodeInfo[mnd_index].nodeId = pMnode->mnodeId;
SDnodeObj *pDnode = mnodeGetDnode(pMnode->mnodeId); SDnodeObj *pDnode = mnodeGetDnode(pMnode->mnodeId);
if (pDnode != NULL) { if (pDnode != NULL) {
syncCfg.nodeInfo[index].nodePort = pDnode->dnodePort + TSDB_PORT_SYNC; syncCfg.nodeInfo[mnd_index].nodePort = pDnode->dnodePort + TSDB_PORT_SYNC;
tstrncpy(syncCfg.nodeInfo[index].nodeFqdn, pDnode->dnodeFqdn, TSDB_FQDN_LEN); tstrncpy(syncCfg.nodeInfo[mnd_index].nodeFqdn, pDnode->dnodeFqdn, TSDB_FQDN_LEN);
index++; mnd_index++;
} }
mnodeDecDnodeRef(pDnode); mnodeDecDnodeRef(pDnode);
mnodeDecMnodeRef(pMnode); mnodeDecMnodeRef(pMnode);
} }
syncCfg.replica = index; syncCfg.replica = mnd_index;
} else { } else {
mDebug("vgId:1, mInfos input, numOfMnodes:%d", pMinfos->mnodeNum); mDebug("vgId:1, mInfos input, numOfMnodes:%d", pMinfos->mnodeNum);
for (index = 0; index < pMinfos->mnodeNum; ++index) { for (mnd_index = 0; mnd_index < pMinfos->mnodeNum; ++mnd_index) {
SMInfo *node = &pMinfos->mnodeInfos[index]; SMInfo *node = &pMinfos->mnodeInfos[mnd_index];
syncCfg.nodeInfo[index].nodeId = node->mnodeId; syncCfg.nodeInfo[mnd_index].nodeId = node->mnodeId;
taosGetFqdnPortFromEp(node->mnodeEp, syncCfg.nodeInfo[index].nodeFqdn, &syncCfg.nodeInfo[index].nodePort); taosGetFqdnPortFromEp(node->mnodeEp, syncCfg.nodeInfo[mnd_index].nodeFqdn, &syncCfg.nodeInfo[mnd_index].nodePort);
syncCfg.nodeInfo[index].nodePort += TSDB_PORT_SYNC; syncCfg.nodeInfo[mnd_index].nodePort += TSDB_PORT_SYNC;
} }
syncCfg.replica = index; syncCfg.replica = mnd_index;
mnodeUpdateMnodeEpSet(pMnodes); mnodeUpdateMnodeEpSet(pMnodes);
} }
......
...@@ -121,7 +121,7 @@ static int32_t mnodeProcessShowMsg(SMnodeMsg *pMsg) { ...@@ -121,7 +121,7 @@ static int32_t mnodeProcessShowMsg(SMnodeMsg *pMsg) {
} }
if (!tsMnodeShowMetaFp[pShowMsg->type] || !tsMnodeShowRetrieveFp[pShowMsg->type]) { if (!tsMnodeShowMetaFp[pShowMsg->type] || !tsMnodeShowRetrieveFp[pShowMsg->type]) {
mError("show type:%s is not support", mnodeGetShowType(pShowMsg->type)); mWarn("show type:%s is not support", mnodeGetShowType(pShowMsg->type));
return TSDB_CODE_COM_OPS_NOT_SUPPORT; return TSDB_CODE_COM_OPS_NOT_SUPPORT;
} }
......
...@@ -10,5 +10,6 @@ ELSEIF (TD_WINDOWS) ...@@ -10,5 +10,6 @@ ELSEIF (TD_WINDOWS)
ENDIF () ENDIF ()
ADD_SUBDIRECTORY(src/detail) ADD_SUBDIRECTORY(src/detail)
ADD_SUBDIRECTORY(tests) IF (NOT TD_NINGSI_60)
ADD_SUBDIRECTORY(tests)
ENDIF ()
...@@ -45,8 +45,8 @@ void taosRemoveDir(char *rootDir) { ...@@ -45,8 +45,8 @@ void taosRemoveDir(char *rootDir) {
uInfo("dir:%s is removed", rootDir); uInfo("dir:%s is removed", rootDir);
} }
bool taosDirExist(const char* dirname) { bool taosDirExist(const char* os_dirname) {
return access(dirname, F_OK) == 0; return access(os_dirname, F_OK) == 0;
} }
int taosMkDir(const char *path, mode_t mode) { int taosMkDir(const char *path, mode_t mode) {
......
...@@ -43,9 +43,9 @@ void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) { ...@@ -43,9 +43,9 @@ void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) {
strcat(tmpPath, "-%d-%s"); strcat(tmpPath, "-%d-%s");
} }
char rand[8] = {0}; char os_rand[8] = {0};
taosRandStr(rand, tListLen(rand) - 1); taosRandStr(os_rand, tListLen(os_rand) - 1);
snprintf(dstPath, PATH_MAX, tmpPath, getpid(), rand); snprintf(dstPath, PATH_MAX, tmpPath, getpid(), os_rand);
} }
#else #else
...@@ -68,11 +68,11 @@ void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) { ...@@ -68,11 +68,11 @@ void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) {
strcat(tmpPath, "-%d-%s"); strcat(tmpPath, "-%d-%s");
} }
char rand[32] = {0}; char os_rand[32] = {0};
sprintf(rand, "%" PRIu64, atomic_add_fetch_64(&seqId, 1)); sprintf(os_rand, "%" PRIu64, atomic_add_fetch_64(&seqId, 1));
snprintf(dstPath, PATH_MAX, tmpPath, getpid(), rand); snprintf(dstPath, PATH_MAX, tmpPath, getpid(), os_rand);
} }
#endif #endif
......
...@@ -82,23 +82,23 @@ void deltaToUtcInitOnce() { ...@@ -82,23 +82,23 @@ void deltaToUtcInitOnce() {
} }
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* os_time, int32_t timePrec);
static int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec); static int32_t parseLocaltime(char* timestr, int64_t* os_time, int32_t timePrec);
static int32_t parseLocaltimeWithDst(char* timestr, int64_t* time, int32_t timePrec); static int32_t parseLocaltimeWithDst(char* timestr, int64_t* os_time, int32_t timePrec);
static int32_t (*parseLocaltimeFp[]) (char* timestr, int64_t* time, int32_t timePrec) = { static int32_t (*parseLocaltimeFp[]) (char* timestr, int64_t* os_time, int32_t timePrec) = {
parseLocaltime, parseLocaltime,
parseLocaltimeWithDst parseLocaltimeWithDst
}; };
int32_t taosGetTimestampSec() { return (int32_t)time(NULL); } int32_t taosGetTimestampSec() { return (int32_t)time(NULL); }
int32_t taosParseTime(char* timestr, int64_t* time, int32_t len, int32_t timePrec, int8_t day_light) { int32_t taosParseTime(char* timestr, int64_t* os_time, int32_t len, int32_t timePrec, int8_t day_light) {
/* parse datatime string in with tz */ /* parse datatime string in with tz */
if (strnchr(timestr, 'T', len, false) != NULL) { if (strnchr(timestr, 'T', len, false) != NULL) {
return parseTimeWithTz(timestr, time, timePrec); return parseTimeWithTz(timestr, os_time, timePrec);
} else { } else {
return (*parseLocaltimeFp[day_light])(timestr, time, timePrec); return (*parseLocaltimeFp[day_light])(timestr, os_time, timePrec);
} }
} }
...@@ -213,7 +213,7 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) { ...@@ -213,7 +213,7 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
* 2013-04-12T15:52:01+0800 * 2013-04-12T15:52:01+0800
* 2013-04-12T15:52:01.123+0800 * 2013-04-12T15:52:01.123+0800
*/ */
int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec) { int32_t parseTimeWithTz(char* timestr, int64_t* os_time, int32_t timePrec) {
int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 :
(timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000); (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000);
...@@ -238,14 +238,14 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec) { ...@@ -238,14 +238,14 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec) {
if (str[0] == 'Z' || str[0] == 'z') { if (str[0] == 'Z' || str[0] == 'z') {
/* utc time, no millisecond, return directly*/ /* utc time, no millisecond, return directly*/
*time = seconds * factor; *os_time = seconds * factor;
} else if (str[0] == '.') { } else if (str[0] == '.') {
str += 1; str += 1;
if ((fraction = parseFraction(str, &str, timePrec)) < 0) { if ((fraction = parseFraction(str, &str, timePrec)) < 0) {
return -1; return -1;
} }
*time = seconds * factor + fraction; *os_time = seconds * factor + fraction;
char seg = str[0]; char seg = str[0];
if (seg != 'Z' && seg != 'z' && seg != '+' && seg != '-') { if (seg != 'Z' && seg != 'z' && seg != '+' && seg != '-') {
...@@ -256,18 +256,18 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec) { ...@@ -256,18 +256,18 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec) {
return -1; return -1;
} }
*time += tzOffset * factor; *os_time += tzOffset * factor;
} }
} else if (str[0] == '+' || str[0] == '-') { } else if (str[0] == '+' || str[0] == '-') {
*time = seconds * factor + fraction; *os_time = seconds * factor + fraction;
// parse the timezone // parse the timezone
if (parseTimezone(str, &tzOffset) == -1) { if (parseTimezone(str, &tzOffset) == -1) {
return -1; return -1;
} }
*time += tzOffset * factor; *os_time += tzOffset * factor;
} else { } else {
return -1; return -1;
} }
...@@ -275,8 +275,8 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec) { ...@@ -275,8 +275,8 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec) {
return 0; return 0;
} }
int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec) { int32_t parseLocaltime(char* timestr, int64_t* os_time, int32_t timePrec) {
*time = 0; *os_time = 0;
struct tm tm = {0}; struct tm tm = {0};
char* str = strptime(timestr, "%Y-%m-%d %H:%M:%S", &tm); char* str = strptime(timestr, "%Y-%m-%d %H:%M:%S", &tm);
...@@ -303,13 +303,13 @@ int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec) { ...@@ -303,13 +303,13 @@ int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec) {
int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 :
(timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000); (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000);
*time = factor * seconds + fraction; *os_time = factor * seconds + fraction;
return 0; return 0;
} }
int32_t parseLocaltimeWithDst(char* timestr, int64_t* time, int32_t timePrec) { int32_t parseLocaltimeWithDst(char* timestr, int64_t* os_time, int32_t timePrec) {
*time = 0; *os_time = 0;
struct tm tm = {0}; struct tm tm = {0};
tm.tm_isdst = -1; tm.tm_isdst = -1;
...@@ -332,64 +332,64 @@ int32_t parseLocaltimeWithDst(char* timestr, int64_t* time, int32_t timePrec) { ...@@ -332,64 +332,64 @@ int32_t parseLocaltimeWithDst(char* timestr, int64_t* time, int32_t timePrec) {
int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 :
(timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000); (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000);
*time = factor * seconds + fraction; *os_time = factor * seconds + fraction;
return 0; return 0;
} }
int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision) { int64_t convertTimePrecision(int64_t os_time, int32_t fromPrecision, int32_t toPrecision) {
assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || assert(fromPrecision == TSDB_TIME_PRECISION_MILLI ||
fromPrecision == TSDB_TIME_PRECISION_MICRO || fromPrecision == TSDB_TIME_PRECISION_MICRO ||
fromPrecision == TSDB_TIME_PRECISION_NANO); fromPrecision == TSDB_TIME_PRECISION_NANO);
assert(toPrecision == TSDB_TIME_PRECISION_MILLI || assert(toPrecision == TSDB_TIME_PRECISION_MILLI ||
toPrecision == TSDB_TIME_PRECISION_MICRO || toPrecision == TSDB_TIME_PRECISION_MICRO ||
toPrecision == TSDB_TIME_PRECISION_NANO); toPrecision == TSDB_TIME_PRECISION_NANO);
double tempResult = (double)time; double tempResult = (double)os_time;
switch(fromPrecision) { switch(fromPrecision) {
case TSDB_TIME_PRECISION_MILLI: { case TSDB_TIME_PRECISION_MILLI: {
switch (toPrecision) { switch (toPrecision) {
case TSDB_TIME_PRECISION_MILLI: case TSDB_TIME_PRECISION_MILLI:
return time; return os_time;
case TSDB_TIME_PRECISION_MICRO: case TSDB_TIME_PRECISION_MICRO:
tempResult *= 1000; tempResult *= 1000;
time *= 1000; os_time *= 1000;
goto end_; goto end_;
case TSDB_TIME_PRECISION_NANO: case TSDB_TIME_PRECISION_NANO:
tempResult *= 1000000; tempResult *= 1000000;
time *= 1000000; os_time *= 1000000;
goto end_; goto end_;
} }
} // end from milli } // end from milli
case TSDB_TIME_PRECISION_MICRO: { case TSDB_TIME_PRECISION_MICRO: {
switch (toPrecision) { switch (toPrecision) {
case TSDB_TIME_PRECISION_MILLI: case TSDB_TIME_PRECISION_MILLI:
return time / 1000; return os_time / 1000;
case TSDB_TIME_PRECISION_MICRO: case TSDB_TIME_PRECISION_MICRO:
return time; return os_time;
case TSDB_TIME_PRECISION_NANO: case TSDB_TIME_PRECISION_NANO:
tempResult *= 1000; tempResult *= 1000;
time *= 1000; os_time *= 1000;
goto end_; goto end_;
} }
} //end from micro } //end from micro
case TSDB_TIME_PRECISION_NANO: { case TSDB_TIME_PRECISION_NANO: {
switch (toPrecision) { switch (toPrecision) {
case TSDB_TIME_PRECISION_MILLI: case TSDB_TIME_PRECISION_MILLI:
return time / 1000000; return os_time / 1000000;
case TSDB_TIME_PRECISION_MICRO: case TSDB_TIME_PRECISION_MICRO:
return time / 1000; return os_time / 1000;
case TSDB_TIME_PRECISION_NANO: case TSDB_TIME_PRECISION_NANO:
return time; return os_time;
} }
} //end from nano } //end from nano
default: { default: {
assert(0); assert(0);
return time; // only to pass windows compilation return os_time; // only to pass windows compilation
} }
} //end switch fromPrecision } //end switch fromPrecision
end_: end_:
if (tempResult >= (double)INT64_MAX) return INT64_MAX; if (tempResult >= (double)INT64_MAX) return INT64_MAX;
if (tempResult <= (double)INT64_MIN) return INT64_MIN + 1; // INT64_MIN means NULL if (tempResult <= (double)INT64_MIN) return INT64_MIN + 1; // INT64_MIN means NULL
return time; return os_time;
} }
static int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision) { static int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision) {
......
...@@ -33,9 +33,9 @@ void* taosLoadDll(const char *filename) { ...@@ -33,9 +33,9 @@ void* taosLoadDll(const char *filename) {
void* taosLoadSym(void* handle, char* name) { void* taosLoadSym(void* handle, char* name) {
void* sym = dlsym(handle, name); void* sym = dlsym(handle, name);
char* error = NULL; char* os_error = NULL;
if ((error = dlerror()) != NULL) { if ((os_error = dlerror()) != NULL) {
uWarn("load sym:%s failed, error:%s", name, dlerror()); uWarn("load sym:%s failed, error:%s", name, dlerror());
return NULL; return NULL;
} }
......
...@@ -61,14 +61,14 @@ char *getpass(const char *prefix) { ...@@ -61,14 +61,14 @@ char *getpass(const char *prefix) {
memset(passwd, 0, TSDB_KEY_LEN); memset(passwd, 0, TSDB_KEY_LEN);
printf("%s", prefix); printf("%s", prefix);
int32_t index = 0; int32_t os_index = 0;
char ch; char ch;
while (index < TSDB_KEY_LEN) { while (os_index < TSDB_KEY_LEN) {
ch = getch(); ch = getch();
if (ch == '\n' || ch == '\r') { if (ch == '\n' || ch == '\r') {
break; break;
} else { } else {
passwd[index++] = ch; passwd[os_index++] = ch;
} }
} }
......
...@@ -31,10 +31,10 @@ bool httpCheckUsedbSql(char *sql) { ...@@ -31,10 +31,10 @@ bool httpCheckUsedbSql(char *sql) {
} }
bool httpCheckAlterSql(char *sql) { bool httpCheckAlterSql(char *sql) {
int32_t index = 0; int32_t htp_index = 0;
do { do {
SStrToken t0 = tStrGetToken(sql, &index, false); SStrToken t0 = tStrGetToken(sql, &htp_index, false);
if (t0.type != TK_LP) { if (t0.type != TK_LP) {
return t0.type == TK_ALTER; return t0.type == TK_ALTER;
} }
......
...@@ -12,10 +12,14 @@ TARGET_LINK_LIBRARIES(query tsdb tutil lua) ...@@ -12,10 +12,14 @@ TARGET_LINK_LIBRARIES(query tsdb tutil lua)
IF (TD_LINUX) IF (TD_LINUX)
TARGET_LINK_LIBRARIES(query m rt lua) TARGET_LINK_LIBRARIES(query m rt lua)
ADD_SUBDIRECTORY(tests) IF (NOT TD_NINGSI_60)
ADD_SUBDIRECTORY(tests)
ENDIF ()
ENDIF () ENDIF ()
IF (TD_DARWIN) IF (TD_DARWIN)
TARGET_LINK_LIBRARIES(query m lua) TARGET_LINK_LIBRARIES(query m lua)
ADD_SUBDIRECTORY(tests) IF (NOT TD_NINGSI_60)
ADD_SUBDIRECTORY(tests)
ENDIF ()
ENDIF () ENDIF ()
...@@ -895,14 +895,14 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin, ...@@ -895,14 +895,14 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
} }
void* tval = NULL; void* tval = NULL;
int16_t index = 0; int16_t qry_index = 0;
if (isMin) { if (isMin) {
tval = &pCtx->preAggVals.statis.min; tval = &pCtx->preAggVals.statis.min;
index = pCtx->preAggVals.statis.minIndex; qry_index = pCtx->preAggVals.statis.minIndex;
} else { } else {
tval = &pCtx->preAggVals.statis.max; tval = &pCtx->preAggVals.statis.max;
index = pCtx->preAggVals.statis.maxIndex; qry_index = pCtx->preAggVals.statis.maxIndex;
} }
TSKEY key = TSKEY_INITIAL_VAL; TSKEY key = TSKEY_INITIAL_VAL;
...@@ -913,12 +913,12 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin, ...@@ -913,12 +913,12 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
* *
* The following codes of 3 lines will be removed later. * The following codes of 3 lines will be removed later.
*/ */
// if (index < 0 || index >= pCtx->size + pCtx->startOffset) { // if (qry_index < 0 || qry_index >= pCtx->size + pCtx->startOffset) {
// index = 0; // qry_index = 0;
// } // }
// the index is the original position, not the relative position // the index is the original position, not the relative position
key = pCtx->ptsList[index]; key = pCtx->ptsList[qry_index];
} }
if (IS_SIGNED_NUMERIC_TYPE(pCtx->inputType)) { if (IS_SIGNED_NUMERIC_TYPE(pCtx->inputType)) {
...@@ -1554,15 +1554,15 @@ static void first_function(SQLFunctionCtx *pCtx) { ...@@ -1554,15 +1554,15 @@ static void first_function(SQLFunctionCtx *pCtx) {
SET_VAL(pCtx, notNullElems, 1); SET_VAL(pCtx, notNullElems, 1);
} }
static void first_data_assign_impl(SQLFunctionCtx *pCtx, char *pData, int32_t index) { static void first_data_assign_impl(SQLFunctionCtx *pCtx, char *pData, int32_t qry_index) {
int64_t *timestamp = GET_TS_LIST(pCtx); int64_t *timestamp = GET_TS_LIST(pCtx);
SFirstLastInfo *pInfo = (SFirstLastInfo *)(pCtx->pOutput + pCtx->inputBytes); SFirstLastInfo *pInfo = (SFirstLastInfo *)(pCtx->pOutput + pCtx->inputBytes);
if (pInfo->hasResult != DATA_SET_FLAG || timestamp[index] < pInfo->ts) { if (pInfo->hasResult != DATA_SET_FLAG || timestamp[qry_index] < pInfo->ts) {
memcpy(pCtx->pOutput, pData, pCtx->inputBytes); memcpy(pCtx->pOutput, pData, pCtx->inputBytes);
pInfo->hasResult = DATA_SET_FLAG; pInfo->hasResult = DATA_SET_FLAG;
pInfo->ts = timestamp[index]; pInfo->ts = timestamp[qry_index];
DO_UPDATE_TAG_COLUMNS(pCtx, pInfo->ts); DO_UPDATE_TAG_COLUMNS(pCtx, pInfo->ts);
} }
...@@ -1685,19 +1685,19 @@ static void last_function(SQLFunctionCtx *pCtx) { ...@@ -1685,19 +1685,19 @@ static void last_function(SQLFunctionCtx *pCtx) {
SET_VAL(pCtx, notNullElems, 1); SET_VAL(pCtx, notNullElems, 1);
} }
static void last_data_assign_impl(SQLFunctionCtx *pCtx, char *pData, int32_t index) { static void last_data_assign_impl(SQLFunctionCtx *pCtx, char *pData, int32_t qry_index) {
int64_t *timestamp = GET_TS_LIST(pCtx); int64_t *timestamp = GET_TS_LIST(pCtx);
SFirstLastInfo *pInfo = (SFirstLastInfo *)(pCtx->pOutput + pCtx->inputBytes); SFirstLastInfo *pInfo = (SFirstLastInfo *)(pCtx->pOutput + pCtx->inputBytes);
if (pInfo->hasResult != DATA_SET_FLAG || pInfo->ts < timestamp[index]) { if (pInfo->hasResult != DATA_SET_FLAG || pInfo->ts < timestamp[qry_index]) {
#if defined(_DEBUG_VIEW) #if defined(_DEBUG_VIEW)
qDebug("assign index:%d, ts:%" PRId64 ", val:%d, ", index, timestamp[index], *(int32_t *)pData); qDebug("assign index:%d, ts:%" PRId64 ", val:%d, ", index, timestamp[index], *(int32_t *)pData);
#endif #endif
memcpy(pCtx->pOutput, pData, pCtx->inputBytes); memcpy(pCtx->pOutput, pData, pCtx->inputBytes);
pInfo->hasResult = DATA_SET_FLAG; pInfo->hasResult = DATA_SET_FLAG;
pInfo->ts = timestamp[index]; pInfo->ts = timestamp[qry_index];
DO_UPDATE_TAG_COLUMNS(pCtx, pInfo->ts); DO_UPDATE_TAG_COLUMNS(pCtx, pInfo->ts);
} }
...@@ -2562,12 +2562,12 @@ static bool leastsquares_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo ...@@ -2562,12 +2562,12 @@ static bool leastsquares_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo
return true; return true;
} }
#define LEASTSQR_CAL(p, x, y, index, step) \ #define LEASTSQR_CAL(p, x, y, qry_index, step) \
do { \ do { \
(p)[0][0] += (double)(x) * (x); \ (p)[0][0] += (double)(x) * (x); \
(p)[0][1] += (double)(x); \ (p)[0][1] += (double)(x); \
(p)[0][2] += (double)(x) * (y)[index]; \ (p)[0][2] += (double)(x) * (y)[qry_index]; \
(p)[1][2] += (y)[index]; \ (p)[1][2] += (y)[qry_index]; \
(x) += step; \ (x) += step; \
} while (0) } while (0)
...@@ -2992,7 +2992,7 @@ static void deriv_function(SQLFunctionCtx *pCtx) { ...@@ -2992,7 +2992,7 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
} else { \ } else { \
*(type *)(ctx)->pOutput = *(type *)(d) - (*(type *)(&(ctx)->param[1].i64)); \ *(type *)(ctx)->pOutput = *(type *)(d) - (*(type *)(&(ctx)->param[1].i64)); \
*(type *)(&(ctx)->param[1].i64) = *(type *)(d); \ *(type *)(&(ctx)->param[1].i64) = *(type *)(d); \
*(int64_t *)(ctx)->ptsOutputBuf = GET_TS_DATA(ctx, index); \ *(int64_t *)(ctx)->ptsOutputBuf = GET_TS_DATA(ctx, qry_index); \
} \ } \
} while (0); } while (0);
...@@ -3164,16 +3164,16 @@ static void diff_function(SQLFunctionCtx *pCtx) { ...@@ -3164,16 +3164,16 @@ static void diff_function(SQLFunctionCtx *pCtx) {
char *getArithColumnData(void *param, const char* name, int32_t colId) { char *getArithColumnData(void *param, const char* name, int32_t colId) {
SArithmeticSupport *pSupport = (SArithmeticSupport *)param; SArithmeticSupport *pSupport = (SArithmeticSupport *)param;
int32_t index = -1; int32_t qry_index = -1;
for (int32_t i = 0; i < pSupport->numOfCols; ++i) { for (int32_t i = 0; i < pSupport->numOfCols; ++i) {
if (colId == pSupport->colList[i].colId) { if (colId == pSupport->colList[i].colId) {
index = i; qry_index = i;
break; break;
} }
} }
assert(index >= 0); assert(qry_index >= 0);
return pSupport->data[index] + pSupport->offset * pSupport->colList[index].bytes; return pSupport->data[qry_index] + pSupport->offset * pSupport->colList[qry_index].bytes;
} }
static void arithmetic_function(SQLFunctionCtx *pCtx) { static void arithmetic_function(SQLFunctionCtx *pCtx) {
...@@ -3381,14 +3381,14 @@ static double twa_get_area(SPoint1 s, SPoint1 e) { ...@@ -3381,14 +3381,14 @@ static double twa_get_area(SPoint1 s, SPoint1 e) {
return val; return val;
} }
static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t index, int32_t size) { static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t qry_index, int32_t size) {
int32_t notNullElems = 0; int32_t notNullElems = 0;
SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx);
STwaInfo *pInfo = GET_ROWCELL_INTERBUF(pResInfo); STwaInfo *pInfo = GET_ROWCELL_INTERBUF(pResInfo);
TSKEY *tsList = GET_TS_LIST(pCtx); TSKEY *tsList = GET_TS_LIST(pCtx);
int32_t i = index; int32_t i = qry_index;
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pCtx->order); int32_t step = GET_FORWARD_DIRECTION_FACTOR(pCtx->order);
SPoint1* last = &pInfo->p; SPoint1* last = &pInfo->p;
...@@ -3399,7 +3399,7 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t index, int32_t si ...@@ -3399,7 +3399,7 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t index, int32_t si
assert(last->key == INT64_MIN); assert(last->key == INT64_MIN);
last->key = tsList[i]; last->key = tsList[i];
GET_TYPED_DATA(last->val, double, pCtx->inputType, GET_INPUT_DATA(pCtx, index)); GET_TYPED_DATA(last->val, double, pCtx->inputType, GET_INPUT_DATA(pCtx, qry_index));
pInfo->dOutput += twa_get_area(pCtx->start, *last); pInfo->dOutput += twa_get_area(pCtx->start, *last);
...@@ -3409,7 +3409,7 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t index, int32_t si ...@@ -3409,7 +3409,7 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t index, int32_t si
i += step; i += step;
} else if (pInfo->p.key == INT64_MIN) { } else if (pInfo->p.key == INT64_MIN) {
last->key = tsList[i]; last->key = tsList[i];
GET_TYPED_DATA(last->val, double, pCtx->inputType, GET_INPUT_DATA(pCtx, index)); GET_TYPED_DATA(last->val, double, pCtx->inputType, GET_INPUT_DATA(pCtx, qry_index));
pInfo->hasResult = DATA_SET_FLAG; pInfo->hasResult = DATA_SET_FLAG;
pInfo->win.skey = last->key; pInfo->win.skey = last->key;
...@@ -4246,7 +4246,7 @@ void generateBlockDistResult(STableBlockDist *pTableBlockDist, char* result) { ...@@ -4246,7 +4246,7 @@ void generateBlockDistResult(STableBlockDist *pTableBlockDist, char* result) {
"5th=[%d], 10th=[%d], 20th=[%d], 30th=[%d], 40th=[%d], 50th=[%d]\n\t " "5th=[%d], 10th=[%d], 20th=[%d], 30th=[%d], 40th=[%d], 50th=[%d]\n\t "
"60th=[%d], 70th=[%d], 80th=[%d], 90th=[%d], 95th=[%d], 99th=[%d]\n\t " "60th=[%d], 70th=[%d], 80th=[%d], 90th=[%d], 95th=[%d], 99th=[%d]\n\t "
"Min=[%"PRId64"(Rows)] Max=[%"PRId64"(Rows)] Avg=[%"PRId64"(Rows)] Stddev=[%.2f] \n\t " "Min=[%"PRId64"(Rows)] Max=[%"PRId64"(Rows)] Avg=[%"PRId64"(Rows)] Stddev=[%.2f] \n\t "
"Rows=[%"PRIu64"], Blocks=[%"PRId64"], SmallBlocks=[%d], Size=[%.3f(Kb)] Comp=[%.2f]\n\t " "Rows=[%"PRIu64"], Blocks=[%"PRId64"], SmallBlocks=[%d], Size=[%.3f(Kb)] Comp=[%.5g]\n\t "
"RowsInMem=[%d] \n\t", "RowsInMem=[%d] \n\t",
percentiles[0], percentiles[1], percentiles[2], percentiles[3], percentiles[4], percentiles[5], percentiles[0], percentiles[1], percentiles[2], percentiles[3], percentiles[4], percentiles[5],
percentiles[6], percentiles[7], percentiles[8], percentiles[9], percentiles[10], percentiles[11], percentiles[6], percentiles[7], percentiles[8], percentiles[9], percentiles[10], percentiles[11],
......
...@@ -478,8 +478,8 @@ static bool chkResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo *p ...@@ -478,8 +478,8 @@ static bool chkResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo *p
existed = (pResultRowInfo->pResult[0] == (*p1)); existed = (pResultRowInfo->pResult[0] == (*p1));
} else { // check if current pResultRowInfo contains the existed pResultRow } else { // check if current pResultRowInfo contains the existed pResultRow
SET_RES_EXT_WINDOW_KEY(pRuntimeEnv->keyBuf, pData, bytes, uid, pResultRowInfo); SET_RES_EXT_WINDOW_KEY(pRuntimeEnv->keyBuf, pData, bytes, uid, pResultRowInfo);
int64_t* index = taosHashGet(pRuntimeEnv->pResultRowListSet, pRuntimeEnv->keyBuf, GET_RES_EXT_WINDOW_KEY_LEN(bytes)); int64_t* qry_index = taosHashGet(pRuntimeEnv->pResultRowListSet, pRuntimeEnv->keyBuf, GET_RES_EXT_WINDOW_KEY_LEN(bytes));
if (index != NULL) { if (qry_index != NULL) {
existed = true; existed = true;
} else { } else {
existed = false; existed = false;
...@@ -517,9 +517,9 @@ static SResultRow* doSetResultOutBufByKey(SQueryRuntimeEnv* pRuntimeEnv, SResult ...@@ -517,9 +517,9 @@ static SResultRow* doSetResultOutBufByKey(SQueryRuntimeEnv* pRuntimeEnv, SResult
pResultRowInfo->curPos = 0; pResultRowInfo->curPos = 0;
} else { // check if current pResultRowInfo contains the existed pResultRow } else { // check if current pResultRowInfo contains the existed pResultRow
SET_RES_EXT_WINDOW_KEY(pRuntimeEnv->keyBuf, pData, bytes, tid, pResultRowInfo); SET_RES_EXT_WINDOW_KEY(pRuntimeEnv->keyBuf, pData, bytes, tid, pResultRowInfo);
int64_t* index = taosHashGet(pRuntimeEnv->pResultRowListSet, pRuntimeEnv->keyBuf, GET_RES_EXT_WINDOW_KEY_LEN(bytes)); int64_t* qry_index = taosHashGet(pRuntimeEnv->pResultRowListSet, pRuntimeEnv->keyBuf, GET_RES_EXT_WINDOW_KEY_LEN(bytes));
if (index != NULL) { if (qry_index != NULL) {
pResultRowInfo->curPos = (int32_t) *index; pResultRowInfo->curPos = (int32_t) *qry_index;
existed = true; existed = true;
} else { } else {
existed = false; existed = false;
...@@ -555,9 +555,9 @@ static SResultRow* doSetResultOutBufByKey(SQueryRuntimeEnv* pRuntimeEnv, SResult ...@@ -555,9 +555,9 @@ static SResultRow* doSetResultOutBufByKey(SQueryRuntimeEnv* pRuntimeEnv, SResult
pResultRowInfo->curPos = pResultRowInfo->size; pResultRowInfo->curPos = pResultRowInfo->size;
pResultRowInfo->pResult[pResultRowInfo->size++] = pResult; pResultRowInfo->pResult[pResultRowInfo->size++] = pResult;
int64_t index = pResultRowInfo->curPos; int64_t qry_index = pResultRowInfo->curPos;
SET_RES_EXT_WINDOW_KEY(pRuntimeEnv->keyBuf, pData, bytes, tid, pResultRowInfo); SET_RES_EXT_WINDOW_KEY(pRuntimeEnv->keyBuf, pData, bytes, tid, pResultRowInfo);
taosHashPut(pRuntimeEnv->pResultRowListSet, pRuntimeEnv->keyBuf, GET_RES_EXT_WINDOW_KEY_LEN(bytes), &index, POINTER_BYTES); taosHashPut(pRuntimeEnv->pResultRowListSet, pRuntimeEnv->keyBuf, GET_RES_EXT_WINDOW_KEY_LEN(bytes), &qry_index, POINTER_BYTES);
} }
// too many time window in query // too many time window in query
...@@ -1166,8 +1166,8 @@ static TSKEY getStartTsKey(SQueryAttr* pQueryAttr, STimeWindow* win, const TSKEY ...@@ -1166,8 +1166,8 @@ static TSKEY getStartTsKey(SQueryAttr* pQueryAttr, STimeWindow* win, const TSKEY
static void setArithParams(SArithmeticSupport* sas, SExprInfo *pExprInfo, SSDataBlock* pSDataBlock) { static void setArithParams(SArithmeticSupport* sas, SExprInfo *pExprInfo, SSDataBlock* pSDataBlock) {
sas->numOfCols = (int32_t) pSDataBlock->info.numOfCols; sas->numOfCols = (int32_t) pSDataBlock->info.numOfCols;
sas->pExprInfo = pExprInfo; sas->pExprInfo = pExprInfo;
if (sas->colList != NULL) { if (sas->colList) {
return; free(sas->colList); // free pre malloc memory
} }
sas->colList = calloc(1, pSDataBlock->info.numOfCols*sizeof(SColumnInfo)); sas->colList = calloc(1, pSDataBlock->info.numOfCols*sizeof(SColumnInfo));
for(int32_t i = 0; i < sas->numOfCols; ++i) { for(int32_t i = 0; i < sas->numOfCols; ++i) {
...@@ -1175,6 +1175,9 @@ static void setArithParams(SArithmeticSupport* sas, SExprInfo *pExprInfo, SSData ...@@ -1175,6 +1175,9 @@ static void setArithParams(SArithmeticSupport* sas, SExprInfo *pExprInfo, SSData
sas->colList[i] = pColData->info; sas->colList[i] = pColData->info;
} }
if(sas->data) {
free(sas->data); // free pre malloc memory
}
sas->data = calloc(sas->numOfCols, POINTER_BYTES); sas->data = calloc(sas->numOfCols, POINTER_BYTES);
// set the input column data // set the input column data
...@@ -1320,14 +1323,14 @@ void doTimeWindowInterpolation(SOperatorInfo* pOperator, SOptrBasicInfo* pInfo, ...@@ -1320,14 +1323,14 @@ void doTimeWindowInterpolation(SOperatorInfo* pOperator, SOptrBasicInfo* pInfo,
} }
SColIndex * pColIndex = &pExpr[k].base.colInfo; SColIndex * pColIndex = &pExpr[k].base.colInfo;
int16_t index = pColIndex->colIndex; int16_t qry_index = pColIndex->colIndex;
SColumnInfoData *pColInfo = taosArrayGet(pDataBlock, index); SColumnInfoData *pColInfo = taosArrayGet(pDataBlock, qry_index);
assert(pColInfo->info.colId == pColIndex->colId && curTs != windowKey); assert(pColInfo->info.colId == pColIndex->colId && curTs != windowKey);
double v1 = 0, v2 = 0, v = 0; double v1 = 0, v2 = 0, v = 0;
if (prevRowIndex == -1) { if (prevRowIndex == -1) {
GET_TYPED_DATA(v1, double, pColInfo->info.type, (char *)pRuntimeEnv->prevRow[index]); GET_TYPED_DATA(v1, double, pColInfo->info.type, (char *)pRuntimeEnv->prevRow[qry_index]);
} else { } else {
GET_TYPED_DATA(v1, double, pColInfo->info.type, (char *)pColInfo->pData + prevRowIndex * pColInfo->info.bytes); GET_TYPED_DATA(v1, double, pColInfo->info.type, (char *)pColInfo->pData + prevRowIndex * pColInfo->info.bytes);
} }
...@@ -1344,7 +1347,7 @@ void doTimeWindowInterpolation(SOperatorInfo* pOperator, SOptrBasicInfo* pInfo, ...@@ -1344,7 +1347,7 @@ void doTimeWindowInterpolation(SOperatorInfo* pOperator, SOptrBasicInfo* pInfo,
if (pColInfo->info.type == TSDB_DATA_TYPE_BINARY || pColInfo->info.type == TSDB_DATA_TYPE_NCHAR) { if (pColInfo->info.type == TSDB_DATA_TYPE_BINARY || pColInfo->info.type == TSDB_DATA_TYPE_NCHAR) {
if (prevRowIndex == -1) { if (prevRowIndex == -1) {
pCtx[k].start.ptr = (char *)pRuntimeEnv->prevRow[index]; pCtx[k].start.ptr = (char *)pRuntimeEnv->prevRow[qry_index];
} else { } else {
pCtx[k].start.ptr = (char *)pColInfo->pData + prevRowIndex * pColInfo->info.bytes; pCtx[k].start.ptr = (char *)pColInfo->pData + prevRowIndex * pColInfo->info.bytes;
} }
...@@ -2779,16 +2782,16 @@ static bool doFilterByBlockStatistics(SQueryRuntimeEnv* pRuntimeEnv, SDataStatis ...@@ -2779,16 +2782,16 @@ static bool doFilterByBlockStatistics(SQueryRuntimeEnv* pRuntimeEnv, SDataStatis
for (int32_t k = 0; k < pQueryAttr->numOfFilterCols; ++k) { for (int32_t k = 0; k < pQueryAttr->numOfFilterCols; ++k) {
SSingleColumnFilterInfo *pFilterInfo = &pQueryAttr->pFilterInfo[k]; SSingleColumnFilterInfo *pFilterInfo = &pQueryAttr->pFilterInfo[k];
int32_t index = -1; int32_t qry_index = -1;
for(int32_t i = 0; i < pQueryAttr->numOfCols; ++i) { for(int32_t i = 0; i < pQueryAttr->numOfCols; ++i) {
if (pDataStatis[i].colId == pFilterInfo->info.colId) { if (pDataStatis[i].colId == pFilterInfo->info.colId) {
index = i; qry_index = i;
break; break;
} }
} }
// no statistics data, load the true data block // no statistics data, load the true data block
if (index == -1) { if (qry_index == -1) {
return true; return true;
} }
...@@ -2798,7 +2801,7 @@ static bool doFilterByBlockStatistics(SQueryRuntimeEnv* pRuntimeEnv, SDataStatis ...@@ -2798,7 +2801,7 @@ static bool doFilterByBlockStatistics(SQueryRuntimeEnv* pRuntimeEnv, SDataStatis
} }
// all data in current column are NULL, no need to check its boundary value // all data in current column are NULL, no need to check its boundary value
if (pDataStatis[index].numOfNull == numOfRows) { if (pDataStatis[qry_index].numOfNull == numOfRows) {
// if isNULL query exists, load the null data column // if isNULL query exists, load the null data column
for (int32_t j = 0; j < pFilterInfo->numOfFilters; ++j) { for (int32_t j = 0; j < pFilterInfo->numOfFilters; ++j) {
...@@ -2811,7 +2814,7 @@ static bool doFilterByBlockStatistics(SQueryRuntimeEnv* pRuntimeEnv, SDataStatis ...@@ -2811,7 +2814,7 @@ static bool doFilterByBlockStatistics(SQueryRuntimeEnv* pRuntimeEnv, SDataStatis
continue; continue;
} }
SDataStatis* pDataBlockst = &pDataStatis[index]; SDataStatis* pDataBlockst = &pDataStatis[qry_index];
if (pFilterInfo->info.type == TSDB_DATA_TYPE_FLOAT) { if (pFilterInfo->info.type == TSDB_DATA_TYPE_FLOAT) {
float minval = (float)(*(double *)(&pDataBlockst->min)); float minval = (float)(*(double *)(&pDataBlockst->min));
...@@ -4593,10 +4596,10 @@ void queryCostStatis(SQInfo *pQInfo) { ...@@ -4593,10 +4596,10 @@ void queryCostStatis(SQInfo *pQInfo) {
// TSKEY key = pTableQueryInfo->win.skey; // TSKEY key = pTableQueryInfo->win.skey;
// //
// pWindowResInfo->prevSKey = tw.skey; // pWindowResInfo->prevSKey = tw.skey;
// int32_t index = pRuntimeEnv->resultRowInfo.curIndex; // int32_t qry_index = pRuntimeEnv->resultRowInfo.curIndex;
// //
// int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, pBlockInfo, NULL, binarySearchForKey, pDataBlock); // int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, pBlockInfo, NULL, binarySearchForKey, pDataBlock);
// pRuntimeEnv->resultRowInfo.curIndex = index; // restore the window index // pRuntimeEnv->resultRowInfo.curIndex = qry_index; // restore the window index
// //
// qDebug("QInfo:0x%"PRIx64" check data block, brange:%" PRId64 "-%" PRId64 ", numOfRows:%d, numOfRes:%d, lastKey:%" PRId64, // qDebug("QInfo:0x%"PRIx64" check data block, brange:%" PRId64 "-%" PRId64 ", numOfRows:%d, numOfRes:%d, lastKey:%" PRId64,
// GET_QID(pRuntimeEnv), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, numOfRes, // GET_QID(pRuntimeEnv), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, numOfRes,
...@@ -5325,15 +5328,15 @@ SArray* getOrderCheckColumns(SQueryAttr* pQuery) { ...@@ -5325,15 +5328,15 @@ SArray* getOrderCheckColumns(SQueryAttr* pQuery) {
{ {
numOfCols = (int32_t) taosArrayGetSize(pOrderColumns); numOfCols = (int32_t) taosArrayGetSize(pOrderColumns);
for(int32_t i = 0; i < numOfCols; ++i) { for(int32_t i = 0; i < numOfCols; ++i) {
SColIndex* index = taosArrayGet(pOrderColumns, i); SColIndex* qry_index = taosArrayGet(pOrderColumns, i);
for(int32_t j = 0; j < pQuery->numOfOutput; ++j) { for(int32_t j = 0; j < pQuery->numOfOutput; ++j) {
SSqlExpr* pExpr = &pQuery->pExpr1[j].base; SSqlExpr* pExpr = &pQuery->pExpr1[j].base;
int32_t functionId = pExpr->functionId; int32_t functionId = pExpr->functionId;
if (index->colId == pExpr->colInfo.colId && if (qry_index->colId == pExpr->colInfo.colId &&
(functionId == TSDB_FUNC_PRJ || functionId == TSDB_FUNC_TAG || functionId == TSDB_FUNC_TS)) { (functionId == TSDB_FUNC_PRJ || functionId == TSDB_FUNC_TAG || functionId == TSDB_FUNC_TS)) {
index->colIndex = j; qry_index->colIndex = j;
index->colId = pExpr->resColId; qry_index->colId = pExpr->resColId;
} }
} }
} }
...@@ -5353,24 +5356,24 @@ SArray* getResultGroupCheckColumns(SQueryAttr* pQuery) { ...@@ -5353,24 +5356,24 @@ SArray* getResultGroupCheckColumns(SQueryAttr* pQuery) {
} }
for(int32_t i = 0; i < numOfCols; ++i) { for(int32_t i = 0; i < numOfCols; ++i) {
SColIndex* index = taosArrayGet(pOrderColumns, i); SColIndex* qry_index = taosArrayGet(pOrderColumns, i);
bool found = false; bool found = false;
for(int32_t j = 0; j < pQuery->numOfOutput; ++j) { for(int32_t j = 0; j < pQuery->numOfOutput; ++j) {
SSqlExpr* pExpr = &pQuery->pExpr1[j].base; SSqlExpr* pExpr = &pQuery->pExpr1[j].base;
// TSDB_FUNC_TAG_DUMMY function needs to be ignored // TSDB_FUNC_TAG_DUMMY function needs to be ignored
if (index->colId == pExpr->colInfo.colId && if (qry_index->colId == pExpr->colInfo.colId &&
((TSDB_COL_IS_TAG(pExpr->colInfo.flag) && ((pExpr->functionId == TSDB_FUNC_TAG) || (pExpr->functionId == TSDB_FUNC_TAGPRJ))) || ((TSDB_COL_IS_TAG(pExpr->colInfo.flag) && ((pExpr->functionId == TSDB_FUNC_TAG) || (pExpr->functionId == TSDB_FUNC_TAGPRJ))) ||
(TSDB_COL_IS_NORMAL_COL(pExpr->colInfo.flag) && pExpr->functionId == TSDB_FUNC_PRJ))) { (TSDB_COL_IS_NORMAL_COL(pExpr->colInfo.flag) && pExpr->functionId == TSDB_FUNC_PRJ))) {
index->colIndex = j; qry_index->colIndex = j;
index->colId = pExpr->resColId; qry_index->colId = pExpr->resColId;
found = true; found = true;
break; break;
} }
} }
assert(found && index->colIndex >= 0 && index->colIndex < pQuery->numOfOutput); assert(found && qry_index->colIndex >= 0 && qry_index->colIndex < pQuery->numOfOutput);
} }
return pOrderColumns; return pOrderColumns;
...@@ -5423,8 +5426,8 @@ SOperatorInfo* createGlobalAggregateOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, ...@@ -5423,8 +5426,8 @@ SOperatorInfo* createGlobalAggregateOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv,
for(int32_t i = 0; i < numOfCols; ++i) { for(int32_t i = 0; i < numOfCols; ++i) {
pInfo->prevRow[i] = (char*)pInfo->prevRow + offset; pInfo->prevRow[i] = (char*)pInfo->prevRow + offset;
SColIndex* index = taosArrayGet(pInfo->orderColumnList, i); SColIndex* qry_index = taosArrayGet(pInfo->orderColumnList, i);
offset += pExpr[index->colIndex].base.resBytes; offset += pExpr[qry_index->colIndex].base.resBytes;
} }
numOfCols = (pInfo->groupColumnList != NULL)? (int32_t)taosArrayGetSize(pInfo->groupColumnList):0; numOfCols = (pInfo->groupColumnList != NULL)? (int32_t)taosArrayGetSize(pInfo->groupColumnList):0;
...@@ -5434,8 +5437,8 @@ SOperatorInfo* createGlobalAggregateOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, ...@@ -5434,8 +5437,8 @@ SOperatorInfo* createGlobalAggregateOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv,
for(int32_t i = 0; i < numOfCols; ++i) { for(int32_t i = 0; i < numOfCols; ++i) {
pInfo->currentGroupColData[i] = (char*)pInfo->currentGroupColData + offset; pInfo->currentGroupColData[i] = (char*)pInfo->currentGroupColData + offset;
SColIndex* index = taosArrayGet(pInfo->groupColumnList, i); SColIndex* qry_index = taosArrayGet(pInfo->groupColumnList, i);
offset += pExpr[index->colIndex].base.resBytes; offset += pExpr[qry_index->colIndex].base.resBytes;
} }
initResultRowInfo(&pInfo->binfo.resultRowInfo, 8, TSDB_DATA_TYPE_INT); initResultRowInfo(&pInfo->binfo.resultRowInfo, 8, TSDB_DATA_TYPE_INT);
...@@ -5482,8 +5485,8 @@ SOperatorInfo *createMultiwaySortOperatorInfo(SQueryRuntimeEnv *pRuntimeEnv, SEx ...@@ -5482,8 +5485,8 @@ SOperatorInfo *createMultiwaySortOperatorInfo(SQueryRuntimeEnv *pRuntimeEnv, SEx
for(int32_t i = 0; i < numOfCols; ++i) { for(int32_t i = 0; i < numOfCols; ++i) {
pInfo->prevRow[i] = (char*)pInfo->prevRow + offset; pInfo->prevRow[i] = (char*)pInfo->prevRow + offset;
SColIndex* index = taosArrayGet(pInfo->orderColumnList, i); SColIndex* qry_index = taosArrayGet(pInfo->orderColumnList, i);
offset += pExpr[index->colIndex].base.colBytes; offset += pExpr[qry_index->colIndex].base.colBytes;
} }
} }
...@@ -7025,8 +7028,8 @@ SOperatorInfo* createSLimitOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperator ...@@ -7025,8 +7028,8 @@ SOperatorInfo* createSLimitOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperator
for(int32_t i = 0; i < numOfCols; ++i) { for(int32_t i = 0; i < numOfCols; ++i) {
pInfo->prevRow[i] = (char*)pInfo->prevRow + offset; pInfo->prevRow[i] = (char*)pInfo->prevRow + offset;
SColIndex* index = taosArrayGet(pInfo->orderColumnList, i); SColIndex* qry_index = taosArrayGet(pInfo->orderColumnList, i);
offset += pExpr[index->colIndex].base.resBytes; offset += pExpr[qry_index->colIndex].base.resBytes;
} }
pInfo->pRes = createOutputBuf(pExpr, numOfOutput, pRuntimeEnv->resultInfo.capacity); pInfo->pRes = createOutputBuf(pExpr, numOfOutput, pRuntimeEnv->resultInfo.capacity);
...@@ -8206,11 +8209,11 @@ int32_t createIndirectQueryFuncExprFromMsg(SQueryTableMsg* pQueryMsg, int32_t nu ...@@ -8206,11 +8209,11 @@ int32_t createIndirectQueryFuncExprFromMsg(SQueryTableMsg* pQueryMsg, int32_t nu
type = TSDB_DATA_TYPE_DOUBLE; type = TSDB_DATA_TYPE_DOUBLE;
bytes = tDataTypes[type].bytes; bytes = tDataTypes[type].bytes;
} else { } else {
int32_t index = pExprs[i].base.colInfo.colIndex; int32_t qry_index = pExprs[i].base.colInfo.colIndex;
assert(prevExpr[index].base.resColId == pExprs[i].base.colInfo.colId); assert(prevExpr[qry_index].base.resColId == pExprs[i].base.colInfo.colId);
type = prevExpr[index].base.resType; type = prevExpr[qry_index].base.resType;
bytes = prevExpr[index].base.resBytes; bytes = prevExpr[qry_index].base.resBytes;
} }
int32_t param = (int32_t)pExprs[i].base.param[0].i64; int32_t param = (int32_t)pExprs[i].base.param[0].i64;
...@@ -8541,7 +8544,7 @@ SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SGroupbyExpr* pGroupbyExpr, S ...@@ -8541,7 +8544,7 @@ SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SGroupbyExpr* pGroupbyExpr, S
SQueryRuntimeEnv* pRuntimeEnv = &pQInfo->runtimeEnv; SQueryRuntimeEnv* pRuntimeEnv = &pQInfo->runtimeEnv;
STimeWindow window = pQueryAttr->window; STimeWindow window = pQueryAttr->window;
int32_t index = 0; int32_t qry_index = 0;
for(int32_t i = 0; i < numOfGroups; ++i) { for(int32_t i = 0; i < numOfGroups; ++i) {
SArray* pa = taosArrayGetP(pQueryAttr->tableGroupInfo.pGroupList, i); SArray* pa = taosArrayGetP(pQueryAttr->tableGroupInfo.pGroupList, i);
...@@ -8557,7 +8560,7 @@ SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SGroupbyExpr* pGroupbyExpr, S ...@@ -8557,7 +8560,7 @@ SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SGroupbyExpr* pGroupbyExpr, S
STableKeyInfo* info = taosArrayGet(pa, j); STableKeyInfo* info = taosArrayGet(pa, j);
window.skey = info->lastKey; window.skey = info->lastKey;
void* buf = (char*) pQInfo->pBuf + index * sizeof(STableQueryInfo); void* buf = (char*) pQInfo->pBuf + qry_index * sizeof(STableQueryInfo);
STableQueryInfo* item = createTableQueryInfo(pQueryAttr, info->pTable, pQueryAttr->groupbyColumn, window, buf); STableQueryInfo* item = createTableQueryInfo(pQueryAttr, info->pTable, pQueryAttr->groupbyColumn, window, buf);
if (item == NULL) { if (item == NULL) {
goto _cleanup; goto _cleanup;
...@@ -8568,7 +8571,7 @@ SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SGroupbyExpr* pGroupbyExpr, S ...@@ -8568,7 +8571,7 @@ SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SGroupbyExpr* pGroupbyExpr, S
STableId* id = TSDB_TABLEID(info->pTable); STableId* id = TSDB_TABLEID(info->pTable);
taosHashPut(pRuntimeEnv->tableqinfoGroupInfo.map, &id->tid, sizeof(id->tid), &item, POINTER_BYTES); taosHashPut(pRuntimeEnv->tableqinfoGroupInfo.map, &id->tid, sizeof(id->tid), &item, POINTER_BYTES);
index += 1; qry_index += 1;
} }
} }
......
...@@ -448,9 +448,9 @@ int32_t compare_a(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1, ...@@ -448,9 +448,9 @@ int32_t compare_a(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1,
int32_t compare_aRv(SSDataBlock* pBlock, SArray* colIndex, int32_t numOfCols, int32_t rowIndex, char** buffer, int32_t order) { int32_t compare_aRv(SSDataBlock* pBlock, SArray* colIndex, int32_t numOfCols, int32_t rowIndex, char** buffer, int32_t order) {
for (int32_t i = 0; i < numOfCols; ++i) { for (int32_t i = 0; i < numOfCols; ++i) {
SColIndex* pColIndex = taosArrayGet(colIndex, i); SColIndex* pColIndex = taosArrayGet(colIndex, i);
int32_t index = pColIndex->colIndex; int32_t qry_index = pColIndex->colIndex;
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, index); SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, qry_index);
assert(pColIndex->colId == pColInfo->info.colId); assert(pColIndex->colId == pColInfo->info.colId);
char* data = pColInfo->pData + rowIndex * pColInfo->info.bytes; char* data = pColInfo->pData + rowIndex * pColInfo->info.bytes;
...@@ -1022,14 +1022,14 @@ void tColModelCompact(SColumnModel *pModel, tFilePage *inputBuffer, int32_t maxE ...@@ -1022,14 +1022,14 @@ void tColModelCompact(SColumnModel *pModel, tFilePage *inputBuffer, int32_t maxE
} }
} }
SSchema* getColumnModelSchema(SColumnModel *pColumnModel, int32_t index) { SSchema* getColumnModelSchema(SColumnModel *pColumnModel, int32_t qry_index) {
assert(pColumnModel != NULL && index >= 0 && index < pColumnModel->numOfCols); assert(pColumnModel != NULL && qry_index >= 0 && qry_index < pColumnModel->numOfCols);
return &pColumnModel->pFields[index].field; return &pColumnModel->pFields[qry_index].field;
} }
int16_t getColumnModelOffset(SColumnModel *pColumnModel, int32_t index) { int16_t getColumnModelOffset(SColumnModel *pColumnModel, int32_t qry_index) {
assert(pColumnModel != NULL && index >= 0 && index < pColumnModel->numOfCols); assert(pColumnModel != NULL && qry_index >= 0 && qry_index < pColumnModel->numOfCols);
return pColumnModel->pFields[index].offset; return pColumnModel->pFields[qry_index].offset;
} }
void tColModelErase(SColumnModel *pModel, tFilePage *inputBuffer, int32_t blockCapacity, int32_t s, int32_t e) { void tColModelErase(SColumnModel *pModel, tFilePage *inputBuffer, int32_t blockCapacity, int32_t s, int32_t e) {
...@@ -1103,17 +1103,17 @@ void tOrderDescDestroy(tOrderDescriptor *pDesc) { ...@@ -1103,17 +1103,17 @@ void tOrderDescDestroy(tOrderDescriptor *pDesc) {
tfree(pDesc); tfree(pDesc);
} }
void taoscQSort(void** pCols, SSchema* pSchema, int32_t numOfCols, int32_t numOfRows, int32_t index, __compar_fn_t compareFn) { void taoscQSort(void** pCols, SSchema* pSchema, int32_t numOfCols, int32_t numOfRows, int32_t qry_index, __compar_fn_t compareFn) {
assert(numOfRows > 0 && numOfCols > 0 && index >= 0 && index < numOfCols); assert(numOfRows > 0 && numOfCols > 0 && qry_index >= 0 && qry_index < numOfCols);
int32_t bytes = pSchema[index].bytes; int32_t bytes = pSchema[qry_index].bytes;
int32_t size = bytes + sizeof(int32_t); int32_t size = bytes + sizeof(int32_t);
char* buf = calloc(1, size * numOfRows); char* buf = calloc(1, size * numOfRows);
for(int32_t i = 0; i < numOfRows; ++i) { for(int32_t i = 0; i < numOfRows; ++i) {
char* dest = buf + size * i; char* dest = buf + size * i;
memcpy(dest, ((char*) pCols[index]) + bytes * i, bytes); memcpy(dest, ((char*) pCols[qry_index]) + bytes * i, bytes);
*(int32_t*)(dest+bytes) = i; *(int32_t*)(dest+bytes) = i;
} }
...@@ -1125,7 +1125,7 @@ void taoscQSort(void** pCols, SSchema* pSchema, int32_t numOfCols, int32_t numOf ...@@ -1125,7 +1125,7 @@ void taoscQSort(void** pCols, SSchema* pSchema, int32_t numOfCols, int32_t numOf
for(int32_t i = 0; i < numOfCols; ++i) { for(int32_t i = 0; i < numOfCols; ++i) {
int32_t bytes1 = pSchema[i].bytes; int32_t bytes1 = pSchema[i].bytes;
if (i == index) { if (i == qry_index) {
for(int32_t j = 0; j < numOfRows; ++j){ for(int32_t j = 0; j < numOfRows; ++j){
char* src = buf + (j * size); char* src = buf + (j * size);
char* dest = ((char*)pCols[i]) + (j * bytes1); char* dest = ((char*)pCols[i]) + (j * bytes1);
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册