Funny table names patch
Thomas Goirand <thomas-/[email protected]> Sun, 27 Apr 2008 19:33:07 +0800
| Newsgroups | gmane.comp.apache.mod-log-sql |
|---|---|
| Organization | GPLHost |
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format. --------------030906070509000902060100 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi, There was some bug reported in the Unbuntu's launchpad, so I had to do the attached patch. This escapes the table names with `` before the SQL queries. Please include that in the next version of mod_log_sql. I have asked my sponsor to upload the new Debian package that includes this patch (version 1.100-12) in SID. I hope it's going to be uploaded very soon, before the next Ubuntu is out (remember: Unbuntu takes SID as upstream, so because mod_log_sql is in SID, it is also in ubuntu). When this is fully resolved, we will work on a new version of the Debian package that uses 1.101 as new upstream version. But as we don't want to break any production server, we will have to make automatic updates to the SQL database to include the new fields. Here is the plan: * Stops Apache * Ask the user for the MySQL server credentials (host, user, pass) with ALTER privileges for the mod_log_sql database * Then ask the user for the database name * Then supply a list of tables and ask conformation if we may add the two fields to these tables. * Then we alter all these tables * Starts Apache If we do this, would you be interested in having the script so that in can be included in upstream releases too? Please let me know. Also, does any of you knows a RELIABLE and EASY way to get the login and password for the SQL database out of the apache configuration? That would be great to be able to do this, so we could get the login and password from the config files directly, but as there are lot's of include possibilities, it might be quite hard to do it. Thomas Goirand (Debian maintainer for mod_log_sql) P.S: For those who doesn't know, mod_log_sql is called "libapache-mod-log-sql" as source package, and the binaries are called libapache2-mod-log-sql* in SID (apache 1.3 support has been dropped, so the source package is not generating them any more) --------------030906070509000902060100 Content-Type: text/plain; name="007-mod_log_sql.c_funny-table-names.dpatch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="007-mod_log_sql.c_funny-table-names.dpatch" #!/bin/sh /usr/share/dpatch/dpatch-run ## 007-mod_log_sql.c_funny-table-names.dpatch by Thomas Goirand <thomas-/[email protected]> ## ## DP: This patch adds the possibility to use any kind of names for ## DP: the table names by escaping it when calling SQL. @DPATCH@ --- libapache-mod-log-sql-1.100/mod_log_sql.c.orig 2008-04-23 04:58:51.000000000 +0000 +++ libapache-mod-log-sql-1.100/mod_log_sql.c 2008-04-23 04:58:53.000000000 +0000 @@ -931,7 +931,7 @@ } } if ( itemsets != "" ) { - note_query = apr_psprintf(r->pool, "insert %s into %s (id, item, val) values %s", + note_query = apr_psprintf(r->pool, "insert %s into `%s` (id, item, val) values %s", /*global_config.insertdelayed?"delayed":*/"", notes_tablename, itemsets); log_error(APLOG_MARK,APLOG_DEBUG,0, orig->server,"mod_log_sql: note string: %s", note_query); @@ -959,7 +959,7 @@ } } if ( itemsets != "" ) { - hout_query = apr_psprintf(r->pool, "insert %s into %s (id, item, val) values %s", + hout_query = apr_psprintf(r->pool, "insert %s into `%s` (id, item, val) values %s", /*global_config.insertdelayed?"delayed":*/"", hout_tablename, itemsets); log_error(APLOG_MARK,APLOG_DEBUG,0, orig->server,"mod_log_sql: header_out string: %s", hout_query); @@ -988,7 +988,7 @@ } } if ( itemsets != "" ) { - hin_query = apr_psprintf(r->pool, "insert %s into %s (id, item, val) values %s", + hin_query = apr_psprintf(r->pool, "insert %s into `%s` (id, item, val) values %s", /*global_config.insertdelayed?"delayed":*/"", hin_tablename, itemsets); log_error(APLOG_MARK,APLOG_DEBUG,0, orig->server,"mod_log_sql: header_in string: %s", hin_query); @@ -1018,7 +1018,7 @@ } if ( itemsets != "" ) { - cookie_query = apr_psprintf(r->pool, "insert %s into %s (id, item, val) values %s", + cookie_query = apr_psprintf(r->pool, "insert %s into `%s` (id, item, val) values %s", /*global_config.insertdelayed?"delayed":*/"", cookie_tablename, itemsets); log_error(APLOG_MARK,APLOG_DEBUG,0, orig->server,"mod_log_sql: cookie string: %s", cookie_query); @@ -1026,7 +1026,7 @@ /* Set up the actual INSERT statement */ - access_query = apr_psprintf(r->pool, "insert %s into %s (%s) values (%s)", + access_query = apr_psprintf(r->pool, "insert %s into `%s` (%s) values (%s)", /*global_config.insertdelayed?"delayed":*/"", transfer_tablename, fields, values); log_error(APLOG_MARK,APLOG_DEBUG,0, r->server,"mod_log_sql: access string: %s", access_query); --------------030906070509000902060100 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Download the latest version at http://www.outoforder.cc/projects/apache/mod_log_sql/ To unsubscribe send an e-mail to mod_log_sql-unsubscribe-7qY7E20V6GW73k+5HYS8LQqVMODqnSLI@public.gmane.org --------------030906070509000902060100--