diff options
-rw-r--r-- | NEWS | 19 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | doc/vmod-dbrw.3 | 24 | ||||
-rw-r--r-- | doc/vmod-dbrw.texi | 38 | ||||
-rw-r--r-- | src/dbrw.h | 1 | ||||
-rw-r--r-- | src/vmod_dbrw.c | 110 | ||||
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/atlocal.in | 9 | ||||
-rw-r--r-- | tests/initdb.at | 4 | ||||
-rw-r--r-- | tests/rewrite07.at | 40 | ||||
-rw-r--r-- | tests/testsuite.at | 1 |
11 files changed, 198 insertions, 53 deletions
@@ -1,11 +1,26 @@ | |||
1 | vmod-dbrw -- history of user-visible changes. 2018-12-10 | 1 | vmod-dbrw -- history of user-visible changes. 2019-02-13 |
2 | See the end of file for copying conditions. | 2 | See the end of file for copying conditions. |
3 | 3 | ||
4 | Please send vmod-dbrw bug reports to <gray@gnu.org> | 4 | Please send vmod-dbrw bug reports to <gray@gnu.org> |
5 | 5 | ||
6 | Version 2.4.90 (git) | ||
7 | |||
8 | * req.http.X-VMOD-DBRW-Error | ||
9 | |||
10 | This header is set to 1 by dbrw.rewrite to indicate that an error | ||
11 | occurred during the rewrite. | ||
12 | |||
13 | * New flags: regex and eq | ||
14 | |||
15 | One of this flags can appear in the fourth column of the returned data | ||
16 | set. The 'eq' flag instructs dbrw.rewrite to use exact string match, | ||
17 | instead of regular expressions. The 'regex' flag instructs it to use | ||
18 | regular expression matching. It is the default. | ||
19 | |||
20 | |||
6 | Version 2.4, 2018-12-10 | 21 | Version 2.4, 2018-12-10 |
7 | 22 | ||
8 | * Support for Varnish version 6.0.2 | 23 | * Support for Varnish version 6.0.2 |
9 | 24 | ||
10 | 25 | ||
11 | Version 2.3, 2018-12-08 | 26 | Version 2.3, 2018-12-08 |
@@ -75,13 +90,13 @@ Version 1.0, 2013-07-20 | |||
75 | 90 | ||
76 | Initial release | 91 | Initial release |
77 | 92 | ||
78 | ========================================================================= | 93 | ========================================================================= |
79 | Copyright information: | 94 | Copyright information: |
80 | 95 | ||
81 | Copyright (C) 2013-2018 Sergey Poznyakoff | 96 | Copyright (C) 2013-2019 Sergey Poznyakoff |
82 | 97 | ||
83 | Permission is granted to anyone to make or distribute verbatim copies | 98 | Permission is granted to anyone to make or distribute verbatim copies |
84 | of this document as received, in any medium, provided that the | 99 | of this document as received, in any medium, provided that the |
85 | copyright notice and this permission notice are preserved, | 100 | copyright notice and this permission notice are preserved, |
86 | thus giving the recipient permission to redistribute in turn. | 101 | thus giving the recipient permission to redistribute in turn. |
87 | 102 | ||
diff --git a/configure.ac b/configure.ac index 62c3afe..fd618d3 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -1,8 +1,8 @@ | |||
1 | # This file is part of vmod-dbrw -*- autoconf -*- | 1 | # This file is part of vmod-dbrw -*- autoconf -*- |
2 | # Copyright (C) 2013-2018 Sergey Poznyakoff | 2 | # Copyright (C) 2013-2019 Sergey Poznyakoff |
3 | # | 3 | # |
4 | # Vmod-dbrw is free software; you can redistribute it and/or modify | 4 | # Vmod-dbrw is free software; you can redistribute it and/or modify |
5 | # it under the terms of the GNU General Public License as published by | 5 | # it under the terms of the GNU General Public License as published by |
6 | # the Free Software Foundation; either version 3, or (at your option) | 6 | # the Free Software Foundation; either version 3, or (at your option) |
7 | # any later version. | 7 | # any later version. |
8 | # | 8 | # |
@@ -11,13 +11,13 @@ | |||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | # GNU General Public License for more details. | 12 | # GNU General Public License for more details. |
13 | # | 13 | # |
14 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
15 | # along with vmod-dbrw. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with vmod-dbrw. If not, see <http://www.gnu.org/licenses/>. |
16 | AC_PREREQ(2.69) | 16 | AC_PREREQ(2.69) |
17 | AC_INIT([vmod-dbrw], 2.4, [gray@gnu.org]) | 17 | AC_INIT([vmod-dbrw], 2.4.90, [gray@gnu.org]) |
18 | AC_CONFIG_AUX_DIR([build-aux]) | 18 | AC_CONFIG_AUX_DIR([build-aux]) |
19 | AC_CONFIG_MACRO_DIR([m4]) | 19 | AC_CONFIG_MACRO_DIR([m4]) |
20 | AC_CONFIG_SRCDIR(src/vmod_dbrw.vcc) | 20 | AC_CONFIG_SRCDIR(src/vmod_dbrw.vcc) |
21 | AM_CONFIG_HEADER(config.h) | 21 | AM_CONFIG_HEADER(config.h) |
22 | 22 | ||
23 | AC_SUBST([AC_VMOD_BASENAME],[dbrw]) | 23 | AC_SUBST([AC_VMOD_BASENAME],[dbrw]) |
diff --git a/doc/vmod-dbrw.3 b/doc/vmod-dbrw.3 index 2abef65..9bec008 100644 --- a/doc/vmod-dbrw.3 +++ b/doc/vmod-dbrw.3 | |||
@@ -10,13 +10,13 @@ | |||
10 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | .\" GNU General Public License for more details. | 12 | .\" GNU General Public License for more details. |
13 | .\" | 13 | .\" |
14 | .\" You should have received a copy of the GNU General Public License | 14 | .\" You should have received a copy of the GNU General Public License |
15 | .\" along with vmod-dbrw. If not, see <http://www.gnu.org/licenses/>. | 15 | .\" along with vmod-dbrw. If not, see <http://www.gnu.org/licenses/>. |
16 | .TH VMOD-DBRW 3 "December 8, 2018" "VMOD-DBRW" "User Reference" | 16 | .TH VMOD-DBRW 3 "February 13, 2019" "VMOD-DBRW" "User Reference" |
17 | .SH NAME | 17 | .SH NAME |
18 | vmod-dbrw \- Database-driven rewrite rules for Varnish Cache | 18 | vmod-dbrw \- Database-driven rewrite rules for Varnish Cache |
19 | .SH SYNOPSIS | 19 | .SH SYNOPSIS |
20 | .B import dbrw; | 20 | .B import dbrw; |
21 | .PP | 21 | .PP |
22 | .BI "VOID dbrw.config(STRING " dbtype ", STRING " params ", STRING " query ");" | 22 | .BI "VOID dbrw.config(STRING " dbtype ", STRING " params ", STRING " query ");" |
@@ -187,29 +187,49 @@ modify regular expression handling. The following flags are defined: | |||
187 | .BR NC " or " nocase | 187 | .BR NC " or " nocase |
188 | Treat \fBregexp\fR as case-insensitive. | 188 | Treat \fBregexp\fR as case-insensitive. |
189 | .TP | 189 | .TP |
190 | .B case | 190 | .B case |
191 | Treat \fBregexp\fR as case-sensitive (default). | 191 | Treat \fBregexp\fR as case-sensitive (default). |
192 | .TP | 192 | .TP |
193 | .B eq | ||
194 | Use exact string matching. | ||
195 | .TP | ||
193 | .BR QSA " or " qsappend | 196 | .BR QSA " or " qsappend |
194 | Treat the resulting value as URL; append any query string from the | 197 | Treat the resulting value as URL; append any query string from the |
195 | original \fBvalue\fR to it. | 198 | original \fBvalue\fR to it. |
196 | .TP | 199 | .TP |
197 | .BR QSD " or " qsdiscard | 200 | .BR QSD " or " qsdiscard |
198 | Treat the resulting value as URL; discard any query string attached to | 201 | Treat the resulting value as URL; discard any query string attached to |
199 | the original \fBvalue\fR. | 202 | the original \fBvalue\fR. |
200 | .TP | 203 | .TP |
201 | \fBredirect=\fICODE\fR or \fBR=\fICODE\fR | 204 | \fBredirect=\fICODE\fR or \fBR=\fICODE\fR |
202 | On success, set the \fBX\-VMOD\-DBRW\-Status\fR header to \fICODE\fR, | 205 | On success, set the \fBX\-VMOD\-DBRW\-Status\fR header to \fICODE\fR, |
203 | which must be a valid HTTP status code. | 206 | which must be a valid HTTP status code. |
207 | .TP | ||
208 | .B regex | ||
209 | Use regular expression matching. This is the default. This flag is | ||
210 | provided for completeness sake, as a counterpart of | ||
211 | .BR eq . | ||
204 | .PP | 212 | .PP |
205 | If \fBregexp\fR or \fBvalue\fR is NULL, the tuple is handled as | 213 | If \fBregexp\fR or \fBvalue\fR is NULL, the tuple is handled as |
206 | described in | 214 | described in |
207 | .BR "Strict matches" . | 215 | .BR "Strict matches" . |
208 | .PP | 216 | .PP |
209 | If \fBflags\fR is NULL, it is ignored. | 217 | If \fBflags\fR is NULL, it is ignored. |
218 | .SH HTTP HEADERS | ||
219 | Upon return, | ||
220 | .B dbrw.return | ||
221 | may set one of the following headers in | ||
222 | .BR resp.http : | ||
223 | .TP | ||
224 | .B X\-VMOD\-DBRW\-Status | ||
225 | If the \fBredirect\fR flag was used, this header contains the HTTP | ||
226 | response code to be used instead of the default. | ||
227 | .TP | ||
228 | .B X\-VMOD\-DBRW\-Error | ||
229 | This header is set to \fB1\fR if an error occurred during the rewrite. | ||
210 | .SH EXAMPLES | 230 | .SH EXAMPLES |
211 | The examples in this section assume \fBMySQL\fR databases. Any | 231 | The examples in this section assume \fBMySQL\fR databases. Any |
212 | details not related to \fBvmod-dbrw\fR are omitted. | 232 | details not related to \fBvmod-dbrw\fR are omitted. |
213 | .SS Redirects | 233 | .SS Redirects |
214 | .PP | 234 | .PP |
215 | This example shows how to implement apache-style permanent redirects | 235 | This example shows how to implement apache-style permanent redirects |
diff --git a/doc/vmod-dbrw.texi b/doc/vmod-dbrw.texi index 734dadb..6a987ed 100644 --- a/doc/vmod-dbrw.texi +++ b/doc/vmod-dbrw.texi | |||
@@ -129,13 +129,20 @@ This latter form can be used in contexts where the variable reference is | |||
129 | immediately followed by a letter, digit or underscore, to prevent it | 129 | immediately followed by a letter, digit or underscore, to prevent it |
130 | from being counted as a part of the name. Special syntax is available | 130 | from being counted as a part of the name. Special syntax is available |
131 | for substituting default values and invoking built-in functions during | 131 | for substituting default values and invoking built-in functions during |
132 | the expansion of the query. @xref{Expansions}, for a detailed | 132 | the expansion of the query. @xref{Expansions}, for a detailed |
133 | description of these. | 133 | description of these. |
134 | 134 | ||
135 | @anchor{X-VMOD-DBRW-Error} | ||
136 | @vindex X-VMOD-DBRW-Error | ||
135 | Having undergone expansions, the query is sent to the database server. | 137 | Having undergone expansions, the query is sent to the database server. |
138 | If the query returns no records or if an error occured, @code{rewrite} | ||
139 | returns empty string. In case of error, it also sets the HTTP header | ||
140 | @samp{X-VMOD-DBRW-Error: 1}. It can be used in VLC code to provide a | ||
141 | special handling for such failures. | ||
142 | |||
136 | The returned set of records (if non-empty) is processed depending on the | 143 | The returned set of records (if non-empty) is processed depending on the |
137 | number of fields it contains. | 144 | number of fields it contains. |
138 | 145 | ||
139 | @cindex result interpretation | 146 | @cindex result interpretation |
140 | @anchor{result interpretation} | 147 | @anchor{result interpretation} |
141 | @cindex strict matching | 148 | @cindex strict matching |
@@ -163,13 +170,13 @@ subexpression in @var{regexp}. For compatibility with the traditional | |||
163 | usage, the @code{\@var{digit}} notation is also allowed. The | 170 | usage, the @code{\@var{digit}} notation is also allowed. The |
164 | resulting value is then returned to the caller. | 171 | resulting value is then returned to the caller. |
165 | 172 | ||
166 | @cindex flags | 173 | @cindex flags |
167 | @anchor{flags} | 174 | @anchor{flags} |
168 | Optional @var{flags} column is a comma-separated list of flags that | 175 | Optional @var{flags} column is a comma-separated list of flags that |
169 | modify regular expression handling: | 176 | control the matching algorithm. |
170 | 177 | ||
171 | @table @samp | 178 | @table @samp |
172 | @kindex NC |