I ran your code with my test file and I get this...which is perfectly correct.  
Do you get something different?  What makes you think the stream is truncated 
in the database?

Also...change SQLITE_STATIC to SQLITE_TRANSIENT...that could be your culprit if 
you are still seeing truncation.

Plus "rb" is a Windows thing...not Unix...Windows treats fopen() files as text 
by default and Windows puts CTRL-Z at the end of text files so the "rb" is 
necessary to remove that.  Unix does no such stupid thing.

This is redundant as the strcpy() in front of ti already puts a nul after the 
string.
msg_in.tid[36] = '\0';

<PETPEEVE>
Rather than
     printf("Cannot open file2\n");
Please use
     perror("in.txt");
I always kicked my students for not using REAL error messages that actually 
tell you what went wrong.
</PETPEEVE>


 ls -l in.txt
-rw-r--r-- 1 mblack users 10 Apr  3 08:03 in.txt
od -xa in.txt
0000000 4241 4400 4645 4847 4a49
          A   B nul   D   E   F   G   H   I   J
0000012



SQLite version 3.7.5
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select length(raw_stream_in) from queue;
10
sqlite> .dump
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE [queue] ( [idx] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, [tid] 
CHAR(24) NOT NULL, [raw_stream_in] BLOB, [num_bytes_in] INTEGER 
[raw_stream_out] BLOB, [num_bytes_out] INTEGER [timestamp] CHAR(20));
INSERT INTO "queue" VALUES(1,'123',X'4142004445464748494A',10,NULL);
DELETE FROM sqlite_sequence;
INSERT INTO "sqlite_sequence" VALUES('queue',1);
CREATE UNIQUE INDEX tid on queue([tid]);
COMMIT;


Michael D. Black
Senior Scientist
NG Information Systems
Advanced Analytics Directorate
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to