diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-07-20 17:50:20 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-07-20 17:50:20 +0300 |
commit | a2ec89d9d05229a5555d8302da83cb7e1314faa6 (patch) | |
tree | 6b4f4f89f9fc2ef483da27f6bb704a1633193944 | |
parent | bc20099519128f2640f57188c392039003a7a452 (diff) | |
download | vmod-dbrw-a2ec89d9d05229a5555d8302da83cb7e1314faa6.tar.gz vmod-dbrw-a2ec89d9d05229a5555d8302da83cb7e1314faa6.tar.bz2 |
Use vmod-dbrw (with a dash) as the canonical project name.
-rw-r--r-- | Makefile.am | 8 | ||||
-rw-r--r-- | configure.ac | 10 | ||||
-rw-r--r-- | doc/.gitignore | 30 | ||||
-rw-r--r-- | doc/Makefile.am | 22 | ||||
-rw-r--r-- | doc/vmod-dbrw.3 | 402 | ||||
-rw-r--r-- | doc/vmod-dbrw.texi (renamed from doc/vmod_dbrw.texi) | 32 | ||||
-rw-r--r-- | doc/vmod_dbrw.3 | 403 | ||||
-rw-r--r-- | src/Makefile.am | 8 | ||||
-rw-r--r-- | src/dbrw.h | 8 | ||||
-rw-r--r-- | src/mysql.c | 8 | ||||
-rw-r--r-- | src/pgsql.c | 8 | ||||
-rw-r--r-- | src/sql.c | 8 | ||||
-rw-r--r-- | src/vmod_dbrw.c | 8 |
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/>. |
16 | ACLOCAL_AMFLAGS = -I m4 | 16 | ACLOCAL_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/>. |
16 | AC_PREREQ(2.69) | 16 | AC_PREREQ(2.69) |
17 | AC_INIT([libvmod-dbrw], 0.99, [gray@gnu.org]) | 17 | AC_INIT([vmod-dbrw], 0.99, [gray@gnu.org]) |
18 | AC_CONFIG_AUX_DIR([build-aux]) | 18 | AC_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 | |||
3 | version.texi | 3 | version.texi |
4 | vmod_dbrw.info* | 4 | vmod-dbrw.info* |
5 | vmod_dbrw.aux | 5 | vmod-dbrw.aux |
6 | vmod_dbrw.cp | 6 | vmod-dbrw.cp |
7 | vmod_dbrw.cps | 7 | vmod-dbrw.cps |
8 | vmod_dbrw.fn | 8 | vmod-dbrw.fn |
9 | vmod_dbrw.kw | 9 | vmod-dbrw.kw |
10 | vmod_dbrw.ky | 10 | vmod-dbrw.ky |
11 | vmod_dbrw.log | 11 | vmod-dbrw.log |
12 | vmod_dbrw.op | 12 | vmod-dbrw.op |
13 | vmod_dbrw.pdf | 13 | vmod-dbrw.pdf |
14 | vmod_dbrw.pg | 14 | vmod-dbrw.pg |
15 | vmod_dbrw.toc | 15 | vmod-dbrw.toc |
16 | vmod_dbrw.tp | 16 | vmod-dbrw.tp |
17 | vmod_dbrw.vr | 17 | vmod-dbrw.vr |
18 | vmod_dbrw.t2p | 18 | vmod-dbrw.t2p |
19 | manual | 19 | manual |
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 @@ | |||
1 | dist_man_MANS = vmod_dbrw.3 | 1 | # This file is part of vmod-dbrw |
2 | info_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 | |||
17 | dist_man_MANS = vmod-dbrw.3 vmod_dbrw.3 | ||
18 | info_TEXINFOS=vmod-dbrw.texi | ||
3 | vmod_dbrw_TEXINFOS=fdl.texi | 19 | vmod_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 | ||
18 | vmod-dbrw \- Database-driven rewrite rules for Varnish Cache | ||
19 | .SH SYNOPSIS | ||
20 | .sp | ||
21 | .nf | ||
22 | import dbrw; | ||
23 | |||
24 | sub vcl_init { | ||
25 | dbrw.config("\fIDBTYPE\fR", "\fIPARAMS\fR", "\fIQUERY\fR"); | ||
26 | } | ||
27 | |||
28 | sub 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 | |||
35 | sub 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 | ||
45 | is a Varnish Cache module implementing database-driven rewrite procedures. | ||
46 | Its intended use is for web sites that need an exceedingly big number | ||
47 | of redirect and/or rewrite rules. | ||
48 | .PP | ||
49 | Upon startup, the \fBconfig\fR function should be called. This call | ||
50 | configures the module and supplies it the information necessary for | ||
51 | accessing the database and interpreting the data obtained from it. | ||
52 | .PP | ||
53 | Two database types are supported: \fBMySQL\fR or \fBPostgreSQL\fR. | ||
54 | The first argument \fBconfig\fR instructs the module which type to | ||
55 | use. | ||
56 | .PP | ||
57 | .B Vmod-dbrw | ||
58 | does not impose any requirements on the structure of the database, | ||
59 | therefore the connection arguments and access credentials may vary | ||
60 | depending on the flavor of the database used. This information is | ||
61 | supplied in the \fIPARAMS\fR argument, which is a list of parameter | ||
62 | assignments separated with semicolons. | ||
63 | .PP | ||
64 | Once configured, the \fBrewrite\fR function can be called in the | ||
65 | appropriate place of the Varnish configuration file. Its argument | ||
66 | \fIARGS\fR is a list of variable assignments separated with | ||
67 | semicolons, similarly to the \fIPARAMS\fR argument described above. | ||
68 | Each assignment has the form \fINAME\fB=\fIVALUE\fR. When called | ||
69 | the function expands the \fBSQL\fR query, supplied with the \fIQUERY\fR | ||
70 | argument to the \fBconfig\fR call, by replacing each \fB$\fINAME\fR | ||
71 | construct (a \fBvariable reference\fR) with the corresponding | ||
72 | \fIVALUE\fR from its argument. Similarly to the shell syntax, the | ||
73 | variable reference can be written as \fB${\fINAME\fB}\fR. This latter | ||
74 | form can be used in contexts where the variable name is immediately | ||
75 | followed by another letter, to prevent it from being counted as a part | ||
76 | of the name. | ||
77 | .PP | ||
78 | The expanded query is then sent to the database server. The handling | ||
79 | of the return value depends on the number of fields it contains. | ||
80 | .SS Strict matches | ||
81 | If the returned set consists of one or two columns, only the | ||
82 | first tuple is used and the value of its first column is returned. | ||
83 | The second column (if present) is ignored. | ||
84 | .SS Regexp matches | ||
85 | Otherwise, if the returned set consists of three or four columns, the | ||
86 | columns 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 | ||
89 | algorithm as when preparing the query, and the resulting string is | ||
90 | matched with the \fBregexp\fR column, which is treated as an extended | ||
91 | \fBPOSIX\fR regular expression. If the match occurs, the \fBresult\fR | ||
92 | column is expanded by replacing \fBbackreferences\fR. Each occurrence | ||
93 | of \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 | ||
96 | compatibility with the traditional usage, the \fB\\\fIDIGIT\fR | ||
97 | notation is also allowed. The resulting value is returned. | ||
98 | .PP | ||
99 | Optional \fBflags\fR column is a comma-separated list of flags that | ||
100 | modify regular expression handling. The following flags are defined: | ||
101 | .TP | ||
102 | .BR NC " or " nocase | ||
103 | Treat \fBregexp\fR as case-insensitive. | ||
104 | .TP | ||