httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrej van der Zee" <andrejvander...@gmail.com>
Subject Re: mod_dbd/apr_dbd and "Commands out of sync"
Date Fri, 03 Oct 2008 15:45:47 GMT
Hi,

When I execute two SELECT statements after each other I do not get the
"Comamnd out of sync" error anymore if I iterate through all the rows
in the apr_dbd_results_t, but I do get all emty values and column
names for the 2nd SELECT.

>
> Can you please post your code ?
>

Below the code. The second SELECT has 5 rows all with empty fields.

Thanks alot!
Andrej

apr_dbd_results_t *dbd_results = NULL;
int dbd_rv;
char *stmt = (char*) apr_psprintf(r->pool, "SELECT request_type_id
FROM request_type WHERE name = '%s'", req_cfg->tid);
if (dbd_rv = apr_dbd_select(dbd->driver, r->pool, dbd->handle,
&dbd_results, stmt, 0)) {
   const char *errmsg = apr_dbd_error(dbd->driver, dbd->handle, dbd_rv);
   ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "Perfmon: Failed
to execute statement '%s': %s", stmt, errmsg);
   return DECLINED;
}

apr_dbd_row_t *dbd_row = NULL;
const char *request_type_id = NULL;
for (rv = apr_dbd_get_row(dbd->driver, r->pool, dbd_results, &dbd_row, -1);
   rv != -1;
   rv = apr_dbd_get_row(dbd->driver, r->pool, dbd_results, &dbd_row, -1)) {
   request_type_id = apr_dbd_get_entry(dbd->driver, dbd_row, 0);
}
	
apr_dbd_results_t *dbd_results2 = NULL;
apr_dbd_row_t *dbd_row2 = NULL;
if (dbd_rv = apr_dbd_select(dbd->driver, r->pool, dbd->handle,
&dbd_results2, "SELECT * FROM request_type", 0)) {
   const char *errmsg = apr_dbd_error(dbd->driver, dbd->handle, dbd_rv);
   ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "Perfmon: Failed
to execute statement '%s': %s", stmt, errmsg);
   return DECLINED;
}

// Here I get all empty strings for the name!
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "Perfmon: name col:
",  apr_dbd_get_name(dbd->driver, dbd_results2, 0));
for (rv = apr_dbd_get_row(dbd->driver, r->pool, dbd_results2, &dbd_row2, -1);
   rv != -1;
   rv = apr_dbd_get_row(dbd->driver, r->pool, dbd_results2, &dbd_row2, -1)) {
   const char *request_type_id = apr_dbd_get_entry(dbd->driver, dbd_row2, 0);
   // Here I get 5 rows with an empty request_type_id!
   ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "Perfmon: : ",
request_type_id);
}

Mime
View raw message