# HG changeset patch # User Timo Sirainen # Date 1246155409 14400 # Node ID e67c9b3e88b09601f34a21ee18639f8c11199f95 # Parent eed86bcc33aa46972c37eba52b428ade09bc9048 dict sql: If pattern, table or value_field is unset, fail early with an error. diff -r eed86bcc33aa -r e67c9b3e88b0 src/lib-dict/dict-sql-settings.c --- a/src/lib-dict/dict-sql-settings.c Sat Jun 27 22:08:33 2009 -0400 +++ b/src/lib-dict/dict-sql-settings.c Sat Jun 27 22:16:49 2009 -0400 @@ -120,6 +120,18 @@ 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);