-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
avoid CatalogType::TABLE_MACRO_ENTRY which can cause SIGABRT #5
Conversation
src/statement_generator.cpp
Outdated
auto &table_function_ref = Choose(generator_context->table_functions); | ||
auto &entry = table_function_ref.get().Cast<TableFunctionCatalogEntry>(); | ||
auto original_val = generator_context->table_functions.size(); | ||
auto random_fun = RandomValue(original_val); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
random_val
?
src/statement_generator.cpp
Outdated
auto random_fun = RandomValue(original_val); | ||
auto table_function_ref = &generator_context->table_functions[random_fun]; | ||
while (table_function_ref->get().type == CatalogType::TABLE_MACRO_ENTRY) { | ||
table_function_ref = &generator_context->table_functions[RandomValue(original_val)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can the logic of the while loop change a bit?
1. random_val +=1 % generator_context->table_functions.size();
2. if (random_val == original_val) -> Error
3. table_function_ref = &generator_context->table_functions[random_val]
This way we can prevent an infinite loop
src/statement_generator.cpp
Outdated
if (random_val == original_val) { | ||
throw InternalException("No table_functions to test."); | ||
} | ||
table_function_ref = &generator_context->table_functions[RandomValue(original_val)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RandomValue(original_val)
is still here, you can just have
table_function_ref = &generator_context->table_functions[random_val];
since random_val was increased by 1
auto table_function_ref = &generator_context->table_functions[random_val]; | ||
while (table_function_ref->get().type == CatalogType::TABLE_MACRO_ENTRY) { | ||
random_val += 1 % original_val; | ||
if (random_val == original_val) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, but realizing this is still wrong.
original_val is set to the size of the generator_context->table_functions
vector.
original_val should be the first random value (i.e the RandomValue()
returned on line 521.
Then random_val
can be increased in the while loop (with the modulo) until it is equal to original_val
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically it should look like
auto num_table_functions = generator_context->table_functions.size();
auto random_val = RandomValue(original_val);
auto original_val = random_val;
auto table_function_ref = &generator_context->table_functions[random_val];
while (table_function_ref->get().type == CatalogType::TABLE_MACRO_ENTRY) {
random_val += 1; // I also think the + and modulo needs to be split up,
// otherwise you get random_val = random_val + (1 % num_table_functions)
random_val = random_val % num_table_functions;
if (random_val == original_val) {
....
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't get all these details earlier. Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great thanks!
StatementGenerator::GetDatabaseState() recognises the
CatalogType::TABLE_MACRO_ENTRY
as atable_functions
according to theCatalogSet &DuckSchemaEntry::GetCatalogSet(CatalogType type)
.During a discussion with @Tmonster it was decided to avoid
CatalogType::TABLE_MACRO_ENTRY
in the Statement Generator.