aboutsummaryrefslogtreecommitdiff
path: root/ext/misc/csv.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2017-08-08 20:03:10 +0000
committerdrh <drh@noemail.net>2017-08-08 20:03:10 +0000
commit4f57352937d848b35bbc7ba44ff12dbd12e12995 (patch)
tree1a45d869eccad76823284150f19747eb07ce52d9 /ext/misc/csv.c
parentb46dfdb81c036085ea47341ac009c36fcbcb8d34 (diff)
downloadsqlite-4f57352937d848b35bbc7ba44ff12dbd12e12995.tar.gz
sqlite-4f57352937d848b35bbc7ba44ff12dbd12e12995.zip
Enhance the CSV virtual table extension so that it accepts the last row of
the CSV file even if the last row omits the closing \n, as long as the last row has a full set of columns. FossilOrigin-Name: 537e3be2e9503183799afffcd91defc751fea2c779e9b77b77f9485f7de5d170
Diffstat (limited to 'ext/misc/csv.c')
-rw-r--r--ext/misc/csv.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/ext/misc/csv.c b/ext/misc/csv.c
index 6d9963427..1eafc3a41 100644
--- a/ext/misc/csv.c
+++ b/ext/misc/csv.c
@@ -680,16 +680,16 @@ static int csvtabNext(sqlite3_vtab_cursor *cur){
i++;
}
}while( pCur->rdr.cTerm==',' );
- while( i<pTab->nCol ){
- sqlite3_free(pCur->azVal[i]);
- pCur->azVal[i] = 0;
- pCur->aLen[i] = 0;
- i++;
- }
- if( z==0 || pCur->rdr.cTerm==EOF ){
+ if( z==0 || (pCur->rdr.cTerm==EOF && i<pTab->nCol) ){
pCur->iRowid = -1;
}else{
pCur->iRowid++;
+ while( i<pTab->nCol ){
+ sqlite3_free(pCur->azVal[i]);
+ pCur->azVal[i] = 0;
+ pCur->aLen[i] = 0;
+ i++;
+ }
}
return SQLITE_OK;
}