summaryrefslogtreecommitdiffstats
path: root/mod_log_sql.c
diff options
context:
space:
mode:
Diffstat (limited to 'mod_log_sql.c')
-rw-r--r--mod_log_sql.c233
1 files changed, 121 insertions, 112 deletions
diff --git a/mod_log_sql.c b/mod_log_sql.c
index d58839b..d604e78 100644
--- a/mod_log_sql.c
+++ b/mod_log_sql.c
@@ -1,4 +1,3 @@
1/* $Id: mod_log_sql.c,v 1.21 2002/12/10 20:37:28 helios Exp $ */
2 1
3/* --------* 2/* --------*
4 * DEFINES * 3 * DEFINES *
@@ -48,22 +47,23 @@ module sql_log_module;
48 * on a per-virtual-server basis. Every virtual server 'knows' the 47 * on a per-virtual-server basis. Every virtual server 'knows' the
49 * same versions of these variables. 48 * same versions of these variables.
50 */ 49 */
51MYSQL sql_server, *mysql_log = NULL; 50MYSQL logsql_server, *logsql_server_p = NULL;
52 51
53int massvirtual = 0; 52int logsql_massvirtual = 0;
54int create_tables = 0; 53int logsql_createtables = 0;
55int force_preserve = 0; 54int logsql_forcepreserve = 0;
56char *db_name = NULL; 55char *logsql_dbname = NULL;
57char *db_host = NULL; 56char *logsql_dbhost = NULL;
58char *db_user = NULL; 57char *logsql_dbuser = NULL;
59char *db_pwd = NULL; 58char *logsql_dbpwd = NULL;
60char *mach_id = NULL; 59char *logsql_machid = NULL;
61char *socket_file = "/tmp/mysql.sock"; 60char *logsql_socketfile = "/tmp/mysql.sock";
62unsigned int tcp_port = 3306; 61unsigned int logsql_tcpport = 3306;
62
63#ifdef WANT_DELAYED_MYSQL_INSERT 63#ifdef WANT_DELAYED_MYSQL_INSERT
64 char *insert_stmt = "insert delayed into "; 64 char *logsql_insertclause = "insert delayed into ";
65#else 65#else
66 char *insert_stmt = "insert into "; 66 char *logsql_insertclause = "insert into ";
67#endif 67#endif
68 68
69typedef const char *(*item_key_func) (request_rec *, char *); 69typedef const char *(*item_key_func) (request_rec *, char *);
@@ -90,14 +90,14 @@ typedef struct {
90 char *transfer_log_format; 90 char *transfer_log_format;
91 char *preserve_file; 91 char *preserve_file;
92 char *cookie_name; 92 char *cookie_name;
93} log_sql_state; 93} logsql_state;
94 94
95 95
96/* -----------------* 96/* -----------------*
97 * HELPER FUNCTIONS * 97 * HELPER FUNCTIONS *
98 * -----------------*/ 98 * -----------------*/
99 99
100int safe_create_tables(log_sql_state *cls, request_rec *r); 100int safe_create_tables(logsql_state *cls, request_rec *r);
101 101
102static char *format_integer(pool *p, int i) 102static char *format_integer(pool *p, int i)
103{ 103{
@@ -220,6 +220,11 @@ static const char *extract_request_uri(request_rec *r, char *a)
220 return r->uri; 220 return r->uri;
221} 221}
222 222
223static const char *extract_request_args(request_rec *r, char *a)
224{
225 return r->args;
226}
227
223static const char *extract_status(request_rec *r, char *a) 228static const char *extract_status(request_rec *r, char *a)
224{ 229{
225 return pfmt(r->pool, r->status); 230 return pfmt(r->pool, r->status);
@@ -295,10 +300,10 @@ static const char *extract_virtual_host(request_rec *r, char *a)
295 300
296static const char *extract_machine_id(request_rec *r, char *a) 301static const char *extract_machine_id(request_rec *r, char *a)
297{ 302{
298 if (!mach_id) 303 if (!logsql_machid)
299 return "-"; 304 return "-";
300 else 305 else
301 return mach_id; 306 return logsql_machid;
302} 307}
303 308
304static const char *extract_server_port(request_rec *r, char *a) 309static const char *extract_server_port(request_rec *r, char *a)
@@ -349,7 +354,7 @@ static const char *extract_cookie(request_rec *r, char *a)
349 char *isvalid; 354 char *isvalid;
350 char *cookiebuf; 355 char *cookiebuf;
351 356
352 log_sql_state *cls = get_module_config(r->server->module_config, &sql_log_module); 357 logsql_state *cls = get_module_config(r->server->module_config, &sql_log_module);
353 358
354 if (cls->cookie_name != NULL) { 359 if (cls->cookie_name != NULL) {
355 #ifdef DEBUG 360 #ifdef DEBUG
@@ -530,6 +535,7 @@ struct log_sql_item_list {
530 } log_sql_item_keys[] = { 535 } log_sql_item_keys[] = {
531 536
532 { 'A', extract_agent, "agent", 1, 1 }, 537 { 'A', extract_agent, "agent", 1, 1 },
538 { 'a', extract_request_args, "request_args", 1, 1 },
533 { 'b', extract_bytes_sent, "bytes_sent", 0, 0 }, 539 { 'b', extract_bytes_sent, "bytes_sent", 0, 0 },
534 { 'c', extract_cookie, "cookie", 0, 1 }, 540 { 'c', extract_cookie, "cookie", 0, 1 },
535 { 'e', extract_env_var, "env_var", 0, 1 }, 541 { 'e', extract_env_var, "env_var", 0, 1 },
@@ -580,7 +586,7 @@ const char *escape_query(const char *from_str, pool *p)
580 return from_str; 586 return from_str;
581 } 587 }
582 588
583 if (!mysql_log) { 589 if (!logsql_server_p) {
584 /* Well, I would have liked to use the current database charset. mysql is 590 /* Well, I would have liked to use the current database charset. mysql is
585 * unavailable, however, so I fall back to the slightly less respectful 591 * unavailable, however, so I fall back to the slightly less respectful
586 * mysql_escape_string() function that uses the default charset. 592 * mysql_escape_string() function that uses the default charset.
@@ -590,7 +596,7 @@ const char *escape_query(const char *from_str, pool *p)
590 /* MySQL is available, so I'll go ahead and respect the current charset when 596 /* MySQL is available, so I'll go ahead and respect the current charset when
591 * I perform the escape. 597 * I perform the escape.
592 */ 598 */
593 retval = mysql_real_escape_string(mysql_log, to_str, from_str, length); 599 retval = mysql_real_escape_string(logsql_server_p, to_str, from_str, length);
594 } 600 }
595 601
596 if (retval) 602 if (retval)
@@ -609,33 +615,34 @@ int open_logdb_link(server_rec* s)
609 0 if unsuccessful 615 0 if unsuccessful
610 */ 616 */
611 617
612 if (force_preserve) 618 if (logsql_forcepreserve)
613 return 3; 619 return 3;
614 620
615 if (mysql_log) 621 if (logsql_server_p)
616 return 2; 622 return 2;
617 623
618 if (db_name) { 624 if ((logsql_dbname) && (logsql_dbhost) && (logsql_dbuser) && (logsql_dbpwd)) {
619 mysql_init(&sql_server); 625 mysql_init(&logsql_server);
620 mysql_log = mysql_real_connect(&sql_server, db_host, db_user, db_pwd, db_name, tcp_port, socket_file, 0); 626 logsql_server_p = mysql_real_connect(&logsql_server, logsql_dbhost, logsql_dbuser, logsql_dbpwd, logsql_dbname, logsql_tcpport, logsql_socketfile, 0);
621 627
622 if (mysql_log) { 628 if (logsql_server_p) {
623 #ifdef DEBUG 629 #ifdef DEBUG
624 ap_log_error(APLOG_MARK,DEBUGLEVEL,s,"HOST: '%s' PORT: '%d' DB: '%s' USER: '%s' SOCKET: '%s'", 630 ap_log_error(APLOG_MARK,DEBUGLEVEL,s,"HOST: '%s' PORT: '%d' DB: '%s' USER: '%s' SOCKET: '%s'",
625 db_host, tcp_port, db_name, db_user, socket_file); 631 logsql_dbhost, logsql_tcpport, logsql_dbname, logsql_dbuser, logsql_socketfile);
626 #endif 632 #endif
627 return 1; 633 return 1;
628 } else { 634 } else {
629 #ifdef DEBUG 635 #ifdef DEBUG
630 ap_log_error(APLOG_MARK,DEBUGLEVEL,s,"mod_log_sql: database connection error: %s",MYSQL_ERROR(&sql_server)); 636 ap_log_error(APLOG_MARK,DEBUGLEVEL,s,"mod_log_sql: database connection error: %s",MYSQL_ERROR(&logsql_server));
631 ap_log_error(APLOG_MARK,DEBUGLEVEL,s,"HOST: '%s' PORT: '%d' DB: '%s' USER: '%s' SOCKET: '%s'", 637 ap_log_error(APLOG_MARK,DEBUGLEVEL,s,"HOST: '%s' PORT: '%d' DB: '%s' USER: '%s' SOCKET: '%s'",
632 db_host, tcp_port, db_name, db_user, socket_file); 638 logsql_dbhost, logsql_tcpport, logsql_dbname, logsql_dbuser, logsql_socketfile);
633 #endif 639 #endif
634 return 0; 640 return 0;
635 } 641 }
642 } else {
643 ap_log_error(APLOG_MARK,ERRLEVEL,s,"mod_log_sql: insufficient configuration info to establish database link");
644 return 0;
636 } 645 }
637
638 return 0;
639} 646}
640 647
641const char *extract_table(void *data, const char *key, const char *val) 648const char *extract_table(void *data, const char *key, const char *val)
@@ -648,7 +655,7 @@ const char *extract_table(void *data, const char *key, const char *val)
648void preserve_entry(request_rec *r, const char *query) 655void preserve_entry(request_rec *r, const char *query)
649{ 656{
650 FILE *fp; 657 FILE *fp;
651 log_sql_state *cls = get_module_config(r->server->module_config, &sql_log_module); 658 logsql_state *cls = get_module_config(r->server->module_config, &sql_log_module);
652 659
653 fp = pfopen(r->pool, cls->preserve_file, "a"); 660 fp = pfopen(r->pool, cls->preserve_file, "a");
654 if (fp == NULL) 661 if (fp == NULL)
@@ -664,7 +671,7 @@ void preserve_entry(request_rec *r, const char *query)
664 671
665 672
666/*-----------------------------------------------------*/ 673/*-----------------------------------------------------*/
667/* safe_mysql_query: perform a database query with */ 674/* safe_sql_query: perform a database query with */
668/* a degree of safety and error checking. */ 675/* a degree of safety and error checking. */
669/* */ 676/* */
670/* Parms: request record, SQL insert statement */ 677/* Parms: request record, SQL insert statement */
@@ -673,13 +680,13 @@ void preserve_entry(request_rec *r, const char *query)
673/* 2 if insert delayed failed (kluge) */ 680/* 2 if insert delayed failed (kluge) */
674/* the actual MySQL return code on error */ 681/* the actual MySQL return code on error */
675/*-----------------------------------------------------*/ 682/*-----------------------------------------------------*/
676unsigned int safe_mysql_query(request_rec *r, const char *query) 683unsigned int safe_sql_query(request_rec *r, const char *query)
677{ 684{
678 int retval; 685 int retval;
679 struct timespec delay, remainder; 686 struct timespec delay, remainder;
680 int ret; 687 int ret;
681 void (*handler) (int); 688 void (*handler) (int);
682 log_sql_state *cls; 689 logsql_state *cls;
683 unsigned int real_error; 690 unsigned int real_error;
684 #ifdef WANT_DELAYED_MYSQL_INSERT 691 #ifdef WANT_DELAYED_MYSQL_INSERT
685 char *real_error_str; 692 char *real_error_str;
@@ -689,10 +696,10 @@ unsigned int safe_mysql_query(request_rec *r, const char *query)
689 handler = signal(SIGPIPE, SIG_IGN); 696 handler = signal(SIGPIPE, SIG_IGN);
690 697
691 /* First attempt for the query */ 698 /* First attempt for the query */
692 if (!mysql_log) { 699 if (!logsql_server_p) {
693 signal(SIGPIPE, handler); 700 signal(SIGPIPE, handler);
694 return 1; 701 return 1;
695 } else if (!(retval = mysql_query(mysql_log, query))) { 702 } else if (!(retval = mysql_query(logsql_server_p, query))) {
696 signal(SIGPIPE, handler); 703 signal(SIGPIPE, handler);
697 return 0; 704 return 0;
698 } 705 }
@@ -701,9 +708,9 @@ unsigned int safe_mysql_query(request_rec *r, const char *query)
701 * (After all, the module thought it had a valid mysql_log connection but the query 708 * (After all, the module thought it had a valid mysql_log connection but the query
702 * could have failed for a number of reasons, so we have to be extra-safe and check.) */ 709 * could have failed for a number of reasons, so we have to be extra-safe and check.) */
703 #ifdef WANT_DELAYED_MYSQL_INSERT 710 #ifdef WANT_DELAYED_MYSQL_INSERT
704 real_error_str = MYSQL_ERROR(mysql_log); 711 real_error_str = MYSQL_ERROR(logsql_server_p);
705 #else 712 #else
706 real_error = mysql_errno(mysql_log); 713 real_error = mysql_errno(logsql_server_p);
707 #endif 714 #endif
708 715
709 /* Check to see if the error is "nonexistent table" */ 716 /* Check to see if the error is "nonexistent table" */
@@ -712,19 +719,19 @@ unsigned int safe_mysql_query(request_rec *r, const char *query)
712 #else 719 #else
713 if (real_error == ER_NO_SUCH_TABLE) { 720 if (real_error == ER_NO_SUCH_TABLE) {
714 #endif 721 #endif
715 if (create_tables) { 722 if (logsql_createtables) {
716 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: table doesn't exist...creating now"); 723 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: table doesn't exist...creating now");
717 cls = get_module_config(r->server->module_config, &sql_log_module); 724 cls = get_module_config(r->server->module_config, &sql_log_module);
718 if (safe_create_tables(cls, r)) { 725 if (safe_create_tables(cls, r)) {
719 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: child attempted but failed to create one or more tables for %s, preserving query", ap_get_server_name(r)); 726 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: child attempted but failed to create one or more tables for %s, preserving query", ap_get_server_name(r));
720 preserve_entry(r, query); 727 preserve_entry(r, query);
721 retval = mysql_errno(mysql_log); 728 retval = mysql_errno(logsql_server_p);
722 } else { 729 } else {
723 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: tables successfully created - retrying query"); 730 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: tables successfully created - retrying query");
724 if (mysql_query(mysql_log, query)) { 731 if (mysql_query(logsql_server_p, query)) {
725 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: giving up, preserving query"); 732 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: giving up, preserving query");
726 preserve_entry(r, query); 733 preserve_entry(r, query);
727 retval = mysql_errno(mysql_log); 734 retval = mysql_errno(logsql_server_p);
728 } else 735 } else
729 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: query successful after table creation"); 736 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: query successful after table creation");
730 retval = 0; 737 retval = 0;
@@ -747,14 +754,14 @@ unsigned int safe_mysql_query(request_rec *r, const char *query)
747 #ifdef WANT_DELAYED_MYSQL_INSERT 754 #ifdef WANT_DELAYED_MYSQL_INSERT
748 real_error = 2; 755 real_error = 2;
749 #else 756 #else
750 real_error = mysql_errno(mysql_log); 757 real_error = mysql_errno(logsql_server_p);
751 #endif 758 #endif
752 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)); 759 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: first attempt failed, API said: error %d, \"%s\"", real_error, MYSQL_ERROR(logsql_server_p));
753 mysql_close(mysql_log); 760 mysql_close(logsql_server_p);
754 mysql_log = NULL; 761 logsql_server_p = NULL;
755 open_logdb_link(r->server); 762 open_logdb_link(r->server);
756 763
757 if (mysql_log == NULL) { /* still unable to link */ 764 if (logsql_server_p == NULL) { /* still unable to link */
758 signal(SIGPIPE, handler); 765 signal(SIGPIPE, handler);
759 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: reconnect failed, unable to reach database. SQL logging stopped until child regains a db connection."); 766 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: reconnect failed, unable to reach database. SQL logging stopped until child regains a db connection.");
760 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: log entries are being preserved in %s", cls->preserve_file); 767 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: log entries are being preserved in %s", cls->preserve_file);
@@ -770,16 +777,16 @@ unsigned int safe_mysql_query(request_rec *r, const char *query)
770 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: nanosleep unsuccessful"); 777 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: nanosleep unsuccessful");
771 778
772 /* Then make our second attempt */ 779 /* Then make our second attempt */
773 retval = mysql_query(mysql_log,query); 780 retval = mysql_query(logsql_server_p,query);
774 781
775 /* If this one also failed, log that and append to our local offline file */ 782 /* If this one also failed, log that and append to our local offline file */
776 if (retval) { 783 if (retval) {
777 #ifdef WANT_DELAYED_MYSQL_INSERT 784 #ifdef WANT_DELAYED_MYSQL_INSERT
778 real_error = 2; 785 real_error = 2;
779 #else 786 #else
780 real_error = mysql_errno(mysql_log); 787 real_error = mysql_errno(logsql_server_p);
781 #endif 788 #endif
782 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: second attempt failed, API said: error %d, \"%s\" -- preserving", real_error, MYSQL_ERROR(mysql_log)); 789 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: second attempt failed, API said: error %d, \"%s\" -- preserving", real_error, MYSQL_ERROR(logsql_server_p));
783 preserve_entry(r, query); 790 preserve_entry(r, query);
784 retval = real_error; 791 retval = real_error;
785 } else 792 } else
@@ -798,7 +805,7 @@ unsigned int safe_mysql_query(request_rec *r, const char *query)
798/* Returns: 0 on no errors */ 805/* Returns: 0 on no errors */
799/* mysql error code on failure */ 806/* mysql error code on failure */
800/*-----------------------------------------------------*/ 807/*-----------------------------------------------------*/
801int safe_create_tables(log_sql_state *cls, request_rec *r) 808int safe_create_tables(logsql_state *cls, request_rec *r)
802{ 809{
803 int retval; 810 int retval;
804 unsigned int create_results; 811 unsigned int create_results;
@@ -827,6 +834,7 @@ int safe_create_tables(log_sql_state *cls, request_rec *r)
827 request_protocol varchar(10),\ 834 request_protocol varchar(10),\
828 request_time char(28),\ 835 request_time char(28),\
829 request_uri varchar(50),\ 836 request_uri varchar(50),\
837 request_args varchar(255),\
830 server_port smallint unsigned,\ 838 server_port smallint unsigned,\
831 ssl_cipher varchar(25),\ 839 ssl_cipher varchar(25),\
832 ssl_keysize smallint unsigned,\ 840 ssl_keysize smallint unsigned,\
@@ -868,27 +876,27 @@ int safe_create_tables(log_sql_state *cls, request_rec *r)
868 /* Assume that things worked unless told otherwise */ 876 /* Assume that things worked unless told otherwise */
869 retval = 0; 877 retval = 0;
870 878
871 if ((create_results = safe_mysql_query(r, create_access))) { 879 if ((create_results = safe_sql_query(r, create_access))) {
872 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: failed to create access table"); 880 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: failed to create access table");
873 retval = create_results; 881 retval = create_results;
874 } 882 }
875 883
876 if ((create_results = safe_mysql_query(r, create_notes))) { 884 if ((create_results = safe_sql_query(r, create_notes))) {
877 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: failed to create notes table"); 885 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: failed to create notes table");
878 retval = create_results; 886 retval = create_results;
879 } 887 }
880 888
881 if ((create_results = safe_mysql_query(r, create_hin))) { 889 if ((create_results = safe_sql_query(r, create_hin))) {
882 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: failed to create header_out table"); 890 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: failed to create header_out table");
883 retval = create_results; 891 retval = create_results;
884 } 892 }
885 893
886 if ((create_results = safe_mysql_query(r, create_hout))) { 894 if ((create_results = safe_sql_query(r, create_hout))) {
887 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: failed to create header_in table"); 895 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: failed to create header_in table");
888 retval = create_results; 896 retval = create_results;
889 } 897 }
890 898
891 if ((create_results = safe_mysql_query(r, create_cookies))) { 899 if ((create_results = safe_sql_query(r, create_cookies))) {
892 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: failed to create cookies table"); 900 ap_log_error(APLOG_MARK,ERRLEVEL,r->server,"mod_log_sql: failed to create cookies table");
893 retval = create_results; 901 retval = create_results;
894 } 902 }
@@ -903,40 +911,40 @@ int safe_create_tables(log_sql_state *cls, request_rec *r)
903 911
904const char *set_log_sql_massvirtual(cmd_parms *parms, void *dummy, int flag) 912const char *set_log_sql_massvirtual(cmd_parms *parms, void *dummy, int flag)
905{ 913{
906 massvirtual = ( flag ? 1 : 0); 914 logsql_massvirtual = ( flag ? 1 : 0);
907 return NULL; 915 return NULL;
908} 916}
909 917
910const char *set_log_sql_force_preserve(cmd_parms *parms, void *dummy, int flag) 918const char *set_log_sql_force_preserve(cmd_parms *parms, void *dummy, int flag)
911{ 919{
912 force_preserve = ( flag ? 1 : 0); 920 logsql_forcepreserve = ( flag ? 1 : 0);
913 return NULL; 921 return NULL;
914} 922}
915 923
916const char *set_log_sql_machine_id(cmd_parms *parms, void *dummy, char *arg) 924const char *set_log_sql_machine_id(cmd_parms *parms, void *dummy, char *arg)
917{ 925{
918 mach_id = arg; 926 logsql_machid = arg;
919 return NULL; 927 return NULL;
920} 928}
921 929
922const char *set_log_sql_create(cmd_parms *parms, void *dummy, int flag) 930const char *set_log_sql_create(cmd_parms *parms, void *dummy, int flag)
923{ 931{
924 if (massvirtual) 932 if (logsql_massvirtual)
925 ap_log_error(APLOG_MARK,WARNINGLEVEL,parms->server,"mod_log_sql: do not set LogSQLCreateTables when LogSQLMassVirtualHosting is On. Ignoring."); 933 ap_log_error(APLOG_MARK,WARNINGLEVEL,parms->server,"mod_log_sql: do not set LogSQLCreateTables when LogSQLMassVirtualHosting is On. Ignoring.");
926 else 934 else
927 create_tables = ( flag ? 1 : 0); 935 logsql_createtables = ( flag ? 1 : 0);
928 return NULL; 936 return NULL;
929} 937}
930 938
931const char *set_log_sql_db(cmd_parms *parms, void *dummy, char *arg) 939const char *set_log_sql_db(cmd_parms *parms, void *dummy, char *arg)
932{ 940{
933 db_name = arg; 941 logsql_dbname = arg;
934 return NULL; 942 return NULL;
935} 943}
936 944
937const char *set_log_sql_cookie(cmd_parms *parms, void *dummy, char *arg) 945const char *set_log_sql_cookie(cmd_parms *parms, void *dummy, char *arg)
938{ 946{
939 log_sql_state *cls = get_module_config(parms->server->module_config, &sql_log_module); 947 logsql_state *cls = get_module_config(parms->server->module_config, &sql_log_module);
940 948
941 cls->cookie_name = arg; 949 cls->cookie_name = arg;
942 return NULL; 950 return NULL;
@@ -945,7 +953,7 @@ const char *set_log_sql_cookie(cmd_parms *parms, void *dummy, char *arg)
945const char *set_log_sql_preserve_file(cmd_parms *parms, void *dummy, char *arg) 953const char *set_log_sql_preserve_file(cmd_parms *parms, void *dummy, char *arg)
946{ 954{
947 /* char *pfile; */ 955 /* char *pfile; */
948 log_sql_state *cls = get_module_config(parms->server->module_config, &sql_log_module); 956 logsql_state *cls = get_module_config(parms->server->module_config, &sql_log_module);
949 957
950 /* pfile = ap_pstrcat(parms->pool, "/tmp/", arg, NULL); */ 958 /* pfile = ap_pstrcat(parms->pool, "/tmp/", arg, NULL); */
951 cls->preserve_file = arg; 959 cls->preserve_file = arg;
@@ -955,22 +963,22 @@ const char *set_log_sql_preserve_file(cmd_parms *parms, void *dummy, char *arg)
955const char *set_log_sql_info(cmd_parms *parms, void *dummy, char *host, char *user, char *pwd) 963const char *set_log_sql_info(cmd_parms *parms, void *dummy, char *host, char *user, char *pwd)
956{ 964{
957 if (*host != '.') { 965 if (*host != '.') {
958 db_host = host; 966 logsql_dbhost = host;
959 } 967 }
960 if (*user != '.') { 968 if (*user != '.') {
961 db_user = user; 969 logsql_dbuser = user;
962 } 970 }
963 if (*pwd != '.') { 971 if (*pwd != '.') {
964 db_pwd = pwd; 972 logsql_dbpwd = pwd;
965 } 973 }
966 return NULL; 974 return NULL;
967} 975}
968 976
969const char *set_log_sql_transfer_table(cmd_parms *parms, void *dummy, char *arg) 977const char *set_log_sql_transfer_table(cmd_parms *parms, void *dummy, char *arg)
970{ 978{
971 log_sql_state *cls = get_module_config(parms->server->module_config, &sql_log_module); 979 logsql_state *cls = get_module_config(parms->server->module_config, &sql_log_module);
972 980
973 if (massvirtual != 0) 981 if (logsql_massvirtual != 0)
974 ap_log_error(APLOG_MARK,WARNINGLEVEL,parms->server,"mod_log_sql: do not set LogSQLTransferLogTable when LogSQLMassVirtualHosting is On. Ignoring."); 982 ap_log_error(APLOG_MARK,WARNINGLEVEL,parms->server,"mod_log_sql: do not set LogSQLTransferLogTable when LogSQLMassVirtualHosting is On. Ignoring.");
975 else 983 else
976 cls->transfer_table_name = arg; 984 cls->transfer_table_name = arg;
@@ -979,9 +987,9 @@ const char *set_log_sql_transfer_table(cmd_parms *parms, void *dummy, char *arg)
979 987
980const char *set_log_sql_cookie_table(cmd_parms *parms, void *dummy, char *arg) 988const char *set_log_sql_cookie_table(cmd_parms *parms, void *dummy, char *arg)
981{ 989{
982 log_sql_state *cls = get_module_config(parms->server->module_config, &sql_log_module); 990 logsql_state *cls = get_module_config(parms->server->module_config, &sql_log_module);
983 991
984 if (massvirtual != 0) 992 if (logsql_massvirtual != 0)
985 ap_log_error(APLOG_MARK,WARNINGLEVEL,parms->server,"mod_log_sql: do not set LogSQLCookieLogTable when LogSQLMassVirtualHosting is On. Ignoring."); 993 ap_log_error(APLOG_MARK,WARNINGLEVEL,parms->server,"mod_log_sql: do not set LogSQLCookieLogTable when LogSQLMassVirtualHosting is On. Ignoring.");
986 else 994 else
987 cls->cookie_table_name = arg; 995 cls->cookie_table_name = arg;
@@ -990,9 +998,9 @@ const char *set_log_sql_cookie_table(cmd_parms *parms, void *dummy, char *arg)
990 998
991const char *set_log_sql_notes_table(cmd_parms *parms, void *dummy, char *arg) 999const char *set_log_sql_notes_table(cmd_parms *parms, void *dummy, char *arg)
992{ 1000{
993 log_sql_state *cls = get_module_config(parms->server->module_config, &sql_log_module); 1001 logsql_state *cls = get_module_config(parms->server->module_config, &sql_log_module);
994 1002
995 if (massvirtual != 0) 1003 if (logsql_massvirtual != 0)
996 ap_log_error(APLOG_MARK,WARNINGLEVEL,parms->server,"mod_log_sql: do not set LogSQLNotesLogTable when LogSQLMassVirtualHosting is On. Ignoring."); 1004 ap_log_error(APLOG_MARK,WARNINGLEVEL,parms->server,"mod_log_sql: do not set LogSQLNotesLogTable when LogSQLMassVirtualHosting is On. Ignoring.");
997 else 1005 else
998 cls->notes_table_name = arg; 1006 cls->notes_table_name = arg;
@@ -1001,9 +1009,9 @@ const char *set_log_sql_notes_table(cmd_parms *parms, void *dummy, char *arg)
1001 1009
1002const char *set_log_sql_hin_table(cmd_parms *parms, void *dummy, char *arg) 1010const char *set_log_sql_hin_table(cmd_parms *parms, void *dummy, char *arg)
1003{ 1011{
1004 log_sql_state *cls = get_module_config(parms->server->module_config, &sql_log_module); 1012 logsql_state *cls = get_module_config(parms->server->module_config, &sql_log_module);
1005 1013
1006 if (massvirtual != 0) 1014 if (logsql_massvirtual != 0)
1007 ap_log_error(APLOG_MARK,WARNINGLEVEL,parms->server,"mod_log_sql: do not set LogSQLHeadersInLogTable when LogSQLMassVirtualHosting is On. Ignoring."); 1015 ap_log_error(APLOG_MARK,WARNINGLEVEL,parms->server,"mod_log_sql: do not set LogSQLHeadersInLogTable when LogSQLMassVirtualHosting is On. Ignoring.");
1008 else 1016 else
1009 cls->hin_table_name = arg; 1017 cls->hin_table_name = arg;
@@ -1012,9 +1020,9 @@ const char *set_log_sql_hin_table(cmd_parms *parms, void *dummy, char *arg)
1012 1020
1013const char *set_log_sql_hout_table(cmd_parms *parms, void *dummy, char *arg) 1021const char *set_log_sql_hout_table(cmd_parms *parms, void *dummy, char *arg)
1014{ 1022{
1015 log_sql_state *cls = get_module_config(parms->server->module_config, &sql_log_module); 1023 logsql_state *cls = get_module_config(parms->server->module_config, &sql_log_module);
1016 1024
1017 if (massvirtual != 0) 1025 if (logsql_massvirtual != 0)
1018 ap_log_error(APLOG_MARK,WARNINGLEVEL,parms->server,"mod_log_sql: do not set LogSQLHeadersOutLogTable when LogSQLMassVirtualHosting is On. Ignoring."); 1026 ap_log_error(APLOG_MARK,WARNINGLEVEL,parms->server,"mod_log_sql: do not set LogSQLHeadersOutLogTable when LogSQLMassVirtualHosting is On. Ignoring.");
1019 else 1027 else
1020 cls->hout_table_name = arg; 1028 cls->hout_table_name = arg;
@@ -1023,7 +1031,7 @@ const char *set_log_sql_hout_table(cmd_parms *parms, void *dummy, char *arg)
1023 1031
1024const char *set_log_sql_transfer_log_format(cmd_parms *parms, void *dummy, char *arg) 1032const char *set_log_sql_transfer_log_format(cmd_parms *parms, void *dummy, char *arg)
1025{ 1033{
1026 log_sql_state *cls = get_module_config(parms->server->module_config, &sql_log_module); 1034 logsql_state *cls = get_module_config(parms->server->module_config, &sql_log_module);
1027 1035
1028 cls->transfer_log_format = arg; 1036 cls->transfer_log_format = arg;
1029 return NULL; 1037 return NULL;
@@ -1031,14 +1039,14 @@ const char *set_log_sql_transfer_log_format(cmd_parms *parms, void *dummy, char
1031 1039
1032const char *set_log_sql_socket_file(cmd_parms *parms, void *dummy, char *arg) 1040const char *set_log_sql_socket_file(cmd_parms *parms, void *dummy, char *arg)
1033{ 1041{
1034 socket_file = arg; 1042 logsql_socketfile = arg;
1035 1043
1036 return NULL; 1044 return NULL;
1037} 1045}
1038 1046
1039const char *set_log_sql_tcp_port(cmd_parms *parms, void *dummy, char *arg) 1047const char *set_log_sql_tcp_port(cmd_parms *parms, void *dummy, char *arg)
1040{ 1048{
1041 tcp_port = (unsigned int)atoi(arg); 1049 logsql_tcpport = (unsigned int)atoi(arg);
1042 1050
1043 return NULL; 1051 return NULL;
1044} 1052}
@@ -1046,7 +1054,7 @@ const char *set_log_sql_tcp_port(cmd_parms *parms, void *dummy, char *arg)
1046const char *add_log_sql_transfer_accept(cmd_parms *parms, void *dummy, char *arg) 1054const char *add_log_sql_transfer_accept(cmd_parms *parms, void *dummy, char *arg)
1047{ 1055{
1048 char **addme; 1056 char **addme;
1049 log_sql_state *cls = get_module_config(parms->server->module_config, &sql_log_module); 1057 logsql_state *cls = get_module_config(parms->server->module_config, &sql_log_module);
1050 1058
1051 addme = push_array(cls->transfer_accept_list); 1059 addme = push_array(cls->transfer_accept_list);
1052 *addme = pstrdup(cls->transfer_accept_list->pool, arg); 1060 *addme = pstrdup(cls->transfer_accept_list->pool, arg);
@@ -1056,7 +1064,7 @@ const char *add_log_sql_transfer_accept(cmd_parms *parms, void *dummy, char *arg
1056const char *add_log_sql_transfer_ignore(cmd_parms *parms, void *dummy, char *arg) 1064const char *add_log_sql_transfer_ignore(cmd_parms *parms, void *dummy, char *arg)
1057{ 1065{
1058 char **addme; 1066 char **addme;
1059 log_sql_state *cls = get_module_config(parms->server->module_config, &sql_log_module); 1067 logsql_state *cls = get_module_config(parms->server->module_config, &sql_log_module);
1060 1068
1061 addme = push_array(cls->transfer_ignore_list); 1069 addme = push_array(cls->transfer_ignore_list);
1062 *addme = pstrdup(cls->transfer_ignore_list->pool, arg); 1070 *addme = pstrdup(cls->transfer_ignore_list->pool, arg);
@@ -1066,7 +1074,7 @@ const char *add_log_sql_transfer_ignore(cmd_parms *parms, void *dummy, char *arg
1066const char *add_log_sql_remhost_ignore(cmd_parms *parms, void *dummy, char *arg) 1074const char *add_log_sql_remhost_ignore(cmd_parms *parms, void *dummy, char *arg)
1067{ 1075{
1068 char **addme; 1076 char **addme;
1069 log_sql_state *cls = get_module_config(parms->server->module_config, &sql_log_module); 1077 logsql_state *cls = get_module_config(parms->server->module_config, &sql_log_module);
1070 1078
1071 addme = push_array(cls->remhost_ignore_list); 1079 addme = push_array(cls->remhost_ignore_list);
1072 *addme = pstrdup(cls->remhost_ignore_list->pool, arg); 1080 *addme = pstrdup(cls->remhost_ignore_list->pool, arg);
@@ -1076,7 +1084,7 @@ const char *add_log_sql_remhost_ignore(cmd_parms *parms, void *dummy, char *arg)
1076const char *add_log_sql_note(cmd_parms *parms, void *dummy, char *arg) 1084const char *add_log_sql_note(cmd_parms *parms, void *dummy, char *arg)
1077{ 1085{
1078 char **addme; 1086 char **addme;
1079 log_sql_state *cls = get_module_config(parms->server->module_config, &sql_log_module); 1087 logsql_state *cls = get_module_config(parms->server->module_config, &sql_log_module);
1080 1088
1081 addme = push_array(cls->notes_list); 1089 addme = push_array(cls->notes_list);
1082 *addme = pstrdup(cls->notes_list->pool, arg); 1090 *addme = pstrdup(cls->notes_list->pool, arg);
@@ -1086,7 +1094,7 @@ const char *add_log_sql_note(cmd_parms *parms, void *dummy, char *arg)
1086const char *add_log_sql_hout(cmd_parms *parms, void *dummy, char *arg) 1094const char *add_log_sql_hout(cmd_parms *parms, void *dummy, char *arg)
1087{ 1095{
1088 char **addme; 1096 char **addme;
1089 log_sql_state *cls = get_module_config(parms->server->module_config, &sql_log_module); 1097 logsql_state *cls = get_module_config(parms->server->module_config, &sql_log_module);
1090 1098
1091 addme = push_array(cls->hout_list); 1099 addme = push_array(cls->hout_list);
1092 *addme = pstrdup(cls->hout_list->pool, arg); 1100 *addme = pstrdup(cls->hout_list->pool, arg);
@@ -1096,7 +1104,7 @@ const char *add_log_sql_hout(cmd_parms *parms, void *dummy, char *arg)
1096const char *add_log_sql_hin(cmd_parms *parms, void *dummy, char *arg) 1104const char *add_log_sql_hin(cmd_parms *parms, void *dummy, char *arg)
1097{ 1105{
1098 char **addme; 1106 char **addme;
1099 log_sql_state *cls = get_module_config(parms->server->module_config, &sql_log_module); 1107 logsql_state *cls = get_module_config(parms->server->module_config, &sql_log_module);
1100 1108
1101 addme = push_array(cls->hin_list); 1109 addme = push_array(cls->hin_list);
1102 *addme = pstrdup(cls->hin_list->pool, arg); 1110 *addme = pstrdup(cls->hin_list->pool, arg);
@@ -1106,7 +1114,7 @@ const char *add_log_sql_hin(cmd_parms *parms, void *dummy, char *arg)
1106const char *add_log_sql_cookie(cmd_parms *parms, void *dummy, char *arg) 1114const char *add_log_sql_cookie(cmd_parms *parms, void *dummy, char *arg)
1107{ 1115{
1108 char **addme; 1116 char **addme;
1109 log_sql_state *cls = get_module_config(parms->server->module_config, &sql_log_module); 1117 logsql_state *cls = get_module_config(parms->server->module_config, &sql_log_module);
1110 1118
1111 addme = push_array(cls->cookie_list); 1119 addme = push_array(cls->cookie_list);
1112 *addme = pstrdup(cls->cookie_list->pool, arg); 1120 *addme = pstrdup(cls->cookie_list->pool, arg);
@@ -1135,7 +1143,7 @@ static void log_sql_child_init(server_rec *s, pool *p)
1135 1143
1136 /* Open a link to the database */ 1144 /* Open a link to the database */
1137 retval = open_logdb_link(s); 1145 retval = open_logdb_link(s);
1138 if (retval == 0) 1146 if (!retval)
1139 ap_log_error(APLOG_MARK,ERRLEVEL,s,"mod_log_sql: child spawned but unable to open database link"); 1147 ap_log_error(APLOG_MARK,ERRLEVEL,s,"mod_log_sql: child spawned but unable to open database link");
1140 1148
1141 #ifdef DEBUG 1149 #ifdef DEBUG
@@ -1156,7 +1164,7 @@ static void log_sql_child_init(server_rec *s, pool *p)
1156 */ 1164 */
1157static void log_sql_child_exit(server_rec *s, pool *p) 1165static void log_sql_child_exit(server_rec *s, pool *p)
1158{ 1166{
1159 mysql_close(mysql_log); 1167 mysql_close(logsql_server_p);
1160} 1168}
1161 1169
1162 1170
@@ -1165,7 +1173,7 @@ void *log_sql_initializer(server_rec *main_server, pool *p)
1165{ 1173{
1166 server_rec *s; 1174 server_rec *s;
1167 1175
1168 log_sql_state main_conf = ap_get_module_config(main_server->module_config, &sql_log_module); 1176 logsql_state main_conf = ap_get_module_config(main_server->module_config, &sql_log_module);
1169 1177
1170 for (server_rec *s = main_server; s; s = s->next) { 1178 for (server_rec *s = main_server; s; s = s->next) {
1171 conf = ap_get_module_config(s->module_config, &sql_log_module); 1179 conf = ap_get_module_config(s->module_config, &sql_log_module);
@@ -1188,7 +1196,7 @@ void *log_sql_initializer(server_rec *main_server, pool *p)
1188void *log_sql_make_state(pool *p, server_rec *s) 1196void *log_sql_make_state(pool *p, server_rec *s)
1189{ 1197{
1190 1198
1191 log_sql_state *cls = (log_sql_state *) ap_palloc(p, sizeof(log_sql_state)); 1199 logsql_state *cls = (logsql_state *) ap_palloc(p, sizeof(logsql_state));
1192 1200
1193 /* These defaults are overridable in the httpd.conf file. */ 1201 /* These defaults are overridable in the httpd.conf file. */
1194 cls->transfer_table_name = NULL; /* No default b/c we want its absence to disable logging */ 1202 cls->transfer_table_name = NULL; /* No default b/c we want its absence to disable logging */
@@ -1296,14 +1304,14 @@ command_rec log_sql_cmds[] = {
1296int log_sql_transaction(request_rec *orig) 1304int log_sql_transaction(request_rec *orig)
1297{ 1305{
1298 char **ptrptr, **ptrptr2; 1306 char **ptrptr, **ptrptr2;
1299 log_sql_state *cls = get_module_config(orig->server->module_config, &sql_log_module); 1307 logsql_state *cls = get_module_config(orig->server->module_config, &sql_log_module);
1300 const char *access_query; 1308 const char *access_query;
1301 request_rec *r; 1309 request_rec *r;
1302 1310
1303 /* We handle mass virtual hosting differently. Dynamically determine the name 1311 /* We handle mass virtual hosting differently. Dynamically determine the name
1304 * of the table from the virtual server's name, and flag it for creation. 1312 * of the table from the virtual server's name, and flag it for creation.
1305 */ 1313 */
1306 if (massvirtual) { 1314 if (logsql_massvirtual) {
1307 char *access_base = "access_"; 1315 char *access_base = "access_";
1308 char *notes_base = "notes_"; 1316 char *notes_base = "notes_";
1309 char *hout_base = "headout_"; 1317 char *hout_base = "headout_";
@@ -1353,11 +1361,12 @@ int log_sql_transaction(request_rec *orig)
1353 cls->hout_table_name = o_tablename; 1361 cls->hout_table_name = o_tablename;
1354 cls->hin_table_name = i_tablename; 1362 cls->hin_table_name = i_tablename;
1355 cls->cookie_table_name = c_tablename; 1363 cls->cookie_table_name = c_tablename;
1356 create_tables = 1; 1364 logsql_createtables = 1;
1357 } 1365 }
1358 1366
1359 /* Do we have enough info to log? */ 1367 /* Do we have enough info to log? */
1360 if ( cls->transfer_table_name == NULL ) { 1368 if (!cls->transfer_table_name) {
1369 ap_log_error(APLOG_MARK,ERRLEVEL,orig->server,"mod_log_sql: configuration info is insufficient to log (hint: LogSQLTransferLogTable)");
1361 return DECLINED; 1370 return DECLINED;
1362 } else { 1371 } else {
1363 const char *thehost; 1372 const char *thehost;
@@ -1476,7 +1485,7 @@ int log_sql_transaction(request_rec *orig)
1476 } 1485 }
1477 } 1486 }
1478 if ( itemsets != "" ) { 1487 if ( itemsets != "" ) {
1479 note_query = ap_pstrcat(r->pool, insert_stmt, "`", cls->notes_table_name, "` (id, item, val) values ", itemsets, NULL); 1488 note_query = ap_pstrcat(r->pool, logsql_insertclause, "`", cls->notes_table_name, "` (id, item, val) values ", itemsets, NULL);
1480 #ifdef DEBUG 1489 #ifdef DEBUG
1481 ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"mod_log_sql: note string: %s", note_query); 1490 ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"mod_log_sql: note string: %s", note_query);
1482 #endif 1491 #endif
@@ -1504,7 +1513,7 @@ int log_sql_transaction(request_rec *orig)
1504 } 1513 }
1505 } 1514 }
1506 if ( itemsets != "" ) { 1515 if ( itemsets != "" ) {
1507 hout_query = ap_pstrcat(r->pool, insert_stmt, "`", cls->hout_table_name, "` (id, item, val) values ", itemsets, NULL); 1516 hout_query = ap_pstrcat(r->pool, logsql_insertclause, "`", cls->hout_table_name, "` (id, item, val) values ", itemsets, NULL);
1508 #ifdef DEBUG 1517 #ifdef DEBUG
1509 ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"mod_log_sql: header_out string: %s", hout_query); 1518 ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"mod_log_sql: header_out string: %s", hout_query);
1510 #endif 1519 #endif
@@ -1533,7 +1542,7 @@ int log_sql_transaction(request_rec *orig)
1533 } 1542 }
1534 } 1543 }
1535 if ( itemsets != "" ) { 1544 if ( itemsets != "" ) {
1536 hin_query = ap_pstrcat(r->pool, insert_stmt, "`", cls->hin_table_name, "` (id, item, val) values ", itemsets, NULL); 1545 hin_query = ap_pstrcat(r->pool, logsql_insertclause, "`", cls->hin_table_name, "` (id, item, val) values ", itemsets, NULL);
1537 #ifdef DEBUG 1546 #ifdef DEBUG
1538 ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"mod_log_sql: header_in string: %s", hin_query); 1547 ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"mod_log_sql: header_in string: %s", hin_query);
1539 #endif 1548 #endif
@@ -1563,7 +1572,7 @@ int log_sql_transaction(request_rec *orig)
1563 1572
1564 } 1573 }
1565 if ( itemsets != "" ) { 1574 if ( itemsets != "" ) {
1566 cookie_query = ap_pstrcat(r->pool, insert_stmt, "`", cls->cookie_table_name, "` (id, item, val) values ", itemsets, NULL); 1575 cookie_query = ap_pstrcat(r->pool, logsql_insertclause, "`", cls->cookie_table_name, "` (id, item, val) values ", itemsets, NULL);
1567 #ifdef DEBUG 1576 #ifdef DEBUG
1568 ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"mod_log_sql: cookie string: %s", cookie_query); 1577 ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"mod_log_sql: cookie string: %s", cookie_query);
1569 #endif 1578 #endif
@@ -1571,7 +1580,7 @@ int log_sql_transaction(request_rec *orig)
1571 1580
1572 1581
1573 /* Set up the actual INSERT statement */ 1582 /* Set up the actual INSERT statement */
1574 access_query = ap_pstrcat(r->pool, insert_stmt, "`", cls->transfer_table_name, "` (", fields, ") values (", values, ")", NULL); 1583 access_query = ap_pstrcat(r->pool, logsql_insertclause, "`", cls->transfer_table_name, "` (", fields, ") values (", values, ")", NULL);
1575 1584
1576 #ifdef DEBUG 1585 #ifdef DEBUG
1577 ap_log_error(APLOG_MARK,DEBUGLEVEL,r->server,"mod_log_sql: access string: %s", access_query); 1586 ap_log_error(APLOG_MARK,DEBUGLEVEL,r->server,"mod_log_sql: access string: %s", access_query);
@@ -1580,7 +1589,7 @@ int log_sql_transaction(request_rec *orig)
1580 /* If the person activated force-preserve, go ahead and push all the entries 1589 /* If the person activated force-preserve, go ahead and push all the entries
1581 * into the preserve file, then return. 1590 * into the preserve file, then return.
1582 */ 1591 */
1583 if (force_preserve) { 1592 if (logsql_forcepreserve) {
1584 #ifdef DEBUG 1593 #ifdef DEBUG
1585 ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"mod_log_sql: preservation forced"); 1594 ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"mod_log_sql: preservation forced");
1586 #endif 1595 #endif
@@ -1597,15 +1606,15 @@ int log_sql_transaction(request_rec *orig)
1597 } 1606 }
1598 1607
1599 /* How's our mysql link integrity? */ 1608 /* How's our mysql link integrity? */
1600 if (mysql_log == NULL) { 1609 if (logsql_server_p == NULL) {
1601 1610
1602 /* Make a try to establish the link */ 1611 /* Make a try to establish the link */
1603 open_logdb_link(r->server); 1612 open_logdb_link(r->server);
1604 1613
1605 if (mysql_log == NULL) { 1614 if (logsql_server_p == NULL) {
1606 /* Unable to re-establish a DB link, so assume that it's really 1615 /* Unable to re-establish a DB link, so assume that it's really
1607 * gone and send the entry to the preserve file instead. 1616 * gone and send the entry to the preserve file instead.
1608 * This short-circuits safe_mysql_query() during a db outage and therefore 1617 * This short-circuits safe_sql_query() during a db outage and therefore
1609 * we don't keep logging the db error over and over. 1618 * we don't keep logging the db error over and over.
1610 */ 1619 */
1611 preserve_entry(orig, access_query); 1620 preserve_entry(orig, access_query);
@@ -1630,20 +1639,20 @@ int log_sql_transaction(request_rec *orig)
1630 /* ---> i.e. we have a good MySQL connection. <--- */ 1639 /* ---> i.e. we have a good MySQL connection. <--- */
1631 1640
1632 /* Make the access-table insert */ 1641 /* Make the access-table insert */
1633 safe_mysql_query(orig, access_query); 1642 safe_sql_query(orig, access_query);
1634 1643
1635 /* Log the optional notes, headers, etc. */ 1644 /* Log the optional notes, headers, etc. */
1636 if (note_query) 1645 if (note_query)
1637 safe_mysql_query(orig, note_query); 1646 safe_sql_query(orig, note_query);
1638 1647
1639 if (hout_query) 1648 if (hout_query)
1640 safe_mysql_query(orig, hout_query); 1649 safe_sql_query(orig, hout_query);
1641 1650
1642 if (hin_query) 1651 if (hin_query)
1643 safe_mysql_query(orig, hin_query); 1652 safe_sql_query(orig, hin_query);
1644 1653
1645 if (cookie_query) 1654 if (cookie_query)
1646 safe_mysql_query(orig, cookie_query); 1655 safe_sql_query(orig, cookie_query);
1647 1656
1648 return OK; 1657 return OK;
1649 } 1658 }