@@ -64,6 +64,7 @@ SQLITE_EXTENSION_INIT1
6464
6565#ifndef SQLITEINT_H
6666typedef sqlite3_int64 i64 ;
67+ typedef sqlite3_uint64 u64 ;
6768#endif
6869
6970/* Max size of the error message in a CsvReader */
@@ -128,7 +129,7 @@ static int csv_reader_open(
128129 const char * zData /* ... or use this data */
129130){
130131 if ( zFilename ){
131- p -> zIn = sqlite3_malloc ( CSV_INBUFSZ );
132+ p -> zIn = sqlite3_malloc64 ( CSV_INBUFSZ );
132133 if ( p -> zIn == 0 ){
133134 csv_errmsg (p , "out of memory" );
134135 return 1 ;
@@ -221,7 +222,7 @@ static char *csv_read_one_field(CsvReader *p){
221222 }
222223 if ( c == '"' ){
223224 int pc , ppc ;
224- int startLine = p -> nLine ;
225+ i64 startLine = p -> nLine ;
225226 pc = ppc = 0 ;
226227 while ( 1 ){
227228 c = csv_getc (p );
@@ -325,7 +326,7 @@ typedef struct CsvCursor {
325326 sqlite3_vtab_cursor base ; /* Base class. Must be first */
326327 CsvReader rdr ; /* The CsvReader object */
327328 char * * azVal ; /* Value of the current row */
328- int * aLen ; /* Length of each entry */
329+ i64 * aLen ; /* Length of each entry */
329330 sqlite3_int64 iRowid ; /* The current rowid. Negative for EOF */
330331} CsvCursor ;
331332
@@ -497,7 +498,7 @@ static int csvtabConnect(
497498 CsvTable * pNew = 0 ; /* The CsvTable object to construct */
498499 int bHeader = -1 ; /* header= flags. -1 means not seen yet */
499500 int rc = SQLITE_OK ; /* Result code from this routine */
500- int i , j ; /* Loop counters */
501+ u64 i , j ; /* Loop counters */
501502#ifdef SQLITE_TEST
502503 int tstFlags = 0 ; /* Value for testflags=N parameter */
503504#endif
@@ -516,7 +517,7 @@ static int csvtabConnect(
516517 assert ( sizeof (azPValue )== sizeof (azParam ) );
517518 memset (& sRdr , 0 , sizeof (sRdr ));
518519 memset (azPValue , 0 , sizeof (azPValue ));
519- for (i = 3 ; i < argc ; i ++ ){
520+ for (i = 3 ; i < ( u64 ) argc ; i ++ ){
520521 const char * z = argv [i ];
521522 const char * zValue ;
522523 for (j = 0 ; j < sizeof (azParam )/sizeof (azParam [0 ]); j ++ ){
@@ -563,7 +564,7 @@ static int csvtabConnect(
563564 ){
564565 goto csvtab_connect_error ;
565566 }
566- pNew = sqlite3_malloc ( sizeof (* pNew ) );
567+ pNew = sqlite3_malloc64 ( sizeof (* pNew ) );
567568 * ppVtab = (sqlite3_vtab * )pNew ;
568569 if ( pNew == 0 ) goto csvtab_connect_oom ;
569570 memset (pNew , 0 , sizeof (* pNew ));
@@ -709,12 +710,12 @@ static int csvtabOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
709710 CsvTable * pTab = (CsvTable * )p ;
710711 CsvCursor * pCur ;
711712 size_t nByte ;
712- nByte = sizeof (* pCur ) + (sizeof (char * )+ sizeof (int ))* pTab -> nCol ;
713+ nByte = sizeof (* pCur ) + (sizeof (char * )+ sizeof (i64 ))* pTab -> nCol ;
713714 pCur = sqlite3_malloc64 ( nByte );
714715 if ( pCur == 0 ) return SQLITE_NOMEM ;
715716 memset (pCur , 0 , nByte );
716717 pCur -> azVal = (char * * )& pCur [1 ];
717- pCur -> aLen = (int * )& pCur -> azVal [pTab -> nCol ];
718+ pCur -> aLen = (i64 * )& pCur -> azVal [pTab -> nCol ];
718719 * ppCursor = & pCur -> base ;
719720 if ( csv_reader_open (& pCur -> rdr , pTab -> zFilename , pTab -> zData ) ){
720721 csv_xfer_error (pTab , & pCur -> rdr );
@@ -946,6 +947,7 @@ static sqlite3_module CsvModuleFauxWrite = {
946947
947948#endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) */
948949
950+
949951#ifndef SQLITE_API
950952#define SQLITE_API
951953#endif
0 commit comments