Skip to content
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

Merged
merged 6 commits into from
Jun 28, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/MainDistributionPipeline.yml
Original file line number Diff line number Diff line change
@@ -14,9 +14,9 @@ concurrency:
jobs:
duckdb-stable-build:
name: Build extension binaries
uses: duckdb/extension-ci-tools/.github/workflows/_extension_distribution.yml@v0.10.3
uses: duckdb/extension-ci-tools/.github/workflows/_extension_distribution.yml@v1.0.0
with:
duckdb_version: v0.10.3
duckdb_version: main
extension_name: sqlsmith

duckdb-stable-deploy:
@@ -25,6 +25,6 @@ jobs:
uses: ./.github/workflows/_extension_deploy.yml
secrets: inherit
with:
duckdb_version: v0.10.3
duckdb_version: main
extension_name: sqlsmith
deploy_latest: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' }}
10 changes: 7 additions & 3 deletions src/statement_generator.cpp
Original file line number Diff line number Diff line change
@@ -517,9 +517,13 @@ unique_ptr<TableRef> StatementGenerator::GenerateSubqueryRef() {
}

unique_ptr<TableRef> StatementGenerator::GenerateTableFunctionRef() {
auto function = make_uniq<TableFunctionRef>();
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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

random_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)];
Copy link
Collaborator

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

Copy link
Collaborator

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 &entry = table_function_ref->get().Cast<TableFunctionCatalogEntry>();
auto table_function = entry.functions.GetFunctionByOffset(RandomValue(entry.functions.Size()));

auto result = make_uniq<TableFunctionRef>();

Unchanged files with check annotations Beta