sqlite3.lsp column type bug

Started by Dmi, March 02, 2007, 05:24:23 AM

Previous topic - Next topic

Dmi

We just found a small bug in sqlite3.lsp :



When some column in the multirow result of a select has a NULL value in the first row and non-null values in the subsequent rows, then all values of this column in the result of (sql3:sql ...) function will be nil.

I.e.:

if the result of a select is:

val1|val2
1|null
2|4
3|5

then the result of a (sql3:sql "select * from ... order by val1")

will be

((1 nil)
 (2 nil)
 (3 nil))

This is caused by the optimization trick that fetches the column's values only from the first row of an sql result:

(if (empty? col-types) (set 'col-types (get-types pstm num-cols)))

should be

(set 'col-types (get-types pstm num-cols))

to fetch actual column types from each row.
WBR, Dmi

Lutz

#1
Thanks Dmitry, I uploaded a corrected version:



http://newlisp.org/code/modules/sqlite3.lsp.html">http://newlisp.org/code/modules/sqlite3.lsp.html



and here:



http://newlisp.org/code/modules/sqlite3.lsp.src.html">http://newlisp.org/code/modules/sqlite3.lsp.src.html





Lutz