Hi
I changed almost of dbmail-src to work with libdbi. My main problem is
to convert dbmsgbuf.c due to the two functions 'db_give_range_size'
and 'db_dump_range'. I changed source in view of using it with
Firebird, but both Firebird and Oracle not supports row_count
functions, only by fetching all records before, what not really spares
recouces.
In 'db.c' and 'authsql.c' I changed source to work like this:
res = dbi_conn_queryf(conn, "select xy from abc"
"where gh = '%s'", myvalue);
while (dbi_result_next_row(res)) {
..
x = dbi_result_get_string_idx(res, 0);
}
dbi_result_free(res);
I this way, there were no 'select count(*) necessary', because PGSQL
is very slow on count(*) statements. Statements which uses row_count
to allocate memory, I changed to allocate f.e. 10 * size and if the
memory is full realloc more:
int row_count = 0;
int max = 10;
int max_count = 10;
xy = (u64_t *) my_malloc(sizeof(u64_t) * max_count);
if (!xy) {
trace(TRACE_ERROR, "%s,%s: not enough memory\n",
__FILE__, __func__);
my_free(xy);
return -1;
}
res = dbi_conn_queryf(conn, "select xy from abc"
"where gh = '%s'", myvalue);
while (dbi_result_next_row(res)) {
row_count++;
if (row_count > max_count) {
max_count+=max;
xy = my_realloc(xy, sizeof(u64_t) * max_count);
if (!xy) {
/* out of mem */
my_free(xy);
dbi_result_free(res);
return -1;
}
}
..
x = dbi_result_get_string_idx(res, 0);
}
dbi_result_free(res);
In 'dbmsgbuf.c' the two functions calculates f.e. the size of the
bodymessage. My question is: Is it possible to calculate the size
on the fly by get 'si=+dbi_result_get_field_length_idx(res,0)' and
realloc memory or is it possible to store Messages in one binary
field? What do you think about this?
Dominik