fix: add $cols to script support

This commit is contained in:
shenglian zhou 2023-09-22 13:29:17 +08:00
parent 80f77251b2
commit 1b71cd4b8d
2 changed files with 6 additions and 0 deletions

View File

@ -161,6 +161,7 @@ typedef struct _script_t {
bool killed;
void *taos;
char rows[12]; // number of rows data retrieved
char cols[12]; // number of columns data retrieved
char data[MAX_QUERY_ROW_NUM][MAX_QUERY_COL_NUM][MAX_QUERY_VALUE_LEN]; // query results
char system_exit_code[12];
char system_ret_content[MAX_SYSTEM_RESULT_LEN];

View File

@ -93,6 +93,8 @@ char *simGetVariable(SScript *script, char *varName, int32_t varLen) {
if (strncmp(varName, "rows", varLen) == 0) return script->rows;
if (strncmp(varName, "cols", varLen) == 0) return script->cols;
if (strncmp(varName, "system_exit", varLen) == 0) return script->system_exit_code;
if (strncmp(varName, "system_content", varLen) == 0) return script->system_ret_content;
@ -808,6 +810,7 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
taos_free_result(pSql);
sprintf(script->rows, "%d", numOfRows);
sprintf(script->cols, "%d", num_fields);
script->linePos++;
return true;
@ -822,6 +825,7 @@ bool simExecuteSqlImpCmd(SScript *script, char *rest, bool isSlow) {
simDebug("script:%s, exec:%s", script->fileName, rest);
strcpy(script->rows, "-1");
strcpy(script->cols, "-1");
for (int32_t row = 0; row < MAX_QUERY_ROW_NUM; ++row) {
for (int32_t col = 0; col < MAX_QUERY_COL_NUM; ++col) {
strcpy(script->data[row][col], "null");
@ -918,6 +922,7 @@ bool simExecuteSqlErrorCmd(SScript *script, char *rest) {
simDebug("script:%s, exec:%s", script->fileName, rest);
strcpy(script->rows, "-1");
strcpy(script->cols, "-1");
for (int32_t row = 0; row < MAX_QUERY_ROW_NUM; ++row) {
for (int32_t col = 0; col < MAX_QUERY_COL_NUM; ++col) {
strcpy(script->data[row][col], "null");