static HASH_TABLE(const char *, struct dict_sql_settings_cache *) dict_sql_settings_cache;
+static const char *dict_sql_type_names[] = {
+ "string",
+ "int",
+ "uint",
+ "double",
+ "hexblob",
+ "uuid",
+};
+static_assert_array_size(dict_sql_type_names, DICT_SQL_TYPE_COUNT);
+
static const char *pattern_read_name(const char **pattern)
{
const char *p = *pattern, *name;
static bool
dict_sql_value_type_parse(const char *value_type, enum dict_sql_type *type_r)
{
- if (strcmp(value_type, "string") == 0)
- *type_r = DICT_SQL_TYPE_STRING;
- else if (strcmp(value_type, "hexblob") == 0)
- *type_r = DICT_SQL_TYPE_HEXBLOB;
- else if (strcmp(value_type, "int") == 0)
- *type_r = DICT_SQL_TYPE_INT;
- else if (strcmp(value_type, "uint") == 0)
- *type_r = DICT_SQL_TYPE_UINT;
- else if (strcmp(value_type, "double") == 0)
- *type_r = DICT_SQL_TYPE_DOUBLE;
- else if (strcmp(value_type, "uuid") == 0)
- *type_r = DICT_SQL_TYPE_UUID;
- else
- return FALSE;
- return TRUE;
+ for (enum dict_sql_type type = DICT_SQL_TYPE_STRING;
+ type < DICT_SQL_TYPE_COUNT; type++) {
+ if (strcmp(value_type, dict_sql_type_names[type]) == 0) {
+ *type_r = type;
+ return TRUE;
+ }
+ }
+ return FALSE;
}
static const char *dict_sql_map_finish(struct setting_parser_ctx *ctx)
case DICT_SQL_TYPE_UUID:
sql_statement_bind_uuid(stmt, column_idx, param->value_uuid);
break;
+ case DICT_SQL_TYPE_COUNT:
+ i_unreached();
}
}
return 0;
case DICT_SQL_TYPE_HEXBLOB:
break;
+ case DICT_SQL_TYPE_COUNT:
+ i_unreached();
}
buf = t_buffer_create(strlen(value)/2);
return guid_128_to_uuid_string(guid, FORMAT_RECORD);
case DICT_SQL_TYPE_HEXBLOB:
break;
+ case DICT_SQL_TYPE_COUNT:
+ i_unreached();
}
data = sql_result_get_field_value_binary(result, result_idx, &size);