Skip to content
This repository has been archived by the owner on Nov 1, 2018. It is now read-only.

NativeMethods.sqlite3_column_blob should not return EmptyByteArray #293

Closed
ericsink opened this issue Sep 29, 2016 · 0 comments
Closed

NativeMethods.sqlite3_column_blob should not return EmptyByteArray #293

ericsink opened this issue Sep 29, 2016 · 0 comments

Comments

@ericsink
Copy link

In NativeMethods, the sqlite3_column_blob function currently does this:

        var ptr = Sqlite3.column_blob(pStmt, iCol);
        if (ptr == IntPtr.Zero)
        {
            return EmptyByteArray;
        }

At the risk of being pedantic, the problem here is that checking for a null pointer and replacing it with an empty byte array makes NativeMethods.sqlite3_column_blob() behave differently from the underlying sqlite3_column_blob() function in SQLite itself.

The documentation for that function says:

The return value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.

Wanting an empty byte array instead of a null is a reasonable choice. I am merely asserting that this should happen somewhere above NativeMethods, not in a method that is claiming to be sqlite3_column_blob(). :-)

This "problem" showed up as a failing test case (GetFieldValue_of_byteArray_empty) during my experimental attempt to replace the Interop stuff with SQLitePCL.raw (see PR #292).

@rowanmiller rowanmiller added this to the Backlog milestone Oct 6, 2016
@bricelam bricelam self-assigned this Jan 13, 2017
@bricelam bricelam modified the milestones: Backlog, 2.0.0 Jan 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants