From 34fb8d57fe04abc0c6f09535d7816d5343ba26fd Mon Sep 17 00:00:00 2001 From: Mark Raasveldt Date: Thu, 19 Oct 2023 09:50:04 +0200 Subject: [PATCH] Adopt test from #59 --- src/include/sqlite_stmt.hpp | 3 +- src/sqlite_stmt.cpp | 3 +- src/storage/sqlite_table_entry.cpp | 3 +- test/sql/storage/attach_mixed_numeric.test | 33 ++++++++++++++++++++++ 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 test/sql/storage/attach_mixed_numeric.test diff --git a/src/include/sqlite_stmt.hpp b/src/include/sqlite_stmt.hpp index 74f26bc..abd92cd 100644 --- a/src/include/sqlite_stmt.hpp +++ b/src/include/sqlite_stmt.hpp @@ -45,7 +45,8 @@ class SQLiteStatement { int GetType(idx_t col); bool IsOpen(); void Close(); - void CheckTypeMatches(const SqliteBindData &bind_data, sqlite3_value *val, int sqlite_column_type, int expected_type, idx_t col_idx); + void CheckTypeMatches(const SqliteBindData &bind_data, sqlite3_value *val, int sqlite_column_type, + int expected_type, idx_t col_idx); void CheckTypeIsFloatOrInteger(sqlite3_value *val, int sqlite_column_type, idx_t col_idx); void Reset(); }; diff --git a/src/sqlite_stmt.cpp b/src/sqlite_stmt.cpp index f5640f2..158f2df 100644 --- a/src/sqlite_stmt.cpp +++ b/src/sqlite_stmt.cpp @@ -56,7 +56,8 @@ void SQLiteStatement::Close() { stmt = nullptr; } -void SQLiteStatement::CheckTypeMatches(const SqliteBindData &bind_data, sqlite3_value *val, int sqlite_column_type, int expected_type, idx_t col_idx) { +void SQLiteStatement::CheckTypeMatches(const SqliteBindData &bind_data, sqlite3_value *val, int sqlite_column_type, + int expected_type, idx_t col_idx) { D_ASSERT(stmt); if (bind_data.all_varchar) { // no type check required diff --git a/src/storage/sqlite_table_entry.cpp b/src/storage/sqlite_table_entry.cpp index c464b3b..9d83f00 100644 --- a/src/storage/sqlite_table_entry.cpp +++ b/src/storage/sqlite_table_entry.cpp @@ -7,7 +7,8 @@ namespace duckdb { -SQLiteTableEntry::SQLiteTableEntry(Catalog &catalog, SchemaCatalogEntry &schema, CreateTableInfo &info, bool all_varchar) +SQLiteTableEntry::SQLiteTableEntry(Catalog &catalog, SchemaCatalogEntry &schema, CreateTableInfo &info, + bool all_varchar) : TableCatalogEntry(catalog, schema, info), all_varchar(all_varchar) { } diff --git a/test/sql/storage/attach_mixed_numeric.test b/test/sql/storage/attach_mixed_numeric.test new file mode 100644 index 0000000..829806d --- /dev/null +++ b/test/sql/storage/attach_mixed_numeric.test @@ -0,0 +1,33 @@ +# name: test/sql/storage/attach_mixed_numeric.test +# description: +# group: [sqlite_storage] + +require sqlite_scanner + +# load from a database with a numeric column that has mixed types + +# using the all_varchar option, without the setting +statement ok +ATTACH 'data/db/mixed_data_numeric.db' as mydb (TYPE sqlite); + +statement error +select * from mydb.tbl; +---- +Invalid type in column "a" + +statement ok +DETACH mydb; + +statement ok +SET sqlite_all_varchar=true + +# using the setting, not the all_varchar option +statement ok +ATTACH 'data/db/mixed_data_numeric.db' as mydb (TYPE sqlite); + +query I +select * from mydb.tbl; +---- +42 +hello +NULL