fix:describe cannot get tag value
This commit is contained in:
parent
fa1ef5cf6f
commit
d03b77ef02
|
@ -720,6 +720,57 @@ void taosDumpCreateMTableClause(STableDef *tableDes, char *metric, int numOfCols
|
||||||
count_temp = counter;
|
count_temp = counter;
|
||||||
|
|
||||||
for (; counter < numOfCols; counter++) {
|
for (; counter < numOfCols; counter++) {
|
||||||
|
TAOS_ROW row = NULL;
|
||||||
|
|
||||||
|
sprintf(command, "select %s from %s limit 1", tableDes->cols[counter].field, tableDes->name);
|
||||||
|
if (taos_query(taos, command) != 0) {
|
||||||
|
fprintf(stderr, "failed to run command %s\n", command);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = taos_use_result(taos);
|
||||||
|
if (result == NULL) {
|
||||||
|
fprintf(stderr, "failed to use result\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAOS_FIELD *fields = taos_fetch_fields(result);
|
||||||
|
|
||||||
|
row = taos_fetch_row(result);
|
||||||
|
switch (fields[0].type) {
|
||||||
|
case TSDB_DATA_TYPE_BOOL:
|
||||||
|
sprintf(tableDes->cols[counter].note, "%d", ((((int)(*((char *)row[0]))) == 1) ? 1 : 0));
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_TINYINT:
|
||||||
|
sprintf(tableDes->cols[counter].note, "%d", (int)(*((char *)row[0])));
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_SMALLINT:
|
||||||
|
sprintf(tableDes->cols[counter].note, "%d", (int)(*((short *)row[0])));
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_INT:
|
||||||
|
sprintf(tableDes->cols[counter].note, "%d", *((int *)row[0]));
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_BIGINT:
|
||||||
|
sprintf(tableDes->cols[counter].note, "%" PRId64 "", *((int64_t *)row[0]));
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_FLOAT:
|
||||||
|
sprintf(tableDes->cols[counter].note, "%f", GET_FLOAT_VAL(row[0]));
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
|
sprintf(tableDes->cols[counter].note, "%f", GET_DOUBLE_VAL(row[0]));
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||||
|
sprintf(tableDes->cols[counter].note, "%" PRId64 "", *(int64_t *)row[0]);
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_BINARY:
|
||||||
|
case TSDB_DATA_TYPE_NCHAR:
|
||||||
|
default:
|
||||||
|
strncpy(tableDes->cols[counter].note, (char *)row[0], fields[0].bytes);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
taos_free_result(result);
|
||||||
|
|
||||||
if (counter != count_temp) {
|
if (counter != count_temp) {
|
||||||
if (strcasecmp(tableDes->cols[counter].type, "binary") == 0 ||
|
if (strcasecmp(tableDes->cols[counter].type, "binary") == 0 ||
|
||||||
strcasecmp(tableDes->cols[counter].type, "nchar") == 0) {
|
strcasecmp(tableDes->cols[counter].type, "nchar") == 0) {
|
||||||
|
|
Loading…
Reference in New Issue