Handle zero-length Span
inputs for sqlite3_bind_text*
#558
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Same as
sqlite3_bind_blob
, the SQLite C APIssqlite3_bind_text*
require the data pointer argument to be non-null to actually accept zero-length input. Otherwise, when a null data pointer is passed, the explicit length is ignored and aSQLITE_NULL
value is bound instead.This PR updates
sqlite3_bind_text
andsqlite3_bind_text16
to handle zero-lengthReadOnlySpan
s, by substituting a valid pointer for the zero-length case.The generated
sqlite3_bind_blob
code already handled this scenario by allocating a newbyte[]
for each call e.g. at:SQLitePCL.raw/src/providers/provider.tt
Lines 1586 to 1595 in 9c66b4f
This PR proposes a potentially lower-overhead solution (passing the address of a local) for both
sqlite3_bind_text*
andsqlite3_bind_blob
, as suggested bySpan<T>
usage Rule #9:These changes address the
sqlite3_bind_text*
functions behavior when called with emptyReadOnlySpan
.Fixes #557