It sounds like you did an sqlite_bind_text instead of sqlite_bind_blob. So
you'll get the correct # of bytes back but length() thinks its text so it
truncates at NULL.
SQLite version 3.7.4
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE "message_revision" (
...> "MessageRevisionId" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
...> "MessageId" INTEGER NOT NULL REFERENCES "message" ("MessageId")
ON DELETE CASCADE,
...> "CreatedTime" DATETIME NOT NULL,
...> "Author" INTEGER NOT NULL REFERENCES "user" ("UserId"),
...> "Subject" VARCHAR(255),
...> "Content" MEDIUMTEXT,
...> "HtmlContent" MEDIUMTEXT,
...> "Summary" VARCHAR(255),
...> "ModerationState" TINYINT NOT NULL DEFAULT 0,
...> "Draft" BOOLEAN NOT NULL DEFAULT FALSE,
...> "ContentType" VARCHAR(255),
...> "Data" BLOB);
sqlite> insert into message_revision values( null,
0,0,0,'sub','cont','html','summary',0,0,'content',x'656500656565656667686970'
);
sqlite> insert into message_revision values( null,
0,0,0,'sub','cont','html','summary',0,0,'content','656500656565656667686970' );
sqlite> select *,typeof(Data),length(Data) from message_revision;
1|0|0|0|sub|cont|html|summary|0|0|content|ee|blob|12
2|0|0|0|sub|cont|html|summary|0|0|content|656500656565656667686970|text|24
Michael D. Black
Senior Scientist
NG Information Systems
Advanced Analytics Directorate
________________________________________
From: [email protected] [[email protected]] on
behalf of Yves Goergen [[email protected]]
Sent: Sunday, February 06, 2011 6:15 AM
To: General Discussion of SQLite Database
Subject: EXT :Re: [sqlite] LENGTH on a BLOB field stops at NUL byte
On 06.02.2011 12:01 CE(S)T, Simon Davies wrote:
> length() should return the number of bytes for a blob.
> What does typeof() tell you about the data?
It says "text". Now tested with SQLite 3.7.4, this is the only command
line client I have here.
Here's the statement how the table was created:
> CREATE TABLE "message_revision" (
> "MessageRevisionId" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
> "MessageId" INTEGER NOT NULL REFERENCES "message" ("MessageId") ON
> DELETE CASCADE,
> "CreatedTime" DATETIME NOT NULL,
> "Author" INTEGER NOT NULL REFERENCES "user" ("UserId"),
> "Subject" VARCHAR(255),
> "Content" MEDIUMTEXT,
> "HtmlContent" MEDIUMTEXT,
> "Summary" VARCHAR(255),
> "ModerationState" TINYINT NOT NULL DEFAULT 0,
> "Draft" BOOLEAN NOT NULL DEFAULT FALSE,
> "ContentType" VARCHAR(255),
> "Data" BLOB);
The column in question is "Data".
I can verify that the entire image file has been stored as it is
entirely returned in a SELECT query and displayed in the web browser.
--
Yves Goergen "LonelyPixel" <[email protected]>
Visit my web laboratory at http://beta.unclassified.de
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users