duckdb 0.8.1-dev341.0 → 0.8.1-dev355.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +0 -1
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/main/attached_database.hpp +4 -1
- package/src/duckdb/src/main/attached_database.cpp +8 -0
- package/src/duckdb/src/main/database.cpp +1 -0
- package/src/duckdb/src/main/database_manager.cpp +5 -0
- package/src/duckdb/src/storage/storage_manager.cpp +6 -0
package/package.json
CHANGED
@@ -14,7 +14,6 @@ namespace duckdb {
|
|
14
14
|
//===--------------------------------------------------------------------===//
|
15
15
|
// Source
|
16
16
|
//===--------------------------------------------------------------------===//
|
17
|
-
|
18
17
|
SourceResultType PhysicalAttach::GetData(ExecutionContext &context, DataChunk &chunk,
|
19
18
|
OperatorSourceInput &input) const {
|
20
19
|
// parse the options
|
@@ -1,8 +1,8 @@
|
|
1
1
|
#ifndef DUCKDB_VERSION
|
2
|
-
#define DUCKDB_VERSION "0.8.1-
|
2
|
+
#define DUCKDB_VERSION "0.8.1-dev355"
|
3
3
|
#endif
|
4
4
|
#ifndef DUCKDB_SOURCE_ID
|
5
|
-
#define DUCKDB_SOURCE_ID "
|
5
|
+
#define DUCKDB_SOURCE_ID "e9b683ce15"
|
6
6
|
#endif
|
7
7
|
#include "duckdb/function/table/system_functions.hpp"
|
8
8
|
#include "duckdb/main/database.hpp"
|
@@ -40,7 +40,7 @@ public:
|
|
40
40
|
//! Create an attached database instance with the specified storage extension
|
41
41
|
AttachedDatabase(DatabaseInstance &db, Catalog &catalog, StorageExtension &ext, string name, AttachInfo &info,
|
42
42
|
AccessMode access_mode);
|
43
|
-
~AttachedDatabase();
|
43
|
+
~AttachedDatabase() override;
|
44
44
|
|
45
45
|
void Initialize();
|
46
46
|
|
@@ -57,6 +57,8 @@ public:
|
|
57
57
|
bool IsSystem() const;
|
58
58
|
bool IsTemporary() const;
|
59
59
|
bool IsReadOnly() const;
|
60
|
+
bool IsInitialDatabase() const;
|
61
|
+
void SetInitialDatabase();
|
60
62
|
|
61
63
|
static string ExtractDatabaseName(const string &dbpath);
|
62
64
|
|
@@ -67,6 +69,7 @@ private:
|
|
67
69
|
unique_ptr<TransactionManager> transaction_manager;
|
68
70
|
AttachedDatabaseType type;
|
69
71
|
optional_ptr<Catalog> parent_catalog;
|
72
|
+
bool is_initial_database = false;
|
70
73
|
};
|
71
74
|
|
72
75
|
} // namespace duckdb
|
@@ -124,4 +124,12 @@ Catalog &AttachedDatabase::ParentCatalog() {
|
|
124
124
|
return *parent_catalog;
|
125
125
|
}
|
126
126
|
|
127
|
+
bool AttachedDatabase::IsInitialDatabase() const {
|
128
|
+
return is_initial_database;
|
129
|
+
}
|
130
|
+
|
131
|
+
void AttachedDatabase::SetInitialDatabase() {
|
132
|
+
is_initial_database = true;
|
133
|
+
}
|
134
|
+
|
127
135
|
} // namespace duckdb
|
@@ -43,6 +43,11 @@ void DatabaseManager::AddDatabase(ClientContext &context, unique_ptr<AttachedDat
|
|
43
43
|
}
|
44
44
|
|
45
45
|
void DatabaseManager::DetachDatabase(ClientContext &context, const string &name, OnEntryNotFound if_not_found) {
|
46
|
+
if (GetDefaultDatabase(context) == name) {
|
47
|
+
throw BinderException("Cannot detach database \"%s\" because it is the default database. Select a different "
|
48
|
+
"database using `USE` to allow detaching this database",
|
49
|
+
name);
|
50
|
+
}
|
46
51
|
if (!databases->DropEntry(context, name, false, true)) {
|
47
52
|
if (if_not_found == OnEntryNotFound::THROW_EXCEPTION) {
|
48
53
|
throw BinderException("Failed to detach database with name \"%s\": database not found", name);
|
@@ -12,6 +12,7 @@
|
|
12
12
|
#include "duckdb/transaction/transaction_manager.hpp"
|
13
13
|
#include "duckdb/common/serializer/buffered_file_reader.hpp"
|
14
14
|
#include "duckdb/main/attached_database.hpp"
|
15
|
+
#include "duckdb/main/database_manager.hpp"
|
15
16
|
|
16
17
|
namespace duckdb {
|
17
18
|
|
@@ -98,6 +99,11 @@ void SingleFileStorageManager::LoadDatabase() {
|
|
98
99
|
auto &fs = FileSystem::Get(db);
|
99
100
|
auto &config = DBConfig::Get(db);
|
100
101
|
bool truncate_wal = false;
|
102
|
+
if (!config.options.enable_external_access) {
|
103
|
+
if (!db.IsInitialDatabase()) {
|
104
|
+
throw PermissionException("Attaching on-disk databases is disabled through configuration");
|
105
|
+
}
|
106
|
+
}
|
101
107
|
|
102
108
|
StorageManagerOptions options;
|
103
109
|
options.read_only = read_only;
|