提交 909ca7ed 编写于 作者: H Haojun Liao

[TD-225]

上级 9487c1b9
...@@ -6060,19 +6060,20 @@ int32_t doCheckForCreateTable(SSqlObj* pSql, int32_t subClauseIndex, SSqlInfo* p ...@@ -6060,19 +6060,20 @@ int32_t doCheckForCreateTable(SSqlObj* pSql, int32_t subClauseIndex, SSqlInfo* p
size_t numOfFields = taosArrayGetSize(pFieldList); size_t numOfFields = taosArrayGetSize(pFieldList);
for (; col < numOfFields; ++col) { for (; col < numOfFields; ++col) {
TAOS_FIELD* p = taosArrayGet(pTagList, col); TAOS_FIELD* p = taosArrayGet(pFieldList, col);
tscFieldInfoAppend(&pQueryInfo->fieldsInfo, p); tscFieldInfoAppend(&pQueryInfo->fieldsInfo, p);
} }
pCmd->numOfCols = (int16_t)numOfFields; pCmd->numOfCols = (int16_t)numOfFields;
if (pTagList != NULL) { // create super table[optional] if (pTagList != NULL) { // create super table[optional]
for (int32_t i = 0; i < numOfFields; ++i) { size_t numOfTags = taosArrayGetSize(pTagList);
for (int32_t i = 0; i < numOfTags; ++i) {
TAOS_FIELD* p = taosArrayGet(pTagList, i); TAOS_FIELD* p = taosArrayGet(pTagList, i);
tscFieldInfoAppend(&pQueryInfo->fieldsInfo, p); tscFieldInfoAppend(&pQueryInfo->fieldsInfo, p);
} }
pCmd->count = numOfFields; pCmd->count = numOfTags;
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
......
...@@ -326,7 +326,7 @@ create_table_args(A) ::= AS select(S). { ...@@ -326,7 +326,7 @@ create_table_args(A) ::= AS select(S). {
%type column{TAOS_FIELD} %type column{TAOS_FIELD}
%type columnlist{SArray*} %type columnlist{SArray*}
%destructor columnlist {taosArrayDestroy($$);} %destructor columnlist {taosArrayDestroy($$);}
columnlist(A) ::= columnlist(X) COMMA column(Y). {A = taosArrayPush(X, &Y); } columnlist(A) ::= columnlist(X) COMMA column(Y). {taosArrayPush(X, &Y); A = X; }
columnlist(A) ::= column(X). {A = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(A, &X);} columnlist(A) ::= column(X). {A = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(A, &X);}
// The information used for a column is the name and type of column: // The information used for a column is the name and type of column:
...@@ -481,7 +481,7 @@ fill_opt(N) ::= FILL LP ID(Y) COMMA tagitemlist(X) RP. { ...@@ -481,7 +481,7 @@ fill_opt(N) ::= FILL LP ID(Y) COMMA tagitemlist(X) RP. {
toTSDBType(Y.type); toTSDBType(Y.type);
tVariantCreate(&A, &Y); tVariantCreate(&A, &Y);
taosArrayPush(X, &A); tVariantListInsert(X, &A, -1, 0);
N = X; N = X;
} }
...@@ -553,11 +553,11 @@ having_opt(A) ::= HAVING expr(X). {A = X;} ...@@ -553,11 +553,11 @@ having_opt(A) ::= HAVING expr(X). {A = X;}
//limit-offset subclause //limit-offset subclause
%type limit_opt {SLimitVal} %type limit_opt {SLimitVal}
limit_opt(A) ::= . {A.limit = -1; A.offset = 0;} limit_opt(A) ::= . {A.limit = -1; A.offset = 0;}
limit_opt(A) ::= LIMIT signed(X). {A.limit = X; A.offset = 0;} limit_opt(A) ::= LIMIT signed(X). {printf("aa1, %d\n", X); A.limit = X; A.offset = 0;}
limit_opt(A) ::= LIMIT signed(X) OFFSET signed(Y). limit_opt(A) ::= LIMIT signed(X) OFFSET signed(Y).
{A.limit = X; A.offset = Y;} {printf("aa2\n, %d\n", X); A.limit = X; A.offset = Y;}
limit_opt(A) ::= LIMIT signed(X) COMMA signed(Y). limit_opt(A) ::= LIMIT signed(X) COMMA signed(Y).
{A.limit = Y; A.offset = X;} {printf("aa3\n, %d\n", X); A.limit = Y; A.offset = X;}
%type slimit_opt {SLimitVal} %type slimit_opt {SLimitVal}
slimit_opt(A) ::= . {A.limit = -1; A.offset = 0;} slimit_opt(A) ::= . {A.limit = -1; A.offset = 0;}
......
...@@ -37,26 +37,34 @@ static int32_t setTagColumnInfo(SFillInfo* pFillInfo, int32_t numOfCols, int32_t ...@@ -37,26 +37,34 @@ static int32_t setTagColumnInfo(SFillInfo* pFillInfo, int32_t numOfCols, int32_t
if (TSDB_COL_IS_TAG(pColInfo->flag)) { if (TSDB_COL_IS_TAG(pColInfo->flag)) {
bool exists = false; bool exists = false;
int32_t index = -1;
for (int32_t j = 0; j < k; ++j) { for (int32_t j = 0; j < k; ++j) {
if (pFillInfo->pTags[j].col.colId == pColInfo->col.colId) { if (pFillInfo->pTags[j].col.colId == pColInfo->col.colId) {
exists = true; exists = true;
index = j;
break; break;
} }
} }
if (!exists) { if (!exists) {
pFillInfo->pTags[k].col.colId = pColInfo->col.colId; SSchema* pSchema = &pFillInfo->pTags[k].col;
pSchema->colId = pColInfo->col.colId;
pSchema->type = pColInfo->col.type;
pSchema->bytes = pColInfo->col.bytes;
pFillInfo->pTags[k].tagVal = calloc(1, pColInfo->col.bytes); pFillInfo->pTags[k].tagVal = calloc(1, pColInfo->col.bytes);
pColInfo->tagIndex = k; pColInfo->tagIndex = k;
k += 1; k += 1;
} else {
pColInfo->tagIndex = index;
} }
} }
rowsize += pColInfo->col.bytes; rowsize += pColInfo->col.bytes;
} }
assert(k < pFillInfo->numOfTags); assert(k <= pFillInfo->numOfTags);
return rowsize; return rowsize;
} }
......
...@@ -2365,7 +2365,7 @@ static void yy_reduce( ...@@ -2365,7 +2365,7 @@ static void yy_reduce(
} }
break; break;
case 117: /* columnlist ::= columnlist COMMA column */ case 117: /* columnlist ::= columnlist COMMA column */
{yylhsminor.yy347 = taosArrayPush(yymsp[-2].minor.yy347, &yymsp[0].minor.yy181); } {taosArrayPush(yymsp[-2].minor.yy347, &yymsp[0].minor.yy181); yylhsminor.yy347 = yymsp[-2].minor.yy347; }
yymsp[-2].minor.yy347 = yylhsminor.yy347; yymsp[-2].minor.yy347 = yylhsminor.yy347;
break; break;
case 118: /* columnlist ::= column */ case 118: /* columnlist ::= column */
...@@ -2612,15 +2612,21 @@ static void yy_reduce( ...@@ -2612,15 +2612,21 @@ static void yy_reduce(
{yymsp[1].minor.yy188.limit = -1; yymsp[1].minor.yy188.offset = 0;} {yymsp[1].minor.yy188.limit = -1; yymsp[1].minor.yy188.offset = 0;}
break; break;
case 174: /* limit_opt ::= LIMIT signed */ case 174: /* limit_opt ::= LIMIT signed */
case 178: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==178); {printf("aa1, %d\n", yymsp[0].minor.yy271); yymsp[-1].minor.yy188.limit = yymsp[0].minor.yy271; yymsp[-1].minor.yy188.offset = 0;}
{yymsp[-1].minor.yy188.limit = yymsp[0].minor.yy271; yymsp[-1].minor.yy188.offset = 0;}
break; break;
case 175: /* limit_opt ::= LIMIT signed OFFSET signed */ case 175: /* limit_opt ::= LIMIT signed OFFSET signed */
case 179: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ yytestcase(yyruleno==179); {printf("aa2\n, %d\n", yymsp[-2].minor.yy271); yymsp[-3].minor.yy188.limit = yymsp[-2].minor.yy271; yymsp[-3].minor.yy188.offset = yymsp[0].minor.yy271;}
{yymsp[-3].minor.yy188.limit = yymsp[-2].minor.yy271; yymsp[-3].minor.yy188.offset = yymsp[0].minor.yy271;}
break; break;
case 176: /* limit_opt ::= LIMIT signed COMMA signed */ case 176: /* limit_opt ::= LIMIT signed COMMA signed */
case 180: /* slimit_opt ::= SLIMIT signed COMMA signed */ yytestcase(yyruleno==180); {printf("aa3\n, %d\n", yymsp[-2].minor.yy271); yymsp[-3].minor.yy188.limit = yymsp[0].minor.yy271; yymsp[-3].minor.yy188.offset = yymsp[-2].minor.yy271;}
break;
case 178: /* slimit_opt ::= SLIMIT signed */
{yymsp[-1].minor.yy188.limit = yymsp[0].minor.yy271; yymsp[-1].minor.yy188.offset = 0;}
break;
case 179: /* slimit_opt ::= SLIMIT signed SOFFSET signed */
{yymsp[-3].minor.yy188.limit = yymsp[-2].minor.yy271; yymsp[-3].minor.yy188.offset = yymsp[0].minor.yy271;}
break;
case 180: /* slimit_opt ::= SLIMIT signed COMMA signed */
{yymsp[-3].minor.yy188.limit = yymsp[0].minor.yy271; yymsp[-3].minor.yy188.offset = yymsp[-2].minor.yy271;} {yymsp[-3].minor.yy188.limit = yymsp[0].minor.yy271; yymsp[-3].minor.yy188.offset = yymsp[-2].minor.yy271;}
break; break;
case 183: /* expr ::= LP expr RP */ case 183: /* expr ::= LP expr RP */
......
...@@ -194,6 +194,10 @@ void taosArrayDestroy(SArray* pArray) { ...@@ -194,6 +194,10 @@ void taosArrayDestroy(SArray* pArray) {
} }
void taosArrayDestroyEx(SArray* pArray, void (*fp)(void*)) { void taosArrayDestroyEx(SArray* pArray, void (*fp)(void*)) {
if (pArray == NULL) {
return;
}
if (fp == NULL) { if (fp == NULL) {
return taosArrayDestroy(pArray); return taosArrayDestroy(pArray);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册