diff --git a/src/maat_compile.c b/src/maat_compile.c index 3744534..a58f56e 100644 --- a/src/maat_compile.c +++ b/src/maat_compile.c @@ -134,7 +134,6 @@ struct maat_clause_state { struct compile_sort_para { int declared_clause_num; long long compile_id; - void *user; }; #define MAAT_COMPILE_MAGIC 0x4a5b6c7d @@ -2095,12 +2094,10 @@ static int compile_sort_para_compare(const struct compile_sort_para *a, } static void compile_sort_para_set(struct compile_sort_para *para, - const struct compile_rule *compile_relation, - void *user) + const struct compile_rule *rule) { - para->compile_id = compile_relation->compile_id; - para->declared_clause_num = compile_relation->declared_clause_num; - para->user = user; + para->compile_id = rule->compile_id; + para->declared_clause_num = rule->declared_clause_num; } static int compare_compile_rule(const void *a, const void *b) @@ -2109,8 +2106,8 @@ static int compare_compile_rule(const void *a, const void *b) const struct compile_rule *rb = *(const struct compile_rule **)b; struct compile_sort_para sa, sb; - compile_sort_para_set(&sa, ra, NULL); - compile_sort_para_set(&sb, rb, NULL); + compile_sort_para_set(&sa, ra); + compile_sort_para_set(&sb, rb); return compile_sort_para_compare(&sa, &sb); } diff --git a/src/maat_virtual.c b/src/maat_virtual.c index 56c0848..a4ce24f 100644 --- a/src/maat_virtual.c +++ b/src/maat_virtual.c @@ -20,8 +20,8 @@ #define MODULE_VIRTUAL module_name_str("maat.virtual") struct virtual_schema { - char physical_table[NAME_MAX]; - int table_id; + int vtable_id; + int physical_table_id; struct table_manager *ref_tbl_mgr; }; @@ -38,7 +38,7 @@ void *virtual_schema_new(cJSON *json, struct table_manager *tbl_mgr, __FUNCTION__, __LINE__, table_name); goto error; } - schema->table_id = item->valueint; + schema->vtable_id = item->valueint; item = cJSON_GetObjectItem(json, "physical_table"); if (NULL == item || item->type != cJSON_String) { @@ -48,7 +48,13 @@ void *virtual_schema_new(cJSON *json, struct table_manager *tbl_mgr, goto error; } - memcpy(schema->physical_table, item->valuestring, strlen(item->valuestring)); + schema->physical_table_id = table_manager_get_table_id(tbl_mgr, item->valuestring); + if (schema->physical_table_id < 0) { + log_error(logger, MODULE_VIRTUAL, + "[%s:%d] virtual table:<%s>'s physical table:<%s> unregistered.", + __FUNCTION__, __LINE__, table_name, item->valuestring); + goto error; + } return schema; error: @@ -69,5 +75,5 @@ int virtual_table_get_physical_table_id(void *virtual_schema) struct virtual_schema *schema = (struct virtual_schema *)virtual_schema; - return table_manager_get_table_id(schema->ref_tbl_mgr, schema->physical_table); + return schema->physical_table_id; } \ No newline at end of file