title: iOS sqlite blob write fails with 'unknown error'
body: <p>I have an SQLite-based app that works fine on Windows, Android and Java. I am trying to port it to iOS: the device is running iOS 9.3.1.</p>
  
  <p>Everything else works apart from the blob write, which fails on the sqlite_step call with an "unknown error". The code is based on <a href="https://stackoverflow.com/questions/4215505/sqlite3-insert-and-read-blob-data-in-database">this SE post</a>.</p>
  
  <p>This is a stripped-down version of the low-level SQLite interface: the query comes from the next level up.</p>
  
  <pre><code>NSLog (@"Preparing query {%s}", query);
  rc = sqlite3_prepare_v2 (hdb, query, -1, &amp;stmt, &amp;tail);
  if (rc == SQLITE_OK) {
     NSLog (@"Binding blob: size= %d", (int)[blob length]);
     rc = sqlite3_bind_blob (stmt, 1, [blob bytes], (int) [blob length], SQLITE_STATIC);
     if (rc == SQLITE_OK) {
        rc = sqlite3_step (stmt);
        if (rc != SQLITE_OK)
          [self sql_error: @"sqlDo" line: __LINE__];
     }
     if (sqlite3_finalize (stmt) != SQLITE_OK)
       [self sql_error: @"sqlEndQuery" line: __LINE__];
  
   }
  </code></pre>
  
  <p>This is the NSLog output:</p>
  
  <pre><code>Preparing query {INSERT OR REPLACE INTO xxx VALUES (18356, '', ?)}
  Binding blob: size= 5388
  SQL error at line 157 in sqlDo: query:{INSERT OR REPLACE INTO xxx VALUES (18356, '', ?)} message:{unknown error}
  </code></pre>