Merge branch '3.0' into enh/TS-3934-3.0
This commit is contained in:
commit
1bbb812557
|
@ -241,6 +241,11 @@ DLL_EXPORT int taos_set_notify_cb(TAOS *taos, __taos_notify_fn_t fp, void *param
|
|||
typedef void (*__taos_async_whitelist_fn_t)(void *param, int code, TAOS *taos, int numOfWhiteLists, uint64_t* pWhiteLists);
|
||||
DLL_EXPORT void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *param);
|
||||
|
||||
typedef enum {
|
||||
TAOS_CONN_MODE_BI = 0,
|
||||
} TAOS_CONN_MODE;
|
||||
|
||||
DLL_EXPORT int taos_set_conn_mode(TAOS* taos, int mode, int value);
|
||||
/* --------------------------schemaless INTERFACE------------------------------- */
|
||||
|
||||
DLL_EXPORT TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision);
|
||||
|
|
|
@ -186,177 +186,179 @@
|
|||
#define TK_SUBSCRIPTIONS 167
|
||||
#define TK_VNODES 168
|
||||
#define TK_ALIVE 169
|
||||
#define TK_LIKE 170
|
||||
#define TK_TBNAME 171
|
||||
#define TK_QTAGS 172
|
||||
#define TK_AS 173
|
||||
#define TK_INDEX 174
|
||||
#define TK_FUNCTION 175
|
||||
#define TK_INTERVAL 176
|
||||
#define TK_COUNT 177
|
||||
#define TK_LAST_ROW 178
|
||||
#define TK_META 179
|
||||
#define TK_ONLY 180
|
||||
#define TK_TOPIC 181
|
||||
#define TK_CONSUMER 182
|
||||
#define TK_GROUP 183
|
||||
#define TK_DESC 184
|
||||
#define TK_DESCRIBE 185
|
||||
#define TK_RESET 186
|
||||
#define TK_QUERY 187
|
||||
#define TK_CACHE 188
|
||||
#define TK_EXPLAIN 189
|
||||
#define TK_ANALYZE 190
|
||||
#define TK_VERBOSE 191
|
||||
#define TK_NK_BOOL 192
|
||||
#define TK_RATIO 193
|
||||
#define TK_NK_FLOAT 194
|
||||
#define TK_OUTPUTTYPE 195
|
||||
#define TK_AGGREGATE 196
|
||||
#define TK_BUFSIZE 197
|
||||
#define TK_LANGUAGE 198
|
||||
#define TK_REPLACE 199
|
||||
#define TK_STREAM 200
|
||||
#define TK_INTO 201
|
||||
#define TK_PAUSE 202
|
||||
#define TK_RESUME 203
|
||||
#define TK_TRIGGER 204
|
||||
#define TK_AT_ONCE 205
|
||||
#define TK_WINDOW_CLOSE 206
|
||||
#define TK_IGNORE 207
|
||||
#define TK_EXPIRED 208
|
||||
#define TK_FILL_HISTORY 209
|
||||
#define TK_UPDATE 210
|
||||
#define TK_SUBTABLE 211
|
||||
#define TK_UNTREATED 212
|
||||
#define TK_KILL 213
|
||||
#define TK_CONNECTION 214
|
||||
#define TK_TRANSACTION 215
|
||||
#define TK_BALANCE 216
|
||||
#define TK_VGROUP 217
|
||||
#define TK_LEADER 218
|
||||
#define TK_MERGE 219
|
||||
#define TK_REDISTRIBUTE 220
|
||||
#define TK_SPLIT 221
|
||||
#define TK_DELETE 222
|
||||
#define TK_INSERT 223
|
||||
#define TK_NULL 224
|
||||
#define TK_NK_QUESTION 225
|
||||
#define TK_NK_ARROW 226
|
||||
#define TK_ROWTS 227
|
||||
#define TK_QSTART 228
|
||||
#define TK_QEND 229
|
||||
#define TK_QDURATION 230
|
||||
#define TK_WSTART 231
|
||||
#define TK_WEND 232
|
||||
#define TK_WDURATION 233
|
||||
#define TK_IROWTS 234
|
||||
#define TK_ISFILLED 235
|
||||
#define TK_CAST 236
|
||||
#define TK_NOW 237
|
||||
#define TK_TODAY 238
|
||||
#define TK_TIMEZONE 239
|
||||
#define TK_CLIENT_VERSION 240
|
||||
#define TK_SERVER_VERSION 241
|
||||
#define TK_SERVER_STATUS 242
|
||||
#define TK_CURRENT_USER 243
|
||||
#define TK_CASE 244
|
||||
#define TK_WHEN 245
|
||||
#define TK_THEN 246
|
||||
#define TK_ELSE 247
|
||||
#define TK_BETWEEN 248
|
||||
#define TK_IS 249
|
||||
#define TK_NK_LT 250
|
||||
#define TK_NK_GT 251
|
||||
#define TK_NK_LE 252
|
||||
#define TK_NK_GE 253
|
||||
#define TK_NK_NE 254
|
||||
#define TK_MATCH 255
|
||||
#define TK_NMATCH 256
|
||||
#define TK_CONTAINS 257
|
||||
#define TK_IN 258
|
||||
#define TK_JOIN 259
|
||||
#define TK_INNER 260
|
||||
#define TK_SELECT 261
|
||||
#define TK_NK_HINT 262
|
||||
#define TK_DISTINCT 263
|
||||
#define TK_WHERE 264
|
||||
#define TK_PARTITION 265
|
||||
#define TK_BY 266
|
||||
#define TK_SESSION 267
|
||||
#define TK_STATE_WINDOW 268
|
||||
#define TK_EVENT_WINDOW 269
|
||||
#define TK_SLIDING 270
|
||||
#define TK_FILL 271
|
||||
#define TK_VALUE 272
|
||||
#define TK_VALUE_F 273
|
||||
#define TK_NONE 274
|
||||
#define TK_PREV 275
|
||||
#define TK_NULL_F 276
|
||||
#define TK_LINEAR 277
|
||||
#define TK_NEXT 278
|
||||
#define TK_HAVING 279
|
||||
#define TK_RANGE 280
|
||||
#define TK_EVERY 281
|
||||
#define TK_ORDER 282
|
||||
#define TK_SLIMIT 283
|
||||
#define TK_SOFFSET 284
|
||||
#define TK_LIMIT 285
|
||||
#define TK_OFFSET 286
|
||||
#define TK_ASC 287
|
||||
#define TK_NULLS 288
|
||||
#define TK_ABORT 289
|
||||
#define TK_AFTER 290
|
||||
#define TK_ATTACH 291
|
||||
#define TK_BEFORE 292
|
||||
#define TK_BEGIN 293
|
||||
#define TK_BITAND 294
|
||||
#define TK_BITNOT 295
|
||||
#define TK_BITOR 296
|
||||
#define TK_BLOCKS 297
|
||||
#define TK_CHANGE 298
|
||||
#define TK_COMMA 299
|
||||
#define TK_CONCAT 300
|
||||
#define TK_CONFLICT 301
|
||||
#define TK_COPY 302
|
||||
#define TK_DEFERRED 303
|
||||
#define TK_DELIMITERS 304
|
||||
#define TK_DETACH 305
|
||||
#define TK_DIVIDE 306
|
||||
#define TK_DOT 307
|
||||
#define TK_EACH 308
|
||||
#define TK_FAIL 309
|
||||
#define TK_FILE 310
|
||||
#define TK_FOR 311
|
||||
#define TK_GLOB 312
|
||||
#define TK_ID 313
|
||||
#define TK_IMMEDIATE 314
|
||||
#define TK_IMPORT 315
|
||||
#define TK_INITIALLY 316
|
||||
#define TK_INSTEAD 317
|
||||
#define TK_ISNULL 318
|
||||
#define TK_KEY 319
|
||||
#define TK_MODULES 320
|
||||
#define TK_NK_BITNOT 321
|
||||
#define TK_NK_SEMI 322
|
||||
#define TK_NOTNULL 323
|
||||
#define TK_OF 324
|
||||
#define TK_PLUS 325
|
||||
#define TK_PRIVILEGE 326
|
||||
#define TK_RAISE 327
|
||||
#define TK_RESTRICT 328
|
||||
#define TK_ROW 329
|
||||
#define TK_SEMI 330
|
||||
#define TK_STAR 331
|
||||
#define TK_STATEMENT 332
|
||||
#define TK_STRICT 333
|
||||
#define TK_STRING 334
|
||||
#define TK_TIMES 335
|
||||
#define TK_VALUES 336
|
||||
#define TK_VARIABLE 337
|
||||
#define TK_VIEW 338
|
||||
#define TK_WAL 339
|
||||
|
||||
#define TK_NORMAL 170
|
||||
#define TK_CHILD 171
|
||||
#define TK_LIKE 172
|
||||
#define TK_TBNAME 173
|
||||
#define TK_QTAGS 174
|
||||
#define TK_AS 175
|
||||
#define TK_SYSTEM 176
|
||||
#define TK_INDEX 177
|
||||
#define TK_FUNCTION 178
|
||||
#define TK_INTERVAL 179
|
||||
#define TK_COUNT 180
|
||||
#define TK_LAST_ROW 181
|
||||
#define TK_META 182
|
||||
#define TK_ONLY 183
|
||||
#define TK_TOPIC 184
|
||||
#define TK_CONSUMER 185
|
||||
#define TK_GROUP 186
|
||||
#define TK_DESC 187
|
||||
#define TK_DESCRIBE 188
|
||||
#define TK_RESET 189
|
||||
#define TK_QUERY 190
|
||||
#define TK_CACHE 191
|
||||
#define TK_EXPLAIN 192
|
||||
#define TK_ANALYZE 193
|
||||
#define TK_VERBOSE 194
|
||||
#define TK_NK_BOOL 195
|
||||
#define TK_RATIO 196
|
||||
#define TK_NK_FLOAT 197
|
||||
#define TK_OUTPUTTYPE 198
|
||||
#define TK_AGGREGATE 199
|
||||
#define TK_BUFSIZE 200
|
||||
#define TK_LANGUAGE 201
|
||||
#define TK_REPLACE 202
|
||||
#define TK_STREAM 203
|
||||
#define TK_INTO 204
|
||||
#define TK_PAUSE 205
|
||||
#define TK_RESUME 206
|
||||
#define TK_TRIGGER 207
|
||||
#define TK_AT_ONCE 208
|
||||
#define TK_WINDOW_CLOSE 209
|
||||
#define TK_IGNORE 210
|
||||
#define TK_EXPIRED 211
|
||||
#define TK_FILL_HISTORY 212
|
||||
#define TK_UPDATE 213
|
||||
#define TK_SUBTABLE 214
|
||||
#define TK_UNTREATED 215
|
||||
#define TK_KILL 216
|
||||
#define TK_CONNECTION 217
|
||||
#define TK_TRANSACTION 218
|
||||
#define TK_BALANCE 219
|
||||
#define TK_VGROUP 220
|
||||
#define TK_LEADER 221
|
||||
#define TK_MERGE 222
|
||||
#define TK_REDISTRIBUTE 223
|
||||
#define TK_SPLIT 224
|
||||
#define TK_DELETE 225
|
||||
#define TK_INSERT 226
|
||||
#define TK_NULL 227
|
||||
#define TK_NK_QUESTION 228
|
||||
#define TK_NK_ARROW 229
|
||||
#define TK_ROWTS 230
|
||||
#define TK_QSTART 231
|
||||
#define TK_QEND 232
|
||||
#define TK_QDURATION 233
|
||||
#define TK_WSTART 234
|
||||
#define TK_WEND 235
|
||||
#define TK_WDURATION 236
|
||||
#define TK_IROWTS 237
|
||||
#define TK_ISFILLED 238
|
||||
#define TK_CAST 239
|
||||
#define TK_NOW 240
|
||||
#define TK_TODAY 241
|
||||
#define TK_TIMEZONE 242
|
||||
#define TK_CLIENT_VERSION 243
|
||||
#define TK_SERVER_VERSION 244
|
||||
#define TK_SERVER_STATUS 245
|
||||
#define TK_CURRENT_USER 246
|
||||
#define TK_CASE 247
|
||||
#define TK_WHEN 248
|
||||
#define TK_THEN 249
|
||||
#define TK_ELSE 250
|
||||
#define TK_BETWEEN 251
|
||||
#define TK_IS 252
|
||||
#define TK_NK_LT 253
|
||||
#define TK_NK_GT 254
|
||||
#define TK_NK_LE 255
|
||||
#define TK_NK_GE 256
|
||||
#define TK_NK_NE 257
|
||||
#define TK_MATCH 258
|
||||
#define TK_NMATCH 259
|
||||
#define TK_CONTAINS 260
|
||||
#define TK_IN 261
|
||||
#define TK_JOIN 262
|
||||
#define TK_INNER 263
|
||||
#define TK_SELECT 264
|
||||
#define TK_NK_HINT 265
|
||||
#define TK_DISTINCT 266
|
||||
#define TK_WHERE 267
|
||||
#define TK_PARTITION 268
|
||||
#define TK_BY 269
|
||||
#define TK_SESSION 270
|
||||
#define TK_STATE_WINDOW 271
|
||||
#define TK_EVENT_WINDOW 272
|
||||
#define TK_SLIDING 273
|
||||
#define TK_FILL 274
|
||||
#define TK_VALUE 275
|
||||
#define TK_VALUE_F 276
|
||||
#define TK_NONE 277
|
||||
#define TK_PREV 278
|
||||
#define TK_NULL_F 279
|
||||
#define TK_LINEAR 280
|
||||
#define TK_NEXT 281
|
||||
#define TK_HAVING 282
|
||||
#define TK_RANGE 283
|
||||
#define TK_EVERY 284
|
||||
#define TK_ORDER 285
|
||||
#define TK_SLIMIT 286
|
||||
#define TK_SOFFSET 287
|
||||
#define TK_LIMIT 288
|
||||
#define TK_OFFSET 289
|
||||
#define TK_ASC 290
|
||||
#define TK_NULLS 291
|
||||
#define TK_ABORT 292
|
||||
#define TK_AFTER 293
|
||||
#define TK_ATTACH 294
|
||||
#define TK_BEFORE 295
|
||||
#define TK_BEGIN 296
|
||||
#define TK_BITAND 297
|
||||
#define TK_BITNOT 298
|
||||
#define TK_BITOR 299
|
||||
#define TK_BLOCKS 300
|
||||
#define TK_CHANGE 301
|
||||
#define TK_COMMA 302
|
||||
#define TK_CONCAT 303
|
||||
#define TK_CONFLICT 304
|
||||
#define TK_COPY 305
|
||||
#define TK_DEFERRED 306
|
||||
#define TK_DELIMITERS 307
|
||||
#define TK_DETACH 308
|
||||
#define TK_DIVIDE 309
|
||||
#define TK_DOT 310
|
||||
#define TK_EACH 311
|
||||
#define TK_FAIL 312
|
||||
#define TK_FILE 313
|
||||
#define TK_FOR 314
|
||||
#define TK_GLOB 315
|
||||
#define TK_ID 316
|
||||
#define TK_IMMEDIATE 317
|
||||
#define TK_IMPORT 318
|
||||
#define TK_INITIALLY 319
|
||||
#define TK_INSTEAD 320
|
||||
#define TK_ISNULL 321
|
||||
#define TK_KEY 322
|
||||
#define TK_MODULES 323
|
||||
#define TK_NK_BITNOT 324
|
||||
#define TK_NK_SEMI 325
|
||||
#define TK_NOTNULL 326
|
||||
#define TK_OF 327
|
||||
#define TK_PLUS 328
|
||||
#define TK_PRIVILEGE 329
|
||||
#define TK_RAISE 330
|
||||
#define TK_RESTRICT 331
|
||||
#define TK_ROW 332
|
||||
#define TK_SEMI 333
|
||||
#define TK_STAR 334
|
||||
#define TK_STATEMENT 335
|
||||
#define TK_STRICT 336
|
||||
#define TK_STRING 337
|
||||
#define TK_TIMES 338
|
||||
#define TK_VALUES 339
|
||||
#define TK_VARIABLE 340
|
||||
#define TK_VIEW 341
|
||||
#define TK_WAL 342
|
||||
|
||||
#define TK_NK_SPACE 600
|
||||
#define TK_NK_COMMENT 601
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
typedef struct SExplainCtx SExplainCtx;
|
||||
|
||||
int32_t qExecCommand(int64_t* pConnId, bool sysInfoUser, SNode *pStmt, SRetrieveTableRsp **pRsp);
|
||||
int32_t qExecCommand(int64_t* pConnId, bool sysInfoUser, SNode *pStmt, SRetrieveTableRsp **pRsp, int8_t biMode);
|
||||
|
||||
int32_t qExecStaticExplain(SQueryPlan *pDag, SRetrieveTableRsp **pRsp);
|
||||
int32_t qExecExplainBegin(SQueryPlan *pDag, SExplainCtx **pCtx, int64_t startTs);
|
||||
|
|
|
@ -273,6 +273,7 @@ typedef struct SShowStmt {
|
|||
SNode* pDbName; // SValueNode
|
||||
SNode* pTbName; // SValueNode
|
||||
EOperatorType tableCondType;
|
||||
EShowKind showKind; // show databases: user/system, show tables: normal/child, others NULL
|
||||
} SShowStmt;
|
||||
|
||||
typedef struct SShowCreateDatabaseStmt {
|
||||
|
|
|
@ -277,6 +277,14 @@ typedef enum ETimeLineMode {
|
|||
TIME_LINE_GLOBAL,
|
||||
} ETimeLineMode;
|
||||
|
||||
typedef enum EShowKind {
|
||||
SHOW_KIND_ALL = 1,
|
||||
SHOW_KIND_TABLES_NORMAL,
|
||||
SHOW_KIND_TABLES_CHILD,
|
||||
SHOW_KIND_DATABASES_USER,
|
||||
SHOW_KIND_DATABASES_SYSTEM
|
||||
} EShowKind;
|
||||
|
||||
typedef struct SFillNode {
|
||||
ENodeType type; // QUERY_NODE_FILL
|
||||
EFillMode mode;
|
||||
|
@ -519,6 +527,8 @@ void* nodesGetValueFromNode(SValueNode* pNode);
|
|||
int32_t nodesSetValueNodeValue(SValueNode* pNode, void* value);
|
||||
char* nodesGetStrValueFromNode(SValueNode* pNode);
|
||||
void nodesValueNodeToVariant(const SValueNode* pNode, SVariant* pVal);
|
||||
SValueNode* nodesMakeValueNodeFromString(char* literal);
|
||||
SValueNode* nodesMakeValueNodeFromBool(bool b);
|
||||
|
||||
char* nodesGetFillModeString(EFillMode mode);
|
||||
int32_t nodesMergeConds(SNode** pDst, SNodeList** pSrc);
|
||||
|
|
|
@ -64,6 +64,7 @@ typedef struct SParseContext {
|
|||
SArray* pTableMetaPos; // sql table pos => catalog data pos
|
||||
SArray* pTableVgroupPos; // sql table pos => catalog data pos
|
||||
int64_t allocatorId;
|
||||
int32_t biMode;
|
||||
} SParseContext;
|
||||
|
||||
int32_t qParseSql(SParseContext* pCxt, SQuery** pQuery);
|
||||
|
|
|
@ -22,6 +22,15 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS) && !defined(__USE_PTHREAD)
|
||||
#include <windows.h>
|
||||
#define __USE_WIN_THREAD
|
||||
// https://learn.microsoft.com/en-us/windows/win32/winprog/using-the-windows-headers
|
||||
// #ifndef _WIN32_WINNT
|
||||
// #define _WIN32_WINNT 0x0600
|
||||
// #endif
|
||||
#endif
|
||||
|
||||
#if !defined(WINDOWS) && !defined(_ALPINE)
|
||||
#ifndef __USE_XOPEN2K
|
||||
#define TD_USE_SPINLOCK_AS_MUTEX
|
||||
|
@ -29,6 +38,22 @@ typedef pthread_mutex_t pthread_spinlock_t;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __USE_WIN_THREAD
|
||||
typedef pthread_t TdThread; // pthread api
|
||||
typedef pthread_spinlock_t TdThreadSpinlock; // pthread api
|
||||
typedef CRITICAL_SECTION TdThreadMutex; // windows api
|
||||
typedef HANDLE TdThreadMutexAttr; // windows api
|
||||
typedef struct {
|
||||
SRWLOCK lock;
|
||||
int8_t excl;
|
||||
} TdThreadRwlock; // pthread api
|
||||
typedef pthread_attr_t TdThreadAttr; // pthread api
|
||||
typedef pthread_once_t TdThreadOnce; // pthread api
|
||||
typedef HANDLE TdThreadRwlockAttr; // windows api
|
||||
typedef CONDITION_VARIABLE TdThreadCond; // windows api
|
||||
typedef HANDLE TdThreadCondAttr; // windows api
|
||||
typedef pthread_key_t TdThreadKey; // pthread api
|
||||
#else
|
||||
typedef pthread_t TdThread;
|
||||
typedef pthread_spinlock_t TdThreadSpinlock;
|
||||
typedef pthread_mutex_t TdThreadMutex;
|
||||
|
@ -40,11 +65,14 @@ typedef pthread_rwlockattr_t TdThreadRwlockAttr;
|
|||
typedef pthread_cond_t TdThreadCond;
|
||||
typedef pthread_condattr_t TdThreadCondAttr;
|
||||
typedef pthread_key_t TdThreadKey;
|
||||
#endif
|
||||
|
||||
#define taosThreadCleanupPush pthread_cleanup_push
|
||||
#define taosThreadCleanupPop pthread_cleanup_pop
|
||||
|
||||
#ifdef WINDOWS
|
||||
#if defined(WINDOWS) && !defined(__USE_PTHREAD)
|
||||
#define TD_PTHREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER_FORBID
|
||||
#elif defined(WINDOWS)
|
||||
#define TD_PTHREAD_MUTEX_INITIALIZER (TdThreadMutex)(-1)
|
||||
#else
|
||||
#define TD_PTHREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
|
||||
|
|
|
@ -152,6 +152,7 @@ typedef struct STscObj {
|
|||
int8_t sysInfo;
|
||||
int8_t connType;
|
||||
int8_t dropped;
|
||||
int8_t biMode;
|
||||
int32_t acctId;
|
||||
uint32_t connId;
|
||||
int64_t id; // ref ID returned by taosAddRef
|
||||
|
|
|
@ -297,7 +297,8 @@ int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtC
|
|||
|
||||
int32_t execLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
|
||||
SRetrieveTableRsp* pRsp = NULL;
|
||||
int32_t code = qExecCommand(&pRequest->pTscObj->id, pRequest->pTscObj->sysInfo, pQuery->pRoot, &pRsp);
|
||||
int8_t biMode = atomic_load_8(&pRequest->pTscObj->biMode);
|
||||
int32_t code = qExecCommand(&pRequest->pTscObj->id, pRequest->pTscObj->sysInfo, pQuery->pRoot, &pRsp, biMode);
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pRsp) {
|
||||
code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, false, true);
|
||||
}
|
||||
|
@ -335,7 +336,7 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
|
|||
return;
|
||||
}
|
||||
|
||||
int32_t code = qExecCommand(&pRequest->pTscObj->id, pRequest->pTscObj->sysInfo, pQuery->pRoot, &pRsp);
|
||||
int32_t code = qExecCommand(&pRequest->pTscObj->id, pRequest->pTscObj->sysInfo, pQuery->pRoot, &pRsp, atomic_load_8(&pRequest->pTscObj->biMode));
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pRsp) {
|
||||
code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, false, true);
|
||||
}
|
||||
|
@ -2553,6 +2554,14 @@ static void fetchCallback(void* pResult, void* param, int32_t code) {
|
|||
}
|
||||
|
||||
void taosAsyncFetchImpl(SRequestObj* pRequest, __taos_async_fn_t fp, void* param) {
|
||||
if (pRequest->syncQuery && pRequest->body.param != param) {
|
||||
if (pRequest->body.param) {
|
||||
tsem_destroy(&((SSyncQueryParam *)pRequest->body.param)->sem);
|
||||
}
|
||||
taosMemoryFree(pRequest->body.param);
|
||||
pRequest->syncQuery = false;
|
||||
}
|
||||
|
||||
pRequest->body.fetchFp = fp;
|
||||
pRequest->body.param = param;
|
||||
|
||||
|
|
|
@ -1173,6 +1173,8 @@ int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt) {
|
|||
.svrVer = pTscObj->sVer,
|
||||
.nodeOffline = (pTscObj->pAppInfo->onlineDnodes < pTscObj->pAppInfo->totalDnodes),
|
||||
.allocatorId = pRequest->allocatorRefId};
|
||||
int8_t biMode = atomic_load_8(&((STscObj *)pTscObj)->biMode);
|
||||
(*pCxt)->biMode = biMode;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1836,3 +1838,26 @@ int taos_stmt_close(TAOS_STMT *stmt) {
|
|||
|
||||
return stmtClose(stmt);
|
||||
}
|
||||
|
||||
int taos_set_conn_mode(TAOS* taos, int mode, int value) {
|
||||
if (taos == NULL) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
STscObj *pObj = acquireTscObj(*(int64_t *)taos);
|
||||
if (NULL == pObj) {
|
||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||
tscError("invalid parameter for %s", __func__);
|
||||
return terrno;
|
||||
}
|
||||
switch (mode) {
|
||||
case TAOS_CONN_MODE_BI:
|
||||
atomic_store_8(&pObj->biMode, value);
|
||||
break;
|
||||
default:
|
||||
tscError("not supported mode.");
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -35,7 +35,6 @@ int32_t mndCheckTopicPrivilegeByName(SMnode *pMnode, const char *user, EOperType
|
|||
}
|
||||
|
||||
|
||||
// TODO: for community version use the commented version
|
||||
int32_t mndSetUserWhiteListRsp(SMnode *pMnode, SUserObj *pUser, SGetUserWhiteListRsp *pWhiteListRsp) {
|
||||
memcpy(pWhiteListRsp->user, pUser->user, TSDB_USER_LEN);
|
||||
pWhiteListRsp->numWhiteLists = 1;
|
||||
|
@ -44,6 +43,9 @@ int32_t mndSetUserWhiteListRsp(SMnode *pMnode, SUserObj *pUser, SGetUserWhiteLis
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
memset(pWhiteListRsp->pWhiteLists, 0, pWhiteListRsp->numWhiteLists * sizeof(SIpV4Range));
|
||||
|
||||
// if (tsEnableWhiteList) {
|
||||
// memcpy(pWhiteListRsp->user, pUser->user, TSDB_USER_LEN);
|
||||
// pWhiteListRsp->numWhiteLists = pUser->pIpWhiteList->num;
|
||||
// pWhiteListRsp->pWhiteLists = taosMemoryMalloc(pWhiteListRsp->numWhiteLists * sizeof(SIpV4Range));
|
||||
// if (pWhiteListRsp->pWhiteLists == NULL) {
|
||||
|
@ -51,6 +53,15 @@ int32_t mndSetUserWhiteListRsp(SMnode *pMnode, SUserObj *pUser, SGetUserWhiteLis
|
|||
// }
|
||||
// memcpy(pWhiteListRsp->pWhiteLists, pUser->pIpWhiteList->pIpRange,
|
||||
// pWhiteListRsp->numWhiteLists * sizeof(SIpV4Range));
|
||||
// } else {
|
||||
// memcpy(pWhiteListRsp->user, pUser->user, TSDB_USER_LEN);
|
||||
// pWhiteListRsp->numWhiteLists = 1;
|
||||
// pWhiteListRsp->pWhiteLists = taosMemoryMalloc(pWhiteListRsp->numWhiteLists * sizeof(SIpV4Range));
|
||||
// if (pWhiteListRsp->pWhiteLists == NULL) {
|
||||
// return TSDB_CODE_OUT_OF_MEMORY;
|
||||
// }
|
||||
// memset(pWhiteListRsp->pWhiteLists, 0, pWhiteListRsp->numWhiteLists * sizeof(SIpV4Range));
|
||||
// }
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -88,8 +88,9 @@ static int32_t buildDescResultDataBlock(SSDataBlock** pOutput) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t setDescResultIntoDataBlock(bool sysInfoUser, SSDataBlock* pBlock, int32_t numOfRows, STableMeta* pMeta) {
|
||||
blockDataEnsureCapacity(pBlock, numOfRows);
|
||||
static int32_t setDescResultIntoDataBlock(bool sysInfoUser, SSDataBlock* pBlock, int32_t numOfRows, STableMeta* pMeta, int8_t biMode) {
|
||||
int32_t blockCap = (biMode != 0) ? numOfRows + 1 : numOfRows;
|
||||
blockDataEnsureCapacity(pBlock, blockCap);
|
||||
pBlock->info.rows = 0;
|
||||
|
||||
// field
|
||||
|
@ -115,6 +116,17 @@ static int32_t setDescResultIntoDataBlock(bool sysInfoUser, SSDataBlock* pBlock,
|
|||
colDataSetVal(pCol4, pBlock->info.rows, buf, false);
|
||||
++(pBlock->info.rows);
|
||||
}
|
||||
if (pMeta->tableType == TSDB_SUPER_TABLE && biMode != 0) {
|
||||
STR_TO_VARSTR(buf, "tbname");
|
||||
colDataSetVal(pCol1, pBlock->info.rows, buf, false);
|
||||
STR_TO_VARSTR(buf, "VARCHAR");
|
||||
colDataSetVal(pCol2, pBlock->info.rows, buf, false);
|
||||
int32_t bytes = TSDB_TABLE_NAME_LEN - 1;
|
||||
colDataSetVal(pCol3, pBlock->info.rows, (const char*)&bytes, false);
|
||||
STR_TO_VARSTR(buf, "TAG");
|
||||
colDataSetVal(pCol4, pBlock->info.rows, buf, false);
|
||||
++(pBlock->info.rows);
|
||||
}
|
||||
if (pBlock->info.rows <= 0) {
|
||||
qError("no permission to view any columns");
|
||||
return TSDB_CODE_PAR_PERMISSION_DENIED;
|
||||
|
@ -122,14 +134,14 @@ static int32_t setDescResultIntoDataBlock(bool sysInfoUser, SSDataBlock* pBlock,
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t execDescribe(bool sysInfoUser, SNode* pStmt, SRetrieveTableRsp** pRsp) {
|
||||
static int32_t execDescribe(bool sysInfoUser, SNode* pStmt, SRetrieveTableRsp** pRsp, int8_t biMode) {
|
||||
SDescribeStmt* pDesc = (SDescribeStmt*)pStmt;
|
||||
int32_t numOfRows = TABLE_TOTAL_COL_NUM(pDesc->pMeta);
|
||||
|
||||
SSDataBlock* pBlock = NULL;
|
||||
int32_t code = buildDescResultDataBlock(&pBlock);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = setDescResultIntoDataBlock(sysInfoUser, pBlock, numOfRows, pDesc->pMeta);
|
||||
code = setDescResultIntoDataBlock(sysInfoUser, pBlock, numOfRows, pDesc->pMeta, biMode);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = buildRetrieveTableRsp(pBlock, DESCRIBE_RESULT_COLS, pRsp);
|
||||
|
@ -926,10 +938,10 @@ static int32_t execSelectWithoutFrom(SSelectStmt* pSelect, SRetrieveTableRsp** p
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t qExecCommand(int64_t* pConnId, bool sysInfoUser, SNode* pStmt, SRetrieveTableRsp** pRsp) {
|
||||
int32_t qExecCommand(int64_t* pConnId, bool sysInfoUser, SNode* pStmt, SRetrieveTableRsp** pRsp, int8_t biMode) {
|
||||
switch (nodeType(pStmt)) {
|
||||
case QUERY_NODE_DESCRIBE_STMT:
|
||||
return execDescribe(sysInfoUser, pStmt, pRsp);
|
||||
return execDescribe(sysInfoUser, pStmt, pRsp, biMode);
|
||||
case QUERY_NODE_RESET_QUERY_CACHE_STMT:
|
||||
return execResetQueryCache();
|
||||
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
||||
|
|
|
@ -2284,3 +2284,37 @@ const char* dataOrderStr(EDataOrderLevel order) {
|
|||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
SValueNode* nodesMakeValueNodeFromString(char* literal) {
|
||||
int32_t lenStr = strlen(literal);
|
||||
SValueNode* pValNode = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
if (pValNode) {
|
||||
pValNode->node.resType.type = TSDB_DATA_TYPE_VARCHAR;
|
||||
pValNode->node.resType.bytes = lenStr + VARSTR_HEADER_SIZE;
|
||||
char* p = taosMemoryMalloc(lenStr + 1 + VARSTR_HEADER_SIZE);
|
||||
if (p == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
varDataSetLen(p, lenStr);
|
||||
memcpy(varDataVal(p), literal, lenStr + 1);
|
||||
pValNode->datum.p = p;
|
||||
pValNode->literal = tstrdup(literal);
|
||||
pValNode->translate = true;
|
||||
pValNode->isDuration = false;
|
||||
pValNode->isNull = false;
|
||||
}
|
||||
return pValNode;
|
||||
}
|
||||
|
||||
SValueNode* nodesMakeValueNodeFromBool(bool b) {
|
||||
SValueNode* pValNode = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
if (pValNode) {
|
||||
pValNode->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||
pValNode->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
|
||||
nodesSetValueNodeValue(pValNode, &b);
|
||||
pValNode->translate = true;
|
||||
pValNode->isDuration = false;
|
||||
pValNode->isNull = false;
|
||||
}
|
||||
return pValNode;
|
||||
}
|
|
@ -87,6 +87,11 @@ typedef struct STokenPair {
|
|||
SToken second;
|
||||
} STokenPair;
|
||||
|
||||
typedef struct SShowTablesOption {
|
||||
EShowKind kind;
|
||||
SToken dbName;
|
||||
} SShowTablesOption;
|
||||
|
||||
extern SToken nil_token;
|
||||
|
||||
void initAstCreateContext(SParseContext* pParseCxt, SAstCreateContext* pCxt);
|
||||
|
@ -181,9 +186,11 @@ SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int
|
|||
SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, SToken* pTagName, SNode* pVal);
|
||||
SNode* setAlterSuperTableType(SNode* pStmt);
|
||||
SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName);
|
||||
SNode* setShowKind(SAstCreateContext* pCxt, SNode* pStmt, EShowKind showKind);
|
||||
SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type);
|
||||
SNode* createShowStmtWithCond(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbName,
|
||||
EOperatorType tableCondType);
|
||||
SNode* createShowTablesStmt(SAstCreateContext* pCxt, SShowTablesOption option, SNode* pTbName, EOperatorType tableCondType);
|
||||
SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName);
|
||||
SNode* createShowAliveStmt(SAstCreateContext* pCxt, SNode* pDbName, ENodeType type);
|
||||
SNode* createShowCreateTableStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pRealTable);
|
||||
|
|
|
@ -458,8 +458,13 @@ col_name(A) ::= column_name(B).
|
|||
cmd ::= SHOW DNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); }
|
||||
cmd ::= SHOW USERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); }
|
||||
cmd ::= SHOW USER PRIVILEGES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USER_PRIVILEGES_STMT); }
|
||||
cmd ::= SHOW DATABASES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); }
|
||||
cmd ::= SHOW db_name_cond_opt(A) TABLES like_pattern_opt(B). { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, A, B, OP_TYPE_LIKE); }
|
||||
cmd ::= SHOW db_kind_opt(A) DATABASES. {
|
||||
pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT);
|
||||
setShowKind(pCxt, pCxt->pRootNode, A);
|
||||
}
|
||||
cmd ::= SHOW table_kind_db_name_cond_opt(A) TABLES like_pattern_opt(B). {
|
||||
pCxt->pRootNode = createShowTablesStmt(pCxt, A, B, OP_TYPE_LIKE);
|
||||
}
|
||||
cmd ::= SHOW db_name_cond_opt(A) STABLES like_pattern_opt(B). { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, A, B, OP_TYPE_LIKE); }
|
||||
cmd ::= SHOW db_name_cond_opt(A) VGROUPS. { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, A, NULL, OP_TYPE_LIKE); }
|
||||
cmd ::= SHOW MNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); }
|
||||
|
@ -501,6 +506,18 @@ cmd ::= SHOW VNODES.
|
|||
cmd ::= SHOW db_name_cond_opt(A) ALIVE. { pCxt->pRootNode = createShowAliveStmt(pCxt, A, QUERY_NODE_SHOW_DB_ALIVE_STMT); }
|
||||
cmd ::= SHOW CLUSTER ALIVE. { pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); }
|
||||
|
||||
%type table_kind_db_name_cond_opt { SShowTablesOption }
|
||||
%destructor table_kind_db_name_cond_opt { }
|
||||
table_kind_db_name_cond_opt(A) ::= . { A.kind = SHOW_KIND_ALL; A.dbName = nil_token; }
|
||||
table_kind_db_name_cond_opt(A) ::= table_kind(B). { A.kind = B; A.dbName = nil_token; }
|
||||
table_kind_db_name_cond_opt(A) ::= db_name(C) NK_DOT. { A.kind = SHOW_KIND_ALL; A.dbName = C; }
|
||||
table_kind_db_name_cond_opt(A) ::= table_kind(B) db_name(C) NK_DOT. { A.kind = B; A.dbName = C; }
|
||||
|
||||
%type table_kind { EShowKind }
|
||||
%destructor table_kind { }
|
||||
table_kind(A) ::= NORMAL. { A = SHOW_KIND_TABLES_NORMAL; }
|
||||
table_kind(A) ::= CHILD. { A = SHOW_KIND_TABLES_CHILD; }
|
||||
|
||||
db_name_cond_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); }
|
||||
db_name_cond_opt(A) ::= db_name(B) NK_DOT. { A = createIdentifierValueNode(pCxt, &B); }
|
||||
|
||||
|
@ -524,6 +541,12 @@ tag_item(A) ::= column_name(B).
|
|||
tag_item(A) ::= column_name(B) column_alias(C). { A = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &B), &C); }
|
||||
tag_item(A) ::= column_name(B) AS column_alias(C). { A = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &B), &C); }
|
||||
|
||||
%type db_kind_opt { EShowKind }
|
||||
%destructor db_kind_opt { }
|
||||
db_kind_opt(A) ::= . { A = SHOW_KIND_ALL; }
|
||||
db_kind_opt(A) ::= USER. { A = SHOW_KIND_DATABASES_USER; }
|
||||
db_kind_opt(A) ::= SYSTEM. { A = SHOW_KIND_DATABASES_SYSTEM; }
|
||||
|
||||
/************************************************ create index ********************************************************/
|
||||
cmd ::= CREATE SMA INDEX not_exists_opt(D)
|
||||
col_name(A) ON full_table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, A, B, NULL, C); }
|
||||
|
|
|
@ -1552,6 +1552,15 @@ SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type) {
|
|||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* setShowKind(SAstCreateContext* pCxt, SNode* pStmt, EShowKind showKind) {
|
||||
if (pStmt == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
SShowStmt* pShow = (SShowStmt*)pStmt;
|
||||
pShow->showKind = showKind;
|
||||
return pStmt;
|
||||
}
|
||||
|
||||
SNode* createShowStmtWithCond(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbName,
|
||||
EOperatorType tableCondType) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
|
@ -1568,6 +1577,19 @@ SNode* createShowStmtWithCond(SAstCreateContext* pCxt, ENodeType type, SNode* pD
|
|||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createShowTablesStmt(SAstCreateContext* pCxt, SShowTablesOption option, SNode* pTbName, EOperatorType tableCondType) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SNode* pDbName = NULL;
|
||||
if (option.dbName.type == TK_NK_NIL) {
|
||||
pDbName = createDefaultDatabaseCondValue(pCxt);
|
||||
} else {
|
||||
pDbName = createIdentifierValueNode(pCxt, &option.dbName);
|
||||
}
|
||||
SNode* pStmt = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, pDbName, pTbName, tableCondType);
|
||||
setShowKind(pCxt, pStmt, option.kind);
|
||||
return pStmt;
|
||||
}
|
||||
|
||||
SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
if (!checkDbName(pCxt, pDbName, true)) {
|
||||
|
|
|
@ -57,6 +57,7 @@ static SKeyword keywordTable[] = {
|
|||
{"CACHESIZE", TK_CACHESIZE},
|
||||
{"CASE", TK_CASE},
|
||||
{"CAST", TK_CAST},
|
||||
{"CHILD", TK_CHILD},
|
||||
{"CLIENT_VERSION", TK_CLIENT_VERSION},
|
||||
{"CLUSTER", TK_CLUSTER},
|
||||
{"COLUMN", TK_COLUMN},
|
||||
|
@ -149,6 +150,7 @@ static SKeyword keywordTable[] = {
|
|||
{"MNODES", TK_MNODES},
|
||||
{"MODIFY", TK_MODIFY},
|
||||
{"MODULES", TK_MODULES},
|
||||
{"NORMAL", TK_NORMAL},
|
||||
{"NCHAR", TK_NCHAR},
|
||||
{"NEXT", TK_NEXT},
|
||||
{"NMATCH", TK_NMATCH},
|
||||
|
@ -224,6 +226,7 @@ static SKeyword keywordTable[] = {
|
|||
{"SUBSCRIPTIONS", TK_SUBSCRIPTIONS},
|
||||
{"SUBTABLE", TK_SUBTABLE},
|
||||
{"SYSINFO", TK_SYSINFO},
|
||||
{"SYSTEM", TK_SYSTEM},
|
||||
{"TABLE", TK_TABLE},
|
||||
{"TABLES", TK_TABLES},
|
||||
{"TABLE_PREFIX", TK_TABLE_PREFIX},
|
||||
|
|
|
@ -7997,12 +7997,12 @@ static const char* getTbNameColName(ENodeType type) {
|
|||
return (QUERY_NODE_SHOW_STABLES_STMT == type ? "stable_name" : "table_name");
|
||||
}
|
||||
|
||||
static int32_t createLogicCondNode(SNode* pCond1, SNode* pCond2, SNode** pCond) {
|
||||
static int32_t createLogicCondNode(SNode* pCond1, SNode* pCond2, SNode** pCond, ELogicConditionType logicCondType) {
|
||||
SLogicConditionNode* pCondition = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
if (NULL == pCondition) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCondition->condType = LOGIC_COND_TYPE_AND;
|
||||
pCondition->condType = logicCondType;
|
||||
pCondition->pParameterList = nodesMakeList();
|
||||
if (NULL == pCondition->pParameterList) {
|
||||
nodesDestroyNode((SNode*)pCondition);
|
||||
|
@ -8018,6 +8018,87 @@ static int32_t createLogicCondNode(SNode* pCond1, SNode* pCond2, SNode** pCond)
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t insertCondIntoSelectStmt(SSelectStmt* pSelect, SNode* pCond) {
|
||||
if (pSelect->pWhere == NULL) {
|
||||
pSelect->pWhere = pCond;
|
||||
} else {
|
||||
SNode* pWhere = NULL;
|
||||
createLogicCondNode(pSelect->pWhere, pCond, &pWhere, LOGIC_COND_TYPE_AND);
|
||||
pSelect->pWhere = pWhere;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t addShowUserDatabasesCond(SSelectStmt* pSelect) {
|
||||
SNode* pNameCond1 = NULL;
|
||||
SNode* pNameCond2 = NULL;
|
||||
SValueNode* pValNode1 = nodesMakeValueNodeFromString(TSDB_INFORMATION_SCHEMA_DB);
|
||||
SValueNode* pValNode2 = nodesMakeValueNodeFromString(TSDB_PERFORMANCE_SCHEMA_DB);
|
||||
createOperatorNode(OP_TYPE_NOT_EQUAL, "name", (SNode*)pValNode1, &pNameCond1);
|
||||
createOperatorNode(OP_TYPE_NOT_EQUAL, "name", (SNode*)pValNode2, &pNameCond2);
|
||||
nodesDestroyNode((SNode*)pValNode2);
|
||||
nodesDestroyNode((SNode*)pValNode1);
|
||||
SNode* pNameCond = NULL;
|
||||
createLogicCondNode(pNameCond1, pNameCond2, &pNameCond, LOGIC_COND_TYPE_AND);
|
||||
insertCondIntoSelectStmt(pSelect, pNameCond);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t addShowSystemDatabasesCond(SSelectStmt* pSelect) {
|
||||
SNode* pNameCond1 = NULL;
|
||||
SNode* pNameCond2 = NULL;
|
||||
SValueNode* pValNode1 = nodesMakeValueNodeFromString(TSDB_INFORMATION_SCHEMA_DB);
|
||||
SValueNode* pValNode2 = nodesMakeValueNodeFromString(TSDB_PERFORMANCE_SCHEMA_DB);
|
||||
createOperatorNode(OP_TYPE_EQUAL, "name", (SNode*)pValNode1, &pNameCond1);
|
||||
createOperatorNode(OP_TYPE_EQUAL, "name", (SNode*)pValNode2, &pNameCond2);
|
||||
nodesDestroyNode((SNode*)pValNode2);
|
||||
nodesDestroyNode((SNode*)pValNode1);
|
||||
SNode* pNameCond = NULL;
|
||||
createLogicCondNode(pNameCond1, pNameCond2, &pNameCond, LOGIC_COND_TYPE_OR);
|
||||
insertCondIntoSelectStmt(pSelect, pNameCond);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t addShowNormalTablesCond(SSelectStmt* pSelect) {
|
||||
SNode* pTypeCond = NULL;
|
||||
SValueNode* pValNode1 = nodesMakeValueNodeFromString("NORMAL_TABLE");
|
||||
createOperatorNode(OP_TYPE_EQUAL, "type", (SNode*)pValNode1, &pTypeCond);
|
||||
nodesDestroyNode((SNode*)pValNode1);
|
||||
insertCondIntoSelectStmt(pSelect, pTypeCond);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t addShowChildTablesCond(SSelectStmt* pSelect) {
|
||||
SNode* pTypeCond = NULL;
|
||||
SValueNode* pValNode1 = nodesMakeValueNodeFromString("CHILD_TABLE");
|
||||
createOperatorNode(OP_TYPE_EQUAL, "type", (SNode*)pValNode1, &pTypeCond);
|
||||
nodesDestroyNode((SNode*)pValNode1);
|
||||
insertCondIntoSelectStmt(pSelect, pTypeCond);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t addShowKindCond(const SShowStmt* pShow, SSelectStmt* pSelect) {
|
||||
if (pShow->type != QUERY_NODE_SHOW_DATABASES_STMT && pShow->type != QUERY_NODE_SHOW_TABLES_STMT ||
|
||||
pShow->showKind == SHOW_KIND_ALL) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
if (pShow->type == QUERY_NODE_SHOW_DATABASES_STMT) {
|
||||
if (pShow->showKind == SHOW_KIND_DATABASES_USER) {
|
||||
addShowUserDatabasesCond(pSelect);
|
||||
} else if (pShow->showKind == SHOW_KIND_DATABASES_SYSTEM) {
|
||||
addShowSystemDatabasesCond(pSelect);
|
||||
}
|
||||
} else if (pShow->type == QUERY_NODE_SHOW_TABLES_STMT) {
|
||||
if (pShow->showKind == SHOW_KIND_TABLES_NORMAL) {
|
||||
addShowNormalTablesCond(pSelect);
|
||||
} else if (pShow->showKind == SHOW_KIND_TABLES_CHILD) {
|
||||
addShowChildTablesCond(pSelect);
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int32_t createShowCondition(const SShowStmt* pShow, SSelectStmt* pSelect) {
|
||||
SNode* pDbCond = NULL;
|
||||
SNode* pTbCond = NULL;
|
||||
|
@ -8030,7 +8111,7 @@ static int32_t createShowCondition(const SShowStmt* pShow, SSelectStmt* pSelect)
|
|||
}
|
||||
|
||||
if (NULL != pDbCond && NULL != pTbCond) {
|
||||
if (TSDB_CODE_SUCCESS != createLogicCondNode(pDbCond, pTbCond, &pSelect->pWhere)) {
|
||||
if (TSDB_CODE_SUCCESS != createLogicCondNode(pDbCond, pTbCond, &pSelect->pWhere, LOGIC_COND_TYPE_AND)) {
|
||||
nodesDestroyNode(pDbCond);
|
||||
nodesDestroyNode(pTbCond);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -8039,6 +8120,11 @@ static int32_t createShowCondition(const SShowStmt* pShow, SSelectStmt* pSelect)
|
|||
pSelect->pWhere = (NULL == pDbCond ? pTbCond : pDbCond);
|
||||
}
|
||||
|
||||
int32_t code = addShowKindCond(pShow, pSelect);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
if (NULL != pShow->pDbName) {
|
||||
strcpy(((SRealTableNode*)pSelect->pFromTable)->qualDbName, ((SValueNode*)pShow->pDbName)->literal);
|
||||
}
|
||||
|
@ -8132,7 +8218,7 @@ static int32_t rewriteShowDnodeVariables(STranslateContext* pCxt, SQuery* pQuery
|
|||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (NULL != pLikeCond) {
|
||||
code = createLogicCondNode(pDnodeCond, pLikeCond, &pSelect->pWhere);
|
||||
code = createLogicCondNode(pDnodeCond, pLikeCond, &pSelect->pWhere, LOGIC_COND_TYPE_AND);
|
||||
} else {
|
||||
pSelect->pWhere = pDnodeCond;
|
||||
}
|
||||
|
@ -9451,6 +9537,11 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t rewriteQueryForBI(STranslateContext* pParseCxt, SQuery* pQuery) {
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t translate(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMetaCache) {
|
||||
STranslateContext cxt = {0};
|
||||
|
||||
|
@ -9458,9 +9549,13 @@ int32_t translate(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMe
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = rewriteQuery(&cxt, pQuery);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code && pParseCxt->biMode != 0) {
|
||||
code = rewriteQueryForBI(&cxt, pQuery);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = translateQuery(&cxt, pQuery->pRoot);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code && (cxt.pPrevRoot || cxt.pPostRoot)) {
|
||||
pQuery->pPrevRoot = cxt.pPrevRoot;
|
||||
pQuery->pPostRoot = cxt.pPostRoot;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -456,10 +456,18 @@ int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset)
|
|||
return -1;
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
size_t pos = _lseeki64(pFile->fd, 0, SEEK_CUR);
|
||||
_lseeki64(pFile->fd, offset, SEEK_SET);
|
||||
int64_t ret = _read(pFile->fd, buf, count);
|
||||
_lseeki64(pFile->fd, pos, SEEK_SET);
|
||||
DWORD ret = 0;
|
||||
OVERLAPPED ol = {0};
|
||||
ol.OffsetHigh = (uint32_t)((offset & 0xFFFFFFFF00000000LL) >> 0x20);
|
||||
ol.Offset = (uint32_t)(offset & 0xFFFFFFFFLL);
|
||||
|
||||
HANDLE handle = (HANDLE)_get_osfhandle(pFile->fd);
|
||||
SetLastError(0);
|
||||
BOOL result = ReadFile(handle, buf, count, &ret, &ol);
|
||||
if (!result && GetLastError() != ERROR_HANDLE_EOF) {
|
||||
errno = GetLastError();
|
||||
ret = -1;
|
||||
}
|
||||
#else
|
||||
int64_t ret = pread(pFile->fd, buf, count, offset);
|
||||
#endif
|
||||
|
@ -523,10 +531,18 @@ int64_t taosPWriteFile(TdFilePtr pFile, const void *buf, int64_t count, int64_t
|
|||
return 0;
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
size_t pos = _lseeki64(pFile->fd, 0, SEEK_CUR);
|
||||
_lseeki64(pFile->fd, offset, SEEK_SET);
|
||||
int64_t ret = _write(pFile->fd, buf, count);
|
||||
_lseeki64(pFile->fd, pos, SEEK_SET);
|
||||
DWORD ret = 0;
|
||||
OVERLAPPED ol = {0};
|
||||
ol.OffsetHigh = (uint32_t)((offset & 0xFFFFFFFF00000000LL) >> 0x20);
|
||||
ol.Offset = (uint32_t)(offset & 0xFFFFFFFFLL);
|
||||
|
||||
HANDLE handle = (HANDLE)_get_osfhandle(pFile->fd);
|
||||
SetLastError(0);
|
||||
BOOL result = WriteFile(handle, buf, count, &ret, &ol);
|
||||
if (!result) {
|
||||
errno = GetLastError();
|
||||
ret = -1;
|
||||
}
|
||||
#else
|
||||
int64_t ret = pwrite(pFile->fd, buf, count, offset);
|
||||
#endif
|
||||
|
|
|
@ -84,34 +84,98 @@ int32_t taosThreadAttrSetStackSize(TdThreadAttr *attr, size_t stacksize) {
|
|||
|
||||
int32_t taosThreadCancel(TdThread thread) { return pthread_cancel(thread); }
|
||||
|
||||
int32_t taosThreadCondDestroy(TdThreadCond *cond) { return pthread_cond_destroy(cond); }
|
||||
int32_t taosThreadCondDestroy(TdThreadCond *cond) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
return 0;
|
||||
#else
|
||||
return pthread_cond_destroy(cond);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadCondInit(TdThreadCond *cond, const TdThreadCondAttr *attr) { return pthread_cond_init(cond, attr); }
|
||||
int32_t taosThreadCondInit(TdThreadCond *cond, const TdThreadCondAttr *attr) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
InitializeConditionVariable(cond);
|
||||
return 0;
|
||||
#else
|
||||
return pthread_cond_init(cond, attr);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadCondSignal(TdThreadCond *cond) { return pthread_cond_signal(cond); }
|
||||
int32_t taosThreadCondSignal(TdThreadCond *cond) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
WakeConditionVariable(cond);
|
||||
return 0;
|
||||
#else
|
||||
return pthread_cond_signal(cond);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadCondBroadcast(TdThreadCond *cond) { return pthread_cond_broadcast(cond); }
|
||||
int32_t taosThreadCondBroadcast(TdThreadCond *cond) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
WakeAllConditionVariable(cond);
|
||||
return 0;
|
||||
#else
|
||||
return pthread_cond_broadcast(cond);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadCondWait(TdThreadCond *cond, TdThreadMutex *mutex) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
if (!SleepConditionVariableCS(cond, mutex, INFINITE)) {
|
||||
return EINVAL;
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
THREAD_PTR_CHECK(mutex)
|
||||
return pthread_cond_wait(cond, mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadCondTimedWait(TdThreadCond *cond, TdThreadMutex *mutex, const struct timespec *abstime) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
if (!abstime) return EINVAL;
|
||||
if (SleepConditionVariableCS(cond, mutex, (DWORD)(abstime->tv_sec * 1e3 + abstime->tv_nsec / 1e6))) return 0;
|
||||
if (GetLastError() == ERROR_TIMEOUT) {
|
||||
return ETIMEDOUT;
|
||||
}
|
||||
return EINVAL;
|
||||
#else
|
||||
THREAD_PTR_CHECK(mutex)
|
||||
return pthread_cond_timedwait(cond, mutex, abstime);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadCondAttrDestroy(TdThreadCondAttr *attr) { return pthread_condattr_destroy(attr); }
|
||||
int32_t taosThreadCondAttrDestroy(TdThreadCondAttr *attr) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
return 0;
|
||||
#else
|
||||
return pthread_condattr_destroy(attr);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadCondAttrGetPshared(const TdThreadCondAttr *attr, int32_t *pshared) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
if (pshared) *pshared = PTHREAD_PROCESS_PRIVATE;
|
||||
return 0;
|
||||
#else
|
||||
return pthread_condattr_getpshared(attr, pshared);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadCondAttrInit(TdThreadCondAttr *attr) { return pthread_condattr_init(attr); }
|
||||
int32_t taosThreadCondAttrInit(TdThreadCondAttr *attr) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
return 0;
|
||||
#else
|
||||
return pthread_condattr_init(attr);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadCondAttrSetPshared(TdThreadCondAttr *attr, int32_t pshared) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
return 0;
|
||||
#else
|
||||
return pthread_condattr_setpshared(attr, pshared);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadDetach(TdThread thread) { return pthread_detach(thread); }
|
||||
|
@ -142,17 +206,37 @@ int32_t taosThreadKill(TdThread thread, int32_t sig) { return pthread_kill(threa
|
|||
// }
|
||||
|
||||
int32_t taosThreadMutexDestroy(TdThreadMutex *mutex) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
DeleteCriticalSection(mutex);
|
||||
return 0;
|
||||
#else
|
||||
THREAD_PTR_CHECK(mutex)
|
||||
return pthread_mutex_destroy(mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexInit(TdThreadMutex *mutex, const TdThreadMutexAttr *attr) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
/**
|
||||
* Windows Server 2003 and Windows XP: In low memory situations, InitializeCriticalSection can raise a
|
||||
* STATUS_NO_MEMORY exception. Starting with Windows Vista, this exception was eliminated and
|
||||
* InitializeCriticalSection always succeeds, even in low memory situations.
|
||||
*/
|
||||
InitializeCriticalSection(mutex);
|
||||
return 0;
|
||||
#else
|
||||
return pthread_mutex_init(mutex, attr);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexLock(TdThreadMutex *mutex) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
EnterCriticalSection(mutex);
|
||||
return 0;
|
||||
#else
|
||||
THREAD_PTR_CHECK(mutex)
|
||||
return pthread_mutex_lock(mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
// int32_t taosThreadMutexTimedLock(TdThreadMutex * mutex, const struct timespec *abstime) {
|
||||
|
@ -160,19 +244,40 @@ int32_t taosThreadMutexLock(TdThreadMutex *mutex) {
|
|||
// }
|
||||
|
||||
int32_t taosThreadMutexTryLock(TdThreadMutex *mutex) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
if (TryEnterCriticalSection(mutex)) return 0;
|
||||
return EBUSY;
|
||||
#else
|
||||
THREAD_PTR_CHECK(mutex)
|
||||
return pthread_mutex_trylock(mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexUnlock(TdThreadMutex *mutex) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
LeaveCriticalSection(mutex);
|
||||
return 0;
|
||||
#else
|
||||
THREAD_PTR_CHECK(mutex)
|
||||
return pthread_mutex_unlock(mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexAttrDestroy(TdThreadMutexAttr *attr) { return pthread_mutexattr_destroy(attr); }
|
||||
int32_t taosThreadMutexAttrDestroy(TdThreadMutexAttr *attr) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
return 0;
|
||||
#else
|
||||
return pthread_mutexattr_destroy(attr);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexAttrGetPshared(const TdThreadMutexAttr *attr, int32_t *pshared) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
if (pshared) *pshared = PTHREAD_PROCESS_PRIVATE;
|
||||
return 0;
|
||||
#else
|
||||
return pthread_mutexattr_getpshared(attr, pshared);
|
||||
#endif
|
||||
}
|
||||
|
||||
// int32_t taosThreadMutexAttrGetRobust(const TdThreadMutexAttr * attr, int32_t * robust) {
|
||||
|
@ -180,13 +285,28 @@ int32_t taosThreadMutexAttrGetPshared(const TdThreadMutexAttr *attr, int32_t *ps
|
|||
// }
|
||||
|
||||
int32_t taosThreadMutexAttrGetType(const TdThreadMutexAttr *attr, int32_t *kind) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
if (kind) *kind = PTHREAD_MUTEX_NORMAL;
|
||||
return 0;
|
||||
#else
|
||||
return pthread_mutexattr_gettype(attr, kind);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexAttrInit(TdThreadMutexAttr *attr) { return pthread_mutexattr_init(attr); }
|
||||
int32_t taosThreadMutexAttrInit(TdThreadMutexAttr *attr) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
return 0;
|
||||
#else
|
||||
return pthread_mutexattr_init(attr);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexAttrSetPshared(TdThreadMutexAttr *attr, int32_t pshared) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
return 0;
|
||||
#else
|
||||
return pthread_mutexattr_setpshared(attr, pshared);
|
||||
#endif
|
||||
}
|
||||
|
||||
// int32_t taosThreadMutexAttrSetRobust(TdThreadMutexAttr * attr, int32_t robust) {
|
||||
|
@ -194,20 +314,46 @@ int32_t taosThreadMutexAttrSetPshared(TdThreadMutexAttr *attr, int32_t pshared)
|
|||
// }
|
||||
|
||||
int32_t taosThreadMutexAttrSetType(TdThreadMutexAttr *attr, int32_t kind) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
return 0;
|
||||
#else
|
||||
return pthread_mutexattr_settype(attr, kind);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadOnce(TdThreadOnce *onceControl, void (*initRoutine)(void)) {
|
||||
return pthread_once(onceControl, initRoutine);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockDestroy(TdThreadRwlock *rwlock) { return pthread_rwlock_destroy(rwlock); }
|
||||
|
||||
int32_t taosThreadRwlockInit(TdThreadRwlock *rwlock, const TdThreadRwlockAttr *attr) {
|
||||
return pthread_rwlock_init(rwlock, attr);
|
||||
int32_t taosThreadRwlockDestroy(TdThreadRwlock *rwlock) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
/* SRWLock does not need explicit destruction so long as there are no waiting threads
|
||||
* See: https://docs.microsoft.com/windows/win32/api/synchapi/nf-synchapi-initializesrwlock#remarks
|
||||
*/
|
||||
return 0;
|
||||
#else
|
||||
return pthread_rwlock_destroy(rwlock);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockRdlock(TdThreadRwlock *rwlock) { return pthread_rwlock_rdlock(rwlock); }
|
||||
int32_t taosThreadRwlockInit(TdThreadRwlock *rwlock, const TdThreadRwlockAttr *attr) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
memset(rwlock, 0, sizeof(*rwlock));
|
||||
InitializeSRWLock(&rwlock->lock);
|
||||
return 0;
|
||||
#else
|
||||
return pthread_rwlock_init(rwlock, attr);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockRdlock(TdThreadRwlock *rwlock) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
AcquireSRWLockShared(&rwlock->lock);
|
||||
return 0;
|
||||
#else
|
||||
return pthread_rwlock_rdlock(rwlock);
|
||||
#endif
|
||||
}
|
||||
|
||||
// int32_t taosThreadRwlockTimedRdlock(TdThreadRwlock * rwlock, const struct timespec *abstime) {
|
||||
// return pthread_rwlock_timedrdlock(rwlock, abstime);
|
||||
|
@ -217,24 +363,79 @@ int32_t taosThreadRwlockRdlock(TdThreadRwlock *rwlock) { return pthread_rwlock_r
|
|||
// return pthread_rwlock_timedwrlock(rwlock, abstime);
|
||||
// }
|
||||
|
||||
int32_t taosThreadRwlockTryRdlock(TdThreadRwlock *rwlock) { return pthread_rwlock_tryrdlock(rwlock); }
|
||||
|
||||
int32_t taosThreadRwlockTryWrlock(TdThreadRwlock *rwlock) { return pthread_rwlock_trywrlock(rwlock); }
|
||||
|
||||
int32_t taosThreadRwlockUnlock(TdThreadRwlock *rwlock) { return pthread_rwlock_unlock(rwlock); }
|
||||
|
||||
int32_t taosThreadRwlockWrlock(TdThreadRwlock *rwlock) { return pthread_rwlock_wrlock(rwlock); }
|
||||
|
||||
int32_t taosThreadRwlockAttrDestroy(TdThreadRwlockAttr *attr) { return pthread_rwlockattr_destroy(attr); }
|
||||
|
||||
int32_t taosThreadRwlockAttrGetPshared(const TdThreadRwlockAttr *attr, int32_t *pshared) {
|
||||
return pthread_rwlockattr_getpshared(attr, pshared);
|
||||
int32_t taosThreadRwlockTryRdlock(TdThreadRwlock *rwlock) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
if (!TryAcquireSRWLockShared(&rwlock->lock)) return EBUSY;
|
||||
return 0;
|
||||
#else
|
||||
return pthread_rwlock_tryrdlock(rwlock);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockAttrInit(TdThreadRwlockAttr *attr) { return pthread_rwlockattr_init(attr); }
|
||||
int32_t taosThreadRwlockTryWrlock(TdThreadRwlock *rwlock) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
if (!TryAcquireSRWLockExclusive(&rwlock->lock)) return EBUSY;
|
||||
atomic_store_8(&rwlock->excl, 1);
|
||||
return 0;
|
||||
#else
|
||||
return pthread_rwlock_trywrlock(rwlock);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockUnlock(TdThreadRwlock *rwlock) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
if (1 == atomic_val_compare_exchange_8(&rwlock->excl, 1, 0)) {
|
||||
ReleaseSRWLockExclusive(&rwlock->lock);
|
||||
} else {
|
||||
ReleaseSRWLockShared(&rwlock->lock);
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
return pthread_rwlock_unlock(rwlock);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockWrlock(TdThreadRwlock *rwlock) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
AcquireSRWLockExclusive(&rwlock->lock);
|
||||
atomic_store_8(&rwlock->excl, 1);
|
||||
return 0;
|
||||
#else
|
||||
return pthread_rwlock_wrlock(rwlock);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockAttrDestroy(TdThreadRwlockAttr *attr) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
return 0;
|
||||
#else
|
||||
return pthread_rwlockattr_destroy(attr);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockAttrGetPshared(const TdThreadRwlockAttr *attr, int32_t *pshared) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
if (pshared) *pshared = PTHREAD_PROCESS_PRIVATE;
|
||||
return 0;
|
||||
#else
|
||||
return pthread_rwlockattr_getpshared(attr, pshared);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockAttrInit(TdThreadRwlockAttr *attr) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
return 0;
|
||||
#else
|
||||
return pthread_rwlockattr_init(attr);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockAttrSetPshared(TdThreadRwlockAttr *attr, int32_t pshared) {
|
||||
#ifdef __USE_WIN_THREAD
|
||||
return 0;
|
||||
#else
|
||||
return pthread_rwlockattr_setpshared(attr, pshared);
|
||||
#endif
|
||||
}
|
||||
|
||||
TdThread taosThreadSelf(void) { return pthread_self(); }
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
static TdThread cacheRefreshWorker = {0};
|
||||
static TdThreadOnce cacheThreadInit = PTHREAD_ONCE_INIT;
|
||||
static TdThreadMutex guard = TD_PTHREAD_MUTEX_INITIALIZER;
|
||||
static TdThreadMutex guard;
|
||||
static SArray *pCacheArrayList = NULL;
|
||||
static bool stopRefreshWorker = false;
|
||||
static bool refreshWorkerNormalStopped = false;
|
||||
|
@ -155,6 +155,8 @@ static void *taosCacheTimedRefresh(void *handle);
|
|||
static void doInitRefreshThread(void) {
|
||||
pCacheArrayList = taosArrayInit(4, POINTER_BYTES);
|
||||
|
||||
taosThreadMutexInit(&guard, NULL);
|
||||
|
||||
TdThreadAttr thattr;
|
||||
taosThreadAttrInit(&thattr);
|
||||
taosThreadAttrSetDetachState(&thattr, PTHREAD_CREATE_JOINABLE);
|
||||
|
|
|
@ -1010,6 +1010,7 @@
|
|||
,,y,script,./test.sh -f tsim/query/emptyTsRange_scl.sim
|
||||
,,y,script,./test.sh -f tsim/query/partitionby.sim
|
||||
,,y,script,./test.sh -f tsim/query/tableCount.sim
|
||||
,,y,script,./test.sh -f tsim/query/show_db_table_kind.sim
|
||||
,,y,script,./test.sh -f tsim/query/tag_scan.sim
|
||||
,,y,script,./test.sh -f tsim/query/nullColSma.sim
|
||||
,,y,script,./test.sh -f tsim/query/bug3398.sim
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
sql connect
|
||||
|
||||
sql drop database if exists db1;
|
||||
sql create database db1 vgroups 3;
|
||||
sql create database db1;
|
||||
sql use db1;
|
||||
sql create stable sta (ts timestamp, f1 int, f2 binary(200)) tags(t1 int, t2 int, t3 int);
|
||||
sql create stable stb (ts timestamp, f1 int, f2 binary(200)) tags(t1 int, t2 int, t3 int);
|
||||
sql create table tba1 using sta tags(1, 1, 1);
|
||||
sql create table tba2 using sta tags(2, 2, 2);
|
||||
sql create table tba3 using sta tags(3, 3, 3);
|
||||
sql create table tba4 using sta tags(3, 3, 3);
|
||||
sql create table tba5 using sta tags(3, 3, 3);
|
||||
sql create table tba6 using sta tags(3, 3, 3);
|
||||
sql create table tba7 using sta tags(3, 3, 3);
|
||||
sql create table tba8 using sta tags(3, 3, 3);
|
||||
sql create table tbb1 using stb tags(4, 4, 4);
|
||||
sql create table tbb2 using stb tags(5, 5, 5);
|
||||
sql create table tbb3 using stb tags(6, 6, 6);
|
||||
sql create table tbb4 using stb tags(4, 4, 4);
|
||||
sql create table tbb5 using stb tags(5, 5, 5);
|
||||
sql create table tbb6 using stb tags(6, 6, 6);
|
||||
sql create table tbb7 using stb tags(7, 7, 7);
|
||||
sql create table tbb8 using stb tags(8, 8, 8);
|
||||
sql create table tbn1 (ts timestamp, f1 int);
|
||||
sql create database db2 vgroups 3;
|
||||
sql create database db2;
|
||||
sql use db2;
|
||||
sql create stable sta (ts timestamp, f1 int, f2 binary(200)) tags(t1 int, t2 int, t3 int);
|
||||
sql create stable stb (ts timestamp, f1 int, f2 binary(200)) tags(t1 int, t2 int, t3 int);
|
||||
sql create table tba1 using sta tags(1, 1, 1);
|
||||
sql create table tba2 using sta tags(2, 2, 2);
|
||||
sql create table tbb1 using stb tags(4, 4, 4);
|
||||
sql create table tbb2 using stb tags(5, 5, 5);
|
||||
sql create table tbb3 using stb tags(6, 6, 6);
|
||||
|
||||
sql show user databases;
|
||||
print $rows
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql show system databases;
|
||||
print $rows
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql show databases;
|
||||
print $rows
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql use db1
|
||||
|
||||
sql show tables
|
||||
print $rows
|
||||
if $rows != 17 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql show normal tables;
|
||||
print $rows
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
print $data00
|
||||
if $data00 != @tbn1@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql show child tables;
|
||||
print $rows
|
||||
if $rows != 16 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql show db2.tables;
|
||||
print $rows
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
sql show normal db2.tables
|
||||
print $rows
|
||||
if $rows != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql show child db2.tables
|
||||
print $rows
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
Loading…
Reference in New Issue