}
}
- if (ctx->set->max_pattern_fields_count < count)
- ctx->set->max_pattern_fields_count = count;
+ if (ctx->set->map_set.max_pattern_fields_count < count)
+ ctx->set->map_set.max_pattern_fields_count = count;
ctx->cur_map.pattern = p_strdup(ctx->pool, str_c(pattern));
return NULL;
}
if (strchr(ctx->cur_map.pattern, '$') != NULL)
return "Missing fields for pattern variables";
}
- array_push_back(&ctx->set->maps, &ctx->cur_map);
+ array_push_back(&ctx->set->map_set.maps, &ctx->cur_map);
i_zero(&ctx->cur_map);
return NULL;
}
ctx.pool = pool;
ctx.set = p_new(pool, struct dict_sql_legacy_settings, 1);
t_array_init(&ctx.cur_fields, 16);
- p_array_init(&ctx.set->maps, pool, 8);
+ p_array_init(&ctx.set->map_set.maps, pool, 8);
if (!settings_read(path, NULL, parse_setting, parse_section,
&ctx, error_r)) {
cache->set = ctx.set;
hash_table_insert(dict_sql_legacy_settings_cache, cache->path, cache);
+
+ ctx.set->map_set.pool = pool;
+ pool_ref(pool);
return ctx.set;
}
pool_t pool;
struct sql_db *db;
- const struct dict_sql_legacy_settings *set;
+ struct dict_sql_map_settings *set;
};
#endif
const enum dict_sql_type *value_types;
};
-struct dict_sql_legacy_settings {
- const char *connect;
-
+struct dict_sql_map_settings {
+ pool_t pool;
unsigned int max_pattern_fields_count;
ARRAY(struct dict_sql_map) maps;
};
+struct dict_sql_legacy_settings {
+ const char *connect;
+ struct dict_sql_map_settings map_set;
+};
+
struct dict_sql_legacy_settings *
dict_sql_legacy_settings_read(const char *path, const char **error_r);
struct dict **dict_r, const char **error_r)
{
struct sql_legacy_settings sql_set;
+ struct dict_sql_legacy_settings *dict_sql_set;
struct sql_dict *dict;
pool_t pool;
pool = pool_alloconly_create("sql dict", 2048);
- dict = p_new(pool, struct sql_dict, 1);
- dict->pool = pool;
- dict->dict = *driver;
- dict->set = dict_sql_legacy_settings_read(uri, error_r);
- if (dict->set == NULL) {
+ dict_sql_set = dict_sql_legacy_settings_read(uri, error_r);
+ if (dict_sql_set == NULL) {
pool_unref(&pool);
return -1;
}
+
+ dict = p_new(pool, struct sql_dict, 1);
+ dict->pool = pool;
+ dict->dict = *driver;
+ dict->set = &dict_sql_set->map_set;
+
i_zero(&sql_set);
sql_set.driver = driver->name;
- sql_set.connect_string = dict->set->connect;
+ sql_set.connect_string = dict_sql_set->connect;
sql_set.event_parent = set->event_parent;
if (sql_db_cache_new_legacy(dict_sql_db_cache, &sql_set,
{
struct sql_dict *dict = (struct sql_dict *)_dict;
+ pool_unref(&dict->set->pool);
sql_unref(&dict->db);
pool_unref(&dict->pool);
}