SQLite

Check-in [0edad5339e]
Login

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

Overview
Comment:Fix the readfile() UDF so that it returns an empty BLOB, not an OOM error, when reading an empty file.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0edad5339e36d69aed9289bb3e60d35f9930386d76a62bb0194c4fdf420d16fb
User & Date: drh 2019-02-27 19:59:56.536
Context
2019-02-27
23:05
Enable the LIKE optimization when the ESCAPE keyword is present and the PRAGMA case_sensitive_like pragma is ON. (check-in: 6ae4b8c525 user: drh tags: trunk)
19:59
Fix the readfile() UDF so that it returns an empty BLOB, not an OOM error, when reading an empty file. (check-in: 0edad5339e user: drh tags: trunk)
16:38
Add the "-returntype" option to the "db function" Tcl method. (check-in: 789a492b68 user: dan tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to ext/misc/fileio.c.
148
149
150
151
152
153
154
155

156
157
158
159
160
161

162
163
164
165
166
167
168
148
149
150
151
152
153
154

155
156
157
158
159
160

161
162
163
164
165
166
167
168







-
+





-
+







  db = sqlite3_context_db_handle(ctx);
  mxBlob = sqlite3_limit(db, SQLITE_LIMIT_LENGTH, -1);
  if( nIn>mxBlob ){
    sqlite3_result_error_code(ctx, SQLITE_TOOBIG);
    fclose(in);
    return;
  }
  pBuf = sqlite3_malloc64( nIn );
  pBuf = sqlite3_malloc64( nIn ? nIn : 1 );
  if( pBuf==0 ){
    sqlite3_result_error_nomem(ctx);
    fclose(in);
    return;
  }
  if( 1==fread(pBuf, nIn, 1, in) ){
  if( nIn==fread(pBuf, 1, nIn, in) ){
    sqlite3_result_blob64(ctx, pBuf, nIn, sqlite3_free);
  }else{
    sqlite3_result_error_code(ctx, SQLITE_IOERR);
    sqlite3_free(pBuf);
  }
  fclose(in);
}