Merge remote-tracking branch 'origin/3.0' into feature/qnode
This commit is contained in:
commit
d04c0bc436
|
@ -1,5 +1,15 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
if (NOT DEFINED TD_GRANT)
|
||||
SET(TD_GRANT FALSE)
|
||||
endif()
|
||||
if (NOT DEFINED TD_USB_DONGLE)
|
||||
SET(TD_USB_DONGLE FALSE)
|
||||
endif()
|
||||
IF (TD_GRANT)
|
||||
ADD_DEFINITIONS(-D_GRANT)
|
||||
ENDIF ()
|
||||
|
||||
IF ("${BUILD_TOOLS}" STREQUAL "")
|
||||
IF (TD_LINUX)
|
||||
IF (TD_ARM_32)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
add_executable(tmq "")
|
||||
add_executable(tstream "")
|
||||
add_executable(demoapi "")
|
||||
|
||||
target_sources(tmq
|
||||
PRIVATE
|
||||
|
@ -10,6 +11,12 @@ target_sources(tstream
|
|||
PRIVATE
|
||||
"src/tstream.c"
|
||||
)
|
||||
|
||||
target_sources(demoapi
|
||||
PRIVATE
|
||||
"src/demoapi.c"
|
||||
)
|
||||
|
||||
target_link_libraries(tmq
|
||||
taos
|
||||
)
|
||||
|
@ -18,6 +25,10 @@ target_link_libraries(tstream
|
|||
taos
|
||||
)
|
||||
|
||||
target_link_libraries(demoapi
|
||||
taos
|
||||
)
|
||||
|
||||
target_include_directories(tmq
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
|
@ -26,5 +37,11 @@ target_include_directories(tstream
|
|||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
|
||||
target_include_directories(demoapi
|
||||
PUBLIC "${TD_SOURCE_DIR}/include/client"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
|
||||
SET_TARGET_PROPERTIES(tmq PROPERTIES OUTPUT_NAME tmq)
|
||||
SET_TARGET_PROPERTIES(tstream PROPERTIES OUTPUT_NAME tstream)
|
||||
SET_TARGET_PROPERTIES(demoapi PROPERTIES OUTPUT_NAME demoapi)
|
||||
|
|
|
@ -0,0 +1,197 @@
|
|||
// C api call sequence demo
|
||||
// to compile: gcc -o apidemo apidemo.c -ltaos
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <inttypes.h>
|
||||
#include <argp.h>
|
||||
|
||||
#include "taos.h"
|
||||
|
||||
#define debugPrint(fmt, ...) \
|
||||
do { if (g_args.debug_print || g_args.verbose_print) \
|
||||
fprintf(stdout, "DEBG: "fmt, __VA_ARGS__); } while(0)
|
||||
|
||||
#define warnPrint(fmt, ...) \
|
||||
do { fprintf(stderr, "\033[33m"); \
|
||||
fprintf(stderr, "WARN: "fmt, __VA_ARGS__); \
|
||||
fprintf(stderr, "\033[0m"); } while(0)
|
||||
|
||||
#define errorPrint(fmt, ...) \
|
||||
do { fprintf(stderr, "\033[31m"); \
|
||||
fprintf(stderr, "ERROR: "fmt, __VA_ARGS__); \
|
||||
fprintf(stderr, "\033[0m"); } while(0)
|
||||
|
||||
#define okPrint(fmt, ...) \
|
||||
do { fprintf(stderr, "\033[32m"); \
|
||||
fprintf(stderr, "OK: "fmt, __VA_ARGS__); \
|
||||
fprintf(stderr, "\033[0m"); } while(0)
|
||||
|
||||
int64_t g_num_of_tb = 2;
|
||||
int64_t g_num_of_rec = 2;
|
||||
|
||||
static struct argp_option options[] = {
|
||||
{"tables", 't', "NUMBER", 0, "Number of child tables, default is 10000."},
|
||||
{"records", 'n', "NUMBER", 0,
|
||||
"Number of records for each table, default is 10000."},
|
||||
{0}};
|
||||
|
||||
static error_t parse_opt(int key, char *arg, struct argp_state *state) {
|
||||
switch (key) {
|
||||
case 't':
|
||||
g_num_of_tb = atoll(arg);
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
g_num_of_rec = atoll(arg);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct argp argp = {options, parse_opt, "", ""};
|
||||
|
||||
static void prepare_data(TAOS* taos) {
|
||||
TAOS_RES *res;
|
||||
res = taos_query(taos, "drop database if exists test;");
|
||||
taos_free_result(res);
|
||||
usleep(100000);
|
||||
|
||||
res = taos_query(taos, "create database test;");
|
||||
taos_free_result(res);
|
||||
usleep(100000);
|
||||
taos_select_db(taos, "test");
|
||||
|
||||
res = taos_query(taos, "create table meters(ts timestamp, f float, n int, b binary(20)) tags(area int, localtion binary(20));");
|
||||
taos_free_result(res);
|
||||
|
||||
char command[1024] = {0};
|
||||
for (int64_t i = 0; i < g_num_of_tb; i ++) {
|
||||
sprintf(command, "create table t%"PRId64" using meters tags(%"PRId64", '%s');",
|
||||
i, i, (i%2)?"beijing":"shanghai");
|
||||
res = taos_query(taos, command);
|
||||
taos_free_result(res);
|
||||
|
||||
int64_t j = 0;
|
||||
int64_t total = 0;
|
||||
int64_t affected;
|
||||
for (; j < g_num_of_rec -1; j ++) {
|
||||
sprintf(command, "insert into t%"PRId64" values(%" PRId64 ", %f, %"PRId64", '%c%d')",
|
||||
i, 1650000000000+j, (float)j, j, 'a'+(int)j%10, rand());
|
||||
res = taos_query(taos, command);
|
||||
if ((res) && (0 == taos_errno(res))) {
|
||||
affected = taos_affected_rows(res);
|
||||
total += affected;
|
||||
} else {
|
||||
errorPrint("%s() LN%d: %s\n",
|
||||
__func__, __LINE__, taos_errstr(res));
|
||||
}
|
||||
taos_free_result(res);
|
||||
}
|
||||
sprintf(command, "insert into t%"PRId64" values(%" PRId64 ", NULL, NULL, NULL)",
|
||||
i, 1650000000000+j+1);
|
||||
res = taos_query(taos, command);
|
||||
if ((res) && (0 == taos_errno(res))) {
|
||||
affected = taos_affected_rows(res);
|
||||
total += affected;
|
||||
} else {
|
||||
errorPrint("%s() LN%d: %s\n",
|
||||
__func__, __LINE__, taos_errstr(res));
|
||||
}
|
||||
taos_free_result(res);
|
||||
|
||||
printf("insert %"PRId64" records into t%"PRId64", total affected rows: %"PRId64"\n", j, i, total);
|
||||
}
|
||||
}
|
||||
|
||||
static int print_result(TAOS_RES* res, int block) {
|
||||
int64_t num_rows = 0;
|
||||
TAOS_ROW row = NULL;
|
||||
int num_fields = taos_num_fields(res);
|
||||
TAOS_FIELD* fields = taos_fetch_fields(res);
|
||||
|
||||
if (block) {
|
||||
warnPrint("%s() LN%d, call taos_fetch_block()\n", __func__, __LINE__);
|
||||
int rows = 0;
|
||||
while ((rows = taos_fetch_block(res, &row))) {
|
||||
num_rows += rows;
|
||||
}
|
||||
} else {
|
||||
warnPrint("%s() LN%d, call taos_fetch_rows()\n", __func__, __LINE__);
|
||||
while ((row = taos_fetch_row(res))) {
|
||||
char temp[256] = {0};
|
||||
taos_print_row(temp, row, fields, num_fields);
|
||||
puts(temp);
|
||||
num_rows ++;
|
||||
}
|
||||
}
|
||||
|
||||
return num_rows;
|
||||
}
|
||||
|
||||
static void verify_query(TAOS* taos) {
|
||||
// TODO: select count(tbname) from stable once stable query work
|
||||
char command[1024] = {0};
|
||||
|
||||
for (int64_t i = 0; i < g_num_of_tb; i++) {
|
||||
sprintf(command, "select * from t%"PRId64"", i);
|
||||
TAOS_RES* res = taos_query(taos, command);
|
||||
|
||||
if (res) {
|
||||
if (0 == taos_errno(res)) {
|
||||
int field_count = taos_field_count(res);
|
||||
printf("field_count: %d\n", field_count);
|
||||
int* lengths = taos_fetch_lengths(res);
|
||||
if (lengths) {
|
||||
for (int c = 0; c < field_count; c++) {
|
||||
printf("length of column %d is %d\n", c, lengths[c]);
|
||||
}
|
||||
} else {
|
||||
errorPrint("%s() LN%d: t%"PRId64"'s lengths is NULL\n",
|
||||
__func__, __LINE__, i);
|
||||
}
|
||||
|
||||
int64_t rows = print_result(res, i % 2);
|
||||
printf("rows is: %"PRId64"\n", rows);
|
||||
|
||||
} else {
|
||||
errorPrint("%s() LN%d: %s\n",
|
||||
__func__, __LINE__, taos_errstr(res));
|
||||
}
|
||||
} else {
|
||||
errorPrint("%s() LN%d: %s\n",
|
||||
__func__, __LINE__, taos_errstr(res));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
const char* host = "127.0.0.1";
|
||||
const char* user = "root";
|
||||
const char* passwd = "taosdata";
|
||||
|
||||
argp_parse(&argp, argc, argv, 0, 0, NULL);
|
||||
TAOS* taos = taos_connect(host, user, passwd, "", 0);
|
||||
if (taos == NULL) {
|
||||
printf("\033[31mfailed to connect to db, reason:%s\033[0m\n", taos_errstr(taos));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
const char* info = taos_get_server_info(taos);
|
||||
printf("server info: %s\n", info);
|
||||
info = taos_get_client_info(taos);
|
||||
printf("client info: %s\n", info);
|
||||
|
||||
prepare_data(taos);
|
||||
|
||||
verify_query(taos);
|
||||
|
||||
taos_close(taos);
|
||||
printf("done\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2034,6 +2034,7 @@ typedef struct {
|
|||
static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema) {
|
||||
int32_t tlen = 0;
|
||||
tlen += taosEncodeFixedI8(buf, pSchema->type);
|
||||
tlen += taosEncodeFixedI8(buf, pSchema->index);
|
||||
tlen += taosEncodeFixedI32(buf, pSchema->bytes);
|
||||
tlen += taosEncodeFixedI16(buf, pSchema->colId);
|
||||
tlen += taosEncodeString(buf, pSchema->name);
|
||||
|
@ -2042,6 +2043,7 @@ static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema
|
|||
|
||||
static FORCE_INLINE void* taosDecodeSSchema(void* buf, SSchema* pSchema) {
|
||||
buf = taosDecodeFixedI8(buf, &pSchema->type);
|
||||
buf = taosDecodeFixedI8(buf, &pSchema->index);
|
||||
buf = taosDecodeFixedI32(buf, &pSchema->bytes);
|
||||
buf = taosDecodeFixedI16(buf, &pSchema->colId);
|
||||
buf = taosDecodeStringTo(buf, pSchema->name);
|
||||
|
@ -2050,6 +2052,7 @@ static FORCE_INLINE void* taosDecodeSSchema(void* buf, SSchema* pSchema) {
|
|||
|
||||
static FORCE_INLINE int32_t tEncodeSSchema(SCoder* pEncoder, const SSchema* pSchema) {
|
||||
if (tEncodeI8(pEncoder, pSchema->type) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pSchema->index) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pSchema->bytes) < 0) return -1;
|
||||
if (tEncodeI16(pEncoder, pSchema->colId) < 0) return -1;
|
||||
if (tEncodeCStr(pEncoder, pSchema->name) < 0) return -1;
|
||||
|
@ -2058,6 +2061,7 @@ static FORCE_INLINE int32_t tEncodeSSchema(SCoder* pEncoder, const SSchema* pSch
|
|||
|
||||
static FORCE_INLINE int32_t tDecodeSSchema(SCoder* pDecoder, SSchema* pSchema) {
|
||||
if (tDecodeI8(pDecoder, &pSchema->type) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pSchema->index) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pSchema->bytes) < 0) return -1;
|
||||
if (tDecodeI16(pDecoder, &pSchema->colId) < 0) return -1;
|
||||
if (tDecodeCStrTo(pDecoder, pSchema->name) < 0) return -1;
|
||||
|
|
|
@ -140,88 +140,89 @@
|
|||
#define TK_APPS 122
|
||||
#define TK_CONNECTIONS 123
|
||||
#define TK_LICENCE 124
|
||||
#define TK_QUERIES 125
|
||||
#define TK_SCORES 126
|
||||
#define TK_TOPICS 127
|
||||
#define TK_VARIABLES 128
|
||||
#define TK_BNODES 129
|
||||
#define TK_SNODES 130
|
||||
#define TK_LIKE 131
|
||||
#define TK_INDEX 132
|
||||
#define TK_FULLTEXT 133
|
||||
#define TK_FUNCTION 134
|
||||
#define TK_INTERVAL 135
|
||||
#define TK_TOPIC 136
|
||||
#define TK_AS 137
|
||||
#define TK_DESC 138
|
||||
#define TK_DESCRIBE 139
|
||||
#define TK_RESET 140
|
||||
#define TK_QUERY 141
|
||||
#define TK_EXPLAIN 142
|
||||
#define TK_ANALYZE 143
|
||||
#define TK_VERBOSE 144
|
||||
#define TK_NK_BOOL 145
|
||||
#define TK_RATIO 146
|
||||
#define TK_COMPACT 147
|
||||
#define TK_VNODES 148
|
||||
#define TK_IN 149
|
||||
#define TK_OUTPUTTYPE 150
|
||||
#define TK_AGGREGATE 151
|
||||
#define TK_BUFSIZE 152
|
||||
#define TK_STREAM 153
|
||||
#define TK_INTO 154
|
||||
#define TK_KILL 155
|
||||
#define TK_CONNECTION 156
|
||||
#define TK_MERGE 157
|
||||
#define TK_VGROUP 158
|
||||
#define TK_REDISTRIBUTE 159
|
||||
#define TK_SPLIT 160
|
||||
#define TK_SYNCDB 161
|
||||
#define TK_NULL 162
|
||||
#define TK_FIRST 163
|
||||
#define TK_LAST 164
|
||||
#define TK_NOW 165
|
||||
#define TK_ROWTS 166
|
||||
#define TK_TBNAME 167
|
||||
#define TK_QSTARTTS 168
|
||||
#define TK_QENDTS 169
|
||||
#define TK_WSTARTTS 170
|
||||
#define TK_WENDTS 171
|
||||
#define TK_WDURATION 172
|
||||
#define TK_BETWEEN 173
|
||||
#define TK_IS 174
|
||||
#define TK_NK_LT 175
|
||||
#define TK_NK_GT 176
|
||||
#define TK_NK_LE 177
|
||||
#define TK_NK_GE 178
|
||||
#define TK_NK_NE 179
|
||||
#define TK_MATCH 180
|
||||
#define TK_NMATCH 181
|
||||
#define TK_JOIN 182
|
||||
#define TK_INNER 183
|
||||
#define TK_SELECT 184
|
||||
#define TK_DISTINCT 185
|
||||
#define TK_WHERE 186
|
||||
#define TK_PARTITION 187
|
||||
#define TK_BY 188
|
||||
#define TK_SESSION 189
|
||||
#define TK_STATE_WINDOW 190
|
||||
#define TK_SLIDING 191
|
||||
#define TK_FILL 192
|
||||
#define TK_VALUE 193
|
||||
#define TK_NONE 194
|
||||
#define TK_PREV 195
|
||||
#define TK_LINEAR 196
|
||||
#define TK_NEXT 197
|
||||
#define TK_GROUP 198
|
||||
#define TK_HAVING 199
|
||||
#define TK_ORDER 200
|
||||
#define TK_SLIMIT 201
|
||||
#define TK_SOFFSET 202
|
||||
#define TK_LIMIT 203
|
||||
#define TK_OFFSET 204
|
||||
#define TK_ASC 205
|
||||
#define TK_NULLS 206
|
||||
#define TK_GRANTS 125
|
||||
#define TK_QUERIES 126
|
||||
#define TK_SCORES 127
|
||||
#define TK_TOPICS 128
|
||||
#define TK_VARIABLES 129
|
||||
#define TK_BNODES 130
|
||||
#define TK_SNODES 131
|
||||
#define TK_LIKE 132
|
||||
#define TK_INDEX 133
|
||||
#define TK_FULLTEXT 134
|
||||
#define TK_FUNCTION 135
|
||||
#define TK_INTERVAL 136
|
||||
#define TK_TOPIC 137
|
||||
#define TK_AS 138
|
||||
#define TK_DESC 139
|
||||
#define TK_DESCRIBE 140
|
||||
#define TK_RESET 141
|
||||
#define TK_QUERY 142
|
||||
#define TK_EXPLAIN 143
|
||||
#define TK_ANALYZE 144
|
||||
#define TK_VERBOSE 145
|
||||
#define TK_NK_BOOL 146
|
||||
#define TK_RATIO 147
|
||||
#define TK_COMPACT 148
|
||||
#define TK_VNODES 149
|
||||
#define TK_IN 150
|
||||
#define TK_OUTPUTTYPE 151
|
||||
#define TK_AGGREGATE 152
|
||||
#define TK_BUFSIZE 153
|
||||
#define TK_STREAM 154
|
||||
#define TK_INTO 155
|
||||
#define TK_KILL 156
|
||||
#define TK_CONNECTION 157
|
||||
#define TK_MERGE 158
|
||||
#define TK_VGROUP 159
|
||||
#define TK_REDISTRIBUTE 160
|
||||
#define TK_SPLIT 161
|
||||
#define TK_SYNCDB 162
|
||||
#define TK_NULL 163
|
||||
#define TK_FIRST 164
|
||||
#define TK_LAST 165
|
||||
#define TK_NOW 166
|
||||
#define TK_ROWTS 167
|
||||
#define TK_TBNAME 168
|
||||
#define TK_QSTARTTS 169
|
||||
#define TK_QENDTS 170
|
||||
#define TK_WSTARTTS 171
|
||||
#define TK_WENDTS 172
|
||||
#define TK_WDURATION 173
|
||||
#define TK_BETWEEN 174
|
||||
#define TK_IS 175
|
||||
#define TK_NK_LT 176
|
||||
#define TK_NK_GT 177
|
||||
#define TK_NK_LE 178
|
||||
#define TK_NK_GE 179
|
||||
#define TK_NK_NE 180
|
||||
#define TK_MATCH 181
|
||||
#define TK_NMATCH 182
|
||||
#define TK_JOIN 183
|
||||
#define TK_INNER 184
|
||||
#define TK_SELECT 185
|
||||
#define TK_DISTINCT 186
|
||||
#define TK_WHERE 187
|
||||
#define TK_PARTITION 188
|
||||
#define TK_BY 189
|
||||
#define TK_SESSION 190
|
||||
#define TK_STATE_WINDOW 191
|
||||
#define TK_SLIDING 192
|
||||
#define TK_FILL 193
|
||||
#define TK_VALUE 194
|
||||
#define TK_NONE 195
|
||||
#define TK_PREV 196
|
||||
#define TK_LINEAR 197
|
||||
#define TK_NEXT 198
|
||||
#define TK_GROUP 199
|
||||
#define TK_HAVING 200
|
||||
#define TK_ORDER 201
|
||||
#define TK_SLIMIT 202
|
||||
#define TK_SOFFSET 203
|
||||
#define TK_LIMIT 204
|
||||
#define TK_OFFSET 205
|
||||
#define TK_ASC 206
|
||||
#define TK_NULLS 207
|
||||
|
||||
#define TK_NK_SPACE 300
|
||||
#define TK_NK_COMMENT 301
|
||||
|
|
|
@ -73,6 +73,9 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
|
|||
/* Conversion functions */
|
||||
int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
|
||||
/* Time related functions */
|
||||
int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
|
||||
bool getTimePseudoFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
|
||||
int32_t winStartTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
|
|
|
@ -38,6 +38,7 @@ typedef struct TdDirEntry *TdDirEntryPtr;
|
|||
void taosRemoveDir(const char *dirname);
|
||||
bool taosDirExist(char *dirname);
|
||||
int32_t taosMkDir(const char *dirname);
|
||||
int32_t taosMulMkDir(const char *dirname);
|
||||
void taosRemoveOldFiles(const char *dirname, int32_t keepDays);
|
||||
int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen);
|
||||
int32_t taosRealPath(char *dirname, int32_t maxlen);
|
||||
|
|
|
@ -94,6 +94,11 @@ extern const int32_t TYPE_BYTES[15];
|
|||
#define TSDB_TIME_PRECISION_MICRO_STR "us"
|
||||
#define TSDB_TIME_PRECISION_NANO_STR "ns"
|
||||
|
||||
#define TSDB_TIME_PRECISION_SEC_DIGITS 10
|
||||
#define TSDB_TIME_PRECISION_MILLI_DIGITS 13
|
||||
#define TSDB_TIME_PRECISION_MICRO_DIGITS 16
|
||||
#define TSDB_TIME_PRECISION_NANO_DIGITS 19
|
||||
|
||||
#define TSDB_INFORMATION_SCHEMA_DB "information_schema"
|
||||
#define TSDB_INS_TABLE_DNODES "dnodes"
|
||||
#define TSDB_INS_TABLE_MNODES "mnodes"
|
||||
|
|
|
@ -616,7 +616,7 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
|
|||
|
||||
taosSetAllDebugFlag(cfgGetItem(pCfg, "debugFlag")->i32);
|
||||
|
||||
if (taosMkDir(tsLogDir) != 0) {
|
||||
if (taosMulMkDir(tsLogDir) != 0) {
|
||||
uError("failed to create dir:%s since %s", tsLogDir, terrstr());
|
||||
cfgCleanup(pCfg);
|
||||
return -1;
|
||||
|
|
|
@ -23,6 +23,14 @@ target_include_directories(
|
|||
)
|
||||
target_link_libraries(taosd dnode)
|
||||
|
||||
IF (TD_GRANT)
|
||||
TARGET_LINK_LIBRARIES(taosd grant)
|
||||
ENDIF ()
|
||||
IF (TD_USB_DONGLE)
|
||||
TARGET_LINK_LIBRARIES(taosd usb_dongle)
|
||||
else()
|
||||
ENDIF ()
|
||||
|
||||
if(${BUILD_TEST})
|
||||
add_subdirectory(test)
|
||||
endif(${BUILD_TEST})
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "dndInt.h"
|
||||
#include "tconfig.h"
|
||||
#include "tgrant.h"
|
||||
|
||||
static struct {
|
||||
bool dumpConfig;
|
||||
|
@ -90,8 +91,7 @@ static int32_t dndParseArgs(int32_t argc, char const *argv[]) {
|
|||
}
|
||||
|
||||
static void dndGenerateGrant() {
|
||||
// grantParseParameter();
|
||||
printf("this feature is not implemented yet\n");
|
||||
grantParseParameter();
|
||||
}
|
||||
|
||||
static void dndPrintVersion() {
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#ifndef _GRANT
|
||||
#include "os.h"
|
||||
#include "taoserror.h"
|
||||
#include "tgrant.h"
|
||||
#include "mndInt.h"
|
||||
|
||||
int32_t grantInit() { return TSDB_CODE_SUCCESS; }
|
||||
void grantCleanUp() {}
|
||||
void grantParseParameter() { mError("can't parsed parameter k"); }
|
||||
int32_t grantCheck(EGrantType grant) { return TSDB_CODE_SUCCESS; }
|
||||
void grantReset(EGrantType grant, uint64_t value) {}
|
||||
void grantAdd(EGrantType grant, uint64_t value) {}
|
||||
void grantRestore(EGrantType grant, uint64_t value) {}
|
||||
|
||||
#endif
|
|
@ -25,18 +25,18 @@ typedef struct SPoolMem {
|
|||
static SPoolMem *openPool();
|
||||
static void clearPool(SPoolMem *pPool);
|
||||
static void closePool(SPoolMem *pPool);
|
||||
static void *poolMalloc(void *arg, size_t size);
|
||||
static void * poolMalloc(void *arg, size_t size);
|
||||
static void poolFree(void *arg, void *ptr);
|
||||
|
||||
struct SMetaDB {
|
||||
TXN txn;
|
||||
TENV *pEnv;
|
||||
TDB *pTbDB;
|
||||
TDB *pSchemaDB;
|
||||
TDB *pNameIdx;
|
||||
TDB *pStbIdx;
|
||||
TDB *pNtbIdx;
|
||||
TDB *pCtbIdx;
|
||||
TENV * pEnv;
|
||||
TDB * pTbDB;
|
||||
TDB * pSchemaDB;
|
||||
TDB * pNameIdx;
|
||||
TDB * pStbIdx;
|
||||
TDB * pNtbIdx;
|
||||
TDB * pCtbIdx;
|
||||
SPoolMem *pPool;
|
||||
};
|
||||
|
||||
|
@ -46,7 +46,7 @@ typedef struct __attribute__((__packed__)) {
|
|||
} SSchemaDbKey;
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
char * name;
|
||||
tb_uid_t uid;
|
||||
} SNameIdxKey;
|
||||
|
||||
|
@ -205,14 +205,14 @@ void metaCloseDB(SMeta *pMeta) {
|
|||
|
||||
int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg) {
|
||||
tb_uid_t uid;
|
||||
SMetaDB *pMetaDb;
|
||||
void *pKey;
|
||||
void *pVal;
|
||||
SMetaDB * pMetaDb;
|
||||
void * pKey;
|
||||
void * pVal;
|
||||
int kLen;
|
||||
int vLen;
|
||||
int ret;
|
||||
char buf[512];
|
||||
void *pBuf;
|
||||
void * pBuf;
|
||||
SCtbIdxKey ctbIdxKey;
|
||||
SSchemaDbKey schemaDbKey;
|
||||
SSchemaWrapper schemaWrapper;
|
||||
|
@ -329,11 +329,11 @@ int metaRemoveTableFromDb(SMeta *pMeta, tb_uid_t uid) {
|
|||
STbCfg *metaGetTbInfoByUid(SMeta *pMeta, tb_uid_t uid) {
|
||||
int ret;
|
||||
SMetaDB *pMetaDb = pMeta->pDB;
|
||||
void *pKey;
|
||||
void *pVal;
|
||||
void * pKey;
|
||||
void * pVal;
|
||||
int kLen;
|
||||
int vLen;
|
||||
STbCfg *pTbCfg;
|
||||
STbCfg * pTbCfg;
|
||||
|
||||
// Fetch
|
||||
pKey = &uid;
|
||||
|
@ -385,14 +385,14 @@ SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, boo
|
|||
}
|
||||
|
||||
static SSchemaWrapper *metaGetTableSchemaImpl(SMeta *pMeta, tb_uid_t uid, int32_t sver, bool isinline, bool isGetEx) {
|
||||
void *pKey;
|
||||
void *pVal;
|
||||
void * pKey;
|
||||
void * pVal;
|
||||
int kLen;
|
||||
int vLen;
|
||||
int ret;
|
||||
SSchemaDbKey schemaDbKey;
|
||||
SSchemaWrapper *pSchemaWrapper;
|
||||
void *pBuf;
|
||||
void * pBuf;
|
||||
|
||||
// fetch
|
||||
schemaDbKey.uid = uid;
|
||||
|
@ -419,9 +419,9 @@ STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver) {
|
|||
tb_uid_t quid;
|
||||
SSchemaWrapper *pSW;
|
||||
STSchemaBuilder sb;
|
||||
SSchemaEx *pSchema;
|
||||
STSchema *pTSchema;
|
||||
STbCfg *pTbCfg;
|
||||
SSchemaEx * pSchema;
|
||||
STSchema * pTSchema;
|
||||
STbCfg * pTbCfg;
|
||||
|
||||
pTbCfg = metaGetTbInfoByUid(pMeta, uid);
|
||||
if (pTbCfg->type == META_CHILD_TABLE) {
|
||||
|
@ -452,7 +452,7 @@ struct SMTbCursor {
|
|||
|
||||
SMTbCursor *metaOpenTbCursor(SMeta *pMeta) {
|
||||
SMTbCursor *pTbCur = NULL;
|
||||
SMetaDB *pDB = pMeta->pDB;
|
||||
SMetaDB * pDB = pMeta->pDB;
|
||||
|
||||
pTbCur = (SMTbCursor *)taosMemoryCalloc(1, sizeof(*pTbCur));
|
||||
if (pTbCur == NULL) {
|
||||
|
@ -474,12 +474,12 @@ void metaCloseTbCursor(SMTbCursor *pTbCur) {
|
|||
}
|
||||
|
||||
char *metaTbCursorNext(SMTbCursor *pTbCur) {
|
||||
void *pKey = NULL;
|
||||
void *pVal = NULL;
|
||||
void * pKey = NULL;
|
||||
void * pVal = NULL;
|
||||
int kLen;
|
||||
int vLen;
|
||||
int ret;
|
||||
void *pBuf;
|
||||
void * pBuf;
|
||||
STbCfg tbCfg;
|
||||
|
||||
for (;;) {
|
||||
|
@ -503,17 +503,17 @@ char *metaTbCursorNext(SMTbCursor *pTbCur) {
|
|||
}
|
||||
|
||||
struct SMCtbCursor {
|
||||
TDBC *pCur;
|
||||
TDBC * pCur;
|
||||
tb_uid_t suid;
|
||||
void *pKey;
|
||||
void *pVal;
|
||||
void * pKey;
|
||||
void * pVal;
|
||||
int kLen;
|
||||
int vLen;
|
||||
};
|
||||
|
||||
SMCtbCursor *metaOpenCtbCursor(SMeta *pMeta, tb_uid_t uid) {
|
||||
SMCtbCursor *pCtbCur = NULL;
|
||||
SMetaDB *pDB = pMeta->pDB;
|
||||
SMetaDB * pDB = pMeta->pDB;
|
||||
int ret;
|
||||
|
||||
pCtbCur = (SMCtbCursor *)taosMemoryCalloc(1, sizeof(*pCtbCur));
|
||||
|
@ -621,6 +621,7 @@ static int metaEncodeSchema(void **buf, SSchemaWrapper *pSW) {
|
|||
for (int i = 0; i < pSW->nCols; i++) {
|
||||
pSchema = pSW->pSchema + i;
|
||||
tlen += taosEncodeFixedI8(buf, pSchema->type);
|
||||
tlen += taosEncodeFixedI8(buf, pSchema->index);
|
||||
tlen += taosEncodeFixedI16(buf, pSchema->colId);
|
||||
tlen += taosEncodeFixedI32(buf, pSchema->bytes);
|
||||
tlen += taosEncodeString(buf, pSchema->name);
|
||||
|
@ -637,6 +638,7 @@ static void *metaDecodeSchema(void *buf, SSchemaWrapper *pSW) {
|
|||
for (int i = 0; i < pSW->nCols; i++) {
|
||||
pSchema = pSW->pSchema + i;
|
||||
buf = taosDecodeFixedI8(buf, &pSchema->type);
|
||||
buf = taosSkipFixedLen(buf, sizeof(int8_t));
|
||||
buf = taosDecodeFixedI16(buf, &pSchema->colId);
|
||||
buf = taosDecodeFixedI32(buf, &pSchema->bytes);
|
||||
buf = taosDecodeStringTo(buf, pSchema->name);
|
||||
|
@ -781,7 +783,7 @@ static void closePool(SPoolMem *pPool) {
|
|||
}
|
||||
|
||||
static void *poolMalloc(void *arg, size_t size) {
|
||||
void *ptr = NULL;
|
||||
void * ptr = NULL;
|
||||
SPoolMem *pPool = (SPoolMem *)arg;
|
||||
SPoolMem *pMem;
|
||||
|
||||
|
|
|
@ -393,6 +393,16 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.sprocessFunc = castFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "to_iso8601",
|
||||
.type = FUNCTION_TYPE_TO_ISO8601,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = toISO8601Function,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "_rowts",
|
||||
.type = FUNCTION_TYPE_ROWTS,
|
||||
|
@ -609,6 +619,9 @@ int32_t checkAndGetResultType(SFunctionNode* pFunc) {
|
|||
pFunc->node.resType = (SDataType) { .bytes = paraBytes, .type = paraType};
|
||||
break;
|
||||
}
|
||||
case FUNCTION_TYPE_TO_ISO8601: {
|
||||
pFunc->node.resType = (SDataType) { .bytes = 64, .type = TSDB_DATA_TYPE_BINARY};
|
||||
}
|
||||
|
||||
case FUNCTION_TYPE_TBNAME: {
|
||||
// todo
|
||||
|
|
|
@ -95,7 +95,6 @@ static void dataTypeCopy(const SDataType* pSrc, SDataType* pDst) {
|
|||
static void exprNodeCopy(const SExprNode* pSrc, SExprNode* pDst) {
|
||||
dataTypeCopy(&pSrc->resType, &pDst->resType);
|
||||
COPY_CHAR_ARRAY_FIELD(aliasName);
|
||||
// CLONE_NODE_LIST_FIELD(pAssociationList);
|
||||
}
|
||||
|
||||
static SNode* columnNodeCopy(const SColumnNode* pSrc, SColumnNode* pDst) {
|
||||
|
@ -222,15 +221,19 @@ static SVgroupsInfo* vgroupsInfoClone(const SVgroupsInfo* pSrc) {
|
|||
}
|
||||
|
||||
static SNode* logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) {
|
||||
COPY_ALL_SCALAR_FIELDS;
|
||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||
CLONE_NODE_LIST_FIELD(pScanCols);
|
||||
CLONE_OBJECT_FIELD(pMeta, tableMetaClone);
|
||||
CLONE_OBJECT_FIELD(pVgroupList, vgroupsInfoClone);
|
||||
COPY_SCALAR_FIELD(scanType);
|
||||
COPY_SCALAR_FIELD(scanFlag);
|
||||
COPY_SCALAR_FIELD(scanRange);
|
||||
COPY_SCALAR_FIELD(tableName);
|
||||
COPY_SCALAR_FIELD(showRewrite);
|
||||
CLONE_NODE_LIST_FIELD(pDynamicScanFuncs);
|
||||
return (SNode*)pDst;
|
||||
}
|
||||
|
||||
static SNode* logicJoinCopy(const SJoinLogicNode* pSrc, SJoinLogicNode* pDst) {
|
||||
COPY_ALL_SCALAR_FIELDS;
|
||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||
CLONE_NODE_FIELD(pOnConditions);
|
||||
return (SNode*)pDst;
|
||||
}
|
||||
|
||||
|
@ -263,15 +266,8 @@ static SNode* logicExchangeCopy(const SExchangeLogicNode* pSrc, SExchangeLogicNo
|
|||
static SNode* logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pDst) {
|
||||
COPY_ALL_SCALAR_FIELDS;
|
||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||
// COPY_SCALAR_FIELD(winType);
|
||||
CLONE_NODE_LIST_FIELD(pFuncs);
|
||||
// COPY_SCALAR_FIELD(interval);
|
||||
// COPY_SCALAR_FIELD(offset);
|
||||
// COPY_SCALAR_FIELD(sliding);
|
||||
// COPY_SCALAR_FIELD(intervalUnit);
|
||||
// COPY_SCALAR_FIELD(slidingUnit);
|
||||
CLONE_NODE_FIELD(pFill);
|
||||
// COPY_SCALAR_FIELD(sessionGap);
|
||||
CLONE_NODE_FIELD(pTspk);
|
||||
return (SNode*)pDst;
|
||||
}
|
||||
|
@ -360,6 +356,8 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
|
|||
return downstreamSourceCopy((const SDownstreamSourceNode*)pNode, (SDownstreamSourceNode*)pDst);
|
||||
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||
return logicScanCopy((const SScanLogicNode*)pNode, (SScanLogicNode*)pDst);
|
||||
case QUERY_NODE_LOGIC_PLAN_JOIN:
|
||||
return logicJoinCopy((const SJoinLogicNode*)pNode, (SJoinLogicNode*)pDst);
|
||||
case QUERY_NODE_LOGIC_PLAN_AGG:
|
||||
return logicAggCopy((const SAggLogicNode*)pNode, (SAggLogicNode*)pDst);
|
||||
case QUERY_NODE_LOGIC_PLAN_PROJECT:
|
||||
|
|
|
@ -158,6 +158,16 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
|||
case QUERY_NODE_SHOW_FUNCTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_INDEXES_STMT:
|
||||
case QUERY_NODE_SHOW_STREAMS_STMT:
|
||||
case QUERY_NODE_SHOW_APPS_STMT:
|
||||
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_LICENCE_STMT:
|
||||
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
||||
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
||||
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||
case QUERY_NODE_SHOW_SCORES_STMT:
|
||||
case QUERY_NODE_SHOW_TOPICS_STMT:
|
||||
case QUERY_NODE_SHOW_VARIABLE_STMT:
|
||||
case QUERY_NODE_SHOW_BNODES_STMT:
|
||||
case QUERY_NODE_SHOW_SNODES_STMT:
|
||||
return makeNode(type, sizeof(SShowStmt));
|
||||
|
|
|
@ -79,13 +79,13 @@ alter_account_option ::= USERS literal.
|
|||
alter_account_option ::= CONNS literal. { }
|
||||
alter_account_option ::= STATE literal. { }
|
||||
|
||||
/************************************************ create/alter/drop/show user *****************************************/
|
||||
/************************************************ create/alter/drop user **********************************************/
|
||||
cmd ::= CREATE USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createCreateUserStmt(pCxt, &A, &B); }
|
||||
cmd ::= ALTER USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PASSWD, &B); }
|
||||
cmd ::= ALTER USER user_name(A) PRIVILEGE NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PRIVILEGES, &B); }
|
||||
cmd ::= DROP USER user_name(A). { pCxt->pRootNode = createDropUserStmt(pCxt, &A); }
|
||||
|
||||
/************************************************ create/drop/alter/show dnode ****************************************/
|
||||
/************************************************ create/drop/alter dnode *********************************************/
|
||||
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); }
|
||||
cmd ::= CREATE DNODE dnode_host_name(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B); }
|
||||
cmd ::= DROP DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A); }
|
||||
|
@ -124,7 +124,7 @@ cmd ::= DROP SNODE ON DNODE NK_INTEGER(A).
|
|||
cmd ::= CREATE MNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_MNODE_STMT, &A); }
|
||||
cmd ::= DROP MNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &A); }
|
||||
|
||||
/************************************************ create/drop/show/use database ***************************************/
|
||||
/************************************************ create/drop/use database ********************************************/
|
||||
cmd ::= CREATE DATABASE not_exists_opt(A) db_name(B) db_options(C). { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, A, &B, C); }
|
||||
cmd ::= DROP DATABASE exists_opt(A) db_name(B). { pCxt->pRootNode = createDropDatabaseStmt(pCxt, A, &B); }
|
||||
cmd ::= USE db_name(A). { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &A); }
|
||||
|
@ -332,6 +332,7 @@ cmd ::= SHOW ACCOUNTS.
|
|||
cmd ::= SHOW APPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT, NULL, NULL); }
|
||||
cmd ::= SHOW CONNECTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT, NULL, NULL); }
|
||||
cmd ::= SHOW LICENCE. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT, NULL, NULL); }
|
||||
cmd ::= SHOW GRANTS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT, NULL, NULL); }
|
||||
cmd ::= SHOW CREATE DATABASE db_name(A). { pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &A); }
|
||||
cmd ::= SHOW CREATE TABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, A); }
|
||||
cmd ::= SHOW CREATE STABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, A); }
|
||||
|
|
|
@ -143,7 +143,7 @@ static int32_t rewriteConditionForFromTable(SCalcConstContext* pCxt, SNode* pTab
|
|||
if (TSDB_CODE_SUCCESS == pCxt->code) {
|
||||
pCxt->code = rewriteConditionForFromTable(pCxt, pJoin->pRight);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == pCxt->code) {
|
||||
if (TSDB_CODE_SUCCESS == pCxt->code && NULL != pJoin->pOnCond) {
|
||||
pCxt->code = rewriteCondition(pCxt, &pJoin->pOnCond);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ static SKeyword keywordTable[] = {
|
|||
{"FSYNC", TK_FSYNC},
|
||||
{"FUNCTION", TK_FUNCTION},
|
||||
{"FUNCTIONS", TK_FUNCTIONS},
|
||||
{"GRANTS", TK_GRANTS},
|
||||
{"GROUP", TK_GROUP},
|
||||
{"HAVING", TK_HAVING},
|
||||
{"IF", TK_IF},
|
||||
|
@ -131,10 +132,10 @@ static SKeyword keywordTable[] = {
|
|||
{"PRECISION", TK_PRECISION},
|
||||
{"PRIVILEGE", TK_PRIVILEGE},
|
||||
{"PREV", TK_PREV},
|
||||
{"_QENDTS", TK_QENDTS},
|
||||
{"_QENDTS", TK_QENDTS},
|
||||
{"QNODE", TK_QNODE},
|
||||
{"QNODES", TK_QNODES},
|
||||
{"_QSTARTTS", TK_QSTARTTS},
|
||||
{"_QSTARTTS", TK_QSTARTTS},
|
||||
{"QTIME", TK_QTIME},
|
||||
{"QUERIES", TK_QUERIES},
|
||||
{"QUERY", TK_QUERY},
|
||||
|
@ -144,7 +145,7 @@ static SKeyword keywordTable[] = {
|
|||
{"RESET", TK_RESET},
|
||||
{"RETENTIONS", TK_RETENTIONS},
|
||||
{"ROLLUP", TK_ROLLUP},
|
||||
{"_ROWTS", TK_ROWTS},
|
||||
{"_ROWTS", TK_ROWTS},
|
||||
{"SCORES", TK_SCORES},
|
||||
{"SELECT", TK_SELECT},
|
||||
{"SESSION", TK_SESSION},
|
||||
|
@ -163,7 +164,7 @@ static SKeyword keywordTable[] = {
|
|||
{"STATE", TK_STATE},
|
||||
{"STATE_WINDOW", TK_STATE_WINDOW},
|
||||
{"STORAGE", TK_STORAGE},
|
||||
{"STREAM", TK_STREAM},
|
||||
{"STREAM", TK_STREAM},
|
||||
{"STREAMS", TK_STREAMS},
|
||||
{"STREAM_MODE", TK_STREAM_MODE},
|
||||
{"SYNCDB", TK_SYNCDB},
|
||||
|
@ -192,8 +193,8 @@ static SKeyword keywordTable[] = {
|
|||
{"VGROUPS", TK_VGROUPS},
|
||||
{"VNODES", TK_VNODES},
|
||||
{"WAL", TK_WAL},
|
||||
{"_WDURATION", TK_WDURATION},
|
||||
{"_WENDTS", TK_WENDTS},
|
||||
{"_WDURATION", TK_WDURATION},
|
||||
{"_WENDTS", TK_WENDTS},
|
||||
{"WHERE", TK_WHERE},
|
||||
{"_WSTARTTS", TK_WSTARTTS},
|
||||
// {"ID", TK_ID},
|
||||
|
@ -221,7 +222,6 @@ static SKeyword keywordTable[] = {
|
|||
// {"UMINUS", TK_UMINUS},
|
||||
// {"UPLUS", TK_UPLUS},
|
||||
// {"BITNOT", TK_BITNOT},
|
||||
// {"GRANTS", TK_GRANTS},
|
||||
// {"DOT", TK_DOT},
|
||||
// {"CTIME", TK_CTIME},
|
||||
// {"LP", TK_LP},
|
||||
|
|
|
@ -762,7 +762,7 @@ static int32_t createAllColumns(STranslateContext* pCxt, SNodeList** pCols) {
|
|||
size_t nums = taosArrayGetSize(pTables);
|
||||
for (size_t i = 0; i < nums; ++i) {
|
||||
STableNode* pTable = taosArrayGetP(pTables, i);
|
||||
int32_t code = createColumnNodeByTable(pCxt, pTable, *pCols);
|
||||
int32_t code = createColumnNodeByTable(pCxt, pTable, *pCols);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
@ -829,11 +829,39 @@ static int32_t createFirstLastAllCols(STranslateContext* pCxt, SFunctionNode* pS
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static bool isTableStar(SNode* pNode) {
|
||||
return (QUERY_NODE_COLUMN == nodeType(pNode)) && (0 == strcmp(((SColumnNode*)pNode)->colName, "*"));
|
||||
}
|
||||
|
||||
static int32_t createTableAllCols(STranslateContext* pCxt, SColumnNode* pCol, SNodeList** pOutput) {
|
||||
*pOutput = nodesMakeList();
|
||||
if (NULL == *pOutput) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
bool foundTable = false;
|
||||
SArray* pTables = taosArrayGetP(pCxt->pNsLevel, pCxt->currLevel);
|
||||
size_t nums = taosArrayGetSize(pTables);
|
||||
for (size_t i = 0; i < nums; ++i) {
|
||||
STableNode* pTable = taosArrayGetP(pTables, i);
|
||||
if (0 == strcmp(pTable->tableAlias, pCol->tableAlias)) {
|
||||
int32_t code = createColumnNodeByTable(pCxt, pTable, *pOutput);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
foundTable = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!foundTable) {
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_TABLE_NOT_EXIST, pCol->tableAlias);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||
if (NULL == pSelect->pProjectionList) { // select * ...
|
||||
return createAllColumns(pCxt, &pSelect->pProjectionList);
|
||||
} else {
|
||||
// todo : t.*
|
||||
SNode* pNode = NULL;
|
||||
WHERE_EACH(pNode, pSelect->pProjectionList) {
|
||||
if (isFirstLastStar(pNode)) {
|
||||
|
@ -844,6 +872,14 @@ static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
|||
INSERT_LIST(pSelect->pProjectionList, pFuncs);
|
||||
ERASE_NODE(pSelect->pProjectionList);
|
||||
continue;
|
||||
} else if (isTableStar(pNode)) {
|
||||
SNodeList* pCols = NULL;
|
||||
if (TSDB_CODE_SUCCESS != createTableAllCols(pCxt, (SColumnNode*)pNode, &pCols)) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
INSERT_LIST(pSelect->pProjectionList, pCols);
|
||||
ERASE_NODE(pSelect->pProjectionList);
|
||||
continue;
|
||||
}
|
||||
WHERE_NEXT;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -147,8 +147,80 @@ static int32_t osdOptimize(SOptimizeContext* pCxt, SLogicNode* pLogicNode) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t cpdOptimizeScanCondition(SOptimizeContext* pCxt, SScanLogicNode* pScan) {
|
||||
// todo
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t cpdPartitionCondition(SJoinLogicNode* pJoin, SNodeList** pMultiTableCond, SNodeList** pSingleTableCond) {
|
||||
// todo
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t cpdPushJoinCondToOnCond(SOptimizeContext* pCxt, SJoinLogicNode* pJoin, SNodeList* pMultiTableCond) {
|
||||
// todo
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t cpdPushJoinCondToChildren(SOptimizeContext* pCxt, SJoinLogicNode* pJoin, SNodeList* pSingleTableCond) {
|
||||
// todo
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t cpdPushJoinCondition(SOptimizeContext* pCxt, SJoinLogicNode* pJoin) {
|
||||
if (NULL != pJoin->node.pConditions) {
|
||||
SNodeList* pMultiTableCond = NULL;
|
||||
SNodeList* pSingleTableCond = NULL;
|
||||
int32_t code = cpdPartitionCondition(pJoin, &pMultiTableCond, &pSingleTableCond);
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pMultiTableCond) {
|
||||
code = cpdPushJoinCondToOnCond(pCxt, pJoin, pMultiTableCond);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pSingleTableCond) {
|
||||
code = cpdPushJoinCondToChildren(pCxt, pJoin, pSingleTableCond);
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t cpdPushAggCondition(SOptimizeContext* pCxt, SAggLogicNode* pAgg) {
|
||||
// todo
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t cpdPushCondition(SOptimizeContext* pCxt, SLogicNode* pLogicNode) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
switch (nodeType(pLogicNode)) {
|
||||
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||
code = cpdOptimizeScanCondition(pCxt, (SScanLogicNode*)pLogicNode);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_JOIN:
|
||||
code = cpdPushJoinCondition(pCxt, (SJoinLogicNode*)pLogicNode);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_AGG:
|
||||
code = cpdPushAggCondition(pCxt, (SAggLogicNode*)pLogicNode);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
SNode* pChild = NULL;
|
||||
FOREACH(pChild, pLogicNode->pChildren) {
|
||||
code = cpdPushCondition(pCxt, (SLogicNode*)pChild);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t cpdOptimize(SOptimizeContext* pCxt, SLogicNode* pLogicNode) {
|
||||
return cpdPushCondition(pCxt, pLogicNode);
|
||||
}
|
||||
|
||||
static const SOptimizeRule optimizeRuleSet[] = {
|
||||
{ .pName = "OptimizeScanData", .optimizeFunc = osdOptimize }
|
||||
{ .pName = "OptimizeScanData", .optimizeFunc = osdOptimize },
|
||||
{ .pName = "ConditionPushDown", .optimizeFunc = cpdOptimize }
|
||||
};
|
||||
|
||||
static const int32_t optimizeRuleNum = (sizeof(optimizeRuleSet) / sizeof(SOptimizeRule));
|
||||
|
|
|
@ -492,58 +492,25 @@ static int32_t createScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan,
|
|||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
static int32_t createColFromDataBlockDesc(SDataBlockDescNode* pDesc, SNodeList* pCols) {
|
||||
SNode* pNode;
|
||||
FOREACH(pNode, pDesc->pSlots) {
|
||||
SSlotDescNode* pSlot = (SSlotDescNode*)pNode;
|
||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
if (NULL == pCol) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCol->node.resType = pSlot->dataType;
|
||||
pCol->dataBlockId = pDesc->dataBlockId;
|
||||
pCol->slotId = pSlot->slotId;
|
||||
pCol->colId = -1;
|
||||
int32_t code = nodesListStrictAppend(pCols, pCol);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t createJoinOutputCols(SPhysiPlanContext* pCxt, SDataBlockDescNode* pLeftDesc, SDataBlockDescNode* pRightDesc, SNodeList** pList) {
|
||||
SNodeList* pCols = nodesMakeList();
|
||||
if (NULL == pCols) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
int32_t code = createColFromDataBlockDesc(pLeftDesc, pCols);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = createColFromDataBlockDesc(pRightDesc, pCols);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pList = pCols;
|
||||
} else {
|
||||
nodesDestroyList(pCols);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SJoinLogicNode* pJoinLogicNode, SPhysiNode** pPhyNode) {
|
||||
SJoinPhysiNode* pJoin = (SJoinPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pJoinLogicNode, QUERY_NODE_PHYSICAL_PLAN_JOIN);
|
||||
if (NULL == pJoin) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
SDataBlockDescNode* pLeftDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc;
|
||||
SDataBlockDescNode* pRightDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 1))->pOutputDataBlockDesc;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
int32_t code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pOnConditions, &pJoin->pOnConditions);
|
||||
pJoin->joinType = pJoinLogicNode->joinType;
|
||||
if (NULL != pJoinLogicNode->pOnConditions) {
|
||||
SDataBlockDescNode* pLeftDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc;
|
||||
SDataBlockDescNode* pRightDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 1))->pOutputDataBlockDesc;
|
||||
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pOnConditions, &pJoin->pOnConditions);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = createJoinOutputCols(pCxt, pLeftDesc, pRightDesc, &pJoin->pTargets);
|
||||
pJoin->pTargets = nodesCloneList(pJoinLogicNode->node.pTargets);
|
||||
if (NULL == pJoin->pTargets) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = addDataBlockSlots(pCxt, pJoin->pTargets, pJoin->node.pOutputDataBlockDesc);
|
||||
|
|
|
@ -190,6 +190,7 @@ int32_t splitLogicPlan(SPlanContext* pCxt, SLogicNode* pLogicNode, SLogicSubplan
|
|||
pSubplan->subplanType = SUBPLAN_TYPE_SCAN;
|
||||
}
|
||||
pSubplan->id.queryId = pCxt->queryId;
|
||||
pSubplan->id.groupId = 1;
|
||||
setLogicNodeParent(pSubplan->pNode);
|
||||
|
||||
int32_t code = applySplitRule(pSubplan);
|
||||
|
|
|
@ -150,7 +150,7 @@ private:
|
|||
SQuery* query_;
|
||||
};
|
||||
|
||||
TEST_F(PlannerTest, simple) {
|
||||
TEST_F(PlannerTest, selectBasic) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("SELECT * FROM t1");
|
||||
|
@ -164,14 +164,27 @@ TEST_F(PlannerTest, selectConstant) {
|
|||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(PlannerTest, stSimple) {
|
||||
TEST_F(PlannerTest, selectStableBasic) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("SELECT * FROM st1");
|
||||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(PlannerTest, groupBy) {
|
||||
TEST_F(PlannerTest, selectJoin) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("SELECT * FROM st1s1 t1, st1s2 t2 where t1.ts = t2.ts");
|
||||
ASSERT_TRUE(run());
|
||||
|
||||
bind("SELECT * FROM st1s1 t1 join st1s2 t2 on t1.ts = t2.ts where t1.c1 > t2.c1");
|
||||
ASSERT_TRUE(run());
|
||||
|
||||
bind("SELECT t1.* FROM st1s1 t1 join st1s2 t2 on t1.ts = t2.ts where t1.c1 > t2.c1");
|
||||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(PlannerTest, selectGroupBy) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("SELECT count(*) FROM t1");
|
||||
|
@ -187,14 +200,14 @@ TEST_F(PlannerTest, groupBy) {
|
|||
// ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(PlannerTest, subquery) {
|
||||
TEST_F(PlannerTest, selectSubquery) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("SELECT count(*) FROM (SELECT c1 + c3 a, c1 + count(*) b FROM t1 where c2 = 'abc' GROUP BY c1, c3) where a > 100 group by b");
|
||||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(PlannerTest, interval) {
|
||||
TEST_F(PlannerTest, selectInterval) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("SELECT count(*) FROM t1 interval(10s)");
|
||||
|
@ -210,14 +223,14 @@ TEST_F(PlannerTest, interval) {
|
|||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(PlannerTest, sessionWindow) {
|
||||
TEST_F(PlannerTest, selectSessionWindow) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("SELECT count(*) FROM t1 session(ts, 10s)");
|
||||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(PlannerTest, stateWindow) {
|
||||
TEST_F(PlannerTest, selectStateWindow) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("SELECT count(*) FROM t1 state_window(c1)");
|
||||
|
@ -227,7 +240,7 @@ TEST_F(PlannerTest, stateWindow) {
|
|||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(PlannerTest, partitionBy) {
|
||||
TEST_F(PlannerTest, selectPartitionBy) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("SELECT * FROM t1 partition by c1");
|
||||
|
@ -243,7 +256,7 @@ TEST_F(PlannerTest, partitionBy) {
|
|||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(PlannerTest, orderBy) {
|
||||
TEST_F(PlannerTest, selectOrderBy) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("SELECT c1 FROM t1 order by c1");
|
||||
|
@ -259,7 +272,7 @@ TEST_F(PlannerTest, orderBy) {
|
|||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(PlannerTest, groupByOrderBy) {
|
||||
TEST_F(PlannerTest, selectGroupByOrderBy) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("select count(*), sum(c1) from t1 order by sum(c1)");
|
||||
|
@ -269,7 +282,7 @@ TEST_F(PlannerTest, groupByOrderBy) {
|
|||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(PlannerTest, distinct) {
|
||||
TEST_F(PlannerTest, selectDistinct) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("SELECT distinct c1 FROM t1");
|
||||
|
@ -282,7 +295,7 @@ TEST_F(PlannerTest, distinct) {
|
|||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(PlannerTest, limit) {
|
||||
TEST_F(PlannerTest, selectLimit) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("SELECT * FROM t1 limit 2");
|
||||
|
@ -295,7 +308,7 @@ TEST_F(PlannerTest, limit) {
|
|||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(PlannerTest, slimit) {
|
||||
TEST_F(PlannerTest, selectSlimit) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("SELECT * FROM t1 partition by c1 slimit 2");
|
||||
|
|
|
@ -801,6 +801,77 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||
int32_t type = GET_PARAM_TYPE(pInput);
|
||||
if (type != TSDB_DATA_TYPE_BIGINT && type != TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
if (inputNum != 1) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
char *input = pInput[0].columnData->pData;
|
||||
for (int32_t i = 0; i < pInput[0].numOfRows; ++i) {
|
||||
if (colDataIsNull_s(pInput[0].columnData, i)) {
|
||||
colDataAppendNULL(pOutput->columnData, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
char fraction[20] = {0};
|
||||
bool hasFraction = false;
|
||||
NUM_TO_STRING(type, input, sizeof(fraction), fraction);
|
||||
int32_t tsDigits = (int32_t)strlen(fraction);
|
||||
|
||||
char buf[64] = {0};
|
||||
int64_t timeVal;
|
||||
GET_TYPED_DATA(timeVal, int64_t, type, input);
|
||||
if (tsDigits > TSDB_TIME_PRECISION_SEC_DIGITS) {
|
||||
if (tsDigits == TSDB_TIME_PRECISION_MILLI_DIGITS) {
|
||||
timeVal = timeVal / 1000;
|
||||
} else if (tsDigits == TSDB_TIME_PRECISION_MICRO_DIGITS) {
|
||||
timeVal = timeVal / (1000 * 1000);
|
||||
} else if (tsDigits == TSDB_TIME_PRECISION_NANO_DIGITS) {
|
||||
timeVal = timeVal / (1000 * 1000 * 1000);
|
||||
} else {
|
||||
assert(0);
|
||||
}
|
||||
hasFraction = true;
|
||||
memmove(fraction, fraction + TSDB_TIME_PRECISION_SEC_DIGITS, TSDB_TIME_PRECISION_SEC_DIGITS);
|
||||
}
|
||||
|
||||
struct tm *tmInfo = localtime((const time_t *)&timeVal);
|
||||
strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S%z", tmInfo);
|
||||
int32_t len = (int32_t)strlen(buf);
|
||||
|
||||
if (hasFraction) {
|
||||
int32_t fracLen = (int32_t)strlen(fraction) + 1;
|
||||
char *tzInfo = strchr(buf, '+');
|
||||
if (tzInfo) {
|
||||
memmove(tzInfo + fracLen, tzInfo, strlen(tzInfo));
|
||||
} else {
|
||||
tzInfo = strchr(buf, '-');
|
||||
memmove(tzInfo + fracLen, tzInfo, strlen(tzInfo));
|
||||
}
|
||||
|
||||
char tmp[32];
|
||||
sprintf(tmp, ".%s", fraction);
|
||||
memcpy(tzInfo, tmp, fracLen);
|
||||
len += fracLen;
|
||||
}
|
||||
|
||||
memmove(buf + VARSTR_HEADER_SIZE, buf, len);
|
||||
varDataSetLen(buf, len);
|
||||
|
||||
colDataAppend(pOutput->columnData, i, buf, false);
|
||||
input += tDataTypes[type].bytes;
|
||||
}
|
||||
|
||||
pOutput->numOfRows = pInput->numOfRows;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t atanFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||
return doScalarFunctionUnique(pInput, inputNum, pOutput, atan);
|
||||
}
|
||||
|
|
|
@ -76,6 +76,47 @@ int32_t taosMkDir(const char *dirname) {
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t taosMulMkDir(const char *dirname) {
|
||||
if (dirname == NULL) return -1;
|
||||
char *temp = strdup(dirname);
|
||||
char *pos = temp;
|
||||
int32_t code = 0;
|
||||
|
||||
if (strncmp(temp, "/", 1) == 0) {
|
||||
pos += 1;
|
||||
} else if (strncmp(temp, "./", 2) == 0) {
|
||||
pos += 2;
|
||||
}
|
||||
|
||||
for ( ; *pos != '\0'; pos++) {
|
||||
if (*pos == '/') {
|
||||
*pos = '\0';
|
||||
code = mkdir(temp, 0755);
|
||||
if (code < 0 && errno != EEXIST) {
|
||||
free(temp);
|
||||
return code;
|
||||
}
|
||||
*pos = '/';
|
||||
}
|
||||
}
|
||||
|
||||
if (*(pos - 1) != '/') {
|
||||
code = mkdir(temp, 0755);
|
||||
if (code < 0 && errno != EEXIST) {
|
||||
free(temp);
|
||||
return code;
|
||||
}
|
||||
}
|
||||
free(temp);
|
||||
|
||||
// int32_t code = mkdir(dirname, 0755);
|
||||
if (code < 0 && errno == EEXIST) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
void taosRemoveOldFiles(const char *dirname, int32_t keepDays) {
|
||||
DIR *dir = opendir(dirname);
|
||||
if (dir == NULL) return;
|
||||
|
|
|
@ -77,9 +77,9 @@ sql insert into ct4 values ( '2022-05-21 01:01:01.000', NULL, NULL, NULL, NULL,
|
|||
print ================ start query ======================
|
||||
|
||||
print ================ query 1 having condition
|
||||
sql_error select c1 from ct1 group by c1 having count(c1)
|
||||
sql_error select c1 from ct4 group by c1 having count(c1)
|
||||
sql_error select count(c1) from ct1 group by c1 having count(c1)
|
||||
sql select c1 from ct1 group by c1 having count(c1)
|
||||
sql select c1 from ct4 group by c1 having count(c1)
|
||||
sql select count(c1) from ct1 group by c1 having count(c1)
|
||||
|
||||
sql select sum(c1) ,count(c7) from ct4 group by c7 having count(c7) > 1 ;
|
||||
print ====> sql : select sum(c1) ,count(c7) from ct4 group by c7 having count(c7) > 1 ;
|
||||
|
@ -98,22 +98,22 @@ endi
|
|||
sql select sum(c1) ,count(c1) from ct4 group by c1 having count(c7) < 2 and sum(c1) > 2 ;
|
||||
print ====> sql : select sum(c1) ,count(c1) from ct4 group by c1 having count(c7) < 2 and sum(c1) > 2 ;
|
||||
print ====> rows: $rows
|
||||
if $rows != 2 then
|
||||
if $rows != 7 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select sum(c1) ,count(c1) from ct4 group by c1 having count(c7) < 1 or sum(c1) > 2 ;
|
||||
print ====> sql : select sum(c1) ,count(c1) from ct4 group by c1 having count(c7) < 1 or sum(c1) > 2 ;
|
||||
print ====> rows: $rows
|
||||
if $rows != 2 then
|
||||
if $rows != 7 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
print ================ query 1 complex with having condition
|
||||
|
||||
sql select count(c1) from ct4 where c1 > 2 group by c7 having count(c1) < 1 limit 1 offset 1
|
||||
print ====> sql : select count(c1) from ct4 where c1 > 2 group by c7 having count(c1) < 1 limit 1 offset 1
|
||||
sql select count(c1) from ct4 where c1 > 2 group by c7 having count(c1) > 1 limit 1 offset 0
|
||||
print ====> sql : select count(c1) from ct4 where c1 > 2 group by c7 having count(c1) > 1 limit 1 offset 0
|
||||
print ====> rows: $rows
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
|
@ -250,9 +250,9 @@ if $data00 != 20 then
|
|||
endi
|
||||
|
||||
print ================ query 1 having condition
|
||||
sql_error select c1 from ct1 group by c1 having count(c1)
|
||||
sql_error select c1 from ct4 group by c1 having count(c1)
|
||||
sql_error select count(c1) from ct1 group by c1 having count(c1)
|
||||
sql select c1 from ct1 group by c1 having count(c1)
|
||||
sql select c1 from ct4 group by c1 having count(c1)
|
||||
sql select count(c1) from ct1 group by c1 having count(c1)
|
||||
|
||||
sql select sum(c1) ,count(c7) from ct4 group by c7 having count(c7) > 1 ;
|
||||
print ====> sql : select sum(c1) ,count(c7) from ct4 group by c7 having count(c7) > 1 ;
|
||||
|
@ -271,22 +271,22 @@ endi
|
|||
sql select sum(c1) ,count(c1) from ct4 group by c1 having count(c7) < 2 and sum(c1) > 2 ;
|
||||
print ====> sql : select sum(c1) ,count(c1) from ct4 group by c1 having count(c7) < 2 and sum(c1) > 2 ;
|
||||
print ====> rows: $rows
|
||||
if $rows != 2 then
|
||||
if $rows != 7 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select sum(c1) ,count(c1) from ct4 group by c1 having count(c7) < 1 or sum(c1) > 2 ;
|
||||
print ====> sql : select sum(c1) ,count(c1) from ct4 group by c1 having count(c7) < 1 or sum(c1) > 2 ;
|
||||
print ====> rows: $rows
|
||||
if $rows != 2 then
|
||||
if $rows != 7 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
print ================ query 1 complex with having condition
|
||||
|
||||
sql select count(c1) from ct4 where c1 > 2 group by c7 having count(c1) < 1 limit 1 offset 1
|
||||
print ====> sql : select count(c1) from ct4 where c1 > 2 group by c7 having count(c1) < 1 limit 1 offset 1
|
||||
sql select count(c1) from ct4 where c1 > 2 group by c7 having count(c1) > 1 limit 1 offset 0
|
||||
print ====> sql : select count(c1) from ct4 where c1 > 2 group by c7 having count(c1) > 1 limit 1 offset 0
|
||||
print ====> rows: $rows
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
|
|
Loading…
Reference in New Issue