Allow TableOptions::Additional to influence cost (#2694)

This also allows LIKE for OS X's preferences table.
This commit is contained in:
Teddy Reed 2016-10-29 23:19:54 -07:00 committed by GitHub
parent ed13157fe5
commit 8fc8134d17
2 changed files with 20 additions and 6 deletions

View File

@ -343,7 +343,7 @@ static int xBestIndex(sqlite3_vtab* tab, sqlite3_index_info* pIdxInfo) {
if (options & ColumnOptions::REQUIRED) {
index_used = true;
required_satisfied = true;
} else if (options & ColumnOptions::INDEX) {
} else if (options & (ColumnOptions::INDEX | ColumnOptions::ADDITIONAL)) {
index_used = true;
}

View File

@ -165,9 +165,8 @@ void genOSXDefaultPreferences(QueryContext& context, QueryData& results) {
app_map = (CFArrayRef)CFArrayCreateMutable(
kCFAllocatorDefault, domains.size(), &kCFTypeArrayCallBacks);
for (const auto& domain : domains) {
auto cf_domain = CFStringCreateWithCString(kCFAllocatorDefault,
domain.c_str(),
kCFStringEncodingASCII);
auto cf_domain = CFStringCreateWithCString(
kCFAllocatorDefault, domain.c_str(), kCFStringEncodingASCII);
CFArrayAppendValue((CFMutableArrayRef)app_map, cf_domain);
CFRelease(cf_domain);
}
@ -244,9 +243,24 @@ void genOSXPlistPreferences(const std::string& path, QueryData& results) {
QueryData genOSXPreferences(QueryContext& context) {
QueryData results;
if (context.constraints["path"].exists(EQUALS)) {
// Read preferences from a plist at path.
if (context.constraints["path"].exists(EQUALS | LIKE)) {
// Resolve file paths for EQUALS and LIKE operations.
auto paths = context.constraints["path"].getAll(EQUALS);
context.expandConstraints(
"path",
LIKE,
paths,
([&](const std::string& pattern, std::set<std::string>& out) {
std::vector<std::string> patterns;
auto status =
resolveFilePattern(pattern, patterns, GLOB_ALL | GLOB_NO_CANON);
if (status.ok()) {
for (const auto& resolved : patterns) {
out.insert(resolved);
}
}
return status;
}));
for (const auto& path : paths) {
genOSXPlistPreferences(path, results);
}