diff options
| -rw-r--r-- | .project | 60 | ||||
| -rw-r--r-- | Makefile.in | 28 | ||||
| -rw-r--r-- | TODO.in | 3 | ||||
| -rw-r--r-- | configure.ac | 12 | ||||
| -rw-r--r-- | mod_log_sql.c | 26 | ||||
| -rw-r--r-- | mod_log_sql.h | 4 | ||||
| -rw-r--r-- | mod_log_sql_dbd.c | 132 | ||||
| -rw-r--r-- | mod_log_sql_dbi.c | 2 | ||||
| -rw-r--r-- | mod_log_sql_mysql.c | 2 |
9 files changed, 211 insertions, 58 deletions
| @@ -3,19 +3,16 @@ | |||
| 3 | <name>mod_log_sql</name> | 3 | <name>mod_log_sql</name> |
| 4 | <comment></comment> | 4 | <comment></comment> |
| 5 | <projects> | 5 | <projects> |
| 6 | <project>includes</project> | ||
| 6 | </projects> | 7 | </projects> |
| 7 | <buildSpec> | 8 | <buildSpec> |
| 8 | <buildCommand> | 9 | <buildCommand> |
| 9 | <name>org.eclipse.cdt.make.core.makeBuilder</name> | 10 | <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> |
| 10 | <triggers>clean,full,incremental,</triggers> | 11 | <triggers>clean,full,incremental,</triggers> |
| 11 | <arguments> | 12 | <arguments> |
| 12 | <dictionary> | 13 | <dictionary> |
| 13 | <key>org.eclipse.cdt.make.core.build.arguments</key> | 14 | <key>org.eclipse.cdt.make.core.fullBuildTarget</key> |
| 14 | <value></value> | 15 | <value>all</value> |
| 15 | </dictionary> | ||
| 16 | <dictionary> | ||
| 17 | <key>org.eclipse.cdt.core.errorOutputParser</key> | ||
| 18 | <value>org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.VCErrorParser;</value> | ||
| 19 | </dictionary> | 16 | </dictionary> |
| 20 | <dictionary> | 17 | <dictionary> |
| 21 | <key>org.eclipse.cdt.make.core.enableAutoBuild</key> | 18 | <key>org.eclipse.cdt.make.core.enableAutoBuild</key> |
| @@ -26,47 +23,47 @@ | |||
| 26 | <value></value> | 23 | <value></value> |
| 27 | </dictionary> | 24 | </dictionary> |
| 28 | <dictionary> | 25 | <dictionary> |
| 29 | <key>org.eclipse.cdt.make.core.enableFullBuild</key> | 26 | <key>org.eclipse.cdt.make.core.buildLocation</key> |
| 30 | <value>true</value> | 27 | <value>${workspace_loc:/mod_log_sql/Linux GCC}</value> |
| 31 | </dictionary> | 28 | </dictionary> |
| 32 | <dictionary> | 29 | <dictionary> |
| 33 | <key>org.eclipse.cdt.make.core.build.target.inc</key> | 30 | <key>?name?</key> |
| 34 | <value>all</value> | 31 | <value></value> |
| 35 | </dictionary> | 32 | </dictionary> |
| 36 | <dictionary> | 33 | <dictionary> |
| 37 | <key>org.eclipse.cdt.make.core.enabledIncrementalBuild</key> | 34 | <key>org.eclipse.cdt.make.core.enableFullBuild</key> |
| 38 | <value>true</value> | 35 | <value>true</value> |
| 39 | </dictionary> | 36 | </dictionary> |
| 40 | <dictionary> | 37 | <dictionary> |
| 41 | <key>org.eclipse.cdt.make.core.build.location</key> | 38 | <key>org.eclipse.cdt.make.core.enableCleanBuild</key> |
| 42 | <value></value> | 39 | <value>true</value> |
| 43 | </dictionary> | 40 | </dictionary> |
| 44 | <dictionary> | 41 | <dictionary> |
| 45 | <key>org.eclipse.cdt.make.core.build.target.clean</key> | 42 | <key>org.eclipse.cdt.make.core.cleanBuildTarget</key> |
| 46 | <value>clean</value> | 43 | <value>clean</value> |
| 47 | </dictionary> | 44 | </dictionary> |
| 48 | <dictionary> | 45 | <dictionary> |
| 49 | <key>org.eclipse.cdt.make.core.build.command</key> | ||
| 50 | <value>sshmake</value> | ||
| 51 | </dictionary> | ||
| 52 | <dictionary> | ||
| 53 | <key>org.eclipse.cdt.make.core.enableCleanBuild</key> | ||
| 54 | <value>true</value> | ||
| 55 | </dictionary> | ||
| 56 | <dictionary> | ||
| 57 | <key>org.eclipse.cdt.make.core.append_environment</key> | 46 | <key>org.eclipse.cdt.make.core.append_environment</key> |
| 58 | <value>true</value> | 47 | <value>true</value> |
| 59 | </dictionary> | 48 | </dictionary> |
| 60 | <dictionary> | 49 | <dictionary> |
| 61 | <key>org.eclipse.cdt.make.core.build.target.full</key> | 50 | <key>org.eclipse.cdt.make.core.contents</key> |
| 62 | <value>clean all</value> | 51 | <value>org.eclipse.cdt.make.core.activeConfigSettings</value> |
| 63 | </dictionary> | 52 | </dictionary> |
| 64 | <dictionary> | 53 | <dictionary> |
| 65 | <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key> | 54 | <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key> |
| 66 | <value>false</value> | 55 | <value>false</value> |
| 67 | </dictionary> | 56 | </dictionary> |
| 68 | <dictionary> | 57 | <dictionary> |
| 69 | <key>org.eclipse.cdt.make.core.build.target.auto</key> | 58 | <key>org.eclipse.cdt.make.core.buildArguments</key> |
| 59 | <value>${project_name} make -k</value> | ||
| 60 | </dictionary> | ||
| 61 | <dictionary> | ||
| 62 | <key>org.eclipse.cdt.make.core.buildCommand</key> | ||
| 63 | <value>${HOME}/bin/sshmake</value> | ||
| 64 | </dictionary> | ||
| 65 | <dictionary> | ||
| 66 | <key>org.eclipse.cdt.make.core.autoBuildTarget</key> | ||
| 70 | <value>all</value> | 67 | <value>all</value> |
| 71 | </dictionary> | 68 | </dictionary> |
| 72 | <dictionary> | 69 | <dictionary> |
| @@ -76,19 +73,14 @@ | |||
| 76 | </arguments> | 73 | </arguments> |
| 77 | </buildCommand> | 74 | </buildCommand> |
| 78 | <buildCommand> | 75 | <buildCommand> |
| 79 | <name>org.eclipse.cdt.make.core.ScannerConfigBuilder</name> | 76 | <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> |
| 80 | <arguments> | ||
| 81 | </arguments> | ||
| 82 | </buildCommand> | ||
| 83 | <buildCommand> | ||
| 84 | <name>de.loskutov.FileSync.FSBuilder</name> | ||
| 85 | <arguments> | 77 | <arguments> |
| 86 | </arguments> | 78 | </arguments> |
| 87 | </buildCommand> | 79 | </buildCommand> |
| 88 | </buildSpec> | 80 | </buildSpec> |
| 89 | <natures> | 81 | <natures> |
| 90 | <nature>org.eclipse.cdt.core.cnature</nature> | 82 | <nature>org.eclipse.cdt.core.cnature</nature> |
| 91 | <nature>org.eclipse.cdt.make.core.makeNature</nature> | 83 | <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> |
| 92 | <nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature> | 84 | <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> |
| 93 | </natures> | 85 | </natures> |
| 94 | </projectDescription> | 86 | </projectDescription> |
diff --git a/Makefile.in b/Makefile.in index 2865d5f..2647d2e 100644 --- a/Makefile.in +++ b/Makefile.in | |||
| @@ -77,6 +77,16 @@ ifeq (@WANT_DBI_MOD@,1) | |||
| 77 | TARGETS += $(dbiTARGET) | 77 | TARGETS += $(dbiTARGET) |
| 78 | endif | 78 | endif |
| 79 | 79 | ||
| 80 | dbdSOURCES = @PACKAGE_NAME@_dbd.c | ||
| 81 | dbdTARGET = @PACKAGE_NAME@_dbd@APXS_EXTENSION@ | ||
| 82 | dbdLDADD = | ||
| 83 | dbdCFLAGS = | ||
| 84 | dbdNAME = log_sql_dbd | ||
| 85 | |||
| 86 | ifeq (@WANT_DBD_MOD@,1) | ||
| 87 | TARGETS += $(dbdTARGET) | ||
| 88 | endif | ||
| 89 | |||
| 80 | #Don't modify anything below here | 90 | #Don't modify anything below here |
| 81 | 91 | ||
| 82 | PROVIDERS_SUBDIRS = @subdirs@ | 92 | PROVIDERS_SUBDIRS = @subdirs@ |
| @@ -85,13 +95,13 @@ srcdir = @abs_srcdir@ | |||
| 85 | builddir = @abs_builddir@ | 95 | builddir = @abs_builddir@ |
| 86 | 96 | ||
| 87 | OBJ = $(coreSOURCES:.c=.o) $(logioSOURCES:.c=.o) $(sslSOURCES:.c=.o) $(mysqlSOURCES:.c=.o) \ | 97 | OBJ = $(coreSOURCES:.c=.o) $(logioSOURCES:.c=.o) $(sslSOURCES:.c=.o) $(mysqlSOURCES:.c=.o) \ |
| 88 | $(dbiSOURCES:.c=.o) $(pgsqlSOURCES:.c=.o) | 98 | $(dbiSOURCES:.c=.o) $(pgsqlSOURCES:.c=.o) $(dbdSOURCES:.c=.o) |
| 89 | 99 | ||
| 90 | LO = $(coreSOURCES:.c=.lo) $(logioSOURCES:.c=.lo) $(sslSOURCES:.c=.lo) $(mysqlSOURCES:.c=.lo) \ | 100 | LO = $(coreSOURCES:.c=.lo) $(logioSOURCES:.c=.lo) $(sslSOURCES:.c=.lo) $(mysqlSOURCES:.c=.lo) \ |
| 91 | $(dbiSOURCES:.c=.lo) $(pgsqlSOURCES:.c=.lo) | 101 | $(dbiSOURCES:.c=.lo) $(pgsqlSOURCES:.c=.lo) $(dbdSOURCES:.c=.lo) |
| 92 | 102 | ||
| 93 | SLO = $(coreSOURCES:.c=.slo) $(logioSOURCES:.c=.slo) $(sslSOURCES:.c=.slo) $(mysqlSOURCES:.c=.slo) \ | 103 | SLO = $(coreSOURCES:.c=.slo) $(logioSOURCES:.c=.slo) $(sslSOURCES:.c=.slo) $(mysqlSOURCES:.c=.slo) \ |
| 94 | $(dbiSOURCES:.c=.slo) $(pgsqlSOURCES:.c=.slo) | 104 | $(dbiSOURCES:.c=.slo) $(pgsqlSOURCES:.c=.slo) $(dbdSOURCES:.c=.slo) |
| 95 | 105 | ||
| 96 | STD_DIST = install-sh \ | 106 | STD_DIST = install-sh \ |
| 97 | config.sub \ | 107 | config.sub \ |
| @@ -104,7 +114,7 @@ STD_DIST = install-sh \ | |||
| 104 | config.h.in | 114 | config.h.in |
| 105 | 115 | ||
| 106 | DISTFILES = $(STD_DIST) $(EXTRA_DIST) $(coreSOURCES) $(HEADERS) \ | 116 | DISTFILES = $(STD_DIST) $(EXTRA_DIST) $(coreSOURCES) $(HEADERS) \ |
| 107 | $(sslSOURCES) $(logioSOURCES) $(mysqlSOURCES) $(pgsqlSOURCES) $(dbiSOURCES) | 117 | $(sslSOURCES) $(logioSOURCES) $(mysqlSOURCES) $(pgsqlSOURCES) $(dbiSOURCES) $(dbdSOURCES) |
| 108 | 118 | ||
| 109 | all: $(TARGETS) all-subdirs | 119 | all: $(TARGETS) all-subdirs |
| 110 | 120 | ||
| @@ -150,6 +160,11 @@ $(dbiTARGET): $(dbiSOURCES) $(HEADERS) | |||
| 150 | @@APXS_BIN@ -c -o $(dbiTARGET) $(dbiCFLAGS) $(CFLAGS) \ | 160 | @@APXS_BIN@ -c -o $(dbiTARGET) $(dbiCFLAGS) $(CFLAGS) \ |
| 151 | @DEFS@ @AP_DEFS@ $(dbiLDADD) $(dbiSOURCES) | 161 | @DEFS@ @AP_DEFS@ $(dbiLDADD) $(dbiSOURCES) |
| 152 | 162 | ||
| 163 | $(dbdTARGET): $(dbdSOURCES) $(HEADERS) | ||
| 164 | @@APXS_BIN@ -c -o $(dbdTARGET) $(dbdCFLAGS) $(CFLAGS) \ | ||
| 165 | @DEFS@ @AP_DEFS@ $(dbdLDADD) $(dbdSOURCES) | ||
| 166 | |||
| 167 | |||
| 153 | install: $(TARGETS) install-subdirs | 168 | install: $(TARGETS) install-subdirs |
| 154 | @@APXS_BIN@ -n $(coreNAME) -i $(coreTARGET); \ | 169 | @@APXS_BIN@ -n $(coreNAME) -i $(coreTARGET); \ |
| 155 | if test @WANT_MYSQL_MOD@ -eq 1; then \ | 170 | if test @WANT_MYSQL_MOD@ -eq 1; then \ |
| @@ -161,6 +176,9 @@ install: $(TARGETS) install-subdirs | |||
| 161 | if test @WANT_DBI_MOD@ -eq 1; then \ | 176 | if test @WANT_DBI_MOD@ -eq 1; then \ |
| 162 | @APXS_BIN@ -n $(dbiNAME) -i $(dbiTARGET); \ | 177 | @APXS_BIN@ -n $(dbiNAME) -i $(dbiTARGET); \ |
| 163 | fi; \ | 178 | fi; \ |
| 179 | if test @WANT_DBD_MOD@ -eq 1; then \ | ||
| 180 | @APXS_BIN@ -n $(dbdNAME) -i $(dbdTARGET); \ | ||
| 181 | fi; \ | ||
| 164 | if test @WANT_SSL_MOD@ -eq 1; then \ | 182 | if test @WANT_SSL_MOD@ -eq 1; then \ |
| 165 | @APXS_BIN@ -n $(sslNAME) -i $(sslTARGET); \ | 183 | @APXS_BIN@ -n $(sslNAME) -i $(sslTARGET); \ |
| 166 | fi; \ | 184 | fi; \ |
| @@ -241,7 +259,7 @@ stamp-h: config.h.in config.status | |||
| 241 | ./config.status | 259 | ./config.status |
| 242 | 260 | ||
| 243 | $(srcdir)/configure: configure.ac aclocal.m4 | 261 | $(srcdir)/configure: configure.ac aclocal.m4 |
| 244 | cd $(srcdir) && autoconf-2.53 | 262 | cd $(srcdir) && autoconf |
| 245 | 263 | ||
| 246 | Makefile: Makefile.in config.status | 264 | Makefile: Makefile.in config.status |
| 247 | ./config.status | 265 | ./config.status |
| @@ -1,5 +1,5 @@ | |||
| 1 | TODO: | 1 | TODO: |
| 2 | * verify a db driver has been loaded. | 2 | * restructure to be more friendly toward DBD pooling |
| 3 | * validate table names before trying to log them. | 3 | * validate table names before trying to log them. |
| 4 | * write alternate DB driver (PostgreSQL, libDBI, mod_*_pool) | 4 | * write alternate DB driver (PostgreSQL, libDBI, mod_*_pool) |
| 5 | * look at forcing table name to ServerName instead of on of the names in | 5 | * look at forcing table name to ServerName instead of on of the names in |
| @@ -7,7 +7,6 @@ TODO: | |||
| 7 | * LogSQLRotateLogs directive with daily/monthly/weekly/etc. | 7 | * LogSQLRotateLogs directive with daily/monthly/weekly/etc. |
| 8 | * socket-based middleman daemon with configurable conns, or connect/disconnect. | 8 | * socket-based middleman daemon with configurable conns, or connect/disconnect. |
| 9 | * DBI connection pooling. | 9 | * DBI connection pooling. |
| 10 | * apr_dbd backend driver | ||
| 11 | * ignore by cookie | 10 | * ignore by cookie |
| 12 | * investigate thread safety issues | 11 | * investigate thread safety issues |
| 13 | Use libmysqlclient_r for threaded MPM (or always?) | 12 | Use libmysqlclient_r for threaded MPM (or always?) |
diff --git a/configure.ac b/configure.ac index 8a348dc..55de120 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -26,8 +26,17 @@ if test $AP_VERSION = "2.0"; then | |||
| 26 | else | 26 | else |
| 27 | WANT_LOGIO_MOD=0 | 27 | WANT_LOGIO_MOD=0 |
| 28 | fi | 28 | fi |
| 29 | |||
| 29 | AC_SUBST(WANT_LOGIO_MOD) | 30 | AC_SUBST(WANT_LOGIO_MOD) |
| 30 | 31 | ||
| 32 | if test $AP_VERSION = "2.0"; then | ||
| 33 | WANT_DBD_MOD=1 | ||
| 34 | else | ||
| 35 | WANT_DBD_MOD=0 | ||
| 36 | fi | ||
| 37 | |||
| 38 | AC_SUBST(WANT_DBD_MOD) | ||
| 39 | |||
| 31 | CHECK_MYSQL( | 40 | CHECK_MYSQL( |
| 32 | WANT_MYSQL_MOD=1, | 41 | WANT_MYSQL_MOD=1, |
| 33 | AC_MSG_WARN([*** Mysql client libraries not found!]) | 42 | AC_MSG_WARN([*** Mysql client libraries not found!]) |
| @@ -105,6 +114,9 @@ fi | |||
| 105 | if test $WANT_DBI_MOD -eq 1; then | 114 | if test $WANT_DBI_MOD -eq 1; then |
| 106 | AC_MSG_RESULT([ libDBI Driver]) | 115 | AC_MSG_RESULT([ libDBI Driver]) |
| 107 | fi | 116 | fi |
| 117 | if test $WANT_DBD_MOD -eq 1; then | ||
| 118 | AC_MSG_RESULT([ APR DBD Driver]) | ||
| 119 | fi | ||
| 108 | if test $OOO_MAINTAIN -eq 1; then | 120 | if test $OOO_MAINTAIN -eq 1; then |
| 109 | AC_MSG_RESULT([Maintainer mode is on. -Werror is in effect]) | 121 | AC_MSG_RESULT([Maintainer mode is on. -Werror is in effect]) |
| 110 | fi | 122 | fi |
diff --git a/mod_log_sql.c b/mod_log_sql.c index b6a5c83..d319e97 100644 --- a/mod_log_sql.c +++ b/mod_log_sql.c | |||
| @@ -1201,7 +1201,7 @@ static int log_sql_transaction(request_rec *orig) | |||
| 1201 | fields = apr_pstrcat(r->pool, fields, (showcomma ? "," : ""), | 1201 | fields = apr_pstrcat(r->pool, fields, (showcomma ? "," : ""), |
| 1202 | item->sql_field_name, NULL); | 1202 | item->sql_field_name, NULL); |
| 1203 | values = apr_pstrcat(r->pool, values, (showcomma ? "," : ""), | 1203 | values = apr_pstrcat(r->pool, values, (showcomma ? "," : ""), |
| 1204 | global_config.driver->escape(formatted_item, r->pool,&global_config.db), NULL); | 1204 | global_config.driver->escape(r, formatted_item, r->pool,&global_config.db), NULL); |
| 1205 | showcomma = 1; | 1205 | showcomma = 1; |
| 1206 | } | 1206 | } |
| 1207 | 1207 | ||
| @@ -1216,11 +1216,11 @@ static int log_sql_transaction(request_rec *orig) | |||
| 1216 | itemsets = apr_pstrcat(r->pool, itemsets, | 1216 | itemsets = apr_pstrcat(r->pool, itemsets, |
| 1217 | (i > 0 ? "," : ""), | 1217 | (i > 0 ? "," : ""), |
| 1218 | "(", | 1218 | "(", |
| 1219 | global_config.driver->escape(unique_id, r->pool, &global_config.db), | 1219 | global_config.driver->escape(r, unique_id, r->pool, &global_config.db), |
| 1220 | ",", | 1220 | ",", |
| 1221 | global_config.driver->escape(*ptrptr, r->pool,&global_config.db), | 1221 | global_config.driver->escape(r, *ptrptr, r->pool,&global_config.db), |
| 1222 | ",", | 1222 | ",", |
| 1223 | global_config.driver->escape(theitem, r->pool,&global_config.db), | 1223 | global_config.driver->escape(r, theitem, r->pool,&global_config.db), |
| 1224 | ")", | 1224 | ")", |
| 1225 | NULL); | 1225 | NULL); |
| 1226 | i++; | 1226 | i++; |
| @@ -1244,11 +1244,11 @@ static int log_sql_transaction(request_rec *orig) | |||
| 1244 | itemsets = apr_pstrcat(r->pool, itemsets, | 1244 | itemsets = apr_pstrcat(r->pool, itemsets, |
| 1245 | (i > 0 ? "," : ""), | 1245 | (i > 0 ? "," : ""), |
| 1246 | "(", | 1246 | "(", |
| 1247 | global_config.driver->escape(unique_id, r->pool, &global_config.db), | 1247 | global_config.driver->escape(r,unique_id, r->pool, &global_config.db), |
| 1248 | ",", | 1248 | ",", |
| 1249 | global_config.driver->escape(*ptrptr, r->pool,&global_config.db), | 1249 | global_config.driver->escape(r,*ptrptr, r->pool,&global_config.db), |
| 1250 | ",", | 1250 | ",", |
| 1251 | global_config.driver->escape(theitem, r->pool,&global_config.db), | 1251 | global_config.driver->escape(r,theitem, r->pool,&global_config.db), |
| 1252 | ")", | 1252 | ")", |
| 1253 | NULL); | 1253 | NULL); |
| 1254 | i++; | 1254 | i++; |
| @@ -1273,11 +1273,11 @@ static int log_sql_transaction(request_rec *orig) | |||
| 1273 | itemsets = apr_pstrcat(r->pool, itemsets, | 1273 | itemsets = apr_pstrcat(r->pool, itemsets, |
| 1274 | (i > 0 ? "," : ""), | 1274 | (i > 0 ? "," : ""), |
| 1275 | "(", | 1275 | "(", |
| 1276 | global_config.driver->escape(unique_id, r->pool, &global_config.db), | 1276 | global_config.driver->escape(r,unique_id, r->pool, &global_config.db), |
| 1277 | ",", | 1277 | ",", |
| 1278 | global_config.driver->escape(*ptrptr, r->pool,&global_config.db), | 1278 | global_config.driver->escape(r,*ptrptr, r->pool,&global_config.db), |
| 1279 | ",", | 1279 | ",", |
| 1280 | global_config.driver->escape(theitem, r->pool,&global_config.db), | 1280 | global_config.driver->escape(r,theitem, r->pool,&global_config.db), |
| 1281 | ")", | 1281 | ")", |
| 1282 | NULL); | 1282 | NULL); |
| 1283 | i++; | 1283 | i++; |
| @@ -1302,11 +1302,11 @@ static int log_sql_transaction(request_rec *orig) | |||
| 1302 | itemsets = apr_pstrcat(r->pool, itemsets, | 1302 | itemsets = apr_pstrcat(r->pool, itemsets, |
| 1303 | (i > 0 ? "," : ""), | 1303 | (i > 0 ? "," : ""), |
| 1304 | "(", | 1304 | "(", |
| 1305 | global_config.driver->escape(unique_id, r->pool, &global_config.db), | 1305 | global_config.driver->escape(r,unique_id, r->pool, &global_config.db), |
| 1306 | ",", | 1306 | ",", |
| 1307 | global_config.driver->escape(*ptrptr, r->pool,&global_config.db), | 1307 | global_config.driver->escape(r,*ptrptr, r->pool,&global_config.db), |
| 1308 | ",", | 1308 | ",", |
| 1309 | global_config.driver->escape(theitem, r->pool,&global_config.db), | 1309 | global_config.driver->escape(r,theitem, r->pool,&global_config.db), |
| 1310 | ")", | 1310 | ")", |
| 1311 | NULL); | 1311 | NULL); |
| 1312 | i++; | 1312 | i++; |
diff --git a/mod_log_sql.h b/mod_log_sql.h index 2d20374..c1d9bff 100644 --- a/mod_log_sql.h +++ b/mod_log_sql.h | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | #define LOGSQL_DECLARE_DATA __declspec(dllimport) | 24 | #define LOGSQL_DECLARE_DATA __declspec(dllimport) |
| 25 | #endif | 25 | #endif |
| 26 | 26 | ||
| 27 | #define LOG_SQL_PLUGIN_VERSION 20070704 | 27 | #define LOG_SQL_PLUGIN_VERSION 20080318 |
| 28 | 28 | ||
| 29 | /* Registration function for extract functions */ | 29 | /* Registration function for extract functions */ |
| 30 | 30 | ||
| @@ -115,7 +115,7 @@ typedef struct { | |||
| 115 | /* disconnect from the underlying database layer */ | 115 | /* disconnect from the underlying database layer */ |
| 116 | void (*disconnect)(logsql_dbconnection *db); | 116 | void (*disconnect)(logsql_dbconnection *db); |
| 117 | /* escape the SQL statement according to database rules */ | 117 | /* escape the SQL statement according to database rules */ |
| 118 | const char *(*escape)(const char *from_str, apr_pool_t *p, | 118 | const char *(*escape)(request_rec *r,const char *from_str, apr_pool_t *p, |
| 119 | logsql_dbconnection *db); | 119 | logsql_dbconnection *db); |
| 120 | /* insert a SQL query statement */ | 120 | /* insert a SQL query statement */ |
| 121 | logsql_query_ret (*insert)(request_rec *r,logsql_dbconnection *db, | 121 | logsql_query_ret (*insert)(request_rec *r,logsql_dbconnection *db, |
diff --git a/mod_log_sql_dbd.c b/mod_log_sql_dbd.c new file mode 100644 index 0000000..c78a128 --- /dev/null +++ b/mod_log_sql_dbd.c | |||
| @@ -0,0 +1,132 @@ | |||
| 1 | /* $Id: mod_log_sql_dbi.c 120 2004-04-17 15:14:12Z urkle@drip.ws $ */ | ||
| 2 | |||
| 3 | #if defined(WITH_APACHE20) | ||
| 4 | # include "apache20.h" | ||
| 5 | #else | ||
| 6 | # error Unsupported Apache version | ||
| 7 | #endif | ||
| 8 | |||
| 9 | |||
| 10 | #ifdef HAVE_CONFIG_H | ||
| 11 | /* Undefine these to prevent conflicts between Apache ap_config_auto.h and | ||
| 12 | * my config.h. Only really needed for Apache < 2.0.48, but it can't hurt. | ||
| 13 | */ | ||
| 14 | #undef PACKAGE_BUGREPORT | ||
| 15 | #undef PACKAGE_NAME | ||
| 16 | #undef PACKAGE_STRING | ||
| 17 | #undef PACKAGE_TARNAME | ||
| 18 | #undef PACKAGE_VERSION | ||
| 19 | |||
| 20 | #include "config.h" | ||
| 21 | #endif | ||
| 22 | |||
| 23 | #include "mod_log_sql.h" | ||
| 24 | |||
| 25 | #include "apr_dbd.h" | ||
| 26 | #include "mod_dbd.h" | ||
| 27 | |||
| 28 | typedef struct { | ||
| 29 | ap_dbd_t *dbd; | ||
| 30 | } request_config_t; | ||
| 31 | |||
| 32 | LOGSQL_MODULE_FORWARD(dbd); | ||
| 33 | |||
| 34 | static ap_dbd_t *(*dbd_acquire_fn)(request_rec*) = NULL; | ||
| 35 | |||
| 36 | static ap_dbd_t *log_sql_dbd_getconnection(request_rec *r) | ||
| 37 | { | ||
| 38 | request_config_t *rconf = ap_get_module_config(r->request_config, &LOGSQL_MODULE(dbd)); | ||
| 39 | if (!rconf) { | ||
| 40 | rconf = apr_pcalloc(r->pool, sizeof(request_config_t)); | ||
| 41 | ap_set_module_config(r->request_config, &LOGSQL_MODULE(dbd), (void *)rconf); | ||
| 42 | rconf->dbd = dbd_acquire_fn(r); | ||
| 43 | } | ||
| 44 | return rconf->dbd; | ||
| 45 | } | ||
| 46 | |||
| 47 | /* Connect to the database */ | ||
| 48 | static logsql_opendb_ret log_sql_dbd_connect(server_rec *s, logsql_dbconnection *db) | ||
| 49 | { | ||
| 50 | // We are using mod_dbd so we don't do anything here | ||
| 51 | if (!dbd_acquire_fn) { | ||
| 52 | // no mod_dbd return failure | ||
| 53 | log_error(APLOG_MARK,APLOG_ERR,0, s,"mod_log_sql_dbd: mod_dbd is not loaded or available"); | ||
| 54 | return LOGSQL_OPENDB_FAIL; | ||
| 55 | } else { | ||
| 56 | return LOGSQL_OPENDB_SUCCESS; | ||
| 57 | } | ||
| 58 | } | ||
| 59 | |||
| 60 | /* Close the DB link */ | ||
| 61 | static void log_sql_dbd_close(logsql_dbconnection *db) | ||
| 62 | { | ||
| 63 | // mod_dbd handles this, so do nothing | ||
| 64 | } | ||
| 65 | |||
| 66 | /* Routine to escape the 'dangerous' characters that would otherwise | ||
| 67 | * corrupt the INSERT string: ', \, and " | ||
| 68 | */ | ||
| 69 | static const char *log_sql_dbd_escape(request_rec *r, const char *from_str, apr_pool_t *p, | ||
| 70 | logsql_dbconnection *db) | ||
| 71 | { | ||
| 72 | // Acquire a DBD connection from mod_dbd | ||
| 73 | ap_dbd_t *dbd = log_sql_dbd_getconnection(r); | ||
| 74 | if (!dbd) return NULL; | ||
| 75 | |||
| 76 | if (!from_str) | ||
| 77 | return NULL; | ||
| 78 | |||
| 79 | return apr_pstrcat(p, "'",apr_dbd_escape(dbd->driver, p, from_str, dbd->handle),"'",NULL); | ||
| 80 | } | ||
| 81 | |||
| 82 | /* Run an insert query and return a categorized error or success */ | ||
| 83 | static logsql_query_ret log_sql_dbd_query(request_rec *r,logsql_dbconnection *db, | ||
| 84 | const char *query) | ||
| 85 | { | ||
| 86 | int ret; | ||
| 87 | const char *err; | ||
| 88 | int affected; | ||
| 89 | // Acquire a DBD connection from mod_dbd | ||
| 90 | ap_dbd_t *dbd = log_sql_dbd_getconnection(r); | ||
| 91 | if (!dbd) return LOGSQL_QUERY_NOLINK; | ||
| 92 | |||
| 93 | // Run the query | ||
| 94 | ret = apr_dbd_query(dbd->driver, dbd->handle, &affected, query); | ||
| 95 | if (ret == 0) { | ||
| 96 | return LOGSQL_QUERY_SUCCESS; | ||
| 97 | } else { | ||
| 98 | // attempt to detect error message | ||
| 99 | err = apr_dbd_error(dbd->driver, dbd->handle, ret); | ||
| 100 | log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "DB Returned error: (%d) %s", ret, err); | ||
| 101 | // Unable to check if "NO SUCH TABLE" due to apr_dbd not mapping error codes to a standard set. | ||
| 102 | return LOGSQL_QUERY_FAIL; | ||
| 103 | } | ||
| 104 | } | ||
| 105 | |||
| 106 | /* Create table table_name of type table_type. */ | ||
| 107 | static logsql_table_ret log_sql_dbd_create(request_rec *r, logsql_dbconnection *db, | ||
| 108 | logsql_tabletype table_type, const char *table_name) | ||
| 109 | { | ||
| 110 | return LOGSQL_TABLE_FAIL; | ||
| 111 | } | ||
| 112 | |||
| 113 | static const char *supported_drivers[] = {"dbd",NULL}; | ||
| 114 | static logsql_dbdriver log_sql_dbd_driver = { | ||
| 115 | "dbd", | ||
| 116 | supported_drivers, | ||
| 117 | log_sql_dbd_connect,/* open DB connection */ | ||
| 118 | log_sql_dbd_close, /* close DB connection */ | ||
| 119 | log_sql_dbd_escape, /* escape query */ | ||
| 120 | log_sql_dbd_query, /* insert query */ | ||
| 121 | log_sql_dbd_create /* create table */ | ||
| 122 | }; | ||
| 123 | |||
| 124 | LOGSQL_REGISTER(dbd) { | ||
| 125 | dbd_acquire_fn = APR_RETRIEVE_OPTIONAL_FN(ap_dbd_acquire); | ||
| 126 | if (dbd_acquire_fn == NULL) { | ||
| 127 | log_error(APLOG_MARK,APLOG_ERR,0,s,"You must load mod_dbd to enable AuthDBD functions"); | ||
| 128 | } | ||
| 129 | |||
| 130 | log_sql_register_driver(p,&log_sql_dbd_driver); | ||
| 131 | LOGSQL_REGISTER_RETURN; | ||
| 132 | } | ||
diff --git a/mod_log_sql_dbi.c b/mod_log_sql_dbi.c index 8afd844..40a972b 100644 --- a/mod_log_sql_dbi.c +++ b/mod_log_sql_dbi.c | |||
| @@ -90,7 +90,7 @@ static void log_sql_dbi_close(logsql_dbconnection *db) | |||
| 90 | /* Routine to escape the 'dangerous' characters that would otherwise | 90 | /* Routine to escape the 'dangerous' characters that would otherwise |
| 91 | * corrupt the INSERT string: ', \, and " | 91 | * corrupt the INSERT string: ', \, and " |
| 92 | */ | 92 | */ |
| 93 | static const char *log_sql_dbi_escape(const char *from_str, apr_pool_t *p, | 93 | static const char *log_sql_dbi_escape(request_rec *r,const char *from_str, apr_pool_t *p, |
| 94 | logsql_dbconnection *db) | 94 | logsql_dbconnection *db) |
| 95 | { | 95 | { |
| 96 | dbi_conn_rec *dblink = db->handle; | 96 | dbi_conn_rec *dblink = db->handle; |
diff --git a/mod_log_sql_mysql.c b/mod_log_sql_mysql.c index 8202672..942c03a 100644 --- a/mod_log_sql_mysql.c +++ b/mod_log_sql_mysql.c | |||
| @@ -74,7 +74,7 @@ static void log_sql_mysql_close(logsql_dbconnection *db) | |||
| 74 | /* Routine to escape the 'dangerous' characters that would otherwise | 74 | /* Routine to escape the 'dangerous' characters that would otherwise |
| 75 | * corrupt the INSERT string: ', \, and " | 75 | * corrupt the INSERT string: ', \, and " |
| 76 | */ | 76 | */ |
| 77 | static const char *log_sql_mysql_escape(const char *from_str, apr_pool_t *p, | 77 | static const char *log_sql_mysql_escape(request_rec *r, const char *from_str, apr_pool_t *p, |
| 78 | logsql_dbconnection *db) | 78 | logsql_dbconnection *db) |
| 79 | { | 79 | { |
| 80 | /* Return "NULL" for empty strings */ | 80 | /* Return "NULL" for empty strings */ |
