Merge pull request #56 from plum-lihui/master
insert into multiple tables with file, return the wrong affected rows
This commit is contained in:
commit
7fa03ddff2
|
@ -1036,7 +1036,8 @@ static int tscInsertDataFromFile(SSqlObj* pSql, FILE* fp) {
|
||||||
// TODO : import data from file
|
// TODO : import data from file
|
||||||
int readLen = 0;
|
int readLen = 0;
|
||||||
char* line = NULL;
|
char* line = NULL;
|
||||||
size_t len = 0;
|
size_t n = 0;
|
||||||
|
int len = 0;
|
||||||
uint32_t maxRows = 0;
|
uint32_t maxRows = 0;
|
||||||
SSqlCmd* pCmd = &pSql->cmd;
|
SSqlCmd* pCmd = &pSql->cmd;
|
||||||
char* pStart = pCmd->payload + tsInsertHeadSize;
|
char* pStart = pCmd->payload + tsInsertHeadSize;
|
||||||
|
@ -1059,9 +1060,11 @@ static int tscInsertDataFromFile(SSqlObj* pSql, FILE* fp) {
|
||||||
|
|
||||||
tscSetAllColumnsHasValue(&spd, pSchema, pCmd->pMeterMeta->numOfColumns);
|
tscSetAllColumnsHasValue(&spd, pSchema, pCmd->pMeterMeta->numOfColumns);
|
||||||
|
|
||||||
while ((readLen = getline(&line, &len, fp)) != -1) {
|
while ((readLen = getline(&line, &n, fp)) != -1) {
|
||||||
// line[--readLen] = '\0';
|
// line[--readLen] = '\0';
|
||||||
if (('\r' == line[readLen - 1]) || ('\n' == line[readLen - 1])) line[--readLen] = 0;
|
if (('\r' == line[readLen - 1]) || ('\n' == line[readLen - 1])) line[--readLen] = 0;
|
||||||
|
if (readLen <= 0 ) continue;
|
||||||
|
|
||||||
char* lineptr = line;
|
char* lineptr = line;
|
||||||
strtolower(line, line);
|
strtolower(line, line);
|
||||||
len = tsParseOneRowData(&lineptr, pStart, pSchema, &spd, error, pCmd->pMeterMeta->precision);
|
len = tsParseOneRowData(&lineptr, pStart, pSchema, &spd, error, pCmd->pMeterMeta->precision);
|
||||||
|
@ -1074,6 +1077,7 @@ static int tscInsertDataFromFile(SSqlObj* pSql, FILE* fp) {
|
||||||
pCmd->payloadLen = (pStart - pCmd->payload);
|
pCmd->payloadLen = (pStart - pCmd->payload);
|
||||||
pBlock->sid = htonl(pMeterMeta->sid);
|
pBlock->sid = htonl(pMeterMeta->sid);
|
||||||
pBlock->numOfRows = htons(count);
|
pBlock->numOfRows = htons(count);
|
||||||
|
pSql->res.numOfRows = 0;
|
||||||
if (tscProcessSql(pSql) != 0) {
|
if (tscProcessSql(pSql) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1090,6 +1094,7 @@ static int tscInsertDataFromFile(SSqlObj* pSql, FILE* fp) {
|
||||||
pCmd->payloadLen = (pStart - pCmd->payload);
|
pCmd->payloadLen = (pStart - pCmd->payload);
|
||||||
pBlock->sid = htonl(pMeterMeta->sid);
|
pBlock->sid = htonl(pMeterMeta->sid);
|
||||||
pBlock->numOfRows = htons(count);
|
pBlock->numOfRows = htons(count);
|
||||||
|
pSql->res.numOfRows = 0;
|
||||||
if (tscProcessSql(pSql) != 0) {
|
if (tscProcessSql(pSql) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue