summaryrefslogtreecommitdiffstatsabout
path: root/mod_log_sql.c
diff options
context:
space:
mode:
Diffstat (limited to 'mod_log_sql.c')
-rw-r--r--mod_log_sql.c220
1 files changed, 141 insertions, 79 deletions
diff --git a/mod_log_sql.c b/mod_log_sql.c
index 8a48b17..de6fe1a 100644
--- a/mod_log_sql.c
+++ b/mod_log_sql.c
@@ -1,4 +1,4 @@
1/* $Header: /home/cvs/mod_log_sql/mod_log_sql.c,v 1.3 2003/12/22 04:45:38 urkle Exp $ */ 1/* $Header: /home/cvs/mod_log_sql/mod_log_sql.c,v 1.4 2003/12/23 19:49:56 urkle Exp $ */
2/* --------* 2/* --------*
3 * DEFINES * 3 * DEFINES *
4 * --------*/ 4 * --------*/
@@ -58,6 +58,15 @@
58#include "mod_ssl.h" 58#include "mod_ssl.h"
59#endif 59#endif
60 60
61
62/* Configuratino Defaults */
63#define DEFAULT_TRANSFER_LOG_FMT "AbHhmRSsTUuv"
64#define DEFAULT_NOTES_TABLE_NAME "notes"
65#define DEFAULT_HIN_TABLE_NAME "headers_in"
66#define DEFAULT_HOUT_TABLE_NAME "headers_out"
67#define DEFAULT_COOKIE_TABLE_NAME "cookies"
68#define DEFAULT_PRESERVE_FILE "/tmp/sql-preserve"
69
61/* -------------* 70/* -------------*
62 * DECLARATIONS * 71 * DECLARATIONS *
63 * -------------*/ 72 * -------------*/
@@ -74,6 +83,7 @@ typedef struct {
74 int massvirtual; 83 int massvirtual;
75 int createtables; 84 int createtables;
76 int forcepreserve; 85 int forcepreserve;
86 char *tabletype;
77 char *dbname; 87 char *dbname;
78 char *dbhost; 88 char *dbhost;
79 char *dbuser; 89 char *dbuser;
@@ -366,13 +376,6 @@ static const char *extract_request_duration(request_rec *r, char *a)
366 return apr_psprintf(r->pool, "%" APR_TIME_T_FMT, apr_time_sec(duration)); 376 return apr_psprintf(r->pool, "%" APR_TIME_T_FMT, apr_time_sec(duration));
367} 377}
368 378
369static const char *extract_request_duration_microseconds(request_rec *r, char *a) __attribute__ ((unused));
370static const char *extract_request_duration_microseconds(request_rec *r, char *a)
371{
372 return apr_psprintf(r->pool, "%" APR_TIME_T_FMT,
373 (apr_time_now() - r->request_time));
374}
375
376static const char *extract_virtual_host(request_rec *r, char *a) 379static const char *extract_virtual_host(request_rec *r, char *a)
377{ 380{
378 return apr_pstrdup(r->pool, r->server->server_hostname); 381 return apr_pstrdup(r->pool, r->server->server_hostname);
@@ -589,7 +592,7 @@ static const char *extract_specific_cookie(request_rec *r, char *a)
589 592
590static const char *extract_request_timestamp(request_rec *r, char *a) 593static const char *extract_request_timestamp(request_rec *r, char *a)
591{ 594{
592 return apr_psprintf(r->pool, "%ld", time(NULL)); 595 return apr_psprintf(r->pool, "%"APR_TIME_T_FMT, apr_time_sec(apr_time_now()));
593} 596}
594 597
595/* 598/*
@@ -910,6 +913,8 @@ static int safe_create_tables(logsql_state *cls, request_rec *r)
910 char *create_hin = NULL; 913 char *create_hin = NULL;
911 char *create_cookies = NULL; 914 char *create_cookies = NULL;
912 915
916 char *type_suffix = NULL;
917
913 char *createprefix = "create table if not exists `"; 918 char *createprefix = "create table if not exists `";
914 char *access_suffix = 919 char *access_suffix =
915 "` (id char(19),\ 920 "` (id char(19),\
@@ -952,13 +957,15 @@ static int safe_create_tables(logsql_state *cls, request_rec *r)
952 "` (id char(19),\ 957 "` (id char(19),\
953 item varchar(80),\ 958 item varchar(80),\
954 val varchar(80))"; 959 val varchar(80))";
955 960 if (global_config.tabletype) {
961 type_suffix = apr_pstrcat(r->pool, " TYPE=", global_config.tabletype, NULL);
962 }
956 /* Find memory long enough to hold the whole CREATE string + \0 */ 963 /* Find memory long enough to hold the whole CREATE string + \0 */
957 create_access = apr_pstrcat(r->pool, createprefix, cls->transfer_table_name, access_suffix, NULL); 964 create_access = apr_pstrcat(r->pool, createprefix, cls->transfer_table_name, access_suffix, type_suffix, NULL);
958 create_notes = apr_pstrcat(r->pool, createprefix, cls->notes_table_name, notes_suffix, NULL); 965 create_notes = apr_pstrcat(r->pool, createprefix, cls->notes_table_name, notes_suffix, type_suffix, NULL);
959 create_hout = apr_pstrcat(r->pool, createprefix, cls->hout_table_name, headers_suffix, NULL); 966 create_hout = apr_pstrcat(r->pool, createprefix, cls->hout_table_name, headers_suffix, type_suffix, NULL);
960 create_hin = apr_pstrcat(r->pool, createprefix, cls->hin_table_name, headers_suffix, NULL); 967 create_hin = apr_pstrcat(r->pool, createprefix, cls->hin_table_name, headers_suffix, type_suffix, NULL);
961 create_cookies= apr_pstrcat(r->pool, createprefix, cls->cookie_table_name, cookies_suffix, NULL); 968 create_cookies= apr_pstrcat(r->pool, createprefix, cls->cookie_table_name, cookies_suffix, type_suffix, NULL);
962 969
963 #ifdef DEBUG 970 #ifdef DEBUG
964 ap_log_error(APLOG_MARK,APLOG_DEBUG,0,r->server,"mod_log_sql: create string: %s", create_access); 971 ap_log_error(APLOG_MARK,APLOG_DEBUG,0,r->server,"mod_log_sql: create string: %s", create_access);
@@ -982,12 +989,12 @@ static int safe_create_tables(logsql_state *cls, request_rec *r)
982 } 989 }
983 990
984 if ((create_results = safe_sql_query(r, create_hin))) { 991 if ((create_results = safe_sql_query(r, create_hin))) {
985 ap_log_error(APLOG_MARK,APLOG_ERR,0,r->server,"mod_log_sql: failed to create header_out table"); 992 ap_log_error(APLOG_MARK,APLOG_ERR,0,r->server,"mod_log_sql: failed to create header_in table");
986 retval = create_results; 993 retval = create_results;
987 } 994 }
988 995
989 if ((create_results = safe_sql_query(r, create_hout))) { 996 if ((create_results = safe_sql_query(r, create_hout))) {
990 ap_log_error(APLOG_MARK,APLOG_ERR,0,r->server,"mod_log_sql: failed to create header_in table"); 997 ap_log_error(APLOG_MARK,APLOG_ERR,0,r->server,"mod_log_sql: failed to create header_out table");
991 retval = create_results; 998 retval = create_results;
992 } 999 }
993 1000
@@ -1009,33 +1016,36 @@ static const char *set_global_flag_slot(cmd_parms *cmd,
1009 void *struct_ptr, 1016 void *struct_ptr,
1010 int flag) 1017 int flag)
1011{ 1018{
1012 int offset = (int)(long)&global_config; 1019 void *ptr = &global_config;
1020 int offset = (int)(long)cmd->info;
1013 1021
1014 *(int *)((char *)struct_ptr + offset) = flag ? 1 : 0; 1022 *(int *)((char *)ptr + offset) = flag ? 1 : 0;
1015 1023
1016 return NULL; 1024 return NULL;
1017} 1025}
1018 1026
1019static const char *set_global_nmv_flag_slot(cmd_parms *parms, 1027static const char *set_global_nmv_flag_slot(cmd_parms *cmd,
1020 void *struct_ptr, 1028 void *struct_ptr,
1021 int flag) 1029 int flag)
1022{ 1030{
1023 if (global_config.massvirtual) 1031 if (global_config.massvirtual) {
1024 return apr_psprintf(parms->pool, 1032 return apr_psprintf(cmd->pool,
1025 "mod_log_sql: do not set %s when LogSQLMassVirtualHosting is On.", 1033 "mod_log_sql: do not set %s when LogSQLMassVirtualHosting(%d) is On.%d:%d",
1026 parms->cmd->name); 1034 cmd->cmd->name, global_config.massvirtual,
1027 else 1035 (int)(long)&global_config, (int)(long)struct_ptr);
1028 return set_global_flag_slot(parms,struct_ptr,flag); 1036 } else {
1037 return set_global_flag_slot(cmd,struct_ptr,flag);
1038 }
1029} 1039}
1030 1040
1031static const char *set_global_string_slot(cmd_parms *cmd, 1041static const char *set_global_string_slot(cmd_parms *cmd,
1032 void *struct_ptr, 1042 void *struct_ptr,
1033 const char *arg) 1043 const char *arg)
1034{ 1044{
1035 int offset = (int)(long)&global_config; 1045 void *ptr = &global_config;
1046 int offset = (int)(long)cmd->info;
1036 1047
1037 *(const char **)((char *)struct_ptr + offset) = apr_pstrdup(cmd->pool,arg); 1048 *(const char **)((char *)ptr + offset) = apr_pstrdup(cmd->pool,arg);
1038
1039 return NULL; 1049 return NULL;
1040} 1050}
1041 1051
@@ -1043,10 +1053,11 @@ static const char *set_server_string_slot(cmd_parms *cmd,
1043 void *struct_ptr, 1053 void *struct_ptr,
1044 const char *arg) 1054 const char *arg)
1045{ 1055{
1046 int offset = (int)(long)ap_get_module_config(cmd->server->module_config, 1056 void *ptr = ap_get_module_config(cmd->server->module_config,
1047 &log_sql_module); 1057 &log_sql_module);
1058 int offset = (int)(long)cmd->info;
1048 1059
1049 *(const char **)((char *)struct_ptr + offset) = arg; 1060 *(const char **)((char *)ptr + offset) = arg;
1050 1061
1051 return NULL; 1062 return NULL;
1052} 1063}
@@ -1058,7 +1069,7 @@ static const char *set_server_nmv_string_slot(cmd_parms *parms,
1058{ 1069{
1059 if (global_config.massvirtual) 1070 if (global_config.massvirtual)
1060 return apr_psprintf(parms->pool, 1071 return apr_psprintf(parms->pool,
1061 "mod_log_sql: do not set %s when LogSQLMassVirtualHosting is On.", 1072 "mod_log_sql: do not set %s when LogSQLMassVirtualHosting is On.",
1062 parms->cmd->name); 1073 parms->cmd->name);
1063 else 1074 else
1064 return set_server_string_slot(parms,struct_ptr,arg); 1075 return set_server_string_slot(parms,struct_ptr,arg);
@@ -1083,9 +1094,10 @@ static const char *add_server_string_slot(cmd_parms *cmd,
1083 const char *arg) 1094 const char *arg)
1084{ 1095{
1085 char **addme; 1096 char **addme;
1086 int offset = (int)(long)ap_get_module_config(cmd->server->module_config, 1097 void *ptr = ap_get_module_config(cmd->server->module_config,
1087 &log_sql_module); 1098 &log_sql_module);
1088 apr_array_header_t *ary = *(apr_array_header_t **)((apr_array_header_t *)struct_ptr + offset); 1099 int offset = (int)(long)cmd->info;
1100 apr_array_header_t *ary = *(apr_array_header_t **)((apr_array_header_t *)ptr + offset);
1089 1101
1090 addme = apr_array_push(ary); 1102 addme = apr_array_push(ary);
1091 *addme = apr_pstrdup(ary->pool, arg); 1103 *addme = apr_pstrdup(ary->pool, arg);
@@ -1131,7 +1143,6 @@ static apr_status_t log_sql_close_link(void *data)
1131static void log_sql_child_init(apr_pool_t *p, server_rec *s) 1143static void log_sql_child_init(apr_pool_t *p, server_rec *s)
1132{ 1144{
1133 apr_pool_cleanup_register(p, NULL, log_sql_close_link, log_sql_close_link); 1145 apr_pool_cleanup_register(p, NULL, log_sql_close_link, log_sql_close_link);
1134
1135} 1146}
1136 1147
1137static int log_sql_open(apr_pool_t *pc, apr_pool_t *p, apr_pool_t *pt, server_rec *s) 1148static int log_sql_open(apr_pool_t *pc, apr_pool_t *p, apr_pool_t *pt, server_rec *s)
@@ -1178,7 +1189,7 @@ void *log_sql_initializer(server_rec *main_server, apr_pool_t *p)
1178static int log_sql_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) 1189static int log_sql_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp)
1179{ 1190{
1180 /* Initialize Global configuration */ 1191 /* Initialize Global configuration */
1181 memset(&global_config,0,sizeof(global_config)); 1192 memset(&global_config,0,sizeof(global_config_t));
1182 global_config.socketfile = "/tmp/mysql.sock"; 1193 global_config.socketfile = "/tmp/mysql.sock";
1183 global_config.tcpport = 3306; 1194 global_config.tcpport = 3306;
1184 return OK; 1195 return OK;
@@ -1186,16 +1197,15 @@ static int log_sql_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp
1186 1197
1187static void *log_sql_make_state(apr_pool_t *p, server_rec *s) 1198static void *log_sql_make_state(apr_pool_t *p, server_rec *s)
1188{ 1199{
1189 logsql_state *cls = (logsql_state *) apr_palloc(p, sizeof(logsql_state)); 1200 logsql_state *cls = (logsql_state *) apr_pcalloc(p, sizeof(logsql_state));
1190 1201
1191 /* These defaults are overridable in the httpd.conf file. */ 1202 /* These defaults are overridable in the httpd.conf file. */
1192 cls->transfer_table_name = NULL; /* No default b/c we want its absence to disable logging */ 1203 cls->transfer_log_format = DEFAULT_TRANSFER_LOG_FMT;
1193 cls->transfer_log_format = "AbHhmRSsTUuv"; 1204 cls->notes_table_name = DEFAULT_NOTES_TABLE_NAME;
1194 cls->notes_table_name = "notes"; 1205 cls->hin_table_name = DEFAULT_HIN_TABLE_NAME;
1195 cls->hin_table_name = "headers_in"; 1206 cls->hout_table_name = DEFAULT_HOUT_TABLE_NAME;
1196 cls->hout_table_name = "headers_out"; 1207 cls->cookie_table_name = DEFAULT_COOKIE_TABLE_NAME;
1197 cls->cookie_table_name = "cookies"; 1208 cls->preserve_file = DEFAULT_PRESERVE_FILE;
1198 cls->preserve_file = "/tmp/sql-preserve";
1199 1209
1200 cls->transfer_ignore_list = apr_array_make(p, 1, sizeof(char *)); 1210 cls->transfer_ignore_list = apr_array_make(p, 1, sizeof(char *));
1201 cls->transfer_accept_list = apr_array_make(p, 1, sizeof(char *)); 1211 cls->transfer_accept_list = apr_array_make(p, 1, sizeof(char *));
@@ -1204,11 +1214,70 @@ static void *log_sql_make_state(apr_pool_t *p, server_rec *s)
1204 cls->hin_list = apr_array_make(p, 1, sizeof(char *)); 1214 cls->hin_list = apr_array_make(p, 1, sizeof(char *));
1205 cls->hout_list = apr_array_make(p, 1, sizeof(char *)); 1215 cls->hout_list = apr_array_make(p, 1, sizeof(char *));
1206 cls->cookie_list = apr_array_make(p, 1, sizeof(char *)); 1216 cls->cookie_list = apr_array_make(p, 1, sizeof(char *));
1207 cls->cookie_name = NULL;
1208 1217
1209 return (void *) cls; 1218 return (void *) cls;
1210} 1219}
1211 1220
1221static void *log_sql_merge_state(apr_pool_t *p, void *basev, void *addv)
1222{
1223 /* Fetch the two states to merge */
1224 logsql_state *parent = (logsql_state *) basev;
1225 logsql_state *child = (logsql_state *) addv;
1226
1227 /* Child can override these, otherwise they default to parent's choice.
1228 * If the parent didn't set them, create reasonable defaults for the
1229 * ones that should have such default settings. Leave the others null. */
1230
1231 child->transfer_table_name = child->transfer_table_name ?
1232 child->transfer_table_name : parent->transfer_table_name;
1233 /* No default for transfer_table_name because we want its absence
1234 * to disable logging. */
1235
1236 if (child->transfer_log_format == DEFAULT_TRANSFER_LOG_FMT)
1237 child->transfer_log_format = parent->transfer_log_format;
1238
1239 if (child->preserve_file == DEFAULT_PRESERVE_FILE)
1240 child->preserve_file = parent->preserve_file;
1241
1242 if (child->notes_table_name == DEFAULT_NOTES_TABLE_NAME)
1243 child->notes_table_name = parent->notes_table_name;
1244
1245 if (child->hin_table_name == DEFAULT_HIN_TABLE_NAME)
1246 child->hin_table_name = parent->hin_table_name;
1247
1248 if (child->hout_table_name == DEFAULT_HOUT_TABLE_NAME)
1249 child->hout_table_name = parent->hout_table_name;
1250
1251 if (child->cookie_table_name == DEFAULT_COOKIE_TABLE_NAME)
1252 child->cookie_table_name = parent->cookie_table_name;
1253
1254 if (apr_is_empty_array(child->transfer_ignore_list))
1255 apr_array_cat(child->transfer_ignore_list, parent->transfer_ignore_list);
1256
1257 if (apr_is_empty_array(child->transfer_accept_list))
1258 apr_array_cat(child->transfer_accept_list, parent->transfer_accept_list);
1259
1260 if (apr_is_empty_array(child->remhost_ignore_list))
1261 apr_array_cat(child->remhost_ignore_list, parent->remhost_ignore_list);
1262
1263 if (apr_is_empty_array(child->notes_list))
1264 apr_array_cat(child->notes_list, parent->notes_list);
1265
1266 if (apr_is_empty_array(child->hin_list))
1267 apr_array_cat(child->hin_list, parent->hin_list);
1268
1269 if (apr_is_empty_array(child->hout_list))
1270 apr_array_cat(child->hout_list, parent->hout_list);
1271
1272 if (apr_is_empty_array(child->cookie_list))
1273 apr_array_cat(child->cookie_list, parent->cookie_list);
1274
1275 if (!child->cookie_name)
1276 child->cookie_name = parent->cookie_name;
1277
1278 return (void*) child;
1279}
1280
1212/* Routine to perform the actual construction and execution of the relevant 1281/* Routine to perform the actual construction and execution of the relevant
1213 * INSERT statements. 1282 * INSERT statements.
1214 */ 1283 */
@@ -1233,36 +1302,22 @@ static int log_sql_transaction(request_rec *orig)
1233 char *i_tablename; 1302 char *i_tablename;
1234 char *o_tablename; 1303 char *o_tablename;
1235 char *c_tablename; 1304 char *c_tablename;
1236 unsigned int i;
1237 1305
1238 /* Find memory long enough to hold the table name + \0. */ 1306 /* Determint the hostname and convert it to all lower-case; */
1239 a_tablename = apr_pstrcat(orig->pool, access_base, ap_get_server_name(orig), NULL); 1307 char *servername = apr_pstrdup(orig->pool,(char *)ap_get_server_name(orig));
1240 n_tablename = apr_pstrcat(orig->pool, notes_base, ap_get_server_name(orig), NULL); 1308 char *p=servername;
1241 i_tablename = apr_pstrcat(orig->pool, hin_base, ap_get_server_name(orig), NULL); 1309 while (*p) {
1242 o_tablename = apr_pstrcat(orig->pool, hout_base, ap_get_server_name(orig), NULL); 1310 *p = apr_tolower(*p);
1243 c_tablename = apr_pstrcat(orig->pool, cookie_base, ap_get_server_name(orig), NULL); 1311 if (*p == '.') *p = '_';
1244 1312 ++p;
1245 /* Transform any dots to underscores */
1246 for (i = 0; i < strlen(a_tablename); i++) {
1247 if (a_tablename[i] == '.')
1248 a_tablename[i] = '_';
1249 }
1250 for (i = 0; i < strlen(n_tablename); i++) {
1251 if (n_tablename[i] == '.')
1252 n_tablename[i] = '_';
1253 }
1254 for (i = 0; i < strlen(i_tablename); i++) {
1255 if (i_tablename[i] == '.')
1256 i_tablename[i] = '_';
1257 }
1258 for (i = 0; i < strlen(o_tablename); i++) {
1259 if (o_tablename[i] == '.')
1260 o_tablename[i] = '_';
1261 }
1262 for (i = 0; i < strlen(c_tablename); i++) {
1263 if (c_tablename[i] == '.')
1264 c_tablename[i] = '_';
1265 } 1313 }
1314
1315 /* Find memory long enough to hold the table name + \0. */
1316 a_tablename = apr_pstrcat(orig->pool, access_base, servername, NULL);
1317 n_tablename = apr_pstrcat(orig->pool, notes_base, servername, NULL);
1318 i_tablename = apr_pstrcat(orig->pool, hin_base, servername, NULL);
1319 o_tablename = apr_pstrcat(orig->pool, hout_base, servername, NULL);
1320 c_tablename = apr_pstrcat(orig->pool, cookie_base, servername, NULL);
1266 1321
1267 /* Tell this virtual server its transfer table name, and 1322 /* Tell this virtual server its transfer table name, and
1268 * turn on create_tables, which is implied by massvirtual. 1323 * turn on create_tables, which is implied by massvirtual.
@@ -1396,7 +1451,8 @@ static int log_sql_transaction(request_rec *orig)
1396 } 1451 }
1397 if ( itemsets != "" ) { 1452 if ( itemsets != "" ) {
1398 note_query = apr_psprintf(r->pool, "insert %s into `%s` (id, item, val) values %s", 1453 note_query = apr_psprintf(r->pool, "insert %s into `%s` (id, item, val) values %s",
1399 global_config.insertdelayed?"delayed":NULL, cls->notes_table_name, itemsets); 1454 global_config.insertdelayed?"delayed":"", cls->notes_table_name, itemsets);
1455
1400 #ifdef DEBUG 1456 #ifdef DEBUG
1401 ap_log_error(APLOG_MARK,APLOG_DEBUG,0,orig->server,"mod_log_sql: note string: %s", note_query); 1457 ap_log_error(APLOG_MARK,APLOG_DEBUG,0,orig->server,"mod_log_sql: note string: %s", note_query);
1402 #endif 1458 #endif
@@ -1425,7 +1481,8 @@ static int log_sql_transaction(request_rec *orig)
1425 } 1481 }
1426 if ( itemsets != "" ) { 1482 if ( itemsets != "" ) {
1427 hout_query = apr_psprintf(r->pool, "insert %s into `%s` (id, item, val) values %s", 1483 hout_query = apr_psprintf(r->pool, "insert %s into `%s` (id, item, val) values %s",
1428 global_config.insertdelayed?"delayed":NULL, cls->hout_table_name, itemsets); 1484 global_config.insertdelayed?"delayed":"", cls->hout_table_name, itemsets);
1485
1429 #ifdef DEBUG 1486 #ifdef DEBUG
1430 ap_log_error(APLOG_MARK,APLOG_DEBUG,0,orig->server,"mod_log_sql: header_out string: %s", hout_query); 1487 ap_log_error(APLOG_MARK,APLOG_DEBUG,0,orig->server,"mod_log_sql: header_out string: %s", hout_query);
1431 #endif 1488 #endif
@@ -1455,7 +1512,7 @@ static int log_sql_transaction(request_rec *orig)
1455 } 1512 }
1456 if ( itemsets != "" ) { 1513 if ( itemsets != "" ) {
1457 hin_query = apr_psprintf(r->pool, "insert %s into `%s` (id, item, val) values %s", 1514 hin_query = apr_psprintf(r->pool, "insert %s into `%s` (id, item, val) values %s",
1458 global_config.insertdelayed?"delayed":NULL, cls->hin_table_name, itemsets); 1515 global_config.insertdelayed?"delayed":"", cls->hin_table_name, itemsets);
1459 1516
1460 #ifdef DEBUG 1517 #ifdef DEBUG
1461 ap_log_error(APLOG_MARK,APLOG_DEBUG,0,orig->server,"mod_log_sql: header_in string: %s", hin_query); 1518 ap_log_error(APLOG_MARK,APLOG_DEBUG,0,orig->server,"mod_log_sql: header_in string: %s", hin_query);
@@ -1487,7 +1544,8 @@ static int log_sql_transaction(request_rec *orig)
1487 } 1544 }
1488 if ( itemsets != "" ) { 1545 if ( itemsets != "" ) {
1489 cookie_query = apr_psprintf(r->pool, "insert %s into `%s` (id, item, val) values %s", 1546 cookie_query = apr_psprintf(r->pool, "insert %s into `%s` (id, item, val) values %s",
1490 global_config.insertdelayed?"delayed":NULL, cls->cookie_table_name, itemsets); 1547 global_config.insertdelayed?"delayed":"", cls->cookie_table_name, itemsets);
1548
1491 #ifdef DEBUG 1549 #ifdef DEBUG
1492 ap_log_error(APLOG_MARK,APLOG_DEBUG,0,orig->server,"mod_log_sql: cookie string: %s", cookie_query); 1550 ap_log_error(APLOG_MARK,APLOG_DEBUG,0,orig->server,"mod_log_sql: cookie string: %s", cookie_query);
1493 #endif 1551 #endif
@@ -1496,7 +1554,7 @@ static int log_sql_transaction(request_rec *orig)
1496 1554
1497 /* Set up the actual INSERT statement */ 1555 /* Set up the actual INSERT statement */
1498 access_query = apr_psprintf(r->pool, "insert %s into `%s` (%s) values (%s)", 1556 access_query = apr_psprintf(r->pool, "insert %s into `%s` (%s) values (%s)",
1499 global_config.insertdelayed?"delayed":NULL, cls->transfer_table_name, fields, values); 1557 global_config.insertdelayed?"delayed":"", cls->transfer_table_name, fields, values);
1500 1558
1501 #ifdef DEBUG 1559 #ifdef DEBUG
1502 ap_log_error(APLOG_MARK,APLOG_DEBUG,0,r->server,"mod_log_sql: access string: %s", access_query); 1560 ap_log_error(APLOG_MARK,APLOG_DEBUG,0,r->server,"mod_log_sql: access string: %s", access_query);
@@ -1656,6 +1714,10 @@ static const command_rec log_sql_cmds[] = {
1656 (void *)APR_OFFSETOF(global_config_t, socketfile), RSRC_CONF, 1714 (void *)APR_OFFSETOF(global_config_t, socketfile), RSRC_CONF,
1657 "Name of the file to employ for socket connections to database") 1715 "Name of the file to employ for socket connections to database")
1658 , 1716 ,
1717 AP_INIT_TAKE1("LogSQLTableType", set_global_string_slot,
1718 (void *)APR_OFFSETOF(global_config_t, tabletype), RSRC_CONF,
1719 "What kind of table to create (MyISAM, InnoDB,...) when creating tables")
1720 ,
1659 AP_INIT_TAKE1("LogSQLTCPPort", set_log_sql_tcp_port, NULL, RSRC_CONF, 1721 AP_INIT_TAKE1("LogSQLTCPPort", set_log_sql_tcp_port, NULL, RSRC_CONF,
1660 "Port number to use for TCP connections to database, defaults to 3306 if not set") 1722 "Port number to use for TCP connections to database, defaults to 3306 if not set")
1661 , 1723 ,
@@ -1690,7 +1752,7 @@ module AP_MODULE_DECLARE_DATA log_sql_module = {
1690 NULL, /* create per-directory config structures */ 1752 NULL, /* create per-directory config structures */
1691 NULL, /* merge per-directory config structures */ 1753 NULL, /* merge per-directory config structures */
1692 log_sql_make_state, /* create per-server config structures */ 1754 log_sql_make_state, /* create per-server config structures */
1693 NULL, /* merge per-server config structures */ 1755 log_sql_merge_state, /* merge per-server config structures */
1694 log_sql_cmds, /* command handlers */ 1756 log_sql_cmds, /* command handlers */
1695 register_hooks /* register hooks */ 1757 register_hooks /* register hooks */
1696}; 1758};