Skip to content

Commit 1b7c244

Browse files
authored
Merge pull request #112 from Mytherin/issue104
Fix #104: make CREATE OR REPLACE TABLE work in SQLite catalog instead of throwing an exception
2 parents d4a7917 + 9227865 commit 1b7c244

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/storage/sqlite_schema_entry.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ void SQLiteSchemaEntry::DropEntry(ClientContext &context, DropInfo &info) {
284284
}
285285
auto table = GetEntry(GetCatalogTransaction(context), info.type, info.name);
286286
if (!table) {
287+
if (info.if_not_found == OnEntryNotFound::RETURN_NULL) {
288+
return;
289+
}
287290
throw InternalException("Failed to drop entry \"%s\" - could not find entry", info.name);
288291
}
289292
auto &transaction = SQLiteTransaction::Get(context, catalog);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# name: test/sql/storage/attach_create_or_replace.test
2+
# description:
3+
# group: [sqlite_storage]
4+
5+
require sqlite_scanner
6+
7+
statement ok
8+
ATTACH '__TEST_DIR__/attach_unnest.sqlite' AS tmp (TYPE SQLITE);
9+
10+
statement ok
11+
USE tmp;
12+
13+
statement ok
14+
CREATE OR REPLACE TABLE xs AS SELECT unnest(['foo', 'bar', 'baz']) AS x;
15+
16+
query I
17+
SELECT * FROM xs;
18+
----
19+
foo
20+
bar
21+
baz

0 commit comments

Comments
 (0)