SQLite Forum

Feature Request: support bulk value fetches
Login
Thank you.  I think that all makes sense to me now.  But I have some additional points regarding my use of statements and values.

* In my code, a prepared statement is only used by a single thread.  If my thread calls 'step' and starts fetching values, how will another 'step' be invoked which might alter a value?  I'll stop referencing fetched values way before I invoke 'step' again.

* In my code, each value is only fetched one time per step.  The invoking thread will retrieve the int64/double/text value, make a deep copy of it, then never fetch it again.  If a value is only ever fetched once following a 'step', is there still a risk that its contents will auto-magically change?

* In my code, statement text is generated programmatically, and every column's type is compiled into my code.  A given value for a given table will always be written and fetched as the same type (either int64, real or text).  My code does not initiate any type conversions.  There should be no way my code would ever write a value out as an integer and try to read it in as text, or write it out as double and try to read it in as integer.

Prior to my proposed interface, my code was invoking sqlite3\_column\_value to get a sqlite3\_value* (yes, unprotected), invoking sqlite3\_value\_type to ensure it indeed held the expected data type, and then invoking sqlite3\_value\_int64/double/text on that to obtain the appropriate underlying data.  I understand (per you and the documentation) that this is a no-no, invoking functions that require a protected object with what was obtained as an unprotected object.  I'm just wondering how this has been working fine for me for a long time.  Is my particular usage of the APIs not tripping any of the problem cases, even though it might be unorthodox, ill-advised and dangerous?

I can appreciate that my proposal is not thread-safe in the general case, and would not be acceptable as-is for public consumption.  I'm just wondering whether, with all the caveats I mentioned above within my personal codebase, I am still susceptible to the lurking issues you raised.  I will certainly alter my course to something that doesn't violate the sqlite APIs, I just wanted to know how much I've been living in danger.  Thanks.