Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-09 Thread Clemens Ladisch
Yuri wrote: > commit of the subsequent unrelated transaction fails with error=5 > (SQLITE_BUSY) if the previous open sqlite3_blob object hasn't been > closed. > > This fails: > > sqlite3_blob_open // table b with rowids unique in db > sqlite3_blob_write // table b > BEGIN > UPDATE // table a >

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-08 Thread Simon Slavin
On 8 Mar 2017, at 10:10pm, Yuri wrote: > This fails: > > sqlite3_blob_open // table b with rowids unique in db > > sqlite3_blob_write // table b > > BEGIN > > UPDATE // table a > > UPDATE // table a > > COMMIT // FAILS SQLITE_BUSY! That would appear to be the bug we

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-08 Thread Yuri
On 03/05/2017 10:19, Clemens Ladisch wrote: or change the row IDs so that they are unique in the entire database. Thanks for your suggestion. I followed it, and made rowids unique in the table b with a blob field. But I've ran into another problem: commit of the subsequent unrelated

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-06 Thread James K. Lowden
On Sun, 5 Mar 2017 08:28:44 -0800 Yuri wrote: > > I think you?re better off reading the existing BLOB value into > > memory using SELECT, editing it using standard memory-manipulation > > routines, then writing it back with an UPDATE when you?re ready. > > This is very slow.

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-05 Thread Keith Medcalf
> To: SQLite mailing list > Subject: Re: [sqlite] Can sqlite3_blob_write be done through SQL? > > On 03/05/2017 03:48, Keith Medcalf wrote: > > Perhaps because you are committing the transaction? > > There is no COMMIT statement there. > > > Yuri > > ___

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-05 Thread Clemens Ladisch
Simon Slavin wrote: > You’re going to have to wait for the developer team to fix the bug, or change the row IDs so that they are unique in the entire database. Regards, Clemens ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-05 Thread Yuri
On 03/05/2017 09:49, Simon Slavin wrote: On 5 Mar 2017, at 4:28pm, Yuri wrote: So, to be clear, blob writes can only be used when no other statements are executed in the middle? Because the latest testcase only changes the other table, not the table where the blob is. I’m

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-05 Thread Simon Slavin
On 5 Mar 2017, at 4:28pm, Yuri wrote: > So, to be clear, blob writes can only be used when no other statements are > executed in the middle? Because the latest testcase only changes the other > table, not the table where the blob is. I’m glad to see that someone else has

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-05 Thread Yuri
On 03/05/2017 08:22, Simon Slavin wrote: Yes, as we already established it’s because you changed the values of other columns in the row. I think you’re using SQLite’s blob calls in an unexpected way. They’re not meant to be used as an ongoing editor. Adding the kind of support you’ve asked

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-05 Thread Simon Slavin
On 5 Mar 2017, at 4:11pm, Yuri wrote: > On 03/05/2017 07:20, Simon Slavin wrote: >> If you want to delay the ending of the transaction you have to put the BEGIN >> in before it, and then you must put the COMMIT in after it or it won’t be >> committed. > > The second blob

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-05 Thread Yuri
On 03/05/2017 07:20, Simon Slavin wrote: If you want to delay the ending of the transaction you have to put the BEGIN in before it, and then you must put the COMMIT in after it or it won’t be committed. The second blob write fails even after adding BEGIN before sqlite3_blob_open and COMMIT

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-05 Thread Simon Slavin
On 5 Mar 2017, at 3:06pm, Yuri wrote: > On 03/05/2017 03:48, Keith Medcalf wrote: >> Perhaps because you are committing the transaction? > > There is no COMMIT statement there. If you try to execute a command without putting it in a transaction (i.e. using BEGIN) then SQLite

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-05 Thread Yuri
On 03/05/2017 03:48, Keith Medcalf wrote: Perhaps because you are committing the transaction? There is no COMMIT statement there. Yuri ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-05 Thread Gerry Snyder
Would it be possible for you to write the other columns just once, after all the blob has been inserted? On Mar 4, 2017 4:34 PM, "Yuri" wrote: > On 03/04/2017 01:22, Clemens Ladisch wrote: > >> Do you have a concrete example for such a statement? >> > > > Yes. I need to

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-05 Thread Keith Medcalf
Perhaps because you are committing the transaction? > -Original Message- > From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] > On Behalf Of Yuri > Sent: Sunday, 5 March, 2017 02:27 > To: SQLite mailing list > Subject: Re: [sqlite] Can sqlite3_

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-05 Thread Yuri
On 03/04/2017 23:08, Clemens Ladisch wrote: I think you can work around these problems by moving the blob value into a separate table. I thought so too. However, even updates to other tables invalidate the blob handle. Please see the example below. Variable breakMe breaks the second

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-04 Thread Clemens Ladisch
Yuri wrote: > So far sqlite is failing, because the handle returned by > sqlite3_blob_write is invalidated by the updates to the other fields, This would happen regardless of whether you call sqlite3_blob_write() yourself or through an SQL function. > and sqlite3_blob_open/sqlite3_blob_close are

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-04 Thread Yuri
On 03/04/2017 01:22, Clemens Ladisch wrote: Do you have a concrete example for such a statement? Yes. I need to re-assemble the large data packet that comes in portions. I would like to use a blob field for this. I don't want to store parts in separate records, because this is essentially

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-04 Thread Jens Alfke
> On Mar 4, 2017, at 8:50 AM, J Decker wrote: > > All blobs I've used in SQL are themselves atomic and partial updates would > never be useful. (images, fingerprints, etc.) If you're updating parts of > blobs then probably you mean that blob to be in multiple parts or broken

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-04 Thread J Decker
On Fri, Mar 3, 2017 at 3:58 PM, Yuri wrote: > On 03/01/2017 23:41, Clemens Ladisch wrote: > > It would certainly be possible to add your own user-defined SQL function >> to call sqlite3_blob_write(). >> > > > I think this should be added to sqlite itself. Writing a portion of

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-04 Thread Clemens Ladisch
Yuri wrote: > On 03/01/2017 23:41, Clemens Ladisch wrote: >> It would certainly be possible to add your own user-defined SQL function >> to call sqlite3_blob_write(). > > I think this should be added to sqlite itself. So far, nobody except you has requested it. > Writing a portion of blob is

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-03 Thread Yuri
On 03/01/2017 23:41, Clemens Ladisch wrote: It would certainly be possible to add your own user-defined SQL function to call sqlite3_blob_write(). I think this should be added to sqlite itself. Writing a portion of blob is very much like updating a field. There is currently no way to do

Re: [sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-01 Thread Clemens Ladisch
Yuri wrote: > I have to call sqlite3_blob_write to partially modify blobs. > > Wouldn't it have been better if there was a function, for example, > writeblob(tbl.blob_fld, offset, portion_data)? SQLite could do the > same that sqlite3_blob_write is doing when writeblob result is > assigned to the

[sqlite] Can sqlite3_blob_write be done through SQL?

2017-03-01 Thread Yuri
I have to call sqlite3_blob_write to partially modify blobs. Wouldn't it have been better if there was a function, for example, writeblob(tbl.blob_fld, offset, portion_data)? SQLite could do the same that sqlite3_blob_write is doing when writeblob result is assigned to the same row/column