Skip to content

Commit

Permalink
Merge pull request #3760 from katzyn/compatibility
Browse files Browse the repository at this point in the history
Restore START sequence option in PostgreSQL mode and improve documentation of MSSQLServer mode
  • Loading branch information
katzyn committed Mar 19, 2023
2 parents 2113b32 + 5a9755a commit 9ef778d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
4 changes: 4 additions & 0 deletions h2/src/docsrc/html/changelog.html
Expand Up @@ -21,6 +21,10 @@ <h1>Change Log</h1>

<h2>Next Version (unreleased)</h2>
<ul>
<li>Issue #3642: AssertionError in mvstore.FileStore.serializeAndStore
</li>
<li>Issue #3675: H2 2.x cannot read PostgreSQL-style sequence generator start with option without WITH keyword
</li>
<li>Issue #3757: FORMATDATETIME function doesn't handle time with time zone properly
</li>
<li>PR #3756: Limit the row list allocation based on the row count
Expand Down
5 changes: 3 additions & 2 deletions h2/src/docsrc/html/features.html
Expand Up @@ -936,8 +936,9 @@ <h3>HSQLDB Compatibility Mode</h3>

<h3>MS SQL Server Compatibility Mode</h3>
<p>
To use the MS SQL Server mode, use the database URL <code>jdbc:h2:~/test;MODE=MSSQLServer</code>
or the SQL statement <code>SET MODE MSSQLServer</code>.
To use the MS SQL Server mode, use the database URL
<code>jdbc:h2:~/test;MODE=MSSQLServer;DATABASE_TO_UPPER=FALSE;CASE_INSENSITIVE_IDENTIFIERS=TRUE</code>.
Do not change value of DATABASE_TO_LOWER and CASE_INSENSITIVE_IDENTIFIERS after creation of database.
</p>
<ul><li>For aliased columns, <code>ResultSetMetaData.getColumnName()</code>
returns the alias name and <code>getTableName()</code> returns
Expand Down
3 changes: 2 additions & 1 deletion h2/src/main/org/h2/command/Parser.java
Expand Up @@ -7874,7 +7874,8 @@ private boolean parseSequenceOptions(SequenceOptions options, CreateSequence com
.getSQL(new StringBuilder("CREATE SEQUENCE AS "), HasSQL.TRACE_SQL_FLAGS).toString());
}
options.setDataType(dataType);
} else if (readIf("START", WITH)) {
} else if (readIf("START", WITH)
|| (database.getMode().getEnum() == ModeEnum.PostgreSQL && readIf("START"))) {
options.setStartValue(readExpression());
} else if (readIf("RESTART")) {
options.setRestartValue(readIf(WITH) ? readExpression() : ValueExpression.DEFAULT);
Expand Down
15 changes: 11 additions & 4 deletions h2/src/main/org/h2/mvstore/FileStore.java
Expand Up @@ -1414,10 +1414,17 @@ private void serializeAndStore(boolean syncRun, ArrayList<Page<?,?>> changed, lo
// never go backward in time
time = Math.max(lastChunk.time, time);
}
C c = createChunk(time, version);
WriteBuffer buff = getWriteBuffer();
serializeToBuffer(buff, changed, c, lastChunk);
chunks.put(c.id, c);
C c;
WriteBuffer buff;
try {
c = createChunk(time, version);
buff = getWriteBuffer();
serializeToBuffer(buff, changed, c, lastChunk);
chunks.put(c.id, c);
} catch (Throwable t) {
lastChunkId = chunkId;
throw t;
}

bufferSaveExecutorHWM = submitOrRun(bufferSaveExecutor, () -> storeBuffer(c, buff),
syncRun, 5, bufferSaveExecutorHWM);
Expand Down
15 changes: 15 additions & 0 deletions h2/src/test/org/h2/test/scripts/other/sequence.sql
Expand Up @@ -488,3 +488,18 @@ SELECT NEXT VALUE FOR SEQ;

DROP SEQUENCE SEQ;
> ok

CREATE SEQUENCE SEQ START 1;
> exception SYNTAX_ERROR_1

SET MODE PostgreSQL;
> ok

CREATE SEQUENCE SEQ START 1;
> ok

DROP SEQUENCE SEQ;
> ok

SET MODE Regular;
> ok

0 comments on commit 9ef778d

Please sign in to comment.