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

Delete statement #11

Merged
merged 5 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 3 additions & 5 deletions .github/workflows/MainDistributionPipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@ jobs:
name: Build extension binaries
uses: duckdb/extension-ci-tools/.github/workflows/[email protected]
with:
duckdb_version: v1.0.0
duckdb_version: main
extension_name: sqlsmith
exclude_archs: 'wasm_mvp;wasm_eh;wasm_threads;windows_amd64_rtools'

duckdb-stable-deploy:
name: Deploy extension binaries
needs: duckdb-stable-build
uses: duckdb/extension-ci-tools/.github/workflows/[email protected]
secrets: inherit
with:
duckdb_version: v1.0.0
duckdb_version: main
extension_name: sqlsmith
exclude_archs: 'wasm_mvp;wasm_eh;wasm_threads;windows_amd64_rtools'
deploy_latest: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' }}
deploy_latest: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' }}
10 changes: 6 additions & 4 deletions src/include/statement_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,18 @@ class StatementGenerator {
unique_ptr<SQLStatement> GenerateStatement(StatementType type); // came from private

private:
unique_ptr<MultiStatement> GenerateAttachUse();
unique_ptr<SetStatement> GenerateSet();
unique_ptr<AttachStatement> GenerateAttach();
unique_ptr<CreateStatement> GenerateCreate();
unique_ptr<DeleteStatement> GenerateDelete();
unique_ptr<DetachStatement> GenerateDetach();
unique_ptr<MultiStatement> GenerateAttachUse();
unique_ptr<SelectStatement> GenerateSelect();
unique_ptr<CreateStatement> GenerateCreate();
unique_ptr<SetStatement> GenerateSet();

unique_ptr<QueryNode> GenerateQueryNode();

unique_ptr<CreateInfo> GenerateCreateInfo();
unique_ptr<AttachInfo> GenerateAttachInfo();
unique_ptr<CreateInfo> GenerateCreateInfo();
unique_ptr<DetachInfo> GenerateDetachInfo();

void GenerateCTEs(QueryNode &node);
Expand Down
25 changes: 25 additions & 0 deletions src/statement_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ unique_ptr<SQLStatement> StatementGenerator::GenerateStatement() {
if (RandomPercentage(30)) {
return GenerateStatement(StatementType::SET_STATEMENT);
}
if (RandomPercentage(40)) { //20
return GenerateStatement(StatementType::DELETE_STATEMENT);
}
return GenerateStatement(StatementType::CREATE_STATEMENT);
}

Expand All @@ -125,6 +128,8 @@ unique_ptr<SQLStatement> StatementGenerator::GenerateStatement(StatementType typ
// generate USE statement
case StatementType::SET_STATEMENT:
return GenerateSet();
case StatementType::DELETE_STATEMENT:
return GenerateDelete();
default:
throw InternalException("Unsupported type");
}
Expand Down Expand Up @@ -175,6 +180,26 @@ unique_ptr<MultiStatement> StatementGenerator::GenerateAttachUse() {
return multi_statement;
}

unique_ptr<DeleteStatement> StatementGenerator::GenerateDelete() {
auto delete_statement = make_uniq<DeleteStatement>();
auto state = GetDatabaseState(context);
if (!generator_context->tables_and_views.empty()) {
auto &entry_ref = Choose(generator_context->tables_and_views);
auto &entry = entry_ref.get();
if (entry.type == CatalogType::TABLE_ENTRY) {
auto result = make_uniq<BaseTableRef>();
result->table_name = entry.name;
delete_statement->table = std::move(result);
} else {
delete_statement->table = GenerateTableRef();
}
} else {
delete_statement->table = GenerateTableRef();
}

return delete_statement;
}

//===--------------------------------------------------------------------===//
// Generate Detach Info
//===--------------------------------------------------------------------===//
Expand Down
Loading