diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index 0a7a1a67949a3f0cccf923e745859f7c0692dda3..96aa3ef711c20d7ef75c8fe74187751614a7fe3b 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -636,9 +636,9 @@ static int32_t tscRebuildDDLForNormalTable(SSqlObj *pSql, const char *tableName, if (type == TSDB_DATA_TYPE_NCHAR) { bytes = bytes/TSDB_NCHAR_SIZE; } - snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s %s(%d),", pSchema[i].name, tDataTypes[pSchema[i].type].name, bytes); + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "`%s` %s(%d),", pSchema[i].name, tDataTypes[pSchema[i].type].name, bytes); } else { - snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s %s,", pSchema[i].name, tDataTypes[pSchema[i].type].name); + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "`%s` %s,", pSchema[i].name, tDataTypes[pSchema[i].type].name); } } sprintf(result + strlen(result) - 1, "%s", ")"); @@ -663,9 +663,9 @@ static int32_t tscRebuildDDLForSuperTable(SSqlObj *pSql, const char *tableName, if (type == TSDB_DATA_TYPE_NCHAR) { bytes = bytes/TSDB_NCHAR_SIZE; } - snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result),"%s %s(%d),", pSchema[i].name,tDataTypes[pSchema[i].type].name, bytes); + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result),"`%s` %s(%d),", pSchema[i].name,tDataTypes[pSchema[i].type].name, bytes); } else { - snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s %s,", pSchema[i].name, tDataTypes[type].name); + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "`%s` %s,", pSchema[i].name, tDataTypes[type].name); } } snprintf(result + strlen(result) - 1, TSDB_MAX_BINARY_LEN - strlen(result), "%s %s", ")", "TAGS ("); @@ -677,9 +677,9 @@ static int32_t tscRebuildDDLForSuperTable(SSqlObj *pSql, const char *tableName, if (type == TSDB_DATA_TYPE_NCHAR) { bytes = bytes/TSDB_NCHAR_SIZE; } - snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s %s(%d),", pSchema[i].name,tDataTypes[pSchema[i].type].name, bytes); + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "`%s` %s(%d),", pSchema[i].name,tDataTypes[pSchema[i].type].name, bytes); } else { - snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s %s,", pSchema[i].name, tDataTypes[type].name); + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "`%s` %s,", pSchema[i].name, tDataTypes[type].name); } } sprintf(result + strlen(result) - 1, "%s", ")"); diff --git a/tests/script/general/parser/columnName_escape.sim b/tests/script/general/parser/columnName_escape.sim index dd3278d0dc98fa5378b7aed122dc39f6717372d5..13ad184518f18096d0d2088957fca28c19fbd86c 100644 --- a/tests/script/general/parser/columnName_escape.sim +++ b/tests/script/general/parser/columnName_escape.sim @@ -423,4 +423,48 @@ if $data04 != 1 then return -1 endi +print ======================= test show create table/stable +sql create table tb3 (ts timestamp, `123` int, `123 456` int, `123.abc` int) +sql create table stb3 (ts timestamp, `123` int, `123 456` int, `123.abc` int) tags (t1 int) +sql create table ctb3 using stb3 tags (1) + +sql show create table tb3; +if $rows != 1 then + return -1 +endi + +if $data00 != @tb3@ then + return -1 +endi + +if $data01 != @create table `tb3` (`ts` TIMESTAMP,`123` INT,`123 456` INT,`123.abc` INT)@ then + return -1 +endi + +sql show create stable stb3; +if $rows != 1 then + return -1 +endi + +if $data00 != @stb3@ then + return -1 +endi + +if $data01 != @create table `stb3` (`ts` TIMESTAMP,`123` INT,`123 456` INT,`123.abc` INT) TAGS (`t1` INT)@ then + return -1 +endi + +sql show create table ctb3; +if $rows != 1 then + return -1 +endi + +if $data00 != @ctb3@ then + return -1 +endi + +if $data01 != @CREATE TABLE `ctb3` USING `stb3` TAGS (1)@ then + return -1 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/tagName_escape.sim b/tests/script/general/parser/tagName_escape.sim index 1dc9121a45ea23201d63dedfb7a6c446ee7b0e87..79073c335ef307770419f3b99736a70f94d73360 100644 --- a/tests/script/general/parser/tagName_escape.sim +++ b/tests/script/general/parser/tagName_escape.sim @@ -203,5 +203,35 @@ if $data24 != NULL then return -1 endi +print ======================= test show create table/stable +sql create stable stb3 (ts timestamp, c0 int) tags (`123` int, `123 456` int, `123.abc` int) +sql create table ctb3 using stb3 (`123`, `123 456`, `123.abc`) tags (1, 1, 1) + +sql show create table stb3; +if $rows != 1 then + return -1 +endi + +if $data00 != @stb3@ then + return -1 +endi + +if $data01 != @create table `stb3` (`ts` TIMESTAMP,`c0` INT) TAGS (`123` INT,`123 456` INT,`123.abc` INT)@ then + return -1 +endi + +sql show create table ctb3; +if $rows != 1 then + return -1 +endi + +if $data00 != @ctb3@ then + return -1 +endi + +if $data01 != @CREATE TABLE `ctb3` USING `stb3` TAGS (1,1,1)@ then + return -1 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT