Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
18f5b8b6
Commit
18f5b8b6
authored
Sep 19, 2013
by
Martin Blix Grydeland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add '==' operator to query language
parent
5fb1da6b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
11 deletions
+53
-11
l00001.vtc
bin/varnishtest/tests/l00001.vtc
+12
-4
vsl_query.c
lib/libvarnishapi/vsl_query.c
+41
-7
No files found.
bin/varnishtest/tests/l00001.vtc
View file @
18f5b8b6
...
...
@@ -17,14 +17,22 @@ client c1 {
} -run
# Test 'eq' operator
logexpect l1 -d 1 -g
request
-q "Begin eq 'req 1000'" {
expect * * Begin
logexpect l1 -d 1 -g
vxid
-q "Begin eq 'req 1000'" {
expect * * Begin
req
expect * = ReqEnd
expect * = End
} -run
# Test 'ne' operator
logexpect l1 -d 1 -g
request
-q "ReqProtocol ne 'HTTP/1.0'" {
expect * * Begin
logexpect l1 -d 1 -g
vxid
-q "ReqProtocol ne 'HTTP/1.0'" {
expect * * Begin
req
expect * = ReqEnd
expect * = End
} -run
# Test '==' operator
logexpect l1 -d 1 -g vxid -q "RespStatus == 200" {
expect * * Begin req
expect * = ReqEnd
expect * = End
} -run
lib/libvarnishapi/vsl_query.c
View file @
18f5b8b6
...
...
@@ -33,6 +33,7 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <ctype.h>
#include "vas.h"
#include "miniobj.h"
...
...
@@ -58,6 +59,8 @@ vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec)
const
struct
vex_val
*
val
;
int
reclen
;
const
char
*
recdata
;
long
long
recint
;
char
*
endptr
;
AN
(
vex
);
AN
(
rec
);
...
...
@@ -67,17 +70,49 @@ vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec)
reclen
=
VSL_LEN
(
rec
->
ptr
);
recdata
=
VSL_CDATA
(
rec
->
ptr
);
/* Prepare */
switch
(
vex
->
tok
)
{
case
T_EQ
:
/* == */
case
T_NEQ
:
/* != */
case
'<'
:
case
'>'
:
case
T_LEQ
:
/* <= */
case
T_GEQ
:
/* >= */
/* Numerical comparison */
switch
(
val
->
type
)
{
case
VEX_INT
:
recint
=
strtoll
(
recdata
,
&
endptr
,
0
);
if
(
*
endptr
==
'\0'
||
isspace
(
*
endptr
))
break
;
/* Can't parse - no match */
return
(
0
);
default:
INCOMPL
();
}
break
;
}
/* Compare */
switch
(
vex
->
tok
)
{
case
T_EQ
:
/* == */
switch
(
val
->
type
)
{
case
VEX_INT
:
if
(
val
->
val_int
==
recint
)
return
(
1
);
return
(
0
);
default:
INCOMPL
();
}
case
T_SEQ
:
/* eq */
assert
(
v
ex
->
v
al
->
type
==
VEX_STRING
);
if
(
reclen
==
val
->
val_stringlen
&&
!
strncmp
(
v
ex
->
v
al
->
val_string
,
recdata
,
reclen
))
assert
(
val
->
type
==
VEX_STRING
);
if
(
reclen
==
val
->
val_stringlen
+
1
&&
!
strncmp
(
val
->
val_string
,
recdata
,
reclen
))
return
(
1
);
return
(
0
);
case
T_SNEQ
:
/* ne */
assert
(
v
ex
->
v
al
->
type
==
VEX_STRING
);
if
(
reclen
!=
val
->
val_stringlen
||
strncmp
(
v
ex
->
v
al
->
val_string
,
recdata
,
reclen
))
assert
(
val
->
type
==
VEX_STRING
);
if
(
reclen
!=
val
->
val_stringlen
+
1
||
strncmp
(
val
->
val_string
,
recdata
,
reclen
))
return
(
1
);
return
(
0
);
default:
...
...
@@ -96,7 +131,6 @@ vslq_test(const struct vex *vex, struct VSL_transaction * const ptrans[])
CHECK_OBJ_NOTNULL
(
vex
,
VEX_MAGIC
);
CHECK_OBJ_NOTNULL
(
vex
->
tag
,
VEX_TAG_MAGIC
);
CHECK_OBJ_NOTNULL
(
vex
->
val
,
VEX_VAL_MAGIC
);
AN
(
vex
->
val
->
val_string
);
for
(
t
=
ptrans
[
0
];
t
!=
NULL
;
t
=
*++
ptrans
)
{
AZ
(
VSL_ResetCursor
(
t
->
c
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment