diff options
| author | 2002-06-27 20:09:17 +0000 | |
|---|---|---|
| committer | 2002-06-27 20:09:17 +0000 | |
| commit | 80673c37abcedb421c04193f50e0cd53a6ac01c4 (patch) | |
| tree | 7a98b73f0341348b6ef81bb17a552dcb9dca7c0b | |
| parent | e8f3aec956154276082ca2b6ed40ac4a320c6af0 (diff) | |
Lots of changes & bugfixes as requested on the list. Pre-1 of 1.17.1.17pre1
| -rw-r--r-- | CHANGELOG | 20 | ||||
| -rw-r--r-- | INSTALL | 25 | ||||
| -rw-r--r-- | LICENSE | 164 | ||||
| -rw-r--r-- | mod_log_sql.c | 76 |
4 files changed, 193 insertions, 92 deletions
| @@ -1,4 +1,4 @@ | |||
| 1 | $Id: CHANGELOG,v 1.13 2002/05/24 20:52:39 helios Exp $ | 1 | $Id: CHANGELOG,v 1.14 2002/06/27 20:09:17 helios Exp $ |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | TODO: | 4 | TODO: |
| @@ -10,6 +10,9 @@ TODO: | |||
| 10 | * port to Apache 2.x | 10 | * port to Apache 2.x |
| 11 | * does determining table name in massvirtual mode upon every request | 11 | * does determining table name in massvirtual mode upon every request |
| 12 | cause performance degradation? If so fix. | 12 | cause performance degradation? If so fix. |
| 13 | * LogSQLRotateLogs directive with daily/monthly/weekly/etc. | ||
| 14 | * new format char: IP as bigint? | ||
| 15 | * socket-based middleman daemon with configurable conns? | ||
| 13 | 16 | ||
| 14 | 17 | ||
| 15 | CHANGES: | 18 | CHANGES: |
| @@ -44,7 +47,18 @@ CHANGES: | |||
| 44 | * Config directives used to begin with MySQL, now begin with LogSQL. | 47 | * Config directives used to begin with MySQL, now begin with LogSQL. |
| 45 | This is for database inspecificity. In your httpd.conf just do | 48 | This is for database inspecificity. In your httpd.conf just do |
| 46 | a search-and-replace. | 49 | a search-and-replace. |
| 47 | 50 | * More robust table-creation code with error checking. [The race condition | |
| 51 | that several users have reported may still exist, but this will go a long | ||
| 52 | way toward debugging the condition.] | ||
| 53 | * Fixed bug whereby a MySQL connection was abandoned on reopen; the old | ||
| 54 | connection is now properly closed first. | ||
| 55 | * Minor: remind user not to set createtables when massvirtual is on. | ||
| 56 | * If Apache started but MySQL was unavailable, the module would do | ||
| 57 | everything it was supposed to (preserve entries, etc.) but not notify | ||
| 58 | the sysadmin. Added a log message to alert sysadmin if MySQL is | ||
| 59 | unreachable at startup. | ||
| 60 | * Migrated to the Artistic License (as used by Perl). | ||
| 61 | |||
| 48 | 62 | ||
| 49 | 1.16: | 63 | 1.16: |
| 50 | * Moved all the user DEFINEs inside the .c file -- splitting them | 64 | * Moved all the user DEFINEs inside the .c file -- splitting them |
| @@ -87,7 +101,7 @@ CHANGES: | |||
| 87 | * Reduced sleep time on a retry to 1/4 second from 1/2 second. | 101 | * Reduced sleep time on a retry to 1/4 second from 1/2 second. |
| 88 | * Confirmed that this module will compile with -pedantic ... but not | 102 | * Confirmed that this module will compile with -pedantic ... but not |
| 89 | with -ansi. :-) | 103 | with -ansi. :-) |
| 90 | 104 | ||
| 91 | 105 | ||
| 92 | 1.15: | 106 | 1.15: |
| 93 | * Vastly improved error reporting is a lot clearer about lost db | 107 | * Vastly improved error reporting is a lot clearer about lost db |
| @@ -1,4 +1,4 @@ | |||
| 1 | $Id: INSTALL,v 1.8 2002/05/14 21:47:14 helios Exp $ | 1 | $Id: INSTALL,v 1.9 2002/06/27 20:09:17 helios Exp $ |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | Requirements | 4 | Requirements |
| @@ -65,26 +65,19 @@ For folks interested in using this module as an Apache DSO: | |||
| 65 | EXAMPLE: | 65 | EXAMPLE: |
| 66 | # /usr/sbin/apxs -i -c -L/usr/lib/mysql -lmysqlclient -lz mod_log_sql.c | 66 | # /usr/sbin/apxs -i -c -L/usr/lib/mysql -lmysqlclient -lz mod_log_sql.c |
| 67 | 67 | ||
| 68 | You should see something like this: | 68 | You should see something similar to this: |
| 69 | 69 | ||
| 70 | gcc -fpic -DSHARED_MODULE -I/usr/local/Apache/include -c mod_log_sql.c | 70 | gcc -fpic -DSHARED_MODULE -I/usr/local/apache/include -c mod_log_mysql.c |
| 71 | ld -Bshareable -o mod_log_sql.so mod_log_sql.o | 71 | gcc -shared -o mod_log_mysql.so mod_log_mysql.o -L/usr/local/lib/mysql/ -lmysqlclient -lz |
| 72 | cp mod_log_sql.so <your path to Apache libexec>/mod_log_sql.so | 72 | cp mod_log_mysql.so /usr/local/apache/libexec/mod_log_mysql.so |
| 73 | chmod 755 <your path to Apache libexec>/mod_log_sql.so | 73 | chmod 755 /usr/local/apache/libexec/mod_log_mysql.so |
| 74 | [activating module blah in /path/to/apache/etc/httpd.conf] | ||
| 75 | 74 | ||
| 76 | 4) Add the following stanzas to your httpd.conf file. Put the second stanza | 75 | 4) Add the following lines to your httpd.conf file. Put the second line |
| 77 | somewhere after the ClearModuleList directive. | 76 | somewhere after the ClearModuleList directive. |
| 78 | 77 | ||
| 79 | <IfDefine HAVE_LOG_MYSQL> | 78 | LoadModule mysql_log_module libexec/mod_log_sql.so |
| 80 | LoadModule mysql_log_module modules/mod_log_sql.so | ||
| 81 | </IfDefine> | ||
| 82 | |||
| 83 | |||
| 84 | <IfDefine HAVE_LOG_MYSQL> | ||
| 85 | AddModule mod_log_sql.c | ||
| 86 | </IfDefine> | ||
| 87 | 79 | ||
| 80 | AddModule mod_log_sql.c | ||
| 88 | 81 | ||
| 89 | 5) Now go to step (9) in the instructions below to configure httpd.conf... | 82 | 5) Now go to step (9) in the instructions below to configure httpd.conf... |
| 90 | 83 | ||
| @@ -1,55 +1,121 @@ | |||
| 1 | $Id: LICENSE,v 1.3 2002/05/14 21:50:51 helios Exp $ | 1 | $Id: LICENSE,v 1.4 2002/06/27 20:09:17 helios Exp $ |
| 2 | 2 | ||
| 3 | Copyright (c) 2002 Christopher B. Powell. All rights reserved. | 3 | Copyright (c) 2002 Christopher B. Powell. All rights reserved. |
| 4 | Portions copyright (c) 2000 The Apache Software Foundation. | 4 | Portions copyright (c) 2000 The Apache Software Foundation. |
| 5 | 5 | ||
| 6 | Redistribution and use in source and binary forms, with or without | 6 | |
| 7 | modification, are permitted provided that the following conditions | 7 | Preamble |
| 8 | are met: | 8 | |
| 9 | 9 | The intent of this document is to state the conditions under which a | |
| 10 | 1. Redistributions of source code must retain the above copyright | 10 | Package may be copied, such that the Copyright Holder maintains some |
| 11 | notice, this list of conditions and the following disclaimer. | 11 | semblance of artistic control over the development of the package, |
| 12 | 12 | while giving the users of the package the right to use and distribute | |
| 13 | 2. Redistributions in binary form must reproduce the above copyright | 13 | the Package in a more-or-less customary fashion, plus the right to make |
| 14 | notice, this list of conditions and the following disclaimer in | 14 | reasonable modifications. |
| 15 | the documentation and/or other materials provided with the | 15 | |
| 16 | distribution. | 16 | |
| 17 | 17 | Definitions: | |
| 18 | 3. The end-user documentation included with the redistribution, | 18 | |
| 19 | if any, must include the following acknowledgment: | 19 | * "Package" refers to the collection of files distributed by the |
| 20 | "This product includes software developed by the | 20 | Copyright Holder, and derivatives of that collection of files created |
| 21 | Apache Software Foundation (http://www.apache.org/) | 21 | through textual modification. |
| 22 | and by Christopher Powell, mod_log_mysql Module Maintainer | 22 | |
| 23 | (http://www.grubbybaby.com/mod_log_mysql/)." | 23 | * "Standard Version" refers to such a Package if it has not been |
| 24 | Alternately, this acknowledgment may appear in the software itself, | 24 | modified, or has been modified in accordance with the wishes of the |
| 25 | if and wherever such third-party acknowledgments normally appear. | 25 | Copyright Holder. |
| 26 | 26 | ||
| 27 | 4. The names "mod_log_mysql" and "mod_log_sql" must | 27 | * "Copyright Holder" is Christopher B. Powell, <chris@grubbybaby.com>. |
| 28 | not be used to endorse or promote products derived from this | 28 | |
| 29 | software without prior written permission. For written | 29 | * "You" is you, if you're thinking about copying or distributing this |
| 30 | permission, please contact <chris@grubbybaby.com>. | 30 | Package. |
| 31 | 31 | ||
| 32 | 5. Products derived from this software may not be called | 32 | * "Reasonable copying fee" is whatever you can justify on the basis of |
| 33 | "mod_log_mysql" or "mod_log_sql", nor may "mod_log_mysql" or | 33 | media cost, duplication charges, time of people involved, and so on. |
| 34 | "mod_log_sql" appear in their names, without prior written permission | 34 | (You will not be required to justify it to the Copyright Holder, but |
| 35 | of Christopher B. Powell. | 35 | only to the computing community at large as a market that must bear the |
| 36 | 36 | fee.) | |
| 37 | 6. Redistributions of any form whatsoever must retain the following | 37 | |
| 38 | acknowledgment: "This product includes software developed by | 38 | * "Freely Available" means that no fee is charged for the item itself, |
| 39 | Christopher B. Powell <chris@grubbybaby.com> for use in the | 39 | though there may be fees involved in handling the item. It also means |
| 40 | mod_log_mysql project (http://www.grubbybaby.com/mod_log_mysql/). | 40 | that recipients of the item may redistribute it under the same |
| 41 | 41 | conditions they received it. | |
| 42 | THIS SOFTWARE IS PROVIDED `AS IS'' AND ANY EXPRESSED OR IMPLIED | 42 | |
| 43 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 43 | |
| 44 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 44 | 1. You may make and give away verbatim copies of the source form of the |
| 45 | DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | 45 | Standard Version of this Package without restriction, provided that you |
| 46 | ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 46 | duplicate all of the original copyright notices and associated |
| 47 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 47 | disclaimers. |
| 48 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | 48 | |
| 49 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 49 | 2. You may apply bug fixes, portability fixes and other modifications |
| 50 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | 50 | derived from the Public Domain or from the Copyright Holder. A Package |
| 51 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | 51 | modified in such a way shall still be considered the Standard Version. |
| 52 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 52 | |
| 53 | SUCH DAMAGE. | 53 | 3. You may otherwise modify your copy of this Package in any way, |
| 54 | provided that you insert a prominent notice in each changed file | ||
| 55 | stating how and when you changed that file, and provided that you do at | ||
| 56 | least ONE of the following: | ||
| 57 | |||
| 58 | a) place your modifications in the Public Domain or otherwise make | ||
| 59 | them Freely Available, such as by posting said modifications to | ||
| 60 | Usenet or an equivalent medium, or placing the modifications on a | ||
| 61 | major archive site such as ftp.uu.net, or by allowing the | ||
| 62 | Copyright Holder to include your modifications in the Standard | ||
| 63 | Version of the Package. | ||
| 64 | |||
| 65 | b) use the modified Package only within your corporation or | ||
| 66 | organization. | ||
| 67 | |||
| 68 | c) rename any non-standard executables so the names do not | ||
| 69 | conflict with standard executables, which must also be provided, | ||
| 70 | and provide a separate manual page for each non-standard | ||
| 71 | executable that clearly documents how it differs from the Standard | ||
| 72 | Version. | ||
| 73 | |||
| 74 | d) make other distribution arrangements with the Copyright Holder. | ||
| 75 | |||
| 76 | 4. You may distribute the programs of this Package in object code or | ||
| 77 | executable form, provided that you do at least ONE of the following: | ||
| 78 | |||
| 79 | a) distribute a Standard Version of the executables and library | ||
| 80 | files, together with instructions (in the manual page or | ||
| 81 | equivalent) on where to get the Standard Version. | ||
| 82 | |||
| 83 | b) accompany the distribution with the machine-readable source of | ||
| 84 | the Package with your modifications. | ||
| 85 | |||
| 86 | c) accompany any non-standard executables with their corresponding | ||
| 87 | Standard Version executables, giving the non-standard executables | ||
| 88 | non-standard names, and clearly documenting the differences in | ||
| 89 | manual pages (or equivalent), together with instructions on where | ||
| 90 | to get the Standard Version. | ||
| 91 | |||
| 92 | d) make other distribution arrangements with the Copyright Holder. | ||
| 93 | |||
| 94 | 5. You may charge a reasonable copying fee for any distribution of this | ||
| 95 | Package. You may charge any fee you choose for support of this Package. | ||
| 96 | You may not charge a fee for this Package itself. However, you may | ||
| 97 | distribute this Package in aggregate with other (possibly commercial) | ||
| 98 | programs as part of a larger (possibly commercial) software | ||
| 99 | distribution provided that you do not advertise this Package as a | ||
| 100 | product of your own. | ||
| 101 | |||
| 102 | 6. The scripts and library files supplied as input to or produced as | ||
| 103 | output from the programs of this Package do not automatically fall | ||
| 104 | under the copyright of this Package, but belong to whomever generated | ||
| 105 | them, and may be sold commercially, and may be aggregated with this | ||
| 106 | Package. | ||
| 107 | |||
| 108 | 7. C or perl subroutines supplied by you and linked into this Package | ||
| 109 | shall not be considered part of this Package. | ||
| 110 | |||
| 111 | 8. The name of the Copyright Holder may not be used to endorse or | ||
| 112 | promote products derived from this software without specific prior | ||
| 113 | written permission. | ||
| 114 | |||
| 115 | 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED | ||
| 116 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | ||
| 117 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
| 118 | |||
| 119 | The End | ||
| 54 | 120 | ||
| 55 | 121 | ||
diff --git a/mod_log_sql.c b/mod_log_sql.c index ecdfcf0..db9b3a3 100644 --- a/mod_log_sql.c +++ b/mod_log_sql.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $Id: mod_log_sql.c,v 1.14 2002/05/24 20:52:39 helios Exp $ */ | 1 | /* $Id: mod_log_sql.c,v 1.15 2002/06/27 20:09:17 helios Exp $ */ |
| 2 | 2 | ||
| 3 | /* --------* | 3 | /* --------* |
| 4 | * DEFINES * | 4 | * DEFINES * |
| @@ -574,11 +574,13 @@ void preserve_entry(request_rec *r, const char *query) | |||
| 574 | /* */ | 574 | /* */ |
| 575 | /* Parms: request record, SQL insert statement */ | 575 | /* Parms: request record, SQL insert statement */ |
| 576 | /* Returns: 0 (OK) on success */ | 576 | /* Returns: 0 (OK) on success */ |
| 577 | /* mysql return code on error */ | 577 | /* -1 if have no log handle */ |
| 578 | /* actual MySQL return code on error */ | ||
| 578 | /*-----------------------------------------------------*/ | 579 | /*-----------------------------------------------------*/ |
| 579 | int safe_mysql_query(request_rec *r, const char *query) | 580 | int safe_mysql_query(request_rec *r, const char *query) |
| 580 | { | 581 | { |
| 581 | int retval; | 582 | int retval; |
| 583 | unsigned int real_error; | ||
| 582 | struct timespec delay, remainder; | 584 | struct timespec delay, remainder; |
| 583 | int ret; | 585 | int ret; |
| 584 | void (*handler) (int); | 586 | void (*handler) (int); |
| @@ -591,19 +593,22 @@ int safe_mysql_query(request_rec *r, const char *query) | |||
| 591 | if (mysql_log != NULL) | 593 | if (mysql_log != NULL) |
| 592 | retval = mysql_query(mysql_log, query); | 594 | retval = mysql_query(mysql_log, query); |
| 593 | else | 595 | else |
| 594 | return 1; | 596 | return -1; |
| 595 | 597 | ||
| 596 | /* If we ran the query and it returned an error, try to be graceful. | 598 | /* If we ran the query and it returned an error, try to be graceful. |
| 597 | * (The module thought it had a valid mysql_log connection but the query | 599 | * (The module thought it had a valid mysql_log connection but the query |
| 598 | * might have failed, so we have to check.) | 600 | * might have failed, so we have to be extra-safe and check.) |
| 599 | */ | 601 | */ |
| 600 | if ( retval != 0 ) | 602 | if ( retval != 0 ) |
| 601 | { | 603 | { |
| 602 | log_sql_state *cls = get_module_config(r->server->module_config, &mysql_log_module); | 604 | log_sql_state *cls = get_module_config(r->server->module_config, &mysql_log_module); |
| 605 | |||
| 606 | real_error = mysql_errno(mysql_log); | ||
| 603 | 607 | ||
| 604 | /* Something went wrong, so start by trying to restart the db link. */ | 608 | /* Something went wrong, so start by trying to restart the db link. */ |
| 605 | ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: first attempt failed, API said: %s", MYSQL_ERROR(mysql_log)); | 609 | ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: first attempt failed, API said: error %d, %s", real_error, MYSQL_ERROR(mysql_log)); |
| 606 | 610 | ||
| 611 | mysql_close(mysql_log); | ||
| 607 | mysql_log = NULL; | 612 | mysql_log = NULL; |
| 608 | open_logdb_link(); | 613 | open_logdb_link(); |
| 609 | 614 | ||
| @@ -630,7 +635,8 @@ int safe_mysql_query(request_rec *r, const char *query) | |||
| 630 | /* If this one also failed, log that and append to our local offline file */ | 635 | /* If this one also failed, log that and append to our local offline file */ |
| 631 | if ( retval != 0 ) | 636 | if ( retval != 0 ) |
| 632 | { | 637 | { |
| 633 | ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: second attempt failed, API said: %s", MYSQL_ERROR(mysql_log)); | 638 | real_error = mysql_errno(mysql_log); |
| 639 | ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: second attempt failed, API said: error %d, %s", real_error, MYSQL_ERROR(mysql_log)); | ||
| 634 | preserve_entry(r, query); | 640 | preserve_entry(r, query); |
| 635 | ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: entry preserved in %s", cls->preserve_file); | 641 | ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: entry preserved in %s", cls->preserve_file); |
| 636 | } else { | 642 | } else { |
| @@ -658,7 +664,10 @@ const char *set_log_sql_massvirtual(cmd_parms *parms, void *dummy, int flag) | |||
| 658 | 664 | ||
| 659 | const char *set_log_sql_create(cmd_parms *parms, void *dummy, int flag) | 665 | const char *set_log_sql_create(cmd_parms *parms, void *dummy, int flag) |
| 660 | { | 666 | { |
| 661 | create_tables = ( flag ? 1 : 0); | 667 | if (massvirtual != 0) |
| 668 | ap_log_error(APLOG_MARK,WARNINGLEVEL,parms->server,"mod_log_sql: do not set LogSQLCreateTables when LogSQLMassVirtualHosting is On. Ignoring."); | ||
| 669 | else | ||
| 670 | create_tables = ( flag ? 1 : 0); | ||
| 662 | return NULL; | 671 | return NULL; |
| 663 | } | 672 | } |
| 664 | 673 | ||
| @@ -841,6 +850,9 @@ static void log_sql_child_init(server_rec *s, pool *p) | |||
| 841 | int retval; | 850 | int retval; |
| 842 | 851 | ||
| 843 | retval = open_logdb_link(); | 852 | retval = open_logdb_link(); |
| 853 | if (retval == 0) | ||
| 854 | ap_log_error(APLOG_MARK,ERRLEVEL,s,"mod_log_sql: child spawned but unable to open database link"); | ||
| 855 | |||
| 844 | #ifdef DEBUG | 856 | #ifdef DEBUG |
| 845 | if (retval > 0) { | 857 | if (retval > 0) { |
| 846 | ap_log_error(APLOG_MARK,DEBUGLEVEL,s,"mod_log_sql: open_logdb_link successful"); | 858 | ap_log_error(APLOG_MARK,DEBUGLEVEL,s,"mod_log_sql: open_logdb_link successful"); |
| @@ -1052,7 +1064,7 @@ int log_sql_transaction(request_rec *orig) | |||
| 1052 | char *create_notes = NULL; | 1064 | char *create_notes = NULL; |
| 1053 | char *create_hout = NULL; | 1065 | char *create_hout = NULL; |
| 1054 | char *create_hin = NULL; | 1066 | char *create_hin = NULL; |
| 1055 | int create_results_access, create_results_notes, create_results_hout, create_results_hin; | 1067 | int create_results; |
| 1056 | 1068 | ||
| 1057 | for (r = orig; r->next; r = r->next) { | 1069 | for (r = orig; r->next; r = r->next) { |
| 1058 | continue; | 1070 | continue; |
| @@ -1266,10 +1278,10 @@ int log_sql_transaction(request_rec *orig) | |||
| 1266 | create_hin = ap_pstrcat(orig->pool, createprefix, cls->hin_table_name, headers_suffix, NULL); | 1278 | create_hin = ap_pstrcat(orig->pool, createprefix, cls->hin_table_name, headers_suffix, NULL); |
| 1267 | 1279 | ||
| 1268 | #ifdef DEBUG | 1280 | #ifdef DEBUG |
| 1269 | ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"create string: %s", create_access); | 1281 | ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"mod_log_sql: create string: %s", create_access); |
| 1270 | ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"create string: %s", create_notes); | 1282 | ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"mod_log_sql: create string: %s", create_notes); |
| 1271 | ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"create string: %s", create_hout); | 1283 | ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"mod_log_sql: create string: %s", create_hout); |
| 1272 | ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"create string: %s", create_hin); | 1284 | ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"mod_log_sql: create string: %s", create_hin); |
| 1273 | #endif | 1285 | #endif |
| 1274 | 1286 | ||
| 1275 | } | 1287 | } |
| @@ -1278,7 +1290,7 @@ int log_sql_transaction(request_rec *orig) | |||
| 1278 | access_query = ap_pstrcat(r->pool, "insert into ", cls->transfer_table_name, " (", fields, ") values (", values, ")", NULL); | 1290 | access_query = ap_pstrcat(r->pool, "insert into ", cls->transfer_table_name, " (", fields, ") values (", values, ")", NULL); |
| 1279 | 1291 | ||
| 1280 | #ifdef DEBUG | 1292 | #ifdef DEBUG |
| 1281 | ap_log_error(APLOG_MARK,DEBUGLEVEL,r->server,"insert string: %s", access_query); | 1293 | ap_log_error(APLOG_MARK,DEBUGLEVEL,r->server,"mod_log_sql: access string: %s", access_query); |
| 1282 | #endif | 1294 | #endif |
| 1283 | 1295 | ||
| 1284 | 1296 | ||
| @@ -1291,7 +1303,9 @@ int log_sql_transaction(request_rec *orig) | |||
| 1291 | if (mysql_log == NULL) { | 1303 | if (mysql_log == NULL) { |
| 1292 | /* Unable to re-establish a DB link, so assume that it's really | 1304 | /* Unable to re-establish a DB link, so assume that it's really |
| 1293 | * gone and send the entry to the preserve file instead. | 1305 | * gone and send the entry to the preserve file instead. |
| 1294 | * Note that we don't keep logging the db error over and over. */ | 1306 | * This short-circuits safe_mysql_query during a db outage and therefore |
| 1307 | * we don't keep logging the db error over and over. | ||
| 1308 | */ | ||
| 1295 | preserve_entry(orig, access_query); | 1309 | preserve_entry(orig, access_query); |
| 1296 | if ( note_query != NULL ) | 1310 | if ( note_query != NULL ) |
| 1297 | preserve_entry(orig, note_query); | 1311 | preserve_entry(orig, note_query); |
| @@ -1313,21 +1327,35 @@ int log_sql_transaction(request_rec *orig) | |||
| 1313 | 1327 | ||
| 1314 | /* Make the tables if we're supposed to. */ | 1328 | /* Make the tables if we're supposed to. */ |
| 1315 | if ((cls->table_made != 1) && (create_tables != 0)) { | 1329 | if ((cls->table_made != 1) && (create_tables != 0)) { |
| 1316 | create_results_access = safe_mysql_query(orig, create_access); | 1330 | |
| 1317 | create_results_notes = safe_mysql_query(orig, create_notes); | 1331 | /* Assume it will be made successfully...*/ |
| 1318 | create_results_hin = safe_mysql_query(orig, create_hin); | 1332 | cls->table_made = 1; |
| 1319 | create_results_hout = safe_mysql_query(orig, create_hout); | ||
| 1320 | 1333 | ||
| 1321 | if ( (create_results_access == 0) && (create_results_notes == 0) && (create_results_hin == 0) && (create_results_hout == 0) ) | 1334 | if ((create_results = safe_mysql_query(orig, create_access)) != 0) { |
| 1322 | cls->table_made = 1; | 1335 | cls->table_made = 0; |
| 1323 | else | 1336 | ap_log_error(APLOG_MARK,ERRLEVEL,orig->server,"mod_log_sql: failed to create access table, see preserve file"); |
| 1324 | ap_log_error(APLOG_MARK,ERRLEVEL,orig->server,"mod_log_sql: failed to create all tables, see preserve file"); | 1337 | } |
| 1338 | |||
| 1339 | if ((create_results = safe_mysql_query(orig, create_notes)) != 0) { | ||
| 1340 | cls->table_made = 0; | ||
| 1341 | ap_log_error(APLOG_MARK,ERRLEVEL,orig->server,"mod_log_sql: failed to create notes table, see preserve file"); | ||
| 1342 | } | ||
| 1343 | |||
| 1344 | if ((create_results = safe_mysql_query(orig, create_hin)) != 0) { | ||
| 1345 | cls->table_made = 0; | ||
| 1346 | ap_log_error(APLOG_MARK,ERRLEVEL,orig->server,"mod_log_sql: failed to create header_out table, see preserve file"); | ||
| 1347 | } | ||
| 1348 | |||
| 1349 | if ((create_results = safe_mysql_query(orig, create_hout)) != 0) { | ||
| 1350 | cls->table_made = 0; | ||
| 1351 | ap_log_error(APLOG_MARK,ERRLEVEL,orig->server,"mod_log_sql: failed to create header_in table, see preserve file"); | ||
| 1352 | } | ||
| 1325 | } | 1353 | } |
| 1326 | 1354 | ||
| 1327 | /* Make the access-table insert */ | 1355 | /* Make the access-table insert */ |
| 1328 | safe_mysql_query(orig, access_query); | 1356 | safe_mysql_query(orig, access_query); |
| 1329 | 1357 | ||
| 1330 | /* If notes are available to log, make the notes-table insert */ | 1358 | /* Log the optional notes, headers, etc. */ |
| 1331 | if ( note_query != NULL ) | 1359 | if ( note_query != NULL ) |
| 1332 | safe_mysql_query(orig, note_query); | 1360 | safe_mysql_query(orig, note_query); |
| 1333 | 1361 | ||
