On 10/21/2008 10:50, Evan Burkitt wrote: > Roger Binns rogerb-at-rogerbinns.com |Sqlite| wrote: >> >> You have the full source to the shell and can change the text printing >> routine to do whatever you want > > Yeah, I know, but that's, like, work. :) > > What I want is a tool I (and tech support) can use to at least view, and > possibly modify, the data outside my application. I can write a simple > dump program but having the full capabilities of the shell would be much > preferable. Hacking the source actually sounds like a good plan.
So that's what I did. I copied into shell.c the sqlite3_exec() function from legacy.c and modified it to extract the length of each field via sqlite3_column_bytes(). I added an array of field lengths to the callback function signature, and added another function to which the callback passes each field to have any embedded nulls converted to a printable character. This is hard-coded to ';' but I'd eventually like to add the ability to specify this on the command line. The biggest change from the original is that the callback code now needs to make a copy of the string returned by sqlite3_column_text() and keep track of the memory allocated for it. To avoid imposing a hard-coded size limit or doing a lot of malloc() and free() thrashing I made a resizable struct that is owned by the callback and passed to the fixup function, where it is resized as needed to hold the field text. I've put a diff of my modified shell.c and the v3.6.4 shell.c at [http://evan.burkitt.us/UnLinked/shell_c.zip] If anyone would like to have a look. -evan _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users