diff options
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | doc/vmod-dbrw.3 | 4 | ||||
-rw-r--r-- | doc/vmod-dbrw.texi | 153 |
4 files changed, 123 insertions, 40 deletions
@@ -3,7 +3,7 @@ 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.2.91 (Git) | 6 | Version 2.3, 2018-12-08 |
7 | 7 | ||
8 | * SQL idle timeout | 8 | * SQL idle timeout |
9 | 9 | ||
diff --git a/configure.ac b/configure.ac index 1212a37..420041e 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -14,7 +14,7 @@ | |||
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.2.91, [gray@gnu.org]) | 17 | AC_INIT([vmod-dbrw], 2.3, [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) |
@@ -43,7 +43,7 @@ AC_PROG_MAKE_SET | |||
43 | AC_HEADER_STDC | 43 | AC_HEADER_STDC |
44 | AC_CHECK_HEADERS([sys/stdlib.h]) | 44 | AC_CHECK_HEADERS([sys/stdlib.h]) |
45 | 45 | ||
46 | AM_VARNISHAPI([4.1],[5.1]) | 46 | AM_VARNISHAPI([4.1],[5.2.1]) |
47 | 47 | ||
48 | ########### | 48 | ########### |
49 | # Check for SQL support | 49 | # Check for SQL support |
diff --git a/doc/vmod-dbrw.3 b/doc/vmod-dbrw.3 index 4760b6b..21d15e2 100644 --- a/doc/vmod-dbrw.3 +++ b/doc/vmod-dbrw.3 | |||
@@ -298,7 +298,7 @@ sub vcl_synth { | |||
298 | .\" for man-based doc pages. | 298 | .\" for man-based doc pages. |
299 | .if "\V[MANCGI]"WEBDOC" \{\ | 299 | .if "\V[MANCGI]"WEBDOC" \{\ |
300 | . ds package vmod-dbrw | 300 | . ds package vmod-dbrw |
301 | . ds version 1.0 | 301 | . ds version 2.2.91 |
302 | . so download.inc | 302 | . so download.inc |
303 | \} | 303 | \} |
304 | .SH "SEE ALSO" | 304 | .SH "SEE ALSO" |
@@ -334,7 +334,7 @@ Sergey Poznyakoff | |||
334 | .SH "BUG REPORTS" | 334 | .SH "BUG REPORTS" |
335 | Report bugs to <gray@gnu.org>. | 335 | Report bugs to <gray@gnu.org>. |
336 | .SH COPYRIGHT | 336 | .SH COPYRIGHT |
337 | Copyright \(co 2013-2014 Sergey Poznyakoff | 337 | Copyright \(co 2013-2018 Sergey Poznyakoff |
338 | .br | 338 | .br |
339 | .na | 339 | .na |
340 | License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> | 340 | License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> |
diff --git a/doc/vmod-dbrw.texi b/doc/vmod-dbrw.texi index 31b15d1..734dadb 100644 --- a/doc/vmod-dbrw.texi +++ b/doc/vmod-dbrw.texi | |||
@@ -118,7 +118,7 @@ configuration file. | |||
118 | 118 | ||
119 | Once the module is configured, the @code{rewrite} function can be called | 119 | Once the module is configured, the @code{rewrite} function can be called |
120 | in the appropriate place of the Varnish configuration file. Its argument | 120 | in the appropriate place of the Varnish configuration file. Its argument |
121 | is a list of variable assignments separated with semicolons, each | 121 | is a list of variable assignments separated by semicolons, each |
122 | assignment having the form @code{@var{name}=@var{value}}. When called, | 122 | assignment having the form @code{@var{name}=@var{value}}. When called, |
123 | @code{rewrite} expands the SQL query registered with the prior call to | 123 | @code{rewrite} expands the SQL query registered with the prior call to |
124 | @code{config} by replacing each @code{$@var{name}} | 124 | @code{config} by replacing each @code{$@var{name}} |
@@ -127,11 +127,14 @@ construct (a @dfn{variable reference}) with the corresponding | |||
127 | variable reference can also be written as @code{$@{@var{name}@}}. | 127 | variable reference can also be written as @code{$@{@var{name}@}}. |
128 | This latter form can be used in contexts where the variable reference is | 128 | 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. | 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 | ||
132 | the expansion of the query. @xref{Expansions}, for a detailed | ||
133 | description of these. | ||
131 | 134 | ||
132 | The expanded query is then sent to the database server. If it returns | 135 | Having undergone expansions, the query is sent to the database server. |
133 | a non-empty set, it is further handled depending on the number of | 136 | The returned set of records (if non-empty) is processed depending on the |
134 | fields it contains. | 137 | number of fields it contains. |
135 | 138 | ||
136 | @cindex result interpretation | 139 | @cindex result interpretation |
137 | @anchor{result interpretation} | 140 | @anchor{result interpretation} |
@@ -155,7 +158,7 @@ treated as an extended POSIX regular expression. If the value matches | |||
155 | the expression, the @var{result} column is expanded by replacing | 158 | the expression, the @var{result} column is expanded by replacing |
156 | @dfn{backreferences}: each occurrence of @code{$@var{digit}} (where | 159 | @dfn{backreferences}: each occurrence of @code{$@var{digit}} (where |
157 | @var{digit} stands for a decimal digit from @samp{0} through @samp{9}) | 160 | @var{digit} stands for a decimal digit from @samp{0} through @samp{9}) |
158 | is replaced with the contents of the @var{digit}s parenthesized | 161 | is replaced by the contents of the @var{digit}s parenthesized |
159 | subexpression in @var{regexp}. For compatibility with the traditional | 162 | subexpression in @var{regexp}. For compatibility with the traditional |
160 | usage, the @code{\@var{digit}} notation is also allowed. The | 163 | usage, the @code{\@var{digit}} notation is also allowed. The |
161 | resulting value is then returned to the caller. | 164 | resulting value is then returned to the caller. |
@@ -234,12 +237,12 @@ Type of the database to use. Valid values are @samp{mysql} and | |||
234 | 237 | ||
235 | @item params | 238 | @item params |
236 | Database connection parameters. This is a list of | 239 | Database connection parameters. This is a list of |
237 | @samp{@var{name}=@var{value}} assignments separated with semicolons. | 240 | @samp{@var{name}=@var{value}} assignments separated by semicolons. |
238 | The @var{value} part can be any sequence of characters, excepting | 241 | The @var{value} part can be any sequence of characters, excepting |
239 | white space and semicolon. If any of these is to appear in it, they | 242 | white space and semicolon. If @var{value} contains any of these, they |
240 | must either be escaped by prepending them with a backslash, or the | 243 | either must be escaped by prepending them with a backslash, or the |
241 | entire @var{value} enclosed in a pair of (single or double) quotes. | 244 | entire @var{value} must be enclosed in a pair of (single or double) |
242 | The following @dfn{escape sequences} are allowed for use in | 245 | quotes. The following @dfn{escape sequences} are allowed for use in |
243 | @var{value}: | 246 | @var{value}: |
244 | 247 | ||
245 | @cindex escape sequences | 248 | @cindex escape sequences |
@@ -247,7 +250,7 @@ The following @dfn{escape sequences} are allowed for use in | |||
247 | @float Table, backslash-interpretation | 250 | @float Table, backslash-interpretation |
248 | @caption{Backslash escapes} | 251 | @caption{Backslash escapes} |
249 | @multitable @columnfractions 0.30 .5 | 252 | @multitable @columnfractions 0.30 .5 |
250 | @item Sequence @tab Replaced with | 253 | @item Sequence @tab Replaced by |
251 | @item \a @tab Audible bell character (@acronym{ASCII} 7) | 254 | @item \a @tab Audible bell character (@acronym{ASCII} 7) |
252 | @item \b @tab Backspace character (@acronym{ASCII} 8) | 255 | @item \b @tab Backspace character (@acronym{ASCII} 8) |
253 | @item \f @tab Form-feed character (@acronym{ASCII} 12) | 256 | @item \f @tab Form-feed character (@acronym{ASCII} 12) |
@@ -258,8 +261,8 @@ The following @dfn{escape sequences} are allowed for use in | |||
258 | @end multitable | 261 | @end multitable |
259 | @end float | 262 | @end float |
260 | 263 | ||
261 | If a backslash is followed by a symbol other than listed above, it | 264 | If a backslash is immediately followed by a symbol not listed in the |
262 | is removed and the symbol following it is reproduced verbatim. | 265 | above table, it is removed and the symbol is reproduced verbatim. |
263 | 266 | ||
264 | Valid parameters are: | 267 | Valid parameters are: |
265 | 268 | ||
@@ -344,15 +347,15 @@ Password to access the database. | |||
344 | @kindex query | 347 | @kindex query |
345 | @cindex database query | 348 | @cindex database query |
346 | @item query | 349 | @item query |
347 | The SQL query to use. It can contain variable references in the | 350 | The SQL query to use. It can contain variable references |
348 | (@code{$@var{name}} or @code{$@{@var{name}@}}), which will be replaced | 351 | (@code{$@var{name}} or @code{$@{@var{name}@}}), which will be expanded |
349 | with the actual value of the @var{name} argument to the function | 352 | to the actual value of the @var{name} argument to the function |
350 | @code{rewrite}. | 353 | @code{rewrite}. @xref{Expansions}, for details. |
351 | @end table | 354 | @end table |
352 | @end deftypefn | 355 | @end deftypefn |
353 | 356 | ||
354 | The example below configures @command{vmod-dbrw} to use MySQL database | 357 | The example below configures @command{vmod-dbrw} to use MySQL database |
355 | @samp{rewrite}, with the user name @samp{varnish} and password @var{guessme}. | 358 | @samp{rewrite}, with the user name @samp{varnish} and password @samp{guessme}. |
356 | 359 | ||
357 | @example | 360 | @example |
358 | @group | 361 | @group |
@@ -369,13 +372,92 @@ sub vcl_recv @{ | |||
369 | @end group | 372 | @end group |
370 | @end example | 373 | @end example |
371 | 374 | ||
375 | @menu | ||
376 | * Expansions:: | ||
377 | @end menu | ||
378 | |||
379 | @node Expansions | ||
380 | @section Expansions | ||
381 | @cindex expansions | ||
382 | @cindex variable expansion | ||
383 | @cindex expansion, variable | ||
384 | The @samp{query} argument to the @code{dbrw.config} function | ||
385 | normally contains variable references. A variable reference has the | ||
386 | form @samp{$@var{variable}} or @samp{$@{@var{variable}@}}, where | ||
387 | @var{variable} is the variable name. When the @code{dbrw.rewrite} | ||
388 | function (@pxref{Rewrite}) is called, each such reference is expanded | ||
389 | to the actual value of @var{variable} passed in the argument to that | ||
390 | function. | ||
391 | |||
392 | The two forms are entirely equivalent. The form with curly braces is | ||
393 | normally used if the variable name is immediately followed by an | ||
394 | alphanumeric symbol, which will otherwise be considered a part of it. | ||
395 | This form also allows for specifying the action to take if the | ||
396 | variable is undefined or expands to an empty value. | ||
397 | |||
398 | During variable expansion, the forms below cause @code{dbrw.rewrite} | ||
399 | to test for a variable that is unset or null (i.e., whose value is an | ||
400 | empty string). Omitting the colon results in a test only for a | ||
401 | variable that is unset. | ||
402 | |||
403 | @table @asis | ||
404 | @item $@{@var{variable}:-@var{word}@} | ||
405 | @dfn{Use Default Values}. If @var{variable} is unset or null, the expansion | ||
406 | of @var{word} is substituted. Otherwise, the value of @var{variable} is | ||
407 | substituted. | ||
408 | |||
409 | @item $@{@var{variable}:=@var{word}@} | ||
410 | @dfn{Assign Default Values}. If @var{variable} is unset or null, the | ||
411 | expansion of @var{word} is assigned to variable. The value of | ||
412 | @var{variable} is then substituted. | ||
413 | |||
414 | @item $@{@var{variable}:?@var{word}@} | ||
415 | @dfn{Display Error if Null or Unset}. If @var{variable} is null or unset, | ||
416 | the expansion of @var{word} (or a message to that effect if @var{word} is | ||
417 | not present) is output to the current logging channel. Otherwise, the | ||
418 | value of @var{variable} is substituted. | ||
419 | |||
420 | @item $@{@var{variable}:+@var{word}@} | ||