提交 854ae073 编写于 作者: H Haojun Liao

[td-4147]<fix>: report error if the column name is too long.

上级 edbc123e
...@@ -589,13 +589,13 @@ void tSetDbName(SStrToken *pCpxName, SStrToken *pDb) { ...@@ -589,13 +589,13 @@ void tSetDbName(SStrToken *pCpxName, SStrToken *pDb) {
void tSetColumnInfo(TAOS_FIELD *pField, SStrToken *pName, TAOS_FIELD *pType) { void tSetColumnInfo(TAOS_FIELD *pField, SStrToken *pName, TAOS_FIELD *pType) {
int32_t maxLen = sizeof(pField->name) / sizeof(pField->name[0]); int32_t maxLen = sizeof(pField->name) / sizeof(pField->name[0]);
// truncate the column name // column name is too long, set the it to be invalid.
if ((int32_t)pName->n >= maxLen) { if ((int32_t) pName->n >= maxLen) {
pName->n = maxLen - 1; pName->n = -1;
} } else {
strncpy(pField->name, pName->z, pName->n); strncpy(pField->name, pName->z, pName->n);
pField->name[pName->n] = 0; pField->name[pName->n] = 0;
}
pField->type = pType->type; pField->type = pType->type;
if(!isValidDataType(pField->type)){ if(!isValidDataType(pField->type)){
......
...@@ -22,7 +22,7 @@ sql_error alter table mt1 change tag a 1 ...@@ -22,7 +22,7 @@ sql_error alter table mt1 change tag a 1
sql_error create table mtx1 (ts timestamp, c1 int) tags (123 int) sql_error create table mtx1 (ts timestamp, c1 int) tags (123 int)
sql create table mt2 (ts timestamp, c1 int) tags (abc012345678901234567890123456789012345678901234567890123456789def int) sql_error create table mt2 (ts timestamp, c1 int) tags (abc012345678901234567890123456789012345678901234567890123456789def int)
sql create table mt3 (ts timestamp, c1 int) tags (abc012345678901234567890123456789012345678901234567890123456789 int) sql create table mt3 (ts timestamp, c1 int) tags (abc012345678901234567890123456789012345678901234567890123456789 int)
sql_error alter table mt3 change tag abc012345678901234567890123456789012345678901234567890123456789 abcdefg012345678901234567890123456789012345678901234567890123456789 sql_error alter table mt3 change tag abc012345678901234567890123456789012345678901234567890123456789 abcdefg012345678901234567890123456789012345678901234567890123456789
sql alter table mt3 change tag abc012345678901234567890123456789012345678901234567890123456789 abcdefg0123456789012345678901234567890123456789 sql alter table mt3 change tag abc012345678901234567890123456789012345678901234567890123456789 abcdefg0123456789012345678901234567890123456789
......
...@@ -115,6 +115,9 @@ sql_error create table $tb (ts timestamp, $tags int) ...@@ -115,6 +115,9 @@ sql_error create table $tb (ts timestamp, $tags int)
sql_error create table $tb (ts timestamp, $sint int) sql_error create table $tb (ts timestamp, $sint int)
sql_error create table $tb (ts timestamp, $tint int) sql_error create table $tb (ts timestamp, $tint int)
sql_error create table $tb (ts timestamp, $nchar int) sql_error create table $tb (ts timestamp, $nchar int)
# too long column name
sql_error create table $tb (ts timestamp, abcde_123456789_123456789_123456789_123456789_123456789_123456789 int)
print illegal_column_names test passed print illegal_column_names test passed
# case5: chinese_char_in_table_support # case5: chinese_char_in_table_support
......
...@@ -119,4 +119,8 @@ if $rows != 4 then ...@@ -119,4 +119,8 @@ if $rows != 4 then
return -1 return -1
endi endi
print ================>td-4147
sql_error create table tx(ts timestamp, a1234_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789 int)
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册