Hi Tom, thank you for sharing the patch. The patched sources pass the tests without problems, but I'd like to set up your test case to make sure the patch indeed fixes a problem on my OS as well. I'll take care of this shortly.
regards, Markus Quoting Tom Lane <[email protected]>: > A loop such as the following leaks memory in libdbi 0.8.3: > > > for (n = 0; n < 100000; n++) { > > res = dbi_conn_query(conn, "SELECT * FROM foo;"); > > if (!dbi_result_first_row(res)) { > fprintf(stderr, "dbi_result_first_row() failed.\n"); > exit(1); > } > > for (i = 0; i < 2; i++) { > do { > val = dbi_result_get_int(res, "val"); > if (n == 0) > printf("val: %d\n", val); > > } while (dbi_result_next_row(res)); > > /* Rewind for the next iteration of the for() loop */ > if (!dbi_result_first_row(res)) { > fprintf(stderr, "dbi_result_first_row() failed.\n"); > exit(1); > } > } > > dbi_result_free(res); > > } > > > This patch appears to fix it: > > > diff -Naur libdbi-0.8.3.orig/src/dbi_result.c libdbi-0.8.3/src/dbi_result.c > --- libdbi-0.8.3.orig/src/dbi_result.c 2008-01-23 11:37:36.000000000 > -0500 > +++ libdbi-0.8.3/src/dbi_result.c 2011-09-06 20:51:34.610449576 -0400 > @@ -1533,7 +1533,7 @@ > } > > static int _is_row_fetched(dbi_result_t *result, unsigned long long row) { > - if (!result->rows || (row >= result->numrows_matched)) return -1; > + if (!result->rows || (row > result->numrows_matched)) return -1; > return !(result->rows[row] == NULL); > } > > > > This was discovered by some folks at Bull, who also deserve credit for > the patch, but I don't have a full name. > > regards, tom lane > > ------------------------------------------------------------------------------ > Using storage to extend the benefits of virtualization and iSCSI > Virtualization increases hardware utilization and delivers a new level of > agility. Learn what those decisions are and how to modernize your storage > and backup environments for virtualization. > http://www.accelacomm.com/jaw/sfnl/114/51434361/ > _______________________________________________ > libdbi-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/libdbi-devel -- Markus Hoenicka http://www.mhoenicka.de AQ score 38 ------------------------------------------------------------------------------ Using storage to extend the benefits of virtualization and iSCSI Virtualization increases hardware utilization and delivers a new level of agility. Learn what those decisions are and how to modernize your storage and backup environments for virtualization. http://www.accelacomm.com/jaw/sfnl/114/51434361/ _______________________________________________ libdbi-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libdbi-devel

