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_field_count(TAOS_RES *res);
|
||||||
DLL_EXPORT int taos_num_fields(TAOS_RES *res);
|
DLL_EXPORT int taos_num_fields(TAOS_RES *res);
|
||||||
DLL_EXPORT int taos_affected_rows(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 TAOS_FIELD *taos_fetch_fields(TAOS_RES *res);
|
||||||
DLL_EXPORT int taos_select_db(TAOS *taos, const char *db);
|
DLL_EXPORT int taos_select_db(TAOS *taos, const char *db);
|
||||||
|
|
|
@ -171,9 +171,9 @@ typedef struct SReqResultInfo {
|
||||||
char** convertBuf;
|
char** convertBuf;
|
||||||
TAOS_ROW row;
|
TAOS_ROW row;
|
||||||
SResultColumn* pCol;
|
SResultColumn* pCol;
|
||||||
uint32_t numOfRows;
|
uint64_t numOfRows;
|
||||||
uint64_t totalRows;
|
uint64_t totalRows;
|
||||||
uint32_t current;
|
uint64_t current;
|
||||||
bool localResultFetched;
|
bool localResultFetched;
|
||||||
bool completed;
|
bool completed;
|
||||||
int32_t precision;
|
int32_t precision;
|
||||||
|
|
|
@ -438,11 +438,23 @@ const char *taos_data_type(int type) {
|
||||||
|
|
||||||
const char *taos_get_client_info() { return version; }
|
const char *taos_get_client_info() { return version; }
|
||||||
|
|
||||||
|
// return int32_t
|
||||||
int taos_affected_rows(TAOS_RES *res) {
|
int taos_affected_rows(TAOS_RES *res) {
|
||||||
if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res) || TD_RES_TMQ_METADATA(res)) {
|
if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res) || TD_RES_TMQ_METADATA(res)) {
|
||||||
return 0;
|
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;
|
SRequestObj *pRequest = (SRequestObj *)res;
|
||||||
SReqResultInfo *pResInfo = &pRequest->body.resInfo;
|
SReqResultInfo *pResInfo = &pRequest->body.resInfo;
|
||||||
return pResInfo->numOfRows;
|
return pResInfo->numOfRows;
|
||||||
|
|
|
@ -189,7 +189,7 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
|
||||||
}
|
}
|
||||||
SDataCacheEntry* pEntry = (SDataCacheEntry*)(pDispatcher->nextOutput.pData);
|
SDataCacheEntry* pEntry = (SDataCacheEntry*)(pDispatcher->nextOutput.pData);
|
||||||
memcpy(pOutput->pData, pEntry->data, pEntry->dataLen);
|
memcpy(pOutput->pData, pEntry->data, pEntry->dataLen);
|
||||||
pOutput->numOfRows = pEntry->numOfRows;
|
pOutput->fr = pEntry->numOfRows;
|
||||||
pOutput->numOfCols = pEntry->numOfCols;
|
pOutput->numOfCols = pEntry->numOfCols;
|
||||||
pOutput->compressed = pEntry->compressed;
|
pOutput->compressed = pEntry->compressed;
|
||||||
|
|
||||||
|
|
|
@ -214,6 +214,18 @@ void shellRunSingleCommandImp(char *command) {
|
||||||
return;
|
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);
|
TAOS_FIELD *pFields = taos_fetch_fields(pSql);
|
||||||
if (pFields != NULL) { // select and show kinds of commands
|
if (pFields != NULL) { // select and show kinds of commands
|
||||||
int32_t error_no = 0;
|
int32_t error_no = 0;
|
||||||
|
@ -229,10 +241,10 @@ void shellRunSingleCommandImp(char *command) {
|
||||||
}
|
}
|
||||||
taos_free_result(pSql);
|
taos_free_result(pSql);
|
||||||
} else {
|
} else {
|
||||||
int32_t num_rows_affacted = taos_affected_rows(pSql);
|
int64_t num_rows_affacted = taos_affected_rows64(pSql);
|
||||||
taos_free_result(pSql);
|
taos_free_result(pSql);
|
||||||
et = taosGetTimestampUs();
|
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
|
// call auto tab
|
||||||
callbackAutoTab(command, NULL, false);
|
callbackAutoTab(command, NULL, false);
|
||||||
|
|
Loading…
Reference in New Issue