I'm trying to write up a document on the whole sqlite3_bind_pointer()
thing now, that describes its motivation and its limitations.
Hopefully that will clear up the confusion.  I will announce when the
new document goes up and request clearance from petern and kmedcalf
prior to the release.

On 7/17/17, Keith Medcalf <[email protected]> wrote:
>
> On Monday, 17 July, 2017 08:00, Richard Hipp <[email protected]> wrote:
>> On 7/17/17, Keith Medcalf <[email protected]> wrote:
>
>> > Also, a question.  sqlite3_bind_pointer(C, P, T) and
>> > sqlite3_value_pointer(C, P, T) indicates that T should be a "static
>> > string".
>
>> > Does this mean of type SQLITE_STATIC and that it cannot be a string
>> > located on the stack (ie, an SQLITE_TRANSIENT), or is a copy made of
>> > the string value (ala SQLITE_TRANSIENT) for future use?
>
>> No copy is made of the string.  SQLite merely keeps a pointer.  If the
>> memory that holds the string is deallocated or reused for some other
>> purpose, bad things will happen.
>
> Ok, understand.  I presume therefore that this is NOT a database type but is
> for passing around value types and contexts only.  Therefore using a
> quoted-string will point to something in the global string table built by
> the compiler and therefore be static.  Makes sense.
>
> So if the sqlite3_bind_pointer is used to bind into a database column, that
> value will be null when stored in the database?  I suppose I could just try
> this, but I thought I would ask you just to be sure ...
>
> Example:
>
> prepare("insert into table (col1, col2) values (?,?)")
> bind_int64(...,1,intval)
> bind_pointer(...,2,&intval, "carray")
> step()
>
> that col1 gets the integer and col2 gets a NULL?  and that the bind_pointer
> actual pointer value and type string is only accessible when the bound
> column is accessed by something that uses the used the sqlite3_value type
> interfaces (that does not actually originate or terminate as a database row
> -- and the pointer type is not preserved in the database itself but would be
> persisted as if NULL?)
>
>
>
>
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


-- 
D. Richard Hipp
[email protected]
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to