feat(shell): supported affected rows int64_t
This commit is contained in:
parent
4f8c04cf79
commit
39482b24db
|
@ -185,6 +185,7 @@ DLL_EXPORT void taos_kill_query(TAOS *taos);
|
|||
DLL_EXPORT int taos_field_count(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_num_fields(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_affected_rows(TAOS_RES *res);
|
||||
DLL_EXPORT int64_t taos_affected_rows64(TAOS_RES *res);
|
||||
|
||||
DLL_EXPORT TAOS_FIELD *taos_fetch_fields(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_select_db(TAOS *taos, const char *db);
|
||||
|
|
|
@ -171,9 +171,9 @@ typedef struct SReqResultInfo {
|
|||
char** convertBuf;
|
||||
TAOS_ROW row;
|
||||
SResultColumn* pCol;
|
||||
uint32_t numOfRows;
|
||||
uint64_t numOfRows;
|
||||
uint64_t totalRows;
|
||||
uint32_t current;
|
||||
uint64_t current;
|
||||
bool localResultFetched;
|
||||
bool completed;
|
||||
int32_t precision;
|
||||
|
|
|
@ -438,11 +438,23 @@ const char *taos_data_type(int type) {
|
|||
|
||||
const char *taos_get_client_info() { return version; }
|
||||
|
||||
// return int32_t
|
||||
int taos_affected_rows(TAOS_RES *res) {
|
||||
if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res) || TD_RES_TMQ_METADATA(res)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SRequestObj *pRequest = (SRequestObj *)res;
|
||||
SReqResultInfo *pResInfo = &pRequest->body.resInfo;
|
||||
return (int)pResInfo->numOfRows;
|
||||
}
|
||||
|
||||
// return int64_t
|
||||
int64_t taos_affected_rows(TAOS_RES *res) {
|
||||
if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res) || TD_RES_TMQ_METADATA(res)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SRequestObj *pRequest = (SRequestObj *)res;
|
||||
SReqResultInfo *pResInfo = &pRequest->body.resInfo;
|
||||
return pResInfo->numOfRows;
|
||||
|
|
|
@ -189,7 +189,7 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
|
|||
}
|
||||
SDataCacheEntry* pEntry = (SDataCacheEntry*)(pDispatcher->nextOutput.pData);
|
||||
memcpy(pOutput->pData, pEntry->data, pEntry->dataLen);
|
||||
pOutput->numOfRows = pEntry->numOfRows;
|
||||
pOutput->fr = pEntry->numOfRows;
|
||||
pOutput->numOfCols = pEntry->numOfCols;
|
||||
pOutput->compressed = pEntry->compressed;
|
||||
|
||||
|
|
|
@ -214,6 +214,18 @@ void shellRunSingleCommandImp(char *command) {
|
|||
return;
|
||||
}
|
||||
|
||||
// pre string
|
||||
char * pre = "Query OK";
|
||||
if (shellRegexMatch(command, "^\\s*delete\\s*from\\s*.*", REG_EXTENDED | REG_ICASE)) {
|
||||
pre = "Deleted OK";
|
||||
} else if(shellRegexMatch(command, "^\\s*insert\\s*into\\s*.*", REG_EXTENDED | REG_ICASE)) {
|
||||
pre = "Inserted OK";
|
||||
} else if(shellRegexMatch(command, "^\\s*create\\s*.*", REG_EXTENDED | REG_ICASE)) {
|
||||
pre = "Created OK";
|
||||
} else if(shellRegexMatch(command, "^\\s*drop\\s*.*", REG_EXTENDED | REG_ICASE)) {
|
||||
pre = "Droped OK";
|
||||
}
|
||||
|
||||
TAOS_FIELD *pFields = taos_fetch_fields(pSql);
|
||||
if (pFields != NULL) { // select and show kinds of commands
|
||||
int32_t error_no = 0;
|
||||
|
@ -229,10 +241,10 @@ void shellRunSingleCommandImp(char *command) {
|
|||
}
|
||||
taos_free_result(pSql);
|
||||
} else {
|
||||
int32_t num_rows_affacted = taos_affected_rows(pSql);
|
||||
int64_t num_rows_affacted = taos_affected_rows64(pSql);
|
||||
taos_free_result(pSql);
|
||||
et = taosGetTimestampUs();
|
||||
printf("Query OK, %d row(s) affected (%.6fs)\r\n", num_rows_affacted, (et - st) / 1E6);
|
||||
printf("%s, %" PRId64 " row(s) affected (%.6fs)\r\n", num_rows_affacted, (et - st) / 1E6);
|
||||
|
||||
// call auto tab
|
||||
callbackAutoTab(command, NULL, false);
|
||||
|
|
Loading…
Reference in New Issue