aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS19
-rw-r--r--configure.ac4
-rw-r--r--doc/vmod-dbrw.324
-rw-r--r--doc/vmod-dbrw.texi38
-rw-r--r--src/dbrw.h1
-rw-r--r--src/vmod_dbrw.c110
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/atlocal.in9
-rw-r--r--tests/initdb.at4
-rw-r--r--tests/rewrite07.at40
-rw-r--r--tests/testsuite.at1
11 files changed, 198 insertions, 53 deletions
diff --git a/NEWS b/NEWS
index 0300ec3..516ca69 100644
--- a/NEWS
+++ b/NEWS
@@ -1,11 +1,26 @@
1vmod-dbrw -- history of user-visible changes. 2018-12-10 1vmod-dbrw -- history of user-visible changes. 2019-02-13
2See the end of file for copying conditions. 2See the end of file for copying conditions.
3 3
4Please send vmod-dbrw bug reports to <gray@gnu.org> 4Please send vmod-dbrw bug reports to <gray@gnu.org>
5 5
6Version 2.4.90 (git)
7
8* req.http.X-VMOD-DBRW-Error
9
10This header is set to 1 by dbrw.rewrite to indicate that an error
11occurred during the rewrite.
12
13* New flags: regex and eq
14
15One of this flags can appear in the fourth column of the returned data
16set. The 'eq' flag instructs dbrw.rewrite to use exact string match,
17instead of regular expressions. The 'regex' flag instructs it to use
18regular expression matching. It is the default.
19
20
6Version 2.4, 2018-12-10 21Version 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
11Version 2.3, 2018-12-08 26Version 2.3, 2018-12-08
@@ -75,13 +90,13 @@ Version 1.0, 2013-07-20
75 90
76Initial release 91Initial release
77 92
78========================================================================= 93=========================================================================
79Copyright information: 94Copyright information:
80 95
81Copyright (C) 2013-2018 Sergey Poznyakoff 96Copyright (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/>.
16AC_PREREQ(2.69) 16AC_PREREQ(2.69)
17AC_INIT([vmod-dbrw], 2.4, [gray@gnu.org]) 17AC_INIT([vmod-dbrw], 2.4.90, [gray@gnu.org])
18AC_CONFIG_AUX_DIR([build-aux]) 18AC_CONFIG_AUX_DIR([build-aux])
19AC_CONFIG_MACRO_DIR([m4]) 19AC_CONFIG_MACRO_DIR([m4])
20AC_CONFIG_SRCDIR(src/vmod_dbrw.vcc) 20AC_CONFIG_SRCDIR(src/vmod_dbrw.vcc)
21AM_CONFIG_HEADER(config.h) 21AM_CONFIG_HEADER(config.h)
22 22
23AC_SUBST([AC_VMOD_BASENAME],[dbrw]) 23AC_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
18vmod-dbrw \- Database-driven rewrite rules for Varnish Cache 18vmod-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
188Treat \fBregexp\fR as case-insensitive. 188Treat \fBregexp\fR as case-insensitive.
189.TP 189.TP
190.B case 190.B case
191Treat \fBregexp\fR as case-sensitive (default). 191Treat \fBregexp\fR as case-sensitive (default).
192.TP 192.TP
193.B eq
194Use exact string matching.
195.TP
193.BR QSA " or " qsappend 196.BR QSA " or " qsappend
194Treat the resulting value as URL; append any query string from the 197Treat the resulting value as URL; append any query string from the
195original \fBvalue\fR to it. 198original \fBvalue\fR to it.
196.TP 199.TP
197.BR QSD " or " qsdiscard 200.BR QSD " or " qsdiscard
198Treat the resulting value as URL; discard any query string attached to 201Treat the resulting value as URL; discard any query string attached to
199the original \fBvalue\fR. 202the original \fBvalue\fR.
200.TP 203.TP
201\fBredirect=\fICODE\fR or \fBR=\fICODE\fR 204\fBredirect=\fICODE\fR or \fBR=\fICODE\fR
202On success, set the \fBX\-VMOD\-DBRW\-Status\fR header to \fICODE\fR, 205On success, set the \fBX\-VMOD\-DBRW\-Status\fR header to \fICODE\fR,
203which must be a valid HTTP status code. 206which must be a valid HTTP status code.
207.TP
208.B regex
209Use regular expression matching. This is the default. This flag is
210provided for completeness sake, as a counterpart of
211.BR eq .
204.PP 212.PP
205If \fBregexp\fR or \fBvalue\fR is NULL, the tuple is handled as 213If \fBregexp\fR or \fBvalue\fR is NULL, the tuple is handled as
206described in 214described in
207.BR "Strict matches" . 215.BR "Strict matches" .
208.PP 216.PP
209If \fBflags\fR is NULL, it is ignored. 217If \fBflags\fR is NULL, it is ignored.
218.SH HTTP HEADERS
219Upon return,
220.B dbrw.return
221may set one of the following headers in
222.BR resp.http :
223.TP
224.B X\-VMOD\-DBRW\-Status
225If the \fBredirect\fR flag was used, this header contains the HTTP
226response code to be used instead of the default.
227.TP
228.B X\-VMOD\-DBRW\-Error
229This header is set to \fB1\fR if an error occurred during the rewrite.
210.SH EXAMPLES 230.SH EXAMPLES
211The examples in this section assume \fBMySQL\fR databases. Any 231The examples in this section assume \fBMySQL\fR databases. Any
212details not related to \fBvmod-dbrw\fR are omitted. 232details not related to \fBvmod-dbrw\fR are omitted.
213.SS Redirects 233.SS Redirects
214.PP 234.PP
215This example shows how to implement apache-style permanent redirects 235This 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
129immediately followed by a letter, digit or underscore, to prevent it 129immediately followed by a letter, digit or underscore, to prevent it
130from being counted as a part of the name. Special syntax is available 130from being counted as a part of the name. Special syntax is available
131for substituting default values and invoking built-in functions during 131for substituting default values and invoking built-in functions during
132the expansion of the query. @xref{Expansions}, for a detailed 132the expansion of the query. @xref{Expansions}, for a detailed
133description of these. 133description of these.
134 134
135@anchor{X-VMOD-DBRW-Error}
136@vindex X-VMOD-DBRW-Error
135Having undergone expansions, the query is sent to the database server. 137Having undergone expansions, the query is sent to the database server.
138If the query returns no records or if an error occured, @code{rewrite}
139returns 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
141special handling for such failures.
142
136The returned set of records (if non-empty) is processed depending on the 143The returned set of records (if non-empty) is processed depending on the
137number of fields it contains. 144number 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
163usage, the @code{\@var{digit}} notation is also allowed. The 170usage, the @code{\@var{digit}} notation is also allowed. The
164resulting value is then returned to the caller. 171resulting value is then returned to the caller.
165 172
166@cindex flags 173@cindex flags
167@anchor{flags} 174@anchor{flags}
168Optional @var{flags} column is a comma-separated list of flags that 175Optional @var{flags} column is a comma-separated list of flags that
169modify regular expression handling: 176control the matching algorithm.
170 177
171@table @samp 178@table @samp
172@kindex NC