/ Check-in [537e3be2]
Login

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 Unified Diffs Ignore Whitespace Patch

Changes to ext/misc/csv.c.

676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692






693
694
695
696
697
698
699
        pCur->azVal[i] = zNew;
        pCur->aLen[i] = pCur->rdr.n+1;
      }
      memcpy(pCur->azVal[i], z, pCur->rdr.n+1);
      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 ){
    pCur->iRowid = -1;
  }else{
    pCur->iRowid++;






  }
  return SQLITE_OK;
}

/*
** Return values of columns for the row at which the CsvCursor
** is currently pointing.







<
<
<
<
<
<
|



>
>
>
>
>
>







676
677
678
679
680
681
682






683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
        pCur->azVal[i] = zNew;
        pCur->aLen[i] = pCur->rdr.n+1;
      }
      memcpy(pCur->azVal[i], z, pCur->rdr.n+1);
      i++;
    }
  }while( pCur->rdr.cTerm==',' );






  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;
}

/*
** Return values of columns for the row at which the CsvCursor
** is currently pointing.