diff options
Diffstat (limited to 'doc/vmod-dbrw.3')
-rw-r--r-- | doc/vmod-dbrw.3 | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/doc/vmod-dbrw.3 b/doc/vmod-dbrw.3 index 6f1dba8..4760b6b 100644 --- a/doc/vmod-dbrw.3 +++ b/doc/vmod-dbrw.3 @@ -1,3 +1,3 @@ .\" This file is part of Vmod-dbrw -*- nroff -*- -.\" Copyright (C) 2013-2017 Sergey Poznyakoff +.\" Copyright (C) 2013-2018 Sergey Poznyakoff .\" @@ -15,3 +15,3 @@ .\" along with vmod-dbrw. If not, see <http://www.gnu.org/licenses/>. -.TH VMOD-DBRW 1 "January 30, 2018" "VMOD-DBRW" "User Reference" +.TH VMOD-DBRW 1 "December 8, 2018" "VMOD-DBRW" "User Reference" .SH NAME @@ -136,2 +136,28 @@ of the name. .PP +The special construct +.sp +.EX +$(urlprefixes \fIPATH\fR) +.EE +.sp +expands to a comma-separated list of all possible path prefixes in +\fIPATH\fR. Each element in the list is quoted, so the result can +safely be used in SQL statements. For example, +.sp +.EX +$(urlprefixes "/local/user/login") +.EE +.sp +produces +.sp +.EX + '/local/user/login','/local/user','/local' +.EE +.PP +This statement is usually used in \fBIN\fR SQL constructs, e.g. +.sp +.EX +SELECT * FROM table WHERE url IN ($(urlprefixes $url)) +.EE +.PP The expanded query is then sent to the database server. Handling @@ -250,3 +276,5 @@ sub vcl_recv { {"SELECT dest,pattern,value,flags FROM rewrite - WHERE host='$host' and '$url' like url"}); + WHERE host='$host' + AND url IN ($(urlprefixes $url)) + ORDER BY LENGTH(dest),value DESC"}); set req.http.X-Redirect-To = |