From a86b81824f948db51d19e0f8abefdb91894e0b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Tue, 2 Jan 2018 14:07:51 +0200 Subject: [PATCH] MXS-1575: Add extra debug assertions Added more debug assertions to JSON serialization of the Avro schema. Also checked that the column count for the TABLE_CREATE object matches that of the TABLE_MAP object. --- server/modules/routing/avrorouter/avro_schema.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/modules/routing/avrorouter/avro_schema.c b/server/modules/routing/avrorouter/avro_schema.c index 2d8199802..9bdc47edb 100644 --- a/server/modules/routing/avrorouter/avro_schema.c +++ b/server/modules/routing/avrorouter/avro_schema.c @@ -123,10 +123,13 @@ char* json_new_schema_from_table(TABLE_MAP *map) json_array_append_new(array, json_pack_ex(&err, 0, "{s:s, s:o}", "name", avro_event_type, "type", event_types)); - for (uint64_t i = 0; i < map->columns; i++) + for (uint64_t i = 0; i < map->columns && i < create->columns; i++) { ss_info_dassert(create->column_names[i] && *create->column_names[i], "Column name should not be empty or NULL"); + ss_info_dassert(create->column_types[i] && *create->column_types[i], + "Column type should not be empty or NULL"); + json_array_append_new(array, json_pack_ex(&err, 0, "{s:s, s:s, s:s, s:i}", "name", create->column_names[i], "type", column_type_to_avro_type(map->column_types[i]),