summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 842fabc)
raw | patch | inline | side by side (parent: 842fabc)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 5 Oct 2014 17:50:20 +0000 (19:50 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 5 Oct 2014 17:50:20 +0000 (19:50 +0200) |
Added an integration test which reproduces the problem -- previously, all
compare operations reported a mismatch.
compare operations reported a mismatch.
src/core/store_lookup.c | patch | blob | history | |
t/integration/simple_query.sh | patch | blob | history | |
t/unit/core/store_lookup_test.c | patch | blob | history |
index d53bd58f35d743228ee054ccdfdd530e94360f6f..9176592723265cd2f5607a8f622473783c8a557b 100644 (file)
--- a/src/core/store_lookup.c
+++ b/src/core/store_lookup.c
sdb_data_t value = SDB_DATA_INIT;
int status;
- if (sdb_store_get_field(obj, OBJ_C(cond)->field, &obj_value))
- return INT_MAX;
if (sdb_store_expr_eval(OBJ_C(cond)->expr, obj, &value))
return INT_MAX;
- if (obj_value.type != value.type) {
- sdb_data_free_datum(&value);
- return INT_MAX;
- }
- else if (OBJ_C(cond)->field == SDB_FIELD_BACKEND) {
+ if (OBJ_C(cond)->field == SDB_FIELD_BACKEND) {
/* this implementation is not actually a conditional but rather checks
* for equality (or rather, existence) only */
size_t i;
+
+ if (value.type != SDB_TYPE_STRING)
+ return INT_MAX;
+
status = INT_MAX;
for (i = 0; i < obj->backends_num; ++i) {
if (! strcasecmp(obj->backends[i], value.data.string)) {
break;
}
}
+ sdb_data_free_datum(&value);
+ return status;
}
- else {
- status = sdb_data_cmp(&obj_value, &value);
+
+ if (sdb_store_get_field(obj, OBJ_C(cond)->field, &obj_value))
+ return INT_MAX;
+ if (obj_value.type != value.type) {
+ sdb_data_free_datum(&obj_value);
+ sdb_data_free_datum(&value);
+ return INT_MAX;
}
+
+ status = sdb_data_cmp(&obj_value, &value);
+ sdb_data_free_datum(&obj_value);
sdb_data_free_datum(&value);
return status;
} /* obj_cmp */
index b6394432d1111cd9e9aa58ee7f58a9329dcaee83..35a55cef8a8f830716172cf351b88ba37f5e694e 100755 (executable)
FILTER :last_update < 2Y" )"
echo $output | grep -E '^\[\]$'
+output="$( run_sysdb -H "$SOCKET_FILE" \
+ -c "LOOKUP hosts FILTER :backend = 'backend::mock_plugin'" )"
+echo "$output" \
+ | grep -F '"host1.example.com"' \
+ | grep -F '"host2.example.com"' \
+ | grep -F '"localhost"' \
+ | grep -F '"other.host.name"' \
+ | grep -F '"some.host.name"'
+output="$( run_sysdb -H "$SOCKET_FILE" \
+ -c "LOOKUP hosts FILTER :backend = 'invalid'" )"
+echo $output | grep -E '^\[\]$'
+
output="$( run_sysdb -H "$SOCKET_FILE" \
-c "LOOKUP hosts MATCHING service = 'sysdbd'" )"
echo "$output" | grep -F '"localhost"'
index 754eb13f18808fba615ed1e809ac4d4b39a526e7..13861bbd79d6d7dcabf237095a91fe1857c9381c 100644 (file)
{ SDB_TYPE_INTEGER, { .integer = 0 } }, 0, 0, 0, 0, 0 },
{ "a", SDB_FIELD_BACKEND,
{ SDB_TYPE_INTEGER, { .integer = 0 } }, 0, 0, 0, 0, 0 },
+ { "a", SDB_FIELD_BACKEND,
+ { SDB_TYPE_INTEGER, { .integer = 0 } }, 0, 0, 0, 0, 0 },
+ /* (64bit) integer value without zero-bytes */
+ { "a", SDB_FIELD_BACKEND,
+ { SDB_TYPE_INTEGER, { .integer = 0xffffffffffffffffL } },
+ 0, 0, 0, 0, 0 },
};
int status;