提交 99c6d1ec 编写于 作者: H Hongze Cheng

Merge branch 'develop' into feature/mergeimport

......@@ -125,7 +125,9 @@ IF (NOT DEFINED TD_CLUSTER)
# debug flag
#
# ADD_DEFINITIONS(-D_CHECK_HEADER_FILE_)
# ADD_DEFINITIONS(-D_TAOS_MEM_TEST_)
IF (${MEM_CHECK} MATCHES "true")
ADD_DEFINITIONS(-DTAOS_MEM_CHECK)
ENDIF ()
IF (TD_CLUSTER)
ADD_DEFINITIONS(-DCLUSTER)
......
......@@ -58,6 +58,12 @@
# The server and client should have the same socket type. Otherwise, connect will fail.
# sockettype udp
# The compressed rpc message, option:
# -1 (no compression)
# 0 (all message compressed),
# > 0 (rpc message body which larger than this value will be compressed)
# compressMsgSize -1
# RPC re-try timer, millisecond
# rpcTimer 300
......
......@@ -105,6 +105,7 @@ enum TSQL_TYPE {
SHOW_MODULES = 0x6c,
SHOW_CONNECTIONS = 0x6d,
SHOW_GRANTS = 0x6e,
SHOW_VNODES = 0x6f,
// create dnode
CREATE_DNODE = 0x80,
......
......@@ -34,8 +34,8 @@ extern "C" {
#include "tglobalcfg.h"
#include "tlog.h"
#include "tscCache.h"
#include "tsdb.h"
#include "tscSQLParser.h"
#include "tsdb.h"
#include "tsqlfunction.h"
#include "tutil.h"
......@@ -247,7 +247,7 @@ typedef struct STableDataBlocks {
// for parameter ('?') binding
uint32_t numOfAllocedParams;
uint32_t numOfParams;
SParamInfo* params;
SParamInfo *params;
} STableDataBlocks;
typedef struct SDataBlockList {
......@@ -262,18 +262,17 @@ typedef struct SDataBlockList {
typedef struct {
SOrderVal order;
int command;
// TODO refactor
int count;
int16_t isInsertFromFile; // load data from file or not
int count;// TODO refactor
union {
bool existsCheck;
int8_t showType;
bool existsCheck; // check if the table exists
int8_t showType; // show command type
};
int8_t isInsertFromFile; // load data from file or not
bool import; // import/insert type
char msgType;
uint16_t type;
uint16_t type; // query type
char intervalTimeUnit;
int64_t etime, stime;
int64_t nAggTimeInterval; // aggregation time interval
......@@ -450,12 +449,6 @@ int taos_retrieve(TAOS_RES *res);
int32_t tscTansformSQLFunctionForMetricQuery(SSqlCmd *pCmd);
void tscRestoreSQLFunctionForMetricQuery(SSqlCmd *pCmd);
/**
* release both metric/meter meta information
* @param pCmd SSqlCmd object that contains the metric/meter meta info
*/
void tscClearSqlMetaInfo(SSqlCmd *pCmd);
void tscClearSqlMetaInfoForce(SSqlCmd *pCmd);
int32_t tscCreateResPointerInfo(SSqlCmd *pCmd, SSqlRes *pRes);
......@@ -483,8 +476,8 @@ void tscProcessMultiVnodesInsert(SSqlObj *pSql);
void tscProcessMultiVnodesInsertForFile(SSqlObj *pSql);
void tscKillMetricQuery(SSqlObj *pSql);
void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen);
int32_t tscBuildResultsForEmptyRetrieval(SSqlObj *pSql);
bool tscIsUpdateQuery(STscObj *pObj);
int32_t tscInvalidSQLErrMsg(char *msg, const char *additionalInfo, const char *sql);
// transfer SSqlInfo to SqlCmd struct
int32_t tscToSQLCmd(SSqlObj *pSql, struct SSqlInfo *pInfo);
......
......@@ -9,6 +9,22 @@ extern "C" {
#endif
#undef com_taosdata_jdbc_TSDBJNIConnector_INVALID_CONNECTION_POINTER_VALUE
#define com_taosdata_jdbc_TSDBJNIConnector_INVALID_CONNECTION_POINTER_VALUE 0LL
/*
* Class: com_taosdata_jdbc_TSDBJNIConnector
* Method:
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setAllocModeImp
(JNIEnv *, jclass, jint, jstring, jboolean);
/*
* Class: com_taosdata_jdbc_TSDBJNIConnector
* Method:
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT void JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_dumpMemoryLeakImp
(JNIEnv *, jclass);
/*
* Class: com_taosdata_jdbc_TSDBJNIConnector
* Method: initImp
......
......@@ -111,6 +111,20 @@ void jniGetGlobalMethod(JNIEnv *env) {
jniTrace("native method register finished");
}
JNIEXPORT void JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setAllocModeImp(JNIEnv *env, jobject jobj, jint jMode, jstring jPath, jboolean jAutoDump) {
if (jPath != NULL) {
const char *path = (*env)->GetStringUTFChars(env, jPath, NULL);
taosSetAllocMode(jMode, path, !!jAutoDump);
(*env)->ReleaseStringUTFChars(env, jPath, path);
} else {
taosSetAllocMode(jMode, NULL, !!jAutoDump);
}
}
JNIEXPORT void JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_dumpMemoryLeakImp(JNIEnv *env, jobject jobj) {
taosDumpMemoryLeak();
}
JNIEXPORT void JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_initImp(JNIEnv *env, jobject jobj, jstring jconfigDir) {
if (jconfigDir != NULL) {
const char *confDir = (*env)->GetStringUTFChars(env, jconfigDir, NULL);
......
......@@ -78,41 +78,39 @@
** defined, then do no error processing.
** YYNSTATE the combined number of states.
** YYNRULE the number of rules in the grammar
** YYNTOKEN Number of terminal symbols
** YY_MAX_SHIFT Maximum value for shift actions
** YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions
** YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions
** YY_MIN_REDUCE Maximum value for reduce actions
** YY_ERROR_ACTION The yy_action[] code for syntax error
** YY_ACCEPT_ACTION The yy_action[] code for accept
** YY_NO_ACTION The yy_action[] code for no-op
** YY_MIN_REDUCE Minimum value for reduce actions
** YY_MAX_REDUCE Maximum value for reduce actions
*/
#ifndef INTERFACE
# define INTERFACE 1
#endif
/************* Begin control #defines *****************************************/
#define YYCODETYPE unsigned short int
#define YYNOCODE 261
#define YYNOCODE 262
#define YYACTIONTYPE unsigned short int
#define ParseTOKENTYPE SSQLToken
typedef union {
int yyinit;
ParseTOKENTYPE yy0;
SQuerySQL* yy24;
tVariantList* yy56;
tSQLExprListList* yy74;
tSQLExpr* yy90;
SCreateTableSQL* yy158;
tVariant yy186;
TAOS_FIELD yy223;
SCreateAcctSQL yy279;
SLimitVal yy294;
int yy332;
int64_t yy389;
SCreateDBInfo yy398;
tFieldList* yy471;
tSQLExprList* yy498;
SQuerySQL* yy138;
SCreateAcctSQL yy155;
SLimitVal yy162;
int yy220;
tVariant yy236;
tSQLExprListList* yy237;
tSQLExpr* yy244;
SCreateDBInfo yy262;
tSQLExprList* yy284;
SCreateTableSQL* yy344;
int64_t yy369;
TAOS_FIELD yy397;
tFieldList* yy421;
tVariantList* yy480;
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
......@@ -122,19 +120,22 @@ typedef union {
#define ParseARG_FETCH SSqlInfo* pInfo = yypParser->pInfo
#define ParseARG_STORE yypParser->pInfo = pInfo
#define YYFALLBACK 1
#define YYNSTATE 251
#define YYNRULE 214
#define YYNTOKEN 195
#define YY_MAX_SHIFT 250
#define YY_MIN_SHIFTREDUCE 401
#define YY_MAX_SHIFTREDUCE 614
#define YY_ERROR_ACTION 615
#define YY_ACCEPT_ACTION 616
#define YY_NO_ACTION 617
#define YY_MIN_REDUCE 618
#define YY_MAX_REDUCE 831
#define YYNSTATE 252
#define YYNRULE 216
#define YY_MAX_SHIFT 251
#define YY_MIN_SHIFTREDUCE 403
#define YY_MAX_SHIFTREDUCE 618
#define YY_MIN_REDUCE 619
#define YY_MAX_REDUCE 834
#define YY_ERROR_ACTION 835
#define YY_ACCEPT_ACTION 836
#define YY_NO_ACTION 837
/************* End control #defines *******************************************/
/* The yyzerominor constant is used to initialize instances of
** YYMINORTYPE objects to zero. */
static const YYMINORTYPE yyzerominor = { 0 };
/* Define the yytestcase() macro to be a no-op if is not already defined
** otherwise.
**
......@@ -162,6 +163,9 @@ typedef union {
** N between YY_MIN_SHIFTREDUCE Shift to an arbitrary state then
** and YY_MAX_SHIFTREDUCE reduce by rule N-YY_MIN_SHIFTREDUCE.
**
** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE
** and YY_MAX_REDUCE
** N == YY_ERROR_ACTION A syntax error has occurred.
**
** N == YY_ACCEPT_ACTION The parser accepts its input.
......@@ -169,22 +173,21 @@ typedef union {
** N == YY_NO_ACTION No such action. Denotes unused
** slots in the yy_action[] table.
**
** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE
** and YY_MAX_REDUCE
**
** The action table is constructed as a single large table named yy_action[].
** Given state S and lookahead X, the action is computed as either:
** Given state S and lookahead X, the action is computed as
**
** (A) N = yy_action[ yy_shift_ofst[S] + X ]
** (B) N = yy_default[S]
** yy_action[ yy_shift_ofst[S] + X ]
**
** The (A) formula is preferred. The B formula is used instead if
** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X.
** If the index value yy_shift_ofst[S]+X is out of range or if the value
** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
** and that yy_default[S] should be used instead.
**
** The formulas above are for computing the action when the lookahead is
** The formula above is for computing the action when the lookahead is
** a terminal symbol. If the lookahead is a non-terminal (as occurs after
** a reduce action) then the yy_reduce_ofst[] array is used in place of
** the yy_shift_ofst[] array.
** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
** YY_SHIFT_USE_DFLT.
**
** The following are the tables generated in this section:
**
......@@ -198,214 +201,198 @@ typedef union {
** yy_default[] Default action for each state.
**
*********** Begin parsing tables **********************************************/
#define YY_ACTTAB_COUNT (530)
#define YY_ACTTAB_COUNT (531)
static const YYACTIONTYPE yy_action[] = {
/* 0 */ 97, 439, 135, 101, 101, 156, 616, 250, 135, 440,
/* 10 */ 135, 159, 814, 43, 45, 21, 37, 38, 813, 158,
/* 20 */ 814, 31, 439, 727, 205, 41, 39, 42, 40, 10,
/* 30 */ 440, 153, 249, 36, 35, 745, 726, 34, 33, 32,
/* 40 */ 43, 45, 737, 37, 38, 166, 132, 167, 31, 724,
/* 50 */ 193, 205, 41, 39, 42, 40, 202, 769, 59, 200,
/* 60 */ 36, 35, 21, 727, 34, 33, 32, 43, 45, 134,
/* 70 */ 37, 38, 74, 78, 244, 31, 85, 77, 205, 41,
/* 80 */ 39, 42, 40, 80, 742, 220, 498, 36, 35, 439,
/* 90 */ 21, 34, 33, 32, 168, 101, 724, 440, 101, 57,
/* 100 */ 114, 115, 224, 727, 65, 68, 45, 7, 37, 38,
/* 110 */ 62, 111, 241, 31, 230, 229, 205, 41, 39, 42,
/* 120 */ 40, 232, 228, 565, 724, 36, 35, 21, 139, 34,
/* 130 */ 33, 32, 21, 402, 403, 404, 405, 406, 407, 408,
/* 140 */ 409, 410, 411, 412, 413, 810, 37, 38, 243, 768,
/* 150 */ 725, 31, 60, 178, 205, 41, 39, 42, 40, 233,
/* 160 */ 186, 724, 183, 36, 35, 809, 723, 34, 33, 32,
/* 170 */ 654, 171, 808, 124, 17, 219, 242, 218, 217, 216,
/* 180 */ 215, 214, 213, 212, 211, 709, 151, 698, 699, 700,
/* 190 */ 701, 702, 703, 704, 705, 706, 707, 708, 163, 578,
/* 200 */ 11, 133, 569, 133, 572, 76, 575, 663, 163, 578,
/* 210 */ 124, 241, 569, 154, 572, 155, 575, 148, 34, 33,
/* 220 */ 32, 248, 247, 422, 87, 86, 142, 243, 546, 547,
/* 230 */ 160, 161, 147, 523, 204, 172, 18, 152, 227, 226,
/* 240 */ 160, 161, 163, 578, 526, 712, 569, 711, 572, 140,
/* 250 */ 575, 41, 39, 42, 40, 242, 141, 61, 27, 36,
/* 260 */ 35, 73, 72, 34, 33, 32, 514, 655, 28, 511,
/* 270 */ 124, 512, 143, 513, 160, 161, 192, 36, 35, 188,
/* 280 */ 601, 34, 33, 32, 29, 571, 150, 574, 567, 128,
/* 290 */ 126, 245, 44, 89, 88, 602, 537, 169, 170, 29,
/* 300 */ 47, 577, 44, 162, 538, 595, 579, 144, 15, 14,
/* 310 */ 14, 577, 570, 49, 573, 504, 576, 52, 503, 47,
/* 320 */ 145, 209, 22, 146, 568, 22, 576, 518, 828, 519,
/* 330 */ 50, 516, 53, 517, 84, 83, 44, 9, 8, 718,
/* 340 */ 137, 2, 131, 138, 136, 577, 779, 744, 778, 164,
/* 350 */ 775, 774, 165, 231, 98, 761, 760, 112, 113, 665,
/* 360 */ 576, 110, 189, 210, 129, 515, 25, 223, 91, 225,
/* 370 */ 827, 70, 826, 824, 116, 683, 26, 23, 130, 652,
/* 380 */ 533, 79, 650, 54, 81, 648, 647, 173, 125, 645,
/* 390 */ 644, 643, 641, 634, 127, 638, 191, 636, 738, 194,
/* 400 */ 198, 95, 748, 749, 762, 51, 102, 46, 203, 103,
/* 410 */ 201, 199, 197, 195, 30, 27, 222, 75, 234, 235,
/* 420 */ 207, 55, 236, 240, 238, 237, 239, 63, 66, 149,
/* 430 */ 246, 614, 175, 174, 176, 646, 613, 90, 640, 119,
/* 440 */ 123, 177, 684, 117, 118, 120, 106, 104, 722, 122,
/* 450 */ 92, 121, 108, 105, 107, 109, 1, 24, 180, 179,
/* 460 */ 181, 182, 612, 184, 185, 605, 58, 12, 13, 99,
/* 470 */ 190, 187, 96, 534, 157, 539, 196, 100, 19, 64,
/* 480 */ 479, 580, 3, 20, 4, 16, 206, 6, 208, 478,
/* 490 */ 477, 476, 475, 5, 474, 473, 472, 470, 47, 443,
/* 500 */ 67, 445, 22, 221, 500, 48, 499, 497, 56, 464,
/* 510 */ 462, 454, 460, 69, 456, 71, 458, 452, 450, 471,
/* 520 */ 469, 82, 441, 425, 93, 415, 618, 617, 617, 94,
/* 0 */ 443, 74, 78, 244, 85, 77, 153, 249, 444, 836,
/* 10 */ 251, 80, 43, 45, 7, 37, 38, 62, 111, 171,
/* 20 */ 31, 443, 443, 205, 41, 39, 42, 40, 241, 444,
/* 30 */ 444, 135, 36, 35, 10, 101, 34, 33, 32, 43,
/* 40 */ 45, 600, 37, 38, 156, 524, 135, 31, 135, 133,
/* 50 */ 205, 41, 39, 42, 40, 159, 601, 158, 601, 36,
/* 60 */ 35, 154, 514, 34, 33, 32, 404, 405, 406, 407,
/* 70 */ 408, 409, 410, 411, 412, 413, 414, 415, 250, 21,
/* 80 */ 43, 45, 172, 37, 38, 227, 226, 202, 31, 59,
/* 90 */ 21, 205, 41, 39, 42, 40, 34, 33, 32, 57,
/* 100 */ 36, 35, 550, 551, 34, 33, 32, 45, 232, 37,
/* 110 */ 38, 167, 132, 511, 31, 21, 21, 205, 41, 39,
/* 120 */ 42, 40, 168, 569, 511, 502, 36, 35, 134, 178,
/* 130 */ 34, 33, 32, 243, 37, 38, 186, 512, 183, 31,
/* 140 */ 532, 101, 205, 41, 39, 42, 40, 228, 233, 511,
/* 150 */ 511, 36, 35, 230, 229, 34, 33, 32, 17, 219,
/* 160 */ 242, 218, 217, 216, 215, 214, 213, 212, 211, 496,
/* 170 */ 139, 485, 486, 487, 488, 489, 490, 491, 492, 493,
/* 180 */ 494, 495, 163, 582, 11, 97, 573, 133, 576, 529,
/* 190 */ 579, 597, 163, 582, 166, 556, 573, 200, 576, 155,
/* 200 */ 579, 36, 35, 148, 220, 34, 33, 32, 21, 87,
/* 210 */ 86, 142, 514, 243, 160, 161, 101, 147, 204, 248,
/* 220 */ 247, 426, 514, 76, 160, 161, 163, 582, 530, 241,
/* 230 */ 573, 101, 576, 513, 579, 193, 41, 39, 42, 40,
/* 240 */ 242, 596, 510, 27, 36, 35, 49, 571, 34, 33,
/* 250 */ 32, 114, 115, 224, 65, 68, 505, 441, 160, 161,
/* 260 */ 124, 192, 518, 50, 188, 515, 499, 516, 498, 517,
/* 270 */ 555, 150, 128, 126, 245, 89, 88, 44, 450, 442,
/* 280 */ 61, 124, 124, 572, 595, 60, 581, 44, 575, 527,
/* 290 */ 578, 28, 18, 169, 170, 605, 581, 162, 606, 29,
/* 300 */ 541, 580, 29, 542, 47, 52, 599, 15, 151, 583,
/* 310 */ 14, 580, 574, 14, 577, 508, 73, 72, 507, 47,
/* 320 */ 53, 44, 22, 209, 522, 152, 523, 22, 140, 520,
/* 330 */ 581, 521, 9, 8, 2, 84, 83, 141, 143, 144,
/* 340 */ 145, 615, 146, 137, 131, 580, 138, 136, 531, 566,
/* 350 */ 98, 565, 164, 562, 561, 165, 231, 548, 547, 189,
/* 360 */ 112, 113, 519, 452, 110, 210, 129, 25, 191, 223,
/* 370 */ 225, 614, 70, 613, 611, 116, 470, 26, 23, 130,
/* 380 */ 439, 91, 79, 437, 81, 435, 434, 537, 194, 198,
/* 390 */ 173, 54, 125, 432, 431, 430, 428, 421, 525, 127,
/* 400 */ 425, 51, 423, 102, 46, 203, 103, 104, 95, 199,
/* 410 */ 201, 535, 197, 30, 536, 549, 195, 27, 222, 75,
/* 420 */ 234, 235, 236, 237, 207, 55, 238, 239, 240, 246,
/* 430 */ 149, 618, 63, 66, 175, 433, 174, 176, 177, 617,
/* 440 */ 180, 427, 119, 90, 118, 471, 117, 120, 122, 121,
/* 450 */ 123, 92, 509, 1, 24, 182, 107, 105, 106, 108,
/* 460 */ 109, 179, 181, 616, 184, 185, 12, 609, 190, 187,
/* 470 */ 13, 157, 96, 538, 99, 196, 58, 4, 19, 543,
/* 480 */ 100, 5, 584, 3, 20, 16, 206, 6, 208, 64,
/* 490 */ 483, 482, 481, 480, 479, 478, 477, 476, 474, 47,
/* 500 */ 447, 449, 67, 22, 504, 221, 503, 501, 56, 468,
/* 510 */ 466, 48, 458, 464, 69, 460, 462, 456, 454, 475,
/* 520 */ 71, 473, 82, 429, 445, 419, 417, 93, 619, 621,
/* 530 */ 94,
};
static const YYCODETYPE yy_lookahead[] = {
/* 0 */ 199, 1, 247, 199, 199, 216, 196, 197, 247, 9,
/* 10 */ 247, 256, 257, 13, 14, 199, 16, 17, 257, 256,
/* 20 */ 257, 21, 1, 234, 24, 25, 26, 27, 28, 247,
/* 30 */ 9, 198, 199, 33, 34, 199, 234, 37, 38, 39,
/* 40 */ 13, 14, 232, 16, 17, 216, 247, 231, 21, 233,
/* 50 */ 249, 24, 25, 26, 27, 28, 251, 253, 253, 255,
/* 60 */ 33, 34, 199, 234, 37, 38, 39, 13, 14, 247,
/* 70 */ 16, 17, 62, 63, 64, 21, 66, 67, 24, 25,
/* 80 */ 26, 27, 28, 73, 248, 216, 5, 33, 34, 1,
/* 90 */ 199, 37, 38, 39, 231, 199, 233, 9, 199, 99,
/* 100 */ 62, 63, 64, 234, 66, 67, 14, 95, 16, 17,
/* 110 */ 98, 99, 77, 21, 33, 34, 24, 25, 26, 27,
/* 120 */ 28, 199, 231, 96, 233, 33, 34, 199, 247, 37,
/* 130 */ 38, 39, 199, 45, 46, 47, 48, 49, 50, 51,
/* 140 */ 52, 53, 54, 55, 56, 247, 16, 17, 58, 253,
/* 150 */ 228, 21, 253, 124, 24, 25, 26, 27, 28, 231,
/* 160 */ 131, 233, 133, 33, 34, 247, 233, 37, 38, 39,
/* 170 */ 203, 61, 247, 206, 84, 85, 86, 87, 88, 89,
/* 180 */ 90, 91, 92, 93, 94, 215, 247, 217, 218, 219,
/* 190 */ 220, 221, 222, 223, 224, 225, 226, 227, 1, 2,
/* 200 */ 44, 247, 5, 247, 7, 71, 9, 203, 1, 2,
/* 210 */ 206, 77, 5, 259, 7, 259, 9, 61, 37, 38,
/* 220 */ 39, 58, 59, 60, 68, 69, 70, 58, 110, 111,
/* 230 */ 33, 34, 76, 100, 37, 125, 103, 247, 128, 129,
/* 240 */ 33, 34, 1, 2, 37, 217, 5, 219, 7, 247,
/* 250 */ 9, 25, 26, 27, 28, 86, 247, 235, 102, 33,
/* 260 */ 34, 126, 127, 37, 38, 39, 2, 203, 246, 5,
/* 270 */ 206, 7, 247, 9, 33, 34, 120, 33, 34, 123,
/* 280 */ 96, 37, 38, 39, 100, 5, 130, 7, 1, 62,
/* 290 */ 63, 64, 95, 66, 67, 96, 96, 33, 34, 100,
/* 300 */ 100, 104, 95, 57, 96, 96, 96, 247, 100, 100,
/* 310 */ 100, 104, 5, 100, 7, 96, 119, 100, 96, 100,
/* 320 */ 247, 96, 100, 247, 37, 100, 119, 5, 234, 7,
/* 330 */ 117, 5, 115, 7, 71, 72, 95, 126, 127, 230,
/* 340 */ 247, 95, 247, 247, 247, 104, 229, 199, 229, 229,
/* 350 */ 229, 229, 229, 229, 199, 254, 254, 199, 199, 199,
/* 360 */ 119, 236, 122, 199, 199, 101, 199, 199, 57, 199,
/* 370 */ 199, 199, 199, 199, 199, 199, 199, 199, 199, 199,
/* 380 */ 104, 199, 199, 114, 199, 199, 199, 199, 199, 199,
/* 390 */ 199, 199, 199, 199, 199, 199, 258, 199, 245, 250,
/* 400 */ 250, 200, 200, 200, 200, 116, 244, 113, 108, 243,
/* 410 */ 112, 107, 106, 105, 118, 102, 74, 83, 82, 49,
/* 420 */ 200, 200, 79, 78, 53, 81, 80, 204, 204, 200,
/* 430 */ 74, 5, 5, 132, 132, 200, 5, 201, 200, 208,
/* 440 */ 207, 65, 214, 213, 212, 211, 240, 242, 232, 210,
/* 450 */ 201, 209, 238, 241, 239, 237, 205, 202, 5, 132,
/* 460 */ 132, 65, 5, 132, 65, 85, 100, 95, 95, 95,
/* 470 */ 122, 124, 121, 96, 1, 96, 95, 95, 100, 71,
/* 480 */ 9, 96, 95, 100, 109, 95, 97, 95, 97, 5,
/* 490 */ 5, 5, 5, 109, 1, 5, 5, 5, 100, 75,
/* 500 */ 71, 65, 100, 15, 5, 16, 5, 96, 95, 5,
/* 510 */ 5, 5, 5, 127, 5, 127, 5, 5, 5, 5,
/* 520 */ 5, 65, 75, 65, 21, 57, 0, 260, 260, 21,
/* 530 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 540 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 550 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 560 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 570 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 580 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 590 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 600 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 610 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 620 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 630 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 640 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 650 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 660 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 670 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 680 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 690 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 700 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 710 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 720 */ 260, 260, 260, 260, 260,
/* 0 */ 1, 64, 65, 66, 67, 68, 199, 200, 9, 197,
/* 10 */ 198, 74, 13, 14, 96, 16, 17, 99, 100, 63,
/* 20 */ 21, 1, 1, 24, 25, 26, 27, 28, 78, 9,
/* 30 */ 9, 248, 33, 34, 248, 200, 37, 38, 39, 13,
/* 40 */ 14, 258, 16, 17, 217, 233, 248, 21, 248, 248,
/* 50 */ 24, 25, 26, 27, 28, 257, 258, 257, 258, 33,
/* 60 */ 34, 260, 235, 37, 38, 39, 45, 46, 47, 48,
/* 70 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 200,
/* 80 */ 13, 14, 126, 16, 17, 129, 130, 252, 21, 254,
/* 90 */ 200, 24, 25, 26, 27, 28, 37, 38, 39, 100,
/* 100 */ 33, 34, 111, 112, 37, 38, 39, 14, 200, 16,
/* 110 */ 17, 232, 248, 234, 21, 200, 200, 24, 25, 26,
/* 120 */ 27, 28, 232, 97, 234, 5, 33, 34, 248, 125,
/* 130 */ 37, 38, 39, 60, 16, 17, 132, 229, 134, 21,
/* 140 */ 200, 200, 24, 25, 26, 27, 28, 232, 232, 234,
/* 150 */ 234, 33, 34, 33, 34, 37, 38, 39, 85, 86,
/* 160 */ 87, 88, 89, 90, 91, 92, 93, 94, 95, 216,
/* 170 */ 248, 218, 219, 220, 221, 222, 223, 224, 225, 226,
/* 180 */ 227, 228, 1, 2, 44, 200, 5, 248, 7, 249,
/* 190 */ 9, 248, 1, 2, 217, 254, 5, 256, 7, 260,
/* 200 */ 9, 33, 34, 63, 217, 37, 38, 39, 200, 69,
/* 210 */ 70, 71, 235, 60, 33, 34, 200, 77, 37, 60,
/* 220 */ 61, 62, 235, 72, 33, 34, 1, 2, 37, 78,
/* 230 */ 5, 200, 7, 235, 9, 250, 25, 26, 27, 28,
/* 240 */ 87, 248, 234, 103, 33, 34, 101, 1, 37, 38,
/* 250 */ 39, 64, 65, 66, 67, 68, 231, 204, 33, 34,
/* 260 */ 207, 121, 2, 118, 124, 5, 218, 7, 220, 9,
/* 270 */ 254, 131, 64, 65, 66, 67, 68, 96, 204, 204,
/* 280 */ 236, 207, 207, 37, 248, 254, 105, 96, 5, 101,
/* 290 */ 7, 247, 104, 33, 34, 97, 105, 59, 97, 101,
/* 300 */ 97, 120, 101, 97, 101, 101, 97, 101, 248, 97,
/* 310 */ 101, 120, 5, 101, 7, 97, 127, 128, 97, 101,
/* 320 */ 116, 96, 101, 97, 5, 248, 7, 101, 248, 5,
/* 330 */ 105, 7, 127, 128, 96, 72, 73, 248, 248, 248,
/* 340 */ 248, 235, 248, 248, 248, 120, 248, 248, 200, 230,
/* 350 */ 200, 230, 230, 230, 230, 230, 230, 255, 255, 123,
/* 360 */ 200, 200, 102, 200, 237, 200, 200, 200, 259, 200,
/* 370 */ 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
/* 380 */ 200, 59, 200, 200, 200, 200, 200, 105, 251, 251,
/* 390 */ 200, 115, 200, 200, 200, 200, 200, 200, 246, 200,
/* 400 */ 200, 117, 200, 245, 114, 109, 244, 243, 201, 108,
/* 410 */ 113, 201, 107, 119, 201, 201, 106, 103, 75, 84,
/* 420 */ 83, 49, 80, 82, 201, 201, 53, 81, 79, 75,
/* 430 */ 201, 5, 205, 205, 5, 201, 133, 133, 58, 5,
/* 440 */ 5, 201, 209, 202, 213, 215, 214, 212, 211, 210,
/* 450 */ 208, 202, 233, 206, 203, 58, 240, 242, 241, 239,
/* 460 */ 238, 133, 133, 5, 133, 58, 96, 86, 123, 125,
/* 470 */ 96, 1, 122, 97, 96, 96, 101, 110, 101, 97,
/* 480 */ 96, 110, 97, 96, 101, 96, 98, 96, 98, 72,
/* 490 */ 9, 5, 5, 5, 5, 1, 5, 5, 5, 101,
/* 500 */ 76, 58, 72, 101, 5, 15, 5, 97, 96, 5,
/* 510 */ 5, 16, 5, 5, 128, 5, 5, 5, 5, 5,
/* 520 */ 128, 5, 58, 58, 76, 59, 58, 21, 0, 261,
/* 530 */ 21,
};
#define YY_SHIFT_COUNT (250)
#define YY_SHIFT_MIN (0)
#define YY_SHIFT_MAX (526)
static const unsigned short int yy_shift_ofst[] = {
/* 0 */ 156, 90, 197, 241, 21, 21, 21, 21, 21, 21,
/* 10 */ 0, 88, 241, 241, 241, 264, 264, 264, 21, 21,
/* 20 */ 21, 21, 21, 134, 169, 35, 35, 530, 207, 241,
/* 30 */ 241, 241, 241, 241, 241, 241, 241, 241, 241, 241,
/* 40 */ 241, 241, 241, 241, 241, 241, 241, 264, 264, 81,
/* 50 */ 81, 81, 81, 81, 81, 12, 81, 21, 21, 118,
/* 60 */ 118, 133, 21, 21, 21, 21, 21, 21, 21, 21,
/* 70 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
/* 80 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
/* 90 */ 21, 21, 21, 21, 21, 240, 311, 311, 311, 276,
/* 100 */ 276, 311, 269, 289, 294, 300, 298, 304, 306, 308,
/* 110 */ 296, 313, 311, 311, 342, 342, 311, 334, 336, 370,
/* 120 */ 343, 344, 371, 346, 345, 311, 356, 311, 356, 530,
/* 130 */ 530, 27, 54, 54, 54, 54, 54, 92, 130, 226,
/* 140 */ 226, 226, 10, 244, 244, 244, 244, 38, 227, 110,
/* 150 */ 29, 181, 181, 163, 184, 199, 200, 208, 209, 210,
/* 160 */ 280, 307, 287, 246, 213, 217, 219, 222, 225, 322,
/* 170 */ 326, 135, 211, 263, 426, 301, 427, 302, 376, 431,
/* 180 */ 327, 453, 328, 396, 457, 331, 399, 380, 347, 372,
/* 190 */ 373, 348, 351, 366, 377, 374, 473, 381, 379, 382,
/* 200 */ 378, 375, 383, 384, 385, 387, 390, 389, 392, 391,
/* 210 */ 408, 471, 484, 485, 486, 487, 493, 490, 491, 492,
/* 220 */ 398, 424, 488, 429, 436, 489, 386, 388, 402, 499,
/* 230 */ 501, 411, 413, 402, 504, 505, 506, 507, 509, 511,
/* 240 */ 512, 513, 514, 515, 456, 458, 447, 503, 508, 468,
/* 250 */ 526,
#define YY_SHIFT_USE_DFLT (-83)
#define YY_SHIFT_COUNT (251)
#define YY_SHIFT_MIN (-82)
#define YY_SHIFT_MAX (528)
static const short yy_shift_ofst[] = {
/* 0 */ 140, 73, 181, 225, 20, 20, 20, 20, 20, 20,
/* 10 */ -1, 21, 225, 225, 225, 260, 260, 260, 20, 20,
/* 20 */ 20, 20, 20, 151, 153, -50, -50, -83, 191, 225,
/* 30 */ 225, 225, 225, 225, 225, 225, 225, 225, 225, 225,
/* 40 */ 225, 225, 225, 225, 225, 225, 225, 260, 260, 120,
/* 50 */ 120, 120, 120, 120, 120, -82, 120, 20, 20, -9,
/* 60 */ -9, 188, 20, 20, 20, 20, 20, 20, 20, 20,
/* 70 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
/* 80 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
/* 90 */ 20, 20, 20, 20, 20, 236, 322, 322, 322, 282,
/* 100 */ 282, 322, 276, 284, 290, 296, 297, 301, 305, 310,
/* 110 */ 294, 314, 322, 322, 343, 343, 322, 335, 337, 372,
/* 120 */ 342, 341, 373, 346, 349, 322, 354, 322, 354, -83,
/* 130 */ -83, 26, 67, 67, 67, 67, 67, 93, 118, 211,
/* 140 */ 211, 211, -63, 168, 168, 168, 168, 187, 208, -44,
/* 150 */ 4, 59, 59, 159, 198, 201, 203, 206, 209, 212,
/* 160 */ 283, 307, 246, 238, 145, 204, 218, 221, 226, 319,
/* 170 */ 324, 189, 205, 263, 426, 303, 429, 304, 380, 434,
/* 180 */ 328, 435, 329, 397, 458, 331, 407, 381, 344, 370,
/* 190 */ 374, 345, 350, 375, 376, 378, 470, 379, 382, 384,
/* 200 */ 377, 367, 383, 371, 385, 387, 389, 388, 391, 390,
/* 210 */ 417, 481, 486, 487, 488, 489, 494, 491, 492, 493,
/* 220 */ 398, 424, 490, 430, 443, 495, 386, 392, 402, 499,
/* 230 */ 501, 410, 412, 402, 504, 505, 507, 508, 510, 511,
/* 240 */ 512, 513, 514, 516, 464, 465, 448, 506, 509, 466,
/* 250 */ 468, 528,
};
#define YY_REDUCE_USE_DFLT (-218)
#define YY_REDUCE_COUNT (130)
#define YY_REDUCE_MIN (-245)
#define YY_REDUCE_MAX (255)
#define YY_REDUCE_MIN (-217)
#define YY_REDUCE_MAX (251)
static const short yy_reduce_ofst[] = {
/* 0 */ -190, -30, -245, -237, -196, -195, -184, -137, -109, -72,
/* 10 */ -164, -167, -46, -44, -239, -211, -171, -131, -199, -104,
/* 20 */ -101, -78, -67, -33, 28, 4, 64, 22, -218, -201,
/* 30 */ -178, -119, -102, -82, -75, -61, -10, 2, 9, 25,
/* 40 */ 60, 73, 76, 93, 95, 96, 97, -198, 94, 117,
/* 50 */ 119, 120, 121, 122, 123, 109, 124, 148, 155, 101,
/* 60 */ 102, 125, 158, 159, 160, 164, 165, 167, 168, 170,
/* 0 */ -188, -47, -202, -200, -59, -165, -121, -110, -85, -84,
/* 10 */ -60, -193, -199, -61, -217, -173, -23, -13, -15, 16,
/* 20 */ 31, -92, 8, 53, 48, 74, 75, 44, -214, -136,
/* 30 */ -120, -78, -57, -7, 36, 60, 77, 80, 89, 90,
/* 40 */ 91, 92, 94, 95, 96, 98, 99, -2, 106, 119,
/* 50 */ 121, 122, 123, 124, 125, 25, 126, 148, 150, 102,
/* 60 */ 103, 127, 160, 161, 163, 165, 166, 167, 169, 170,
/* 70 */ 171, 172, 173, 174, 175, 176, 177, 178, 179, 180,
/* 80 */ 182, 183, 185, 186, 187, 188, 189, 190, 191, 192,
/* 90 */ 193, 194, 195, 196, 198, 138, 201, 202, 203, 149,
/* 100 */ 150, 204, 153, 162, 166, 205, 212, 206, 215, 214,
/* 110 */ 218, 216, 220, 221, 223, 224, 229, 228, 230, 232,
/* 120 */ 231, 234, 242, 239, 233, 235, 236, 238, 249, 251,
/* 130 */ 255,
/* 80 */ 182, 183, 184, 185, 186, 190, 192, 193, 194, 195,
/* 90 */ 196, 197, 199, 200, 202, 109, 207, 210, 213, 137,
/* 100 */ 138, 214, 152, 158, 162, 164, 215, 217, 216, 220,
/* 110 */ 222, 219, 223, 224, 227, 228, 229, 230, 232, 231,
/* 120 */ 233, 235, 239, 237, 242, 234, 241, 240, 249, 247,
/* 130 */ 251,
};
static const YYACTIONTYPE yy_default[] = {
/* 0 */ 615, 664, 816, 816, 615, 615, 615, 615, 615, 615,
/* 10 */ 746, 631, 615, 615, 816, 615, 615, 615, 615, 615,
/* 20 */ 615, 615, 615, 666, 653, 666, 666, 741, 615, 615,
/* 30 */ 615, 615, 615, 615, 615, 615, 615, 615, 615, 615,
/* 40 */ 615, 615, 615, 615, 615, 615, 615, 615, 615, 615,
/* 50 */ 615, 615, 615, 615, 615, 615, 615, 615, 615, 765,
/* 60 */ 765, 739, 615, 615, 615, 615, 615, 615, 615, 615,
/* 70 */ 615, 615, 615, 615, 615, 615, 615, 615, 615, 651,
/* 80 */ 615, 649, 615, 615, 615, 615, 615, 615, 615, 615,
/* 90 */ 615, 615, 615, 615, 615, 615, 633, 633, 633, 615,
/* 100 */ 615, 633, 772, 776, 770, 758, 766, 757, 753, 752,
/* 110 */ 780, 615, 633, 633, 661, 661, 633, 682, 680, 678,
/* 120 */ 670, 676, 672, 674, 668, 633, 659, 633, 659, 697,
/* 130 */ 710, 615, 820, 821, 781, 815, 771, 799, 798, 811,
/* 140 */ 805, 804, 615, 803, 802, 801, 800, 615, 615, 615,
/* 150 */ 615, 807, 806, 615, 615, 615, 615, 615, 615, 615,
/* 160 */ 615, 615, 615, 783, 777, 773, 615, 615, 615, 615,
/* 170 */ 615, 615, 615, 615, 615, 615, 615, 615, 615, 615,
/* 180 */ 615, 615, 615, 615, 615, 615, 615, 615, 615, 615,
/* 190 */ 615, 817, 615, 747, 615, 615, 615, 615, 615, 615,
/* 200 */ 767, 615, 759, 615, 615, 615, 615, 615, 615, 719,
/* 210 */ 615, 615, 615, 615, 615, 615, 615, 615, 615, 615,
/* 220 */ 685, 615, 615, 615, 615, 615, 615, 615, 825, 615,
/* 230 */ 615, 615, 713, 823, 615, 615, 615, 615, 615, 615,
/* 240 */ 615, 615, 615, 615, 615, 615, 615, 637, 635, 615,
/* 250 */ 615,
/* 0 */ 835, 667, 819, 819, 835, 835, 835, 835, 835, 835,
/* 10 */ 749, 634, 835, 835, 819, 835, 835, 835, 835, 835,
/* 20 */ 835, 835, 835, 669, 656, 669, 669, 744, 835, 835,
/* 30 */ 835, 835, 835, 835, 835, 835, 835, 835, 835, 835,
/* 40 */ 835, 835, 835, 835, 835, 835, 835, 835, 835, 835,
/* 50 */ 835, 835, 835, 835, 835, 835, 835, 835, 835, 768,
/* 60 */ 768, 742, 835, 835, 835, 835, 835, 835, 835, 835,
/* 70 */ 835, 835, 835, 835, 835, 835, 835, 835, 835, 654,
/* 80 */ 835, 652, 835, 835, 835, 835, 835, 835, 835, 835,
/* 90 */ 835, 835, 835, 835, 835, 835, 636, 636, 636, 835,
/* 100 */ 835, 636, 775, 779, 773, 761, 769, 760, 756, 755,
/* 110 */ 783, 835, 636, 636, 664, 664, 636, 685, 683, 681,
/* 120 */ 673, 679, 675, 677, 671, 636, 662, 636, 662, 700,
/* 130 */ 713, 835, 823, 824, 784, 818, 774, 802, 801, 814,
/* 140 */ 808, 807, 835, 806, 805, 804, 803, 835, 835, 835,
/* 150 */ 835, 810, 809, 835, 835, 835, 835, 835, 835, 835,
/* 160 */ 835, 835, 835, 786, 780, 776, 835, 835, 835, 835,
/* 170 */ 835, 835, 835, 835, 835, 835, 835, 835, 835, 835,
/* 180 */ 835, 835, 835, 835, 835, 835, 835, 835, 835, 835,
/* 190 */ 835, 820, 835, 750, 835, 835, 835, 835, 835, 835,
/* 200 */ 770, 835, 762, 835, 835, 835, 835, 835, 835, 722,
/* 210 */ 835, 835, 835, 835, 835, 835, 835, 835, 835, 835,
/* 220 */ 688, 835, 835, 835, 835, 835, 835, 835, 828, 835,
/* 230 */ 835, 835, 716, 826, 835, 835, 835, 835, 835, 835,
/* 240 */ 835, 835, 835, 835, 835, 835, 835, 640, 638, 835,
/* 250 */ 632, 835,
};
/********** End of lemon-generated parsing tables *****************************/
......@@ -482,6 +469,8 @@ static const YYCODETYPE yyFallback[] = {
0, /* CONFIGS => nothing */
0, /* SCORES => nothing */
0, /* GRANTS => nothing */
0, /* VNODES => nothing */
1, /* IPTOKEN => ID */
0, /* DOT => nothing */
0, /* TABLES => nothing */
0, /* STABLES => nothing */
......@@ -490,7 +479,6 @@ static const YYCODETYPE yyFallback[] = {
0, /* TABLE => nothing */
1, /* DATABASE => ID */
0, /* DNODE => nothing */
1, /* IPTOKEN => ID */
0, /* USER => nothing */
0, /* ACCOUNT => nothing */
0, /* USE => nothing */
......@@ -651,21 +639,17 @@ typedef struct yyStackEntry yyStackEntry;
/* The state of the parser is completely contained in an instance of
** the following structure */
struct yyParser {
yyStackEntry *yytos; /* Pointer to top element of the stack */
int yyidx; /* Index of top element in stack */
#ifdef YYTRACKMAXSTACKDEPTH
int yyhwm; /* High-water mark of the stack */
int yyidxMax; /* Maximum value of yyidx */
#endif
#ifndef YYNOERRORRECOVERY
int yyerrcnt; /* Shifts left before out of the error */
#endif
ParseARG_SDECL /* A place to hold %extra_argument */
#if YYSTACKDEPTH<=0
int yystksz; /* Current side of the stack */
yyStackEntry *yystack; /* The parser's stack */
yyStackEntry yystk0; /* First stack entry */
#else
yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
yyStackEntry *yystackEnd; /* Last entry in the stack */
#endif
};
typedef struct yyParser yyParser;
......@@ -702,272 +686,78 @@ void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
}
#endif /* NDEBUG */
#if defined(YYCOVERAGE) || !defined(NDEBUG)
#ifndef NDEBUG
/* For tracing shifts, the names of all terminals and nonterminals
** are required. The following table supplies these names */
static const char *const yyTokenName[] = {
/* 0 */ "$",
/* 1 */ "ID",
/* 2 */ "BOOL",
/* 3 */ "TINYINT",
/* 4 */ "SMALLINT",
/* 5 */ "INTEGER",
/* 6 */ "BIGINT",
/* 7 */ "FLOAT",
/* 8 */ "DOUBLE",
/* 9 */ "STRING",
/* 10 */ "TIMESTAMP",
/* 11 */ "BINARY",
/* 12 */ "NCHAR",
/* 13 */ "OR",
/* 14 */ "AND",
/* 15 */ "NOT",
/* 16 */ "EQ",
/* 17 */ "NE",
/* 18 */ "ISNULL",
/* 19 */ "NOTNULL",
/* 20 */ "IS",
/* 21 */ "LIKE",
/* 22 */ "GLOB",
/* 23 */ "BETWEEN",
/* 24 */ "IN",
/* 25 */ "GT",
/* 26 */ "GE",
/* 27 */ "LT",
/* 28 */ "LE",
/* 29 */ "BITAND",
/* 30 */ "BITOR",
/* 31 */ "LSHIFT",
/* 32 */ "RSHIFT",
/* 33 */ "PLUS",
/* 34 */ "MINUS",
/* 35 */ "DIVIDE",
/* 36 */ "TIMES",
/* 37 */ "STAR",
/* 38 */ "SLASH",
/* 39 */ "REM",
/* 40 */ "CONCAT",
/* 41 */ "UMINUS",
/* 42 */ "UPLUS",
/* 43 */ "BITNOT",
/* 44 */ "SHOW",
/* 45 */ "DATABASES",
/* 46 */ "MNODES",
/* 47 */ "DNODES",
/* 48 */ "ACCOUNTS",
/* 49 */ "USERS",
/* 50 */ "MODULES",
/* 51 */ "QUERIES",
/* 52 */ "CONNECTIONS",
/* 53 */ "STREAMS",
/* 54 */ "CONFIGS",
/* 55 */ "SCORES",
/* 56 */ "GRANTS",
/* 57 */ "DOT",
/* 58 */ "TABLES",
/* 59 */ "STABLES",
/* 60 */ "VGROUPS",
/* 61 */ "DROP",
/* 62 */ "TABLE",
/* 63 */ "DATABASE",
/* 64 */ "DNODE",
/* 65 */ "IPTOKEN",
/* 66 */ "USER",
/* 67 */ "ACCOUNT",
/* 68 */ "USE",
/* 69 */ "DESCRIBE",
/* 70 */ "ALTER",
/* 71 */ "PASS",
/* 72 */ "PRIVILEGE",
/* 73 */ "LOCAL",
/* 74 */ "IF",
/* 75 */ "EXISTS",
/* 76 */ "CREATE",
/* 77 */ "PPS",
/* 78 */ "TSERIES",
/* 79 */ "DBS",
/* 80 */ "STORAGE",
/* 81 */ "QTIME",
/* 82 */ "CONNS",
/* 83 */ "STATE",
/* 84 */ "KEEP",
/* 85 */ "CACHE",
/* 86 */ "REPLICA",
/* 87 */ "DAYS",
/* 88 */ "ROWS",
/* 89 */ "ABLOCKS",
/* 90 */ "TBLOCKS",
/* 91 */ "CTIME",
/* 92 */ "CLOG",
/* 93 */ "COMP",
/* 94 */ "PRECISION",
/* 95 */ "LP",
/* 96 */ "RP",
/* 97 */ "TAGS",
/* 98 */ "USING",
/* 99 */ "AS",
/* 100 */ "COMMA",
/* 101 */ "NULL",
/* 102 */ "SELECT",
/* 103 */ "FROM",
/* 104 */ "VARIABLE",
/* 105 */ "INTERVAL",
/* 106 */ "FILL",
/* 107 */ "SLIDING",
/* 108 */ "ORDER",
/* 109 */ "BY",
/* 110 */ "ASC",
/* 111 */ "DESC",
/* 112 */ "GROUP",
/* 113 */ "HAVING",
/* 114 */ "LIMIT",
/* 115 */ "OFFSET",
/* 116 */ "SLIMIT",
/* 117 */ "SOFFSET",
/* 118 */ "WHERE",
/* 119 */ "NOW",
/* 120 */ "INSERT",
/* 121 */ "INTO",
/* 122 */ "VALUES",
/* 123 */ "RESET",
/* 124 */ "QUERY",
/* 125 */ "ADD",
/* 126 */ "COLUMN",
/* 127 */ "TAG",
/* 128 */ "CHANGE",
/* 129 */ "SET",
/* 130 */ "KILL",
/* 131 */ "CONNECTION",
/* 132 */ "COLON",
/* 133 */ "STREAM",
/* 134 */ "ABORT",
/* 135 */ "AFTER",
/* 136 */ "ATTACH",
/* 137 */ "BEFORE",
/* 138 */ "BEGIN",
/* 139 */ "CASCADE",
/* 140 */ "CLUSTER",
/* 141 */ "CONFLICT",
/* 142 */ "COPY",
/* 143 */ "DEFERRED",
/* 144 */ "DELIMITERS",
/* 145 */ "DETACH",
/* 146 */ "EACH",
/* 147 */ "END",
/* 148 */ "EXPLAIN",
/* 149 */ "FAIL",
/* 150 */ "FOR",
/* 151 */ "IGNORE",
/* 152 */ "IMMEDIATE",
/* 153 */ "INITIALLY",
/* 154 */ "INSTEAD",
/* 155 */ "MATCH",
/* 156 */ "KEY",
/* 157 */ "OF",
/* 158 */ "RAISE",
/* 159 */ "REPLACE",
/* 160 */ "RESTRICT",
/* 161 */ "ROW",
/* 162 */ "STATEMENT",
/* 163 */ "TRIGGER",
/* 164 */ "VIEW",
/* 165 */ "ALL",
/* 166 */ "COUNT",
/* 167 */ "SUM",
/* 168 */ "AVG",
/* 169 */ "MIN",
/* 170 */ "MAX",
/* 171 */ "FIRST",
/* 172 */ "LAST",
/* 173 */ "TOP",
/* 174 */ "BOTTOM",
/* 175 */ "STDDEV",
/* 176 */ "PERCENTILE",
/* 177 */ "APERCENTILE",
/* 178 */ "LEASTSQUARES",
/* 179 */ "HISTOGRAM",
/* 180 */ "DIFF",
/* 181 */ "SPREAD",
/* 182 */ "TWA",
/* 183 */ "INTERP",
/* 184 */ "LAST_ROW",
/* 185 */ "SEMI",
/* 186 */ "NONE",
/* 187 */ "PREV",
/* 188 */ "LINEAR",
/* 189 */ "IMPORT",
/* 190 */ "METRIC",
/* 191 */ "TBNAME",
/* 192 */ "JOIN",
/* 193 */ "METRICS",
/* 194 */ "STABLE",
/* 195 */ "error",
/* 196 */ "program",
/* 197 */ "cmd",
/* 198 */ "dbPrefix",
/* 199 */ "ids",
/* 200 */ "cpxName",
/* 201 */ "ifexists",
/* 202 */ "alter_db_optr",
/* 203 */ "acct_optr",
/* 204 */ "ifnotexists",
/* 205 */ "db_optr",
/* 206 */ "pps",
/* 207 */ "tseries",
/* 208 */ "dbs",
/* 209 */ "streams",
/* 210 */ "storage",
/* 211 */ "qtime",
/* 212 */ "users",
/* 213 */ "conns",
/* 214 */ "state",
/* 215 */ "keep",
/* 216 */ "tagitemlist",
/* 217 */ "tables",
/* 218 */ "cache",
/* 219 */ "replica",
/* 220 */ "days",
/* 221 */ "rows",
/* 222 */ "ablocks",
/* 223 */ "tblocks",
/* 224 */ "ctime",
/* 225 */ "clog",
/* 226 */ "comp",
/* 227 */ "prec",
/* 228 */ "typename",
/* 229 */ "signed",
/* 230 */ "create_table_args",
/* 231 */ "columnlist",
/* 232 */ "select",
/* 233 */ "column",
/* 234 */ "tagitem",
/* 235 */ "selcollist",
/* 236 */ "from",
/* 237 */ "where_opt",
/* 238 */ "interval_opt",
/* 239 */ "fill_opt",
/* 240 */ "sliding_opt",
/* 241 */ "groupby_opt",
/* 242 */ "orderby_opt",
/* 243 */ "having_opt",
/* 244 */ "slimit_opt",
/* 245 */ "limit_opt",
/* 246 */ "sclp",
/* 247 */ "expr",
/* 248 */ "as",
/* 249 */ "tablelist",
/* 250 */ "tmvar",
/* 251 */ "sortlist",
/* 252 */ "sortitem",
/* 253 */ "item",
/* 254 */ "sortorder",
/* 255 */ "grouplist",
/* 256 */ "exprlist",
/* 257 */ "expritem",
/* 258 */ "insert_value_list",
/* 259 */ "itemlist",
"$", "ID", "BOOL", "TINYINT",
"SMALLINT", "INTEGER", "BIGINT", "FLOAT",
"DOUBLE", "STRING", "TIMESTAMP", "BINARY",
"NCHAR", "OR", "AND", "NOT",
"EQ", "NE", "ISNULL", "NOTNULL",
"IS", "LIKE", "GLOB", "BETWEEN",
"IN", "GT", "GE", "LT",
"LE", "BITAND", "BITOR", "LSHIFT",
"RSHIFT", "PLUS", "MINUS", "DIVIDE",
"TIMES", "STAR", "SLASH", "REM",
"CONCAT", "UMINUS", "UPLUS", "BITNOT",
"SHOW", "DATABASES", "MNODES", "DNODES",
"ACCOUNTS", "USERS", "MODULES", "QUERIES",
"CONNECTIONS", "STREAMS", "CONFIGS", "SCORES",
"GRANTS", "VNODES", "IPTOKEN", "DOT",
"TABLES", "STABLES", "VGROUPS", "DROP",
"TABLE", "DATABASE", "DNODE", "USER",
"ACCOUNT", "USE", "DESCRIBE", "ALTER",
"PASS", "PRIVILEGE", "LOCAL", "IF",
"EXISTS", "CREATE", "PPS", "TSERIES",
"DBS", "STORAGE", "QTIME", "CONNS",
"STATE", "KEEP", "CACHE", "REPLICA",
"DAYS", "ROWS", "ABLOCKS", "TBLOCKS",
"CTIME", "CLOG", "COMP", "PRECISION",
"LP", "RP", "TAGS", "USING",
"AS", "COMMA", "NULL", "SELECT",
"FROM", "VARIABLE", "INTERVAL", "FILL",
"SLIDING", "ORDER", "BY", "ASC",
"DESC", "GROUP", "HAVING", "LIMIT",
"OFFSET", "SLIMIT", "SOFFSET", "WHERE",
"NOW", "INSERT", "INTO", "VALUES",
"RESET", "QUERY", "ADD", "COLUMN",
"TAG", "CHANGE", "SET", "KILL",
"CONNECTION", "COLON", "STREAM", "ABORT",
"AFTER", "ATTACH", "BEFORE", "BEGIN",
"CASCADE", "CLUSTER", "CONFLICT", "COPY",
"DEFERRED", "DELIMITERS", "DETACH", "EACH",
"END", "EXPLAIN", "FAIL", "FOR",
"IGNORE", "IMMEDIATE", "INITIALLY", "INSTEAD",
"MATCH", "KEY", "OF", "RAISE",
"REPLACE", "RESTRICT", "ROW", "STATEMENT",
"TRIGGER", "VIEW", "ALL", "COUNT",
"SUM", "AVG", "MIN", "MAX",
"FIRST", "LAST", "TOP", "BOTTOM",
"STDDEV", "PERCENTILE", "APERCENTILE", "LEASTSQUARES",
"HISTOGRAM", "DIFF", "SPREAD", "TWA",
"INTERP", "LAST_ROW", "SEMI", "NONE",
"PREV", "LINEAR", "IMPORT", "METRIC",
"TBNAME", "JOIN", "METRICS", "STABLE",
"error", "program", "cmd", "dbPrefix",
"ids", "cpxName", "ifexists", "alter_db_optr",
"acct_optr", "ifnotexists", "db_optr", "pps",
"tseries", "dbs", "streams", "storage",
"qtime", "users", "conns", "state",
"keep", "tagitemlist", "tables", "cache",
"replica", "days", "rows", "ablocks",
"tblocks", "ctime", "clog", "comp",
"prec", "typename", "signed", "create_table_args",
"columnlist", "select", "column", "tagitem",
"selcollist", "from", "where_opt", "interval_opt",
"fill_opt", "sliding_opt", "groupby_opt", "orderby_opt",
"having_opt", "slimit_opt", "limit_opt", "sclp",
"expr", "as", "tablelist", "tmvar",
"sortlist", "sortitem", "item", "sortorder",
"grouplist", "exprlist", "expritem", "insert_value_list",
"itemlist",
};
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
#endif /* NDEBUG */
#ifndef NDEBUG
/* For tracing reduce actions, the names of all rules are required.
......@@ -986,241 +776,233 @@ static const char *const yyRuleName[] = {
/* 10 */ "cmd ::= SHOW CONFIGS",
/* 11 */ "cmd ::= SHOW SCORES",
/* 12 */ "cmd ::= SHOW GRANTS",
/* 13 */ "dbPrefix ::=",
/* 14 */ "dbPrefix ::= ids DOT",
/* 15 */ "cpxName ::=",
/* 16 */ "cpxName ::= DOT ids",
/* 17 */ "cmd ::= SHOW dbPrefix TABLES",
/* 18 */ "cmd ::= SHOW dbPrefix TABLES LIKE ids",
/* 19 */ "cmd ::= SHOW dbPrefix STABLES",
/* 20 */ "cmd ::= SHOW dbPrefix STABLES LIKE ids",
/* 21 */ "cmd ::= SHOW dbPrefix VGROUPS",
/* 22 */ "cmd ::= DROP TABLE ifexists ids cpxName",
/* 23 */ "cmd ::= DROP DATABASE ifexists ids",
/* 24 */ "cmd ::= DROP DNODE IPTOKEN",
/* 25 */ "cmd ::= DROP USER ids",
/* 26 */ "cmd ::= DROP ACCOUNT ids",
/* 27 */ "cmd ::= USE ids",
/* 28 */ "cmd ::= DESCRIBE ids cpxName",
/* 29 */ "cmd ::= ALTER USER ids PASS ids",
/* 30 */ "cmd ::= ALTER USER ids PRIVILEGE ids",
/* 31 */ "cmd ::= ALTER DNODE IPTOKEN ids",
/* 32 */ "cmd ::= ALTER DNODE IPTOKEN ids ids",
/* 33 */ "cmd ::= ALTER LOCAL ids",
/* 34 */ "cmd ::= ALTER LOCAL ids ids",
/* 35 */ "cmd ::= ALTER DATABASE ids alter_db_optr",
/* 36 */ "cmd ::= ALTER ACCOUNT ids acct_optr",
/* 37 */ "cmd ::= ALTER ACCOUNT ids PASS ids acct_optr",
/* 38 */ "ids ::= ID",
/* 39 */ "ids ::= STRING",
/* 40 */ "ifexists ::= IF EXISTS",
/* 41 */ "ifexists ::=",
/* 42 */ "ifnotexists ::= IF NOT EXISTS",
/* 43 */ "ifnotexists ::=",
/* 44 */ "cmd ::= CREATE DNODE IPTOKEN",
/* 45 */ "cmd ::= CREATE ACCOUNT ids PASS ids acct_optr",
/* 46 */ "cmd ::= CREATE DATABASE ifnotexists ids db_optr",
/* 47 */ "cmd ::= CREATE USER ids PASS ids",
/* 48 */ "pps ::=",
/* 49 */ "pps ::= PPS INTEGER",
/* 50 */ "tseries ::=",
/* 51 */ "tseries ::= TSERIES INTEGER",
/* 52 */ "dbs ::=",
/* 53 */ "dbs ::= DBS INTEGER",
/* 54 */ "streams ::=",
/* 55 */ "streams ::= STREAMS INTEGER",
/* 56 */ "storage ::=",
/* 57 */ "storage ::= STORAGE INTEGER",
/* 58 */ "qtime ::=",
/* 59 */ "qtime ::= QTIME INTEGER",
/* 60 */ "users ::=",
/* 61 */ "users ::= USERS INTEGER",
/* 62 */ "conns ::=",
/* 63 */ "conns ::= CONNS INTEGER",
/* 64 */ "state ::=",
/* 65 */ "state ::= STATE ids",
/* 66 */ "acct_optr ::= pps tseries storage streams qtime dbs users conns state",
/* 67 */ "keep ::= KEEP tagitemlist",
/* 68 */ "tables ::= TABLES INTEGER",
/* 69 */ "cache ::= CACHE INTEGER",
/* 70 */ "replica ::= REPLICA INTEGER",
/* 71 */ "days ::= DAYS INTEGER",
/* 72 */ "rows ::= ROWS INTEGER",
/* 73 */ "ablocks ::= ABLOCKS ID",
/* 74 */ "tblocks ::= TBLOCKS INTEGER",
/* 75 */ "ctime ::= CTIME INTEGER",
/* 76 */ "clog ::= CLOG INTEGER",
/* 77 */ "comp ::= COMP INTEGER",
/* 78 */ "prec ::= PRECISION STRING",
/* 79 */ "db_optr ::=",
/* 80 */ "db_optr ::= db_optr tables",
/* 81 */ "db_optr ::= db_optr cache",
/* 82 */ "db_optr ::= db_optr replica",
/* 83 */ "db_optr ::= db_optr days",
/* 84 */ "db_optr ::= db_optr rows",
/* 85 */ "db_optr ::= db_optr ablocks",
/* 86 */ "db_optr ::= db_optr tblocks",
/* 87 */ "db_optr ::= db_optr ctime",
/* 88 */ "db_optr ::= db_optr clog",
/* 89 */ "db_optr ::= db_optr comp",
/* 90 */ "db_optr ::= db_optr prec",
/* 91 */ "db_optr ::= db_optr keep",
/* 92 */ "alter_db_optr ::=",
/* 93 */ "alter_db_optr ::= alter_db_optr replica",
/* 94 */ "alter_db_optr ::= alter_db_optr tables",
/* 95 */ "typename ::= ids",
/* 96 */ "typename ::= ids LP signed RP",
/* 97 */ "signed ::= INTEGER",
/* 98 */ "signed ::= PLUS INTEGER",
/* 99 */ "signed ::= MINUS INTEGER",
/* 100 */ "cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args",
/* 101 */ "create_table_args ::= LP columnlist RP",
/* 102 */ "create_table_args ::= LP columnlist RP TAGS LP columnlist RP",
/* 103 */ "create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP",
/* 104 */ "create_table_args ::= AS select",
/* 105 */ "columnlist ::= columnlist COMMA column",
/* 106 */ "columnlist ::= column",
/* 107 */ "column ::= ids typename",
/* 108 */ "tagitemlist ::= tagitemlist COMMA tagitem",
/* 109 */ "tagitemlist ::= tagitem",
/* 110 */ "tagitem ::= INTEGER",
/* 111 */ "tagitem ::= FLOAT",
/* 112 */ "tagitem ::= STRING",
/* 113 */ "tagitem ::= BOOL",
/* 114 */ "tagitem ::= NULL",
/* 115 */ "tagitem ::= MINUS INTEGER",
/* 116 */ "tagitem ::= MINUS FLOAT",
/* 117 */ "tagitem ::= PLUS INTEGER",
/* 118 */ "tagitem ::= PLUS FLOAT",
/* 119 */ "cmd ::= select",
/* 120 */ "select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt",
/* 121 */ "select ::= SELECT selcollist",
/* 122 */ "sclp ::= selcollist COMMA",
/* 123 */ "sclp ::=",
/* 124 */ "selcollist ::= sclp expr as",
/* 125 */ "selcollist ::= sclp STAR",
/* 126 */ "as ::= AS ids",
/* 127 */ "as ::= ids",
/* 128 */ "as ::=",
/* 129 */ "from ::= FROM tablelist",
/* 130 */ "tablelist ::= ids cpxName",
/* 131 */ "tablelist ::= tablelist COMMA ids cpxName",
/* 132 */ "tmvar ::= VARIABLE",
/* 133 */ "interval_opt ::= INTERVAL LP tmvar RP",
/* 134 */ "interval_opt ::=",
/* 135 */ "fill_opt ::=",
/* 136 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP",
/* 137 */ "fill_opt ::= FILL LP ID RP",
/* 138 */ "sliding_opt ::= SLIDING LP tmvar RP",
/* 139 */ "sliding_opt ::=",
/* 140 */ "orderby_opt ::=",
/* 141 */ "orderby_opt ::= ORDER BY sortlist",
/* 142 */ "sortlist ::= sortlist COMMA item sortorder",
/* 143 */ "sortlist ::= item sortorder",
/* 144 */ "item ::= ids cpxName",
/* 145 */ "sortorder ::= ASC",
/* 146 */ "sortorder ::= DESC",
/* 147 */ "sortorder ::=",
/* 148 */ "groupby_opt ::=",
/* 149 */ "groupby_opt ::= GROUP BY grouplist",
/* 150 */ "grouplist ::= grouplist COMMA item",
/* 151 */ "grouplist ::= item",
/* 152 */ "having_opt ::=",
/* 153 */ "having_opt ::= HAVING expr",
/* 154 */ "limit_opt ::=",
/* 155 */ "limit_opt ::= LIMIT signed",
/* 156 */ "limit_opt ::= LIMIT signed OFFSET signed",
/* 157 */ "limit_opt ::= LIMIT signed COMMA signed",
/* 158 */ "slimit_opt ::=",
/* 159 */ "slimit_opt ::= SLIMIT signed",
/* 160 */ "slimit_opt ::= SLIMIT signed SOFFSET signed",
/* 161 */ "slimit_opt ::= SLIMIT signed COMMA signed",
/* 162 */ "where_opt ::=",
/* 163 */ "where_opt ::= WHERE expr",
/* 164 */ "expr ::= LP expr RP",
/* 165 */ "expr ::= ID",
/* 166 */ "expr ::= ID DOT ID",
/* 167 */ "expr ::= ID DOT STAR",
/* 168 */ "expr ::= INTEGER",
/* 169 */ "expr ::= MINUS INTEGER",
/* 170 */ "expr ::= PLUS INTEGER",
/* 171 */ "expr ::= FLOAT",
/* 172 */ "expr ::= MINUS FLOAT",
/* 173 */ "expr ::= PLUS FLOAT",
/* 174 */ "expr ::= STRING",
/* 175 */ "expr ::= NOW",
/* 176 */ "expr ::= VARIABLE",
/* 177 */ "expr ::= BOOL",
/* 178 */ "expr ::= ID LP exprlist RP",
/* 179 */ "expr ::= ID LP STAR RP",
/* 180 */ "expr ::= expr AND expr",
/* 181 */ "expr ::= expr OR expr",
/* 182 */ "expr ::= expr LT expr",
/* 183 */ "expr ::= expr GT expr",
/* 184 */ "expr ::= expr LE expr",
/* 185 */ "expr ::= expr GE expr",
/* 186 */ "expr ::= expr NE expr",
/* 187 */ "expr ::= expr EQ expr",
/* 188 */ "expr ::= expr PLUS expr",
/* 189 */ "expr ::= expr MINUS expr",
/* 190 */ "expr ::= expr STAR expr",
/* 191 */ "expr ::= expr SLASH expr",
/* 192 */ "expr ::= expr REM expr",
/* 193 */ "expr ::= expr LIKE expr",
/* 194 */ "expr ::= expr IN LP exprlist RP",
/* 195 */ "exprlist ::= exprlist COMMA expritem",
/* 196 */ "exprlist ::= expritem",
/* 197 */ "expritem ::= expr",
/* 198 */ "expritem ::=",
/* 199 */ "cmd ::= INSERT INTO cpxName insert_value_list",
/* 200 */ "insert_value_list ::= VALUES LP itemlist RP",
/* 201 */ "insert_value_list ::= insert_value_list VALUES LP itemlist RP",
/* 202 */ "itemlist ::= itemlist COMMA expr",
/* 203 */ "itemlist ::= expr",
/* 204 */ "cmd ::= RESET QUERY CACHE",
/* 205 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist",
/* 206 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids",
/* 207 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist",
/* 208 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids",
/* 209 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids",
/* 210 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem",
/* 211 */ "cmd ::= KILL CONNECTION IPTOKEN COLON INTEGER",
/* 212 */ "cmd ::= KILL STREAM IPTOKEN COLON INTEGER COLON INTEGER",
/* 213 */ "cmd ::= KILL QUERY IPTOKEN COLON INTEGER COLON INTEGER",
/* 13 */ "cmd ::= SHOW VNODES",
/* 14 */ "cmd ::= SHOW VNODES IPTOKEN",
/* 15 */ "dbPrefix ::=",
/* 16 */ "dbPrefix ::= ids DOT",
/* 17 */ "cpxName ::=",
/* 18 */ "cpxName ::= DOT ids",
/* 19 */ "cmd ::= SHOW dbPrefix TABLES",
/* 20 */ "cmd ::= SHOW dbPrefix TABLES LIKE ids",
/* 21 */ "cmd ::= SHOW dbPrefix STABLES",
/* 22 */ "cmd ::= SHOW dbPrefix STABLES LIKE ids",
/* 23 */ "cmd ::= SHOW dbPrefix VGROUPS",
/* 24 */ "cmd ::= DROP TABLE ifexists ids cpxName",
/* 25 */ "cmd ::= DROP DATABASE ifexists ids",
/* 26 */ "cmd ::= DROP DNODE IPTOKEN",
/* 27 */ "cmd ::= DROP USER ids",
/* 28 */ "cmd ::= DROP ACCOUNT ids",
/* 29 */ "cmd ::= USE ids",
/* 30 */ "cmd ::= DESCRIBE ids cpxName",
/* 31 */ "cmd ::= ALTER USER ids PASS ids",
/* 32 */ "cmd ::= ALTER USER ids PRIVILEGE ids",
/* 33 */ "cmd ::= ALTER DNODE IPTOKEN ids",
/* 34 */ "cmd ::= ALTER DNODE IPTOKEN ids ids",
/* 35 */ "cmd ::= ALTER LOCAL ids",
/* 36 */ "cmd ::= ALTER LOCAL ids ids",
/* 37 */ "cmd ::= ALTER DATABASE ids alter_db_optr",
/* 38 */ "cmd ::= ALTER ACCOUNT ids acct_optr",
/* 39 */ "cmd ::= ALTER ACCOUNT ids PASS ids acct_optr",
/* 40 */ "ids ::= ID",
/* 41 */ "ids ::= STRING",
/* 42 */ "ifexists ::= IF EXISTS",
/* 43 */ "ifexists ::=",
/* 44 */ "ifnotexists ::= IF NOT EXISTS",
/* 45 */ "ifnotexists ::=",
/* 46 */ "cmd ::= CREATE DNODE IPTOKEN",
/* 47 */ "cmd ::= CREATE ACCOUNT ids PASS ids acct_optr",
/* 48 */ "cmd ::= CREATE DATABASE ifnotexists ids db_optr",
/* 49 */ "cmd ::= CREATE USER ids PASS ids",
/* 50 */ "pps ::=",
/* 51 */ "pps ::= PPS INTEGER",
/* 52 */ "tseries ::=",
/* 53 */ "tseries ::= TSERIES INTEGER",
/* 54 */ "dbs ::=",
/* 55 */ "dbs ::= DBS INTEGER",
/* 56 */ "streams ::=",
/* 57 */ "streams ::= STREAMS INTEGER",
/* 58 */ "storage ::=",
/* 59 */ "storage ::= STORAGE INTEGER",
/* 60 */ "qtime ::=",
/* 61 */ "qtime ::= QTIME INTEGER",
/* 62 */ "users ::=",
/* 63 */ "users ::= USERS INTEGER",
/* 64 */ "conns ::=",
/* 65 */ "conns ::= CONNS INTEGER",
/* 66 */ "state ::=",
/* 67 */ "state ::= STATE ids",
/* 68 */ "acct_optr ::= pps tseries storage streams qtime dbs users conns state",
/* 69 */ "keep ::= KEEP tagitemlist",
/* 70 */ "tables ::= TABLES INTEGER",
/* 71 */ "cache ::= CACHE INTEGER",
/* 72 */ "replica ::= REPLICA INTEGER",
/* 73 */ "days ::= DAYS INTEGER",
/* 74 */ "rows ::= ROWS INTEGER",
/* 75 */ "ablocks ::= ABLOCKS ID",
/* 76 */ "tblocks ::= TBLOCKS INTEGER",
/* 77 */ "ctime ::= CTIME INTEGER",
/* 78 */ "clog ::= CLOG INTEGER",
/* 79 */ "comp ::= COMP INTEGER",
/* 80 */ "prec ::= PRECISION STRING",
/* 81 */ "db_optr ::=",
/* 82 */ "db_optr ::= db_optr tables",
/* 83 */ "db_optr ::= db_optr cache",
/* 84 */ "db_optr ::= db_optr replica",
/* 85 */ "db_optr ::= db_optr days",
/* 86 */ "db_optr ::= db_optr rows",
/* 87 */ "db_optr ::= db_optr ablocks",
/* 88 */ "db_optr ::= db_optr tblocks",
/* 89 */ "db_optr ::= db_optr ctime",
/* 90 */ "db_optr ::= db_optr clog",
/* 91 */ "db_optr ::= db_optr comp",
/* 92 */ "db_optr ::= db_optr prec",
/* 93 */ "db_optr ::= db_optr keep",
/* 94 */ "alter_db_optr ::=",
/* 95 */ "alter_db_optr ::= alter_db_optr replica",
/* 96 */ "alter_db_optr ::= alter_db_optr tables",
/* 97 */ "typename ::= ids",
/* 98 */ "typename ::= ids LP signed RP",
/* 99 */ "signed ::= INTEGER",
/* 100 */ "signed ::= PLUS INTEGER",
/* 101 */ "signed ::= MINUS INTEGER",
/* 102 */ "cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args",
/* 103 */ "create_table_args ::= LP columnlist RP",
/* 104 */ "create_table_args ::= LP columnlist RP TAGS LP columnlist RP",
/* 105 */ "create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP",
/* 106 */ "create_table_args ::= AS select",
/* 107 */ "columnlist ::= columnlist COMMA column",
/* 108 */ "columnlist ::= column",
/* 109 */ "column ::= ids typename",
/* 110 */ "tagitemlist ::= tagitemlist COMMA tagitem",
/* 111 */ "tagitemlist ::= tagitem",
/* 112 */ "tagitem ::= INTEGER",
/* 113 */ "tagitem ::= FLOAT",
/* 114 */ "tagitem ::= STRING",
/* 115 */ "tagitem ::= BOOL",
/* 116 */ "tagitem ::= NULL",
/* 117 */ "tagitem ::= MINUS INTEGER",
/* 118 */ "tagitem ::= MINUS FLOAT",
/* 119 */ "tagitem ::= PLUS INTEGER",
/* 120 */ "tagitem ::= PLUS FLOAT",
/* 121 */ "cmd ::= select",
/* 122 */ "select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt",
/* 123 */ "select ::= SELECT selcollist",
/* 124 */ "sclp ::= selcollist COMMA",
/* 125 */ "sclp ::=",
/* 126 */ "selcollist ::= sclp expr as",
/* 127 */ "selcollist ::= sclp STAR",
/* 128 */ "as ::= AS ids",
/* 129 */ "as ::= ids",
/* 130 */ "as ::=",
/* 131 */ "from ::= FROM tablelist",
/* 132 */ "tablelist ::= ids cpxName",
/* 133 */ "tablelist ::= tablelist COMMA ids cpxName",
/* 134 */ "tmvar ::= VARIABLE",
/* 135 */ "interval_opt ::= INTERVAL LP tmvar RP",
/* 136 */ "interval_opt ::=",
/* 137 */ "fill_opt ::=",
/* 138 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP",
/* 139 */ "fill_opt ::= FILL LP ID RP",
/* 140 */ "sliding_opt ::= SLIDING LP tmvar RP",
/* 141 */ "sliding_opt ::=",
/* 142 */ "orderby_opt ::=",
/* 143 */ "orderby_opt ::= ORDER BY sortlist",
/* 144 */ "sortlist ::= sortlist COMMA item sortorder",
/* 145 */ "sortlist ::= item sortorder",
/* 146 */ "item ::= ids cpxName",
/* 147 */ "sortorder ::= ASC",
/* 148 */ "sortorder ::= DESC",
/* 149 */ "sortorder ::=",
/* 150 */ "groupby_opt ::=",
/* 151 */ "groupby_opt ::= GROUP BY grouplist",
/* 152 */ "grouplist ::= grouplist COMMA item",
/* 153 */ "grouplist ::= item",
/* 154 */ "having_opt ::=",
/* 155 */ "having_opt ::= HAVING expr",
/* 156 */ "limit_opt ::=",
/* 157 */ "limit_opt ::= LIMIT signed",
/* 158 */ "limit_opt ::= LIMIT signed OFFSET signed",
/* 159 */ "limit_opt ::= LIMIT signed COMMA signed",
/* 160 */ "slimit_opt ::=",
/* 161 */ "slimit_opt ::= SLIMIT signed",
/* 162 */ "slimit_opt ::= SLIMIT signed SOFFSET signed",
/* 163 */ "slimit_opt ::= SLIMIT signed COMMA signed",
/* 164 */ "where_opt ::=",
/* 165 */ "where_opt ::= WHERE expr",
/* 166 */ "expr ::= LP expr RP",
/* 167 */ "expr ::= ID",
/* 168 */ "expr ::= ID DOT ID",
/* 169 */ "expr ::= ID DOT STAR",
/* 170 */ "expr ::= INTEGER",
/* 171 */ "expr ::= MINUS INTEGER",
/* 172 */ "expr ::= PLUS INTEGER",
/* 173 */ "expr ::= FLOAT",
/* 174 */ "expr ::= MINUS FLOAT",
/* 175 */ "expr ::= PLUS FLOAT",
/* 176 */ "expr ::= STRING",
/* 177 */ "expr ::= NOW",
/* 178 */ "expr ::= VARIABLE",
/* 179 */ "expr ::= BOOL",
/* 180 */ "expr ::= ID LP exprlist RP",
/* 181 */ "expr ::= ID LP STAR RP",
/* 182 */ "expr ::= expr AND expr",
/* 183 */ "expr ::= expr OR expr",
/* 184 */ "expr ::= expr LT expr",
/* 185 */ "expr ::= expr GT expr",
/* 186 */ "expr ::= expr LE expr",
/* 187 */ "expr ::= expr GE expr",
/* 188 */ "expr ::= expr NE expr",
/* 189 */ "expr ::= expr EQ expr",
/* 190 */ "expr ::= expr PLUS expr",
/* 191 */ "expr ::= expr MINUS expr",
/* 192 */ "expr ::= expr STAR expr",
/* 193 */ "expr ::= expr SLASH expr",
/* 194 */ "expr ::= expr REM expr",
/* 195 */ "expr ::= expr LIKE expr",
/* 196 */ "expr ::= expr IN LP exprlist RP",
/* 197 */ "exprlist ::= exprlist COMMA expritem",
/* 198 */ "exprlist ::= expritem",
/* 199 */ "expritem ::= expr",
/* 200 */ "expritem ::=",
/* 201 */ "cmd ::= INSERT INTO cpxName insert_value_list",
/* 202 */ "insert_value_list ::= VALUES LP itemlist RP",
/* 203 */ "insert_value_list ::= insert_value_list VALUES LP itemlist RP",
/* 204 */ "itemlist ::= itemlist COMMA expr",
/* 205 */ "itemlist ::= expr",
/* 206 */ "cmd ::= RESET QUERY CACHE",
/* 207 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist",
/* 208 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids",
/* 209 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist",
/* 210 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids",
/* 211 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids",
/* 212 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem",
/* 213 */ "cmd ::= KILL CONNECTION IPTOKEN COLON INTEGER",
/* 214 */ "cmd ::= KILL STREAM IPTOKEN COLON INTEGER COLON INTEGER",
/* 215 */ "cmd ::= KILL QUERY IPTOKEN COLON INTEGER COLON INTEGER",
};
#endif /* NDEBUG */
#if YYSTACKDEPTH<=0
/*
** Try to increase the size of the parser stack. Return the number
** of errors. Return 0 on success.
** Try to increase the size of the parser stack.
*/
static int yyGrowStack(yyParser *p){
static void yyGrowStack(yyParser *p){
int newSize;
int idx;
yyStackEntry *pNew;
newSize = p->yystksz*2 + 100;
idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;
if( p->yystack==&p->yystk0 ){
pNew = malloc(newSize*sizeof(pNew[0]));
if( pNew ) pNew[0] = p->yystk0;
}else{
pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
}
if( pNew ){
p->yystack = pNew;
p->yytos = &p->yystack[idx];
p->yystksz = newSize;
#ifndef NDEBUG
if( yyTraceFILE ){
fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n",
yyTracePrompt, p->yystksz, newSize);
fprintf(yyTraceFILE,"%sStack grows to %d entries!\n",
yyTracePrompt, p->yystksz);
}
#endif
p->yystksz = newSize;
}
return pNew==0;
}
#endif
......@@ -1233,34 +1015,6 @@ static int yyGrowStack(yyParser *p){
# define YYMALLOCARGTYPE size_t
#endif
/* Initialize a new parser that has already been allocated.
*/
void ParseInit(void *yypParser){
yyParser *pParser = (yyParser*)yypParser;
#ifdef YYTRACKMAXSTACKDEPTH
pParser->yyhwm = 0;
#endif
#if YYSTACKDEPTH<=0
pParser->yytos = NULL;
pParser->yystack = NULL;
pParser->yystksz = 0;
if( yyGrowStack(pParser) ){
pParser->yystack = &pParser->yystk0;
pParser->yystksz = 1;
}
#endif
#ifndef YYNOERRORRECOVERY
pParser->yyerrcnt = -1;
#endif
pParser->yytos = pParser->yystack;
pParser->yystack[0].stateno = 0;
pParser->yystack[0].major = 0;
#if YYSTACKDEPTH>0
pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1];
#endif
}
#ifndef Parse_ENGINEALWAYSONSTACK
/*
** This function allocates a new parser.
** The only argument is a pointer to a function which works like
......@@ -1276,11 +1030,19 @@ void ParseInit(void *yypParser){
void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){
yyParser *pParser;
pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
if( pParser ) ParseInit(pParser);
if( pParser ){
pParser->yyidx = -1;
#ifdef YYTRACKMAXSTACKDEPTH
pParser->yyidxMax = 0;
#endif
#if YYSTACKDEPTH<=0
pParser->yystack = NULL;
pParser->yystksz = 0;
yyGrowStack(pParser);
#endif
}
return pParser;
}
#endif /* Parse_ENGINEALWAYSONSTACK */
/* The following function deletes the "minor type" or semantic value
** associated with a symbol. The symbol can be either a terminal
......@@ -1307,46 +1069,46 @@ static void yy_destructor(
** inside the C code.
*/
/********* Begin destructor definitions ***************************************/
case 215: /* keep */
case 216: /* tagitemlist */
case 239: /* fill_opt */
case 241: /* groupby_opt */
case 242: /* orderby_opt */
case 251: /* sortlist */
case 255: /* grouplist */
case 216: /* keep */
case 217: /* tagitemlist */
case 240: /* fill_opt */
case 242: /* groupby_opt */
case 243: /* orderby_opt */
case 252: /* sortlist */
case 256: /* grouplist */
{
tVariantListDestroy((yypminor->yy56));
tVariantListDestroy((yypminor->yy480));
}
break;
case 231: /* columnlist */
case 232: /* columnlist */
{
tFieldListDestroy((yypminor->yy471));
tFieldListDestroy((yypminor->yy421));
}
break;
case 232: /* select */
case 233: /* select */
{
destroyQuerySql((yypminor->yy24));
destroyQuerySql((yypminor->yy138));
}
break;
case 235: /* selcollist */
case 246: /* sclp */
case 256: /* exprlist */
case 259: /* itemlist */
case 236: /* selcollist */
case 247: /* sclp */
case 257: /* exprlist */
case 260: /* itemlist */
{
tSQLExprListDestroy((yypminor->yy498));
tSQLExprListDestroy((yypminor->yy284));
}
break;
case 237: /* where_opt */
case 243: /* having_opt */
case 247: /* expr */
case 257: /* expritem */
case 238: /* where_opt */
case 244: /* having_opt */
case 248: /* expr */
case 258: /* expritem */
{
tSQLExprDestroy((yypminor->yy90));
tSQLExprDestroy((yypminor->yy244));
}
break;
case 252: /* sortitem */
case 253: /* sortitem */
{
tVariantDestroy(&(yypminor->yy186));
tVariantDestroy(&(yypminor->yy236));
}
break;
/********* End destructor definitions *****************************************/
......@@ -1362,9 +1124,8 @@ tVariantDestroy(&(yypminor->yy186));
*/
static void yy_pop_parser_stack(yyParser *pParser){
yyStackEntry *yytos;
assert( pParser->yytos!=0 );
assert( pParser->yytos > pParser->yystack );
yytos = pParser->yytos--;
assert( pParser->yyidx>=0 );
yytos = &pParser->yystack[pParser->yyidx--];
#ifndef NDEBUG
if( yyTraceFILE ){
fprintf(yyTraceFILE,"%sPopping %s\n",
......@@ -1375,18 +1136,6 @@ static void yy_pop_parser_stack(yyParser *pParser){
yy_destructor(pParser, yytos->major, &yytos->minor);
}
/*
** Clear all secondary memory allocations from the parser
*/
void ParseFinalize(void *p){
yyParser *pParser = (yyParser*)p;
while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);
#if YYSTACKDEPTH<=0
if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack);
#endif
}
#ifndef Parse_ENGINEALWAYSONSTACK
/*
** Deallocate and destroy a parser. Destructors are called for
** all stack elements before shutting the parser down.
......@@ -1399,13 +1148,16 @@ void ParseFree(
void *p, /* The parser to be deleted */
void (*freeProc)(void*) /* Function used to reclaim memory */
){
yyParser *pParser = (yyParser*)p;
#ifndef YYPARSEFREENEVERNULL
if( p==0 ) return;
if( pParser==0 ) return;
#endif
while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
#if YYSTACKDEPTH<=0
free(pParser->yystack);
#endif
ParseFinalize(p);
(*freeProc)(p);
(*freeProc)((void*)pParser);
}
#endif /* Parse_ENGINEALWAYSONSTACK */
/*
** Return the peak depth of the stack for a parser.
......@@ -1413,44 +1165,7 @@ void ParseFree(
#ifdef YYTRACKMAXSTACKDEPTH
int ParseStackPeak(void *p){
yyParser *pParser = (yyParser*)p;
return pParser->yyhwm;
}
#endif
/* This array of booleans keeps track of the parser statement
** coverage. The element yycoverage[X][Y] is set when the parser
** is in state X and has a lookahead token Y. In a well-tested
** systems, every element of this matrix should end up being set.
*/
#if defined(YYCOVERAGE)
static unsigned char yycoverage[YYNSTATE][YYNTOKEN];
#endif
/*
** Write into out a description of every state/lookahead combination that
**
** (1) has not been used by the parser, and
** (2) is not a syntax error.
**
** Return the number of missed state/lookahead combinations.
*/
#if defined(YYCOVERAGE)
int ParseCoverage(FILE *out){
int stateno, iLookAhead, i;
int nMissed = 0;
for(stateno=0; stateno<YYNSTATE; stateno++){
i = yy_shift_ofst[stateno];
for(iLookAhead=0; iLookAhead<YYNTOKEN; iLookAhead++){
if( yy_lookahead[i+iLookAhead]!=iLookAhead ) continue;
if( yycoverage[stateno][iLookAhead]==0 ) nMissed++;
if( out ){
fprintf(out,"State %d lookahead %s %s\n", stateno,
yyTokenName[iLookAhead],
yycoverage[stateno][iLookAhead] ? "ok" : "missed");
}
}
}
return nMissed;
return pParser->yyidxMax;
}
#endif
......@@ -1458,25 +1173,22 @@ int ParseCoverage(FILE *out){
** Find the appropriate action for a parser given the terminal
** look-ahead token iLookAhead.
*/
static unsigned int yy_find_shift_action(
static int yy_find_shift_action(
yyParser *pParser, /* The parser */
YYCODETYPE iLookAhead /* The look-ahead token */
){
int i;
int stateno = pParser->yytos->stateno;
int stateno = pParser->yystack[pParser->yyidx].stateno;
if( stateno>YY_MAX_SHIFT ) return stateno;
if( stateno>=YY_MIN_REDUCE ) return stateno;
assert( stateno <= YY_SHIFT_COUNT );
#if defined(YYCOVERAGE)
yycoverage[stateno][iLookAhead] = 1;
#endif
do{
i = yy_shift_ofst[stateno];
assert( i>=0 && i+YYNTOKEN<=sizeof(yy_lookahead)/sizeof(yy_lookahead[0]) );
if( i==YY_SHIFT_USE_DFLT ) return yy_default[stateno];
assert( iLookAhead!=YYNOCODE );
assert( iLookAhead < YYNTOKEN );
i += iLookAhead;
if( yy_lookahead[i]!=iLookAhead ){
if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
if( iLookAhead>0 ){
#ifdef YYFALLBACK
YYCODETYPE iFallback; /* Fallback token */
if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
......@@ -1502,7 +1214,7 @@ static unsigned int yy_find_shift_action(
#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
j<YY_ACTTAB_COUNT &&
#endif
yy_lookahead[j]==YYWILDCARD && iLookAhead>0
yy_lookahead[j]==YYWILDCARD
){
#ifndef NDEBUG
if( yyTraceFILE ){
......@@ -1515,6 +1227,7 @@ static unsigned int yy_find_shift_action(
}
}
#endif /* YYWILDCARD */
}
return yy_default[stateno];
}else{
return yy_action[i];
......@@ -1539,6 +1252,7 @@ static int yy_find_reduce_action(
assert( stateno<=YY_REDUCE_COUNT );
#endif
i = yy_reduce_ofst[stateno];
assert( i!=YY_REDUCE_USE_DFLT );
assert( iLookAhead!=YYNOCODE );
i += iLookAhead;
#ifdef YYERRORSYMBOL
......@@ -1555,14 +1269,15 @@ static int yy_find_reduce_action(
/*
** The following routine is called if the stack overflows.
*/
static void yyStackOverflow(yyParser *yypParser){
static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){
ParseARG_FETCH;
yypParser->yyidx--;
#ifndef NDEBUG
if( yyTraceFILE ){
fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
}
#endif
while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
/* Here code is inserted which will execute if the parser
** stack every overflows */
/******** Begin %stack_overflow code ******************************************/
......@@ -1574,21 +1289,20 @@ static void yyStackOverflow(yyParser *yypParser){
** Print tracing information for a SHIFT action
*/
#ifndef NDEBUG
static void yyTraceShift(yyParser *yypParser, int yyNewState, const char *zTag){
static void yyTraceShift(yyParser *yypParser, int yyNewState){
if( yyTraceFILE ){
if( yyNewState<YYNSTATE ){
fprintf(yyTraceFILE,"%s%s '%s', go to state %d\n",
yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major],
fprintf(yyTraceFILE,"%sShift '%s', go to state %d\n",
yyTracePrompt,yyTokenName[yypParser->yystack[yypParser->yyidx].major],
yyNewState);
}else{
fprintf(yyTraceFILE,"%s%s '%s', pending reduce %d\n",
yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major],
yyNewState - YY_MIN_REDUCE);
fprintf(yyTraceFILE,"%sShift '%s'\n",
yyTracePrompt,yyTokenName[yypParser->yystack[yypParser->yyidx].major]);
}
}
}
#else
# define yyTraceShift(X,Y,Z)
# define yyTraceShift(X,Y)
#endif
/*
......@@ -1598,39 +1312,34 @@ static void yy_shift(
yyParser *yypParser, /* The parser to be shifted */
int yyNewState, /* The new state to shift in */
int yyMajor, /* The major token to shift in */
ParseTOKENTYPE yyMinor /* The minor token to shift in */
YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */
){
yyStackEntry *yytos;
yypParser->yytos++;
yypParser->yyidx++;
#ifdef YYTRACKMAXSTACKDEPTH
if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
yypParser->yyhwm++;
assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
if( yypParser->yyidx>yypParser->yyidxMax ){
yypParser->yyidxMax = yypParser->yyidx;
}
#endif
#if YYSTACKDEPTH>0
if( yypParser->yytos>yypParser->yystackEnd ){
yypParser->yytos--;
yyStackOverflow(yypParser);
if( yypParser->yyidx>=YYSTACKDEPTH ){
yyStackOverflow(yypParser, yypMinor);
return;
}
#else
if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){
if( yyGrowStack(yypParser) ){
yypParser->yytos--;
yyStackOverflow(yypParser);
if( yypParser->yyidx>=yypParser->yystksz ){
yyGrowStack(yypParser);
if( yypParser->yyidx>=yypParser->yystksz ){
yyStackOverflow(yypParser, yypMinor);
return;
}
}
#endif
if( yyNewState > YY_MAX_SHIFT ){
yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
}
yytos = yypParser->yytos;
yytos = &yypParser->yystack[yypParser->yyidx];
yytos->stateno = (YYACTIONTYPE)yyNewState;
yytos->major = (YYCODETYPE)yyMajor;
yytos->minor.yy0 = yyMinor;
yyTraceShift(yypParser, yyNewState, "Shift");
yytos->minor = *yypMinor;
yyTraceShift(yypParser, yyNewState);
}
/* The following table contains information about every rule that
......@@ -1638,222 +1347,224 @@ static void yy_shift(
*/
static const struct {
YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
signed char nrhs; /* Negative of the number of RHS symbols in the rule */
unsigned char nrhs; /* Number of right-hand side symbols in the rule */
} yyRuleInfo[] = {
{ 196, -1 }, /* (0) program ::= cmd */
{ 197, -2 }, /* (1) cmd ::= SHOW DATABASES */
{ 197, -2 }, /* (2) cmd ::= SHOW MNODES */
{ 197, -2 }, /* (3) cmd ::= SHOW DNODES */
{ 197, -2 }, /* (4) cmd ::= SHOW ACCOUNTS */
{ 197, -2 }, /* (5) cmd ::= SHOW USERS */
{ 197, -2 }, /* (6) cmd ::= SHOW MODULES */
{ 197, -2 }, /* (7) cmd ::= SHOW QUERIES */
{ 197, -2 }, /* (8) cmd ::= SHOW CONNECTIONS */
{ 197, -2 }, /* (9) cmd ::= SHOW STREAMS */
{ 197, -2 }, /* (10) cmd ::= SHOW CONFIGS */
{ 197, -2 }, /* (11) cmd ::= SHOW SCORES */
{ 197, -2 }, /* (12) cmd ::= SHOW GRANTS */
{ 198, 0 }, /* (13) dbPrefix ::= */
{ 198, -2 }, /* (14) dbPrefix ::= ids DOT */
{ 200, 0 }, /* (15) cpxName ::= */
{ 200, -2 }, /* (16) cpxName ::= DOT ids */
{ 197, -3 }, /* (17) cmd ::= SHOW dbPrefix TABLES */
{ 197, -5 }, /* (18) cmd ::= SHOW dbPrefix TABLES LIKE ids */
{ 197, -3 }, /* (19) cmd ::= SHOW dbPrefix STABLES */
{ 197, -5 }, /* (20) cmd ::= SHOW dbPrefix STABLES LIKE ids */
{ 197, -3 }, /* (21) cmd ::= SHOW dbPrefix VGROUPS */
{ 197, -5 }, /* (22) cmd ::= DROP TABLE ifexists ids cpxName */
{ 197, -4 }, /* (23) cmd ::= DROP DATABASE ifexists ids */
{ 197, -3 }, /* (24) cmd ::= DROP DNODE IPTOKEN */
{ 197, -3 }, /* (25) cmd ::= DROP USER ids */
{ 197, -3 }, /* (26) cmd ::= DROP ACCOUNT ids */
{ 197, -2 }, /* (27) cmd ::= USE ids */
{ 197, -3 }, /* (28) cmd ::= DESCRIBE ids cpxName */
{ 197, -5 }, /* (29) cmd ::= ALTER USER ids PASS ids */
{ 197, -5 }, /* (30) cmd ::= ALTER USER ids PRIVILEGE ids */
{ 197, -4 }, /* (31) cmd ::= ALTER DNODE IPTOKEN ids */
{ 197, -5 }, /* (32) cmd ::= ALTER DNODE IPTOKEN ids ids */
{ 197, -3 }, /* (33) cmd ::= ALTER LOCAL ids */
{ 197, -4 }, /* (34) cmd ::= ALTER LOCAL ids ids */
{ 197, -4 }, /* (35) cmd ::= ALTER DATABASE ids alter_db_optr */
{ 197, -4 }, /* (36) cmd ::= ALTER ACCOUNT ids acct_optr */
{ 197, -6 }, /* (37) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */
{ 199, -1 }, /* (38) ids ::= ID */
{ 199, -1 }, /* (39) ids ::= STRING */
{ 201, -2 }, /* (40) ifexists ::= IF EXISTS */
{ 201, 0 }, /* (41) ifexists ::= */
{ 204, -3 }, /* (42) ifnotexists ::= IF NOT EXISTS */
{ 204, 0 }, /* (43) ifnotexists ::= */
{ 197, -3 }, /* (44) cmd ::= CREATE DNODE IPTOKEN */
{ 197, -6 }, /* (45) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */
{ 197, -5 }, /* (46) cmd ::= CREATE DATABASE ifnotexists ids db_optr */
{ 197, -5 }, /* (47) cmd ::= CREATE USER ids PASS ids */
{ 206, 0 }, /* (48) pps ::= */
{ 206, -2 }, /* (49) pps ::= PPS INTEGER */
{ 207, 0 }, /* (50) tseries ::= */
{ 207, -2 }, /* (51) tseries ::= TSERIES INTEGER */
{ 208, 0 }, /* (52) dbs ::= */
{ 208, -2 }, /* (53) dbs ::= DBS INTEGER */
{ 209, 0 }, /* (54) streams ::= */
{ 209, -2 }, /* (55) streams ::= STREAMS INTEGER */
{ 210, 0 }, /* (56) storage ::= */
{ 210, -2 }, /* (57) storage ::= STORAGE INTEGER */
{ 211, 0 }, /* (58) qtime ::= */
{ 211, -2 }, /* (59) qtime ::= QTIME INTEGER */
{ 212, 0 }, /* (60) users ::= */
{ 212, -2 }, /* (61) users ::= USERS INTEGER */
{ 213, 0 }, /* (62) conns ::= */
{ 213, -2 }, /* (63) conns ::= CONNS INTEGER */
{ 214, 0 }, /* (64) state ::= */
{ 214, -2 }, /* (65) state ::= STATE ids */
{ 203, -9 }, /* (66) acct_optr ::= pps tseries storage streams qtime dbs users conns state */
{ 215, -2 }, /* (67) keep ::= KEEP tagitemlist */
{ 217, -2 }, /* (68) tables ::= TABLES INTEGER */
{ 218, -2 }, /* (69) cache ::= CACHE INTEGER */
{ 219, -2 }, /* (70) replica ::= REPLICA INTEGER */
{ 220, -2 }, /* (71) days ::= DAYS INTEGER */
{ 221, -2 }, /* (72) rows ::= ROWS INTEGER */
{ 222, -2 }, /* (73) ablocks ::= ABLOCKS ID */
{ 223, -2 }, /* (74) tblocks ::= TBLOCKS INTEGER */
{ 224, -2 }, /* (75) ctime ::= CTIME INTEGER */
{ 225, -2 }, /* (76) clog ::= CLOG INTEGER */
{ 226, -2 }, /* (77) comp ::= COMP INTEGER */
{ 227, -2 }, /* (78) prec ::= PRECISION STRING */
{ 205, 0 }, /* (79) db_optr ::= */
{ 205, -2 }, /* (80) db_optr ::= db_optr tables */
{ 205, -2 }, /* (81) db_optr ::= db_optr cache */
{ 205, -2 }, /* (82) db_optr ::= db_optr replica */
{ 205, -2 }, /* (83) db_optr ::= db_optr days */
{ 205, -2 }, /* (84) db_optr ::= db_optr rows */
{ 205, -2 }, /* (85) db_optr ::= db_optr ablocks */
{ 205, -2 }, /* (86) db_optr ::= db_optr tblocks */
{ 205, -2 }, /* (87) db_optr ::= db_optr ctime */
{ 205, -2 }, /* (88) db_optr ::= db_optr clog */
{ 205, -2 }, /* (89) db_optr ::= db_optr comp */
{ 205, -2 }, /* (90) db_optr ::= db_optr prec */
{ 205, -2 }, /* (91) db_optr ::= db_optr keep */
{ 202, 0 }, /* (92) alter_db_optr ::= */
{ 202, -2 }, /* (93) alter_db_optr ::= alter_db_optr replica */
{ 202, -2 }, /* (94) alter_db_optr ::= alter_db_optr tables */
{ 228, -1 }, /* (95) typename ::= ids */
{ 228, -4 }, /* (96) typename ::= ids LP signed RP */
{ 229, -1 }, /* (97) signed ::= INTEGER */
{ 229, -2 }, /* (98) signed ::= PLUS INTEGER */
{ 229, -2 }, /* (99) signed ::= MINUS INTEGER */
{ 197, -6 }, /* (100) cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */
{ 230, -3 }, /* (101) create_table_args ::= LP columnlist RP */
{ 230, -7 }, /* (102) create_table_args ::= LP columnlist RP TAGS LP columnlist RP */
{ 230, -7 }, /* (103) create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */
{ 230, -2 }, /* (104) create_table_args ::= AS select */
{ 231, -3 }, /* (105) columnlist ::= columnlist COMMA column */
{ 231, -1 }, /* (106) columnlist ::= column */
{ 233, -2 }, /* (107) column ::= ids typename */
{ 216, -3 }, /* (108) tagitemlist ::= tagitemlist COMMA tagitem */
{ 216, -1 }, /* (109) tagitemlist ::= tagitem */
{ 234, -1 }, /* (110) tagitem ::= INTEGER */
{ 234, -1 }, /* (111) tagitem ::= FLOAT */
{ 234, -1 }, /* (112) tagitem ::= STRING */
{ 234, -1 }, /* (113) tagitem ::= BOOL */
{ 234, -1 }, /* (114) tagitem ::= NULL */
{ 234, -2 }, /* (115) tagitem ::= MINUS INTEGER */
{ 234, -2 }, /* (116) tagitem ::= MINUS FLOAT */
{ 234, -2 }, /* (117) tagitem ::= PLUS INTEGER */
{ 234, -2 }, /* (118) tagitem ::= PLUS FLOAT */
{ 197, -1 }, /* (119) cmd ::= select */
{ 232, -12 }, /* (120) select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */
{ 232, -2 }, /* (121) select ::= SELECT selcollist */
{ 246, -2 }, /* (122) sclp ::= selcollist COMMA */
{ 246, 0 }, /* (123) sclp ::= */
{ 235, -3 }, /* (124) selcollist ::= sclp expr as */
{ 235, -2 }, /* (125) selcollist ::= sclp STAR */
{ 248, -2 }, /* (126) as ::= AS ids */
{ 248, -1 }, /* (127) as ::= ids */
{ 248, 0 }, /* (128) as ::= */
{ 236, -2 }, /* (129) from ::= FROM tablelist */
{ 249, -2 }, /* (130) tablelist ::= ids cpxName */
{ 249, -4 }, /* (131) tablelist ::= tablelist COMMA ids cpxName */
{ 250, -1 }, /* (132) tmvar ::= VARIABLE */
{ 238, -4 }, /* (133) interval_opt ::= INTERVAL LP tmvar RP */
{ 238, 0 }, /* (134) interval_opt ::= */
{ 239, 0 }, /* (135) fill_opt ::= */
{ 239, -6 }, /* (136) fill_opt ::= FILL LP ID COMMA tagitemlist RP */
{ 239, -4 }, /* (137) fill_opt ::= FILL LP ID RP */
{ 240, -4 }, /* (138) sliding_opt ::= SLIDING LP tmvar RP */
{ 240, 0 }, /* (139) sliding_opt ::= */
{ 242, 0 }, /* (140) orderby_opt ::= */
{ 242, -3 }, /* (141) orderby_opt ::= ORDER BY sortlist */
{ 251, -4 }, /* (142) sortlist ::= sortlist COMMA item sortorder */
{ 251, -2 }, /* (143) sortlist ::= item sortorder */
{ 253, -2 }, /* (144) item ::= ids cpxName */
{ 254, -1 }, /* (145) sortorder ::= ASC */
{ 254, -1 }, /* (146) sortorder ::= DESC */
{ 254, 0 }, /* (147) sortorder ::= */
{ 241, 0 }, /* (148) groupby_opt ::= */
{ 241, -3 }, /* (149) groupby_opt ::= GROUP BY grouplist */
{ 255, -3 }, /* (150) grouplist ::= grouplist COMMA item */
{ 255, -1 }, /* (151) grouplist ::= item */
{ 243, 0 }, /* (152) having_opt ::= */
{ 243, -2 }, /* (153) having_opt ::= HAVING expr */
{ 245, 0 }, /* (154) limit_opt ::= */
{ 245, -2 }, /* (155) limit_opt ::= LIMIT signed */
{ 245, -4 }, /* (156) limit_opt ::= LIMIT signed OFFSET signed */
{ 245, -4 }, /* (157) limit_opt ::= LIMIT signed COMMA signed */
{ 244, 0 }, /* (158) slimit_opt ::= */
{ 244, -2 }, /* (159) slimit_opt ::= SLIMIT signed */
{ 244, -4 }, /* (160) slimit_opt ::= SLIMIT signed SOFFSET signed */
{ 244, -4 }, /* (161) slimit_opt ::= SLIMIT signed COMMA signed */
{ 237, 0 }, /* (162) where_opt ::= */
{ 237, -2 }, /* (163) where_opt ::= WHERE expr */
{ 247, -3 }, /* (164) expr ::= LP expr RP */
{ 247, -1 }, /* (165) expr ::= ID */
{ 247, -3 }, /* (166) expr ::= ID DOT ID */
{ 247, -3 }, /* (167) expr ::= ID DOT STAR */
{ 247, -1 }, /* (168) expr ::= INTEGER */
{ 247, -2 }, /* (169) expr ::= MINUS INTEGER */
{ 247, -2 }, /* (170) expr ::= PLUS INTEGER */
{ 247, -1 }, /* (171) expr ::= FLOAT */
{ 247, -2 }, /* (172) expr ::= MINUS FLOAT */
{ 247, -2 }, /* (173) expr ::= PLUS FLOAT */
{ 247, -1 }, /* (174) expr ::= STRING */
{ 247, -1 }, /* (175) expr ::= NOW */
{ 247, -1 }, /* (176) expr ::= VARIABLE */
{ 247, -1 }, /* (177) expr ::= BOOL */
{ 247, -4 }, /* (178) expr ::= ID LP exprlist RP */
{ 247, -4 }, /* (179) expr ::= ID LP STAR RP */
{ 247, -3 }, /* (180) expr ::= expr AND expr */
{ 247, -3 }, /* (181) expr ::= expr OR expr */
{ 247, -3 }, /* (182) expr ::= expr LT expr */
{ 247, -3 }, /* (183) expr ::= expr GT expr */
{ 247, -3 }, /* (184) expr ::= expr LE expr */
{ 247, -3 }, /* (185) expr ::= expr GE expr */
{ 247, -3 }, /* (186) expr ::= expr NE expr */
{ 247, -3 }, /* (187) expr ::= expr EQ expr */
{ 247, -3 }, /* (188) expr ::= expr PLUS expr */
{ 247, -3 }, /* (189) expr ::= expr MINUS expr */
{ 247, -3 }, /* (190) expr ::= expr STAR expr */
{ 247, -3 }, /* (191) expr ::= expr SLASH expr */
{ 247, -3 }, /* (192) expr ::= expr REM expr */
{ 247, -3 }, /* (193) expr ::= expr LIKE expr */
{ 247, -5 }, /* (194) expr ::= expr IN LP exprlist RP */
{ 256, -3 }, /* (195) exprlist ::= exprlist COMMA expritem */
{ 256, -1 }, /* (196) exprlist ::= expritem */
{ 257, -1 }, /* (197) expritem ::= expr */
{ 257, 0 }, /* (198) expritem ::= */
{ 197, -4 }, /* (199) cmd ::= INSERT INTO cpxName insert_value_list */
{ 258, -4 }, /* (200) insert_value_list ::= VALUES LP itemlist RP */
{ 258, -5 }, /* (201) insert_value_list ::= insert_value_list VALUES LP itemlist RP */
{ 259, -3 }, /* (202) itemlist ::= itemlist COMMA expr */
{ 259, -1 }, /* (203) itemlist ::= expr */
{ 197, -3 }, /* (204) cmd ::= RESET QUERY CACHE */
{ 197, -7 }, /* (205) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
{ 197, -7 }, /* (206) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
{ 197, -7 }, /* (207) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
{ 197, -7 }, /* (208) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
{ 197, -8 }, /* (209) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
{ 197, -9 }, /* (210) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
{ 197, -5 }, /* (211) cmd ::= KILL CONNECTION IPTOKEN COLON INTEGER */
{ 197, -7 }, /* (212) cmd ::= KILL STREAM IPTOKEN COLON INTEGER COLON INTEGER */
{ 197, -7 }, /* (213) cmd ::= KILL QUERY IPTOKEN COLON INTEGER COLON INTEGER */
{ 197, 1 },
{ 198, 2 },
{ 198, 2 },
{ 198, 2 },
{ 198, 2 },
{ 198, 2 },
{ 198, 2 },
{ 198, 2 },
{ 198, 2 },
{ 198, 2 },
{ 198, 2 },
{ 198, 2 },
{ 198, 2 },
{ 198, 2 },
{ 198, 3 },
{ 199, 0 },
{ 199, 2 },
{ 201, 0 },
{ 201, 2 },
{ 198, 3 },
{ 198, 5 },
{ 198, 3 },
{ 198, 5 },
{ 198, 3 },
{ 198, 5 },
{ 198, 4 },
{ 198, 3 },
{ 198, 3 },
{ 198, 3 },
{ 198, 2 },
{ 198, 3 },
{ 198, 5 },
{ 198, 5 },
{ 198, 4 },
{ 198, 5 },
{ 198, 3 },
{ 198, 4 },
{ 198, 4 },
{ 198, 4 },
{ 198, 6 },
{ 200, 1 },
{ 200, 1 },
{ 202, 2 },
{ 202, 0 },
{ 205, 3 },
{ 205, 0 },
{ 198, 3 },
{ 198, 6 },
{ 198, 5 },
{ 198, 5 },
{ 207, 0 },
{ 207, 2 },
{ 208, 0 },
{ 208, 2 },
{ 209, 0 },
{ 209, 2 },
{ 210, 0 },
{ 210, 2 },
{ 211, 0 },
{ 211, 2 },
{ 212, 0 },
{ 212, 2 },
{ 213, 0 },
{ 213, 2 },
{ 214, 0 },
{ 214, 2 },
{ 215, 0 },
{ 215, 2 },
{ 204, 9 },
{ 216, 2 },
{ 218, 2 },
{ 219, 2 },
{ 220, 2 },
{ 221, 2 },
{ 222, 2 },
{ 223, 2 },
{ 224, 2 },
{ 225, 2 },
{ 226, 2 },
{ 227, 2 },
{ 228, 2 },
{ 206, 0 },
{ 206, 2 },
{ 206, 2 },
{ 206, 2 },
{ 206, 2 },
{ 206, 2 },
{ 206, 2 },
{ 206, 2 },
{ 206, 2 },
{ 206, 2 },
{ 206, 2 },
{ 206, 2 },
{ 206, 2 },
{ 203, 0 },
{ 203, 2 },
{ 203, 2 },
{ 229, 1 },
{ 229, 4 },
{ 230, 1 },
{ 230, 2 },
{ 230, 2 },
{ 198, 6 },
{ 231, 3 },
{ 231, 7 },
{ 231, 7 },
{ 231, 2 },
{ 232, 3 },
{ 232, 1 },
{ 234, 2 },
{ 217, 3 },
{ 217, 1 },
{ 235, 1 },
{ 235, 1 },
{ 235, 1 },
{ 235, 1 },
{ 235, 1 },
{ 235, 2 },
{ 235, 2 },
{ 235, 2 },
{ 235, 2 },
{ 198, 1 },
{ 233, 12 },
{ 233, 2 },
{ 247, 2 },
{ 247, 0 },
{ 236, 3 },
{ 236, 2 },
{ 249, 2 },
{ 249, 1 },
{ 249, 0 },
{ 237, 2 },
{ 250, 2 },
{ 250, 4 },
{ 251, 1 },
{ 239, 4 },
{ 239, 0 },
{ 240, 0 },
{ 240, 6 },
{ 240, 4 },
{ 241, 4 },
{ 241, 0 },
{ 243, 0 },
{ 243, 3 },
{ 252, 4 },
{ 252, 2 },
{ 254, 2 },
{ 255, 1 },
{ 255, 1 },
{ 255, 0 },
{ 242, 0 },
{ 242, 3 },
{ 256, 3 },
{ 256, 1 },
{ 244, 0 },
{ 244, 2 },
{ 246, 0 },
{ 246, 2 },
{ 246, 4 },
{ 246, 4 },
{ 245, 0 },
{ 245, 2 },
{ 245, 4 },
{ 245, 4 },
{ 238, 0 },
{ 238, 2 },
{ 248, 3 },
{ 248, 1 },
{ 248, 3 },
{ 248, 3 },
{ 248, 1 },
{ 248, 2 },
{ 248, 2 },
{ 248, 1 },
{ 248, 2 },
{ 248, 2 },
{ 248, 1 },
{ 248, 1 },
{ 248, 1 },
{ 248, 1 },
{ 248, 4 },
{ 248, 4 },
{ 248, 3 },
{ 248, 3 },
{ 248, 3 },
{ 248, 3 },
{ 248, 3 },
{ 248, 3 },
{ 248, 3 },
{ 248, 3 },
{ 248, 3 },
{ 248, 3 },
{ 248, 3 },
{ 248, 3 },
{ 248, 3 },
{ 248, 3 },
{ 248, 5 },
{ 257, 3 },
{ 257, 1 },
{ 258, 1 },
{ 258, 0 },
{ 198, 4 },
{ 259, 4 },
{ 259, 5 },
{ 260, 3 },
{ 260, 1 },
{ 198, 3 },
{ 198, 7 },
{ 198, 7 },
{ 198, 7 },
{ 198, 7 },
{ 198, 8 },
{ 198, 9 },
{ 198, 5 },
{ 198, 7 },
{ 198, 7 },
};
static void yy_accept(yyParser*); /* Forward Declaration */
......@@ -1861,66 +1572,27 @@ static void yy_accept(yyParser*); /* Forward Declaration */
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
**
** The yyLookahead and yyLookaheadToken parameters provide reduce actions
** access to the lookahead token (if any). The yyLookahead will be YYNOCODE
** if the lookahead token has already been consumed. As this procedure is
** only called from one place, optimizing compilers will in-line it, which
** means that the extra parameters have no performance impact.
*/
static void yy_reduce(
yyParser *yypParser, /* The parser */
unsigned int yyruleno, /* Number of the rule by which to reduce */
int yyLookahead, /* Lookahead token, or YYNOCODE if none */
ParseTOKENTYPE yyLookaheadToken /* Value of the lookahead token */
int yyruleno /* Number of the rule by which to reduce */
){
int yygoto; /* The next state */
int yyact; /* The next action */
YYMINORTYPE yygotominor; /* The LHS of the rule reduced */
yyStackEntry *yymsp; /* The top of the parser's stack */
int yysize; /* Amount to pop the stack */
ParseARG_FETCH;
(void)yyLookahead;
(void)yyLookaheadToken;
yymsp = yypParser->yytos;
yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
if( yyTraceFILE && yyruleno>=0
&& yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
yysize = yyRuleInfo[yyruleno].nrhs;
if( yysize ){
fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n",
yyTracePrompt,
yyruleno, yyRuleName[yyruleno], yymsp[yysize].stateno);
}else{
fprintf(yyTraceFILE, "%sReduce %d [%s].\n",
yyTracePrompt, yyruleno, yyRuleName[yyruleno]);
}
fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
yyRuleName[yyruleno], yymsp[-yysize].stateno);
}
#endif /* NDEBUG */
/* Check that the stack is large enough to grow by a single entry
** if the RHS of the rule is empty. This ensures that there is room
** enough on the stack to push the LHS value */
if( yyRuleInfo[yyruleno].nrhs==0 ){
#ifdef YYTRACKMAXSTACKDEPTH
if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
yypParser->yyhwm++;
assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));
}
#endif
#if YYSTACKDEPTH>0
if( yypParser->yytos>=yypParser->yystackEnd ){
yyStackOverflow(yypParser);
return;
}
#else
if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
if( yyGrowStack(yypParser) ){
yyStackOverflow(yypParser);
return;
}
yymsp = yypParser->yytos;
}
#endif
}
yygotominor = yyzerominor;
switch( yyruleno ){
/* Beginning here are the reduction cases. A typical example
......@@ -1932,7 +1604,6 @@ static void yy_reduce(
** break;
*/
/********** Begin reduce actions **********************************************/
YYMINORTYPE yylhsminor;
case 0: /* program ::= cmd */
{}
break;
......@@ -1972,654 +1643,578 @@ static void yy_reduce(
case 12: /* cmd ::= SHOW GRANTS */
{ setDCLSQLElems(pInfo, SHOW_GRANTS, 0); }
break;
case 13: /* dbPrefix ::= */
case 41: /* ifexists ::= */ yytestcase(yyruleno==41);
case 43: /* ifnotexists ::= */ yytestcase(yyruleno==43);
{yymsp[1].minor.yy0.n = 0;}
case 13: /* cmd ::= SHOW VNODES */
{ setDCLSQLElems(pInfo, SHOW_VNODES, 0); }
break;
case 14: /* cmd ::= SHOW VNODES IPTOKEN */
{ setDCLSQLElems(pInfo, SHOW_VNODES, 1, &yymsp[0].minor.yy0); }
break;
case 15: /* dbPrefix ::= */
case 43: /* ifexists ::= */ yytestcase(yyruleno==43);
case 45: /* ifnotexists ::= */ yytestcase(yyruleno==45);
{yygotominor.yy0.n = 0;}
break;
case 14: /* dbPrefix ::= ids DOT */
{yylhsminor.yy0 = yymsp[-1].minor.yy0; }
yymsp[-1].minor.yy0 = yylhsminor.yy0;
case 16: /* dbPrefix ::= ids DOT */
{yygotominor.yy0 = yymsp[-1].minor.yy0; }
break;
case 15: /* cpxName ::= */
{yymsp[1].minor.yy0.n = 0; }
case 17: /* cpxName ::= */
{yygotominor.yy0.n = 0; }
break;
case 16: /* cpxName ::= DOT ids */
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n += 1; }
case 18: /* cpxName ::= DOT ids */
{yygotominor.yy0 = yymsp[0].minor.yy0; yygotominor.yy0.n += 1; }
break;
case 17: /* cmd ::= SHOW dbPrefix TABLES */
case 19: /* cmd ::= SHOW dbPrefix TABLES */
{
setDCLSQLElems(pInfo, SHOW_TABLES, 1, &yymsp[-1].minor.yy0);
}
break;
case 18: /* cmd ::= SHOW dbPrefix TABLES LIKE ids */
case 20: /* cmd ::= SHOW dbPrefix TABLES LIKE ids */
{
setDCLSQLElems(pInfo, SHOW_TABLES, 2, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0);
}
break;
case 19: /* cmd ::= SHOW dbPrefix STABLES */
case 21: /* cmd ::= SHOW dbPrefix STABLES */
{
setDCLSQLElems(pInfo, SHOW_STABLES, 1, &yymsp[-1].minor.yy0);
}
break;
case 20: /* cmd ::= SHOW dbPrefix STABLES LIKE ids */
case 22: /* cmd ::= SHOW dbPrefix STABLES LIKE ids */
{
SSQLToken token;
setDBName(&token, &yymsp[-3].minor.yy0);
setDCLSQLElems(pInfo, SHOW_STABLES, 2, &token, &yymsp[0].minor.yy0);
}
break;
case 21: /* cmd ::= SHOW dbPrefix VGROUPS */
case 23: /* cmd ::= SHOW dbPrefix VGROUPS */
{
SSQLToken token;
setDBName(&token, &yymsp[-1].minor.yy0);
setDCLSQLElems(pInfo, SHOW_VGROUPS, 1, &token);
}
break;
case 22: /* cmd ::= DROP TABLE ifexists ids cpxName */
case 24: /* cmd ::= DROP TABLE ifexists ids cpxName */
{
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
setDCLSQLElems(pInfo, DROP_TABLE, 2, &yymsp[-1].minor.yy0, &yymsp[-2].minor.yy0);
}
break;
case 23: /* cmd ::= DROP DATABASE ifexists ids */
case 25: /* cmd ::= DROP DATABASE ifexists ids */
{ setDCLSQLElems(pInfo, DROP_DATABASE, 2, &yymsp[0].minor.yy0, &yymsp[-1].minor.yy0); }
break;
case 24: /* cmd ::= DROP DNODE IPTOKEN */
case 26: /* cmd ::= DROP DNODE IPTOKEN */
{ setDCLSQLElems(pInfo, DROP_DNODE, 1, &yymsp[0].minor.yy0); }
break;
case 25: /* cmd ::= DROP USER ids */
case 27: /* cmd ::= DROP USER ids */
{ setDCLSQLElems(pInfo, DROP_USER, 1, &yymsp[0].minor.yy0); }
break;
case 26: /* cmd ::= DROP ACCOUNT ids */
case 28: /* cmd ::= DROP ACCOUNT ids */
{ setDCLSQLElems(pInfo, DROP_ACCOUNT, 1, &yymsp[0].minor.yy0); }
break;
case 27: /* cmd ::= USE ids */
case 29: /* cmd ::= USE ids */
{ setDCLSQLElems(pInfo, USE_DATABASE, 1, &yymsp[0].minor.yy0);}
break;
case 28: /* cmd ::= DESCRIBE ids cpxName */
case 30: /* cmd ::= DESCRIBE ids cpxName */
{
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
setDCLSQLElems(pInfo, DESCRIBE_TABLE, 1, &yymsp[-1].minor.yy0);
}
break;
case 29: /* cmd ::= ALTER USER ids PASS ids */
case 31: /* cmd ::= ALTER USER ids PASS ids */
{ setDCLSQLElems(pInfo, ALTER_USER_PASSWD, 2, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); }
break;
case 30: /* cmd ::= ALTER USER ids PRIVILEGE ids */
case 32: /* cmd ::= ALTER USER ids PRIVILEGE ids */
{ setDCLSQLElems(pInfo, ALTER_USER_PRIVILEGES, 2, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);}
break;
case 31: /* cmd ::= ALTER DNODE IPTOKEN ids */
case 33: /* cmd ::= ALTER DNODE IPTOKEN ids */
{ setDCLSQLElems(pInfo, ALTER_DNODE, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); }
break;
case 32: /* cmd ::= ALTER DNODE IPTOKEN ids ids */
case 34: /* cmd ::= ALTER DNODE IPTOKEN ids ids */
{ setDCLSQLElems(pInfo, ALTER_DNODE, 3, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); }
break;
case 33: /* cmd ::= ALTER LOCAL ids */
case 35: /* cmd ::= ALTER LOCAL ids */
{ setDCLSQLElems(pInfo, ALTER_LOCAL, 1, &yymsp[0].minor.yy0); }
break;
case 34: /* cmd ::= ALTER LOCAL ids ids */
case 36: /* cmd ::= ALTER LOCAL ids ids */
{ setDCLSQLElems(pInfo, ALTER_LOCAL, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); }
break;
case 35: /* cmd ::= ALTER DATABASE ids alter_db_optr */
{ SSQLToken t = {0}; setCreateDBSQL(pInfo, ALTER_DATABASE, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy398, &t);}
case 37: /* cmd ::= ALTER DATABASE ids alter_db_optr */
{ SSQLToken t = {0}; setCreateDBSQL(pInfo, ALTER_DATABASE, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy262, &t);}
break;
case 36: /* cmd ::= ALTER ACCOUNT ids acct_optr */
{ SSQLToken t = {0}; setCreateAcctSQL(pInfo, ALTER_ACCT, &yymsp[-1].minor.yy0, &t, &yymsp[0].minor.yy279);}
case 38: /* cmd ::= ALTER ACCOUNT ids acct_optr */
{ SSQLToken t = {0}; setCreateAcctSQL(pInfo, ALTER_ACCT, &yymsp[-1].minor.yy0, &t, &yymsp[0].minor.yy155);}
break;
case 37: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */
{ setCreateAcctSQL(pInfo, ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy279);}
case 39: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */
{ setCreateAcctSQL(pInfo, ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy155);}
break;
case 38: /* ids ::= ID */
case 39: /* ids ::= STRING */ yytestcase(yyruleno==39);
{yylhsminor.yy0 = yymsp[0].minor.yy0; }
yymsp[0].minor.yy0 = yylhsminor.yy0;
case 40: /* ids ::= ID */
case 41: /* ids ::= STRING */ yytestcase(yyruleno==41);
{yygotominor.yy0 = yymsp[0].minor.yy0; }
break;
case 40: /* ifexists ::= IF EXISTS */
{yymsp[-1].minor.yy0.n = 1;}
case 42: /* ifexists ::= IF EXISTS */
case 44: /* ifnotexists ::= IF NOT EXISTS */ yytestcase(yyruleno==44);
{yygotominor.yy0.n = 1;}
break;
case 42: /* ifnotexists ::= IF NOT EXISTS */
{yymsp[-2].minor.yy0.n = 1;}
break;
case 44: /* cmd ::= CREATE DNODE IPTOKEN */
case 46: /* cmd ::= CREATE DNODE IPTOKEN */
{ setDCLSQLElems(pInfo, CREATE_DNODE, 1, &yymsp[0].minor.yy0);}
break;
case 45: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */
{ setCreateAcctSQL(pInfo, CREATE_ACCOUNT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy279);}
case 47: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */
{ setCreateAcctSQL(pInfo, CREATE_ACCOUNT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy155);}
break;
case 46: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */
{ setCreateDBSQL(pInfo, CREATE_DATABASE, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy398, &yymsp[-2].minor.yy0);}
case 48: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */
{ setCreateDBSQL(pInfo, CREATE_DATABASE, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy262, &yymsp[-2].minor.yy0);}
break;
case 47: /* cmd ::= CREATE USER ids PASS ids */
case 49: /* cmd ::= CREATE USER ids PASS ids */
{ setDCLSQLElems(pInfo, CREATE_USER, 2, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);}
break;
case 48: /* pps ::= */
case 50: /* tseries ::= */ yytestcase(yyruleno==50);
case 52: /* dbs ::= */ yytestcase(yyruleno==52);
case 54: /* streams ::= */ yytestcase(yyruleno==54);
case 56: /* storage ::= */ yytestcase(yyruleno==56);
case 58: /* qtime ::= */ yytestcase(yyruleno==58);
case 60: /* users ::= */ yytestcase(yyruleno==60);
case 62: /* conns ::= */ yytestcase(yyruleno==62);
case 64: /* state ::= */ yytestcase(yyruleno==64);
{yymsp[1].minor.yy0.n = 0; }
break;
case 49: /* pps ::= PPS INTEGER */
case 51: /* tseries ::= TSERIES INTEGER */ yytestcase(yyruleno==51);
case 53: /* dbs ::= DBS INTEGER */ yytestcase(yyruleno==53);
case 55: /* streams ::= STREAMS INTEGER */ yytestcase(yyruleno==55);
case 57: /* storage ::= STORAGE INTEGER */ yytestcase(yyruleno==57);
case 59: /* qtime ::= QTIME INTEGER */ yytestcase(yyruleno==59);
case 61: /* users ::= USERS INTEGER */ yytestcase(yyruleno==61);
case 63: /* conns ::= CONNS INTEGER */ yytestcase(yyruleno==63);
case 65: /* state ::= STATE ids */ yytestcase(yyruleno==65);
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; }
break;
case 66: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */
case 50: /* pps ::= */
case 52: /* tseries ::= */ yytestcase(yyruleno==52);
case 54: /* dbs ::= */ yytestcase(yyruleno==54);
case 56: /* streams ::= */ yytestcase(yyruleno==56);
case 58: /* storage ::= */ yytestcase(yyruleno==58);
case 60: /* qtime ::= */ yytestcase(yyruleno==60);
case 62: /* users ::= */ yytestcase(yyruleno==62);
case 64: /* conns ::= */ yytestcase(yyruleno==64);
case 66: /* state ::= */ yytestcase(yyruleno==66);
{yygotominor.yy0.n = 0; }
break;
case 51: /* pps ::= PPS INTEGER */
case 53: /* tseries ::= TSERIES INTEGER */ yytestcase(yyruleno==53);
case 55: /* dbs ::= DBS INTEGER */ yytestcase(yyruleno==55);
case 57: /* streams ::= STREAMS INTEGER */ yytestcase(yyruleno==57);
case 59: /* storage ::= STORAGE INTEGER */ yytestcase(yyruleno==59);
case 61: /* qtime ::= QTIME INTEGER */ yytestcase(yyruleno==61);
case 63: /* users ::= USERS INTEGER */ yytestcase(yyruleno==63);
case 65: /* conns ::= CONNS INTEGER */ yytestcase(yyruleno==65);
case 67: /* state ::= STATE ids */ yytestcase(yyruleno==67);
{yygotominor.yy0 = yymsp[0].minor.yy0; }
break;
case 68: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */
{
yylhsminor.yy279.users = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1;
yylhsminor.yy279.dbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1;
yylhsminor.yy279.tseries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1;
yylhsminor.yy279.streams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1;
yylhsminor.yy279.pps = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1;
yylhsminor.yy279.storage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1;
yylhsminor.yy279.qtime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1;
yylhsminor.yy279.conns = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1;
yylhsminor.yy279.stat = yymsp[0].minor.yy0;
yygotominor.yy155.users = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1;
yygotominor.yy155.dbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1;
yygotominor.yy155.tseries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1;
yygotominor.yy155.streams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1;
yygotominor.yy155.pps = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1;
yygotominor.yy155.storage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1;
yygotominor.yy155.qtime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1;
yygotominor.yy155.conns = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1;
yygotominor.yy155.stat = yymsp[0].minor.yy0;
}
yymsp[-8].minor.yy279 = yylhsminor.yy279;
break;
case 67: /* keep ::= KEEP tagitemlist */
{ yymsp[-1].minor.yy56 = yymsp[0].minor.yy56; }
break;
case 68: /* tables ::= TABLES INTEGER */
case 69: /* cache ::= CACHE INTEGER */ yytestcase(yyruleno==69);
case 70: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==70);
case 71: /* days ::= DAYS INTEGER */ yytestcase(yyruleno==71);
case 72: /* rows ::= ROWS INTEGER */ yytestcase(yyruleno==72);
case 73: /* ablocks ::= ABLOCKS ID */ yytestcase(yyruleno==73);
case 74: /* tblocks ::= TBLOCKS INTEGER */ yytestcase(yyruleno==74);
case 75: /* ctime ::= CTIME INTEGER */ yytestcase(yyruleno==75);
case 76: /* clog ::= CLOG INTEGER */ yytestcase(yyruleno==76);
case 77: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==77);
case 78: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==78);
{ yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; }
break;
case 79: /* db_optr ::= */
{setDefaultCreateDbOption(&yymsp[1].minor.yy398);}
break;
case 80: /* db_optr ::= db_optr tables */
case 94: /* alter_db_optr ::= alter_db_optr tables */ yytestcase(yyruleno==94);
{ yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.tablesPerVnode = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break;
case 81: /* db_optr ::= db_optr cache */
{ yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break;
case 82: /* db_optr ::= db_optr replica */
case 93: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==93);
{ yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break;
case 83: /* db_optr ::= db_optr days */
{ yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break;
case 84: /* db_optr ::= db_optr rows */
{ yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.rowPerFileBlock = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break;
case 85: /* db_optr ::= db_optr ablocks */
{ yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.numOfAvgCacheBlocks = strtod(yymsp[0].minor.yy0.z, NULL); }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break;
case 86: /* db_optr ::= db_optr tblocks */
{ yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.numOfBlocksPerTable = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break;
case 87: /* db_optr ::= db_optr ctime */
{ yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break;
case 88: /* db_optr ::= db_optr clog */
{ yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.commitLog = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break;
case 89: /* db_optr ::= db_optr comp */
{ yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break;
case 90: /* db_optr ::= db_optr prec */
{ yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.precision = yymsp[0].minor.yy0; }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break;
case 91: /* db_optr ::= db_optr keep */
{ yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.keep = yymsp[0].minor.yy56; }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break;
case 92: /* alter_db_optr ::= */
{ setDefaultCreateDbOption(&yymsp[1].minor.yy398);}
break;
case 95: /* typename ::= ids */
{ tSQLSetColumnType (&yylhsminor.yy223, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy223 = yylhsminor.yy223;
break;
case 96: /* typename ::= ids LP signed RP */
break;
case 69: /* keep ::= KEEP tagitemlist */
{ yygotominor.yy480 = yymsp[0].minor.yy480; }
break;
case 70: /* tables ::= TABLES INTEGER */
case 71: /* cache ::= CACHE INTEGER */ yytestcase(yyruleno==71);
case 72: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==72);
case 73: /* days ::= DAYS INTEGER */ yytestcase(yyruleno==73);
case 74: /* rows ::= ROWS INTEGER */ yytestcase(yyruleno==74);
case 75: /* ablocks ::= ABLOCKS ID */ yytestcase(yyruleno==75);
case 76: /* tblocks ::= TBLOCKS INTEGER */ yytestcase(yyruleno==76);
case 77: /* ctime ::= CTIME INTEGER */ yytestcase(yyruleno==77);
case 78: /* clog ::= CLOG INTEGER */ yytestcase(yyruleno==78);
case 79: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==79);
case 80: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==80);
{ yygotominor.yy0 = yymsp[0].minor.yy0; }
break;
case 81: /* db_optr ::= */
{setDefaultCreateDbOption(&yygotominor.yy262);}
break;
case 82: /* db_optr ::= db_optr tables */
case 96: /* alter_db_optr ::= alter_db_optr tables */ yytestcase(yyruleno==96);
{ yygotominor.yy262 = yymsp[-1].minor.yy262; yygotominor.yy262.tablesPerVnode = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
break;
case 83: /* db_optr ::= db_optr cache */
{ yygotominor.yy262 = yymsp[-1].minor.yy262; yygotominor.yy262.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
break;
case 84: /* db_optr ::= db_optr replica */
case 95: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==95);
{ yygotominor.yy262 = yymsp[-1].minor.yy262; yygotominor.yy262.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
break;
case 85: /* db_optr ::= db_optr days */
{ yygotominor.yy262 = yymsp[-1].minor.yy262; yygotominor.yy262.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
break;
case 86: /* db_optr ::= db_optr rows */
{ yygotominor.yy262 = yymsp[-1].minor.yy262; yygotominor.yy262.rowPerFileBlock = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
break;
case 87: /* db_optr ::= db_optr ablocks */
{ yygotominor.yy262 = yymsp[-1].minor.yy262; yygotominor.yy262.numOfAvgCacheBlocks = strtod(yymsp[0].minor.yy0.z, NULL); }
break;
case 88: /* db_optr ::= db_optr tblocks */
{ yygotominor.yy262 = yymsp[-1].minor.yy262; yygotominor.yy262.numOfBlocksPerTable = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
break;
case 89: /* db_optr ::= db_optr ctime */
{ yygotominor.yy262 = yymsp[-1].minor.yy262; yygotominor.yy262.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
break;
case 90: /* db_optr ::= db_optr clog */
{ yygotominor.yy262 = yymsp[-1].minor.yy262; yygotominor.yy262.commitLog = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
break;
case 91: /* db_optr ::= db_optr comp */
{ yygotominor.yy262 = yymsp[-1].minor.yy262; yygotominor.yy262.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
break;
case 92: /* db_optr ::= db_optr prec */
{ yygotominor.yy262 = yymsp[-1].minor.yy262; yygotominor.yy262.precision = yymsp[0].minor.yy0; }
break;
case 93: /* db_optr ::= db_optr keep */
{ yygotominor.yy262 = yymsp[-1].minor.yy262; yygotominor.yy262.keep = yymsp[0].minor.yy480; }
break;
case 94: /* alter_db_optr ::= */
{ setDefaultCreateDbOption(&yygotominor.yy262);}
break;
case 97: /* typename ::= ids */
{ tSQLSetColumnType (&yygotominor.yy397, &yymsp[0].minor.yy0); }
break;
case 98: /* typename ::= ids LP signed RP */
{
yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy389; // negative value of name length
tSQLSetColumnType(&yylhsminor.yy223, &yymsp[-3].minor.yy0);
yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy369; // negative value of name length
tSQLSetColumnType(&yygotominor.yy397, &yymsp[-3].minor.yy0);
}
yymsp[-3].minor.yy223 = yylhsminor.yy223;
break;
case 97: /* signed ::= INTEGER */
{ yylhsminor.yy389 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[0].minor.yy389 = yylhsminor.yy389;
case 99: /* signed ::= INTEGER */
case 100: /* signed ::= PLUS INTEGER */ yytestcase(yyruleno==100);
{ yygotominor.yy369 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
break;
case 98: /* signed ::= PLUS INTEGER */
{ yymsp[-1].minor.yy389 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
case 101: /* signed ::= MINUS INTEGER */
{ yygotominor.yy369 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);}
break;
case 99: /* signed ::= MINUS INTEGER */
{ yymsp[-1].minor.yy389 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);}
break;
case 100: /* cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */
case 102: /* cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */
{
yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n;
setCreatedMeterName(pInfo, &yymsp[-2].minor.yy0, &yymsp[-3].minor.yy0);
}
break;
case 101: /* create_table_args ::= LP columnlist RP */
case 103: /* create_table_args ::= LP columnlist RP */
{
yymsp[-2].minor.yy158 = tSetCreateSQLElems(yymsp[-1].minor.yy471, NULL, NULL, NULL, NULL, TSQL_CREATE_NORMAL_METER);
setSQLInfo(pInfo, yymsp[-2].minor.yy158, NULL, TSQL_CREATE_NORMAL_METER);
yygotominor.yy344 = tSetCreateSQLElems(yymsp[-1].minor.yy421, NULL, NULL, NULL, NULL, TSQL_CREATE_NORMAL_METER);
setSQLInfo(pInfo, yygotominor.yy344, NULL, TSQL_CREATE_NORMAL_METER);
}
break;
case 102: /* create_table_args ::= LP columnlist RP TAGS LP columnlist RP */
case 104: /* create_table_args ::= LP columnlist RP TAGS LP columnlist RP */
{
yymsp[-6].minor.yy158 = tSetCreateSQLElems(yymsp[-5].minor.yy471, yymsp[-1].minor.yy471, NULL, NULL, NULL, TSQL_CREATE_NORMAL_METRIC);
setSQLInfo(pInfo, yymsp[-6].minor.yy158, NULL, TSQL_CREATE_NORMAL_METRIC);
yygotominor.yy344 = tSetCreateSQLElems(yymsp[-5].minor.yy421, yymsp[-1].minor.yy421, NULL, NULL, NULL, TSQL_CREATE_NORMAL_METRIC);
setSQLInfo(pInfo, yygotominor.yy344, NULL, TSQL_CREATE_NORMAL_METRIC);
}
break;
case 103: /* create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */
case 105: /* create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */
{
yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n;
yymsp[-6].minor.yy158 = tSetCreateSQLElems(NULL, NULL, &yymsp[-5].minor.yy0, yymsp[-1].minor.yy56, NULL, TSQL_CREATE_METER_FROM_METRIC);
setSQLInfo(pInfo, yymsp[-6].minor.yy158, NULL, TSQL_CREATE_METER_FROM_METRIC);
yygotominor.yy344 = tSetCreateSQLElems(NULL, NULL, &yymsp[-5].minor.yy0, yymsp[-1].minor.yy480, NULL, TSQL_CREATE_METER_FROM_METRIC);
setSQLInfo(pInfo, yygotominor.yy344, NULL, TSQL_CREATE_METER_FROM_METRIC);
}
break;
case 104: /* create_table_args ::= AS select */
case 106: /* create_table_args ::= AS select */
{
yymsp[-1].minor.yy158 = tSetCreateSQLElems(NULL, NULL, NULL, NULL, yymsp[0].minor.yy24, TSQL_CREATE_STREAM);
setSQLInfo(pInfo, yymsp[-1].minor.yy158, NULL, TSQL_CREATE_STREAM);
yygotominor.yy344 = tSetCreateSQLElems(NULL, NULL, NULL, NULL, yymsp[0].minor.yy138, TSQL_CREATE_STREAM);
setSQLInfo(pInfo, yygotominor.yy344, NULL, TSQL_CREATE_STREAM);
}
break;
case 105: /* columnlist ::= columnlist COMMA column */
{yylhsminor.yy471 = tFieldListAppend(yymsp[-2].minor.yy471, &yymsp[0].minor.yy223); }
yymsp[-2].minor.yy471 = yylhsminor.yy471;
case 107: /* columnlist ::= columnlist COMMA column */
{yygotominor.yy421 = tFieldListAppend(yymsp[-2].minor.yy421, &yymsp[0].minor.yy397); }
break;
case 106: /* columnlist ::= column */
{yylhsminor.yy471 = tFieldListAppend(NULL, &yymsp[0].minor.yy223);}
yymsp[0].minor.yy471 = yylhsminor.yy471;
case 108: /* columnlist ::= column */
{yygotominor.yy421 = tFieldListAppend(NULL, &yymsp[0].minor.yy397);}
break;
case 107: /* column ::= ids typename */
case 109: /* column ::= ids typename */
{
tSQLSetColumnInfo(&yylhsminor.yy223, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy223);
tSQLSetColumnInfo(&yygotominor.yy397, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy397);
}
yymsp[-1].minor.yy223 = yylhsminor.yy223;
break;
case 108: /* tagitemlist ::= tagitemlist COMMA tagitem */
{ yylhsminor.yy56 = tVariantListAppend(yymsp[-2].minor.yy56, &yymsp[0].minor.yy186, -1); }
yymsp[-2].minor.yy56 = yylhsminor.yy56;
break;
case 109: /* tagitemlist ::= tagitem */
{ yylhsminor.yy56 = tVariantListAppend(NULL, &yymsp[0].minor.yy186, -1); }
yymsp[0].minor.yy56 = yylhsminor.yy56;
break;
case 110: /* tagitem ::= INTEGER */
case 111: /* tagitem ::= FLOAT */ yytestcase(yyruleno==111);
case 112: /* tagitem ::= STRING */ yytestcase(yyruleno==112);
case 113: /* tagitem ::= BOOL */ yytestcase(yyruleno==113);
{toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy186, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy186 = yylhsminor.yy186;
break;
case 114: /* tagitem ::= NULL */
{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy186, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy186 = yylhsminor.yy186;
break;
case 115: /* tagitem ::= MINUS INTEGER */
case 116: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==116);
case 117: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==117);
case 118: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==118);
break;
case 110: /* tagitemlist ::= tagitemlist COMMA tagitem */
{ yygotominor.yy480 = tVariantListAppend(yymsp[-2].minor.yy480, &yymsp[0].minor.yy236, -1); }
break;
case 111: /* tagitemlist ::= tagitem */
{ yygotominor.yy480 = tVariantListAppend(NULL, &yymsp[0].minor.yy236, -1); }
break;
case 112: /* tagitem ::= INTEGER */
case 113: /* tagitem ::= FLOAT */ yytestcase(yyruleno==113);
case 114: /* tagitem ::= STRING */ yytestcase(yyruleno==114);
case 115: /* tagitem ::= BOOL */ yytestcase(yyruleno==115);
{toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yygotominor.yy236, &yymsp[0].minor.yy0); }
break;
case 116: /* tagitem ::= NULL */
{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yygotominor.yy236, &yymsp[0].minor.yy0); }
break;
case 117: /* tagitem ::= MINUS INTEGER */
case 118: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==118);
case 119: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==119);
case 120: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==120);
{
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type;
toTSDBType(yymsp[-1].minor.yy0.type);
tVariantCreate(&yylhsminor.yy186, &yymsp[-1].minor.yy0);
tVariantCreate(&yygotominor.yy236, &yymsp[-1].minor.yy0);
}
yymsp[-1].minor.yy186 = yylhsminor.yy186;
break;
case 119: /* cmd ::= select */
case 121: /* cmd ::= select */
{
setSQLInfo(pInfo, yymsp[0].minor.yy24, NULL, TSQL_QUERY_METER);
setSQLInfo(pInfo, yymsp[0].minor.yy138, NULL, TSQL_QUERY_METER);
}
break;
case 120: /* select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */
case 122: /* select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */
{
yylhsminor.yy24 = tSetQuerySQLElems(&yymsp[-11].minor.yy0, yymsp[-10].minor.yy498, yymsp[-9].minor.yy56, yymsp[-8].minor.yy90, yymsp[-4].minor.yy56, yymsp[-3].minor.yy56, &yymsp[-7].minor.yy0, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy56, &yymsp[0].minor.yy294, &yymsp[-1].minor.yy294);
yygotominor.yy138 = tSetQuerySQLElems(&yymsp[-11].minor.yy0, yymsp[-10].minor.yy284, yymsp[-9].minor.yy480, yymsp[-8].minor.yy244, yymsp[-4].minor.yy480, yymsp[-3].minor.yy480, &yymsp[-7].minor.yy0, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy480, &yymsp[0].minor.yy162, &yymsp[-1].minor.yy162);
}
yymsp[-11].minor.yy24 = yylhsminor.yy24;
break;
case 121: /* select ::= SELECT selcollist */
case 123: /* select ::= SELECT selcollist */
{
yylhsminor.yy24 = tSetQuerySQLElems(&yymsp[-1].minor.yy0, yymsp[0].minor.yy498, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
yygotominor.yy138 = tSetQuerySQLElems(&yymsp[-1].minor.yy0, yymsp[0].minor.yy284, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
yymsp[-1].minor.yy24 = yylhsminor.yy24;
break;
case 122: /* sclp ::= selcollist COMMA */
{yylhsminor.yy498 = yymsp[-1].minor.yy498;}
yymsp[-1].minor.yy498 = yylhsminor.yy498;
case 124: /* sclp ::= selcollist COMMA */
{yygotominor.yy284 = yymsp[-1].minor.yy284;}
break;
case 123: /* sclp ::= */
{yymsp[1].minor.yy498 = 0;}
case 125: /* sclp ::= */
{yygotominor.yy284 = 0;}
break;
case 124: /* selcollist ::= sclp expr as */
case 126: /* selcollist ::= sclp expr as */
{
yylhsminor.yy498 = tSQLExprListAppend(yymsp[-2].minor.yy498, yymsp[-1].minor.yy90, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0);
yygotominor.yy284 = tSQLExprListAppend(yymsp[-2].minor.yy284, yymsp[-1].minor.yy244, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0);
}
yymsp[-2].minor.yy498 = yylhsminor.yy498;
break;
case 125: /* selcollist ::= sclp STAR */
case 127: /* selcollist ::= sclp STAR */
{
tSQLExpr *pNode = tSQLExprIdValueCreate(NULL, TK_ALL);
yylhsminor.yy498 = tSQLExprListAppend(yymsp[-1].minor.yy498, pNode, 0);
yygotominor.yy284 = tSQLExprListAppend(yymsp[-1].minor.yy284, pNode, 0);
}
yymsp[-1].minor.yy498 = yylhsminor.yy498;
break;
case 126: /* as ::= AS ids */
{ yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; }
break;
case 127: /* as ::= ids */
{ yylhsminor.yy0 = yymsp[0].minor.yy0; }
yymsp[0].minor.yy0 = yylhsminor.yy0;
case 128: /* as ::= AS ids */
case 129: /* as ::= ids */ yytestcase(yyruleno==129);
{ yygotominor.yy0 = yymsp[0].minor.yy0; }
break;
case 128: /* as ::= */
{ yymsp[1].minor.yy0.n = 0; }
case 130: /* as ::= */
{ yygotominor.yy0.n = 0; }
break;
case 129: /* from ::= FROM tablelist */
{yymsp[-1].minor.yy56 = yymsp[0].minor.yy56;}
case 131: /* from ::= FROM tablelist */
case 143: /* orderby_opt ::= ORDER BY sortlist */ yytestcase(yyruleno==143);
case 151: /* groupby_opt ::= GROUP BY grouplist */ yytestcase(yyruleno==151);
{yygotominor.yy480 = yymsp[0].minor.yy480;}
break;
case 130: /* tablelist ::= ids cpxName */
{ toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yylhsminor.yy56 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1);}
yymsp[-1].minor.yy56 = yylhsminor.yy56;
case 132: /* tablelist ::= ids cpxName */
{ toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yygotominor.yy480 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1);}
break;
case 131: /* tablelist ::= tablelist COMMA ids cpxName */
{ toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yylhsminor.yy56 = tVariantListAppendToken(yymsp[-3].minor.yy56, &yymsp[-1].minor.yy0, -1); }
yymsp[-3].minor.yy56 = yylhsminor.yy56;
case 133: /* tablelist ::= tablelist COMMA ids cpxName */
{ toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yygotominor.yy480 = tVariantListAppendToken(yymsp[-3].minor.yy480, &yymsp[-1].minor.yy0, -1); }
break;
case 132: /* tmvar ::= VARIABLE */
{yylhsminor.yy0 = yymsp[0].minor.yy0;}
yymsp[0].minor.yy0 = yylhsminor.yy0;
case 134: /* tmvar ::= VARIABLE */
{yygotominor.yy0 = yymsp[0].minor.yy0;}
break;
case 133: /* interval_opt ::= INTERVAL LP tmvar RP */
case 138: /* sliding_opt ::= SLIDING LP tmvar RP */ yytestcase(yyruleno==138);
{yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; }
case 135: /* interval_opt ::= INTERVAL LP tmvar RP */
case 140: /* sliding_opt ::= SLIDING LP tmvar RP */ yytestcase(yyruleno==140);
{yygotominor.yy0 = yymsp[-1].minor.yy0; }
break;
case 134: /* interval_opt ::= */
case 139: /* sliding_opt ::= */ yytestcase(yyruleno==139);
{yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; }
case 136: /* interval_opt ::= */
case 141: /* sliding_opt ::= */ yytestcase(yyruleno==141);
{yygotominor.yy0.n = 0; yygotominor.yy0.z = NULL; yygotominor.yy0.type = 0; }
break;
case 135: /* fill_opt ::= */
{yymsp[1].minor.yy56 = 0; }
case 137: /* fill_opt ::= */
{yygotominor.yy480 = 0; }
break;
case 136: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */
case 138: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */
{
tVariant A = {0};
toTSDBType(yymsp[-3].minor.yy0.type);
tVariantCreate(&A, &yymsp[-3].minor.yy0);
tVariantListInsert(yymsp[-1].minor.yy56, &A, -1, 0);
yymsp[-5].minor.yy56 = yymsp[-1].minor.yy56;
tVariantListInsert(yymsp[-1].minor.yy480, &A, -1, 0);
yygotominor.yy480 = yymsp[-1].minor.yy480;
}
break;
case 137: /* fill_opt ::= FILL LP ID RP */
case 139: /* fill_opt ::= FILL LP ID RP */
{
toTSDBType(yymsp[-1].minor.yy0.type);
yymsp[-3].minor.yy56 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1);
yygotominor.yy480 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1);
}
break;
case 140: /* orderby_opt ::= */
case 148: /* groupby_opt ::= */ yytestcase(yyruleno==148);
{yymsp[1].minor.yy56 = 0;}
case 142: /* orderby_opt ::= */
case 150: /* groupby_opt ::= */ yytestcase(yyruleno==150);
{yygotominor.yy480 = 0;}
break;
case 141: /* orderby_opt ::= ORDER BY sortlist */
case 149: /* groupby_opt ::= GROUP BY grouplist */ yytestcase(yyruleno==149);
{yymsp[-2].minor.yy56 = yymsp[0].minor.yy56;}
break;
case 142: /* sortlist ::= sortlist COMMA item sortorder */
case 144: /* sortlist ::= sortlist COMMA item sortorder */
{
yylhsminor.yy56 = tVariantListAppend(yymsp[-3].minor.yy56, &yymsp[-1].minor.yy186, yymsp[0].minor.yy332);
yygotominor.yy480 = tVariantListAppend(yymsp[-3].minor.yy480, &yymsp[-1].minor.yy236, yymsp[0].minor.yy220);
}
yymsp[-3].minor.yy56 = yylhsminor.yy56;
break;
case 143: /* sortlist ::= item sortorder */
case 145: /* sortlist ::= item sortorder */
{
yylhsminor.yy56 = tVariantListAppend(NULL, &yymsp[-1].minor.yy186, yymsp[0].minor.yy332);
yygotominor.yy480 = tVariantListAppend(NULL, &yymsp[-1].minor.yy236, yymsp[0].minor.yy220);
}
yymsp[-1].minor.yy56 = yylhsminor.yy56;
break;
case 144: /* item ::= ids cpxName */
case 146: /* item ::= ids cpxName */
{
toTSDBType(yymsp[-1].minor.yy0.type);
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
tVariantCreate(&yylhsminor.yy186, &yymsp[-1].minor.yy0);
tVariantCreate(&yygotominor.yy236, &yymsp[-1].minor.yy0);
}
yymsp[-1].minor.yy186 = yylhsminor.yy186;
break;
case 145: /* sortorder ::= ASC */
{yymsp[0].minor.yy332 = TSQL_SO_ASC; }
case 147: /* sortorder ::= ASC */
{yygotominor.yy220 = TSQL_SO_ASC; }
break;
case 146: /* sortorder ::= DESC */
{yymsp[0].minor.yy332 = TSQL_SO_DESC;}
case 148: /* sortorder ::= DESC */
{yygotominor.yy220 = TSQL_SO_DESC;}
break;
case 147: /* sortorder ::= */
{yymsp[1].minor.yy332 = TSQL_SO_ASC;}
case 149: /* sortorder ::= */
{yygotominor.yy220 = TSQL_SO_ASC;}
break;
case 150: /* grouplist ::= grouplist COMMA item */
case 152: /* grouplist ::= grouplist COMMA item */
{
yylhsminor.yy56 = tVariantListAppend(yymsp[-2].minor.yy56, &yymsp[0].minor.yy186, -1);
yygotominor.yy480 = tVariantListAppend(yymsp[-2].minor.yy480, &yymsp[0].minor.yy236, -1);
}
yymsp[-2].minor.yy56 = yylhsminor.yy56;
break;
case 151: /* grouplist ::= item */
case 153: /* grouplist ::= item */
{
yylhsminor.yy56 = tVariantListAppend(NULL, &yymsp[0].minor.yy186, -1);
yygotominor.yy480 = tVariantListAppend(NULL, &yymsp[0].minor.yy236, -1);
}
yymsp[0].minor.yy56 = yylhsminor.yy56;
break;
case 152: /* having_opt ::= */
case 162: /* where_opt ::= */ yytestcase(yyruleno==162);
case 198: /* expritem ::= */ yytestcase(yyruleno==198);
{yymsp[1].minor.yy90 = 0;}
case 154: /* having_opt ::= */
case 164: /* where_opt ::= */ yytestcase(yyruleno==164);
case 200: /* expritem ::= */ yytestcase(yyruleno==200);
{yygotominor.yy244 = 0;}
break;
case 153: /* having_opt ::= HAVING expr */
case 163: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==163);
{yymsp[-1].minor.yy90 = yymsp[0].minor.yy90;}
case 155: /* having_opt ::= HAVING expr */
case 165: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==165);
case 199: /* expritem ::= expr */ yytestcase(yyruleno==199);
{yygotominor.yy244 = yymsp[0].minor.yy244;}
break;
case 154: /* limit_opt ::= */
case 158: /* slimit_opt ::= */ yytestcase(yyruleno==158);
{yymsp[1].minor.yy294.limit = -1; yymsp[1].minor.yy294.offset = 0;}
case 156: /* limit_opt ::= */
case 160: /* slimit_opt ::= */ yytestcase(yyruleno==160);
{yygotominor.yy162.limit = -1; yygotominor.yy162.offset = 0;}
break;
case 155: /* limit_opt ::= LIMIT signed */
case 159: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==159);
{yymsp[-1].minor.yy294.limit = yymsp[0].minor.yy389; yymsp[-1].minor.yy294.offset = 0;}
case 157: /* limit_opt ::= LIMIT signed */
case 161: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==161);
{yygotominor.yy162.limit = yymsp[0].minor.yy369; yygotominor.yy162.offset = 0;}
break;
case 156: /* limit_opt ::= LIMIT signed OFFSET signed */
case 160: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ yytestcase(yyruleno==160);
{yymsp[-3].minor.yy294.limit = yymsp[-2].minor.yy389; yymsp[-3].minor.yy294.offset = yymsp[0].minor.yy389;}
case 158: /* limit_opt ::= LIMIT signed OFFSET signed */
case 162: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ yytestcase(yyruleno==162);
{yygotominor.yy162.limit = yymsp[-2].minor.yy369; yygotominor.yy162.offset = yymsp[0].minor.yy369;}
break;
case 157: /* limit_opt ::= LIMIT signed COMMA signed */
case 161: /* slimit_opt ::= SLIMIT signed COMMA signed */ yytestcase(yyruleno==161);
{yymsp[-3].minor.yy294.limit = yymsp[0].minor.yy389; yymsp[-3].minor.yy294.offset = yymsp[-2].minor.yy389;}
case 159: /* limit_opt ::= LIMIT signed COMMA signed */
case 163: /* slimit_opt ::= SLIMIT signed COMMA signed */ yytestcase(yyruleno==163);
{yygotominor.yy162.limit = yymsp[0].minor.yy369; yygotominor.yy162.offset = yymsp[-2].minor.yy369;}
break;
case 164: /* expr ::= LP expr RP */
{yymsp[-2].minor.yy90 = yymsp[-1].minor.yy90; }
case 166: /* expr ::= LP expr RP */
{yygotominor.yy244 = yymsp[-1].minor.yy244; }
break;
case 165: /* expr ::= ID */
{yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_ID);}
yymsp[0].minor.yy90 = yylhsminor.yy90;
case 167: /* expr ::= ID */
{yygotominor.yy244 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_ID);}
break;
case 166: /* expr ::= ID DOT ID */
{yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ID);}
yymsp[-2].minor.yy90 = yylhsminor.yy90;
case 168: /* expr ::= ID DOT ID */
{yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yygotominor.yy244 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ID);}
break;
case 167: /* expr ::= ID DOT STAR */
{yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ALL);}
yymsp[-2].minor.yy90 = yylhsminor.yy90;
case 169: /* expr ::= ID DOT STAR */
{yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yygotominor.yy244 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ALL);}
break;
case 168: /* expr ::= INTEGER */
{yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_INTEGER);}
yymsp[0].minor.yy90 = yylhsminor.yy90;
case 170: /* expr ::= INTEGER */
{yygotominor.yy244 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_INTEGER);}
break;
case 169: /* expr ::= MINUS INTEGER */
case 170: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==170);
{yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_INTEGER);}
yymsp[-1].minor.yy90 = yylhsminor.yy90;
case 171: /* expr ::= MINUS INTEGER */
case 172: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==172);
{yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yygotominor.yy244 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_INTEGER);}
break;
case 171: /* expr ::= FLOAT */
{yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_FLOAT);}
yymsp[0].minor.yy90 = yylhsminor.yy90;
case 173: /* expr ::= FLOAT */
{yygotominor.yy244 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_FLOAT);}
break;
case 172: /* expr ::= MINUS FLOAT */
case 173: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==173);
{yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_FLOAT);}
yymsp[-1].minor.yy90 = yylhsminor.yy90;
case 174: /* expr ::= MINUS FLOAT */
case 175: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==175);
{yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yygotominor.yy244 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_FLOAT);}
break;
case 174: /* expr ::= STRING */
{yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_STRING);}
yymsp[0].minor.yy90 = yylhsminor.yy90;
case 176: /* expr ::= STRING */
{yygotominor.yy244 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_STRING);}
break;
case 175: /* expr ::= NOW */
{yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_NOW); }
yymsp[0].minor.yy90 = yylhsminor.yy90;
case 177: /* expr ::= NOW */
{yygotominor.yy244 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_NOW); }
break;
case 176: /* expr ::= VARIABLE */
{yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_VARIABLE);}
yymsp[0].minor.yy90 = yylhsminor.yy90;
case 178: /* expr ::= VARIABLE */
{yygotominor.yy244 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_VARIABLE);}
break;
case 177: /* expr ::= BOOL */
{yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_BOOL);}
yymsp[0].minor.yy90 = yylhsminor.yy90;
case 179: /* expr ::= BOOL */
{yygotominor.yy244 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_BOOL);}
break;
case 178: /* expr ::= ID LP exprlist RP */
case 180: /* expr ::= ID LP exprlist RP */
{
yylhsminor.yy90 = tSQLExprCreateFunction(yymsp[-1].minor.yy498, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type);
yygotominor.yy244 = tSQLExprCreateFunction(yymsp[-1].minor.yy284, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type);
}
yymsp[-3].minor.yy90 = yylhsminor.yy90;
break;
case 179: /* expr ::= ID LP STAR RP */
case 181: /* expr ::= ID LP STAR RP */
{
yylhsminor.yy90 = tSQLExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type);
yygotominor.yy244 = tSQLExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type);
}
yymsp[-3].minor.yy90 = yylhsminor.yy90;
break;
case 180: /* expr ::= expr AND expr */
{yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_AND);}
yymsp[-2].minor.yy90 = yylhsminor.yy90;
break;
case 181: /* expr ::= expr OR expr */
{yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_OR); }
yymsp[-2].minor.yy90 = yylhsminor.yy90;
case 182: /* expr ::= expr AND expr */
{yygotominor.yy244 = tSQLExprCreate(yymsp[-2].minor.yy244, yymsp[0].minor.yy244, TK_AND);}
break;
case 182: /* expr ::= expr LT expr */
{yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_LT);}
yymsp[-2].minor.yy90 = yylhsminor.yy90;
case 183: /* expr ::= expr OR expr */
{yygotominor.yy244 = tSQLExprCreate(yymsp[-2].minor.yy244, yymsp[0].minor.yy244, TK_OR); }
break;
case 183: /* expr ::= expr GT expr */
{yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_GT);}
yymsp[-2].minor.yy90 = yylhsminor.yy90;
case 184: /* expr ::= expr LT expr */
{yygotominor.yy244 = tSQLExprCreate(yymsp[-2].minor.yy244, yymsp[0].minor.yy244, TK_LT);}
break;
case 184: /* expr ::= expr LE expr */
{yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_LE);}
yymsp[-2].minor.yy90 = yylhsminor.yy90;
case 185: /* expr ::= expr GT expr */
{yygotominor.yy244 = tSQLExprCreate(yymsp[-2].minor.yy244, yymsp[0].minor.yy244, TK_GT);}
break;
case 185: /* expr ::= expr GE expr */
{yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_GE);}
yymsp[-2].minor.yy90 = yylhsminor.yy90;
case 186: /* expr ::= expr LE expr */
{yygotominor.yy244 = tSQLExprCreate(yymsp[-2].minor.yy244, yymsp[0].minor.yy244, TK_LE);}
break;
case 186: /* expr ::= expr NE expr */
{yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_NE);}
yymsp[-2].minor.yy90 = yylhsminor.yy90;
case 187: /* expr ::= expr GE expr */
{yygotominor.yy244 = tSQLExprCreate(yymsp[-2].minor.yy244, yymsp[0].minor.yy244, TK_GE);}
break;
case 187: /* expr ::= expr EQ expr */
{yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_EQ);}
yymsp[-2].minor.yy90 = yylhsminor.yy90;
case 188: /* expr ::= expr NE expr */
{yygotominor.yy244 = tSQLExprCreate(yymsp[-2].minor.yy244, yymsp[0].minor.yy244, TK_NE);}
break;
case 188: /* expr ::= expr PLUS expr */
{yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_PLUS); }
yymsp[-2].minor.yy90 = yylhsminor.yy90;
case 189: /* expr ::= expr EQ expr */
{yygotominor.yy244 = tSQLExprCreate(yymsp[-2].minor.yy244, yymsp[0].minor.yy244, TK_EQ);}
break;
case 189: /* expr ::= expr MINUS expr */
{yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_MINUS); }
yymsp[-2].minor.yy90 = yylhsminor.yy90;
case 190: /* expr ::= expr PLUS expr */
{yygotominor.yy244 = tSQLExprCreate(yymsp[-2].minor.yy244, yymsp[0].minor.yy244, TK_PLUS); }
break;
case 190: /* expr ::= expr STAR expr */
{yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_STAR); }
yymsp[-2].minor.yy90 = yylhsminor.yy90;
case 191: /* expr ::= expr MINUS expr */
{yygotominor.yy244 = tSQLExprCreate(yymsp[-2].minor.yy244, yymsp[0].minor.yy244, TK_MINUS); }
break;
case 191: /* expr ::= expr SLASH expr */
{yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_DIVIDE);}
yymsp[-2].minor.yy90 = yylhsminor.yy90;
case 192: /* expr ::= expr STAR expr */
{yygotominor.yy244 = tSQLExprCreate(yymsp[-2].minor.yy244, yymsp[0].minor.yy244, TK_STAR); }
break;
case 192: /* expr ::= expr REM expr */
{yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_REM); }
yymsp[-2].minor.yy90 = yylhsminor.yy90;
case 193: /* expr ::= expr SLASH expr */
{yygotominor.yy244 = tSQLExprCreate(yymsp[-2].minor.yy244, yymsp[0].minor.yy244, TK_DIVIDE);}
break;
case 193: /* expr ::= expr LIKE expr */
{yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_LIKE); }
yymsp[-2].minor.yy90 = yylhsminor.yy90;
case 194: /* expr ::= expr REM expr */
{yygotominor.yy244 = tSQLExprCreate(yymsp[-2].minor.yy244, yymsp[0].minor.yy244, TK_REM); }
break;
case 194: /* expr ::= expr IN LP exprlist RP */
{yylhsminor.yy90 = tSQLExprCreate(yymsp[-4].minor.yy90, (tSQLExpr*)yymsp[-1].minor.yy498, TK_IN); }
yymsp[-4].minor.yy90 = yylhsminor.yy90;
case 195: /* expr ::= expr LIKE expr */
{yygotominor.yy244 = tSQLExprCreate(yymsp[-2].minor.yy244, yymsp[0].minor.yy244, TK_LIKE); }
break;
case 195: /* exprlist ::= exprlist COMMA expritem */
case 202: /* itemlist ::= itemlist COMMA expr */ yytestcase(yyruleno==202);
{yylhsminor.yy498 = tSQLExprListAppend(yymsp[-2].minor.yy498,yymsp[0].minor.yy90,0);}
yymsp[-2].minor.yy498 = yylhsminor.yy498;
case 196: /* expr ::= expr IN LP exprlist RP */
{yygotominor.yy244 = tSQLExprCreate(yymsp[-4].minor.yy244, (tSQLExpr*)yymsp[-1].minor.yy284, TK_IN); }
break;
case 196: /* exprlist ::= expritem */
case 203: /* itemlist ::= expr */ yytestcase(yyruleno==203);
{yylhsminor.yy498 = tSQLExprListAppend(0,yymsp[0].minor.yy90,0);}
yymsp[0].minor.yy498 = yylhsminor.yy498;
case 197: /* exprlist ::= exprlist COMMA expritem */
case 204: /* itemlist ::= itemlist COMMA expr */ yytestcase(yyruleno==204);
{yygotominor.yy284 = tSQLExprListAppend(yymsp[-2].minor.yy284,yymsp[0].minor.yy244,0);}
break;
case 197: /* expritem ::= expr */
{yylhsminor.yy90 = yymsp[0].minor.yy90;}
yymsp[0].minor.yy90 = yylhsminor.yy90;
case 198: /* exprlist ::= expritem */
case 205: /* itemlist ::= expr */ yytestcase(yyruleno==205);
{yygotominor.yy284 = tSQLExprListAppend(0,yymsp[0].minor.yy244,0);}
break;
case 199: /* cmd ::= INSERT INTO cpxName insert_value_list */
case 201: /* cmd ::= INSERT INTO cpxName insert_value_list */
{
tSetInsertSQLElems(pInfo, &yymsp[-1].minor.yy0, yymsp[0].minor.yy74);
tSetInsertSQLElems(pInfo, &yymsp[-1].minor.yy0, yymsp[0].minor.yy237);
}
break;
case 200: /* insert_value_list ::= VALUES LP itemlist RP */
{yymsp[-3].minor.yy74 = tSQLListListAppend(NULL, yymsp[-1].minor.yy498);}
case 202: /* insert_value_list ::= VALUES LP itemlist RP */
{yygotominor.yy237 = tSQLListListAppend(NULL, yymsp[-1].minor.yy284);}
break;
case 201: /* insert_value_list ::= insert_value_list VALUES LP itemlist RP */
{yylhsminor.yy74 = tSQLListListAppend(yymsp[-4].minor.yy74, yymsp[-1].minor.yy498);}
yymsp[-4].minor.yy74 = yylhsminor.yy74;
case 203: /* insert_value_list ::= insert_value_list VALUES LP itemlist RP */
{yygotominor.yy237 = tSQLListListAppend(yymsp[-4].minor.yy237, yymsp[-1].minor.yy284);}
break;
case 204: /* cmd ::= RESET QUERY CACHE */
case 206: /* cmd ::= RESET QUERY CACHE */
{ setDCLSQLElems(pInfo, RESET_QUERY_CACHE, 0);}
break;
case 205: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
case 207: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy471, NULL, ALTER_TABLE_ADD_COLUMN);
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, ALTER_TABLE_ADD_COLUMN);
setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_ADD_COLUMN);
}
break;
case 206: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
case 208: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
......@@ -2630,14 +2225,14 @@ static void yy_reduce(
setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_DROP_COLUMN);
}
break;
case 207: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
case 209: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy471, NULL, ALTER_TABLE_TAGS_ADD);
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, ALTER_TABLE_TAGS_ADD);
setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_ADD);
}
break;
case 208: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
case 210: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
......@@ -2648,7 +2243,7 @@ static void yy_reduce(
setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_DROP);
}
break;
case 209: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
case 211: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
{
yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n;
......@@ -2662,48 +2257,56 @@ static void yy_reduce(
setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_CHG);
}
break;
case 210: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
case 212: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
{
yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n;
toTSDBType(yymsp[-2].minor.yy0.type);
tVariantList* A = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1);
A = tVariantListAppend(A, &yymsp[0].minor.yy186, -1);
A = tVariantListAppend(A, &yymsp[0].minor.yy236, -1);
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-6].minor.yy0, NULL, A, ALTER_TABLE_TAGS_SET);
setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_SET);
}
break;
case 211: /* cmd ::= KILL CONNECTION IPTOKEN COLON INTEGER */
case 213: /* cmd ::= KILL CONNECTION IPTOKEN COLON INTEGER */
{yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setDCLSQLElems(pInfo, KILL_CONNECTION, 1, &yymsp[-2].minor.yy0);}
break;
case 212: /* cmd ::= KILL STREAM IPTOKEN COLON INTEGER COLON INTEGER */
case 214: /* cmd ::= KILL STREAM IPTOKEN COLON INTEGER COLON INTEGER */
{yymsp[-4].minor.yy0.n += (yymsp[-3].minor.yy0.n + yymsp[-2].minor.yy0.n + yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setDCLSQLElems(pInfo, KILL_STREAM, 1, &yymsp[-4].minor.yy0);}
break;
case 213: /* cmd ::= KILL QUERY IPTOKEN COLON INTEGER COLON INTEGER */
case 215: /* cmd ::= KILL QUERY IPTOKEN COLON INTEGER COLON INTEGER */
{yymsp[-4].minor.yy0.n += (yymsp[-3].minor.yy0.n + yymsp[-2].minor.yy0.n + yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setDCLSQLElems(pInfo, KILL_QUERY, 1, &yymsp[-4].minor.yy0);}
break;
default:
break;
/********** End reduce actions ************************************************/
};
assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
assert( yyruleno>=0 && yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
yygoto = yyRuleInfo[yyruleno].lhs;
yysize = yyRuleInfo[yyruleno].nrhs;
yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);
/* There are no SHIFTREDUCE actions on nonterminals because the table
** generator has simplified them to pure REDUCE actions. */
assert( !(yyact>YY_MAX_SHIFT && yyact<=YY_MAX_SHIFTREDUCE) );
/* It is not possible for a REDUCE to be followed by an error */
assert( yyact!=YY_ERROR_ACTION );
yymsp += yysize+1;
yypParser->yytos = yymsp;
yypParser->yyidx -= yysize;
yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
if( yyact <= YY_MAX_SHIFTREDUCE ){
if( yyact>YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
/* If the reduce action popped at least
** one element off the stack, then we can push the new element back
** onto the stack here, and skip the stack overflow test in yy_shift().
** That gives a significant speed improvement. */
if( yysize ){
yypParser->yyidx++;
yymsp -= yysize-1;
yymsp->stateno = (YYACTIONTYPE)yyact;
yymsp->major = (YYCODETYPE)yygoto;
yyTraceShift(yypParser, yyact, "... then shift");
yymsp->minor = yygotominor;
yyTraceShift(yypParser, yyact);
}else{
yy_shift(yypParser,yyact,yygoto,&yygotominor);
}
}else{
assert( yyact == YY_ACCEPT_ACTION );
yy_accept(yypParser);
}
}
/*
......@@ -2719,7 +2322,7 @@ static void yy_parse_failed(
fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
}
#endif
while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
/* Here code is inserted which will be executed whenever the
** parser fails */
/************ Begin %parse_failure code ***************************************/
......@@ -2734,10 +2337,10 @@ static void yy_parse_failed(
static void yy_syntax_error(
yyParser *yypParser, /* The parser */
int yymajor, /* The major type of the error token */
ParseTOKENTYPE yyminor /* The minor type of the error token */
YYMINORTYPE yyminor /* The minor type of the error token */
){
ParseARG_FETCH;
#define TOKEN yyminor
#define TOKEN (yyminor.yy0)
/************ Begin %syntax_error code ****************************************/
pInfo->validSql = false;
......@@ -2777,10 +2380,7 @@ static void yy_accept(
fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
}
#endif
#ifndef YYNOERRORRECOVERY
yypParser->yyerrcnt = -1;
#endif
assert( yypParser->yytos==yypParser->yystack );
while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
/* Here code is inserted which will be executed whenever the
** parser accepts */
/*********** Begin %parse_accept code *****************************************/
......@@ -2815,7 +2415,7 @@ void Parse(
ParseARG_PDECL /* Optional %extra_argument parameter */
){
YYMINORTYPE yyminorunion;
unsigned int yyact; /* The parser action. */
int yyact; /* The parser action. */
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
int yyendofinput; /* True if we are at the end of input */
#endif
......@@ -2824,8 +2424,29 @@ void Parse(
#endif
yyParser *yypParser; /* The parser */
/* (re)initialize the parser, if necessary */
yypParser = (yyParser*)yyp;
assert( yypParser->yytos!=0 );
if( yypParser->yyidx<0 ){
#if YYSTACKDEPTH<=0
if( yypParser->yystksz <=0 ){
/*memset(&yyminorunion, 0, sizeof(yyminorunion));*/
yyminorunion = yyzerominor;
yyStackOverflow(yypParser, &yyminorunion);
return;
}
#endif
yypParser->yyidx = 0;
yypParser->yyerrcnt = -1;
yypParser->yystack[0].stateno = 0;
yypParser->yystack[0].major = 0;
#ifndef NDEBUG
if( yyTraceFILE ){
fprintf(yyTraceFILE,"%sInitialize. Empty stack. State 0\n",
yyTracePrompt);
}
#endif
}
yyminorunion.yy0 = yyminor;
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
yyendofinput = (yymajor==0);
#endif
......@@ -2833,34 +2454,21 @@ void Parse(
#ifndef NDEBUG
if( yyTraceFILE ){
int stateno = yypParser->yytos->stateno;
if( stateno < YY_MIN_REDUCE ){
fprintf(yyTraceFILE,"%sInput '%s' in state %d\n",
yyTracePrompt,yyTokenName[yymajor],stateno);
}else{
fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n",
yyTracePrompt,yyTokenName[yymajor],stateno-YY_MIN_REDUCE);
}
fprintf(yyTraceFILE,"%sInput '%s'\n",yyTracePrompt,yyTokenName[yymajor]);
}
#endif
do{
yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
if( yyact >= YY_MIN_REDUCE ){
yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,yyminor);
}else if( yyact <= YY_MAX_SHIFTREDUCE ){
yy_shift(yypParser,yyact,yymajor,yyminor);
#ifndef YYNOERRORRECOVERY
if( yyact <= YY_MAX_SHIFTREDUCE ){
if( yyact > YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
yy_shift(yypParser,yyact,yymajor,&yyminorunion);
yypParser->yyerrcnt--;
#endif
yymajor = YYNOCODE;
}else if( yyact==YY_ACCEPT_ACTION ){
yypParser->yytos--;
yy_accept(yypParser);
return;
}else if( yyact <= YY_MAX_REDUCE ){
yy_reduce(yypParser,yyact-YY_MIN_REDUCE);
}else{
assert( yyact == YY_ERROR_ACTION );
yyminorunion.yy0 = yyminor;
#ifdef YYERRORSYMBOL
int yymx;
#endif
......@@ -2890,9 +2498,9 @@ void Parse(
**
*/
if( yypParser->yyerrcnt<0 ){
yy_syntax_error(yypParser,yymajor,yyminor);
yy_syntax_error(yypParser,yymajor,yyminorunion);
}
yymx = yypParser->yytos->major;
yymx = yypParser->yystack[yypParser->yyidx].major;
if( yymx==YYERRORSYMBOL || yyerrorhit ){
#ifndef NDEBUG
if( yyTraceFILE ){
......@@ -2900,26 +2508,26 @@ void Parse(
yyTracePrompt,yyTokenName[yymajor]);
}
#endif
yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion);
yymajor = YYNOCODE;
}else{
while( yypParser->yytos >= yypParser->yystack
&& yymx != YYERRORSYMBOL
&& (yyact = yy_find_reduce_action(
yypParser->yytos->stateno,
while(
yypParser->yyidx >= 0 &&
yymx != YYERRORSYMBOL &&
(yyact = yy_find_reduce_action(
yypParser->yystack[yypParser->yyidx].stateno,
YYERRORSYMBOL)) >= YY_MIN_REDUCE
){
yy_pop_parser_stack(yypParser);
}
if( yypParser->yytos < yypParser->yystack || yymajor==0 ){
if( yypParser->yyidx < 0 || yymajor==0 ){
yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
yy_parse_failed(yypParser);
#ifndef YYNOERRORRECOVERY
yypParser->yyerrcnt = -1;
#endif
yymajor = YYNOCODE;
}else if( yymx!=YYERRORSYMBOL ){
yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor);
YYMINORTYPE u2;
u2.YYERRSYMDT = 0;
yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);
}
}
yypParser->yyerrcnt = 3;
......@@ -2932,7 +2540,7 @@ void Parse(
** Applications can set this macro (for example inside %include) if
** they intend to abandon the parse upon the first syntax error seen.
*/
yy_syntax_error(yypParser,yymajor, yyminor);
yy_syntax_error(yypParser,yymajor,yyminorunion);
yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
yymajor = YYNOCODE;
......@@ -2947,29 +2555,24 @@ void Parse(
** three input tokens have been successfully shifted.
*/
if( yypParser->yyerrcnt<=0 ){
yy_syntax_error(yypParser,yymajor, yyminor);
yy_syntax_error(yypParser,yymajor,yyminorunion);
}
yypParser->yyerrcnt = 3;
yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
if( yyendofinput ){
yy_parse_failed(yypParser);
#ifndef YYNOERRORRECOVERY
yypParser->yyerrcnt = -1;
#endif
}
yymajor = YYNOCODE;
#endif
}
}while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack );
}while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
#ifndef NDEBUG
if( yyTraceFILE ){
yyStackEntry *i;
char cDiv = '[';
int i;
fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt);
for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){
fprintf(yyTraceFILE,"%c%s", cDiv, yyTokenName[i->major]);
cDiv = ' ';
}
for(i=1; i<=yypParser->yyidx; i++)
fprintf(yyTraceFILE,"%c%s", i==1 ? '[' : ' ',
yyTokenName[yypParser->yystack[i].major]);
fprintf(yyTraceFILE,"]\n");
}
#endif
......
......@@ -40,6 +40,7 @@ static void tscProcessAsyncRetrieveImpl(void *param, TAOS_RES *tres, int numOfRo
*/
static void tscProcessAsyncFetchRowsProxy(void *param, TAOS_RES *tres, int numOfRows);
// TODO return the correct error code to client in tscQueueAsyncError
void taos_query_a(TAOS *taos, const char *sqlstr, void (*fp)(void *, TAOS_RES *, int), void *param) {
STscObj *pObj = (STscObj *)taos;
if (pObj == NULL || pObj->signature != pObj) {
......@@ -58,14 +59,13 @@ void taos_query_a(TAOS *taos, const char *sqlstr, void (*fp)(void *, TAOS_RES *,
taosNotePrintTsc(sqlstr);
SSqlObj *pSql = (SSqlObj *)malloc(sizeof(SSqlObj));
SSqlObj *pSql = (SSqlObj *)calloc(1, sizeof(SSqlObj));
if (pSql == NULL) {
tscError("failed to malloc sqlObj");
tscQueueAsyncError(fp, param);
return;
}
memset(pSql, 0, sizeof(SSqlObj));
SSqlCmd *pCmd = &pSql->cmd;
SSqlRes *pRes = &pSql->res;
......
......@@ -34,18 +34,11 @@
#include "tstoken.h"
#include "ttime.h"
#define INVALID_SQL_RET_MSG(p, ...) \
do { \
sprintf(p, __VA_ARGS__); \
return TSDB_CODE_INVALID_SQL; \
} while (0)
enum {
TSDB_USE_SERVER_TS = 0,
TSDB_USE_CLI_TS = 1,
};
static void setErrMsg(char *msg, const char *sql);
static int32_t tscAllocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize);
static int32_t tscToInteger(SSQLToken *pToken, int64_t *value, char **endPtr) {
......@@ -63,6 +56,7 @@ static int32_t tscToInteger(SSQLToken *pToken, int64_t *value, char **endPtr) {
radix = 2;
}
errno = 0;
*value = strtoll(pToken->z, endPtr, radix);
return numType;
......@@ -73,6 +67,8 @@ static int32_t tscToDouble(SSQLToken *pToken, double *value, char **endPtr) {
if (TK_ILLEGAL == numType) {
return numType;
}
errno = 0;
*value = strtod(pToken->z, endPtr);
return numType;
}
......@@ -97,7 +93,7 @@ int tsParseTime(SSQLToken *pToken, int64_t *time, char **next, char *error, int1
} else {
// strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm);
if (taosParseTime(pToken->z, time, pToken->n, timePrec) != TSDB_CODE_SUCCESS) {
return TSDB_CODE_INVALID_SQL;
return tscInvalidSQLErrMsg(error, "invalid timestamp format", pToken->z);
}
return TSDB_CODE_SUCCESS;
......@@ -122,18 +118,21 @@ int tsParseTime(SSQLToken *pToken, int64_t *time, char **next, char *error, int1
index = 0;
sToken = tStrGetToken(pTokenEnd, &index, false, 0, NULL);
pTokenEnd += index;
if (sToken.type == TK_MINUS || sToken.type == TK_PLUS) {
index = 0;
valueToken = tStrGetToken(pTokenEnd, &index, false, 0, NULL);
pTokenEnd += index;
if (valueToken.n < 2) {
strcpy(error, "value is expected");
return TSDB_CODE_INVALID_SQL;
return tscInvalidSQLErrMsg(error, "value expected in timestamp", sToken.z);
}
if (getTimestampInUsFromStr(valueToken.z, valueToken.n, &interval) != TSDB_CODE_SUCCESS) {
return TSDB_CODE_INVALID_SQL;
}
if (timePrec == TSDB_TIME_PRECISION_MILLI) {
interval /= 1000;
}
......@@ -156,7 +155,6 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload,
int64_t iv;
int32_t numType;
char * endptr = NULL;
errno = 0; // reset global error code
switch (pSchema->type) {
case TSDB_DATA_TYPE_BOOL: { // bool
......@@ -168,7 +166,7 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload,
} else if (strncasecmp(TSDB_DATA_NULL_STR_L, pToken->z, pToken->n) == 0) {
*(uint8_t *)payload = TSDB_DATA_BOOL_NULL;
} else {
INVALID_SQL_RET_MSG(msg, "data is illegal");
return tscInvalidSQLErrMsg(msg, "invalid bool data", pToken->z);
}
} else if (pToken->type == TK_INTEGER) {
iv = strtoll(pToken->z, NULL, 10);
......@@ -179,7 +177,7 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload,
} else if (pToken->type == TK_NULL) {
*(uint8_t *)payload = TSDB_DATA_BOOL_NULL;
} else {
INVALID_SQL_RET_MSG(msg, "data is illegal");
return tscInvalidSQLErrMsg(msg, "invalid bool data", pToken->z);
}
break;
}
......@@ -192,12 +190,12 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload,
} else {
numType = tscToInteger(pToken, &iv, &endptr);
if (TK_ILLEGAL == numType) {
INVALID_SQL_RET_MSG(msg, "data is illegal");
return tscInvalidSQLErrMsg(msg, "invalid tinyint data", pToken->z);
} else if (errno == ERANGE || iv > INT8_MAX || iv <= INT8_MIN) {
INVALID_SQL_RET_MSG(msg, "data is overflow");
return tscInvalidSQLErrMsg(msg, "tinyint data overflow", pToken->z);
}
*((int8_t *)payload) = (int8_t)iv;
*((int8_t *)payload) = (int8_t) iv;
}
break;
......@@ -211,9 +209,9 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload,
} else {
numType = tscToInteger(pToken, &iv, &endptr);
if (TK_ILLEGAL == numType) {
INVALID_SQL_RET_MSG(msg, "data is illegal");
return tscInvalidSQLErrMsg(msg, "invalid smallint data", pToken->z);
} else if (errno == ERANGE || iv > INT16_MAX || iv <= INT16_MIN) {
INVALID_SQL_RET_MSG(msg, "data is overflow");
return tscInvalidSQLErrMsg(msg, "smallint data overflow", pToken->z);
}
*((int16_t *)payload) = (int16_t)iv;
......@@ -229,9 +227,9 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload,
} else {
numType = tscToInteger(pToken, &iv, &endptr);
if (TK_ILLEGAL == numType) {
INVALID_SQL_RET_MSG(msg, "data is illegal");
return tscInvalidSQLErrMsg(msg, "invalid int data", pToken->z);
} else if (errno == ERANGE || iv > INT32_MAX || iv <= INT32_MIN) {
INVALID_SQL_RET_MSG(msg, "data is overflow");
return tscInvalidSQLErrMsg(msg, "int data overflow", pToken->z);
}
*((int32_t *)payload) = (int32_t)iv;
......@@ -248,9 +246,9 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload,
} else {
numType = tscToInteger(pToken, &iv, &endptr);
if (TK_ILLEGAL == numType) {
INVALID_SQL_RET_MSG(msg, "data is illegal");
return tscInvalidSQLErrMsg(msg, "invalid bigint data", pToken->z);
} else if (errno == ERANGE || iv > INT64_MAX || iv <= INT64_MIN) {
INVALID_SQL_RET_MSG(msg, "data is overflow");
return tscInvalidSQLErrMsg(msg, "bigint data overflow", pToken->z);
}
*((int64_t *)payload) = iv;
......@@ -266,12 +264,12 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload,
} else {
double dv;
if (TK_ILLEGAL == tscToDouble(pToken, &dv, &endptr)) {
INVALID_SQL_RET_MSG(msg, "data is illegal");
return tscInvalidSQLErrMsg(msg, "illegal float data", pToken->z);
}
float fv = (float)dv;
if (((dv == HUGE_VAL || dv == -HUGE_VAL) && errno == ERANGE) || (fv > FLT_MAX || fv < -FLT_MAX)) {
INVALID_SQL_RET_MSG(msg, "data is illegal");
return tscInvalidSQLErrMsg(msg, "illegal float data", pToken->z);
}
if (isinf(fv) || isnan(fv)) {
......@@ -291,11 +289,11 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload,
} else {
double dv;
if (TK_ILLEGAL == tscToDouble(pToken, &dv, &endptr)) {
INVALID_SQL_RET_MSG(msg, "data is illegal");
return tscInvalidSQLErrMsg(msg, "illegal double data", pToken->z);
}
if (((dv == HUGE_VAL || dv == -HUGE_VAL) && errno == ERANGE) || (dv > DBL_MAX || dv < -DBL_MAX)) {
INVALID_SQL_RET_MSG(msg, "data is illegal");
return tscInvalidSQLErrMsg(msg, "illegal double data", pToken->z);
}
if (isinf(dv) || isnan(dv)) {
......@@ -310,11 +308,11 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload,
// binary data cannot be null-terminated char string, otherwise the last char of the string is lost
if (pToken->type == TK_NULL) {
*payload = TSDB_DATA_BINARY_NULL;
} else {
// too long values will return invalid sql, not be truncated automatically
} else { // too long values will return invalid sql, not be truncated automatically
if (pToken->n > pSchema->bytes) {
INVALID_SQL_RET_MSG(msg, "value too long");
return tscInvalidSQLErrMsg(msg, "string data overflow", pToken->z);
}
strncpy(payload, pToken->z, pToken->n);
}
......@@ -326,8 +324,10 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload,
} else {
// if the converted output len is over than pSchema->bytes, return error: 'Argument list too long'
if (!taosMbsToUcs4(pToken->z, pToken->n, payload, pSchema->bytes)) {
sprintf(msg, "%s", strerror(errno));
return TSDB_CODE_INVALID_SQL;
char buf[512] = {0};
snprintf(buf, 512, "%s", strerror(errno));
return tscInvalidSQLErrMsg(msg, buf, pToken->z);
}
}
break;
......@@ -342,8 +342,9 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload,
} else {
int64_t temp;
if (tsParseTime(pToken, &temp, str, msg, timePrec) != TSDB_CODE_SUCCESS) {
return TSDB_CODE_INVALID_SQL;
return tscInvalidSQLErrMsg(msg, "invalid timestamp", pToken->z);
}
*((int64_t *)payload) = temp;
}
......@@ -351,18 +352,7 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload,
}
}
return 0;
}
// todo merge the error msg function with tSQLParser
static void setErrMsg(char *msg, const char *sql) {
const char * msgFormat = "near \"%s\" syntax error";
const int32_t BACKWARD_CHAR_STEP = 15;
// only extract part of sql string,avoid too long sql string cause stack over flow
char buf[64] = {0};
strncpy(buf, (sql - BACKWARD_CHAR_STEP), tListLen(buf) - 1);
sprintf(msg, msgFormat, buf);
return TSDB_CODE_SUCCESS;
}
/*
......@@ -385,7 +375,8 @@ static int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start
}
} else {
if (pDataBlocks->tsSource == TSDB_USE_SERVER_TS) {
return -1;
return -1; // client time/server time can not be mixed
} else if (pDataBlocks->tsSource == -1) {
pDataBlocks->tsSource = TSDB_USE_CLI_TS;
}
......@@ -403,7 +394,7 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[
int16_t timePrec) {
int32_t index = 0;
bool isPrevOptr;
SSQLToken sToken;
SSQLToken sToken = {0};
char * payload = pDataBlocks->pData + pDataBlocks->size;
// 1. set the parsed value from sql string
......@@ -424,6 +415,7 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[
if (tscAddParamToDataBlock(pDataBlocks, pSchema->type, (uint8_t)timePrec, pSchema->bytes, offset) != NULL) {
continue;
}
strcpy(error, "client out of memory");
return -1;
}
......@@ -431,7 +423,7 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[
if (((sToken.type != TK_NOW) && (sToken.type != TK_INTEGER) && (sToken.type != TK_STRING) &&
(sToken.type != TK_FLOAT) && (sToken.type != TK_BOOL) && (sToken.type != TK_NULL)) ||
(sToken.n == 0) || (sToken.type == TK_RP)) {
setErrMsg(error, *str);
tscInvalidSQLErrMsg(error, "invalid data or symbol", sToken.z);
return -1;
}
......@@ -448,6 +440,7 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[
}
if (isPrimaryKey && tsCheckTimestamp(pDataBlocks, start) != TSDB_CODE_SUCCESS) {
tscInvalidSQLErrMsg(error, "client time/server time can not be mixed up", sToken.z);
return -1;
}
}
......@@ -457,8 +450,7 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[
char *ptr = payload;
for (int32_t i = 0; i < spd->numOfCols; ++i) {
if (!spd->hasVal[i]) {
// current column do not have any value to insert, set it to null
if (!spd->hasVal[i]) { // current column do not have any value to insert, set it to null
setNull(ptr, schema[i].type, schema[i].bytes);
}
......@@ -513,8 +505,7 @@ int tsParseValues(char **str, STableDataBlocks *pDataBlock, SMeterMeta *pMeterMe
}
int32_t len = tsParseOneRowData(str, pDataBlock, pSchema, spd, error, precision);
if (len <= 0) {
setErrMsg(error, *str);
if (len <= 0) { // error message has been set in tsParseOneRowData
return -1;
}
......@@ -524,7 +515,7 @@ int tsParseValues(char **str, STableDataBlocks *pDataBlock, SMeterMeta *pMeterMe
sToken = tStrGetToken(*str, &index, false, 0, NULL);
*str += index;
if (sToken.n == 0 || sToken.type != TK_RP) {
setErrMsg(error, *str);
tscInvalidSQLErrMsg(error, ") expected", *str);
return -1;
}
......@@ -719,8 +710,7 @@ static int32_t tscParseSqlForCreateTableOnDemand(char **sqlstr, SSqlObj *pSql) {
return TSDB_CODE_INVALID_SQL;
}
if (sToken.type == TK_USING) {
// create table if not exists
if (sToken.type == TK_USING) { // create table if not exists
index = 0;
sToken = tStrGetToken(sql, &index, false, 0, NULL);
sql += index;
......@@ -736,8 +726,7 @@ static int32_t tscParseSqlForCreateTableOnDemand(char **sqlstr, SSqlObj *pSql) {
}
if (!UTIL_METER_IS_METRIC(pMeterMetaInfo)) {
strcpy(pCmd->payload, "create table only from super table is allowed");
return TSDB_CODE_INVALID_SQL;
return tscInvalidSQLErrMsg(pCmd->payload, "create table only from super table is allowed", sToken.z);
}
char * tagVal = pTag->data;
......@@ -747,8 +736,7 @@ static int32_t tscParseSqlForCreateTableOnDemand(char **sqlstr, SSqlObj *pSql) {
sToken = tStrGetToken(sql, &index, false, 0, NULL);
sql += index;
if (sToken.type != TK_TAGS) {
setErrMsg(pCmd->payload, sql);
return TSDB_CODE_INVALID_SQL;
return tscInvalidSQLErrMsg(pCmd->payload, "keyword TAGS expected", sql);
}
int32_t numOfTagValues = 0;
......@@ -773,28 +761,23 @@ static int32_t tscParseSqlForCreateTableOnDemand(char **sqlstr, SSqlObj *pSql) {
code = tsParseOneColumnData(&pTagSchema[numOfTagValues], &sToken, tagVal, pCmd->payload, &sql, false,
pMeterMetaInfo->pMeterMeta->precision);
if (code != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd->payload, sql);
return TSDB_CODE_INVALID_SQL;
return code;
}
if ((pTagSchema[numOfTagValues].type == TSDB_DATA_TYPE_BINARY ||
pTagSchema[numOfTagValues].type == TSDB_DATA_TYPE_NCHAR) &&
sToken.n > pTagSchema[numOfTagValues].bytes) {
strcpy(pCmd->payload, "tag value too long");
return TSDB_CODE_INVALID_SQL;
pTagSchema[numOfTagValues].type == TSDB_DATA_TYPE_NCHAR) && sToken.n > pTagSchema[numOfTagValues].bytes) {
return tscInvalidSQLErrMsg(pCmd->payload, "string too long", sToken.z);
}
tagVal += pTagSchema[numOfTagValues++].bytes;
}
if (numOfTagValues != pMeterMetaInfo->pMeterMeta->numOfTags) {
setErrMsg(pCmd->payload, sql);
return TSDB_CODE_INVALID_SQL;
return tscInvalidSQLErrMsg(pCmd->payload, "number of tags mismatch", sql);
}
if (tscValidateName(&tableToken) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd->payload, sql);
return TSDB_CODE_INVALID_SQL;
return tscInvalidSQLErrMsg(pCmd->payload, "invalid table name", sql);
}
int32_t ret = setMeterID(pSql, &tableToken, 0);
......@@ -844,25 +827,19 @@ int validateTableName(char *tblName, int len) {
* @param pSql
* @return
*/
int tsParseInsertStatement(SSqlObj *pSql, char *str, char *acct, char *db) {
int doParserInsertSql(SSqlObj *pSql, char *str) {
SSqlCmd *pCmd = &pSql->cmd;
pCmd->command = TSDB_SQL_INSERT;
pCmd->isInsertFromFile = -1;
pCmd->count = 0;
pSql->res.numOfRows = 0;
int32_t code = TSDB_CODE_INVALID_SQL;
int32_t totalNum = 0;
int code = TSDB_CODE_INVALID_SQL;
SMeterMetaInfo *pMeterMetaInfo = tscAddEmptyMeterMetaInfo(pCmd);
if ((code = tscAllocPayload(pCmd, TSDB_PAYLOAD_SIZE)) != TSDB_CODE_SUCCESS) {
return code;
}
void *pTableHashList = taosInitIntHash(128, sizeof(void *), taosHashInt);
void *pTableHashList = taosInitIntHash(128, POINTER_BYTES, taosHashInt);
pSql->cmd.pDataBlocks = tscCreateBlockArrayList();
tscTrace("%p create data block list for submit data, %p", pSql, pSql->cmd.pDataBlocks);
......@@ -885,11 +862,11 @@ int tsParseInsertStatement(SSqlObj *pSql, char *str, char *acct, char *db) {
// Check if the table name available or not
if (validateTableName(sToken.z, sToken.n) != TSDB_CODE_SUCCESS) {
code = TSDB_CODE_INVALID_SQL;
sprintf(pCmd->payload, "table name is invalid");
code = tscInvalidSQLErrMsg(pCmd->payload, "table name invalid", sToken.z);
goto _error_clean;
}
//TODO refactor
if ((code = setMeterID(pSql, &sToken, 0)) != TSDB_CODE_SUCCESS) {
goto _error_clean;
}
......@@ -909,8 +886,7 @@ int tsParseInsertStatement(SSqlObj *pSql, char *str, char *acct, char *db) {
}
if (UTIL_METER_IS_METRIC(pMeterMetaInfo)) {
code = TSDB_CODE_INVALID_SQL;
sprintf(pCmd->payload, "insert data into metric is not supported");
code = tscInvalidSQLErrMsg(pCmd->payload, "insert data into super table is not supported", NULL);
goto _error_clean;
}
......@@ -918,8 +894,7 @@ int tsParseInsertStatement(SSqlObj *pSql, char *str, char *acct, char *db) {
sToken = tStrGetToken(str, &index, false, 0, NULL);
str += index;
if (sToken.n == 0) {
code = TSDB_CODE_INVALID_SQL;
sprintf(pCmd->payload, "keyword VALUES or FILE are required");
code = tscInvalidSQLErrMsg(pCmd->payload, "keyword VALUES or FILE are required", sToken.z);
goto _error_clean;
}
......@@ -933,8 +908,7 @@ int tsParseInsertStatement(SSqlObj *pSql, char *str, char *acct, char *db) {
pCmd->isInsertFromFile = 0;
} else {
if (pCmd->isInsertFromFile == 1) {
code = TSDB_CODE_INVALID_SQL;
sprintf(pCmd->payload, "keyword VALUES and FILE are not allowed to mix up");
code = tscInvalidSQLErrMsg(pCmd->payload, "keyword VALUES and FILE are not allowed to mix up", sToken.z);
goto _error_clean;
}
}
......@@ -953,8 +927,7 @@ int tsParseInsertStatement(SSqlObj *pSql, char *str, char *acct, char *db) {
pCmd->isInsertFromFile = 1;
} else {
if (pCmd->isInsertFromFile == 0) {
code = TSDB_CODE_INVALID_SQL;
sprintf(pCmd->payload, "keyword VALUES and FILE are not allowed to mix up");
code = tscInvalidSQLErrMsg(pCmd->payload, "keyword VALUES and FILE are not allowed to mix up", sToken.z);
goto _error_clean;
}
}
......@@ -963,8 +936,7 @@ int tsParseInsertStatement(SSqlObj *pSql, char *str, char *acct, char *db) {
sToken = tStrGetToken(str, &index, false, 0, NULL);
str += index;
if (sToken.n == 0) {
code = TSDB_CODE_INVALID_SQL;
sprintf(pCmd->payload, "file path is required following keyword FILE");
code = tscInvalidSQLErrMsg(pCmd->payload, "file path is required following keyword FILE", sToken.z);
goto _error_clean;
}
......@@ -974,8 +946,7 @@ int tsParseInsertStatement(SSqlObj *pSql, char *str, char *acct, char *db) {
wordexp_t full_path;
if (wordexp(fname, &full_path, 0) != 0) {
code = TSDB_CODE_INVALID_SQL;
sprintf(pCmd->payload, "invalid filename");
code = tscInvalidSQLErrMsg(pCmd->payload, "invalid filename", sToken.z);
goto _error_clean;
}
strcpy(fname, full_path.we_wordv[0]);
......@@ -994,8 +965,7 @@ int tsParseInsertStatement(SSqlObj *pSql, char *str, char *acct, char *db) {
if (pCmd->isInsertFromFile == -1) {
pCmd->isInsertFromFile = 0;
} else if (pCmd->isInsertFromFile == 1) {
code = TSDB_CODE_INVALID_SQL;
sprintf(pCmd->payload, "keyword VALUES and FILE are not allowed to mix up");
code = tscInvalidSQLErrMsg(pCmd->payload, "keyword VALUES and FILE are not allowed to mix up", sToken.z);
goto _error_clean;
}
......@@ -1032,8 +1002,7 @@ int tsParseInsertStatement(SSqlObj *pSql, char *str, char *acct, char *db) {
pElem->colIndex = t;
if (spd.hasVal[t] == true) {
code = TSDB_CODE_INVALID_SQL;
sprintf(pCmd->payload, "duplicated column name");
code = tscInvalidSQLErrMsg(pCmd->payload, "duplicated column name", sToken.z);
goto _error_clean;
}
......@@ -1044,15 +1013,13 @@ int tsParseInsertStatement(SSqlObj *pSql, char *str, char *acct, char *db) {
}
if (!findColumnIndex) {
code = TSDB_CODE_INVALID_SQL;
sprintf(pCmd->payload, "invalid column name");
code = tscInvalidSQLErrMsg(pCmd->payload, "invalid column name", sToken.z);
goto _error_clean;
}
}
if (spd.numOfAssignedCols == 0 || spd.numOfAssignedCols > pMeterMeta->numOfColumns) {
code = TSDB_CODE_INVALID_SQL;
sprintf(pCmd->payload, "column name expected");
code = tscInvalidSQLErrMsg(pCmd->payload, "column name expected", sToken.z);
goto _error_clean;
}
......@@ -1061,8 +1028,7 @@ int tsParseInsertStatement(SSqlObj *pSql, char *str, char *acct, char *db) {
str += index;
if (sToken.type != TK_VALUES) {
code = TSDB_CODE_INVALID_SQL;
sprintf(pCmd->payload, "keyword VALUES is expected");
code = tscInvalidSQLErrMsg(pCmd->payload, "keyword VALUES is expected", sToken.z);
goto _error_clean;
}
......@@ -1071,8 +1037,7 @@ int tsParseInsertStatement(SSqlObj *pSql, char *str, char *acct, char *db) {
goto _error_clean;
}
} else {
code = TSDB_CODE_INVALID_SQL;
sprintf(pCmd->payload, "keyword VALUES or FILE are required");
code = tscInvalidSQLErrMsg(pCmd->payload, "keyword VALUES or FILE are required", sToken.z);
goto _error_clean;
}
}
......@@ -1120,25 +1085,21 @@ int tsParseInsertSql(SSqlObj *pSql, char *sql, char *acct, char *db) {
SSqlCmd *pCmd = &pSql->cmd;
SSQLToken sToken = tStrGetToken(sql, &index, false, 0, NULL);
if (sToken.type == TK_IMPORT) {
pCmd->order.order = TSQL_SO_ASC;
} else if (sToken.type != TK_INSERT) {
if (sToken.n) {
sToken.z[sToken.n] = 0;
sprintf(pCmd->payload, "invalid keyword:%s", sToken.z);
} else {
strcpy(pCmd->payload, "no any keywords");
}
return TSDB_CODE_INVALID_SQL;
}
assert(sToken.type == TK_INSERT || sToken.type == TK_IMPORT);
pCmd->import = (sToken.type == TK_IMPORT);
sToken = tStrGetToken(sql, &index, false, 0, NULL);
if (sToken.type != TK_INTO) {
strcpy(pCmd->payload, "keyword INTO is expected");
return TSDB_CODE_INVALID_SQL;
return tscInvalidSQLErrMsg(pCmd->payload, "keyword INTO is expected", sToken.z);
}
return tsParseInsertStatement(pSql, sql + index, acct, db);
pCmd->count = 0;
pCmd->command = TSDB_SQL_INSERT;
pCmd->isInsertFromFile = -1;
pSql->res.numOfRows = 0;
return doParserInsertSql(pSql, sql + index);
}
int tsParseSql(SSqlObj *pSql, char *acct, char *db, bool multiVnodeInsertion) {
......@@ -1259,6 +1220,7 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp) {
pSql->res.code = TSDB_CODE_INVALID_SQL;
return -1;
}
pTableDataBlock->size += len;
count++;
......
......@@ -62,17 +62,15 @@ static bool validateTagParams(tFieldList* pTagsList, tFieldList* pFieldList, SSq
static int32_t setObjFullName(char* fullName, char* account, SSQLToken* pDB, SSQLToken* tableName, int32_t* len);
static void getColumnName(tSQLExprItem* pItem, char* resultFieldName, int32_t nLen);
static void getColumnName(tSQLExprItem* pItem, char* resultFieldName, int32_t nameLength);
static void getRevisedName(char* resultFieldName, int32_t functionId, int32_t maxLen, char* columnName);
static int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem);
static int32_t insertResultField(SSqlCmd* pCmd, int32_t fieldIDInResult, SColumnList* pIdList, int16_t bytes,
int8_t type, char* fieldName);
static int32_t insertResultField(SSqlCmd* pCmd, int32_t outputIndex, SColumnList* pIdList, int16_t bytes, int8_t type,
char* fieldName);
static int32_t changeFunctionID(int32_t optr, int16_t* functionId);
static int32_t parseSelectClause(SSqlCmd* pCmd, tSQLExprList* pSelection, bool isMetric);
static void setErrMsg(SSqlCmd* pCmd, const char* pzErrMsg);
static bool validateIpAddress(char* ip);
static bool hasUnsupportFunctionsForMetricQuery(SSqlCmd* pCmd);
static bool functionCompatibleCheck(SSqlCmd* pCmd);
......@@ -117,6 +115,14 @@ static int32_t tscCheckCreateDbParams(SSqlCmd* pCmd, SCreateDbMsg *pCreate);
static SColumnList getColumnList(int32_t num, int16_t tableIndex, int32_t columnIndex);
/*
* Used during parsing query sql. Since the query sql usually small in length, error position
* is not needed in the final error message.
*/
static int32_t invalidSqlErrMsg(SSqlCmd *pCmd, const char* errMsg) {
return tscInvalidSQLErrMsg(pCmd->payload, errMsg, NULL);
}
static int32_t tscQueryOnlyMetricTags(SSqlCmd* pCmd, bool* queryOnMetricTags) {
assert(QUERY_IS_STABLE_QUERY(pCmd->type));
......@@ -144,13 +150,11 @@ static int setColumnFilterInfoForTimestamp(SSqlCmd* pCmd, tVariant* pVar) {
if (seg != NULL) {
if (taosParseTime(pVar->pz, &time, pVar->nLen, pMeterMetaInfo->pMeterMeta->precision) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
} else {
if (tVariantDump(pVar, (char*)&time, TSDB_DATA_TYPE_BIGINT)) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
}
......@@ -169,8 +173,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
SSqlCmd* pCmd = &(pSql->cmd);
if (!pInfo->validSql) {
setErrMsg(pCmd, pInfo->pzErrMsg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, pInfo->pzErrMsg);
}
SMeterMetaInfo* pMeterMetaInfo = tscAddEmptyMeterMetaInfo(pCmd);
......@@ -188,8 +191,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
SSQLToken* pzName = &pInfo->pDCLInfo->a[0];
if ((pInfo->sqlType != DROP_DNODE) && (tscValidateName(pzName) != TSDB_CODE_SUCCESS)) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
if (pInfo->sqlType == DROP_DATABASE) {
......@@ -200,7 +202,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
int32_t code = setObjFullName(pMeterMetaInfo->name, getAccountId(pSql), pzName, NULL, NULL);
if (code != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg2);
invalidSqlErrMsg(pCmd, msg2);
}
return code;
......@@ -212,13 +214,12 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
int32_t ret = setMeterID(pSql, pzName, 0);
if (ret != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg);
invalidSqlErrMsg(pCmd, msg);
}
return ret;
} else {
if (pzName->n > TSDB_USER_LEN) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
if (pInfo->sqlType == DROP_USER) {
......@@ -230,15 +231,13 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
const int32_t MAX_IP_ADDRESS_LEGNTH = 16;
if (pzName->n > MAX_IP_ADDRESS_LEGNTH) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
char str[128] = {0};
strncpy(str, pzName->z, pzName->n);
if (!validateIpAddress(str)) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
}
......@@ -254,14 +253,11 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
SSQLToken* pToken = &pInfo->pDCLInfo->a[0];
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
const char* msg1 = "invalid db name";
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, "invalid db name");
}
if (pToken->n > TSDB_DB_NAME_LEN) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
int32_t ret = setObjFullName(pMeterMetaInfo->name, getAccountId(pSql), pToken, NULL, NULL);
......@@ -291,7 +287,8 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
case SHOW_STREAMS:
case SHOW_SCORES:
case SHOW_GRANTS:
case SHOW_CONFIGS: {
case SHOW_CONFIGS:
case SHOW_VNODES: {
return setShowInfo(pSql, pInfo);
}
......@@ -309,14 +306,12 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
SCreateDBInfo* pCreateDB = &(pInfo->pDCLInfo->dbOpt);
if (tscValidateName(&pCreateDB->dbname) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
int32_t ret = setObjFullName(pMeterMetaInfo->name, getAccountId(pSql), &(pCreateDB->dbname), NULL, NULL);
if (ret != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg2);
return ret;
return invalidSqlErrMsg(pCmd, msg2);
}
if (parseCreateDBOptions(pCmd, pCreateDB) != TSDB_CODE_SUCCESS) {
......@@ -334,14 +329,12 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
char ipAddr[64] = {0};
const int32_t MAX_IP_ADDRESS_LENGTH = 16;
if (pInfo->pDCLInfo->nTokens > 1 || pInfo->pDCLInfo->a[0].n > MAX_IP_ADDRESS_LENGTH) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
memcpy(ipAddr, pInfo->pDCLInfo->a[0].z, pInfo->pDCLInfo->a[0].n);
if (validateIpAddress(ipAddr) == false) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
strncpy(pMeterMetaInfo->name, pInfo->pDCLInfo->a[0].z, pInfo->pDCLInfo->a[0].n);
......@@ -360,8 +353,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
const char* msg4 = "invalid state option, available options[no, r, w, all]";
if (pInfo->pDCLInfo->a[1].type != TK_STRING) {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
strdequote(pInfo->pDCLInfo->a[1].z);
......@@ -369,18 +361,15 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pInfo->pDCLInfo->a[1].n = strlen(pInfo->pDCLInfo->a[1].z);
if (pInfo->pDCLInfo->a[1].n <= 0) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
if (pInfo->pDCLInfo->a[0].n > TSDB_USER_LEN || pInfo->pDCLInfo->a[1].n > TSDB_PASSWORD_LEN) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
if (tscValidateName(&pInfo->pDCLInfo->a[0]) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
strncpy(pMeterMetaInfo->name, pInfo->pDCLInfo->a[0].z, pInfo->pDCLInfo->a[0].n); // name
......@@ -413,8 +402,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
} else if (strncmp(pAcctOpt->stat.z, "no", 2) == 0 && pAcctOpt->stat.n == 2) {
pCmd->defaultVal[8] = 0;
} else {
setErrMsg(pCmd, msg4);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg4);
}
}
}
......@@ -433,8 +421,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if (num == 2) {
if (pInfo->pDCLInfo->a[1].type != TK_STRING) {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
strdequote(pInfo->pDCLInfo->a[1].z);
......@@ -442,26 +429,22 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pInfo->pDCLInfo->a[1].n = strlen(pInfo->pDCLInfo->a[1].z);
if (pInfo->pDCLInfo->a[1].n <= 0) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
if (pInfo->pDCLInfo->a[1].n > TSDB_PASSWORD_LEN) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
strncpy(pCmd->payload, pInfo->pDCLInfo->a[1].z, pInfo->pDCLInfo->a[1].n); // passwd
}
if (pInfo->pDCLInfo->a[0].n > TSDB_USER_LEN) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
if (tscValidateName(&pInfo->pDCLInfo->a[0]) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
strncpy(pMeterMetaInfo->name, pInfo->pDCLInfo->a[0].z, pInfo->pDCLInfo->a[0].n); // name
......@@ -491,8 +474,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
} else if (strncmp(pAcctOpt->stat.z, "no", 2) == 0 && pAcctOpt->stat.n == 2) {
pCmd->defaultVal[8] = 0;
} else {
setErrMsg(pCmd, msg4);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg4);
}
}
break;
......@@ -502,21 +484,18 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
SSQLToken* pToken = &pInfo->pDCLInfo->a[0];
const char* msg = "table name is too long";
const char* msg1 = "invalid table name";
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
const char* msg1 = "invalid table name";
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
if (pToken->n > TSDB_METER_NAME_LEN) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
if (setMeterID(pSql, pToken, 0) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
int32_t ret = tscGetMeterMeta(pSql, pMeterMetaInfo->name, 0);
......@@ -545,13 +524,11 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
if (pDCL->a[1].n <= 0) {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
if (pDCL->a[0].n > TSDB_METER_NAME_LEN || pDCL->a[1].n > TSDB_PASSWORD_LEN) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
if (pCmd->command == TSDB_SQL_CFG_DNODE) {
......@@ -560,16 +537,14 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
/* validate the ip address */
if (!validateIpAddress(ip)) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
strcpy(pMeterMetaInfo->name, ip);
/* validate the parameter names and options */
if (validateDNodeConfig(pDCL) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
strncpy(pCmd->payload, pDCL->a[1].z, pDCL->a[1].n);
......@@ -593,8 +568,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if (pDCL->a[1].n <= 0 || pInfo->pDCLInfo->a[1].n > TSDB_PASSWORD_LEN) {
/* password cannot be empty string */
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
strncpy(pCmd->payload, pDCL->a[1].z, pDCL->a[1].n);
......@@ -608,8 +582,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
} else if (strncasecmp(pDCL->a[1].z, "write", 5) == 0 && pDCL->a[1].n == 5) {
pCmd->count = 3;
} else {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
} else {
return TSDB_CODE_INVALID_SQL;
......@@ -619,19 +592,12 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
case ALTER_LOCAL: {
pCmd->command = TSDB_SQL_CFG_LOCAL;
/*
if (pInfo->pDCLInfo->a[0].n > TSDB_METER_ID_LEN) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
*/
tDCLSQL* pDCL = pInfo->pDCLInfo;
const char* msg = "invalid configure options or values";
// validate the parameter names and options
if (validateLocalConfig(pDCL) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
strncpy(pCmd->payload, pDCL->a[0].z, pDCL->a[0].n);
......@@ -658,13 +624,11 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
SSQLToken* pzTableName = &(pInfo->pCreateTableInfo->name);
if (tscValidateName(pzTableName) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
if (setMeterID(pSql, pzTableName, 0) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
if (!validateTableColumnInfo(pFieldList, pCmd) ||
......@@ -694,19 +658,18 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
const char* msg = "invalid table name";
const char* msg1 = "illegal value or data overflow";
const char* msg2 = "illegal number of tags";
const char* msg3 = "tag value too long";
// table name
// metric name, create table by using dst
SSQLToken* pToken = &(pInfo->pCreateTableInfo->usingInfo.metricName);
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
if (setMeterID(pSql, pToken, 0) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
// get meter meta from mnode
......@@ -721,8 +684,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
if (pMeterMetaInfo->pMeterMeta->numOfTags != pList->nExpr) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
// too long tag values will return invalid sql, not be truncated automatically
......@@ -732,24 +694,20 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
for (int32_t i = 0; i < pList->nExpr; ++i) {
int32_t ret = tVariantDump(&(pList->a[i].pVar), tagVal, pTagSchema[i].type);
if (ret != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
// validate the length of binary
if ((pTagSchema[i].type == TSDB_DATA_TYPE_BINARY || pTagSchema[i].type == TSDB_DATA_TYPE_NCHAR) &&
pList->a[i].pVar.nLen > pTagSchema[i].bytes) {
const char* msg3 = "tag value too long";
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
tagVal += pTagSchema[i].bytes;
}
if (tscValidateName(&pInfo->pCreateTableInfo->name) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
int32_t ret = setMeterID(pSql, &pInfo->pCreateTableInfo->name, 0);
......@@ -767,14 +725,14 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
const char* msg2 = "table name too long";
const char* msg3 = "fill only available for interval query";
const char* msg4 = "fill option not supported in stream computing";
const char* msg5 = "sql too long"; // todo ADD support
// if sql specifies db, use it, otherwise use default db
SSQLToken* pzTableName = &(pInfo->pCreateTableInfo->name);
SQuerySQL* pQuerySql = pInfo->pCreateTableInfo->pSelect;
if (tscValidateName(pzTableName) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
tVariantList* pSrcMeterName = pInfo->pCreateTableInfo->pSelect->from;
......@@ -782,13 +740,11 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
SSQLToken srcToken = {.z = pVar->pz, .n = pVar->nLen, .type = TK_STRING};
if (tscValidateName(&srcToken) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
if (setMeterID(pSql, &srcToken, 0) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
int32_t code = tscGetMeterMeta(pSql, pMeterMetaInfo->name, 0);
......@@ -822,23 +778,19 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
// set the created table[stream] name
if (setMeterID(pSql, pzTableName, 0) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
// copy sql length
int ret = tscAllocPayload(pCmd, pQuerySql->selectToken.n + 8);
if (TSDB_CODE_SUCCESS != ret) {
const char* msg6 = "client out of memory";
setErrMsg(pCmd, msg6);
invalidSqlErrMsg(pCmd, "client out of memory");
return ret;
}
strncpy(pCmd->payload, pQuerySql->selectToken.z, pQuerySql->selectToken.n);
if (pQuerySql->selectToken.n > TSDB_MAX_SAVED_SQL_LEN) {
const char* msg5 = "sql too long"; // todo ADD support
setErrMsg(pCmd, msg5);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg5);
}
if (tsRewriteFieldNameIfNecessary(pCmd) != TSDB_CODE_SUCCESS) {
......@@ -857,16 +809,14 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
*/
if (pQuerySql->fillType != NULL) {
if (pCmd->nAggTimeInterval == 0) {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
tVariantListItem* pItem = &pQuerySql->fillType->a[0];
if (pItem->pVar.nType == TSDB_DATA_TYPE_BINARY) {
if (!((strncmp(pItem->pVar.pz, "none", 4) == 0 && pItem->pVar.nLen == 4) ||
(strncmp(pItem->pVar.pz, "null", 4) == 0 && pItem->pVar.nLen == 4))) {
setErrMsg(pCmd, msg4);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg4);
}
}
}
......@@ -889,10 +839,11 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
const char* msg8 = "too many columns in selection clause";
const char* msg9 = "TWA query requires both the start and end time";
int32_t code = TSDB_CODE_SUCCESS;
// too many result columns not support order by in query
if (pQuerySql->pSelection->nExpr > TSDB_MAX_COLUMNS) {
setErrMsg(pCmd, msg8);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg8);
}
/*
......@@ -909,8 +860,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
if (pQuerySql->from->nExpr > TSDB_MAX_JOIN_TABLE_NUM) {
setErrMsg(pCmd, msg7);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg7);
}
// set all query tables, which are maybe more than one.
......@@ -918,16 +868,14 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
tVariant* pTableItem = &pQuerySql->from->a[i].pVar;
if (pTableItem->nType != TSDB_DATA_TYPE_BINARY) {
setErrMsg(pCmd, msg0);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg0);
}
pTableItem->nLen = strdequote(pTableItem->pz);
SSQLToken tableName = {.z = pTableItem->pz, .n = pTableItem->nLen, .type = TK_STRING};
if (tscValidateName(&tableName) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg0);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg0);
}
if (pCmd->numOfTables <= i) {
......@@ -936,19 +884,17 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
SSQLToken t = {.type = TSDB_DATA_TYPE_BINARY, .n = pTableItem->nLen, .z = pTableItem->pz};
if (setMeterID(pSql, &t, i) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
SMeterMetaInfo* pMeterInfo1 = tscGetMeterMetaInfo(pCmd, i);
int32_t code = tscGetMeterMeta(pSql, pMeterInfo1->name, i);
code = tscGetMeterMeta(pSql, pMeterInfo1->name, i);
if (code != TSDB_CODE_SUCCESS) {
return code;
}
}
pSql->cmd.command = TSDB_SQL_SELECT;
int32_t code = TSDB_CODE_SUCCESS;
// parse the group by clause in the first place
if (parseGroupbyClause(pCmd, pQuerySql->pGroupby) != TSDB_CODE_SUCCESS) {
......@@ -975,8 +921,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
// TODO refactor pCmd->count == 1 means sql in stream function
if (!tscEmbedded && pCmd->count == 0) {
const char* msg = "not support sliding in query";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
getTimestampInUsFromStr(pSliding->z, pSliding->n, &pCmd->nSlidingTime);
......@@ -985,13 +930,11 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
if (pCmd->nSlidingTime < tsMinSlidingTime) {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
if (pCmd->nSlidingTime > pCmd->nAggTimeInterval) {
setErrMsg(pCmd, msg4);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg4);
}
}
......@@ -1022,8 +965,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if ((pCmd->stime == 0 || pCmd->etime == INT64_MAX ||
(pCmd->etime == INT64_MAX / 1000 && pMeterMetaInfo->pMeterMeta->precision == TSDB_TIME_PRECISION_MILLI)) &&
tscIsTWAQuery(pCmd)) {
setErrMsg(pCmd, msg9);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg9);
}
// no result due to invalid query time range
......@@ -1033,22 +975,19 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
if (!hasTimestampForPointInterpQuery(pCmd)) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
if (pQuerySql->fillType != NULL) {
if (pCmd->nAggTimeInterval == 0 && (!tscIsPointInterpQuery(pCmd))) {
setErrMsg(pCmd, msg5);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg5);
}
if (pCmd->nAggTimeInterval > 0) {
int64_t timeRange = labs(pCmd->stime - pCmd->etime);
// number of result is not greater than 10,000,000
if ((timeRange == 0) || (timeRange / pCmd->nAggTimeInterval) > MAX_RETRIEVE_ROWS_IN_INTERVAL_QUERY) {
setErrMsg(pCmd, msg6);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg6);
}
}
......@@ -1063,8 +1002,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
int64_t timeRange = labs(pCmd->stime - pCmd->etime);
if (timeRange == 0 && pCmd->stime == 0) {
setErrMsg(pCmd, msg6);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg6);
}
}
......@@ -1152,8 +1090,7 @@ int32_t parseIntervalClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql) {
// interval cannot be less than 10 milliseconds
if (pCmd->nAggTimeInterval < tsMinIntervalTime) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
// for top/bottom + interval query, we do not add additional timestamp column in the front
......@@ -1165,8 +1102,7 @@ int32_t parseIntervalClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql) {
for (int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
SSqlExpr* pExpr = tscSqlExprGet(pCmd, i);
if (pExpr->functionId == TSDB_FUNC_COUNT && TSDB_COL_IS_TAG(pExpr->colInfo.flag)) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
}
......@@ -1209,13 +1145,11 @@ int32_t setSlidingClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql) {
}
if (pCmd->nSlidingTime < tsMinSlidingTime) {
setErrMsg(pCmd, msg0);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg0);
}
if (pCmd->nSlidingTime > pCmd->nAggTimeInterval) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
}
......@@ -1243,7 +1177,7 @@ int32_t setMeterID(SSqlObj* pSql, SSQLToken* pzTableName, int32_t tableIndex) {
}
if (code != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg);
invalidSqlErrMsg(pCmd, msg);
}
return code;
......@@ -1262,13 +1196,13 @@ static bool validateTableColumnInfo(tFieldList* pFieldList, SSqlCmd* pCmd) {
// number of fields no less than 2
if (pFieldList->nField <= 1 || pFieldList->nField > TSDB_MAX_COLUMNS) {
setErrMsg(pCmd, msg);
invalidSqlErrMsg(pCmd, msg);
return false;
}
// first column must be timestamp
if (pFieldList->p[0].type != TSDB_DATA_TYPE_TIMESTAMP) {
setErrMsg(pCmd, msg1);
invalidSqlErrMsg(pCmd, msg1);
return false;
}
......@@ -1279,7 +1213,7 @@ static bool validateTableColumnInfo(tFieldList* pFieldList, SSqlCmd* pCmd) {
// max row length must be less than TSDB_MAX_BYTES_PER_ROW
if (nLen > TSDB_MAX_BYTES_PER_ROW) {
setErrMsg(pCmd, msg2);
invalidSqlErrMsg(pCmd, msg2);
return false;
}
......@@ -1287,23 +1221,23 @@ static bool validateTableColumnInfo(tFieldList* pFieldList, SSqlCmd* pCmd) {
for (int32_t i = 0; i < pFieldList->nField; ++i) {
TAOS_FIELD* pField = &pFieldList->p[i];
if (pField->type < TSDB_DATA_TYPE_BOOL || pField->type > TSDB_DATA_TYPE_NCHAR) {
setErrMsg(pCmd, msg4);
invalidSqlErrMsg(pCmd, msg4);
return false;
}
if ((pField->type == TSDB_DATA_TYPE_BINARY && (pField->bytes <= 0 || pField->bytes > TSDB_MAX_BINARY_LEN)) ||
(pField->type == TSDB_DATA_TYPE_NCHAR && (pField->bytes <= 0 || pField->bytes > TSDB_MAX_NCHAR_LEN))) {
setErrMsg(pCmd, msg5);
invalidSqlErrMsg(pCmd, msg5);
return false;
}
if (validateColumnName(pField->name) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg6);
invalidSqlErrMsg(pCmd, msg6);
return false;
}
if (has(pFieldList, i + 1, pFieldList->p[i].name) == true) {
setErrMsg(pCmd, msg3);
invalidSqlErrMsg(pCmd, msg3);
return false;
}
}
......@@ -1324,7 +1258,7 @@ static bool validateTagParams(tFieldList* pTagsList, tFieldList* pFieldList, SSq
// number of fields at least 1
if (pTagsList->nField < 1 || pTagsList->nField > TSDB_MAX_TAGS) {
setErrMsg(pCmd, msg1);
invalidSqlErrMsg(pCmd, msg1);
return false;
}
......@@ -1335,14 +1269,14 @@ static bool validateTagParams(tFieldList* pTagsList, tFieldList* pFieldList, SSq
// max tag row length must be less than TSDB_MAX_TAGS_LEN
if (nLen > TSDB_MAX_TAGS_LEN) {
setErrMsg(pCmd, msg2);
invalidSqlErrMsg(pCmd, msg2);
return false;
}
// field name must be unique
for (int32_t i = 0; i < pTagsList->nField; ++i) {
if (has(pFieldList, 0, pTagsList->p[i].name) == true) {
setErrMsg(pCmd, msg3);
invalidSqlErrMsg(pCmd, msg3);
return false;
}
}
......@@ -1350,28 +1284,28 @@ static bool validateTagParams(tFieldList* pTagsList, tFieldList* pFieldList, SSq
/* timestamp in tag is not allowed */
for (int32_t i = 0; i < pTagsList->nField; ++i) {
if (pTagsList->p[i].type == TSDB_DATA_TYPE_TIMESTAMP) {
setErrMsg(pCmd, msg4);
invalidSqlErrMsg(pCmd, msg4);
return false;
}
if (pTagsList->p[i].type < TSDB_DATA_TYPE_BOOL || pTagsList->p[i].type > TSDB_DATA_TYPE_NCHAR) {
setErrMsg(pCmd, msg5);
invalidSqlErrMsg(pCmd, msg5);
return false;
}
if ((pTagsList->p[i].type == TSDB_DATA_TYPE_BINARY && pTagsList->p[i].bytes <= 0) ||
(pTagsList->p[i].type == TSDB_DATA_TYPE_NCHAR && pTagsList->p[i].bytes <= 0)) {
setErrMsg(pCmd, msg7);
invalidSqlErrMsg(pCmd, msg7);
return false;
}
if (validateColumnName(pTagsList->p[i].name) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg6);
invalidSqlErrMsg(pCmd, msg6);
return false;
}
if (has(pTagsList, i + 1, pTagsList->p[i].name) == true) {
setErrMsg(pCmd, msg3);
invalidSqlErrMsg(pCmd, msg3);
return false;
}
}
......@@ -1398,18 +1332,18 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) {
char msg[128] = {0};
sprintf(msg, "tags no more than %d", TSDB_MAX_TAGS);
setErrMsg(pCmd, msg);
invalidSqlErrMsg(pCmd, msg);
return false;
}
// no timestamp allowable
if (pTagField->type == TSDB_DATA_TYPE_TIMESTAMP) {
setErrMsg(pCmd, msg1);
invalidSqlErrMsg(pCmd, msg1);
return false;
}
if (pTagField->type < TSDB_DATA_TYPE_BOOL && pTagField->type > TSDB_DATA_TYPE_NCHAR) {
setErrMsg(pCmd, msg6);
invalidSqlErrMsg(pCmd, msg6);
return false;
}
......@@ -1422,19 +1356,19 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) {
// length less than TSDB_MAX_TASG_LEN
if (nLen + pTagField->bytes > TSDB_MAX_TAGS_LEN) {
setErrMsg(pCmd, msg3);
invalidSqlErrMsg(pCmd, msg3);
return false;
}
// tags name can not be a keyword
if (validateColumnName(pTagField->name) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg4);
invalidSqlErrMsg(pCmd, msg4);
return false;
}
// binary(val), val can not be equalled to or less than 0
if ((pTagField->type == TSDB_DATA_TYPE_BINARY || pTagField->type == TSDB_DATA_TYPE_NCHAR) && pTagField->bytes <= 0) {
setErrMsg(pCmd, msg5);
invalidSqlErrMsg(pCmd, msg5);
return false;
}
......@@ -1443,7 +1377,7 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) {
for (int32_t i = 0; i < pMeterMeta->numOfTags + pMeterMeta->numOfColumns; ++i) {
if (strncasecmp(pTagField->name, pSchema[i].name, TSDB_COL_NAME_LEN) == 0) {
setErrMsg(pCmd, msg2);
invalidSqlErrMsg(pCmd, msg2);
return false;
}
}
......@@ -1465,17 +1399,17 @@ bool validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) {
// no more max columns
if (pMeterMeta->numOfColumns >= TSDB_MAX_COLUMNS ||
pMeterMeta->numOfTags + pMeterMeta->numOfColumns >= TSDB_MAX_COLUMNS) {
setErrMsg(pCmd, msg1);
invalidSqlErrMsg(pCmd, msg1);
return false;
}
if (pColField->type < TSDB_DATA_TYPE_BOOL || pColField->type > TSDB_DATA_TYPE_NCHAR) {
setErrMsg(pCmd, msg4);
invalidSqlErrMsg(pCmd, msg4);
return false;
}
if (validateColumnName(pColField->name) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg5);
invalidSqlErrMsg(pCmd, msg5);
return false;
}
......@@ -1487,20 +1421,20 @@ bool validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) {
}
if (pColField->bytes <= 0) {
setErrMsg(pCmd, msg6);
invalidSqlErrMsg(pCmd, msg6);
return false;
}
// length less than TSDB_MAX_BYTES_PER_ROW
if (nLen + pColField->bytes > TSDB_MAX_BYTES_PER_ROW) {
setErrMsg(pCmd, msg3);
invalidSqlErrMsg(pCmd, msg3);
return false;
}
// field name must be unique
for (int32_t i = 0; i < pMeterMeta->numOfTags + pMeterMeta->numOfColumns; ++i) {
if (strncasecmp(pColField->name, pSchema[i].name, TSDB_COL_NAME_LEN) == 0) {
setErrMsg(pCmd, msg2);
invalidSqlErrMsg(pCmd, msg2);
return false;
}
}
......@@ -1641,8 +1575,7 @@ int32_t parseSelectClause(SSqlCmd* pCmd, tSQLExprList* pSelection, bool isMetric
int32_t ret =
validateArithmeticSQLExpr(pItem->pNode, pSchema, pMeterMetaInfo->pMeterMeta->numOfColumns, &columnList);
if (ret != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
char arithmeticExprStr[1024] = {0};
......@@ -1671,8 +1604,7 @@ int32_t parseSelectClause(SSqlCmd* pCmd, tSQLExprList* pSelection, bool isMetric
* not support such expression
* e.g., select 12+5 from table_name
*/
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
if (pCmd->fieldsInfo.numOfOutputCols > TSDB_MAX_COLUMNS) {
......@@ -1681,8 +1613,7 @@ int32_t parseSelectClause(SSqlCmd* pCmd, tSQLExprList* pSelection, bool isMetric
}
if (!functionCompatibleCheck(pCmd)) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
if (isMetric) {
......@@ -1860,8 +1791,7 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, tSQLExprItem* pItem) {
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
if (getColumnIndexByNameEx(&pItem->pNode->colInfo, pCmd, &index) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg0);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg0);
}
if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) {
......@@ -1876,8 +1806,7 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, tSQLExprItem* pItem) {
SMeterMeta* pMeterMeta = pMeterMetaInfo->pMeterMeta;
if (index.columnIndex >= pMeterMeta->numOfColumns && UTIL_METER_IS_NOMRAL_METER(pMeterMetaInfo)) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
addProjectQueryCol(pCmd, startPos, &index, pItem);
......@@ -1901,7 +1830,7 @@ static int32_t setExprInfoForFunctions(SSqlCmd* pCmd, SSchema* pSchema, int32_t
if (pSchema[pColIndex->columnIndex].type == TSDB_DATA_TYPE_BINARY ||
pSchema[pColIndex->columnIndex].type == TSDB_DATA_TYPE_NCHAR ||
pSchema[pColIndex->columnIndex].type == TSDB_DATA_TYPE_BOOL) {
setErrMsg(pCmd, msg1);
invalidSqlErrMsg(pCmd, msg1);
return -1;
} else {
type = TSDB_DATA_TYPE_DOUBLE;
......@@ -1949,8 +1878,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
case TK_COUNT: {
if (pItem->pNode->pParam != NULL && pItem->pNode->pParam->nExpr != 1) {
/* more than one parameter for count() function */
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
int16_t functionID = 0;
......@@ -1963,8 +1891,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
if (pItem->pNode->pParam != NULL) {
SSQLToken* pToken = &pItem->pNode->pParam->a[0].pNode->colInfo;
if (pToken->z == NULL || pToken->n == 0) {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
tSQLExprItem* pParamElem = &pItem->pNode->pParam->a[0];
......@@ -1974,8 +1901,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
SSQLToken tmpToken = pParamElem->pNode->colInfo;
if (getTableIndexByName(&tmpToken, pCmd, &index) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg4);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg4);
}
index = (SColumnIndex){0, PRIMARYKEY_TIMESTAMP_COL_INDEX};
......@@ -1984,8 +1910,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
} else {
// count the number of meters created according to the metric
if (getColumnIndexByNameEx(pToken, pCmd, &index) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, index.tableIndex);
......@@ -2026,20 +1951,17 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
if (pItem->pNode->pParam == NULL || (optr != TK_LEASTSQUARES && pItem->pNode->pParam->nExpr != 1) ||
(optr == TK_LEASTSQUARES && pItem->pNode->pParam->nExpr != 3)) {
/* no parameters or more than one parameter for function */
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
tSQLExprItem* pParamElem = &(pItem->pNode->pParam->a[0]);
if (pParamElem->pNode->nSQLOptr != TK_ALL && pParamElem->pNode->nSQLOptr != TK_ID) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
if (getColumnIndexByNameEx(&pParamElem->pNode->colInfo, pCmd, &index) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
// 2. check if sql function can be applied on this column data type
......@@ -2048,8 +1970,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
int16_t colType = pSchema->type;
if (colType == TSDB_DATA_TYPE_BOOL || colType >= TSDB_DATA_TYPE_BINARY) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
char columnName[TSDB_COL_NAME_LEN] = {0};
......@@ -2081,8 +2002,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
// functions can not be applied to tags
if (index.columnIndex >= pMeterMetaInfo->pMeterMeta->numOfColumns) {
setErrMsg(pCmd, msg6);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg6);
}
SSqlExpr* pExpr = tscSqlExprInsert(pCmd, colIdx, functionID, &index, resultType, resultSize, resultSize);
......@@ -2124,8 +2044,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
if (!requireAllFields) {
if (pItem->pNode->pParam->nExpr < 1) {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
/* in first/last function, multiple columns can be add to resultset */
......@@ -2133,8 +2052,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
for (int32_t i = 0; i < pItem->pNode->pParam->nExpr; ++i) {
tSQLExprItem* pParamElem = &(pItem->pNode->pParam->a[i]);
if (pParamElem->pNode->nSQLOptr != TK_ALL && pParamElem->pNode->nSQLOptr != TK_ID) {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
......@@ -2144,8 +2062,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
SSQLToken tmpToken = pParamElem->pNode->colInfo;
if (getTableIndexByName(&tmpToken, pCmd, &index) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg4);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg4);
}
pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, index.tableIndex);
......@@ -2160,8 +2077,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
} else {
if (getColumnIndexByNameEx(&pParamElem->pNode->colInfo, pCmd, &index) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, index.tableIndex);
......@@ -2169,8 +2085,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
// functions can not be applied to tags
if (index.columnIndex >= pMeterMetaInfo->pMeterMeta->numOfColumns) {
setErrMsg(pCmd, msg6);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg6);
}
if (setExprInfoForFunctions(pCmd, pSchema, functionID, pItem->aliasName, colIdx + i, &index) != 0) {
......@@ -2207,14 +2122,12 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
// 1. valid the number of parameters
if (pItem->pNode->pParam == NULL || pItem->pNode->pParam->nExpr != 2) {
/* no parameters or more than one parameter for function */
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
tSQLExprItem* pParamElem = &(pItem->pNode->pParam->a[0]);
if (pParamElem->pNode->nSQLOptr != TK_ID) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
char columnName[TSDB_COL_NAME_LEN] = {0};
......@@ -2222,8 +2135,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
if (getColumnIndexByNameEx(&pParamElem->pNode->colInfo, pCmd, &index) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, index.tableIndex);
......@@ -2231,21 +2143,18 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
// functions can not be applied to tags
if (index.columnIndex >= pMeterMetaInfo->pMeterMeta->numOfColumns) {
setErrMsg(pCmd, msg6);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg6);
}
// 2. valid the column type
int16_t colType = pSchema[index.columnIndex].type;
if (colType == TSDB_DATA_TYPE_BOOL || colType >= TSDB_DATA_TYPE_BINARY) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
// 3. valid the parameters
if (pParamElem[1].pNode->nSQLOptr == TK_ID) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
tVariant* pVariant = &pParamElem[1].pNode->val;
......@@ -2259,8 +2168,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
double dp = *((double*)val);
if (dp < 0 || dp > TOP_BOTTOM_QUERY_LIMIT) {
setErrMsg(pCmd, msg5);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg5);
}
resultSize = sizeof(double);
......@@ -2283,8 +2191,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
int64_t nTop = *((int32_t*)val);
if (nTop <= 0 || nTop > 100) { // todo use macro
setErrMsg(pCmd, msg5);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg5);
}
int16_t functionId = 0;
......@@ -2391,8 +2298,7 @@ int32_t doGetColumnIndexByName(SSQLToken* pToken, SSqlCmd* pCmd, SColumnIndex* p
if (colIndex != COLUMN_INDEX_INITIAL_VAL) {
if (pIndex->columnIndex != COLUMN_INDEX_INITIAL_VAL) {
setErrMsg(pCmd, msg0);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg0);
} else {
pIndex->tableIndex = i;
pIndex->columnIndex = colIndex;
......@@ -2407,8 +2313,7 @@ int32_t doGetColumnIndexByName(SSQLToken* pToken, SSqlCmd* pCmd, SColumnIndex* p
}
if (pIndex->columnIndex == COLUMN_INDEX_INITIAL_VAL) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
}
......@@ -2595,6 +2500,9 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
case SHOW_CONFIGS:
pCmd->showType = TSDB_MGMT_TABLE_CONFIGS;
break;
case SHOW_VNODES:
pCmd->showType = TSDB_MGMT_TABLE_VNODES;
break;
default:
return TSDB_CODE_INVALID_SQL;
}
......@@ -2609,13 +2517,11 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
SSQLToken* pDbPrefixToken = &pInfo->pDCLInfo->a[0];
if (pDbPrefixToken->n > TSDB_DB_NAME_LEN) { // db name is too long
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
if (pDbPrefixToken->n > 0 && tscValidateName(pDbPrefixToken) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
int32_t ret = 0;
......@@ -2635,10 +2541,25 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pCmd->payloadLen = strdequote(pCmd->payload);
if (pCmd->payloadLen > TSDB_METER_NAME_LEN) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL; // wildcard is too long
return invalidSqlErrMsg(pCmd, msg2);
}
}
}
}else if (type == SHOW_VNODES) {
if (NULL == pInfo->pDCLInfo) {
return invalidSqlErrMsg(pCmd, "No specified ip of dnode");
}
// show vnodes may be ip addr of dnode in payload
if (pInfo->pDCLInfo->nTokens > 0) {
SSQLToken* pDnodeIp = &pInfo->pDCLInfo->a[0];
if (pDnodeIp->n > TSDB_IPv4ADDR_LEN) { // ip addr is too long
return invalidSqlErrMsg(pCmd, msg);
}
strncpy(pCmd->payload, pDnodeIp->z, pDnodeIp->n);
pCmd->payloadLen = strdequote(pCmd->payload);
}
}
......@@ -2677,8 +2598,7 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
memset(pCmd->payload, 0, tListLen(pCmd->payload));
const char* msg = "invalid ip address";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
uint16_t port = (uint16_t)strtol(portStr, NULL, 10);
......@@ -2686,18 +2606,12 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
memset(pCmd->payload, 0, tListLen(pCmd->payload));
const char* msg = "invalid port";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
return TSDB_CODE_SUCCESS;
}
void setErrMsg(SSqlCmd* pCmd, const char* pzErrMsg) {
strncpy(pCmd->payload, pzErrMsg, pCmd->allocSize);
pCmd->payload[pCmd->allocSize - 1] = 0;
}
bool validateIpAddress(char* ip) {
in_addr_t ipAddr = inet_addr(ip);
return (ipAddr != 0) && (ipAddr != 0xffffffff);
......@@ -2773,12 +2687,12 @@ bool hasUnsupportFunctionsForMetricQuery(SSqlCmd* pCmd) {
if (tscIsTWAQuery(pCmd)) {
if (pCmd->groupbyExpr.numOfGroupCols == 0) {
setErrMsg(pCmd, msg1);
invalidSqlErrMsg(pCmd, msg1);
return true;
}
if (pCmd->groupbyExpr.numOfGroupCols != 1 || pCmd->groupbyExpr.columnInfo[0].colIdx != TSDB_TBNAME_COLUMN_INDEX) {
setErrMsg(pCmd, msg3);
invalidSqlErrMsg(pCmd, msg3);
return true;
}
}
......@@ -2872,8 +2786,7 @@ int32_t parseGroupbyClause(SSqlCmd* pCmd, tVariantList* pList) {
pCmd->groupbyExpr.numOfGroupCols = pList->nExpr;
if (pList->nExpr > TSDB_MAX_TAGS) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
SMeterMeta* pMeterMeta = NULL;
......@@ -2890,13 +2803,11 @@ int32_t parseGroupbyClause(SSqlCmd* pCmd, tVariantList* pList) {
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
if (getColumnIndexByNameEx(&token, pCmd, &index) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
if (tableIndex != index.tableIndex && tableIndex >= 0) {
setErrMsg(pCmd, msg5);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg5);
}
tableIndex = index.tableIndex;
......@@ -2927,8 +2838,7 @@ int32_t parseGroupbyClause(SSqlCmd* pCmd, tVariantList* pList) {
if (groupTag) {
if (!UTIL_METER_IS_METRIC(pMeterMetaInfo)) {
setErrMsg(pCmd, msg9);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg9);
}
int32_t relIndex = index.columnIndex;
......@@ -2942,8 +2852,7 @@ int32_t parseGroupbyClause(SSqlCmd* pCmd, tVariantList* pList) {
} else {
// check if the column type is valid, here only support the bool/tinyint/smallint/bigint group by
if (pSchema->type > TSDB_DATA_TYPE_BIGINT) {
setErrMsg(pCmd, msg8);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg8);
}
tscColumnBaseInfoInsert(pCmd, &index);
......@@ -2952,8 +2861,7 @@ int32_t parseGroupbyClause(SSqlCmd* pCmd, tVariantList* pList) {
pCmd->groupbyExpr.orderType = TSQL_SO_ASC;
if (i == 0 && pList->nExpr > 1) {
setErrMsg(pCmd, msg7);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg7);
}
}
}
......@@ -3055,8 +2963,7 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SColumnFilterInfo* pColu
pColumnFilter->lowerRelOptr = TSDB_RELATION_LIKE;
break;
default:
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
return TSDB_CODE_SUCCESS;
......@@ -3278,13 +3185,11 @@ static int32_t extractColumnFilterInfo(SSqlCmd* pCmd, SColumnIndex* pIndex, tSQL
if (pColFilter->filterOnBinary) {
if (pExpr->nSQLOptr != TK_EQ && pExpr->nSQLOptr != TK_NE && pExpr->nSQLOptr != TK_LIKE) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
} else {
if (pExpr->nSQLOptr == TK_LIKE) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
}
......@@ -3359,7 +3264,7 @@ static int32_t getTablenameCond(SSqlCmd* pCmd, tSQLExpr* pTableCond, char* str)
}
if (ret != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg0);
invalidSqlErrMsg(pCmd, msg0);
}
return ret;
......@@ -3397,8 +3302,7 @@ static int32_t getJoinCondInfo(SSqlObj* pSql, tSQLExpr* pExpr) {
SSqlCmd* pCmd = &pSql->cmd;
if (!isExprDirectParentOfLeaftNode(pExpr)) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
STagCond* pTagCond = &pCmd->tagCond;
......@@ -3609,14 +3513,14 @@ static bool validateJoinExprNode(SSqlCmd* pCmd, tSQLExpr* pExpr, SColumnIndex* p
}
if (pExpr->nSQLOptr != TK_EQ) {
setErrMsg(pCmd, msg2);
invalidSqlErrMsg(pCmd, msg2);
return false;
}
SColumnIndex rightIndex = COLUMN_INDEX_INITIALIZER;
if (getColumnIndexByNameEx(&pRight->colInfo, pCmd, &rightIndex) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg1);
invalidSqlErrMsg(pCmd, msg1);
return false;
}
......@@ -3630,19 +3534,19 @@ static bool validateJoinExprNode(SSqlCmd* pCmd, tSQLExpr* pExpr, SColumnIndex* p
int16_t rightType = pRightSchema[rightIndex.columnIndex].type;
if (leftType != rightType) {
setErrMsg(pCmd, msg3);
invalidSqlErrMsg(pCmd, msg3);
return false;
} else if (pLeftIndex->tableIndex == rightIndex.tableIndex) {
setErrMsg(pCmd, msg4);
invalidSqlErrMsg(pCmd, msg4);
return false;
} else if (leftType == TSDB_DATA_TYPE_BINARY || leftType == TSDB_DATA_TYPE_NCHAR) {
setErrMsg(pCmd, msg6);
invalidSqlErrMsg(pCmd, msg6);
return false;
}
// table to table/ super table to super table are allowed
if (UTIL_METER_IS_METRIC(pLeftMeterMeta) != UTIL_METER_IS_METRIC(pRightMeterMeta)) {
setErrMsg(pCmd, msg5);
invalidSqlErrMsg(pCmd, msg5);
return false;
}
......@@ -3664,8 +3568,7 @@ static bool validTableNameOptr(tSQLExpr* pExpr) {
static int32_t setExprToCond(SSqlCmd* pCmd, tSQLExpr** parent, tSQLExpr* pExpr, const char* msg, int32_t parentOptr) {
if (*parent != NULL) {
if (parentOptr == TK_OR && msg != NULL) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
*parent = tSQLExprCreate((*parent), pExpr, parentOptr);
......@@ -3694,8 +3597,7 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, tSQLExpr** pExpr, SCondExpr*
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
if (getColumnIndexByNameEx(&pLeft->colInfo, pCmd, &index) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
assert(isExprDirectParentOfLeaftNode(*pExpr));
......@@ -3728,8 +3630,7 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, tSQLExpr** pExpr, SCondExpr*
index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) { // query on tags
// check for tag query condition
if (UTIL_METER_IS_NOMRAL_METER(pMeterMetaInfo)) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
// check for like expression
......@@ -3742,16 +3643,14 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, tSQLExpr** pExpr, SCondExpr*
if ((!isTablenameToken(&pLeft->colInfo)) && pSchema[index.columnIndex].type != TSDB_DATA_TYPE_BINARY &&
pSchema[index.columnIndex].type != TSDB_DATA_TYPE_NCHAR) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
}
// in case of in operator, keep it in a seperate attribute
if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) {
if (!validTableNameOptr(*pExpr)) {
setErrMsg(pCmd, msg8);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg8);
}
if (pCondExpr->pTableCond == NULL) {
......@@ -3759,8 +3658,7 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, tSQLExpr** pExpr, SCondExpr*
pCondExpr->relType = parentOptr;
pCondExpr->tableCondIndex = index.tableIndex;
} else {
setErrMsg(pCmd, msg7);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg7);
}
*type = TSQL_EXPR_TBNAME;
......@@ -3772,8 +3670,7 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, tSQLExpr** pExpr, SCondExpr*
}
if (pCondExpr->pJoinExpr != NULL) {
setErrMsg(pCmd, msg4);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg4);
}
pCmd->type |= TSDB_QUERY_TYPE_JOIN_QUERY;
......@@ -3792,15 +3689,9 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, tSQLExpr** pExpr, SCondExpr*
*type = TSQL_EXPR_COLUMN;
if (pRight->nSQLOptr == TK_ID) { // other column cannot be served as the join column
setErrMsg(pCmd, msg6);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg6);
}
// if (parentOptr == TK_OR) {
// setErrMsg(pCmd, msg5);
// return TSDB_CODE_INVALID_SQL;
// }
ret = setExprToCond(pCmd, &pCondExpr->pColumnCond, *pExpr, NULL, parentOptr);
*pExpr = NULL; // remove it from expr tree
}
......@@ -3842,8 +3733,7 @@ int32_t getQueryCondExpr(SSqlCmd* pCmd, tSQLExpr** pExpr, SCondExpr* pCondExpr,
*/
if (leftType != rightType) {
if ((*pExpr)->nSQLOptr == TK_OR && (leftType + rightType != TSQL_EXPR_TBNAME + TSQL_EXPR_TAG)) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
}
......@@ -3997,7 +3887,7 @@ static int32_t setTableCondForMetricQuery(SSqlObj* pSql, tSQLExpr* pExpr, int16_
int32_t ret = setObjFullName(pTableCond->z + pTableCond->n, acc, &dbToken, &t, &xlen);
if (ret != TSDB_CODE_SUCCESS) {
tfree(segments);
setErrMsg(pCmd, msg);
invalidSqlErrMsg(pCmd, msg);
return ret;
}
......@@ -4042,8 +3932,7 @@ static int32_t getTimeRangeFromExpr(SSqlCmd* pCmd, tSQLExpr* pExpr) {
if (!isExprDirectParentOfLeaftNode(pExpr)) {
if (pExpr->nSQLOptr == TK_OR) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
getTimeRangeFromExpr(pCmd, pExpr->pLeft);
......@@ -4064,8 +3953,7 @@ static int32_t getTimeRangeFromExpr(SSqlCmd* pCmd, tSQLExpr* pExpr) {
TSKEY etime = INT64_MAX;
if (getTimeRange(&stime, &etime, pRight, pExpr->nSQLOptr, pMeterMeta->precision) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg0);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg0);
}
// update the timestamp query range
......@@ -4090,8 +3978,7 @@ static int32_t validateJoinExpr(SSqlCmd* pCmd, SCondExpr* pCondExpr) {
if (pCmd->numOfTables == 1) {
return TSDB_CODE_SUCCESS;
} else {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
}
......@@ -4099,14 +3986,12 @@ static int32_t validateJoinExpr(SSqlCmd* pCmd, SCondExpr* pCondExpr) {
if (UTIL_METER_IS_METRIC(pMeterMetaInfo)) { // for stable join, tag columns
// must be present for join
if (pCondExpr->pJoinExpr == NULL) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
}
if (!pCondExpr->tsJoin) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
return TSDB_CODE_SUCCESS;
......@@ -4150,8 +4035,7 @@ int32_t parseWhereClause(SSqlObj* pSql, tSQLExpr** pExpr) {
SCondExpr condExpr = {0};
if ((*pExpr)->pLeft == NULL || (*pExpr)->pRight == NULL) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
ret = doParseWhereClause(pSql, pExpr, &condExpr);
......@@ -4253,8 +4137,7 @@ int32_t doParseWhereClause(SSqlObj* pSql, tSQLExpr** pExpr, SCondExpr* condExpr)
pCmd->tagCond.relType = (condExpr->relType == TK_AND) ? TSDB_RELATION_AND : TSDB_RELATION_OR;
ret = setTableCondForMetricQuery(pSql, condExpr->pTableCond, condExpr->tableCondIndex, tableNameCond);
if (!validateFilterExpr(pCmd)) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
return ret;
......@@ -4372,8 +4255,7 @@ int32_t tsRewriteFieldNameIfNecessary(SSqlCmd* pCmd) {
for (int32_t j = i + 1; j < pCmd->fieldsInfo.numOfOutputCols; ++j) {
if (strncasecmp(fieldName, tscFieldInfoGetField(pCmd, j)->name, TSDB_COL_NAME_LEN) == 0) {
const char* msg = "duplicated column name in new table";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
}
}
......@@ -4391,8 +4273,7 @@ int32_t parseFillClause(SSqlCmd* pCmd, SQuerySQL* pQuerySQL) {
const char* msg2 = "invalid fill option";
if (pItem->pVar.nType != TSDB_DATA_TYPE_BINARY) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
if (strncasecmp(pItem->pVar.pz, "none", 4) == 0 && pItem->pVar.nLen == 4) {
......@@ -4412,8 +4293,7 @@ int32_t parseFillClause(SSqlCmd* pCmd, SQuerySQL* pQuerySQL) {
pCmd->interpoType = TSDB_INTERPO_SET_VALUE;
if (pFillToken->nExpr == 1) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
int32_t startPos = 1;
......@@ -4438,8 +4318,7 @@ int32_t parseFillClause(SSqlCmd* pCmd, SQuerySQL* pQuerySQL) {
int32_t ret = tVariantDump(&pFillToken->a[j].pVar, (char*)&pCmd->defaultVal[i], pFields->type);
if (ret != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
if (pFields->type == TSDB_DATA_TYPE_BINARY || pFields->type == TSDB_DATA_TYPE_NCHAR) {
......@@ -4461,8 +4340,7 @@ int32_t parseFillClause(SSqlCmd* pCmd, SQuerySQL* pQuerySQL) {
}
}
} else {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
return TSDB_CODE_SUCCESS;
......@@ -4509,13 +4387,11 @@ int32_t parseOrderbyClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql, SSchema* pSchema
*/
if (UTIL_METER_IS_NOMRAL_METER(pMeterMetaInfo)) {
if (pSortorder->nExpr > 1) {
setErrMsg(pCmd, msg0);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg0);
}
} else {
if (pSortorder->nExpr > 2) {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
}
......@@ -4532,8 +4408,7 @@ int32_t parseOrderbyClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql, SSchema* pSchema
if (UTIL_METER_IS_METRIC(pMeterMetaInfo)) { // metric query
if (getColumnIndexByNameEx(&columnName, pCmd, &index) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
bool orderByTags = false;
......@@ -4554,8 +4429,7 @@ int32_t parseOrderbyClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql, SSchema* pSchema
}
if (!(orderByTags || orderByTS) && !isTopBottomQuery(pCmd)) {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
} else {
assert(!(orderByTags && orderByTS));
}
......@@ -4571,8 +4445,7 @@ int32_t parseOrderbyClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql, SSchema* pSchema
pExpr = tscSqlExprGet(pCmd, 1);
if (pExpr->colInfo.colIdx != index.columnIndex && index.columnIndex != PRIMARYKEY_TIMESTAMP_COL_INDEX) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
pCmd->order.order = pQuerySql->pSortOrder->a[0].sortOrder;
......@@ -4596,13 +4469,11 @@ int32_t parseOrderbyClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql, SSchema* pSchema
tVariant* pVar2 = &pSortorder->a[1].pVar;
SSQLToken cname = {pVar2->nLen, pVar2->nType, pVar2->pz};
if (getColumnIndexByNameEx(&cname, pCmd, &index) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
if (index.columnIndex != PRIMARYKEY_TIMESTAMP_COL_INDEX) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
} else {
pCmd->order.order = pSortorder->a[1].sortOrder;
pCmd->order.orderColId = PRIMARYKEY_TIMESTAMP_COL_INDEX;
......@@ -4611,13 +4482,11 @@ int32_t parseOrderbyClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql, SSchema* pSchema
} else { // meter query
if (getColumnIndexByNameEx(&columnName, pCmd, &index) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
if (index.columnIndex != PRIMARYKEY_TIMESTAMP_COL_INDEX && !isTopBottomQuery(pCmd)) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
if (isTopBottomQuery(pCmd)) {
......@@ -4627,8 +4496,7 @@ int32_t parseOrderbyClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql, SSchema* pSchema
pExpr = tscSqlExprGet(pCmd, 1);
if (pExpr->colInfo.colIdx != index.columnIndex && index.columnIndex != PRIMARYKEY_TIMESTAMP_COL_INDEX) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
pCmd->order.order = pQuerySql->pSortOrder->a[0].sortOrder;
......@@ -4653,14 +4521,12 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if (tscValidateName(&(pAlterSQL->name)) != TSDB_CODE_SUCCESS) {
const char* msg = "invalid table name";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
if (setMeterID(pSql, &(pAlterSQL->name), 0) != TSDB_CODE_SUCCESS) {
const char* msg = "table name too long";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
int32_t ret = tscGetMeterMeta(pSql, pMeterMetaInfo->name, DEFAULT_TABLE_INDEX);
......@@ -4675,18 +4541,15 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pInfo->sqlType == ALTER_TABLE_TAGS_CHG) {
if (UTIL_METER_IS_NOMRAL_METER(pMeterMetaInfo)) {
const char* msg = "manipulation of tag available for metric";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
} else if ((pInfo->sqlType == ALTER_TABLE_TAGS_SET) && (UTIL_METER_IS_METRIC(pMeterMetaInfo))) {
const char* msg = "set tag value only available for table";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
} else if ((pInfo->sqlType == ALTER_TABLE_ADD_COLUMN || pInfo->sqlType == ALTER_TABLE_DROP_COLUMN) &&
UTIL_METER_IS_CREATE_FROM_METRIC(pMeterMetaInfo)) {
const char* msg = "column can only be modified by metric";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
if (pInfo->sqlType == ALTER_TABLE_TAGS_ADD) {
......@@ -4695,8 +4558,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
tFieldList* pFieldList = pAlterSQL->pAddColumns;
if (pFieldList->nField > 1) {
const char* msg = "only support add one tag";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
if (!validateOneTags(pCmd, &pFieldList->p[0])) {
......@@ -4716,20 +4578,17 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
const char* msg5 = "primary tag cannot be dropped";
if (pMeterMeta->numOfTags == 1) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
// numOfTags == 1
if (pAlterSQL->varList->nExpr > 1) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
tVariantListItem* pItem = &pAlterSQL->varList->a[0];
if (pItem->pVar.nLen > TSDB_COL_NAME_LEN) {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
int32_t idx = -1;
......@@ -4745,11 +4604,9 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
if (idx == -1) {
setErrMsg(pCmd, msg4);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg4);
} else if (idx == 0) {
setErrMsg(pCmd, msg5);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg5);
}
char name[128] = {0};
......@@ -4772,13 +4629,11 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
tVariantListItem* pDstItem = &pAlterSQL->varList->a[1];
if (pSrcItem->pVar.nLen >= TSDB_COL_NAME_LEN || pDstItem->pVar.nLen >= TSDB_COL_NAME_LEN) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
if (pSrcItem->pVar.nType != TSDB_DATA_TYPE_BINARY || pDstItem->pVar.nType != TSDB_DATA_TYPE_BINARY) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
SColumnIndex srcIndex = COLUMN_INDEX_INITIALIZER;
......@@ -4818,8 +4673,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
tVariant* pTagName = &pVarList->a[0].pVar;
if (pTagName->nLen > TSDB_COL_NAME_LEN) {
setErrMsg(pCmd, msg0);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg0);
}
int32_t tagsIndex = -1;
......@@ -4833,20 +4687,17 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
if (tagsIndex == -1) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
if (tVariantDump(&pVarList->a[1].pVar, pCmd->payload, pTagsSchema[tagsIndex].type) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
// validate the length of binary
if ((pTagsSchema[tagsIndex].type == TSDB_DATA_TYPE_BINARY || pTagsSchema[tagsIndex].type == TSDB_DATA_TYPE_NCHAR) &&
pVarList->a[1].pVar.nLen > pTagsSchema[tagsIndex].bytes) {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
char name[128] = {0};
......@@ -4860,8 +4711,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
tFieldList* pFieldList = pAlterSQL->pAddColumns;
if (pFieldList->nField > 1) {
const char* msg = "only support add one column";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
if (!validateOneColumn(pCmd, &pFieldList->p[0])) {
......@@ -4880,19 +4730,16 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
const char* msg5 = "primary timestamp column cannot be dropped";
if (pMeterMeta->numOfColumns == TSDB_MIN_COLUMNS) { //
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
if (pAlterSQL->varList->nExpr > 1) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
tVariantListItem* pItem = &pAlterSQL->varList->a[0];
if (pItem->pVar.nLen > TSDB_COL_NAME_LEN) {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
int32_t idx = -1;
......@@ -4907,11 +4754,9 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
if (idx == -1) {
setErrMsg(pCmd, msg4);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg4);
} else if (idx == 0) {
setErrMsg(pCmd, msg5);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg5);
}
char name[128] = {0};
......@@ -4929,15 +4774,13 @@ int32_t validateSqlFunctionInStreamSql(SSqlCmd* pCmd) {
const char* msg1 = "functions not allowed in select clause";
if (pCmd->nAggTimeInterval != 0 && pCmd->nAggTimeInterval < 10) {
setErrMsg(pCmd, msg0);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg0);
}
for (int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
int32_t functId = tscSqlExprGet(pCmd, i)->functionId;
if (!IS_STREAM_QUERY_VALID(aAggs[functId].nStatus)) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
}
......@@ -4976,7 +4819,7 @@ int32_t validateFunctionsInIntervalOrGroupbyQuery(SSqlCmd* pCmd) {
}
if (isProjectionFunction) {
setErrMsg(pCmd, msg1);
invalidSqlErrMsg(pCmd, msg1);
}
return isProjectionFunction == true ? TSDB_CODE_INVALID_SQL : TSDB_CODE_SUCCESS;
......@@ -5131,8 +4974,7 @@ int32_t parseLimitClause(SSqlObj* pSql, SQuerySQL* pQuerySql) {
pCmd->slimit = pQuerySql->slimit;
if (pCmd->slimit.offset < 0 || pCmd->limit.offset < 0) {
setErrMsg(pCmd, msg0);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg0);
}
if (pCmd->limit.limit == 0) {
......@@ -5150,8 +4992,7 @@ int32_t parseLimitClause(SSqlObj* pSql, SQuerySQL* pQuerySql) {
pCmd->command = TSDB_SQL_RETRIEVE_TAGS;
} else {
if (tscProjectionQueryOnMetric(pCmd) && (pCmd->slimit.limit > 0 || pCmd->slimit.offset > 0)) {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
}
......@@ -5182,16 +5023,14 @@ int32_t parseLimitClause(SSqlObj* pSql, SQuerySQL* pQuerySql) {
pCmd->globalLimit = pCmd->limit.limit;
} else {
if (pCmd->slimit.limit != -1 || pCmd->slimit.offset != 0) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
// filter the query functions operating on "tbname" column that are not supported by normal columns.
for (int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
SSqlExpr* pExpr = tscSqlExprGet(pCmd, i);
if (pExpr->colInfo.colIdx == TSDB_TBNAME_COLUMN_INDEX) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
}
}
......@@ -5224,8 +5063,7 @@ static int32_t setKeepOption(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDBInfo* p
break;
}
default: {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
}
}
......@@ -5250,8 +5088,7 @@ static int32_t setTimePrecisionOption(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreate
strlen(TSDB_TIME_PRECISION_MICRO_STR) == pToken->n) {
pMsg->precision = TSDB_TIME_PRECISION_MICRO;
} else {
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
}
......@@ -5514,8 +5351,7 @@ static int32_t checkUpdateTagPrjFunctions(SSqlCmd* pCmd) {
// When the tag projection function on tag column that is not in the group by clause, aggregation function and
// selectivity function exist in select clause is not allowed.
if (numOfAggregation > 0) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
/*
......@@ -5536,8 +5372,7 @@ static int32_t checkUpdateTagPrjFunctions(SSqlCmd* pCmd) {
}
if (((aAggs[functionId].nStatus & TSDB_FUNCSTATE_SELECTIVITY) != 0) && (functionId != TSDB_FUNC_LAST_ROW)) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
}
......@@ -5547,8 +5382,7 @@ static int32_t checkUpdateTagPrjFunctions(SSqlCmd* pCmd) {
} else {
if ((pCmd->type & TSDB_QUERY_TYPE_PROJECTION_QUERY) == TSDB_QUERY_TYPE_PROJECTION_QUERY) {
if (numOfAggregation > 0 && pCmd->groupbyExpr.numOfGroupCols == 0) {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
if (numOfAggregation > 0 || numOfSelectivity > 0) {
......@@ -5603,8 +5437,7 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd) {
} else {
// if this query is "group by" normal column, interval is not allowed
if (pCmd->nAggTimeInterval > 0) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
bool hasGroupColumn = false;
......@@ -5641,8 +5474,7 @@ int32_t doFunctionsCompatibleCheck(SSqlObj* pSql) {
// only retrieve tags, group by is not supportted
if (pCmd->command == TSDB_SQL_RETRIEVE_TAGS) {
if (pCmd->groupbyExpr.numOfGroupCols > 0 || pCmd->nAggTimeInterval > 0) {
setErrMsg(pCmd, msg5);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg5);
} else {
return TSDB_CODE_SUCCESS;
}
......@@ -5686,13 +5518,11 @@ int32_t doFunctionsCompatibleCheck(SSqlObj* pSql) {
if (IS_MULTIOUTPUT(aAggs[functId].nStatus) && functId != TSDB_FUNC_TOP && functId != TSDB_FUNC_BOTTOM &&
functId != TSDB_FUNC_TAGPRJ && functId != TSDB_FUNC_PRJ) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
if (functId == TSDB_FUNC_COUNT && pExpr->colInfo.colIdx == TSDB_TBNAME_COLUMN_INDEX) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
}
......@@ -5710,8 +5540,7 @@ int32_t doFunctionsCompatibleCheck(SSqlObj* pSql) {
// projection query on metric does not compatible with "group by" syntax
if (tscProjectionQueryOnMetric(pCmd)) {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
return TSDB_CODE_SUCCESS;
......@@ -5727,16 +5556,15 @@ int32_t doLocalQueryProcess(SQuerySQL* pQuerySql, SSqlCmd* pCmd) {
tSQLExprList* pExprList = pQuerySql->pSelection;
if (pExprList->nExpr != 1) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg1);
}
tSQLExpr* pExpr = pExprList->a[0].pNode;
if (pExpr->operand.z == NULL) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg2);
}
// TODO redefine the function
SDNodeDynConfOption functionsInfo[5] = {{"database()", 10},
{"server_version()", 16},
{"server_status()", 15},
......@@ -5776,8 +5604,7 @@ int32_t doLocalQueryProcess(SQuerySQL* pQuerySql, SSqlCmd* pCmd) {
pCmd->command = TSDB_SQL_CURRENT_USER;
return TSDB_CODE_SUCCESS;
default: {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg3);
}
}
}
......@@ -5788,80 +5615,70 @@ int32_t tscCheckCreateDbParams(SSqlCmd* pCmd, SCreateDbMsg *pCreate) {
if (pCreate->commitLog != -1 && (pCreate->commitLog < 0 || pCreate->commitLog > 1)) {
snprintf(msg, tListLen(msg), "invalid db option commitLog: %d, only 0 or 1 allowed", pCreate->commitLog);
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
if (pCreate->replications != -1 &&
(pCreate->replications < TSDB_REPLICA_MIN_NUM || pCreate->replications > TSDB_REPLICA_MAX_NUM)) {
snprintf(msg, tListLen(msg), "invalid db option replications: %d valid range: [%d, %d]", pCreate->replications, TSDB_REPLICA_MIN_NUM,
TSDB_REPLICA_MAX_NUM);
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
int32_t val = htonl(pCreate->daysPerFile);
if (val != -1 && (val < TSDB_FILE_MIN_PARTITION_RANGE || val > TSDB_FILE_MAX_PARTITION_RANGE)) {
snprintf(msg, tListLen(msg), "invalid db option daysPerFile: %d valid range: [%d, %d]", val,
TSDB_FILE_MIN_PARTITION_RANGE, TSDB_FILE_MAX_PARTITION_RANGE);
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
val = htonl(pCreate->rowsInFileBlock);
if (val != -1 && (val < TSDB_MIN_ROWS_IN_FILEBLOCK || val > TSDB_MAX_ROWS_IN_FILEBLOCK)) {
snprintf(msg, tListLen(msg), "invalid db option rowsInFileBlock: %d valid range: [%d, %d]", val,
TSDB_MIN_ROWS_IN_FILEBLOCK, TSDB_MAX_ROWS_IN_FILEBLOCK);
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
val = htonl(pCreate->cacheBlockSize);
if (val != -1 && (val < TSDB_MIN_CACHE_BLOCK_SIZE || val > TSDB_MAX_CACHE_BLOCK_SIZE)) {
snprintf(msg, tListLen(msg), "invalid db option cacheBlockSize: %d valid range: [%d, %d]", val,
TSDB_MIN_CACHE_BLOCK_SIZE, TSDB_MAX_CACHE_BLOCK_SIZE);
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
val = htonl(pCreate->maxSessions);
if (val != -1 && (val < TSDB_MIN_TABLES_PER_VNODE || val > TSDB_MAX_TABLES_PER_VNODE)) {
snprintf(msg, tListLen(msg), "invalid db option maxSessions: %d valid range: [%d, %d]", val, TSDB_MIN_TABLES_PER_VNODE,
TSDB_MAX_TABLES_PER_VNODE);
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
if (pCreate->precision != -1 &&
(pCreate->precision != TSDB_TIME_PRECISION_MILLI && pCreate->precision != TSDB_TIME_PRECISION_MICRO)) {
snprintf(msg, tListLen(msg), "invalid db option timePrecision: %d valid value: [%d, %d]", pCreate->precision, TSDB_TIME_PRECISION_MILLI,
TSDB_TIME_PRECISION_MICRO);
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
if (pCreate->cacheNumOfBlocks.fraction != -1 && (pCreate->cacheNumOfBlocks.fraction < TSDB_MIN_AVG_BLOCKS ||
pCreate->cacheNumOfBlocks.fraction > TSDB_MAX_AVG_BLOCKS)) {
snprintf(msg, tListLen(msg), "invalid db option ablocks: %f valid value: [%d, %d]", pCreate->cacheNumOfBlocks.fraction,
TSDB_MIN_AVG_BLOCKS, TSDB_MAX_AVG_BLOCKS);
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
val = htonl(pCreate->commitTime);
if (val != -1 && (val < TSDB_MIN_COMMIT_TIME_INTERVAL || val > TSDB_MAX_COMMIT_TIME_INTERVAL)) {
snprintf(msg, tListLen(msg), "invalid db option commitTime: %d valid range: [%d, %d]", val,
TSDB_MIN_COMMIT_TIME_INTERVAL, TSDB_MAX_COMMIT_TIME_INTERVAL);
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
if (pCreate->compression != -1 &&
(pCreate->compression < TSDB_MIN_COMPRESSION_LEVEL || pCreate->compression > TSDB_MAX_COMPRESSION_LEVEL)) {
snprintf(msg, tListLen(msg), "invalid db option compression: %d valid range: [%d, %d]", pCreate->compression, TSDB_MIN_COMPRESSION_LEVEL,
TSDB_MAX_COMPRESSION_LEVEL);
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
return invalidSqlErrMsg(pCmd, msg);
}
return TSDB_CODE_SUCCESS;
......
......@@ -746,7 +746,7 @@ void setCreateAcctSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pName, SSQLToken
}
void setDefaultCreateDbOption(SCreateDBInfo *pDBInfo) {
pDBInfo->numOfBlocksPerTable = -1;
pDBInfo->numOfBlocksPerTable = 50;
pDBInfo->compressionLevel = -1;
pDBInfo->commitLog = -1;
......
......@@ -123,6 +123,7 @@ bool tsMeterMetaIdentical(SMeterMeta* p1, SMeterMeta* p2) {
return memcmp(p1, p2, size) == 0;
}
//todo refactor
static FORCE_INLINE char* skipSegments(char* input, char delimiter, int32_t num) {
for (int32_t i = 0; i < num; ++i) {
while (*input != 0 && *input++ != delimiter) {
......
......@@ -1415,7 +1415,7 @@ int tscBuildSubmitMsg(SSqlObj *pSql) {
pMsg = pStart;
pShellMsg = (SShellSubmitMsg *)pMsg;
pShellMsg->import = pSql->cmd.order.order;
pShellMsg->import = pSql->cmd.import;
pShellMsg->vnode = htons(pMeterMeta->vpeerDesc[pMeterMeta->index].vnode);
pShellMsg->numOfSid = htonl(pSql->cmd.count); // number of meters to be inserted
......@@ -2175,7 +2175,7 @@ int tscBuildShowMsg(SSqlObj *pSql) {
pShowMsg = (SShowMsg *)pMsg;
pShowMsg->type = pCmd->showType;
if ((pShowMsg->type == TSDB_MGMT_TABLE_TABLE || pShowMsg->type == TSDB_MGMT_TABLE_METRIC) && pCmd->payloadLen != 0) {
if ((pShowMsg->type == TSDB_MGMT_TABLE_TABLE || pShowMsg->type == TSDB_MGMT_TABLE_METRIC || pShowMsg->type == TSDB_MGMT_TABLE_VNODES ) && pCmd->payloadLen != 0) {
// only show tables support wildcard query
pShowMsg->payloadLen = htons(pCmd->payloadLen);
memcpy(pShowMsg->payload, payload, pCmd->payloadLen);
......@@ -3453,31 +3453,6 @@ int tscProcessQueryRsp(SSqlObj *pSql) {
return 0;
}
static void doDecompressPayload(SSqlCmd *pCmd, SSqlRes *pRes, int16_t compressed) {
if (compressed && pRes->numOfRows > 0) {
SRetrieveMeterRsp *pRetrieve = (SRetrieveMeterRsp *)pRes->pRsp;
int32_t numOfTotalCols = pCmd->fieldsInfo.numOfOutputCols + pCmd->fieldsInfo.numOfHiddenCols;
int32_t rowSize = pCmd->fieldsInfo.pOffset[numOfTotalCols - 1] + pCmd->fieldsInfo.pFields[numOfTotalCols - 1].bytes;
// TODO handle the OOM problem
char * buf = malloc(rowSize * pRes->numOfRows);
int32_t payloadSize = pRes->rspLen - 1 - sizeof(SRetrieveMeterRsp);
assert(payloadSize > 0);
int32_t decompressedSize = tsDecompressString(pRetrieve->data, payloadSize, 1, buf, rowSize * pRes->numOfRows, 0, 0, 0);
assert(decompressedSize == rowSize * pRes->numOfRows);
pRes->pRsp = realloc(pRes->pRsp, pRes->rspLen - payloadSize + decompressedSize);
memcpy(pRes->pRsp + sizeof(SRetrieveMeterRsp), buf, decompressedSize);
free(buf);
}
pRes->data = ((SRetrieveMeterRsp *)pRes->pRsp)->data;
}
int tscProcessRetrieveRspFromVnode(SSqlObj *pSql) {
SSqlRes *pRes = &pSql->res;
SSqlCmd *pCmd = &pSql->cmd;
......@@ -3490,9 +3465,7 @@ int tscProcessRetrieveRspFromVnode(SSqlObj *pSql) {
pRes->offset = htobe64(pRetrieve->offset);
pRes->useconds = htobe64(pRetrieve->useconds);
pRetrieve->compress = htons(pRetrieve->compress);
doDecompressPayload(pCmd, pRes, pRetrieve->compress);
pRes->data = pRetrieve->data;
tscSetResultPointer(pCmd, pRes);
pRes->row = 0;
......@@ -3652,7 +3625,7 @@ int tscRenewMeterMeta(SSqlObj *pSql, char *meterId) {
*/
if (pMeterMetaInfo->pMeterMeta == NULL || !tscQueryOnMetric(pCmd)) {
if (pMeterMetaInfo->pMeterMeta) {
tscTrace("%p update meter meta, old: numOfTags:%d, numOfCols:%d, uid:%d, addr:%p", pSql,
tscTrace("%p update meter meta, old: numOfTags:%d, numOfCols:%d, uid:%lld, addr:%p", pSql,
pMeterMetaInfo->numOfTags, pCmd->numOfCols, pMeterMetaInfo->pMeterMeta->uid, pMeterMetaInfo->pMeterMeta);
}
tscWaitingForCreateTable(&pSql->cmd);
......
......@@ -246,7 +246,12 @@ int taos_query_imp(STscObj* pObj, SSqlObj* pSql) {
tscDoQuery(pSql);
}
if (pRes->code == TSDB_CODE_SUCCESS) {
tscTrace("%p SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(pObj), pObj);
} else {
tscError("%p SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(pObj), pObj);
}
if (pRes->code != TSDB_CODE_SUCCESS) {
tscFreeSqlObjPartial(pSql);
}
......@@ -266,8 +271,9 @@ int taos_query(TAOS *taos, const char *sqlstr) {
size_t sqlLen = strlen(sqlstr);
if (sqlLen > TSDB_MAX_SQL_LEN) {
tscError("%p sql too long", pSql);
pRes->code = TSDB_CODE_INVALID_SQL;
pRes->code = tscInvalidSQLErrMsg(pSql->cmd.payload, "sql too long", NULL); // set the additional error msg for invalid sql
tscError("%p SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(taos), pObj);
return pRes->code;
}
......@@ -276,8 +282,9 @@ int taos_query(TAOS *taos, const char *sqlstr) {
void *sql = realloc(pSql->sqlstr, sqlLen + 1);
if (sql == NULL) {
pRes->code = TSDB_CODE_CLI_OUT_OF_MEMORY;
tscError("%p failed to malloc sql string buffer", pSql);
tscTrace("%p SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(taos), pObj);
tscError("%p failed to malloc sql string buffer, reason:%s", pSql, strerror(errno));
tscError("%p SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(taos), pObj);
return pRes->code;
}
......@@ -777,9 +784,9 @@ int taos_errno(TAOS *taos) {
}
char *taos_errstr(TAOS *taos) {
STscObj * pObj = (STscObj *)taos;
unsigned char code;
char temp[256] = {0};
STscObj *pObj = (STscObj *)taos;
uint8_t code;
// char temp[256] = {0};
if (pObj == NULL || pObj->signature != pObj) return tsError[globalCode];
......@@ -788,9 +795,10 @@ char *taos_errstr(TAOS *taos) {
else
code = pObj->pSql->res.code;
// for invalid sql, additional information is attached to explain why the sql is invalid
if (code == TSDB_CODE_INVALID_SQL) {
snprintf(temp, tListLen(temp), "invalid SQL: %s", pObj->pSql->cmd.payload);
strcpy(pObj->pSql->cmd.payload, temp);
// snprintf(temp, tListLen(temp), "invalid SQL: %s", pObj->pSql->cmd.payload);
// strcpy(pObj->pSql->cmd.payload, temp);
return pObj->pSql->cmd.payload;
} else {
return tsError[code];
......
......@@ -1294,8 +1294,7 @@ int32_t tscValidateName(SSQLToken* pToken) {
// re-build the whole name string
if (pStr[firstPartLen] == TS_PATH_DELIMITER[0]) {
// first part do not have quote
// do nothing
// first part do not have quote do nothing
} else {
pStr[firstPartLen] = TS_PATH_DELIMITER[0];
memmove(&pStr[firstPartLen + 1], pToken->z, pToken->n);
......@@ -1842,5 +1841,30 @@ bool tscIsUpdateQuery(STscObj* pObj) {
SSqlCmd* pCmd = &pObj->pSql->cmd;
return ((pCmd->command >= TSDB_SQL_INSERT && pCmd->command <= TSDB_SQL_DROP_DNODE) ||
TSDB_SQL_USE_DB == pCmd->command) ? 1 : 0;
}
int32_t tscInvalidSQLErrMsg(char *msg, const char *additionalInfo, const char *sql) {
const char *msgFormat1 = "invalid SQL: %s";
const char *msgFormat2 = "invalid SQL: syntax error near \"%s\" (%s)";
const char *msgFormat3 = "invalid SQL: syntax error near \"%s\"";
const int32_t BACKWARD_CHAR_STEP = 0;
if (sql == NULL) {
assert(additionalInfo != NULL);
sprintf(msg, msgFormat1, additionalInfo);
return TSDB_CODE_INVALID_SQL;
}
char buf[64] = {0}; // only extract part of sql string
strncpy(buf, (sql - BACKWARD_CHAR_STEP), tListLen(buf) - 1);
if (additionalInfo != NULL) {
sprintf(msg, msgFormat2, buf, additionalInfo);
} else {
sprintf(msg, msgFormat3, buf); // no additional information for invalid sql error
}
return TSDB_CODE_INVALID_SQL;
}
......@@ -12,15 +12,25 @@
* 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/>.
*/
package taosSql
/*
#cgo CFLAGS : -I/usr/include
#include <stdlib.h>
#cgo LDFLAGS: -L/usr/lib -ltaos
void taosSetAllocMode(int mode, const char* path, _Bool autoDump);
void taosDumpMemoryLeak();
*/
import "C"
import (
"database/sql/driver"
"errors"
"fmt"
"sync/atomic"
"time"
"unsafe"
)
// Returns the bool value of the input.
......@@ -398,3 +408,15 @@ func namedValueToValue(named []driver.NamedValue) ([]driver.Value, error) {
}
/******************************************************************************
* Utils for C memory issues debugging *
******************************************************************************/
func SetAllocMode(mode int32, path string) {
cpath := C.CString(path)
defer C.free(unsafe.Pointer(cpath))
C.taosSetAllocMode(C.int(mode), cpath, false)
}
func DumpMemoryLeak() {
C.taosDumpMemoryLeak()
}
......@@ -73,6 +73,9 @@ cmd ::= SHOW CONFIGS. { setDCLSQLElems(pInfo, SHOW_CONFIGS, 0); }
cmd ::= SHOW SCORES. { setDCLSQLElems(pInfo, SHOW_SCORES, 0); }
cmd ::= SHOW GRANTS. { setDCLSQLElems(pInfo, SHOW_GRANTS, 0); }
cmd ::= SHOW VNODES. { setDCLSQLElems(pInfo, SHOW_VNODES, 0); }
cmd ::= SHOW VNODES IPTOKEN(X). { setDCLSQLElems(pInfo, SHOW_VNODES, 1, &X); }
%type dbPrefix {SSQLToken}
dbPrefix(A) ::=. {A.n = 0;}
dbPrefix(A) ::= ids(X) DOT. {A = X; }
......
......@@ -158,6 +158,7 @@ enum _mgmt_table {
TSDB_MGMT_TABLE_CONNS,
TSDB_MGMT_TABLE_SCORES,
TSDB_MGMT_TABLE_GRANTS,
TSDB_MGMT_TABLE_VNODES,
TSDB_MGMT_TABLE_MAX,
};
......@@ -224,7 +225,7 @@ typedef struct {
char meterId[TSDB_UNI_LEN];
uint16_t port; // for UDP only
char empty[1];
char msgType;
uint8_t msgType;
int32_t msgLen;
uint8_t content[0];
} STaosHeader;
......@@ -567,7 +568,6 @@ typedef struct {
typedef struct {
int32_t numOfRows;
int16_t precision;
int16_t compress;
int64_t offset; // updated offset value for multi-vnode projection query
int64_t useconds;
char data[];
......
......@@ -256,6 +256,8 @@ SGlobalConfig *tsGetConfigOption(const char *option);
#define TSDB_CFG_OPTION_LEN 24
#define TSDB_CFG_VALUE_LEN 41
#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
#ifdef __cplusplus
}
#endif
......
......@@ -20,7 +20,6 @@
extern "C" {
#endif
#include "unistd.h"
#include "os.h"
#include "tutil.h"
#include "tglobalcfg.h"
......
......@@ -72,145 +72,144 @@
#define TK_CONFIGS 54
#define TK_SCORES 55
#define TK_GRANTS 56
#define TK_DOT 57
#define TK_TABLES 58
#define TK_STABLES 59
#define TK_VGROUPS 60
#define TK_DROP 61
#define TK_TABLE 62
#define TK_DATABASE 63
#define TK_DNODE 64
#define TK_IPTOKEN 65
#define TK_USER 66
#define TK_ACCOUNT 67
#define TK_USE 68
#define TK_DESCRIBE 69
#define TK_ALTER 70
#define TK_PASS 71
#define TK_PRIVILEGE 72
#define TK_LOCAL 73
#define TK_IF 74
#define TK_EXISTS 75
#define TK_CREATE 76
#define TK_PPS 77
#define TK_TSERIES 78
#define TK_DBS 79
#define TK_STORAGE 80
#define TK_QTIME 81
#define TK_CONNS 82
#define TK_STATE 83
#define TK_KEEP 84
#define TK_CACHE 85
#define TK_REPLICA 86
#define TK_DAYS 87
#define TK_ROWS 88
#define TK_ABLOCKS 89
#define TK_TBLOCKS 90
#define TK_CTIME 91
#define TK_CLOG 92
#define TK_COMP 93
#define TK_PRECISION 94
#define TK_LP 95
#define TK_RP 96
#define TK_TAGS 97
#define TK_USING 98
#define TK_AS 99
#define TK_COMMA 100
#define TK_NULL 101
#define TK_SELECT 102
#define TK_FROM 103
#define TK_VARIABLE 104
#define TK_INTERVAL 105
#define TK_FILL 106
#define TK_SLIDING 107
#define TK_ORDER 108
#define TK_BY 109
#define TK_ASC 110
#define TK_DESC 111
#define TK_GROUP 112
#define TK_HAVING 113
#define TK_LIMIT 114
#define TK_OFFSET 115
#define TK_SLIMIT 116
#define TK_SOFFSET 117
#define TK_WHERE 118
#define TK_NOW 119
#define TK_INSERT 120
#define TK_INTO 121
#define TK_VALUES 122
#define TK_RESET 123
#define TK_QUERY 124
#define TK_ADD 125
#define TK_COLUMN 126
#define TK_TAG 127
#define TK_CHANGE 128
#define TK_SET 129
#define TK_KILL 130
#define TK_CONNECTION 131
#define TK_COLON 132
#define TK_STREAM 133
#define TK_ABORT 134
#define TK_AFTER 135
#define TK_ATTACH 136
#define TK_BEFORE 137
#define TK_BEGIN 138
#define TK_CASCADE 139
#define TK_CLUSTER 140
#define TK_CONFLICT 141
#define TK_COPY 142
#define TK_DEFERRED 143
#define TK_DELIMITERS 144
#define TK_DETACH 145
#define TK_EACH 146
#define TK_END 147
#define TK_EXPLAIN 148
#define TK_FAIL 149
#define TK_FOR 150
#define TK_IGNORE 151
#define TK_IMMEDIATE 152
#define TK_INITIALLY 153
#define TK_INSTEAD 154
#define TK_MATCH 155
#define TK_KEY 156
#define TK_OF 157
#define TK_RAISE 158
#define TK_REPLACE 159
#define TK_RESTRICT 160
#define TK_ROW 161
#define TK_STATEMENT 162
#define TK_TRIGGER 163
#define TK_VIEW 164
#define TK_ALL 165
#define TK_COUNT 166
#define TK_SUM 167
#define TK_AVG 168
#define TK_MIN 169
#define TK_MAX 170
#define TK_FIRST 171
#define TK_LAST 172
#define TK_TOP 173
#define TK_BOTTOM 174
#define TK_STDDEV 175
#define TK_PERCENTILE 176
#define TK_APERCENTILE 177
#define TK_LEASTSQUARES 178
#define TK_HISTOGRAM 179
#define TK_DIFF 180
#define TK_SPREAD 181
#define TK_TWA 182
#define TK_INTERP 183
#define TK_LAST_ROW 184
#define TK_SEMI 185
#define TK_NONE 186
#define TK_PREV 187
#define TK_LINEAR 188
#define TK_IMPORT 189
#define TK_METRIC 190
#define TK_TBNAME 191
#define TK_JOIN 192
#define TK_METRICS 193
#define TK_STABLE 194
#define TK_VNODES 57
#define TK_IPTOKEN 58
#define TK_DOT 59
#define TK_TABLES 60
#define TK_STABLES 61
#define TK_VGROUPS 62
#define TK_DROP 63
#define TK_TABLE 64
#define TK_DATABASE 65
#define TK_DNODE 66
#define TK_USER 67
#define TK_ACCOUNT 68
#define TK_USE 69
#define TK_DESCRIBE 70
#define TK_ALTER 71
#define TK_PASS 72
#define TK_PRIVILEGE 73
#define TK_LOCAL 74
#define TK_IF 75
#define TK_EXISTS 76
#define TK_CREATE 77
#define TK_PPS 78
#define TK_TSERIES 79
#define TK_DBS 80
#define TK_STORAGE 81
#define TK_QTIME 82
#define TK_CONNS 83
#define TK_STATE 84
#define TK_KEEP 85
#define TK_CACHE 86
#define TK_REPLICA 87
#define TK_DAYS 88
#define TK_ROWS 89
#define TK_ABLOCKS 90
#define TK_TBLOCKS 91
#define TK_CTIME 92
#define TK_CLOG 93
#define TK_COMP 94
#define TK_PRECISION 95
#define TK_LP 96
#define TK_RP 97
#define TK_TAGS 98
#define TK_USING 99
#define TK_AS 100
#define TK_COMMA 101
#define TK_NULL 102
#define TK_SELECT 103
#define TK_FROM 104
#define TK_VARIABLE 105
#define TK_INTERVAL 106
#define TK_FILL 107
#define TK_SLIDING 108
#define TK_ORDER 109
#define TK_BY 110
#define TK_ASC 111
#define TK_DESC 112
#define TK_GROUP 113
#define TK_HAVING 114
#define TK_LIMIT 115
#define TK_OFFSET 116
#define TK_SLIMIT 117
#define TK_SOFFSET 118
#define TK_WHERE 119
#define TK_NOW 120
#define TK_INSERT 121
#define TK_INTO 122
#define TK_VALUES 123
#define TK_RESET 124
#define TK_QUERY 125
#define TK_ADD 126
#define TK_COLUMN 127
#define TK_TAG 128
#define TK_CHANGE 129
#define TK_SET 130
#define TK_KILL 131
#define TK_CONNECTION 132
#define TK_COLON 133
#define TK_STREAM 134
#define TK_ABORT 135
#define TK_AFTER 136
#define TK_ATTACH 137
#define TK_BEFORE 138
#define TK_BEGIN 139
#define TK_CASCADE 140
#define TK_CLUSTER 141
#define TK_CONFLICT 142
#define TK_COPY 143
#define TK_DEFERRED 144
#define TK_DELIMITERS 145
#define TK_DETACH 146
#define TK_EACH 147
#define TK_END 148
#define TK_EXPLAIN 149
#define TK_FAIL 150
#define TK_FOR 151
#define TK_IGNORE 152
#define TK_IMMEDIATE 153
#define TK_INITIALLY 154
#define TK_INSTEAD 155
#define TK_MATCH 156
#define TK_KEY 157
#define TK_OF 158
#define TK_RAISE 159
#define TK_REPLACE 160
#define TK_RESTRICT 161
#define TK_ROW 162
#define TK_STATEMENT 163
#define TK_TRIGGER 164
#define TK_VIEW 165
#define TK_ALL 166
#define TK_COUNT 167
#define TK_SUM 168
#define TK_AVG 169
#define TK_MIN 170
#define TK_MAX 171
#define TK_FIRST 172
#define TK_LAST 173
#define TK_TOP 174
#define TK_BOTTOM 175
#define TK_STDDEV 176
#define TK_PERCENTILE 177
#define TK_APERCENTILE 178
#define TK_LEASTSQUARES 179
#define TK_HISTOGRAM 180
#define TK_DIFF 181
#define TK_SPREAD 182
#define TK_TWA 183
#define TK_INTERP 184
#define TK_LAST_ROW 185
#define TK_SEMI 186
#define TK_NONE 187
#define TK_PREV 188
#define TK_LINEAR 189
#define TK_IMPORT 190
#define TK_METRIC 191
#define TK_TBNAME 192
#define TK_JOIN 193
#define TK_METRICS 194
#define TK_STABLE 195
#endif
......@@ -187,18 +187,35 @@ static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, unsigned int inLen, cha
char *taosIpStr(uint32_t ipInt);
#ifdef _TAOS_MEM_TEST_
// Use during test to simulate the success and failure scenarios of memory allocation
extern void* taos_malloc(unsigned int size, char* _func);
extern void* taos_calloc(unsigned int num, unsigned int size, char* _func);
extern void* taos_realloc(void* ptr, unsigned int size, char* _func);
extern void taos_free(void* ptr);
#define malloc(size) taos_malloc(size, __FUNCTION__)
#define calloc(num, size) taos_calloc(num, size, __FUNCTION__)
#define realloc(ptr, size) taos_realloc(ptr, size, __FUNCTION__)
#define free(ptr) taos_free(ptr)
#endif
#define TAOS_ALLOC_MODE_DEFAULT 0
#define TAOS_ALLOC_MODE_RANDOM_FAIL 1
#define TAOS_ALLOC_MODE_DETECT_LEAK 2
void taosSetAllocMode(int mode, const char* path, bool autoDump);
void taosDumpMemoryLeak();
#ifdef TAOS_MEM_CHECK
void * taos_malloc(size_t size, const char *file, uint32_t line);
void * taos_calloc(size_t num, size_t size, const char *file, uint32_t line);
void * taos_realloc(void *ptr, size_t size, const char *file, uint32_t line);
void taos_free(void *ptr, const char *file, uint32_t line);
char * taos_strdup(const char *str, const char *file, uint32_t line);
char * taos_strndup(const char *str, size_t size, const char *file, uint32_t line);
ssize_t taos_getline(char **lineptr, size_t *n, FILE *stream, const char *file, uint32_t line);
#ifndef TAOS_MEM_CHECK_IMPL
#define malloc(size) taos_malloc(size, __FILE__, __LINE__)
#define calloc(num, size) taos_calloc(num, size, __FILE__, __LINE__)
#define realloc(ptr, size) taos_realloc(ptr, size, __FILE__, __LINE__)
#define free(ptr) taos_free(ptr, __FILE__, __LINE__)
#define strdup(str) taos_strdup(str, __FILE__, __LINE__)
#define strndup(str, size) taos_strndup(str, size, __FILE__, __LINE__)
#define getline(lineptr, n, stream) taos_getline(lineptr, n, stream, __FILE__, __LINE__)
#endif // TAOS_MEM_CHECK_IMPL
#endif // TAOS_MEM_CHECK
#ifdef __cplusplus
}
......
......@@ -21,6 +21,7 @@
#include "shellCommand.h"
#include "ttime.h"
#include "tutil.h"
#include <regex.h>
/**************** Global variables ****************/
#ifdef WINDOWS
......
......@@ -81,6 +81,7 @@ bool taosGetProcMemory(float *memoryUsedMB) {
char * line = NULL;
while (!feof(fp)) {
tfree(line);
len = 0;
getline(&line, &len, fp);
if (line == NULL) {
break;
......@@ -137,7 +138,7 @@ bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
return false;
}
size_t len;
size_t len = 0;
char * line = NULL;
getline(&line, &len, fp);
if (line == NULL) {
......@@ -409,6 +410,7 @@ bool taosGetCardInfo(int64_t *bytes) {
while (!feof(fp)) {
tfree(line);
len = 0;
getline(&line, &len, fp);
if (line == NULL) {
break;
......@@ -480,6 +482,7 @@ bool taosReadProcIO(int64_t *readbyte, int64_t *writebyte) {
while (!feof(fp)) {
tfree(line);
len = 0;
getline(&line, &len, fp);
if (line == NULL) {
break;
......
......@@ -16,20 +16,30 @@
#ifndef TDENGINE_PLATFORM_WINDOWS_H
#define TDENGINE_PLATFORM_WINDOWS_H
#include <assert.h>
#include <ctype.h>
#include <direct.h>
#include <errno.h>
#include <fcntl.h>
#include <float.h>
#include <locale.h>
#include <intrin.h>
#include <io.h>
#include <math.h>
#include <pthread.h>
#include <semaphore.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <stdint.h>
#include <stdbool.h>
#include <pthread.h>
#include <direct.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include "winsock2.h"
#include <WS2tcpip.h>
#include <assert.h>
#include <math.h>
#include <string.h>
#include <assert.h>
#include <intrin.h>
#ifdef __cplusplus
extern "C" {
......@@ -366,6 +376,8 @@ int fsendfile(FILE* out_file, FILE* in_file, int64_t* offset, int32_t count);
char *strndup(const char *s, size_t n);
void taosSetCoreDump();
#ifdef __cplusplus
}
#endif
......
......@@ -395,3 +395,5 @@ char *strndup(const char *s, size_t n) {
r[len] = 0;
return r;
}
void taosSetCoreDump() {}
\ No newline at end of file
......@@ -14,7 +14,6 @@
*/
#include "os.h"
#include "shash.h"
#include "taosmsg.h"
#include "tidpool.h"
......@@ -30,6 +29,7 @@
#include "ttimer.h"
#include "tudp.h"
#include "tutil.h"
#include "lz4.h"
#pragma GCC diagnostic ignored "-Wpointer-to-int-cast"
......@@ -50,7 +50,6 @@ typedef struct {
char encrypt;
uint8_t secret[TSDB_KEY_LEN];
uint8_t ckey[TSDB_KEY_LEN];
uint16_t localPort; // for UDP only
uint32_t peerUid;
uint32_t peerIp; // peer IP
......@@ -107,7 +106,6 @@ typedef struct rpc_server {
SRpcChann *channList;
} STaosRpc;
int tsRpcProgressTime = 10; // milliseocnds
// not configurable
......@@ -141,6 +139,89 @@ void taosProcessSchedMsg(SSchedMsg *pMsg);
int taosAuthenticateMsg(uint8_t *pMsg, int msgLen, uint8_t *pAuth, uint8_t *pKey);
int taosBuildAuthHeader(uint8_t *pMsg, int msgLen, uint8_t *pAuth, uint8_t *pKey);
static int32_t taosCompressRpcMsg(char* pCont, int32_t contLen) {
STaosHeader* pHeader = (STaosHeader *)(pCont - sizeof(STaosHeader));
int32_t overhead = sizeof(int32_t) * 2;
int32_t finalLen = 0;
if (!NEEDTO_COMPRESSS_MSG(contLen)) {
return contLen;
}
char *buf = malloc (contLen + overhead + 8); // 16 extra bytes
if (buf == NULL) {
tError("failed to allocate memory for rpc msg compression, contLen:%d, reason:%s", contLen, strerror(errno));
return contLen;
}
int32_t compLen = LZ4_compress_default(pCont, buf, contLen, contLen + overhead);
/*
* only the compressed size is less than the value of contLen - overhead, the compression is applied
* The first four bytes is set to 0, the second four bytes are utilized to keep the original length of message
*/
if (compLen < contLen - overhead) {
//tDump(pCont, contLen);
int32_t *pLen = (int32_t *)pCont;
*pLen = 0; // first 4 bytes must be zero
pLen = (int32_t *)(pCont + sizeof(int32_t));
*pLen = htonl(contLen); // contLen is encoded in second 4 bytes
memcpy(pCont + overhead, buf, compLen);
pHeader->comp = 1;
tTrace("compress rpc msg, before:%lld, after:%lld", contLen, compLen);
finalLen = compLen + overhead;
//tDump(pCont, contLen);
} else {
finalLen = contLen;
}
free(buf);
return finalLen;
}
static STaosHeader* taosDecompressRpcMsg(STaosHeader* pHeader, SSchedMsg* pSchedMsg, int32_t msgLen) {
int overhead = sizeof(int32_t) * 2;
if (pHeader->comp == 0) {
pSchedMsg->msg = (char *)(&(pHeader->destId));
return pHeader;
}
// decompress the content
assert(GET_INT32_VAL(pHeader->content) == 0);
// contLen is original message length before compression applied
int contLen = htonl(GET_INT32_VAL(pHeader->content + sizeof(int32_t)));
// prepare the temporary buffer to decompress message
char *buf = malloc(sizeof(STaosHeader) + contLen);
//tDump(pHeader->content, msgLen);
if (buf) {
int32_t originalLen = LZ4_decompress_safe(pHeader->content + overhead, buf + sizeof(STaosHeader),
msgLen - overhead, contLen);
memcpy(buf, pHeader, sizeof(STaosHeader));
free(pHeader); // free the compressed message buffer
STaosHeader* pNewHeader = (STaosHeader *) buf;
pNewHeader->msgLen = originalLen + (int) sizeof(SIntMsg);
assert(originalLen == contLen);
pSchedMsg->msg = (char *)(&(pNewHeader->destId));
//tDump(pHeader->content, contLen);
return pNewHeader;
} else {
tError("failed to allocate memory to decompress msg, contLen:%d, reason:%s", contLen, strerror(errno));
pSchedMsg->msg = NULL;
}
}
char *taosBuildReqHeader(void *param, char type, char *msg) {
STaosHeader *pHeader;
SRpcConn * pConn = (SRpcConn *)param;
......@@ -151,7 +232,9 @@ char *taosBuildReqHeader(void *param, char type, char *msg) {
}
pHeader = (STaosHeader *)(msg + sizeof(SMsgNode));
memset(pHeader, 0, sizeof(STaosHeader));
pHeader->version = 1;
pHeader->comp = 0;
pHeader->msgType = type;
pHeader->spi = 0;
pHeader->tcp = 0;
......@@ -1074,8 +1157,9 @@ void *taosProcessDataFromPeer(char *data, int dataLen, uint32_t ip, uint16_t por
if (code != 0) {
// parsing error
if (pHeader->msgType & 1) {
if (pHeader->msgType & 1U) {
memset(pReply, 0, sizeof(pReply));
msgLen = taosBuildErrorMsgToPeer(data, code, pReply);
(*taosSendData[pServer->type])(ip, port, pReply, msgLen, chandle);
tTrace("%s cid:%d sid:%d id:%s, %s is sent with error code:%u pConn:%p", pServer->label, chann, sid,
......@@ -1090,17 +1174,17 @@ void *taosProcessDataFromPeer(char *data, int dataLen, uint32_t ip, uint16_t por
// parsing OK
// internal communication is based on TAOS protocol, a trick here to make it efficient
pHeader->msgLen = msgLen - (int)sizeof(STaosHeader) + (int)sizeof(SIntMsg);
if (pHeader->spi) pHeader->msgLen -= sizeof(STaosDigest);
if (pHeader->spi) msgLen -= sizeof(STaosDigest);
msgLen -= (int)sizeof(STaosHeader);
pHeader->msgLen = msgLen + (int)sizeof(SIntMsg);
if ((pHeader->msgType & 1) == 0 && (pHeader->content[0] == TSDB_CODE_INVALID_VALUE)) {
if ((pHeader->msgType & 1U) == 0 && (pHeader->content[0] == TSDB_CODE_INVALID_VALUE)) {
schedMsg.msg = NULL; // connection shall be closed
} else {
schedMsg.msg = (char *)(&(pHeader->destId));
// memcpy(schedMsg.msg, (char *)(&(pHeader->destId)), pHeader->msgLen);
pHeader = taosDecompressRpcMsg(pHeader, &schedMsg, msgLen);
}
if (pHeader->msgType < TSDB_MSG_TYPE_HEARTBEAT || (rpcDebugFlag & 16)) {
if (pHeader->msgType < TSDB_MSG_TYPE_HEARTBEAT || (rpcDebugFlag & 16U)) {
tTrace("%s cid:%d sid:%d id:%s, %s is put into queue, msgLen:%d pConn:%p pTimer:%p", pServer->label, chann, sid,
pHeader->meterId, taosMsg[pHeader->msgType], pHeader->msgLen, pConn, pConn->pTimer);
}
......@@ -1132,9 +1216,12 @@ int taosSendMsgToPeerH(void *thandle, char *pCont, int contLen, void *ahandle) {
pChann = pServer->channList + pConn->chann;
pHeader = (STaosHeader *)(pCont - sizeof(STaosHeader));
msg = (char *)pHeader;
msgLen = contLen + (int32_t)sizeof(STaosHeader);
if ((pHeader->msgType & 1) == 0 && pConn->localPort) pHeader->port = pConn->localPort;
if ((pHeader->msgType & 1U) == 0 && pConn->localPort) pHeader->port = pConn->localPort;
contLen = taosCompressRpcMsg(pCont, contLen);
msgLen = contLen + (int32_t)sizeof(STaosHeader);
if (pConn->spi) {
// add auth part
......@@ -1151,7 +1238,7 @@ int taosSendMsgToPeerH(void *thandle, char *pCont, int contLen, void *ahandle) {
pthread_mutex_lock(&pChann->mutex);
msgType = pHeader->msgType;
if ((msgType & 1) == 0) {
if ((msgType & 1U) == 0) {
// response
pConn->inType = 0;
tfree(pConn->pRspMsg);
......
......@@ -346,10 +346,41 @@ int64_t sdbInsertRow(void *handle, void *row, int rowSize) {
int real_size = 0;
/* char action = SDB_TYPE_INSERT; */
if (pTable == NULL) return -1;
if (pTable == NULL) {
sdbError("sdb tables is null");
return -1;
}
if ((pTable->keyType != SDB_KEYTYPE_AUTO) || *((int64_t *)row))
if (sdbGetRow(handle, row)) return -1;
if (sdbGetRow(handle, row)) {
if (strcmp(pTable->name, "mnode") == 0) {
/*
* The first mnode created when the system just start, so the insert action may failed
* see sdbPeer.c : sdbInitPeers
*/
pTable->id++;
sdbVersion++;
sdbPrint("table:%s, record:%s already exist, think it successed, sdbVersion:%ld id:%d",
pTable->name, taosIpStr(*(int32_t *)row), sdbVersion, pTable->id);
return 0;
} else {
switch (pTable->keyType) {
case SDB_KEYTYPE_STRING:
sdbError("table:%s, failed to insert record:%s sdbVersion:%ld id:%d", pTable->name, (char *)row, sdbVersion, pTable->id);
break;
case SDB_KEYTYPE_UINT32: //dnodes or mnodes
sdbError("table:%s, failed to insert record:%s sdbVersion:%ld id:%d", pTable->name, taosIpStr(*(int32_t *)row), sdbVersion, pTable->id);
break;
case SDB_KEYTYPE_AUTO:
sdbError("table:%s, failed to insert record:%s sdbVersion:%ld id:%d", pTable->name, *(int32_t *)row, sdbVersion, pTable->id);
break;
default:
sdbError("table:%s, failed to insert record:%s sdbVersion:%ld id:%d", pTable->name, sdbVersion, pTable->id);
break;
}
return -1;
}
}
total_size = sizeof(SRowHead) + pTable->maxRowSize + sizeof(TSCKSUM);
SRowHead *rowHead = (SRowHead *)malloc(total_size);
......@@ -408,24 +439,26 @@ int64_t sdbInsertRow(void *handle, void *row, int rowSize) {
pTable->numOfRows++;
switch (pTable->keyType) {
case SDB_KEYTYPE_STRING:
sdbTrace(
"table:%s, a record is inserted:%s, sdbVersion:%ld id:%ld rowSize:%d numOfRows:%d fileSize:%ld",
sdbTrace("table:%s, a record is inserted:%s, sdbVersion:%ld id:%ld rowSize:%d numOfRows:%d fileSize:%ld",
pTable->name, (char *)row, sdbVersion, rowHead->id, rowHead->rowSize, pTable->numOfRows, pTable->size);
break;
case SDB_KEYTYPE_UINT32:
case SDB_KEYTYPE_UINT32: //dnodes or mnodes
sdbTrace("table:%s, a record is inserted:%s, sdbVersion:%ld id:%ld rowSize:%d numOfRows:%d fileSize:%ld",
pTable->name, taosIpStr(*(int32_t *)row), sdbVersion, rowHead->id, rowHead->rowSize, pTable->numOfRows, pTable->size);
break;
case SDB_KEYTYPE_AUTO:
sdbTrace(
"table:%s, a record is inserted:%d, sdbVersion:%ld id:%ld rowSize:%d numOfRows:%d fileSize:%ld",
sdbTrace("table:%s, a record is inserted:%d, sdbVersion:%ld id:%ld rowSize:%d numOfRows:%d fileSize:%ld",
pTable->name, *(int32_t *)row, sdbVersion, rowHead->id, rowHead->rowSize, pTable->numOfRows, pTable->size);
break;
default:
sdbTrace(
"table:%s, a record is inserted, sdbVersion:%ld id:%ld rowSize:%d numOfRows:%d fileSize:%ld",
sdbTrace("table:%s, a record is inserted, sdbVersion:%ld id:%ld rowSize:%d numOfRows:%d fileSize:%ld",
pTable->name, sdbVersion, rowHead->id, rowHead->rowSize, pTable->numOfRows, pTable->size);
break;
}
id = rowMeta.id;
} else {
sdbError("table:%s, failed to insert record", pTable->name);
}
tfree(rowHead);
......@@ -509,14 +542,15 @@ int sdbDeleteRow(void *handle, void *row) {
sdbAddIntoUpdateList(pTable, SDB_TYPE_DELETE, pMetaRow);
switch (pTable->keyType) {
case SDB_KEYTYPE_STRING:
sdbTrace(
"table:%s, a record is deleted:%s, sdbVersion:%ld id:%ld numOfRows:%d",
sdbTrace("table:%s, a record is deleted:%s, sdbVersion:%ld id:%ld numOfRows:%d",
pTable->name, (char *)row, sdbVersion, pTable->id, pTable->numOfRows);
break;
case SDB_KEYTYPE_UINT32:
case SDB_KEYTYPE_UINT32: //dnodes or mnodes
sdbTrace("table:%s, a record is deleted:%s, sdbVersion:%ld id:%ld numOfRows:%d",
pTable->name, taosIpStr(*(int32_t *)row), sdbVersion, pTable->id, pTable->numOfRows);
break;
case SDB_KEYTYPE_AUTO:
sdbTrace(
"table:%s, a record is deleted:%d, sdbVersion:%ld id:%ld numOfRows:%d",
sdbTrace("table:%s, a record is deleted:%d, sdbVersion:%ld id:%ld numOfRows:%d",
pTable->name, *(int32_t *)row, sdbVersion, pTable->id, pTable->numOfRows);
break;
default:
......@@ -553,7 +587,24 @@ int sdbUpdateRow(void *handle, void *row, int updateSize, char isUpdated) {
if (pTable == NULL || row == NULL) return -1;
pMeta = sdbGetRowMeta(handle, row);
if (pMeta == NULL) {
sdbTrace("table:%s, record is not there, update failed", pTable->name);
switch (pTable->keyType) {
case SDB_KEYTYPE_STRING:
sdbError("table:%s, failed to update record:%s, record is not there, sdbVersion:%ld id:%d",
pTable->name, (char *) row, sdbVersion, pTable->id);
break;
case SDB_KEYTYPE_UINT32: //dnodes or mnodes
sdbError("table:%s, failed to update record:%s record is not there, sdbVersion:%ld id:%d",
pTable->name, taosIpStr(*(int32_t *) row), sdbVersion, pTable->id);
break;
case SDB_KEYTYPE_AUTO:
sdbError("table:%s, failed to update record:F%s record is not there, sdbVersion:%ld id:%d",
pTable->name, *(int32_t *) row, sdbVersion, pTable->id);
break;
default:
sdbError("table:%s, failed to update record:%s record is not there, sdbVersion:%ld id:%d",
pTable->name, sdbVersion, pTable->id);
break;
}
return -1;
}
......@@ -610,14 +661,15 @@ int sdbUpdateRow(void *handle, void *row, int updateSize, char isUpdated) {
switch (pTable->keyType) {
case SDB_KEYTYPE_STRING:
sdbTrace(
"table:%s, a record is updated:%s, sdbVersion:%ld id:%ld numOfRows:%d",
sdbTrace("table:%s, a record is updated:%s, sdbVersion:%ld id:%ld numOfRows:%d",
pTable->name, (char *)row, sdbVersion, pTable->id, pTable->numOfRows);
break;
case SDB_KEYTYPE_UINT32:
case SDB_KEYTYPE_UINT32: //dnodes or mnodes
sdbTrace("table:%s, a record is updated:%s, sdbVersion:%ld id:%ld numOfRows:%d",
pTable->name, taosIpStr(*(int32_t *)row), sdbVersion, pTable->id, pTable->numOfRows);
break;
case SDB_KEYTYPE_AUTO:
sdbTrace(
"table:%s, a record is updated:%d, sdbVersion:%ld id:%ld numOfRows:%d",
sdbTrace("table:%s, a record is updated:%d, sdbVersion:%ld id:%ld numOfRows:%d",
pTable->name, *(int32_t *)row, sdbVersion, pTable->id, pTable->numOfRows);
break;
default:
......
......@@ -410,6 +410,9 @@ int mgmtRetrieveScores(SShowObj *pShow, char *data, int rows, SConnObj *pConn);
int grantGetGrantsMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
int grantRetrieveGrants(SShowObj *pShow, char *data, int rows, SConnObj *pConn);
int mgmtGetVnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
int mgmtRetrieveVnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn);
// dnode balance api
int mgmtInitBalance();
void mgmtCleanupBalance();
......
......@@ -353,7 +353,7 @@ bool vnodeIsValidVnodeCfg(SVnodeCfg *pCfg);
int32_t vnodeGetResultSize(void *handle, int32_t *numOfRows);
int32_t vnodeCopyQueryResultToMsg(void *handle, char *data, int32_t numOfRows, int32_t *size);
int32_t vnodeCopyQueryResultToMsg(void *handle, char *data, int32_t numOfRows);
int64_t vnodeGetOffsetVal(void *thandle);
......
......@@ -61,6 +61,20 @@ int main(int argc, char *argv[]) {
return 0;
} else if (strcmp(argv[i], "-k") == 0) {
dnodeParseParameterK();
#ifdef TAOS_MEM_CHECK
} else if (strcmp(argv[i], "--alloc-random-fail") == 0) {
if ((i < argc - 1) && (argv[i+1][0] != '-')) {
taosSetAllocMode(TAOS_ALLOC_MODE_RANDOM_FAIL, argv[++i], true);
} else {
taosSetAllocMode(TAOS_ALLOC_MODE_RANDOM_FAIL, NULL, true);
}
} else if (strcmp(argv[i], "--detect-mem-leak") == 0) {
if ((i < argc - 1) && (argv[i+1][0] != '-')) {
taosSetAllocMode(TAOS_ALLOC_MODE_DETECT_LEAK, argv[++i], true);
} else {
taosSetAllocMode(TAOS_ALLOC_MODE_DETECT_LEAK, NULL, true);
}
#endif
}
}
......
......@@ -389,3 +389,121 @@ int mgmtRetrieveConfigs(SShowObj *pShow, char *data, int rows, SConnObj *pConn)
pShow->numOfReads += numOfRows;
return numOfRows;
}
int mgmtGetVnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
int cols = 0;
if (strcmp(pConn->pAcct->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
SSchema *pSchema = tsGetSchema(pMeta);
pShow->bytes[cols] = 4;
pSchema[cols].type = TSDB_DATA_TYPE_INT;
strcpy(pSchema[cols].name, "vnode");
pSchema[cols].bytes = htons(pShow->bytes[cols]);
cols++;
pShow->bytes[cols] = 4;
pSchema[cols].type = TSDB_DATA_TYPE_INT;
strcpy(pSchema[cols].name, "vgid");
pSchema[cols].bytes = htons(pShow->bytes[cols]);
cols++;
pShow->bytes[cols] = 12;
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
strcpy(pSchema[cols].name, "status");
pSchema[cols].bytes = htons(pShow->bytes[cols]);
cols++;
pShow->bytes[cols] = 12;
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
strcpy(pSchema[cols].name, "sync status");
pSchema[cols].bytes = htons(pShow->bytes[cols]);
cols++;
pMeta->numOfColumns = htons(cols);
pShow->numOfColumns = cols;
pShow->offset[0] = 0;
for (int i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
// TODO: if other thread drop dnode ????
SDnodeObj *pDnode = NULL;
if (pShow->payloadLen > 0 ) {
uint32_t ip = ip2uint(pShow->payload);
pDnode = mgmtGetDnode(ip);
if (NULL == pDnode) {
return TSDB_CODE_NODE_OFFLINE;
}
pShow->numOfRows = pDnode->openVnodes;
pShow->pNode = pDnode;
} else {
while (true) {
pShow->pNode = mgmtGetNextDnode(pShow, (SDnodeObj **)&pDnode);
if (pDnode == NULL) break;
pShow->numOfRows += pDnode->openVnodes;
if (0 == pShow->numOfRows) return TSDB_CODE_NODE_OFFLINE;
}
pShow->pNode = NULL;
}
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
return 0;
}
int mgmtRetrieveVnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
int numOfRows = 0;
SDnodeObj *pDnode = NULL;
char * pWrite;
int cols = 0;
char ipstr[20];
if (0 == rows) return 0;
if (pShow->payloadLen) {
// output the vnodes info of the designated dnode. And output all vnodes of this dnode, instead of rows (max 100)
pDnode = (SDnodeObj *)(pShow->pNode);
if (pDnode != NULL) {
SVnodeLoad* pVnode;
for (int i = 0 ; i < TSDB_MAX_VNODES; i++) {
pVnode = &pDnode->vload[i];
if (0 == pVnode->vgId) {
continue;
}
cols = 0;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
*(uint32_t *)pWrite = pVnode->vnode;
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
*(uint32_t *)pWrite = pVnode->vgId;
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
strcpy(pWrite, taosGetVnodeStatusStr(pVnode->status));
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
strcpy(pWrite, taosGetVnodeSyncStatusStr(pVnode->syncStatus));
cols++;
numOfRows++;
}
}
} else {
// TODO: output all vnodes of all dnodes
numOfRows = 0;
}
pShow->numOfReads += numOfRows;
return numOfRows;
}
......@@ -519,10 +519,8 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
pMeter = mgmtGetMeter(pCreate->meterId);
if (pMeter) {
if (pCreate->igExists) {
mError("table:%s, igExists is true", pCreate->meterId);
return TSDB_CODE_SUCCESS;
} else {
mError("table:%s, table is already exist", pCreate->meterId);
return TSDB_CODE_TABLE_ALREADY_EXIST;
}
}
......@@ -675,7 +673,7 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
// send create message to the selected vnode servers
if (pCreate->numOfTags == 0) {
mTrace("table:%s, send create msg to dnode, vgId:%d, sid:%d, vnode:%d",
mTrace("table:%s, send create table msg to dnode, vgId:%d, sid:%d, vnode:%d",
pMeter->meterId, pMeter->gid.vgId, pMeter->gid.sid, pVgroup->vnodeGid[0].vnode);
grantAddTimeSeries(pMeter->numOfColumns - 1);
......
......@@ -788,12 +788,14 @@ int (*mgmtGetMetaFp[])(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) = {
mgmtGetAcctMeta, mgmtGetUserMeta, mgmtGetDbMeta, mgmtGetMeterMeta, mgmtGetDnodeMeta,
mgmtGetMnodeMeta, mgmtGetVgroupMeta, mgmtGetMetricMeta, mgmtGetModuleMeta, mgmtGetQueryMeta,
mgmtGetStreamMeta, mgmtGetConfigMeta, mgmtGetConnsMeta, mgmtGetScoresMeta, grantGetGrantsMeta,
mgmtGetVnodeMeta,
};
int (*mgmtRetrieveFp[])(SShowObj *pShow, char *data, int rows, SConnObj *pConn) = {
mgmtRetrieveAccts, mgmtRetrieveUsers, mgmtRetrieveDbs, mgmtRetrieveMeters, mgmtRetrieveDnodes,
mgmtRetrieveMnodes, mgmtRetrieveVgroups, mgmtRetrieveMetrics, mgmtRetrieveModules, mgmtRetrieveQueries,
mgmtRetrieveStreams, mgmtRetrieveConfigs, mgmtRetrieveConns, mgmtRetrieveScores, grantRetrieveGrants,
mgmtRetrieveVnodes,
};
int mgmtProcessShowMsg(char *pMsg, int msgLen, SConnObj *pConn) {
......
......@@ -114,6 +114,7 @@ int vnodeCreateHeadDataFile(int vnode, int fileId, char *headName, char *dataNam
char *path = vnodeGetDataDir(vnode, fileId);
if (path == NULL) {
dError("vid:%d, fileId:%d, failed to get dataDir", vnode, fileId);
return -1;
}
......
......@@ -2952,11 +2952,11 @@ static int32_t vnodeOpenVnodeDBFiles(SQInfo *pQInfo, SQueryFileInfo *pVnodeFiles
pVnodeFiles->dataFd = open(pVnodeFiles->dataFilePath, O_RDONLY);
pVnodeFiles->lastFd = open(pVnodeFiles->lastFilePath, O_RDONLY);
if (stat(pVnodeFiles->dataFilePath, &fstat) < 0) return -1;
pVnodeFiles->dataFileSize = fstat.st_size;
if (stat(pVnodeFiles->lastFilePath, &fstat) < 0) return -1;
pVnodeFiles->lastFileSize = fstat.st_size;
// if (stat(pVnodeFiles->dataFilePath, &fstat) < 0) return -1;
// pVnodeFiles->dataFileSize = fstat.st_size;
//
// if (stat(pVnodeFiles->lastFilePath, &fstat) < 0) return -1;
// pVnodeFiles->lastFileSize = fstat.st_size;
#if DEFAULT_IO_ENGINE == IO_ENGINE_MMAP
/* enforce kernel to preload data when the file is mapping */
......@@ -6943,37 +6943,19 @@ static int32_t resultInterpolate(SQInfo *pQInfo, tFilePage **data, tFilePage **p
return numOfRes;
}
static void doCopyQueryResultToMsg(SQInfo *pQInfo, int32_t numOfRows, char *data, int32_t *size) {
static void doCopyQueryResultToMsg(SQInfo *pQInfo, int32_t numOfRows, char *data) {
SMeterObj *pObj = pQInfo->pObj;
SQuery * pQuery = &pQInfo->query;
int tnumOfRows = vnodeList[pObj->vnode].cfg.rowsInFileBlock;
int32_t dataSize = pQInfo->query.rowSize * numOfRows;
if (dataSize >= tsCompressMsgSize && tsCompressMsgSize > 0) {
char *compBuf = malloc((size_t)dataSize);
// for metric query, bufIndex always be 0.
char *d = compBuf;
for (int32_t col = 0; col < pQuery->numOfOutputCols; ++col) { // pQInfo->bufIndex == 0
int32_t bytes = pQuery->pSelectExpr[col].resBytes;
memmove(d, pQuery->sdata[col]->data + bytes * tnumOfRows * pQInfo->bufIndex, bytes * numOfRows);
d += bytes * numOfRows;
}
*size = tsCompressString(compBuf, dataSize, 1, data, dataSize + EXTRA_BYTES, 0, 0, 0);
dTrace("QInfo:%p compress rsp msg, before:%d, after:%d", pQInfo, dataSize, *size);
free(compBuf);
} else { // for metric query, bufIndex always be 0.
for (int32_t col = 0; col < pQuery->numOfOutputCols; ++col) { // pQInfo->bufIndex == 0
int32_t bytes = pQuery->pSelectExpr[col].resBytes;
memmove(data, pQuery->sdata[col]->data + bytes * tnumOfRows * pQInfo->bufIndex, bytes * numOfRows);
data += bytes * numOfRows;
}
}
}
/**
......@@ -6987,7 +6969,7 @@ static void doCopyQueryResultToMsg(SQInfo *pQInfo, int32_t numOfRows, char *data
* @param numOfRows the number of rows that are not returned in current retrieve
* @return
*/
int32_t vnodeCopyQueryResultToMsg(void *handle, char *data, int32_t numOfRows, int32_t *size) {
int32_t vnodeCopyQueryResultToMsg(void *handle, char *data, int32_t numOfRows) {
SQInfo *pQInfo = (SQInfo *)handle;
SQuery *pQuery = &pQInfo->query;
......@@ -7000,7 +6982,7 @@ int32_t vnodeCopyQueryResultToMsg(void *handle, char *data, int32_t numOfRows, i
// make sure file exist
if (VALIDFD(fd)) {
size_t s = lseek(fd, 0, SEEK_END);
dTrace("QInfo:%p ts comp data return, file:%s, size:%ld", pQInfo, pQuery->sdata[0]->data, size);
dTrace("QInfo:%p ts comp data return, file:%s, size:%lld", pQInfo, pQuery->sdata[0]->data, s);
lseek(fd, 0, SEEK_SET);
read(fd, data, s);
......@@ -7012,7 +6994,7 @@ int32_t vnodeCopyQueryResultToMsg(void *handle, char *data, int32_t numOfRows, i
pQuery->sdata[0]->data, strerror(errno));
}
} else {
doCopyQueryResultToMsg(pQInfo, numOfRows, data, size);
doCopyQueryResultToMsg(pQInfo, numOfRows, data);
}
return numOfRows;
......
......@@ -483,13 +483,9 @@ void vnodeFreeQInfo(void *param, bool decQueryRef) {
}
tfree(pQuery->pGroupbyExpr);
dTrace("QInfo:%p vid:%d sid:%d meterId:%s, QInfo is freed", pQInfo, pObj->vnode, pObj->sid, pObj->meterId);
/*
* destory signature, in order to avoid the query process pass the object
* safety check
*/
//destroy signature, in order to avoid the query process pass the object safety check
memset(pQInfo, 0, sizeof(SQInfo));
tfree(pQInfo);
}
......@@ -854,7 +850,7 @@ int vnodeSaveQueryResult(void *handle, char *data, int32_t *size) {
// the remained number of retrieved rows, not the interpolated result
int numOfRows = pQInfo->pointsRead - pQInfo->pointsReturned;
int32_t numOfFinal = vnodeCopyQueryResultToMsg(pQInfo, data, numOfRows, size);
int32_t numOfFinal = vnodeCopyQueryResultToMsg(pQInfo, data, numOfRows);
pQInfo->pointsReturned += numOfFinal;
dTrace("QInfo:%p %d are returned, totalReturned:%d totalRead:%d", pQInfo, numOfFinal, pQInfo->pointsReturned,
......@@ -866,12 +862,9 @@ int vnodeSaveQueryResult(void *handle, char *data, int32_t *size) {
uint64_t oldSignature = TSDB_QINFO_SET_QUERY_FLAG(pQInfo);
/*
* If SQInfo has been released, the value of signature cannot be equalled to
* the address of pQInfo, since in release function, the original value has
* been
* destroyed. However, this memory area may be reused by another function.
* It may be 0 or any value, but it is rarely still be equalled to the address
* of SQInfo.
* If SQInfo has been released, the value of signature cannot be equalled to the address of pQInfo,
* since in release function, the original value has been destroyed. However, this memory area may be reused
* by another function. It may be 0 or any value, but it is rarely still be equalled to the address of SQInfo.
*/
if (oldSignature == 0 || oldSignature != (uint64_t)pQInfo) {
dTrace("%p freed or killed, old sig:%p abort query", pQInfo, oldSignature);
......
......@@ -99,28 +99,32 @@ void *vnodeProcessMsgFromShell(char *msg, void *ahandle, void *thandle) {
}
}
// if ( vnodeList[vnode].status != TSDB_STATUS_MASTER && pMsg->msgType != TSDB_MSG_TYPE_RETRIEVE ) {
#ifdef CLUSTER
if (vnodeList[vnode].vnodeStatus != TSDB_VN_STATUS_MASTER) {
taosSendSimpleRsp(thandle, pMsg->msgType + 1, TSDB_CODE_NOT_READY);
dTrace("vid:%d sid:%d, shell msg is ignored since in state:%d", vnode, sid, vnodeList[vnode].vnodeStatus);
} else {
#endif
dTrace("vid:%d sid:%d, msg:%s is received pConn:%p", vnode, sid, taosMsg[pMsg->msgType], thandle);
if (pMsg->msgType == TSDB_MSG_TYPE_QUERY) {
if (vnodeList[vnode].vnodeStatus == TSDB_VN_STATUS_MASTER || vnodeList[vnode].vnodeStatus == TSDB_VN_STATUS_SLAVE) {
vnodeProcessQueryRequest((char *)pMsg->content, pMsg->msgLen - sizeof(SIntMsg), pObj);
} else {
taosSendSimpleRsp(thandle, pMsg->msgType + 1, TSDB_CODE_NOT_READY);
dTrace("vid:%d sid:%d, shell query msg is ignored since in status:%s", vnode, sid, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus));
}
} else if (pMsg->msgType == TSDB_MSG_TYPE_RETRIEVE) {
vnodeProcessRetrieveRequest((char *)pMsg->content, pMsg->msgLen - sizeof(SIntMsg), pObj);
if (vnodeList[vnode].vnodeStatus == TSDB_VN_STATUS_MASTER || vnodeList[vnode].vnodeStatus == TSDB_VN_STATUS_SLAVE) {
vnodeProcessRetrieveRequest((char *) pMsg->content, pMsg->msgLen - sizeof(SIntMsg), pObj);
} else {
taosSendSimpleRsp(thandle, pMsg->msgType + 1, TSDB_CODE_NOT_READY);
dTrace("vid:%d sid:%d, shell retrieve msg is ignored since in status:%s", vnode, sid, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus));
}
} else if (pMsg->msgType == TSDB_MSG_TYPE_SUBMIT) {
vnodeProcessShellSubmitRequest((char *)pMsg->content, pMsg->msgLen - sizeof(SIntMsg), pObj);
if (vnodeList[vnode].vnodeStatus == TSDB_VN_STATUS_MASTER) {
vnodeProcessShellSubmitRequest((char *) pMsg->content, pMsg->msgLen - sizeof(SIntMsg), pObj);
} else {
dError("%s is not processed", taosMsg[pMsg->msgType]);
taosSendSimpleRsp(thandle, pMsg->msgType + 1, TSDB_CODE_NOT_READY);
dTrace("vid:%d sid:%d, shell submit msg is ignored since in status:%s", vnode, sid, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus));
}
#ifdef CLUSTER
} else {
dError("%s is not processed", taosMsg[pMsg->msgType]);
}
#endif
return pObj;
}
......@@ -461,11 +465,7 @@ void vnodeExecuteRetrieveReq(SSchedMsg *pSched) {
pMsg = pRsp->data;
if (numOfRows > 0 && code == TSDB_CODE_SUCCESS) {
int32_t oldSize = size;
vnodeSaveQueryResult((void *)(pRetrieve->qhandle), pRsp->data, &size);
if (oldSize > size) {
pRsp->compress = htons(1); // denote that the response msg is compressed
}
}
pMsg += size;
......@@ -587,6 +587,7 @@ int vnodeProcessShellSubmitRequest(char *pMsg, int msgLen, SShellObj *pObj) {
int32_t sversion = htonl(pBlocks->sversion);
if (pSubmit->import) {
dTrace("start to import data");
code = vnodeImportPoints(pMeterObj, (char *) &(pBlocks->numOfRows), subMsgLen, TSDB_DATA_SOURCE_SHELL, pObj,
sversion, &numOfPoints, now);
pObj->numOfTotalPoints += numOfPoints;
......
......@@ -37,7 +37,6 @@ ELSEIF (TD_WINDOWS_64)
LIST(APPEND SRC ./src/ihash.c)
LIST(APPEND SRC ./src/lz4.c)
LIST(APPEND SRC ./src/shash.c)
LIST(APPEND SRC ./src/sql.c)
LIST(APPEND SRC ./src/tbase64.c)
LIST(APPEND SRC ./src/tcache.c)
LIST(APPEND SRC ./src/tcompression.c)
......@@ -59,8 +58,6 @@ ELSEIF (TD_WINDOWS_64)
LIST(APPEND SRC ./src/tskiplist.c)
LIST(APPEND SRC ./src/tsocket.c)
LIST(APPEND SRC ./src/tstatus.c)
LIST(APPEND SRC ./src/tstoken.c)
LIST(APPEND SRC ./src/tstoken.c)
LIST(APPEND SRC ./src/tstrbuild.c)
LIST(APPEND SRC ./src/ttime.c)
LIST(APPEND SRC ./src/ttimer.c)
......
......@@ -644,6 +644,7 @@ static void doInitGlobalConfig() {
tsInitConfigOption(cfg++, "defaultPass", tsDefaultPass, TSDB_CFG_VTYPE_STRING,
TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_NOT_PRINT,
0, 0, TSDB_PASSWORD_LEN, TSDB_CFG_UTYPE_NONE);
// socket type, udp by default
tsInitConfigOption(cfg++, "sockettype", tsSocketType, TSDB_CFG_VTYPE_STRING,
TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_SHOW,
......
......@@ -16,63 +16,462 @@
#include "os.h"
#include "tlog.h"
#define TAOS_MEM_CHECK_IMPL
#include "tutil.h"
#ifdef TAOS_MEM_CHECK
static int allocMode = TAOS_ALLOC_MODE_DEFAULT;
static FILE* fpAllocLog = NULL;
////////////////////////////////////////////////////////////////////////////////
// memory allocator which fails randomly
extern int32_t taosGetTimestampSec();
static int32_t startTime = 0;
static int64_t m_curLimit = 100*1024;
static int32_t startTime = INT32_MAX;;
bool isMallocMem(unsigned int size, char* _func) {
if (0 == startTime) {
startTime = taosGetTimestampSec();
return true;
} else {
int32_t currentTime = taosGetTimestampSec();
if (currentTime - startTime < 10) return true;
static bool random_alloc_fail(size_t size, const char* file, uint32_t line) {
if (taosGetTimestampSec() < startTime) {
return false;
}
if (size < 100 * (size_t)1024) {
return false;
}
if (size > m_curLimit) {
if (3 == rand() % 20) {
pTrace("====no alloc mem in func: %s, size:%d", _func, size);
if (rand() % 20 != 0) {
return false;
}
if (fpAllocLog != NULL) {
fprintf(fpAllocLog, "%s:%d: memory allocation of %zu bytes will fail.\n", file, line, size);
}
return true;
}
void* taos_malloc(unsigned int size, char* _func) {
static void* malloc_random(size_t size, const char* file, uint32_t line) {
return random_alloc_fail(size, file, line) ? NULL : malloc(size);
}
if (false == isMallocMem(size, _func)) {
return NULL;
static void* calloc_random(size_t num, size_t size, const char* file, uint32_t line) {
return random_alloc_fail(num * size, file, line) ? NULL : calloc(num, size);
}
static void* realloc_random(void* ptr, size_t size, const char* file, uint32_t line) {
return random_alloc_fail(size, file, line) ? NULL : realloc(ptr, size);
}
static char* strdup_random(const char* str, const char* file, uint32_t line) {
size_t len = strlen(str);
return random_alloc_fail(len + 1, file, line) ? NULL : strdup(str);
}
static char* strndup_random(const char* str, size_t size, const char* file, uint32_t line) {
size_t len = strlen(str);
if (len > size) {
len = size;
}
return random_alloc_fail(len + 1, file, line) ? NULL : strndup(str, len);
}
void *p = NULL;
p = malloc(size);
return p;
static ssize_t getline_random(char **lineptr, size_t *n, FILE *stream, const char* file, uint32_t line) {
return random_alloc_fail(*n, file, line) ? -1 : getline(lineptr, n, stream);
}
////////////////////////////////////////////////////////////////////////////////
// memory allocator with leak detection
#define MEMBLK_MAGIC 0x55AA
typedef struct SMemBlock {
const char* file;
uint16_t line;
uint16_t magic;
uint32_t size;
struct SMemBlock* prev;
struct SMemBlock* next;
// TODO: need pading in 32bit platform
char data[0];
} SMemBlock;
static SMemBlock *blocks = NULL;
static uintptr_t lock = 0;
static void add_mem_block(SMemBlock* blk) {
blk->prev = NULL;
while (atomic_val_compare_exchange_ptr(&lock, 0, 1) != 0);
blk->next = blocks;
if (blocks != NULL) {
blocks->prev = blk;
}
blocks = blk;
atomic_store_ptr(&lock, 0);
}
static void remove_mem_block(SMemBlock* blk) {
while (atomic_val_compare_exchange_ptr(&lock, 0, 1) != 0);
if (blocks == blk) {
blocks = blk->next;
}
if (blk->prev != NULL) {
blk->prev->next = blk->next;
}
if (blk->next != NULL) {
blk->next->prev = blk->prev;
}
atomic_store_ptr(&lock, 0);
blk->prev = NULL;
blk->next = NULL;
}
static void free_detect_leak(void* ptr, const char* file, uint32_t line) {
if (ptr == NULL) {
return;
}
SMemBlock* blk = (SMemBlock*)(((char*)ptr) - sizeof(SMemBlock));
if (blk->magic != MEMBLK_MAGIC) {
if (fpAllocLog != NULL) {
fprintf(fpAllocLog, "%s:%d: memory is allocated by default allocator.\n", file, line);
}
free(ptr);
return;
}
remove_mem_block(blk);
free(blk);
}
void* taos_calloc(unsigned int num, unsigned int size, char* _func) {
static void* malloc_detect_leak(size_t size, const char* file, uint32_t line) {
if (size == 0) {
return NULL;
}
if (false == isMallocMem(size, _func)) {
SMemBlock *blk = (SMemBlock*)malloc(size + sizeof(SMemBlock));
if (blk == NULL) {
return NULL;
}
void *p = NULL;
p = calloc(num, size);
if (line > UINT16_MAX && fpAllocLog != NULL) {
fprintf(fpAllocLog, "%s:%d: line number too large.\n", file, line);
}
if (size > UINT32_MAX && fpAllocLog != NULL) {
fprintf(fpAllocLog, "%s:%d: size too large: %zu.\n", file, line, size);
}
blk->file = file;
blk->line = (uint16_t)line;
blk->magic = MEMBLK_MAGIC;
blk->size = size;
add_mem_block(blk);
return blk->data;
}
static void* calloc_detect_leak(size_t num, size_t size, const char* file, uint32_t line) {
size *= num;
void* p = malloc_detect_leak(size, file, line);
if (p != NULL) {
memset(p, 0, size);
}
return p;
}
void* taos_realloc(void* ptr, unsigned int size, char* _func) {
static void* realloc_detect_leak(void* ptr, size_t size, const char* file, uint32_t line) {
if (size == 0) {
free_detect_leak(ptr, file, line);
return NULL;
}
if (ptr == NULL) {
return malloc_detect_leak(size, file, line);
}
if (false == isMallocMem(size, _func)) {
SMemBlock* blk = ((char*)ptr) - sizeof(SMemBlock);
if (blk->magic != MEMBLK_MAGIC) {
if (fpAllocLog != NULL) {
fprintf(fpAllocLog, "%s:%d: memory is allocated by default allocator.\n", file, line);
}
return realloc(ptr, size);
}
remove_mem_block(blk);
void* p = realloc(blk, size + sizeof(SMemBlock));
if (p == NULL) {
add_mem_block(blk);
return NULL;
}
void *p = NULL;
p = realloc(ptr, size);
if (size > UINT32_MAX && fpAllocLog != NULL) {
fprintf(fpAllocLog, "%s:%d: size too large: %zu.\n", file, line, size);
}
blk = (SMemBlock*)p;
blk->size = size;
add_mem_block(blk);
return blk->data;
}
static char* strdup_detect_leak(const char* str, const char* file, uint32_t line) {
size_t len = strlen(str);
char *p = malloc_detect_leak(len + 1, file, line);
if (p != NULL) {
memcpy(p, str, len);
p[len] = 0;
}
return p;
}
void taos_free(void* ptr) {
free(ptr);
static char* strndup_detect_leak(const char* str, size_t size, const char* file, uint32_t line) {
size_t len = strlen(str);
if (len > size) {
len = size;
}
char *p = malloc_detect_leak(len + 1, file, line);
if (p != NULL) {
memcpy(p, str, len);
p[len] = 0;
}
return p;
}
static ssize_t getline_detect_leak(char **lineptr, size_t *n, FILE *stream, const char* file, uint32_t line) {
char* buf = NULL;
size_t bufSize = 0;
ssize_t size = getline(&buf, &bufSize, stream);
if (size != -1) {
if (*n < size + 1) {
void* p = realloc_detect_leak(*lineptr, size + 1, file, line);
if (p == NULL) {
free(buf);
return -1;
}
*lineptr = (char*)p;
*n = size + 1;
}
memcpy(*lineptr, buf, size + 1);
}
free(buf);
return size;
}
static void dump_memory_leak() {
const char* hex = "0123456789ABCDEF";
const char* fmt = ":%d: addr=%p, size=%d, content(first 16 bytes)=";
size_t numOfBlk = 0, totalSize = 0;
if (fpAllocLog == NULL) {
return;
}
fputs("memory blocks allocated but not freed before exit:\n", fpAllocLog);
while (atomic_val_compare_exchange_ptr(&lock, 0, 1) != 0);
for (SMemBlock* blk = blocks; blk != NULL; blk = blk->next) {
++numOfBlk;
totalSize += blk->size;
fputs(blk->file, fpAllocLog);
fprintf(fpAllocLog, fmt, blk->line, blk->data, blk->size);
char sep = '\'';
size_t size = blk->size > 16 ? 16 : blk->size;
for (size_t i = 0; i < size; ++i) {
uint8_t c = (uint8_t)(blk->data[i]);
fputc(sep, fpAllocLog);
sep = ' ';
fputc(hex[c >> 4], fpAllocLog);
fputc(hex[c & 0x0f], fpAllocLog);
}
fputs("'\n", fpAllocLog);
}
atomic_store_ptr(&lock, 0);
fprintf(fpAllocLog, "\nnumber of blocks: %zu, total bytes: %zu\n", numOfBlk, totalSize);
fflush(fpAllocLog);
}
static void dump_memory_leak_on_sig(int sig) {
fprintf(fpAllocLog, "signal %d received.\n", sig);
// restore default signal handler
struct sigaction act = {0};
act.sa_handler = SIG_DFL;
sigaction(sig, &act, NULL);
dump_memory_leak();
}
////////////////////////////////////////////////////////////////////////////////
// interface functions
void* taos_malloc(size_t size, const char* file, uint32_t line) {
switch (allocMode) {
case TAOS_ALLOC_MODE_DEFAULT:
return malloc(size);
case TAOS_ALLOC_MODE_RANDOM_FAIL:
return malloc_random(size, file, line);
case TAOS_ALLOC_MODE_DETECT_LEAK:
return malloc_detect_leak(size, file, line);
}
return malloc(size);
}
void* taos_calloc(size_t num, size_t size, const char* file, uint32_t line) {
switch (allocMode) {
case TAOS_ALLOC_MODE_DEFAULT:
return calloc(num, size);
case TAOS_ALLOC_MODE_RANDOM_FAIL:
return calloc_random(num, size, file, line);
case TAOS_ALLOC_MODE_DETECT_LEAK:
return calloc_detect_leak(num, size, file, line);
}
return calloc(num, size);
}
void* taos_realloc(void* ptr, size_t size, const char* file, uint32_t line) {
switch (allocMode) {
case TAOS_ALLOC_MODE_DEFAULT:
return realloc(ptr, size);
case TAOS_ALLOC_MODE_RANDOM_FAIL:
return realloc_random(ptr, size, file, line);
case TAOS_ALLOC_MODE_DETECT_LEAK:
return realloc_detect_leak(ptr, size, file, line);
}
return realloc(ptr, size);
}
void taos_free(void* ptr, const char* file, uint32_t line) {
switch (allocMode) {
case TAOS_ALLOC_MODE_DEFAULT:
return free(ptr);
case TAOS_ALLOC_MODE_RANDOM_FAIL:
return free(ptr);
case TAOS_ALLOC_MODE_DETECT_LEAK:
return free_detect_leak(ptr, file, line);
}
return free(ptr);
}
char* taos_strdup(const char* str, const char* file, uint32_t line) {
switch (allocMode) {
case TAOS_ALLOC_MODE_DEFAULT:
return strdup(str);
case TAOS_ALLOC_MODE_RANDOM_FAIL:
return strdup_random(str, file, line);
case TAOS_ALLOC_MODE_DETECT_LEAK:
return strdup_detect_leak(str, file, line);
}
return strdup(str);
}
char* taos_strndup(const char* str, size_t size, const char* file, uint32_t line) {
switch (allocMode) {
case TAOS_ALLOC_MODE_DEFAULT:
return strndup(str, size);
case TAOS_ALLOC_MODE_RANDOM_FAIL:
return strndup_random(str, size, file, line);
case TAOS_ALLOC_MODE_DETECT_LEAK:
return strndup_detect_leak(str, size, file, line);
}
return strndup(str, size);
}
ssize_t taos_getline(char **lineptr, size_t *n, FILE *stream, const char* file, uint32_t line) {
switch (allocMode) {
case TAOS_ALLOC_MODE_DEFAULT:
return getline(lineptr, n, stream);
case TAOS_ALLOC_MODE_RANDOM_FAIL:
return getline_random(lineptr, n, stream, file, line);
case TAOS_ALLOC_MODE_DETECT_LEAK:
return getline_detect_leak(lineptr, n, stream, file, line);
}
return getline(lineptr, n, stream);
}
static void close_alloc_log() {
if (fpAllocLog != NULL) {
if (fpAllocLog != stdout) {
fclose(fpAllocLog);
}
fpAllocLog = NULL;
}
}
void taosSetAllocMode(int mode, const char* path, bool autoDump) {
assert(mode >= TAOS_ALLOC_MODE_DEFAULT);
assert(mode <= TAOS_ALLOC_MODE_DETECT_LEAK);
if (fpAllocLog != NULL || allocMode != TAOS_ALLOC_MODE_DEFAULT) {
printf("memory allocation mode can only be set once.\n");
return;
}
if (path == NULL || path[0] == 0) {
fpAllocLog = stdout;
} else if ((fpAllocLog = fopen(path, "w")) != NULL) {
atexit(close_alloc_log);
} else {
printf("failed to open memory allocation log file '%s', errno=%d\n", path, errno);
return;
}
allocMode = mode;
if (mode == TAOS_ALLOC_MODE_RANDOM_FAIL) {
startTime = taosGetTimestampSec() + 10;
return;
}
if (autoDump && mode == TAOS_ALLOC_MODE_DETECT_LEAK) {
atexit(dump_memory_leak);
struct sigaction act = {0};
act.sa_handler = dump_memory_leak_on_sig;
sigaction(SIGFPE, &act, NULL);
sigaction(SIGSEGV, &act, NULL);
sigaction(SIGILL, &act, NULL);
}
}
void taosDumpMemoryLeak() {
dump_memory_leak();
close_alloc_log();
}
#else // 'TAOS_MEM_CHECK' not defined
void taosSetAllocMode(int mode, const char* path, bool autoDump) {
// do nothing
}
void taosDumpMemoryLeak() {
// do nothing
}
#endif // TAOS_MEM_CHECK
......@@ -224,6 +224,7 @@ static SKeyword keywordTable[] = {
{"METRICS", TK_METRICS},
{"STABLE", TK_STABLE},
{"FILE", TK_FILE},
{"VNODES", TK_VNODES},
};
/* This is the hash table */
......
char version[64] = "1.6.4.0";
char compatible_version[64] = "1.6.1.0";
char gitinfo[128] = "d04354a8ac2f7dd9ba521d755e5d484a203783d9";
char buildinfo[512] = "Built by root at 2019-11-11 10:23";
char gitinfo[128] = "b6e308866e315483915f4c42a2717547ed0b9d36";
char buildinfo[512] = "Built by ubuntu at 2019-11-26 21:56";
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册