提交 90697d04 编写于 作者: dengyihao's avatar dengyihao

bugfix TD-690

上级 1886b9c9
......@@ -752,6 +752,10 @@ static bool validateTableColumnInfo(tFieldList* pFieldList, SSqlCmd* pCmd) {
int32_t nLen = 0;
for (int32_t i = 0; i < pFieldList->nField; ++i) {
if (pFieldList->p[i].bytes == 0) {
invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg5);
return false;
}
nLen += pFieldList->p[i].bytes;
}
......@@ -808,6 +812,10 @@ static bool validateTagParams(tFieldList* pTagsList, tFieldList* pFieldList, SSq
int32_t nLen = 0;
for (int32_t i = 0; i < pTagsList->nField; ++i) {
if (pTagsList->p[i].bytes == 0) {
invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg7);
return false;
}
nLen += pTagsList->p[i].bytes;
}
......
......@@ -251,12 +251,20 @@ alter_db_optr(Y) ::= alter_db_optr(Z) comp(X). { Y = Z; Y.compressionLeve
alter_db_optr(Y) ::= alter_db_optr(Z) wal(X). { Y = Z; Y.walLevel = strtol(X.z, NULL, 10); }
%type typename {TAOS_FIELD}
typename(A) ::= ids(X). { tSQLSetColumnType (&A, &X); }
typename(A) ::= ids(X). {
X.type = 0;
tSQLSetColumnType (&A, &X);
}
//define binary type, e.g., binary(10), nchar(10)
typename(A) ::= ids(X) LP signed(Y) RP. {
X.type = -Y; // negative value of name length
tSQLSetColumnType(&A, &X);
if (Y <= 0) {
X.type = 0;
tSQLSetColumnType(&A, &X);
} else {
X.type = -Y; // negative value of name length
tSQLSetColumnType(&A, &X);
}
}
%type signed {int64_t}
......
......@@ -497,10 +497,18 @@ void tSQLSetColumnType(TAOS_FIELD *pField, SSQLToken *type) {
* number of bytes in UCS-4 format, which is 4 times larger than the
* number of characters
*/
pField->bytes = -(int32_t)type->type * TSDB_NCHAR_SIZE + LENGTH_SIZE_OF_STR;
if (type->type == 0) {
pField->bytes = 0;
} else {
pField->bytes = -(int32_t)type->type * TSDB_NCHAR_SIZE + LENGTH_SIZE_OF_STR;
}
} else if (i == TSDB_DATA_TYPE_BINARY) {
/* for binary, the TOKENTYPE is the length of binary */
pField->bytes = -(int32_t) type->type + LENGTH_SIZE_OF_STR;
if (type->type == 0) {
pField->bytes = 0;
} else {
pField->bytes = -(int32_t) type->type + LENGTH_SIZE_OF_STR;
}
}
break;
}
......
......@@ -25,17 +25,17 @@
#include <stdio.h>
/************ Begin %include sections from the grammar ************************/
#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdbool.h>
#include "tutil.h"
#include "qsqlparser.h"
#include "tstoken.h"
#include "tutil.h"
#include "tvariant.h"
#include "ttokendef.h"
#include "qsqltype.h"
/**************** End of %include directives **********************************/
/* These constants specify the various numeric values for terminal symbols
** in a format understandable to "makeheaders". This section is blank unless
......@@ -2262,13 +2262,21 @@ static void yy_reduce(
{ setDefaultCreateDbOption(&yymsp[1].minor.yy374);}
break;
case 102: /* typename ::= ids */
{ tSQLSetColumnType (&yylhsminor.yy325, &yymsp[0].minor.yy0); }
{
yymsp[0].minor.yy0.type = 0;
tSQLSetColumnType (&yylhsminor.yy325, &yymsp[0].minor.yy0);
}
yymsp[0].minor.yy325 = yylhsminor.yy325;
break;
case 103: /* typename ::= ids LP signed RP */
{
yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy279; // negative value of name length
tSQLSetColumnType(&yylhsminor.yy325, &yymsp[-3].minor.yy0);
if (yymsp[-1].minor.yy279 <= 0) {
yymsp[-3].minor.yy0.type = 0;
tSQLSetColumnType(&yylhsminor.yy325, &yymsp[-3].minor.yy0);
} else {
yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy279; // negative value of name length
tSQLSetColumnType(&yylhsminor.yy325, &yymsp[-3].minor.yy0);
}
}
yymsp[-3].minor.yy325 = yylhsminor.yy325;
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册