Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@locus.apache.org Received: (qmail 88222 invoked from network); 18 Oct 2008 13:20:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Oct 2008 13:20:51 -0000 Received: (qmail 674 invoked by uid 500); 18 Oct 2008 13:20:52 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 650 invoked by uid 500); 18 Oct 2008 13:20:52 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 639 invoked by uid 99); 18 Oct 2008 13:20:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 18 Oct 2008 06:20:52 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of andrejvanderzee@gmail.com designates 209.85.128.185 as permitted sender) Received: from [209.85.128.185] (HELO fk-out-0910.google.com) (209.85.128.185) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 18 Oct 2008 13:19:45 +0000 Received: by fk-out-0910.google.com with SMTP id 19so1047268fkr.8 for ; Sat, 18 Oct 2008 06:20:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type:references; bh=6tD5h5WwmB4cKkH3994QMUqjdajQ+MgqXCHTPcDNir0=; b=VsUwKotAoii3wAswpXnLGhNFdWy4F77QS+ty4S1J+qqBfhLU++Pgf5hZDmOj76F6n5 vBwybBSrhroY/mcsJ3BdzEOuboz9mrUEsYfLEdumSqPzhBZ7tKjcfpQkzwTqtudzeQQJ 8I9T7UxuaH61xdGb+fSwPMApsbL3HnUhZ/agQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=QWCtsvgThchZ88TXwpSr4aQr9larZvi/sBPNu+Fn7MKHjegO+sQhHqY1T2PeRu1EXo gStSExLGDoy7aX2uvGawBZGoTqVqQ/nQFi9d7IiJY7CRLB8H+zUQouwhDJCjAZfSla4P SQcQLg+XdFuu2gNA2VsV0Dxnd+Zypfa86BhIo= Received: by 10.187.233.6 with SMTP id k6mr795111far.64.1224336022055; Sat, 18 Oct 2008 06:20:22 -0700 (PDT) Received: by 10.187.236.3 with HTTP; Sat, 18 Oct 2008 06:20:21 -0700 (PDT) Message-ID: <6456355d0810180620h1539f0aey1b7fcca4326c249a@mail.gmail.com> Date: Sat, 18 Oct 2008 22:20:21 +0900 From: "Andrej van der Zee" To: modules-dev@httpd.apache.org Subject: Re: mod_dbd and prepared statements (httpd-2.2.9) In-Reply-To: <48F883ED.7010208@ez.no> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_73901_10359287.1224336022030" References: <6456355d0810132323h4ea325c5r32aad3b348b4e4e0@mail.gmail.com> <48F883ED.7010208@ez.no> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_73901_10359287.1224336022030 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, I did not find a solution, I just stopped using prepared statements altogether. But I tried to isolate the problem just now, and found somehow that I cannot use FLOAT in prepared statement somehow (when I tried INT columns it even segfaults). Below the source code of a mini-module to illustrate this. This is the table I created in MySQL: CREATE TABLE simple_table (duration FLOAT NOT NULL) ENGINE=INNODEDB; And this is what appears in the MySQL log: Prepare INSERT INTO simple_table (duration) VALUES (?) Execute INSERT INTO simple_table (duration) VALUES ('') If you want to reproduce it, dont forget to put this in httpd.conf: LoadModule prep_stmt_module modules/mod_prep_stmt.so PrepStmt on ----------------- Complete mini-module ------------------------- #include #include #include #include #include #include #include #include #include #include module AP_MODULE_DECLARE_DATA prep_stmt_module; static int prep_stmt_write(request_rec *r); typedef struct prep_stmt_config { int prep_stmt_on; } prep_stmt_config; static const char * prep_stmt_config_set_prep_stmt_on(cmd_parms *cmd, void *dummy, int flag) { ap_dbd_prepare(cmd->server, "INSERT INTO simple_table (duration) VALUES (%f)", "insert_row"); prep_stmt_config *cfg = ap_get_module_config(cmd->server->module_config, &prep_stmt_module); cfg->prep_stmt_on = flag; return NULL; } static int prep_stmt_write(request_rec *r) { prep_stmt_config *cfg = ap_get_module_config(r->server->module_config, &prep_stmt_module); if (!cfg->prep_stmt_on) return DECLINED; ap_dbd_t * dbd = ap_dbd_acquire(r); apr_dbd_prepared_t *prepared = apr_hash_get(dbd->prepared, "insert_row", APR_HASH_KEY_STRING); if (!prepared) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "DBD Log: Failed to get prepared statement: update_request"); return DECLINED; } int rv, nrows; if (rv = apr_dbd_pvquery(dbd->driver, r->pool, dbd->handle, &nrows, prepared, 10.2, NULL)) { const char *errmsg = apr_dbd_error(dbd->driver, dbd->handle, rv); ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "DBD Log: Failed to execute prepared statement: insert_row"); return DECLINED; } } static const command_rec prep_stmt_cmds[] = { AP_INIT_FLAG("PrepStmt", prep_stmt_config_set_prep_stmt_on, NULL, RSRC_CONF, "Enable DBD Log"), { NULL } }; static void prep_stmt_register_hooks(apr_pool_t *p) { ap_hook_log_transaction(prep_stmt_write, NULL, NULL, APR_HOOK_MIDDLE); } static void * prep_stmt_create_config(apr_pool_t *pool, server_rec *s) { prep_stmt_config *cfg = apr_pcalloc(pool, sizeof(prep_stmt_config)); return cfg; } module AP_MODULE_DECLARE_DATA prep_stmt_module = { STANDARD20_MODULE_STUFF, /* stuff that needs to be declared in every 2.0 mod */ NULL, /* create per-directory config structure */ NULL, /* merge per-directory config structures */ prep_stmt_create_config, /* create per-server config structure */ NULL, /* merge per-server config structures */ prep_stmt_cmds, /* command apr_table_t */ prep_stmt_register_hooks /* register hooks */ }; ------=_Part_73901_10359287.1224336022030--