changeset 9175:e67c9b3e88b0 HEAD

dict sql: If pattern, table or value_field is unset, fail early with an error.
author Timo Sirainen <tss@iki.fi>
date Sat, 27 Jun 2009 22:16:49 -0400
parents eed86bcc33aa
children fcebba0f438f
files src/lib-dict/dict-sql-settings.c
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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);