On Sunday 23 July 2006 19:41, Anton Golubev wrote:
> Hi Nick,
>
> I think you are right about crash reason. It probably was an
> incompatibility of http and apr-util, which I built separately to
> overcame configuration issues. Once I've had the clean build, the problem
> disappeared.
That's a relief :-) So the underlying bug is indeed what I thought!
> There are three issues with the current
> auto-configuration regarding activation mysql driver for DBD:
[chop]
Thanks for the patch. Can someone @apache who groks
autoconf/tools properly review it, as I don't feel qualified in that area?
> Hope, that will help other non-programmers like me to avoid linking
> clashes trying to build all manually.
What I'd like to see is dynamic loading of apr-util modules, and a
build process as simple as apxs. But that's another subject.
> Besides that, I still can't get DBD authorization with mysql driver
> running. It is very hard to guess, what it behind the error:
> "Internal error: DBD: failed to initialise prepared SQL statements"
> when the query as simple as
> "select PASS from Users where LOGIN=?"
That should work I think ... if you're connected to a database where
that's valid. What happens if you use apr_dbd syntax of
"select PASS from Users where LOGIN=%s"?
> I have been trying to implement mysql errno printing to get at least
> the direction of the problem, but I haven't found the proper way, how
> to do that.
I attach a patch that adds the error from mysql (note, the chunk
around line 300 is the only one that wasn't in the previous patch).
> I would be very-very grateful for the help with debugging this.
Me too. Thanks for the very useful reports!
--
Nick Kew
Index: mod_dbd.c
===================================================================
--- mod_dbd.c (revision 424565)
+++ mod_dbd.c (working copy)
@@ -67,6 +67,8 @@
cmd_min, cmd_keep, cmd_max, cmd_exp
} cmd_parts;
+static apr_hash_t *dbd_prepared_defns;
+
/* a default DBDriver value that'll generate meaningful error messages */
static const char *const no_dbdriver = "[DBDriver unset]";
@@ -144,12 +146,13 @@
DBD_DECLARE_NONSTD(void) ap_dbd_prepare(server_rec *s, const char *query,
const char *label)
{
- svr_cfg *svr = ap_get_module_config(s->module_config, &dbd_module);
dbd_prepared *prepared = apr_pcalloc(s->process->pool, sizeof(dbd_prepared));
prepared->label = label;
prepared->query = query;
- prepared->next = svr->prepared;
- svr->prepared = prepared;
+ prepared->next = apr_hash_get(dbd_prepared_defns, s->server_hostname,
+ APR_HASH_KEY_STRING);
+ apr_hash_set(dbd_prepared_defns, s->server_hostname, APR_HASH_KEY_STRING,
+ prepared);
}
static const char *dbd_prepare(cmd_parms *cmd, void *cfg, const char *query,
const char *label)
@@ -299,8 +302,10 @@
*db = rec;
rv = dbd_prepared_init(rec->pool, svr, rec);
if (rv != APR_SUCCESS) {
+ const char *errmsg = apr_dbd_error(rec->driver, rec->handle, rv);
ap_log_perror(APLOG_MARK, APLOG_CRIT, rv, rec->pool,
- "DBD: failed to initialise prepared SQL statements");
+ "DBD: failed to initialise prepared SQL statements: %s",
+ (errmsg ? errmsg : "[???]"));
}
return rv;
}
@@ -602,6 +607,23 @@
}
#endif
+static int dbd_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp)
+{
+ dbd_prepared_defns = apr_hash_make(ptemp);
+ return OK;
+}
+static int dbd_post_config(apr_pool_t *pconf, apr_pool_t *plog,
+ apr_pool_t *ptemp, server_rec *s)
+{
+ svr_cfg *svr;
+ server_rec *sp;
+ for (sp = s; sp; sp = sp->next) {
+ svr = ap_get_module_config(sp->module_config, &dbd_module);
+ svr->prepared = apr_hash_get(dbd_prepared_defns, sp->server_hostname,
+ APR_HASH_KEY_STRING);
+ }
+ return OK;
+}
static void dbd_hooks(apr_pool_t *pool)
{
#if APR_HAS_THREADS
@@ -613,6 +635,8 @@
APR_REGISTER_OPTIONAL_FN(ap_dbd_cacquire);
APR_REGISTER_OPTIONAL_FN(ap_dbd_prepare);
apr_dbd_init(pool);
+ ap_hook_pre_config(dbd_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
+ ap_hook_post_config(dbd_post_config, NULL, NULL, APR_HOOK_MIDDLE);
}
module AP_MODULE_DECLARE_DATA dbd_module = {