Merge remote-tracking branch 'origin/3.0' into feature/qnode
This commit is contained in:
commit
19660534cd
|
@ -218,26 +218,6 @@ typedef struct {
|
|||
char data[];
|
||||
} SMDCreateTableMsg;
|
||||
|
||||
// typedef struct {
|
||||
// int32_t len; // one create table message
|
||||
// char tableName[TSDB_TABLE_FNAME_LEN];
|
||||
// int16_t numOfColumns;
|
||||
// int16_t sqlLen; // the length of SQL, it starts after schema , sql is a null-terminated string
|
||||
// int8_t igExists;
|
||||
// int8_t rspMeta;
|
||||
// int8_t reserved[16];
|
||||
// char schema[];
|
||||
//} SCreateTableMsg;
|
||||
|
||||
typedef struct {
|
||||
char tableName[TSDB_TABLE_FNAME_LEN];
|
||||
int16_t numOfColumns;
|
||||
int16_t numOfTags;
|
||||
int8_t igExists;
|
||||
int8_t rspMeta;
|
||||
char schema[];
|
||||
} SCreateCTableMsg;
|
||||
|
||||
typedef struct {
|
||||
char name[TSDB_TABLE_FNAME_LEN];
|
||||
int8_t igExists;
|
||||
|
|
|
@ -13,205 +13,199 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _TD_COMMON_TOKEN_DEF_H_
|
||||
#define _TD_COMMON_TOKEN_DEF_H_
|
||||
#ifndef TDENGINE_TTOKENDEF_H
|
||||
#define TDENGINE_TTOKENDEF_H
|
||||
|
||||
#define TK_ID 1
|
||||
#define TK_BOOL 2
|
||||
#define TK_TINYINT 3
|
||||
#define TK_SMALLINT 4
|
||||
#define TK_INTEGER 5
|
||||
#define TK_BIGINT 6
|
||||
#define TK_FLOAT 7
|
||||
#define TK_DOUBLE 8
|
||||
#define TK_STRING 9
|
||||
#define TK_TIMESTAMP 10
|
||||
#define TK_BINARY 11
|
||||
#define TK_NCHAR 12
|
||||
#define TK_OR 13
|
||||
#define TK_AND 14
|
||||
#define TK_NOT 15
|
||||
#define TK_EQ 16
|
||||
#define TK_NE 17
|
||||
#define TK_ISNULL 18
|
||||
#define TK_NOTNULL 19
|
||||
#define TK_IS 20
|
||||
#define TK_LIKE 21
|
||||
#define TK_MATCH 22
|
||||
#define TK_NMATCH 23
|
||||
#define TK_GLOB 24
|
||||
#define TK_BETWEEN 25
|
||||
#define TK_IN 26
|
||||
#define TK_GT 27
|
||||
#define TK_GE 28
|
||||
#define TK_LT 29
|
||||
#define TK_LE 30
|
||||
#define TK_BITAND 31
|
||||
#define TK_BITOR 32
|
||||
#define TK_LSHIFT 33
|
||||
#define TK_RSHIFT 34
|
||||
#define TK_PLUS 35
|
||||
#define TK_MINUS 36
|
||||
#define TK_DIVIDE 37
|
||||
#define TK_TIMES 38
|
||||
#define TK_STAR 39
|
||||
#define TK_SLASH 40
|
||||
#define TK_REM 41
|
||||
#define TK_CONCAT 42
|
||||
#define TK_UMINUS 43
|
||||
#define TK_UPLUS 44
|
||||
#define TK_BITNOT 45
|
||||
#define TK_SHOW 46
|
||||
#define TK_DATABASES 47
|
||||
#define TK_TOPICS 48
|
||||
#define TK_FUNCTIONS 49
|
||||
#define TK_MNODES 50
|
||||
#define TK_DNODES 51
|
||||
#define TK_ACCOUNTS 52
|
||||
#define TK_USERS 53
|
||||
#define TK_MODULES 54
|
||||
#define TK_QUERIES 55
|
||||
#define TK_CONNECTIONS 56
|
||||
#define TK_STREAMS 57
|
||||
#define TK_VARIABLES 58
|
||||
#define TK_SCORES 59
|
||||
#define TK_GRANTS 60
|
||||
#define TK_VNODES 61
|
||||
#define TK_DOT 62
|
||||
#define TK_CREATE 63
|
||||
#define TK_TABLE 64
|
||||
#define TK_STABLE 65
|
||||
#define TK_DATABASE 66
|
||||
#define TK_TABLES 67
|
||||
#define TK_STABLES 68
|
||||
#define TK_VGROUPS 69
|
||||
#define TK_DROP 70
|
||||
#define TK_TOPIC 71
|
||||
#define TK_FUNCTION 72
|
||||
#define TK_DNODE 73
|
||||
#define TK_USER 74
|
||||
#define TK_ACCOUNT 75
|
||||
#define TK_USE 76
|
||||
#define TK_DESCRIBE 77
|
||||
#define TK_DESC 78
|
||||
#define TK_ALTER 79
|
||||
#define TK_PASS 80
|
||||
#define TK_PRIVILEGE 81
|
||||
#define TK_LOCAL 82
|
||||
#define TK_COMPACT 83
|
||||
#define TK_LP 84
|
||||
#define TK_RP 85
|
||||
#define TK_IF 86
|
||||
#define TK_EXISTS 87
|
||||
#define TK_AS 88
|
||||
#define TK_OUTPUTTYPE 89
|
||||
#define TK_AGGREGATE 90
|
||||
#define TK_BUFSIZE 91
|
||||
#define TK_PPS 92
|
||||
#define TK_TSERIES 93
|
||||
#define TK_DBS 94
|
||||
#define TK_STORAGE 95
|
||||
#define TK_QTIME 96
|
||||
#define TK_CONNS 97
|
||||
#define TK_STATE 98
|
||||
#define TK_COMMA 99
|
||||
#define TK_KEEP 100
|
||||
#define TK_CACHE 101
|
||||
#define TK_REPLICA 102
|
||||
#define TK_QUORUM 103
|
||||
#define TK_DAYS 104
|
||||
#define TK_MINROWS 105
|
||||
#define TK_MAXROWS 106
|
||||
#define TK_BLOCKS 107
|
||||
#define TK_CTIME 108
|
||||
#define TK_WAL 109
|
||||
#define TK_FSYNC 110
|
||||
#define TK_COMP 111
|
||||
#define TK_PRECISION 112
|
||||
#define TK_UPDATE 113
|
||||
#define TK_CACHELAST 114
|
||||
#define TK_PARTITIONS 115
|
||||
#define TK_UNSIGNED 116
|
||||
#define TK_TAGS 117
|
||||
#define TK_USING 118
|
||||
#define TK_NULL 119
|
||||
#define TK_NOW 120
|
||||
#define TK_SELECT 121
|
||||
#define TK_UNION 122
|
||||
#define TK_ALL 123
|
||||
#define TK_DISTINCT 124
|
||||
#define TK_FROM 125
|
||||
#define TK_VARIABLE 126
|
||||
#define TK_INTERVAL 127
|
||||
#define TK_EVERY 128
|
||||
#define TK_SESSION 129
|
||||
#define TK_STATE_WINDOW 130
|
||||
#define TK_FILL 131
|
||||
#define TK_SLIDING 132
|
||||
#define TK_ORDER 133
|
||||
#define TK_BY 134
|
||||
#define TK_ASC 135
|
||||
#define TK_GROUP 136
|
||||
#define TK_HAVING 137
|
||||
#define TK_LIMIT 138
|
||||
#define TK_OFFSET 139
|
||||
#define TK_SLIMIT 140
|
||||
#define TK_SOFFSET 141
|
||||
#define TK_WHERE 142
|
||||
#define TK_RESET 143
|
||||
#define TK_QUERY 144
|
||||
#define TK_SYNCDB 145
|
||||
#define TK_ADD 146
|
||||
#define TK_COLUMN 147
|
||||
#define TK_MODIFY 148
|
||||
#define TK_TAG 149
|
||||
#define TK_CHANGE 150
|
||||
#define TK_SET 151
|
||||
#define TK_KILL 152
|
||||
#define TK_CONNECTION 153
|
||||
#define TK_STREAM 154
|
||||
#define TK_COLON 155
|
||||
#define TK_ABORT 156
|
||||
#define TK_AFTER 157
|
||||
#define TK_ATTACH 158
|
||||
#define TK_BEFORE 159
|
||||
#define TK_BEGIN 160
|
||||
#define TK_CASCADE 161
|
||||
#define TK_CLUSTER 162
|
||||
#define TK_CONFLICT 163
|
||||
#define TK_COPY 164
|
||||
#define TK_DEFERRED 165
|
||||
#define TK_DELIMITERS 166
|
||||
#define TK_DETACH 167
|
||||
#define TK_EACH 168
|
||||
#define TK_END 169
|
||||
#define TK_EXPLAIN 170
|
||||
#define TK_FAIL 171
|
||||
#define TK_FOR 172
|
||||
#define TK_IGNORE 173
|
||||
#define TK_IMMEDIATE 174
|
||||
#define TK_INITIALLY 175
|
||||
#define TK_INSTEAD 176
|
||||
#define TK_KEY 177
|
||||
#define TK_OF 178
|
||||
#define TK_RAISE 179
|
||||
#define TK_REPLACE 180
|
||||
#define TK_RESTRICT 181
|
||||
#define TK_ROW 182
|
||||
#define TK_STATEMENT 183
|
||||
#define TK_TRIGGER 184
|
||||
#define TK_VIEW 185
|
||||
#define TK_IPTOKEN 186
|
||||
#define TK_SEMI 187
|
||||
#define TK_NONE 188
|
||||
#define TK_PREV 189
|
||||
#define TK_LINEAR 190
|
||||
#define TK_IMPORT 191
|
||||
#define TK_TBNAME 192
|
||||
#define TK_JOIN 193
|
||||
#define TK_INSERT 194
|
||||
#define TK_INTO 195
|
||||
#define TK_VALUES 196
|
||||
#define TK_INTEGER 3
|
||||
#define TK_FLOAT 4
|
||||
#define TK_STRING 5
|
||||
#define TK_TIMESTAMP 6
|
||||
#define TK_OR 7
|
||||
#define TK_AND 8
|
||||
#define TK_NOT 9
|
||||
#define TK_EQ 10
|
||||
#define TK_NE 11
|
||||
#define TK_ISNULL 12
|
||||
#define TK_NOTNULL 13
|
||||
#define TK_IS 14
|
||||
#define TK_LIKE 15
|
||||
#define TK_MATCH 16
|
||||
#define TK_NMATCH 17
|
||||
#define TK_GLOB 18
|
||||
#define TK_BETWEEN 19
|
||||
#define TK_IN 20
|
||||
#define TK_GT 21
|
||||
#define TK_GE 22
|
||||
#define TK_LT 23
|
||||
#define TK_LE 24
|
||||
#define TK_BITAND 25
|
||||
#define TK_BITOR 26
|
||||
#define TK_LSHIFT 27
|
||||
#define TK_RSHIFT 28
|
||||
#define TK_PLUS 29
|
||||
#define TK_MINUS 30
|
||||
#define TK_DIVIDE 31
|
||||
#define TK_TIMES 32
|
||||
#define TK_STAR 33
|
||||
#define TK_SLASH 34
|
||||
#define TK_REM 35
|
||||
#define TK_CONCAT 36
|
||||
#define TK_UMINUS 37
|
||||
#define TK_UPLUS 38
|
||||
#define TK_BITNOT 39
|
||||
#define TK_SHOW 40
|
||||
#define TK_DATABASES 41
|
||||
#define TK_TOPICS 42
|
||||
#define TK_FUNCTIONS 43
|
||||
#define TK_MNODES 44
|
||||
#define TK_DNODES 45
|
||||
#define TK_ACCOUNTS 46
|
||||
#define TK_USERS 47
|
||||
#define TK_MODULES 48
|
||||
#define TK_QUERIES 49
|
||||
#define TK_CONNECTIONS 50
|
||||
#define TK_STREAMS 51
|
||||
#define TK_VARIABLES 52
|
||||
#define TK_SCORES 53
|
||||
#define TK_GRANTS 54
|
||||
#define TK_VNODES 55
|
||||
#define TK_DOT 56
|
||||
#define TK_CREATE 57
|
||||
#define TK_TABLE 58
|
||||
#define TK_STABLE 59
|
||||
#define TK_DATABASE 60
|
||||
#define TK_TABLES 61
|
||||
#define TK_STABLES 62
|
||||
#define TK_VGROUPS 63
|
||||
#define TK_DROP 64
|
||||
#define TK_TOPIC 65
|
||||
#define TK_FUNCTION 66
|
||||
#define TK_DNODE 67
|
||||
#define TK_USER 68
|
||||
#define TK_ACCOUNT 69
|
||||
#define TK_USE 70
|
||||
#define TK_DESCRIBE 71
|
||||
#define TK_DESC 72
|
||||
#define TK_ALTER 73
|
||||
#define TK_PASS 74
|
||||
#define TK_PRIVILEGE 75
|
||||
#define TK_LOCAL 76
|
||||
#define TK_COMPACT 77
|
||||
#define TK_LP 78
|
||||
#define TK_RP 79
|
||||
#define TK_IF 80
|
||||
#define TK_EXISTS 81
|
||||
#define TK_PORT 82
|
||||
#define TK_IPTOKEN 83
|
||||
#define TK_AS 84
|
||||
#define TK_OUTPUTTYPE 85
|
||||
#define TK_AGGREGATE 86
|
||||
#define TK_BUFSIZE 87
|
||||
#define TK_PPS 88
|
||||
#define TK_TSERIES 89
|
||||
#define TK_DBS 90
|
||||
#define TK_STORAGE 91
|
||||
#define TK_QTIME 92
|
||||
#define TK_CONNS 93
|
||||
#define TK_STATE 94
|
||||
#define TK_COMMA 95
|
||||
#define TK_KEEP 96
|
||||
#define TK_CACHE 97
|
||||
#define TK_REPLICA 98
|
||||
#define TK_QUORUM 99
|
||||
#define TK_DAYS 100
|
||||
#define TK_MINROWS 101
|
||||
#define TK_MAXROWS 102
|
||||
#define TK_BLOCKS 103
|
||||
#define TK_CTIME 104
|
||||
#define TK_WAL 105
|
||||
#define TK_FSYNC 106
|
||||
#define TK_COMP 107
|
||||
#define TK_PRECISION 108
|
||||
#define TK_UPDATE 109
|
||||
#define TK_CACHELAST 110
|
||||
#define TK_UNSIGNED 111
|
||||
#define TK_TAGS 112
|
||||
#define TK_USING 113
|
||||
#define TK_NULL 114
|
||||
#define TK_NOW 115
|
||||
#define TK_SELECT 116
|
||||
#define TK_UNION 117
|
||||
#define TK_ALL 118
|
||||
#define TK_DISTINCT 119
|
||||
#define TK_FROM 120
|
||||
#define TK_VARIABLE 121
|
||||
#define TK_INTERVAL 122
|
||||
#define TK_EVERY 123
|
||||
#define TK_SESSION 124
|
||||
#define TK_STATE_WINDOW 125
|
||||
#define TK_FILL 126
|
||||
#define TK_SLIDING 127
|
||||
#define TK_ORDER 128
|
||||
#define TK_BY 129
|
||||
#define TK_ASC 130
|
||||
#define TK_GROUP 131
|
||||
#define TK_HAVING 132
|
||||
#define TK_LIMIT 133
|
||||
#define TK_OFFSET 134
|
||||
#define TK_SLIMIT 135
|
||||
#define TK_SOFFSET 136
|
||||
#define TK_WHERE 137
|
||||
#define TK_RESET 138
|
||||
#define TK_QUERY 139
|
||||
#define TK_SYNCDB 140
|
||||
#define TK_ADD 141
|
||||
#define TK_COLUMN 142
|
||||
#define TK_MODIFY 143
|
||||
#define TK_TAG 144
|
||||
#define TK_CHANGE 145
|
||||
#define TK_SET 146
|
||||
#define TK_KILL 147
|
||||
#define TK_CONNECTION 148
|
||||
#define TK_STREAM 149
|
||||
#define TK_COLON 150
|
||||
#define TK_ABORT 151
|
||||
#define TK_AFTER 152
|
||||
#define TK_ATTACH 153
|
||||
#define TK_BEFORE 154
|
||||
#define TK_BEGIN 155
|
||||
#define TK_CASCADE 156
|
||||
#define TK_CLUSTER 157
|
||||
#define TK_CONFLICT 158
|
||||
#define TK_COPY 159
|
||||
#define TK_DEFERRED 160
|
||||
#define TK_DELIMITERS 161
|
||||
#define TK_DETACH 162
|
||||
#define TK_EACH 163
|
||||
#define TK_END 164
|
||||
#define TK_EXPLAIN 165
|
||||
#define TK_FAIL 166
|
||||
#define TK_FOR 167
|
||||
#define TK_IGNORE 168
|
||||
#define TK_IMMEDIATE 169
|
||||
#define TK_INITIALLY 170
|
||||
#define TK_INSTEAD 171
|
||||
#define TK_KEY 172
|
||||
#define TK_OF 173
|
||||
#define TK_RAISE 174
|
||||
#define TK_REPLACE 175
|
||||
#define TK_RESTRICT 176
|
||||
#define TK_ROW 177
|
||||
#define TK_STATEMENT 178
|
||||
#define TK_TRIGGER 179
|
||||
#define TK_VIEW 180
|
||||
#define TK_SEMI 181
|
||||
#define TK_NONE 182
|
||||
#define TK_PREV 183
|
||||
#define TK_LINEAR 184
|
||||
#define TK_IMPORT 185
|
||||
#define TK_TBNAME 186
|
||||
#define TK_JOIN 187
|
||||
#define TK_INSERT 188
|
||||
#define TK_INTO 189
|
||||
#define TK_VALUES 190
|
||||
|
||||
|
||||
#define TK_SPACE 300
|
||||
|
@ -223,6 +217,6 @@
|
|||
#define TK_FILE 306
|
||||
#define TK_QUESTION 307 // denoting the placeholder of "?",when invoking statement bind query
|
||||
|
||||
#endif /*_TD_COMMON_TOKEN_DEF_H_*/
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -166,6 +166,7 @@ typedef struct SInsertStmtInfo {
|
|||
typedef struct SDclStmtInfo {
|
||||
int16_t nodeType;
|
||||
int16_t msgType;
|
||||
SEpSet epSet;
|
||||
char* pMsg;
|
||||
int32_t msgLen;
|
||||
} SDclStmtInfo;
|
||||
|
|
|
@ -317,7 +317,7 @@ do { \
|
|||
#define TSDB_MAX_FIELD_LEN 16384
|
||||
#define TSDB_MAX_BINARY_LEN (TSDB_MAX_FIELD_LEN-TSDB_KEYSIZE) // keep 16384
|
||||
#define TSDB_MAX_NCHAR_LEN (TSDB_MAX_FIELD_LEN-TSDB_KEYSIZE) // keep 16384
|
||||
#define PRIMARYKEY_TIMESTAMP_COL_ID 0
|
||||
#define PRIMARYKEY_TIMESTAMP_COL_ID 1
|
||||
|
||||
#define TSDB_MAX_RPC_THREADS 5
|
||||
|
||||
|
|
|
@ -182,40 +182,40 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQueryNode* pQuery) {
|
|||
|
||||
STscObj* pTscObj = pRequest->pTscObj;
|
||||
|
||||
|
||||
SMsgSendInfo* pSendMsg = buildSendMsgInfoImpl(pRequest);
|
||||
SEpSet* pEpSet = &pTscObj->pAppInfo->mgmtEp.epSet;
|
||||
|
||||
if (pDcl->msgType == TDMT_VND_CREATE_TABLE) {
|
||||
struct SCatalog* pCatalog = NULL;
|
||||
|
||||
char buf[18] = {0};
|
||||
sprintf(buf, "%" PRId64, pRequest->pTscObj->pAppInfo->clusterId);
|
||||
int32_t code = catalogGetHandle(buf, &pCatalog);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
||||
SCreateTableMsg* pMsg = pSendMsg->msgInfo.pData;
|
||||
|
||||
SName t = {0};
|
||||
tNameFromString(&t, pMsg->name, T_NAME_ACCT|T_NAME_DB|T_NAME_TABLE);
|
||||
|
||||
char db[TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN + TSDB_ACCT_ID_LEN] = {0};
|
||||
tNameGetFullDbName(&t, db);
|
||||
|
||||
SVgroupInfo info = {0};
|
||||
catalogGetTableHashVgroup(pCatalog, pRequest->pTscObj->pTransporter, pEpSet, db, tNameGetTableName(&t), &info);
|
||||
|
||||
// struct SCatalog* pCatalog = NULL;
|
||||
//
|
||||
// char buf[18] = {0};
|
||||
// sprintf(buf, "%" PRId64, pRequest->pTscObj->pAppInfo->clusterId);
|
||||
// int32_t code = catalogGetHandle(buf, &pCatalog);
|
||||
// if (code != TSDB_CODE_SUCCESS) {
|
||||
// return code;
|
||||
// }
|
||||
//
|
||||
// SCreateTableMsg* pMsg = pSendMsg->msgInfo.pData;
|
||||
//
|
||||
// SName t = {0};
|
||||
// tNameFromString(&t, pMsg->name, T_NAME_ACCT|T_NAME_DB|T_NAME_TABLE);
|
||||
//
|
||||
// char db[TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN + TSDB_ACCT_ID_LEN] = {0};
|
||||
// tNameGetFullDbName(&t, db);
|
||||
//
|
||||
// SVgroupInfo info = {0};
|
||||
// catalogGetTableHashVgroup(pCatalog, pRequest->pTscObj->pTransporter, pEpSet, db, tNameGetTableName(&t), &info);
|
||||
//
|
||||
int64_t transporterId = 0;
|
||||
SEpSet ep = {0};
|
||||
ep.inUse = info.inUse;
|
||||
ep.numOfEps = info.numOfEps;
|
||||
for(int32_t i = 0; i < ep.numOfEps; ++i) {
|
||||
ep.port[i] = info.epAddr[i].port;
|
||||
tstrncpy(ep.fqdn[i], info.epAddr[i].fqdn, tListLen(ep.fqdn[i]));
|
||||
}
|
||||
|
||||
asyncSendMsgToServer(pTscObj->pTransporter, &ep, &transporterId, pSendMsg);
|
||||
// SEpSet ep = {0};
|
||||
// ep.inUse = info.inUse;
|
||||
// ep.numOfEps = info.numOfEps;
|
||||
// for(int32_t i = 0; i < ep.numOfEps; ++i) {
|
||||
// ep.port[i] = info.epAddr[i].port;
|
||||
// tstrncpy(ep.fqdn[i], info.epAddr[i].fqdn, tListLen(ep.fqdn[i]));
|
||||
// }
|
||||
asyncSendMsgToServer(pTscObj->pTransporter, &pDcl->epSet, &transporterId, pSendMsg);
|
||||
} else {
|
||||
int64_t transporterId = 0;
|
||||
asyncSendMsgToServer(pTscObj->pTransporter, pEpSet, &transporterId, pSendMsg);
|
||||
|
|
|
@ -177,14 +177,14 @@ TEST(testCase, create_dnode_Test) {
|
|||
if (taos_errno(pRes) != 0) {
|
||||
printf("error in create dnode, reason:%s\n", taos_errstr(pRes));
|
||||
}
|
||||
|
||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||
ASSERT_TRUE(pFields == NULL);
|
||||
|
||||
int32_t numOfFields = taos_num_fields(pRes);
|
||||
ASSERT_EQ(numOfFields, 0);
|
||||
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create dnode 1.1.1.1 port 9000");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create dnode, reason:%s\n", taos_errstr(pRes));
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
taos_close(pConn);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
#include "taos.h"
|
||||
#include "taosdef.h"
|
||||
#include "thash.h"
|
||||
#include "ttime.h"
|
||||
#include "ttokendef.h"
|
||||
#include "ttypes.h"
|
||||
|
|
|
@ -68,7 +68,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
|||
|
||||
{
|
||||
SSchema* pSchema = &pReq->pSchema[0];
|
||||
pSchema->colId = htonl(0);
|
||||
pSchema->bytes = htonl(8);
|
||||
pSchema->type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema->name, "ts");
|
||||
|
@ -76,7 +75,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
|||
|
||||
{
|
||||
SSchema* pSchema = &pReq->pSchema[1];
|
||||
pSchema->colId = htonl(1);
|
||||
pSchema->bytes = htonl(4);
|
||||
pSchema->type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema->name, "col1");
|
||||
|
@ -84,7 +82,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
|||
|
||||
{
|
||||
SSchema* pSchema = &pReq->pSchema[2];
|
||||
pSchema->colId = htonl(2);
|
||||
pSchema->bytes = htonl(2);
|
||||
pSchema->type = TSDB_DATA_TYPE_TINYINT;
|
||||
strcpy(pSchema->name, "tag1");
|
||||
|
@ -92,7 +89,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
|||
|
||||
{
|
||||
SSchema* pSchema = &pReq->pSchema[3];
|
||||
pSchema->colId = htonl(3);
|
||||
pSchema->bytes = htonl(8);
|
||||
pSchema->type = TSDB_DATA_TYPE_BIGINT;
|
||||
strcpy(pSchema->name, "tag2");
|
||||
|
@ -100,7 +96,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
|||
|
||||
{
|
||||
SSchema* pSchema = &pReq->pSchema[4];
|
||||
pSchema->colId = htonl(4);
|
||||
pSchema->bytes = htonl(16);
|
||||
pSchema->type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema->name, "tag3");
|
||||
|
@ -167,10 +162,42 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
|||
{
|
||||
SSchema* pSchema = &pRsp->pSchema[0];
|
||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TIMESTAMP);
|
||||
EXPECT_EQ(pSchema->colId, 0);
|
||||
EXPECT_EQ(pSchema->colId, 1);
|
||||
EXPECT_EQ(pSchema->bytes, 8);
|
||||
EXPECT_STREQ(pSchema->name, "ts");
|
||||
}
|
||||
|
||||
{
|
||||
SSchema* pSchema = &pRsp->pSchema[1];
|
||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_INT);
|
||||
EXPECT_EQ(pSchema->colId, 2);
|
||||
EXPECT_EQ(pSchema->bytes, 4);
|
||||
EXPECT_STREQ(pSchema->name, "col1");
|
||||
}
|
||||
|
||||
{
|
||||
SSchema* pSchema = &pRsp->pSchema[2];
|
||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TINYINT);
|
||||
EXPECT_EQ(pSchema->colId, 3);
|
||||
EXPECT_EQ(pSchema->bytes, 2);
|
||||
EXPECT_STREQ(pSchema->name, "tag1");
|
||||
}
|
||||
|
||||
{
|
||||
SSchema* pSchema = &pRsp->pSchema[3];
|
||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BIGINT);
|
||||
EXPECT_EQ(pSchema->colId, 4);
|
||||
EXPECT_EQ(pSchema->bytes, 8);
|
||||
EXPECT_STREQ(pSchema->name, "tag2");
|
||||
}
|
||||
|
||||
{
|
||||
SSchema* pSchema = &pRsp->pSchema[4];
|
||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY);
|
||||
EXPECT_EQ(pSchema->colId, 5);
|
||||
EXPECT_EQ(pSchema->bytes, 16);
|
||||
EXPECT_STREQ(pSchema->name, "tag3");
|
||||
}
|
||||
}
|
||||
|
||||
// restart
|
||||
|
|
|
@ -291,7 +291,6 @@ static int32_t mndCheckCreateStbMsg(SCreateStbMsg *pCreate) {
|
|||
int32_t totalCols = pCreate->numOfColumns + pCreate->numOfTags;
|
||||
for (int32_t i = 0; i < totalCols; ++i) {
|
||||
SSchema *pSchema = &pCreate->pSchema[i];
|
||||
pSchema->colId = htonl(pSchema->colId);
|
||||
pSchema->bytes = htonl(pSchema->bytes);
|
||||
}
|
||||
|
||||
|
@ -317,10 +316,6 @@ static int32_t mndCheckCreateStbMsg(SCreateStbMsg *pCreate) {
|
|||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||
return -1;
|
||||
}
|
||||
if (pSchema->colId < 0 || pSchema->colId >= maxColId) {
|
||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||
return -1;
|
||||
}
|
||||
if (pSchema->bytes <= 0) {
|
||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||
return -1;
|
||||
|
@ -453,6 +448,10 @@ static int32_t mndCreateStb(SMnode *pMnode, SMnodeMsg *pMsg, SCreateStbMsg *pCre
|
|||
}
|
||||
memcpy(stbObj.pSchema, pCreate->pSchema, totalSize);
|
||||
|
||||
for (int32_t i = 0; i < totalCols; ++i) {
|
||||
stbObj.pSchema[i].colId = i + 1;
|
||||
}
|
||||
|
||||
int32_t code = 0;
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg);
|
||||
if (pTrans == NULL) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
%default_type {SToken}
|
||||
%extra_argument {SSqlInfo* pInfo}
|
||||
|
||||
%fallback ID BOOL TINYINT SMALLINT INTEGER BIGINT FLOAT DOUBLE STRING TIMESTAMP BINARY NCHAR.
|
||||
%fallback ID BOOL INTEGER FLOAT STRING TIMESTAMP.
|
||||
|
||||
%left OR.
|
||||
%left AND.
|
||||
|
@ -201,6 +201,7 @@ ifnotexists(X) ::= . { X.n = 0;}
|
|||
/////////////////////////////////THE CREATE STATEMENT///////////////////////////////////////
|
||||
//create option for dnode/db/user/account
|
||||
cmd ::= CREATE DNODE ids(X) PORT ids(Y). { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 2, &X, &Y);}
|
||||
cmd ::= CREATE DNODE IPTOKEN(X) PORT ids(Y). { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 2, &X, &Y);}
|
||||
cmd ::= CREATE ACCOUNT ids(X) PASS ids(Y) acct_optr(Z).
|
||||
{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &X, &Y, &Z);}
|
||||
cmd ::= CREATE DATABASE ifnotexists(Z) ids(X) db_optr(Y). { setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &X, &Y, &Z);}
|
||||
|
|
|
@ -1,230 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TDENGINE_TTOKENDEF_H
|
||||
#define TDENGINE_TTOKENDEF_H
|
||||
|
||||
#define TK_ID 1
|
||||
#define TK_BOOL 2
|
||||
#define TK_TINYINT 3
|
||||
#define TK_SMALLINT 4
|
||||
#define TK_INTEGER 5
|
||||
#define TK_BIGINT 6
|
||||
#define TK_FLOAT 7
|
||||
#define TK_DOUBLE 8
|
||||
#define TK_STRING 9
|
||||
#define TK_TIMESTAMP 10
|
||||
#define TK_BINARY 11
|
||||
#define TK_NCHAR 12
|
||||
#define TK_OR 13
|
||||
#define TK_AND 14
|
||||
#define TK_NOT 15
|
||||
#define TK_EQ 16
|
||||
#define TK_NE 17
|
||||
#define TK_ISNULL 18
|
||||
#define TK_NOTNULL 19
|
||||
#define TK_IS 20
|
||||
#define TK_LIKE 21
|
||||
#define TK_MATCH 22
|
||||
#define TK_NMATCH 23
|
||||
#define TK_GLOB 24
|
||||
#define TK_BETWEEN 25
|
||||
#define TK_IN 26
|
||||
#define TK_GT 27
|
||||
#define TK_GE 28
|
||||
#define TK_LT 29
|
||||
#define TK_LE 30
|
||||
#define TK_BITAND 31
|
||||
#define TK_BITOR 32
|
||||
#define TK_LSHIFT 33
|
||||
#define TK_RSHIFT 34
|
||||
#define TK_PLUS 35
|
||||
#define TK_MINUS 36
|
||||
#define TK_DIVIDE 37
|
||||
#define TK_TIMES 38
|
||||
#define TK_STAR 39
|
||||
#define TK_SLASH 40
|
||||
#define TK_REM 41
|
||||
#define TK_CONCAT 42
|
||||
#define TK_UMINUS 43
|
||||
#define TK_UPLUS 44
|
||||
#define TK_BITNOT 45
|
||||
#define TK_SHOW 46
|
||||
#define TK_DATABASES 47
|
||||
#define TK_TOPICS 48
|
||||
#define TK_FUNCTIONS 49
|
||||
#define TK_MNODES 50
|
||||
#define TK_DNODES 51
|
||||
#define TK_ACCOUNTS 52
|
||||
#define TK_USERS 53
|
||||
#define TK_MODULES 54
|
||||
#define TK_QUERIES 55
|
||||
#define TK_CONNECTIONS 56
|
||||
#define TK_STREAMS 57
|
||||
#define TK_VARIABLES 58
|
||||
#define TK_SCORES 59
|
||||
#define TK_GRANTS 60
|
||||
#define TK_VNODES 61
|
||||
#define TK_DOT 62
|
||||
#define TK_CREATE 63
|
||||
#define TK_TABLE 64
|
||||
#define TK_STABLE 65
|
||||
#define TK_DATABASE 66
|
||||
#define TK_TABLES 67
|
||||
#define TK_STABLES 68
|
||||
#define TK_VGROUPS 69
|
||||
#define TK_DROP 70
|
||||
#define TK_TOPIC 71
|
||||
#define TK_FUNCTION 72
|
||||
#define TK_DNODE 73
|
||||
#define TK_USER 74
|
||||
#define TK_ACCOUNT 75
|
||||
#define TK_USE 76
|
||||
#define TK_DESCRIBE 77
|
||||
#define TK_DESC 78
|
||||
#define TK_ALTER 79
|
||||
#define TK_PASS 80
|
||||
#define TK_PRIVILEGE 81
|
||||
#define TK_LOCAL 82
|
||||
#define TK_COMPACT 83
|
||||
#define TK_LP 84
|
||||
#define TK_RP 85
|
||||
#define TK_IF 86
|
||||
#define TK_EXISTS 87
|
||||
#define TK_PORT 88
|
||||
#define TK_AS 89
|
||||
#define TK_OUTPUTTYPE 90
|
||||
#define TK_AGGREGATE 91
|
||||
#define TK_BUFSIZE 92
|
||||
#define TK_PPS 93
|
||||
#define TK_TSERIES 94
|
||||
#define TK_DBS 95
|
||||
#define TK_STORAGE 96
|
||||
#define TK_QTIME 97
|
||||
#define TK_CONNS 98
|
||||
#define TK_STATE 99
|
||||
#define TK_COMMA 100
|
||||
#define TK_KEEP 101
|
||||
#define TK_CACHE 102
|
||||
#define TK_REPLICA 103
|
||||
#define TK_QUORUM 104
|
||||
#define TK_DAYS 105
|
||||
#define TK_MINROWS 106
|
||||
#define TK_MAXROWS 107
|
||||
#define TK_BLOCKS 108
|
||||
#define TK_CTIME 109
|
||||
#define TK_WAL 110
|
||||
#define TK_FSYNC 111
|
||||
#define TK_COMP 112
|
||||
#define TK_PRECISION 113
|
||||
#define TK_UPDATE 114
|
||||
#define TK_CACHELAST 115
|
||||
#define TK_UNSIGNED 116
|
||||
#define TK_TAGS 117
|
||||
#define TK_USING 118
|
||||
#define TK_NULL 119
|
||||
#define TK_NOW 120
|
||||
#define TK_SELECT 121
|
||||
#define TK_UNION 122
|
||||
#define TK_ALL 123
|
||||
#define TK_DISTINCT 124
|
||||
#define TK_FROM 125
|
||||
#define TK_VARIABLE 126
|
||||
#define TK_INTERVAL 127
|
||||
#define TK_EVERY 128
|
||||
#define TK_SESSION 129
|
||||
#define TK_STATE_WINDOW 130
|
||||
#define TK_FILL 131
|
||||
#define TK_SLIDING 132
|
||||
#define TK_ORDER 133
|
||||
#define TK_BY 134
|
||||
#define TK_ASC 135
|
||||
#define TK_GROUP 136
|
||||
#define TK_HAVING 137
|
||||
#define TK_LIMIT 138
|
||||
#define TK_OFFSET 139
|
||||
#define TK_SLIMIT 140
|
||||
#define TK_SOFFSET 141
|
||||
#define TK_WHERE 142
|
||||
#define TK_RESET 143
|
||||
#define TK_QUERY 144
|
||||
#define TK_SYNCDB 145
|
||||
#define TK_ADD 146
|
||||
#define TK_COLUMN 147
|
||||
#define TK_MODIFY 148
|
||||
#define TK_TAG 149
|
||||
#define TK_CHANGE 150
|
||||
#define TK_SET 151
|
||||
#define TK_KILL 152
|
||||
#define TK_CONNECTION 153
|
||||
#define TK_STREAM 154
|
||||
#define TK_COLON 155
|
||||
#define TK_ABORT 156
|
||||
#define TK_AFTER 157
|
||||
#define TK_ATTACH 158
|
||||
#define TK_BEFORE 159
|
||||
#define TK_BEGIN 160
|
||||
#define TK_CASCADE 161
|
||||
#define TK_CLUSTER 162
|
||||
#define TK_CONFLICT 163
|
||||
#define TK_COPY 164
|
||||
#define TK_DEFERRED 165
|
||||
#define TK_DELIMITERS 166
|
||||
#define TK_DETACH 167
|
||||
#define TK_EACH 168
|
||||
#define TK_END 169
|
||||
#define TK_EXPLAIN 170
|
||||
#define TK_FAIL 171
|
||||
#define TK_FOR 172
|
||||
#define TK_IGNORE 173
|
||||
#define TK_IMMEDIATE 174
|
||||
#define TK_INITIALLY 175
|
||||
#define TK_INSTEAD 176
|
||||
#define TK_KEY 177
|
||||
#define TK_OF 178
|
||||
#define TK_RAISE 179
|
||||
#define TK_REPLACE 180
|
||||
#define TK_RESTRICT 181
|
||||
#define TK_ROW 182
|
||||
#define TK_STATEMENT 183
|
||||
#define TK_TRIGGER 184
|
||||
#define TK_VIEW 185
|
||||
#define TK_IPTOKEN 186
|
||||
#define TK_SEMI 187
|
||||
#define TK_NONE 188
|
||||
#define TK_PREV 189
|
||||
#define TK_LINEAR 190
|
||||
#define TK_IMPORT 191
|
||||
#define TK_TBNAME 192
|
||||
#define TK_JOIN 193
|
||||
#define TK_INSERT 194
|
||||
#define TK_INTO 195
|
||||
#define TK_VALUES 196
|
||||
|
||||
|
||||
|
||||
|
||||
#define TK_SPACE 300
|
||||
#define TK_COMMENT 301
|
||||
#define TK_ILLEGAL 302
|
||||
#define TK_HEX 303 // hex number 0x123
|
||||
#define TK_OCT 304 // oct number
|
||||
#define TK_BIN 305 // bin format data 0b111
|
||||
#define TK_FILE 306
|
||||
#define TK_QUESTION 307 // denoting the placeholder of "?",when invoking statement bind query
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -276,7 +276,7 @@ bool tSqlExprIsLeaf(tSqlExpr *pExpr) {
|
|||
return (pExpr->pRight == NULL && pExpr->pLeft == NULL) &&
|
||||
(pExpr->tokenId == 0 ||
|
||||
(pExpr->tokenId == TK_ID) ||
|
||||
(pExpr->tokenId >= TK_BOOL && pExpr->tokenId <= TK_NCHAR) ||
|
||||
(pExpr->tokenId == TK_BOOL || pExpr->tokenId == TK_STRING || pExpr->tokenId == TK_FLOAT) ||
|
||||
(pExpr->tokenId == TK_NULL) ||
|
||||
(pExpr->tokenId == TK_SET));
|
||||
}
|
||||
|
|
|
@ -388,7 +388,7 @@ SCreateDnodeMsg *buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMs
|
|||
}
|
||||
|
||||
SToken* id = taosArrayGet(pInfo->pMiscInfo->a, 0);
|
||||
if (id->type != TK_ID) {
|
||||
if (id->type != TK_ID && id->type != TK_IPTOKEN) {
|
||||
buildInvalidOperationMsg(pMsgBuf, msg2);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <tmsg.h>
|
||||
#include <ttime.h>
|
||||
#include "astToMsg.h"
|
||||
#include "parserInt.h"
|
||||
|
@ -283,7 +284,7 @@ int32_t doCheckForCreateTable(SSqlInfo* pInfo, SMsgBuf* pMsgBuf) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* pMsgBuf) {
|
||||
int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* pMsgBuf, char** pOutput, int32_t* len, SEpSet* pEpSet) {
|
||||
const char* msg1 = "invalid table name";
|
||||
const char* msg2 = "tags number not matched";
|
||||
const char* msg3 = "tag value too long";
|
||||
|
@ -313,20 +314,17 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
|
|||
return code;
|
||||
}
|
||||
|
||||
const char* pSTableName = tNameGetTableName(&name);
|
||||
|
||||
const char* pStableName = tNameGetTableName(&name);
|
||||
SArray* pValList = pCreateTableInfo->pTagVals;
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
||||
size_t valSize = taosArrayGetSize(pValList);
|
||||
size_t numOfInputTag = taosArrayGetSize(pValList);
|
||||
STableMeta* pSuperTableMeta = NULL;
|
||||
|
||||
char dbName[TSDB_DB_FNAME_LEN] = {0};
|
||||
tNameGetFullDbName(&name, dbName);
|
||||
|
||||
catalogGetTableMeta(pCtx->pCatalog, pCtx->pTransporter, &pCtx->mgmtEpSet, dbName, pSTableName, &pSuperTableMeta);
|
||||
catalogGetTableMeta(pCtx->pCatalog, pCtx->pTransporter, &pCtx->mgmtEpSet, dbName, pStableName, &pSuperTableMeta);
|
||||
assert(pSuperTableMeta != NULL);
|
||||
|
||||
// too long tag values will return invalid sql, not be truncated automatically
|
||||
SSchema *pTagSchema = getTableTagSchema(pSuperTableMeta);
|
||||
|
@ -346,7 +344,7 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
|
|||
pNameList = pCreateTableInfo->pTagNames;
|
||||
nameSize = taosArrayGetSize(pNameList);
|
||||
|
||||
if (valSize != nameSize || schemaSize < valSize) {
|
||||
if (numOfInputTag != nameSize || schemaSize < numOfInputTag) {
|
||||
tdDestroyKVRowBuilder(&kvRowBuilder);
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg2);
|
||||
}
|
||||
|
@ -422,33 +420,36 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (schemaSize != valSize) {
|
||||
if (schemaSize != numOfInputTag) {
|
||||
tdDestroyKVRowBuilder(&kvRowBuilder);
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg2);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < valSize; ++i) {
|
||||
for (int32_t i = 0; i < numOfInputTag; ++i) {
|
||||
SSchema *pSchema = &pTagSchema[i];
|
||||
SListItem *pItem = taosArrayGet(pValList, i);
|
||||
SToken* pItem = taosArrayGet(pValList, i);
|
||||
|
||||
char tagVal[TSDB_MAX_TAGS_LEN];
|
||||
if (pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) {
|
||||
if (pItem->pVar.nLen > pSchema->bytes) {
|
||||
if (pItem->n > pSchema->bytes) {
|
||||
tdDestroyKVRowBuilder(&kvRowBuilder);
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg3);
|
||||
}
|
||||
} else if (pSchema->type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
if (pItem->pVar.nType == TSDB_DATA_TYPE_BINARY) {
|
||||
// code = convertTimestampStrToInt64(&(pItem->pVar), tinfo.precision);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg4);
|
||||
}
|
||||
} else if (pItem->pVar.nType == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
pItem->pVar.i = convertTimePrecision(pItem->pVar.i, TSDB_TIME_PRECISION_NANO, tinfo.precision);
|
||||
}
|
||||
// if (pItem->pVar.nType == TSDB_DATA_TYPE_BINARY) {
|
||||
//// code = convertTimestampStrToInt64(&(pItem->pVar), tinfo.precision);
|
||||
// if (code != TSDB_CODE_SUCCESS) {
|
||||
// return buildInvalidOperationMsg(pMsgBuf, msg4);
|
||||
// }
|
||||
// } else if (pItem->pVar.nType == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
// pItem->pVar.i = convertTimePrecision(pItem->pVar.i, TSDB_TIME_PRECISION_NANO, tinfo.precision);
|
||||
// }
|
||||
}
|
||||
|
||||
code = taosVariantDump(&(pItem->pVar), tagVal, pSchema->type, true);
|
||||
char* endPtr = NULL;
|
||||
int64_t v = strtoll(pItem->z, &endPtr, 10);
|
||||
*(int32_t*) tagVal = v;
|
||||
// code = taosVariantDump(&(pItem->pVar), tagVal, pSchema->type, true);
|
||||
|
||||
// check again after the convert since it may be converted from binary to nchar.
|
||||
if (pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) {
|
||||
|
@ -473,33 +474,37 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
|
|||
if (row == NULL) {
|
||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
}
|
||||
tdSortKVRowByColIdx(row);
|
||||
pTag->dataLen = kvRowLen(row);
|
||||
|
||||
if (pTag->data == NULL) {
|
||||
pTag->data = malloc(pTag->dataLen);
|
||||
tdSortKVRowByColIdx(row);
|
||||
|
||||
SName tableName = {0};
|
||||
code = createSName(&tableName, &pCreateTableInfo->name, pCtx, pMsgBuf);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
||||
kvRowCpy(pTag->data, row);
|
||||
free(row);
|
||||
struct SVCreateTbReq req = {0};
|
||||
req.type = TD_CHILD_TABLE;
|
||||
req.name = strdup(tNameGetTableName(&tableName));
|
||||
req.ctbCfg.suid = pSuperTableMeta->suid;
|
||||
req.ctbCfg.pTag = row;
|
||||
|
||||
bool dbIncluded2 = false;
|
||||
// table name
|
||||
// if (tscValidateName(&(pCreateTableInfo->name), true, &dbIncluded2) != TSDB_CODE_SUCCESS) {
|
||||
// return buildInvalidOperationMsg(pMsgBuf, msg1);
|
||||
// }
|
||||
int32_t serLen = tSerializeSVCreateTbReq(NULL, &req);
|
||||
char* buf1 = calloc(1, serLen);
|
||||
char* p = buf1;
|
||||
tSerializeSVCreateTbReq((void*) &buf1, &req);
|
||||
*pOutput = p;
|
||||
*len = serLen;
|
||||
|
||||
// STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, TABLE_INDEX);
|
||||
// code = tscSetTableFullName(&pTableMetaInfo->name, &pCreateTableInfo->name, pSql, dbIncluded2);
|
||||
// if (code != TSDB_CODE_SUCCESS) {
|
||||
// return code;
|
||||
// }
|
||||
SVgroupInfo info = {0};
|
||||
catalogGetTableHashVgroup(pCtx->pCatalog, pCtx->pTransporter, &pCtx->mgmtEpSet, dbName, req.name, &info);
|
||||
|
||||
// pCreateTableInfo->fullname = calloc(1, tNameLen(&pTableMetaInfo->name) + 1);
|
||||
// code = tNameExtractFullName(&pTableMetaInfo->name, pCreateTableInfo->fullname);
|
||||
// if (code != TSDB_CODE_SUCCESS) {
|
||||
// return buildInvalidOperationMsg(pMsgBuf, msg1);
|
||||
// }
|
||||
pEpSet->inUse = info.inUse;
|
||||
pEpSet->numOfEps = info.numOfEps;
|
||||
for(int32_t i = 0; i < pEpSet->numOfEps; ++i) {
|
||||
pEpSet->port[i] = info.epAddr[i].port;
|
||||
tstrncpy(pEpSet->fqdn[i], info.epAddr[i].fqdn, tListLen(pEpSet->fqdn[i]));
|
||||
}
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -696,10 +701,11 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm
|
|||
pDcl->pMsg = (char*)buildCreateTableMsg(pCreateTable, &pDcl->msgLen, pCtx, pMsgBuf);
|
||||
pDcl->msgType = (pCreateTable->type == TSQL_CREATE_TABLE)? TDMT_VND_CREATE_TABLE:TDMT_MND_CREATE_STB;
|
||||
} else if (pCreateTable->type == TSQL_CREATE_CTABLE) {
|
||||
if ((code = doCheckForCreateCTable(pInfo, pCtx, pMsgBuf)) != TSDB_CODE_SUCCESS) {
|
||||
if ((code = doCheckForCreateCTable(pInfo, pCtx, pMsgBuf, &pDcl->pMsg, &pDcl->msgLen, &pDcl->epSet)) != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
||||
pDcl->msgType = TDMT_VND_CREATE_TABLE;
|
||||
} else if (pCreateTable->type == TSQL_CREATE_STREAM) {
|
||||
// if ((code = doCheckForStream(pSql, pInfo)) != TSDB_CODE_SUCCESS) {
|
||||
// return code;
|
||||
|
|
|
@ -26,7 +26,7 @@ size_t getNumOfExprs(SQueryStmtInfo* pQueryInfo) {
|
|||
}
|
||||
|
||||
SSchema* getOneColumnSchema(const STableMeta* pTableMeta, int32_t colIndex) {
|
||||
assert(pTableMeta != NULL && pTableMeta->schema != NULL && colIndex >= 0 && colIndex < getNumOfColumns(pTableMeta));
|
||||
assert(pTableMeta != NULL && pTableMeta->schema != NULL && colIndex >= 0 && colIndex < (getNumOfColumns(pTableMeta) + getNumOfTags(pTableMeta)));
|
||||
|
||||
SSchema* pSchema = (SSchema*) pTableMeta->schema;
|
||||
return &pSchema[colIndex];
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -31,17 +31,17 @@ typedef struct SKeyword {
|
|||
static SKeyword keywordTable[] = {
|
||||
{"ID", TK_ID},
|
||||
{"BOOL", TK_BOOL},
|
||||
{"TINYINT", TK_TINYINT},
|
||||
{"SMALLINT", TK_SMALLINT},
|
||||
// {"TINYINT", TK_TINYINT},
|
||||
// {"SMALLINT", TK_SMALLINT},
|
||||
{"INTEGER", TK_INTEGER},
|
||||
{"INT", TK_INTEGER},
|
||||
{"BIGINT", TK_BIGINT},
|
||||
// {"BIGINT", TK_BIGINT},
|
||||
{"FLOAT", TK_FLOAT},
|
||||
{"DOUBLE", TK_DOUBLE},
|
||||
// {"DOUBLE", TK_DOUBLE},
|
||||
{"STRING", TK_STRING},
|
||||
{"TIMESTAMP", TK_TIMESTAMP},
|
||||
{"BINARY", TK_BINARY},
|
||||
{"NCHAR", TK_NCHAR},
|
||||
// {"BINARY", TK_BINARY},
|
||||
// {"NCHAR", TK_NCHAR},
|
||||
{"OR", TK_OR},
|
||||
{"AND", TK_AND},
|
||||
{"NOT", TK_NOT},
|
||||
|
|
Loading…
Reference in New Issue