| 
      
      
      From: Michael N. <mne...@nt...> - 2003-05-14 19:50:00
      
     | 
| On Mon, May 12, 2003 at 04:01:43PM +0100, Brian Candler wrote:
> I have found a bug using ruby-dbi-0.0.18 or 0.0.19 with sqlite-2.8.0. I am
> running under ruby-1.6.8 and FreeBSD-4.7
> 
> The attached code replicates it: you prepare a statement, execute it
> (for parameters giving no results), then execute it again (for a parameter
> which gives a non-empty result set). The second execution causes a segv
> crash when you call 'fetch' to get the results.
> 
> Any takers?
I've found the bug.
The problem was, when executing a statement that produces an empty row,
no column information was available, which is required when fetching a
row. As DBD::SQLite caches the column information, but it's not set
during the first execute call, the fetch failed.
Here the patch (it's in CVS):
diff -r1.5 SQLite.c
478c478
<   if (rb_iv_get(self, "@col_info") == Qnil) {
---
>   if (rb_iv_get(self, "@col_info") == Qnil || RARRAY(rb_iv_get(self, "@col_info"))->len == 0) {
Regards,
  Michael
 |