fix: a problem of auto-create-table insert statement
This commit is contained in:
parent
364250b857
commit
aa9d3ac521
|
@ -67,6 +67,13 @@ typedef struct SInsertParseContext {
|
||||||
SParseMetaCache* pMetaCache;
|
SParseMetaCache* pMetaCache;
|
||||||
} SInsertParseContext;
|
} SInsertParseContext;
|
||||||
|
|
||||||
|
typedef struct SInsertParseSyntaxCxt {
|
||||||
|
SParseContext* pComCxt;
|
||||||
|
char* pSql;
|
||||||
|
SMsgBuf msg;
|
||||||
|
SParseMetaCache* pMetaCache;
|
||||||
|
} SInsertParseSyntaxCxt;
|
||||||
|
|
||||||
typedef int32_t (*_row_append_fn_t)(SMsgBuf* pMsgBuf, const void* value, int32_t len, void* param);
|
typedef int32_t (*_row_append_fn_t)(SMsgBuf* pMsgBuf, const void* value, int32_t len, void* param);
|
||||||
|
|
||||||
static uint8_t TRUE_VALUE = (uint8_t)TSDB_TRUE;
|
static uint8_t TRUE_VALUE = (uint8_t)TSDB_TRUE;
|
||||||
|
@ -1098,11 +1105,24 @@ static int32_t storeTableMeta(SInsertParseContext* pCxt, SHashObj* pHash, SName*
|
||||||
return taosHashPut(pHash, pName, len, &pBackup, POINTER_BYTES);
|
return taosHashPut(pHash, pName, len, &pBackup, POINTER_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t skipUsingClause(SInsertParseSyntaxCxt* pCxt);
|
||||||
|
|
||||||
|
// pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)
|
||||||
|
static int32_t ignoreAutoCreateTableClause(SInsertParseContext* pCxt) {
|
||||||
|
SToken sToken;
|
||||||
|
NEXT_TOKEN(pCxt->pSql, sToken);
|
||||||
|
SInsertParseSyntaxCxt cxt = {.pComCxt = pCxt->pComCxt, .pSql = pCxt->pSql, .msg = pCxt->msg, .pMetaCache = NULL};
|
||||||
|
int32_t code = skipUsingClause(&cxt);
|
||||||
|
pCxt->pSql = cxt.pSql;
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
// pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)
|
// pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)
|
||||||
static int32_t parseUsingClause(SInsertParseContext* pCxt, SName* name, char* tbFName) {
|
static int32_t parseUsingClause(SInsertParseContext* pCxt, SName* name, char* tbFName) {
|
||||||
int32_t len = strlen(tbFName);
|
int32_t len = strlen(tbFName);
|
||||||
STableMeta** pMeta = taosHashGet(pCxt->pSubTableHashObj, tbFName, len);
|
STableMeta** pMeta = taosHashGet(pCxt->pSubTableHashObj, tbFName, len);
|
||||||
if (NULL != pMeta) {
|
if (NULL != pMeta) {
|
||||||
|
CHECK_CODE(ignoreAutoCreateTableClause(pCxt));
|
||||||
return cloneTableMeta(*pMeta, &pCxt->pTableMeta);
|
return cloneTableMeta(*pMeta, &pCxt->pTableMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1522,13 +1542,6 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery, SParseMetaCache
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct SInsertParseSyntaxCxt {
|
|
||||||
SParseContext* pComCxt;
|
|
||||||
char* pSql;
|
|
||||||
SMsgBuf msg;
|
|
||||||
SParseMetaCache* pMetaCache;
|
|
||||||
} SInsertParseSyntaxCxt;
|
|
||||||
|
|
||||||
static int32_t skipParentheses(SInsertParseSyntaxCxt* pCxt) {
|
static int32_t skipParentheses(SInsertParseSyntaxCxt* pCxt) {
|
||||||
SToken sToken;
|
SToken sToken;
|
||||||
int32_t expectRightParenthesis = 1;
|
int32_t expectRightParenthesis = 1;
|
||||||
|
|
|
@ -265,6 +265,11 @@ TEST_F(InsertTest, autoCreateTableTest) {
|
||||||
"insert into st1s1 using st1 (tag1, tag2) tags(1, 'wxy') values (now, 1, \"beijing\")"
|
"insert into st1s1 using st1 (tag1, tag2) tags(1, 'wxy') values (now, 1, \"beijing\")"
|
||||||
"(now+1s, 2, \"shanghai\")(now+2s, 3, \"guangzhou\")");
|
"(now+1s, 2, \"shanghai\")(now+2s, 3, \"guangzhou\")");
|
||||||
ASSERT_EQ(runAsync(), TSDB_CODE_SUCCESS);
|
ASSERT_EQ(runAsync(), TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
bind(
|
||||||
|
"insert into st1s1 using st1 tags(1, 'wxy', now) values (now, 1, \"beijing\")"
|
||||||
|
"st1s1 using st1 tags(1, 'wxy', now) values (now+1s, 2, \"shanghai\")");
|
||||||
|
ASSERT_EQ(run(), TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InsertTest, toleranceTest) {
|
TEST_F(InsertTest, toleranceTest) {
|
||||||
|
|
Loading…
Reference in New Issue