Skip to content

Commit

Permalink
Fix for CREATE OR REPLACE VIEW/DROP VIEW IF EXISTS
Browse files Browse the repository at this point in the history
  • Loading branch information
Mytherin committed Sep 16, 2024
1 parent ee018fc commit 5e30a17
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/storage/sqlite_schema_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ void SQLiteSchemaEntry::DropEntry(ClientContext &context, DropInfo &info) {
}
auto table = GetEntry(GetCatalogTransaction(context), info.type, info.name);
if (!table) {
if (info.if_not_found == OnEntryNotFound::RETURN_NULL) {
return;
}
throw InternalException("Failed to drop entry \"%s\" - could not find entry", info.name);
}
auto &transaction = SQLiteTransaction::Get(context, catalog);
Expand Down
22 changes: 22 additions & 0 deletions test/sql/storage/attach_create_if_exists.test
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,25 @@ CREATE OR REPLACE TABLE s1.test(j INTEGER);
statement ok
SELECT j FROM s1.test

# create or replace view
statement ok
CREATE OR REPLACE VIEW s1.test_view AS SELECT 42

statement ok
CREATE OR REPLACE VIEW s1.test_view AS SELECT 84

query I
SELECT * FROM s1.test_view
----
84

statement ok
DROP VIEW IF EXISTS s1.test_view

statement ok
DROP VIEW IF EXISTS s1.test_view

statement error
SELECT * FROM s1.test_view
----
test_view does not exist

0 comments on commit 5e30a17

Please sign in to comment.