Skip to content

Commit

Permalink
Merge pull request #3834 from katzyn/version
Browse files Browse the repository at this point in the history
Increase database format version
  • Loading branch information
katzyn committed Jul 3, 2023
2 parents 581ed18 + 72f6e98 commit 4ac5343
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
4 changes: 4 additions & 0 deletions h2/src/docsrc/html/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ <h1>Change Log</h1>

<h2>Next Version (unreleased)</h2>
<ul>
<li>PR #3834: Increase database format version
</li>
<li>PR #3833: Disallow plain webAdminPassword values to force usage of hashes
</li>
<li>PR #3831: Add Oracle-style NOWAIT, WAIT n, and SKIP LOCKED to FOR UPDATE clause
</li>
<li>RP #3830: Fix time zone of time/timestamp with time zone AT LOCAL
Expand Down
8 changes: 4 additions & 4 deletions h2/src/main/org/h2/mvstore/FileStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ public abstract class FileStore<C extends Chunk<C>>
*/
static final int BLOCK_SIZE = 4 * 1024;

private static final int FORMAT_WRITE_MIN = 2;
private static final int FORMAT_WRITE_MAX = 2;
private static final int FORMAT_READ_MIN = 2;
private static final int FORMAT_READ_MAX = 2;
private static final int FORMAT_WRITE_MIN = 3;
private static final int FORMAT_WRITE_MAX = 3;
private static final int FORMAT_READ_MIN = 3;
private static final int FORMAT_READ_MAX = 3;

MVStore mvStore;
private boolean closed;
Expand Down
16 changes: 14 additions & 2 deletions h2/src/main/org/h2/tools/Upgrade.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ public final class Upgrade {
/* 1.4.198 */ "32dd6b149cb722aa4c2dd4d40a74a9cd41e32ac59a4e755a66e5753660d61d46",
/* 1.4.199 */ "3125a16743bc6b4cfbb61abba783203f1fb68230aa0fdc97898f796f99a5d42e",
/* 1.4.200 */ "3ad9ac4b6aae9cd9d3ac1c447465e1ed06019b851b893dd6a8d76ddb6d85bca6",
/* 2.0.202 */ "95090f0609aacb0ee339128ef04077145ef28320ee874ea2e33a692938da5b97",
/* 2.0.204 */ "712a616409580bd4ac7c10e48f2599cc32ba3a433a1804da619c3f0a5ef66a04",
/* 2.0.206 */ "3b9607c5673fd8b87e49e3ac46bd88fd3561e863dce673a35234e8b5708f3deb",
/* 2.0.208 */ null,
/* 2.1.210 */ "edc57299926297fd9315e04de75f8538c4cb5fe97fd3da2a1e5cee6a4c98b5cd",
/* 2.1.212 */ "db9284c6ff9bf3bc0087851edbd34563f1180df3ae87c67c5fe2203c0e67a536",
/* 2.1.214 */ "d623cdc0f61d218cf549a8d09f1c391ff91096116b22e2475475fce4fbe72bd0",
/* 2.1.216 */ null,
/* 2.1.218 */ null,
//
};

Expand Down Expand Up @@ -227,7 +236,9 @@ public static java.sql.Driver loadH2(int version) throws IOException, Reflective
if ((version & 1) != 0 || version > Constants.BUILD_ID) {
throw new IllegalArgumentException("version=" + version);
}
prefix = "2.0.";
int major = version / 100;
int minor = version / 10 % 10;
prefix = new StringBuilder().append(major).append('.').append(minor).append('.').toString();
} else if (version >= 177) {
prefix = "1.4.";
} else if (version >= 146 && version != 147) {
Expand All @@ -238,7 +249,8 @@ public static java.sql.Driver loadH2(int version) throws IOException, Reflective
throw new IllegalArgumentException("version=" + version);
}
String fullVersion = prefix + version;
byte[] data = downloadUsingMaven("com.h2database", "h2", fullVersion, CHECKSUMS[version - 120]);
byte[] data = downloadUsingMaven("com.h2database", "h2", fullVersion,
CHECKSUMS[version >= 202 ? (version >>> 1) - 20 : version - 120]);
ZipInputStream is = new ZipInputStream(new ByteArrayInputStream(data));
HashMap<String, byte[]> map = new HashMap<>(version >= 198 ? 2048 : 1024);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Expand Down
12 changes: 7 additions & 5 deletions h2/src/test/org/h2/test/store/TestMVStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
*/
public class TestMVStore extends TestBase {

private static final int CURRENT_FORMAT = 3;

/**
* Run just this test.
*
Expand Down Expand Up @@ -426,9 +428,9 @@ private void testNewerWriteVersion() {
open();
s.setRetentionTime(Integer.MAX_VALUE);
Map<String, Object> header = s.getStoreHeader();
assertEquals("2", header.get("format").toString());
header.put("formatRead", "2");
header.put("format", "3");
assertEquals(Integer.toString(CURRENT_FORMAT), header.get("format").toString());
header.put("formatRead", Integer.toString(CURRENT_FORMAT));
header.put("format", Integer.toString(CURRENT_FORMAT + 1));
forceWriteStoreHeader(s);
MVMap<Integer, String> m = s.openMap("data");
forceWriteStoreHeader(s);
Expand Down Expand Up @@ -727,7 +729,7 @@ private void testFileFormatChange() {
m.put(1, 1);
Map<String, Object> header = s.getStoreHeader();
int format = Integer.parseInt(header.get("format").toString());
assertEquals(2, format);
assertEquals(CURRENT_FORMAT, format);
header.put("format", Integer.toString(format + 1));
forceWriteStoreHeader(s);
}
Expand Down Expand Up @@ -849,7 +851,7 @@ private void testFileHeader() {
s.setRetentionTime(Integer.MAX_VALUE);
long time = System.currentTimeMillis();
Map<String, Object> m = s.getStoreHeader();
assertEquals("2", m.get("format").toString());
assertEquals(Integer.toString(CURRENT_FORMAT), m.get("format").toString());
long creationTime = (Long) m.get("created");
assertTrue(Math.abs(time - creationTime) < 100);
m.put("test", "123");
Expand Down

0 comments on commit 4ac5343

Please sign in to comment.