aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-07-20 17:50:20 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2013-07-20 17:50:20 +0300
commita2ec89d9d05229a5555d8302da83cb7e1314faa6 (patch)
tree6b4f4f89f9fc2ef483da27f6bb704a1633193944
parentbc20099519128f2640f57188c392039003a7a452 (diff)
downloadvmod-dbrw-a2ec89d9d05229a5555d8302da83cb7e1314faa6.tar.gz
vmod-dbrw-a2ec89d9d05229a5555d8302da83cb7e1314faa6.tar.bz2
Use vmod-dbrw (with a dash) as the canonical project name.
-rw-r--r--Makefile.am8
-rw-r--r--configure.ac10
-rw-r--r--doc/.gitignore30
-rw-r--r--doc/Makefile.am22
-rw-r--r--doc/vmod-dbrw.3402
-rw-r--r--doc/vmod-dbrw.texi (renamed from doc/vmod_dbrw.texi)32
-rw-r--r--doc/vmod_dbrw.3403
-rw-r--r--src/Makefile.am8
-rw-r--r--src/dbrw.h8
-rw-r--r--src/mysql.c8
-rw-r--r--src/pgsql.c8
-rw-r--r--src/sql.c8
-rw-r--r--src/vmod_dbrw.c8
13 files changed, 486 insertions, 469 deletions
diff --git a/Makefile.am b/Makefile.am
index 829c138..fa15223 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,5 @@
1# This file is part of libvmod_dbrw 1# This file is part of vmod-dbrw
2# Copyright (C) 2013 Sergey Poznyakoff 2# Copyright (C) 2013 Sergey Poznyakoff
3# 3#
4# Libvmod_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
@@ -8,3 +8,3 @@
8# 8#
9# Libvmod_dbrw is distributed in the hope that it will be useful, 9# Vmod-dbrw is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -14,3 +14,3 @@
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 libvmod_dbrw. If not, see <http://www.gnu.org/licenses/>. 15# along with vmod-dbrw. If not, see <http://www.gnu.org/licenses/>.
16ACLOCAL_AMFLAGS = -I m4 16ACLOCAL_AMFLAGS = -I m4
diff --git a/configure.ac b/configure.ac
index d5a8767..a287eb3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
1# This file is part of libvmod_dbrw -*- autoconf -*- 1# This file is part of vmod-dbrw -*- autoconf -*-
2# Copyright (C) 2013 Sergey Poznyakoff 2# Copyright (C) 2013 Sergey Poznyakoff
3# 3#
4# Libvmod_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
@@ -8,3 +8,3 @@
8# 8#
9# Libvmod_dbrw is distributed in the hope that it will be useful, 9# Vmod-dbrw is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -14,5 +14,5 @@
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 libvmod_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([libvmod-dbrw], 0.99, [gray@gnu.org]) 17AC_INIT([vmod-dbrw], 0.99, [gray@gnu.org])
18AC_CONFIG_AUX_DIR([build-aux]) 18AC_CONFIG_AUX_DIR([build-aux])
diff --git a/doc/.gitignore b/doc/.gitignore
index 4e23977..ddb72ba 100644
--- a/doc/.gitignore
+++ b/doc/.gitignore
@@ -3,17 +3,17 @@ stamp-vti
3version.texi 3version.texi
4vmod_dbrw.info* 4vmod-dbrw.info*
5vmod_dbrw.aux 5vmod-dbrw.aux
6vmod_dbrw.cp 6vmod-dbrw.cp
7vmod_dbrw.cps 7vmod-dbrw.cps
8vmod_dbrw.fn 8vmod-dbrw.fn
9vmod_dbrw.kw 9vmod-dbrw.kw
10vmod_dbrw.ky 10vmod-dbrw.ky
11vmod_dbrw.log 11vmod-dbrw.log
12vmod_dbrw.op 12vmod-dbrw.op
13vmod_dbrw.pdf 13vmod-dbrw.pdf
14vmod_dbrw.pg 14vmod-dbrw.pg
15vmod_dbrw.toc 15vmod-dbrw.toc
16vmod_dbrw.tp 16vmod-dbrw.tp
17vmod_dbrw.vr 17vmod-dbrw.vr
18vmod_dbrw.t2p 18vmod-dbrw.t2p
19manual 19manual
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 9e03e8a..88cf24b 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,3 +1,19 @@
1dist_man_MANS = vmod_dbrw.3 1# This file is part of vmod-dbrw
2info_TEXINFOS=vmod_dbrw.texi 2# Copyright (C) 2013 Sergey Poznyakoff
3#
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
6# the Free Software Foundation; either version 3, or (at your option)
7# any later version.
8#
9# Vmod-dbrw is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
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/>.
16
17dist_man_MANS = vmod-dbrw.3 vmod_dbrw.3
18info_TEXINFOS=vmod-dbrw.texi
3vmod_dbrw_TEXINFOS=fdl.texi 19vmod_dbrw_TEXINFOS=fdl.texi
@@ -21,3 +37,3 @@ manual:
21 TEXI2HTML="texi2html $(AM_MAKEINFOFLAGS)" \ 37 TEXI2HTML="texi2html $(AM_MAKEINFOFLAGS)" \
22 $(GENDOCS) --texi2html vmod_dbrw 'Vmod_dbrw manual' 38 $(GENDOCS) --texi2html $(PACKAGE) '$(PACKAGE_NAME) manual'
23 39
diff --git a/doc/vmod-dbrw.3 b/doc/vmod-dbrw.3
new file mode 100644
index 0000000..9c35772
--- /dev/null
+++ b/doc/vmod-dbrw.3
@@ -0,0 +1,402 @@
1.\" This file is part of Vmod-dbrw -*- nroff -*-
2.\" Copyright (C) 2013 Sergey Poznyakoff
3.\"
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
6.\" the Free Software Foundation; either version 3, or (at your option)
7.\" any later version.
8.\"
9.\" Vmod-dbrw is distributed in the hope that it will be useful,
10.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
11.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12.\" GNU General Public License for more details.
13.\"
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/>.
16.TH VMOD_DBRW 1 "July 19, 2013" "VMOD_DBRW" "User Reference"
17.SH NAME
18vmod-dbrw \- Database-driven rewrite rules for Varnish Cache
19.SH SYNOPSIS
20.sp
21.nf
22import dbrw;
23
24sub vcl_init {
25 dbrw.config("\fIDBTYPE\fR", "\fIPARAMS\fR", "\fIQUERY\fR");
26}
27
28sub vcl_recv {
29 set req.http.\fIXHEADER\fR = dbrw.rewrite(\fIARGS\fR);
30 if (req.http.\fIXHEADER\fR) {
31 error(750, "Redirect");
32 }
33}
34
35sub vcl_error {
36 if (obj.status == 750) {
37 set obj.http.Location = req.http.\fIXHEADER\fR;
38 set obj.status = 301;
39 return (deliver);
40 }
41}
42.fi
43.SH DESCRIPTION
44.B Vmod-dbrw
45is a Varnish Cache module implementing database-driven rewrite procedures.
46Its intended use is for web sites that need an exceedingly big number
47of redirect and/or rewrite rules.
48.PP
49Upon startup, the \fBconfig\fR function should be called. This call
50configures the module and supplies it the information necessary for
51accessing the database and interpreting the data obtained from it.
52.PP
53Two database types are supported: \fBMySQL\fR or \fBPostgreSQL\fR.
54The first argument \fBconfig\fR instructs the module which type to
55use.
56.PP
57.B Vmod-dbrw
58does not impose any requirements on the structure of the database,
59therefore the connection arguments and access credentials may vary
60depending on the flavor of the database used. This information is
61supplied in the \fIPARAMS\fR argument, which is a list of parameter
62assignments separated with semicolons.
63.PP
64Once configured, the \fBrewrite\fR function can be called in the
65appropriate place of the Varnish configuration file. Its argument
66\fIARGS\fR is a list of variable assignments separated with
67semicolons, similarly to the \fIPARAMS\fR argument described above.
68Each assignment has the form \fINAME\fB=\fIVALUE\fR. When called
69the function expands the \fBSQL\fR query, supplied with the \fIQUERY\fR
70argument to the \fBconfig\fR call, by replacing each \fB$\fINAME\fR
71construct (a \fBvariable reference\fR) with the corresponding
72\fIVALUE\fR from its argument. Similarly to the shell syntax, the
73variable reference can be written as \fB${\fINAME\fB}\fR. This latter
74form can be used in contexts where the variable name is immediately
75followed by another letter, to prevent it from being counted as a part
76of the name.
77.PP
78The expanded query is then sent to the database server. The handling
79of the return value depends on the number of fields it contains.
80.SS Strict matches
81If the returned set consists of one or two columns, only the
82first tuple is used and the value of its first column is returned.
83The second column (if present) is ignored.
84.SS Regexp matches
85Otherwise, if the returned set consists of three or four columns, the
86columns are interpreted as follows: \fBresult\fR, \fBregexp\fR,
87\fBvalue\fR and optional \fBflags\fR. For each returned tuple, the
88\fBvalue\fR column undergoes variable expansion, using the same
89algorithm as when preparing the query, and the resulting string is
90matched with the \fBregexp\fR column, which is treated as an extended
91\fBPOSIX\fR regular expression. If the match occurs, the \fBresult\fR
92column is expanded by replacing \fBbackreferences\fR. Each occurrence
93of \fB$\fIDIGIT\fR (where \fIDIGIT\fR stands for a decimal digit from
94\fB0\fR through \fB9\fR) is replaced with the contents of the
95\fIDIGIT\fR's parenthesized subexpression in \fBregexp\fR. For
96compatibility with the traditional usage, the \fB\\\fIDIGIT\fR
97notation is also allowed. The resulting value is returned.
98.PP
99Optional \fBflags\fR column is a comma-separated list of flags that
100modify regular expression handling. The following flags are defined:
101.TP
102.BR NC " or " nocase
103Treat \fBregexp\fR as case-insensitive.
104.TP