From 8856a91711f93e099b6d1dfc89af7248017ffe5e Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sat, 27 Jun 2009 22:16:40 -0400 Subject: [PATCH] dict sql: If pattern, table or value_field is unset, fail early with an error. --HG-- branch : HEAD --- src/lib-dict/dict-sql-settings.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lib-dict/dict-sql-settings.c b/src/lib-dict/dict-sql-settings.c index 0afa362189..c9a16e6833 100644 --- a/src/lib-dict/dict-sql-settings.c +++ b/src/lib-dict/dict-sql-settings.c @@ -120,6 +120,18 @@ static const char *dict_sql_fields_map(struct setting_parser_ctx *ctx) static const char *dict_sql_map_finish(struct setting_parser_ctx *ctx) { + if (ctx->cur_map.pattern == NULL) + return "Missing setting: pattern"; + if (ctx->cur_map.table == NULL) + return "Missing setting: table"; + if (ctx->cur_map.value_field == NULL) + return "Missing setting: value_field"; + + if (ctx->cur_map.username_field == NULL) { + /* not all queries require this */ + ctx->cur_map.username_field = "'username_field not set'"; + } + if (!array_is_created(&ctx->cur_map.sql_fields)) { /* no fields besides value. allocate the array anyway. */ p_array_init(&ctx->cur_map.sql_fields, ctx->pool, 1); -- 2.47.3