diff --git a/src/storage/sqlite_transaction.cpp b/src/storage/sqlite_transaction.cpp index 058bf1c..9ab3a92 100644 --- a/src/storage/sqlite_transaction.cpp +++ b/src/storage/sqlite_transaction.cpp @@ -135,16 +135,15 @@ optional_ptr SQLiteTransaction::GetCatalogEntry(const string &entr string sql; db->GetViewInfo(entry_name, sql); - unique_ptr view_info; try { - view_info = CreateViewInfo::FromCreateView(*context.lock(), sql); + view_info = CreateViewInfo::FromCreateView(*context.lock(), sqlite_catalog.GetMainSchema(), sql); } catch(std::exception &ex) { auto view_sql = ExtractSelectStatement(sql); auto catalog_name = StringUtil::Replace(sqlite_catalog.GetName(), "\"", "\"\""); auto escaped_view_sql = StringUtil::Replace(view_sql, "'", "''"); auto view_def = StringUtil::Format("CREATE VIEW %s AS FROM sqlite_query(\"%s\", '%s')", entry_name, catalog_name, escaped_view_sql); - view_info = CreateViewInfo::FromCreateView(*context.lock(), view_def); + view_info = CreateViewInfo::FromCreateView(*context.lock(), sqlite_catalog.GetMainSchema(), view_def); } view_info->internal = false; result = make_uniq(sqlite_catalog, sqlite_catalog.GetMainSchema(), *view_info); diff --git a/test/sql/storage/attach_describe.test b/test/sql/storage/attach_describe.test index b92ebd6..0726a9e 100644 --- a/test/sql/storage/attach_describe.test +++ b/test/sql/storage/attach_describe.test @@ -16,6 +16,12 @@ DESCRIBE s1.test i BIGINT YES PRI NULL NULL j BIGINT YES NULL 42 NULL +query IIIIII +DESCRIBE TABLE s1.test +---- +i BIGINT YES PRI NULL NULL +j BIGINT YES NULL 42 NULL + query ITTTTT PRAGMA table_info('s1.test'); ---- diff --git a/test/sql/storage/attach_show_tables.test b/test/sql/storage/attach_show_tables.test new file mode 100644 index 0000000..7d78dd6 --- /dev/null +++ b/test/sql/storage/attach_show_tables.test @@ -0,0 +1,11 @@ +# name: test/sql/storage/attach_show_tables.test +# description: +# group: [sqlite_storage] + +require sqlite_scanner + +statement ok +ATTACH 'data/db/sakila.db' AS sakila (TYPE SQLITE, READ_ONLY) + +statement ok +SHOW TABLES