未验证 提交 1041396a 编写于 作者: Y Yang Zhao 提交者: GitHub

[TD-10712]<fix>taosdemo escape character (#8320)

* add -E to --help

* add escape char to stable

* stable escape char
上级 f5d9a1cf
...@@ -800,6 +800,8 @@ static void printHelp() { ...@@ -800,6 +800,8 @@ static void printHelp() {
"Set the replica parameters of the database, By default use 1, min: 1, max: 3."); "Set the replica parameters of the database, By default use 1, min: 1, max: 3.");
printf("%s%s%s%s\n", indent, "-m, --table-prefix=TABLEPREFIX", "\t", printf("%s%s%s%s\n", indent, "-m, --table-prefix=TABLEPREFIX", "\t",
"Table prefix name. By default use 'd'."); "Table prefix name. By default use 'd'.");
printf("%s%s%s%s\n", indent, "-E, --escape-character", "\t",
"Use escape character for Both Stable and normmal table name");
printf("%s%s%s%s\n", indent, "-s, --sql-file=FILE", "\t\t", printf("%s%s%s%s\n", indent, "-s, --sql-file=FILE", "\t\t",
"The select sql file."); "The select sql file.");
printf("%s%s%s%s\n", indent, "-N, --normal-table", "\t\t", "Use normal table flag."); printf("%s%s%s%s\n", indent, "-N, --normal-table", "\t\t", "Use normal table flag.");
...@@ -3777,7 +3779,7 @@ static int calcRowLen(SSuperTable* superTbls) { ...@@ -3777,7 +3779,7 @@ static int calcRowLen(SSuperTable* superTbls) {
static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos, static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
char* dbName, char* stbName, char** childTblNameOfSuperTbl, char* dbName, char* stbName, char** childTblNameOfSuperTbl,
int64_t* childTblCountOfSuperTbl, int64_t limit, uint64_t offset) { int64_t* childTblCountOfSuperTbl, int64_t limit, uint64_t offset, bool escapChar) {
char command[1024] = "\0"; char command[1024] = "\0";
char limitBuf[100] = "\0"; char limitBuf[100] = "\0";
...@@ -3791,8 +3793,8 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos, ...@@ -3791,8 +3793,8 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
limit, offset); limit, offset);
//get all child table name use cmd: select tbname from superTblName; //get all child table name use cmd: select tbname from superTblName;
snprintf(command, 1024, "select tbname from %s.%s %s", snprintf(command, 1024, escapChar ? "select tbname from %s.`%s` %s" :
dbName, stbName, limitBuf); "select tbname from %s.%s %s", dbName, stbName, limitBuf);
res = taos_query(taos, command); res = taos_query(taos, command);
int32_t code = taos_errno(res); int32_t code = taos_errno(res);
...@@ -3863,7 +3865,7 @@ static int getAllChildNameOfSuperTable(TAOS * taos, char* dbName, ...@@ -3863,7 +3865,7 @@ static int getAllChildNameOfSuperTable(TAOS * taos, char* dbName,
return getChildNameOfSuperTableWithLimitAndOffset(taos, dbName, stbName, return getChildNameOfSuperTableWithLimitAndOffset(taos, dbName, stbName,
childTblNameOfSuperTbl, childTblCountOfSuperTbl, childTblNameOfSuperTbl, childTblCountOfSuperTbl,
-1, 0); -1, 0, false);
} }
static int getSuperTableFromServer(TAOS * taos, char* dbName, static int getSuperTableFromServer(TAOS * taos, char* dbName,
...@@ -4320,9 +4322,12 @@ static int createSuperTable( ...@@ -4320,9 +4322,12 @@ static int createSuperTable(
superTbl->lenOfTagOfOneRow = lenOfTagOfOneRow; superTbl->lenOfTagOfOneRow = lenOfTagOfOneRow;
snprintf(command, BUFFER_SIZE, snprintf(command, BUFFER_SIZE,
"CREATE TABLE IF NOT EXISTS %s.%s (ts TIMESTAMP%s) TAGS %s", superTbl->escapeChar ?
dbName, superTbl->stbName, cols, tags); "CREATE TABLE IF NOT EXISTS %s.`%s` (ts TIMESTAMP%s) TAGS %s":
"CREATE TABLE IF NOT EXISTS %s.%s (ts TIMESTAMP%s) TAGS %s",
dbName, superTbl->stbName, cols, tags);
if (0 != queryDbExec(taos, command, NO_INSERT_TYPE, false)) { if (0 != queryDbExec(taos, command, NO_INSERT_TYPE, false)) {
errorPrint2("create supertable %s failed!\n\n", errorPrint2("create supertable %s failed!\n\n",
superTbl->stbName); superTbl->stbName);
...@@ -10364,7 +10369,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, ...@@ -10364,7 +10369,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
db_name, stbInfo->stbName, db_name, stbInfo->stbName,
&stbInfo->childTblName, &childTblCount, &stbInfo->childTblName, &childTblCount,
limit, limit,
offset); offset, stbInfo->escapeChar);
ntables = childTblCount; ntables = childTblCount;
} else { } else {
ntables = g_args.ntables; ntables = g_args.ntables;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册