/ Check-in [537e3be2]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 537e3be2e9503183799afffcd91defc751fea2c779e9b77b77f9485f7de5d170
User & Date: drh 2017-08-08 20:03:10
Context
2017-08-08
21:30
Fix a faulty signed/unsigned character comparison in the LIKE optimization logic. check-in: f4a4b149 user: drh tags: trunk
20:03
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. check-in: 537e3be2 user: drh tags: trunk
2017-08-07
19:12
Avoid casting a value larger than 2^31 to a (size_t) or (SIZE_T) on systems where it is a 32-bit type. check-in: b26d7a1c user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/misc/csv.c.

   676    676           pCur->azVal[i] = zNew;
   677    677           pCur->aLen[i] = pCur->rdr.n+1;
   678    678         }
   679    679         memcpy(pCur->azVal[i], z, pCur->rdr.n+1);
   680    680         i++;
   681    681       }
   682    682     }while( pCur->rdr.cTerm==',' );
   683         -  while( i<pTab->nCol ){
   684         -    sqlite3_free(pCur->azVal[i]);
   685         -    pCur->azVal[i] = 0;
   686         -    pCur->aLen[i] = 0;
   687         -    i++;
   688         -  }
   689         -  if( z==0 || pCur->rdr.cTerm==EOF ){
          683  +  if( z==0 || (pCur->rdr.cTerm==EOF && i<pTab->nCol) ){
   690    684       pCur->iRowid = -1;
   691    685     }else{
   692    686       pCur->iRowid++;
          687  +    while( i<pTab->nCol ){
          688  +      sqlite3_free(pCur->azVal[i]);
          689  +      pCur->azVal[i] = 0;
          690  +      pCur->aLen[i] = 0;
          691  +      i++;
          692  +    }
   693    693     }
   694    694     return SQLITE_OK;
   695    695   }
   696    696   
   697    697   /*
   698    698   ** Return values of columns for the row at which the CsvCursor
   699    699   ** is currently pointing.