summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Edward Rudd 2003-12-23 19:49:56 +0000
committerGravatar Edward Rudd 2003-12-23 19:49:56 +0000
commitab1ac8ba7570005c169e7aa772762b55d354e07d (patch)
treea4e8d712b5dbf4b5edbb7bd89edc1fa08e40a332
parentf89b2cced3608b248cb02b2e48907dcae07e8bbe (diff)
update autoconf scripts to check MySQL..1.91
moved autoconf DEFUN macros to m4 subdirectory autogen.sh calls aclocal to include m4 directory. merged in changes from 1.19b1 fixed log_sql_merge_config bug in 1.19b1 release 1.91
-rw-r--r--CHANGELOG44
-rw-r--r--Documentation/documentation.lyx353
-rw-r--r--Makefile.in4
-rwxr-xr-xautogen.sh6
-rw-r--r--configure.ac7
-rw-r--r--create_tables.sql2
-rw-r--r--m4/apache.m4 (renamed from aclocal.m4)0
-rw-r--r--m4/mysql.m464
-rw-r--r--mod_log_sql.c220
9 files changed, 520 insertions, 180 deletions
diff --git a/CHANGELOG b/CHANGELOG
index de34ba1..9769044 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,23 +1,59 @@
1$Id: CHANGELOG,v 1.2 2003/12/22 04:45:38 urkle Exp $ 1$Id: CHANGELOG,v 1.3 2003/12/23 19:49:55 urkle Exp $
2 2
3TODO: 3TODO:
4* Rethink documentation flow and rewrite?
5* Port connection portion to other DBMS? Genericize the module? Start with 4* Port connection portion to other DBMS? Genericize the module? Start with
6 PostgreSQL. (provider mechanism, and libDBI) 5 PostgreSQL. (provider mechanism, and libDBI)
7* merge server config into vh config
8* does determining table name in massvirtual mode upon every request 6* does determining table name in massvirtual mode upon every request
9 cause performance degradation? If so fix. 7 cause performance degradation? If so fix.
10* LogSQLRotateLogs directive with daily/monthly/weekly/etc. 8* LogSQLRotateLogs directive with daily/monthly/weekly/etc.
11* new format char: IP as bigint? ( not w/ ipV6 ) 9* new format char: IP as bigint? ( not w/ ipV6 )
12* socket-based middleman daemon with configurable conns, or connect/disconnect. 10* socket-based middleman daemon with configurable conns, or connect/disconnect.
13* ignore by cookie 11* ignore by cookie
12* tools to import logs into SQL
13* Directive to yes/no create ancillary tables (or just access table)
14* break module into separate code files
15 separate DB implimentation into sub-modules via provider mechanism
16* add document building to Makefile.in
17* backport patch for apache 1.3
14 18
15CHANGES: 19CHANGES:
161.90: ? 201.91: 2003-12-23
21* Added checks for MySQL to autoconf
22* fixed merge code to work correctly.
23* Merged in 1.19b1 changes
24* Hostnames are now converted to lowercase in the mass-virtual naming section.
25 The loop that converts dots to underscores has been optimized as well.
26* New directive LogSQLTableType allows one to specify the kind of table that
27 the module makes during table creation (e.g. InnoDB, MyISAM). Thanks to Jim
28 Turner for the suggestion and patch. If your MySQL server does not support
29 the specified type, it will create a MyISAM table instead.
30* Directives can now be placed in the 'main' server config and will be
31 inherited by the virtual hosts. This means a LOT less repetition: you only
32 specify the item once to have it inherited, but it can still be overridden
33 on a virtualhost level. These can be specified in this manner:
34
35 LogSQLTransferLogTable
36 LogSQLTransferLogFormat
37 LogSQLPreserveFile
38 LogSQLNotesLogTable
39 LogSQLHeadersInLogTable
40 LogSQLHeadersOutLogTable
41 LogSQLCookieLogTable
42 LogSQLRemhostIgnore
43 LogSQLRequestIgnore
44 LogSQLRequestAccept
45 LogSQLWhichNotes
46 LogSQLWhichHeadersOut
47 LogSQLWhichHeadersIn
48 LogSQLWhichCookies
49 LogSQLWhichCookie
50
511.90: 2003-12-22
17* updated code to compile under apache 2.0 52* updated code to compile under apache 2.0
18* rewrote and consolidate configuration handler routines 53* rewrote and consolidate configuration handler routines
19* made all functions static. 54* made all functions static.
20* made delayed insert configurable, instead of compile time 55* made delayed insert configurable, instead of compile time
56* moved to my autoconfigure support
21 57
221.18: 581.18:
23* Delayed inserts (a MySQL extension) are now available at compile-time. 59* Delayed inserts (a MySQL extension) are now available at compile-time.
diff --git a/Documentation/documentation.lyx b/Documentation/documentation.lyx
index a678315..eeb6af5 100644
--- a/Documentation/documentation.lyx
+++ b/Documentation/documentation.lyx
@@ -1,5 +1,5 @@
1#LyX 1.2 created this file. For more info see http://www.lyx.org/ 1#LyX 1.3 created this file. For more info see http://www.lyx.org/
2\lyxformat 220 2\lyxformat 221
3\textclass article 3\textclass article
4\language english 4\language english
5\inputencoding default 5\inputencoding default
@@ -162,7 +162,7 @@ Note which directives go in the 'main server config' and which directives
162 This is made clear in the directive documentation. 162 This is made clear in the directive documentation.
163\layout Itemize 163\layout Itemize
164 164
165The 'time_stamp' field is stored in an UNSIGNED INTEGER column, in the standard 165The 'time_stamp' field is stored in an UNSIGNED INTEGER format, in the standard
166 unix 166 unix
167\begin_inset Quotes eld 167\begin_inset Quotes eld
168\end_inset 168\end_inset
@@ -173,9 +173,9 @@ seconds since the epoch
173 173
174 format. 174 format.
175 This is superior to storing the access time as a string due to size requirement 175 This is superior to storing the access time as a string due to size requirement
176s: an UNSIGNED INT requires 4 bytes, whereas an Apache date string -- e.g. 176s: an UNSIGNED INT requires 4 bytes, whereas an Apache date string (e.g.
177 "18/Nov/2001:13:59:52 -0800" -- requires 26 bytes: those extra 22 bytes 177 "18/Nov/2001:13:59:52 -0800") requires 26 bytes: those extra 22 bytes become
178 become significant when multiplied by thousands of accesses on a busy server. 178 significant when multiplied by thousands of accesses on a busy server.
179 Besides, an INT type is far more flexible for comparisons, etc. 179 Besides, an INT type is far more flexible for comparisons, etc.
180\begin_deeper 180\begin_deeper
181\layout Standard 181\layout Standard
@@ -301,6 +301,11 @@ These installation documents assume a relatively modern GNU/Linux scenario.
301 compiling the module for those platforms. 301 compiling the module for those platforms.
302\layout Subsubsection 302\layout Subsubsection
303 303
304
305\begin_inset LatexCommand \label{sub:Solaris}
306
307\end_inset
308
304Solaris 309Solaris
305\layout Standard 310\layout Standard
306 311
@@ -387,6 +392,143 @@ contact
387\end_inset 392\end_inset
388 393
389 and help fill in this section. 394 and help fill in this section.
395\layout Subsubsection
396
397OS X
398\layout Standard
399
400mod_log_sql should compile and work out-of-the-box on this platform.
401 Here are some notes from a user successfully running the module on OS X:
402\layout Quote
403
404
405\emph on
406The only changes I had to make were to where I had the various libraries
407 installed.
408\layout Quote
409
410
411\emph on
412Here are the changes I made to the head of the Makefile:
413\layout LyX-Code
414
415APACHESOURCE = /usr/local/src/apache_1.3.27
416\layout Quote
417
418
419\emph on
420(Wasn't sure if this was really needed or not, so I downloaded the Apache
421 source just in case)
422\layout LyX-Code
423
424APACHEINSTALLED = /usr/sbin
425\layout LyX-Code
426
427APACHEHEADERS = /usr/include/httpd
428\layout LyX-Code
429
430APXS = $(APACHEINSTALLED)/apxs
431\layout LyX-Code
432
433MYSQLLIBRARIES = /usr/local/mysql/lib
434\layout LyX-Code
435
436MYSQLHEADERS = /usr/local/mysql/include
437\layout Quote
438
439
440\emph on
441I'm using a binary installation of MySQL and the default apache installation
442 on OS X Client 10.2.3, the locations of these files may vary depending on
443 how you've installed MySQL and will almost certainly be different if you're
444 using OS X Server.
445\layout Standard
446
447My thanks to Tom Wiebe for being the first (to my knowlege) mod_log_sql
448 user on OS X and for providing these notes.
449\layout Subsubsection
450
451Digital Unix
452\layout Standard
453
454Digital Unix, like Solaris, needs to be linked against librt; see section
455
456\begin_inset LatexCommand \ref{sub:Solaris}
457
458\end_inset
459
460.
461 Here are further notes from a user successfully running the module on Digital
462 Unix:
463\layout Quote
464
465
466\emph on
467Instead of trying to get the module to remember where the MySQL libraries
468 were, I instead compiled apache with the information:
469\layout Quote
470
471
472\emph on
473LDFLAGS='-rpath /isp/mysql/lib/mysql' ./configure ...
474\layout Quote
475
476
477\emph on
478Everything worked as expected after that.
479 (The error I got without this was "/sbin/loader: Fatal Error: cannot map
480 libmysqlclient.so" )
481\layout Quote
482
483
484\emph on
485Digital Unix (v4.0f, at least ) appears to follow the same requirements needed
486 by Solaris, so simply adding librt to the module made it compile without
487 errors.
488\layout Quote
489
490
491\emph on
492As for the warnings, here's the text:
493\layout LyX-Code
494
495
496\emph on
497mod_log_sql.c: In function `extract_request_duration':
498\layout LyX-Code
499
500
501\emph on
502mod_log_sql.c:292: warning: long int format, different type arg (arg 4)
503\layout LyX-Code
504
505
506\emph on
507mod_log_sql.c: In function `extract_request_timestamp':
508\layout LyX-Code
509
510
511\emph on
512mod_log_sql.c:497: warning: long int format, different type arg (arg 4)
513\layout Quote
514
515
516\emph on
517Poking around in the code, it looks like the compiler was complaining that
518 what time() is returning doesn't play nicely with %ld by default.
519 I just typecast them as (long)'s and the warnings went away ( not that
520 the module wasn't working correctly without them ).
521\layout Quote
522
523
524\emph on
525The module works very well so far in testing...
526 hasn't dropped a single log entry yet.
527
528\layout Standard
529
530My thanks to Jim Turner for permitting me to quote him here, and for being
531 the first known user of mod_log_sql on Digital Unix.
390\layout Subsection 532\layout Subsection
391 533
392Do I want a DSO or a static module? 534Do I want a DSO or a static module?
@@ -919,10 +1061,24 @@ mysql> create database apachelogs;
919\end_inset 1061\end_inset
920 1062
921If you want to hand-create the tables, run the enclosed 'create-tables' 1063If you want to hand-create the tables, run the enclosed 'create-tables'
922 SQL script as follows: 1064 SQL script as follows (
1065\begin_inset Quotes eld
1066\end_inset
1067
1068create_tables.sql
1069\begin_inset Quotes erd
1070\end_inset
1071
1072 needs to be in your current working directory).
923\begin_deeper 1073\begin_deeper
924\layout LyX-Code 1074\layout LyX-Code
925 1075
1076mysql> use apachelogs
1077\layout LyX-Code
1078
1079Database changed
1080\layout LyX-Code
1081
926mysql> source create_tables.sql 1082mysql> source create_tables.sql
927\end_deeper 1083\end_deeper
928\layout Enumerate 1084\layout Enumerate
@@ -939,9 +1095,7 @@ Create a specific MySQL userid that httpd will use to authenticate and enter
939\layout LyX-Code 1095\layout LyX-Code
940 1096
941mysql> grant insert,create on apachelogs.* to loguser@my.apachemachine.com 1097mysql> grant insert,create on apachelogs.* to loguser@my.apachemachine.com
942\layout LyX-Code 1098 identified by 'l0gger';
943
944identified by 'l0gger';
945\end_deeper 1099\end_deeper
946\layout Enumerate 1100\layout Enumerate
947 1101
@@ -4817,24 +4971,29 @@ Context: virtual host
4817In HTTP, cookies have names to distinguish them from each other. 4971In HTTP, cookies have names to distinguish them from each other.
4818 Using mod_usertrack, for example, you can give your user-tracking cookies 4972 Using mod_usertrack, for example, you can give your user-tracking cookies
4819 a name with the CookieName directive. 4973 a name with the CookieName directive.
4974
4820\layout Standard 4975\layout Standard
4821 4976
4822You must include a 'c' character in 4977mod_log_sql allows you to log cookie information.
4823\noun on 4978
4824LogSQLTransferLogFormat
4825\noun default
4826 for this directive to take effect; once you specify 'c',
4827\noun on 4979\noun on
4828LogSQLWhichCookie 4980 LogSQLWhichCookie
4829\noun default 4981\noun default
4830 tells mod_log_sql which cookie to log. 4982 tells mod_log_sql which cookie to log.
4831 This is necessary because you will usually be setting and receiving more 4983 This is necessary because you will usually be setting and receiving more
4832 than one cookie from a client; this cookie designates which one to log. 4984 than one cookie from a client.
4985\layout Standard
4986
4987You must include a 'c' character in
4988\noun on
4989LogSQLTransferLogFormat
4990\noun default
4991 for this directive to take effect.
4833\layout Standard 4992\layout Standard
4834 4993
4835Note: although this was intended for people who are using mod_usertrack 4994Note: although this was origintally intended for people using mod_usertrack
4836 to set user-tracking cookies, you aren't restricted in any way. 4995 to create user-tracking cookies, you aren't restricted in any way.
4837 You can choose which cookie you wish to log to the database --any cookie 4996 You can choose which cookie you wish to log to the database -- any cookie
4838 at all -- and it doesn't necessarily have to have anything to do with mod_usert 4997 at all -- and it doesn't necessarily have to have anything to do with mod_usert
4839rack. 4998rack.
4840\layout Subsubsection 4999\layout Subsubsection
@@ -5742,7 +5901,7 @@ Please contact
5742Problems 5901Problems
5743\layout Subsubsection 5902\layout Subsubsection
5744 5903
5745Apache segfaults when using PHP and mod_log_sql 5904Apache segfaults or has other problems when using PHP and mod_log_sql
5746\layout Standard 5905\layout Standard
5747 5906
5748This occurs if you compiled PHP with MySQL database support. 5907This occurs if you compiled PHP with MySQL database support.
@@ -5759,8 +5918,9 @@ real
5759 5918
5760\layout Standard 5919\layout Standard
5761 5920
5762The solution is to configure PHP to link against the real MySQL libraries 5921PHP and mod_log_sql can be configured to happily coexist.
5763 and recompile mod_php. 5922 The solution is to configure PHP to link against the real MySQL libraries:
5923 recompile PHP using --with-mysql=/your/path.
5764 Apache will run properly once the modules are all using the same version 5924 Apache will run properly once the modules are all using the same version
5765 of the MySQL libraries. 5925 of the MySQL libraries.
5766\layout Subsubsection 5926\layout Subsubsection
@@ -5983,6 +6143,83 @@ Reference:
5983\end_inset 6143\end_inset
5984 6144
5985 6145
6146\layout Subsubsection
6147
6148Sometimes a single VirtualHost gets logged to two different tables (e.g.
6149 access_foo_com, access_www_foo_com).
6150 Or, accesses to an unqualified hostname (e.g.
6151
6152\begin_inset Quotes eld
6153\end_inset
6154
6155http://intranet/index.html
6156\begin_inset Quotes erd
6157\end_inset
6158
6159) get logged in separate tables.
6160\layout Standard
6161
6162Proper usage of the Apache runtime
6163\noun on
6164ServerName
6165\noun default
6166 directive and the directive
6167\noun on
6168UseCanonicalName On
6169\noun default
6170(or
6171\noun on
6172DNS
6173\noun default
6174) are necessary to prevent this problem.
6175
6176\begin_inset Quotes eld
6177\end_inset
6178
6179On
6180\begin_inset Quotes erd
6181\end_inset
6182
6183 is the default for
6184\noun on
6185UseCanonicalName
6186\noun default
6187, and specifies that self-referential URLs are generated from the
6188\noun on
6189ServerName
6190\noun default
6191part of your VirtualHost:
6192\layout Quote
6193
6194With UseCanonicalName on (and in all versions prior to 1.3) Apache will use
6195 the ServerName and Port directives to construct the canonical name for
6196 the server.
6197 With UseCanonicalName off Apache will form self-referential URLs using
6198 the hostname and port supplied by the client if any are supplied (otherwise
6199 it will use the canonical name, as defined above).
6200 [From
6201\begin_inset LatexCommand \url[the Apache documentation]{http://httpd.apache.org/docs/mod/core.html#usecanonicalname}
6202
6203\end_inset
6204
6205]
6206\layout Standard
6207
6208The module inherits Apache's
6209\begin_inset Quotes eld
6210\end_inset
6211
6212knowledge
6213\begin_inset Quotes erd
6214\end_inset
6215
6216 about the server name being accessed.
6217 As long as those two directives are properly configured, mod_log_sql will
6218 log to only one table per virtual host while using
6219\noun on
6220LogSQLMassVirtualHosting
6221\noun default
6222.
5986\layout Subsection 6223\layout Subsection
5987 6224
5988Performance and Tuning 6225Performance and Tuning
@@ -6236,7 +6473,7 @@ not
6236correct 6473correct
6237\series default 6474\series default
6238 to assume that 20 Apache children with a VSZ of 7MB each equals 6475 to assume that 20 Apache children with a VSZ of 7MB each equals
6239\begin_inset Formula $(20\times 7MB)$ 6476\begin_inset Formula $(20\times7MB)$
6240\end_inset 6477\end_inset
6241 6478
6242 of memory consumption -- the real answer is much, much lower. 6479 of memory consumption -- the real answer is much, much lower.
@@ -6359,74 +6596,6 @@ How do I...?
6359 -- accomplishing certain tasks 6596 -- accomplishing certain tasks
6360\layout Subsubsection 6597\layout Subsubsection
6361 6598
6362I am using LogSQLMassVirtualHosting, and sometimes a single VirtualHost
6363 gets logged to two different tables.
6364 How do I prevent that?
6365\layout Standard
6366
6367Proper usage of the Apache runtime
6368\noun on
6369ServerName
6370\noun default
6371 directive and the directive
6372\noun on
6373UseCanonicalName On
6374\noun default
6375(or
6376\noun on
6377DNS
6378\noun default
6379) are necessary to prevent this problem.
6380
6381\begin_inset Quotes eld
6382\end_inset
6383
6384On
6385\begin_inset Quotes erd
6386\end_inset
6387
6388 is the default for
6389\noun on
6390UseCanonicalName
6391\noun default
6392, and specifies that self-referential URLs are generated from the
6393\noun on
6394ServerName
6395\noun default
6396part of your VirtualHost:
6397\layout Quote
6398
6399With UseCanonicalName on (and in all versions prior to 1.3) Apache will use
6400 the ServerName and Port directives to construct the canonical name for
6401 the server.
6402 With UseCanonicalName off Apache will form self-referential URLs using
6403 the hostname and port supplied by the client if any are supplied (otherwise
6404 it will use the canonical name, as defined above).
6405 [From
6406\begin_inset LatexCommand \url[the Apache documentation]{http://httpd.apache.org/docs/mod/core.html#usecanonicalname}
6407
6408\end_inset
6409
6410]
6411\layout Standard
6412
6413The module inherits Apache's
6414\begin_inset Quotes eld
6415\end_inset
6416
6417knowledge
6418\begin_inset Quotes erd
6419\end_inset
6420
6421 about the server name being accessed.
6422 As long as those two directives are properly configured, mod_log_sql will
6423 log to only one table per virtual host while using
6424\noun on
6425LogSQLMassVirtualHosting
6426\noun default
6427.
6428\layout Subsubsection
6429
6430How do I extract the data in a format that my analysis tool can understand? 6599How do I extract the data in a format that my analysis tool can understand?
6431\layout Standard 6600\layout Standard
6432 6601
diff --git a/Makefile.in b/Makefile.in
index b143029..97f961c 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -9,9 +9,9 @@ HEADERS =
9 9
10CFLAGS = -Wc,-Wall -Wc,-Werror -Wc,-fno-strict-aliasing 10CFLAGS = -Wc,-Wall -Wc,-Werror -Wc,-fno-strict-aliasing
11 11
12INCLUDES = -I/usr/include/mysql 12INCLUDES = @MYSQL_CFLAGS@
13 13
14LDADD = -L/usr/lib/mysql -lmysqlclient 14LDADD = @MYSQL_LDFLAGS@ @MYSQL_LIBS@
15 15
16EXTRA_DIST = INSTALL LICENSE CHANGELOG make_combined_log.pl 16EXTRA_DIST = INSTALL LICENSE CHANGELOG make_combined_log.pl
17 17
diff --git a/autogen.sh b/autogen.sh
index eda8b43..9ae9c6b 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,12 +1,16 @@
1#!/bin/sh 1#!/bin/sh
2 2
3rm -rf autom4te-2.53.cache 3if [ -z $ACLOCAL ]; then
4 ACLOCAL=aclocal-1.5
5fi
4if [ -z $AUTOCONF ]; then 6if [ -z $AUTOCONF ]; then
5 AUTOCONF=autoconf-2.53 7 AUTOCONF=autoconf-2.53
6fi 8fi
7if [ -z $AUTOHEADER ]; then 9if [ -z $AUTOHEADER ]; then
8 AUTOHEADER=autoheader-2.53 10 AUTOHEADER=autoheader-2.53
9fi 11fi
12rm -rf autom4te-2.53.cache
13$ACLOCAL -I m4
10$AUTOHEADER 14$AUTOHEADER
11$AUTOCONF 15$AUTOCONF
12touch stamp-h.in 16touch stamp-h.in
diff --git a/configure.ac b/configure.ac
index 4fa277a..56f648c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
1dnl Required initializer 1dnl Required initializer
2AC_INIT(mod_log_sql, 1.90) 2AC_INIT(mod_log_sql, 1.91)
3AC_PREREQ(2.53) 3AC_PREREQ(2.53)
4AC_CONFIG_HEADERS(config.h) 4AC_CONFIG_HEADERS(config.h)
5 5
@@ -14,6 +14,11 @@ CHECK_PATH_APACHE($APACHE_VERSION,
14 AC_MSG_ERROR([*** Apache version $APACHE_VERSION not found!]) 14 AC_MSG_ERROR([*** Apache version $APACHE_VERSION not found!])
15 ) 15 )
16 16
17CHECK_PATH_MYSQL(:,
18 AC_MSG_ERROR([*** Mysql client libraries not found!])
19 )
20
21
17AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) 22AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
18 23
19dnl Write config.status and the Makefile 24dnl Write config.status and the Makefile
diff --git a/create_tables.sql b/create_tables.sql
index 0266b52..0fe0f4b 100644
--- a/create_tables.sql
+++ b/create_tables.sql
@@ -23,7 +23,7 @@ create table access_log (
23 ssl_maxkeysize smallint unsigned, 23 ssl_maxkeysize smallint unsigned,
24 status smallint unsigned , 24 status smallint unsigned ,
25 time_stamp int unsigned , 25 time_stamp int unsigned ,
26 virtual_host varchar(50) 26 virtual_host varchar(255)
27); 27);
28 28
29create table notes ( 29create table notes (
diff --git a/aclocal.m4 b/m4/apache.m4
index b74f335..b74f335 100644
--- a/aclocal.m4
+++ b/m4/apache.m4
diff --git a/m4/mysql.m4 b/m4/mysql.m4
new file mode 100644
index 0000000..c4c4a3b
--- /dev/null
+++ b/m4/mysql.m4
@@ -0,0 +1,64 @@
1dnl CHECK_PATH_MYSQL([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUNT]])
2dnl Check for MySQL Libs
3dnl
4AC_DEFUN(CHECK_PATH_MYSQL,
5[dnl
6AC_ARG_WITH(
7 mysql,
8 [AC_HELP_STRING([--with-mysql],[Path to MySQL client library])],
9 mysql_prefix="$withval",
10
11 )
12AC_ARG_ENABLE(
13 mysqltest,
14 [AC_HELP_STRING([--disble-mysqltest],[Do not try to compile and run mysql test program])],
15 ,
16 enable_apachetest=yes)
17
18 AC_REQUIRE([AC_CANONICAL_TARGET])
19 ac_save_CFLAGS=$CFLAGS
20 ac_save_LDFLAGS=$LDFLAGS
21 if test "x$mysql_prefix" != "x" && test "x$mysql_prefix" != "xyes"; then
22 MYSQL_LDFLAGS="-L${mysql_prefix}/lib -L${mysql_prefix}/lib/mysql -L${mysql_prefix}/mysql/lib"
23 MYSQL_CFLAGS="-I${mysql_prefix}/include -I${mysql_prefix}/include/mysql -I${mysql_prefix}/mysql/include"
24 else
25 MYSQL_LDFLAGS="-L/usr/local/mysql/lib -L/usr/lib/mysql -L/usr/mysql/lib -L/usr/local/lib/mysql -L/usr/local/mysql/lib/mysql -L/usr/mysql/lib/mysql"
26 MYSQL_CFLAGS="-I/usr/local/mysql/include -I/usr/include/mysql -I/usr/mysql/include -I/usr/local/include/mysql -I/usr/local/mysql/include/mysql -I/usr/mysql/include/mysql"
27 fi
28 CFLAGS="$CFLAGS $MYSQL_CFLAGS"
29 LDFLAGS="$LDFLAGS $MYSQL_LDFLAGS"
30 AC_CHECK_LIB(m, floor)
31 AC_CHECK_LIB(z, gzclose)
32 with_mysql="yes"
33 AC_DEFINE(WITH_MYSQL,,[with mysql])
34 AC_CHECK_LIB(mysqlclient, mysql_init, ,
35 [AC_MSG_ERROR(libmysqlclient is needed for MySQL support)])
36 MYSQL_LIBS=$LIBS
37 AC_CHECK_FUNCS(mysql_real_escape_string)
38 AC_MSG_CHECKING(whether mysql clients can run)
39 AC_TRY_RUN([
40 #include <stdio.h>
41 #include <mysql.h>
42 int main(void)
43 {
44 MYSQL *a = mysql_init(NULL);
45 return 0;
46 }
47 ], , no_mysql=yes,[echo $ac_n "cross compiling; assumed OK.... $ac_c"])
48 CFLAGS=$ac_save_CFLAGS
49 LDFLAGS=$ac_save_LDFLAGS
50 if test "x$no_mysql" = x; then
51 AC_MSG_RESULT(yes)
52 ifelse([$1], , :, [$1])
53 else
54 AC_MSG_RESULT(no)
55 echo "*** MySQL could not be found ***"
56 MYSQL_CFLAGS=""
57 MYSQL_LDFLAGS=""
58 MYSQL_LIBS=""
59 ifelse([$2], , :, [$2])
60 fi
61 AC_SUBST(MYSQL_LDFLAGS)
62 AC_SUBST(MYSQL_CFLAGS)
63 AC_SUBST(MYSQL_LIBS)
64])
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};