duckdb 0.6.2-dev758.0 → 0.6.2-dev761.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 CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
4
  "types": "./lib/duckdb.d.ts",
5
- "version": "0.6.2-dev758.0",
5
+ "version": "0.6.2-dev761.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
@@ -1,8 +1,8 @@
1
1
  #ifndef DUCKDB_VERSION
2
- #define DUCKDB_VERSION "0.6.2-dev758"
2
+ #define DUCKDB_VERSION "0.6.2-dev761"
3
3
  #endif
4
4
  #ifndef DUCKDB_SOURCE_ID
5
- #define DUCKDB_SOURCE_ID "cd29769dcd"
5
+ #define DUCKDB_SOURCE_ID "a133a60550"
6
6
  #endif
7
7
  #include "duckdb/function/table/system_functions.hpp"
8
8
  #include "duckdb/main/database.hpp"
@@ -28,6 +28,8 @@ struct FileHandle;
28
28
  //! The version number of the database storage format
29
29
  extern const uint64_t VERSION_NUMBER;
30
30
 
31
+ const char *GetDuckDBVersion(idx_t version_number);
32
+
31
33
  using block_id_t = int64_t;
32
34
 
33
35
  #define INVALID_BLOCK (-1)
@@ -46,6 +46,29 @@ MainHeader MainHeader::Deserialize(Deserializer &source) {
46
46
  throw IOException("The file is not a valid DuckDB database file!");
47
47
  }
48
48
  header.version_number = source.Read<uint64_t>();
49
+ // check the version number
50
+ if (header.version_number != VERSION_NUMBER) {
51
+ auto version = GetDuckDBVersion(header.version_number);
52
+ string version_text;
53
+ if (version) {
54
+ // known version
55
+ version_text = "DuckDB version " + string(version);
56
+ } else {
57
+ version_text = string("an ") + (VERSION_NUMBER > header.version_number ? "older development" : "newer") +
58
+ string(" version of DuckDB");
59
+ }
60
+ throw IOException(
61
+ "Trying to read a database file with version number %lld, but we can only read version %lld.\n"
62
+ "The database file was created with %s.\n\n"
63
+ "The storage of DuckDB is not yet stable; newer versions of DuckDB cannot read old database files and "
64
+ "vice versa.\n"
65
+ "The storage will be stabilized when version 1.0 releases.\n\n"
66
+ "For now, we recommend that you load the database file in a supported version of DuckDB, and use the "
67
+ "EXPORT DATABASE command "
68
+ "followed by IMPORT DATABASE on the current version of DuckDB.\n\n"
69
+ "See the storage page for more information: https://duckdb.org/internals/storage",
70
+ header.version_number, VERSION_NUMBER, version_text);
71
+ }
49
72
  // read the flags
50
73
  FieldReader reader(source);
51
74
  for (idx_t i = 0; i < FLAG_COUNT; i++) {
@@ -150,20 +173,7 @@ SingleFileBlockManager::SingleFileBlockManager(DatabaseInstance &db, string path
150
173
  MainHeader::CheckMagicBytes(*handle);
151
174
  // otherwise, we check the metadata of the file
152
175
  header_buffer.ReadAndChecksum(*handle, 0);
153
- MainHeader header = DeserializeHeaderStructure<MainHeader>(header_buffer.buffer);
154
- // check the version number
155
- if (header.version_number != VERSION_NUMBER) {
156
- throw IOException(
157
- "Trying to read a database file with version number %lld, but we can only read version %lld.\n"
158
- "The database file was created with an %s version of DuckDB.\n\n"
159
- "The storage of DuckDB is not yet stable; newer versions of DuckDB cannot read old database files and "
160
- "vice versa.\n"
161
- "The storage will be stabilized when version 1.0 releases.\n\n"
162
- "For now, we recommend that you load the database file in a supported version of DuckDB, and use the "
163
- "EXPORT DATABASE command "
164
- "followed by IMPORT DATABASE on the current version of DuckDB.",
165
- header.version_number, VERSION_NUMBER, VERSION_NUMBER > header.version_number ? "older" : "newer");
166
- }
176
+ DeserializeHeaderStructure<MainHeader>(header_buffer.buffer);
167
177
 
168
178
  // read the database headers from disk
169
179
  DatabaseHeader h1, h2;
@@ -4,4 +4,35 @@ namespace duckdb {
4
4
 
5
5
  const uint64_t VERSION_NUMBER = 40;
6
6
 
7
+ struct StorageVersionInfo {
8
+ const char *version_name;
9
+ idx_t storage_version;
10
+ };
11
+
12
+ static StorageVersionInfo storage_version_info[] = {{"v0.6.0 or v0.6.1", 39},
13
+ {"v0.5.0 or v0.5.1", 38},
14
+ {"v0.3.3, v0.3.4 or v0.4.0", 33},
15
+ {"v0.3.2", 31},
16
+ {"v0.3.1", 27},
17
+ {"v0.3.0", 25},
18
+ {"v0.2.9", 21},
19
+ {"v0.2.8", 18},
20
+ {"v0.2.7", 17},
21
+ {"v0.2.6", 15},
22
+ {"v0.2.5", 13},
23
+ {"v0.2.4", 11},
24
+ {"v0.2.3", 6},
25
+ {"v0.2.2", 4},
26
+ {"v0.2.1 and prior", 1},
27
+ {nullptr, 0}};
28
+
29
+ const char *GetDuckDBVersion(idx_t version_number) {
30
+ for (idx_t i = 0; storage_version_info[i].version_name; i++) {
31
+ if (version_number == storage_version_info[i].storage_version) {
32
+ return storage_version_info[i].version_name;
33
+ }
34
+ }
35
+ return nullptr;
36
+ }
37
+
7
38
  } // namespace duckdb