Hello, we are experiencing a problem with SQLite 3.7.9 where 213 Mb (!) are allocated for the following query:
SELECT "partBody" IS NULL AS "partBodyIsNull" FROM LocalMailContents; The database has a table LocalMailContents with several text / integer columns and two BLOB columns at the end ("partHeader" and "partBody"). Both of the blob columns either contain NULL or a value created by zeroblob() function and later filled by the blob API. In our tests the last column is filled with large data, specifically about 213 Mb. SQLite actually tries to read the data when evaluating the above query and moreover it reads all the data into a single memory chunk. The code that is responsible for the read is in OP_Column: if( u.am.aOffset[u.am.p2] ){ assert( rc==SQLITE_OK ); if( u.am.zRec ){ MemReleaseExt(u.am.pDest); sqlite3VdbeSerialGet((u8 *)&u.am.zRec[u.am.aOffset[u.am.p2]], u.am.aType[u.am.p2], u.am.pDest); }else{ u.am.len = sqlite3VdbeSerialTypeLen(u.am.aType[u.am.p2]); sqlite3VdbeMemMove(&u.am.sMem, u.am.pDest); rc = sqlite3VdbeMemFromBtree(u.am.pCrsr, u.am.aOffset[u.am.p2], u.am.len, u.am.pC->isIndex, &u.am.sMem); if( rc!=SQLITE_OK ){ goto op_column_out; } u.am.zData = u.am.sMem.z; sqlite3VdbeSerialGet((u8*)u.am.zData, u.am.aType[u.am.p2], u.am.pDest); } u.am.pDest->enc = encoding; }else{ A test database is available at http://www.emclient.com/temp/mail_data.zipthat exhibits the behavior. Is this something that is intended behavior? Is the memory allocation really necessary? Best regards, Filip Navara _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users