Skip to content

Commit 1d9d0f5

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 0fd83a5 + 2241b38 commit 1d9d0f5

60 files changed

Lines changed: 713 additions & 276 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

h2/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<lucene.version>9.7.0</lucene.version>
4545
<osgi.version>5.0.0</osgi.version>
4646
<osgi.jdbc.version>1.1.0</osgi.jdbc.version>
47-
<pgjdbc.version>42.5.4</pgjdbc.version>
47+
<pgjdbc.version>42.7.2</pgjdbc.version>
4848
<javax.servlet.version>4.0.1</javax.servlet.version>
4949
<jakarta.servlet.version>5.0.0</jakarta.servlet.version>
5050
<slf4j.version>2.0.7</slf4j.version>

h2/src/docsrc/html/changelog.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,23 @@ <h1>Change Log</h1>
2121

2222
<h2>Next Version (unreleased)</h2>
2323
<ul>
24+
<li>Issue #701: An available index is never used for ordering, when the requested order is DESC
25+
</li>
26+
<li>Issue #4036: NULLS NOT DISTINCT constraint changed after column dropped
27+
</li>
28+
<li>Issue #4033: Wrong array produced when using ARRAY_AGG() on UNNEST(ARRAY[CAST(? AS INT)]) expression
29+
in a PreparedStatement
30+
</li>
31+
<li>Issue #3909: Maintenance taking too much resources since 2.2.222
32+
</li>
33+
<li>Issue #4010: org.h2.jdbc.JdbcConnection.getTypeMap() returns null
34+
</li>
35+
<li>PR #4007: Update pom.xml related to CVE-2024-1597
36+
</li>
37+
<li>Issue #3907: MvStoreTool unable to Repair() or Rollback() [2.1.214]
38+
</li>
39+
<li>RP #3997: Server-side batch execution for prepared statements
40+
</li>
2441
<li>Issue #3106: Trailing commas in SELECT are accepted by the parser
2542
</li>
2643
<li>PR #3992: Add IPv6 support to H2 Console

h2/src/docsrc/html/performance.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,17 @@ <h3>Special Optimizations</h3>
732732
</p><p>
733733
For queries of the form <code>SELECT * FROM TEST ORDER BY ID</code>, the query plan includes the line
734734
<code>/* index sorted */</code> to indicate there is no separate sorting required.
735+
<code>/* index sorted: 2 of 3 columns */</code> indicates that only some columns are sorted with an index.
736+
An additional sorting is still required, but queries with the FETCH (TOP, LIMIT) clause
737+
may still stop their execution earlier.
738+
An index on <code>(A ASC, B ASC)</code> columns can be used for <code>ORDER BY A</code>, <code>ORDER BY A DESC</code>,
739+
<code>ORDER BY A, B</code> or <code>ORDER BY A DESC, B DESC</code>.
740+
With <code>ORDER BY A, B DESC</code> this index can only be used for ordering on the column <code>A</code>.
741+
If columns are nullable, order of nulls is also important. Index on <code>(A ASC NULLS FIRST)</code> cannot be used for
742+
<code>ORDER BY A ASC NULLS LAST</code>, but can be used for <code>ORDER BY A ASC NULLS FIRST</code> or
743+
<code>ORDER BY A DESC NULLS LAST</code>.
744+
When neither <code>NULLS FIRST</code> nor <code>NULLS LAST</code> is specified, a default is used, this default
745+
is controlled by <a href="commands.html#set_default_null_ordering"><code>DEFAULT_NULL_ORDERING</code></a> setting.
735746
</p><p>
736747
For queries of the form <code>SELECT * FROM TEST GROUP BY ID ORDER BY ID</code>, the query plan includes the line
737748
<code>/* group sorted */</code> to indicate there is no separate sorting required.

h2/src/main/org/h2/bnf/context/DbContextRule.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ public boolean autoComplete(Sentence sentence) {
8989
best = quotedName;
9090
bestSchema = schema;
9191
}
92-
} else if (s.isEmpty() || StringUtils.startsWithIgnoringCase(name, query) || StringUtils.startsWithIgnoringCase(quotedName, query)) {
92+
} else if (s.isEmpty() || StringUtils.startsWithIgnoringCase(name, query)
93+
|| StringUtils.startsWithIgnoringCase(quotedName, query)) {
9394
if (s.length() < name.length()) {
9495
sentence.add(name, name.substring(s.length()), type);
9596
sentence.add(schema.quotedName + ".",
@@ -116,12 +117,14 @@ public boolean autoComplete(Sentence sentence) {
116117
String name = table.getName();
117118
String quotedName = StringUtils.quoteIdentifier(name);
118119

119-
if (StringUtils.startsWithIgnoringCase(query, name) || StringUtils.startsWithIgnoringCase("\"" + query, quotedName)) {
120+
if (StringUtils.startsWithIgnoringCase(query, name)
121+
|| StringUtils.startsWithIgnoringCase("\"" + query, quotedName)) {
120122
if (best == null || name.length() > best.length()) {
121123
best = name;
122124
bestTable = table;
123125
}
124-
} else if (s.isEmpty() || StringUtils.startsWithIgnoringCase(name, query) || StringUtils.startsWithIgnoringCase(quotedName, query)) {
126+
} else if (s.isEmpty() || StringUtils.startsWithIgnoringCase(name, query)
127+
|| StringUtils.startsWithIgnoringCase(quotedName, query)) {
125128
if (s.length() < name.length()) {
126129
sentence.add(table.getQuotedName(),
127130
table.getQuotedName().substring(s.length()),

h2/src/main/org/h2/command/CommandContainer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public CommandContainer(SessionLocal session, String sql, Prepared prepared) {
8888
@Override
8989
public ArrayList<? extends ParameterInterface> getParameters() {
9090
ArrayList<Parameter> parameters = prepared.getParameters();
91-
if (parameters.size() > 0 && prepared.isWithParamValues()) {
91+
if (!parameters.isEmpty() && prepared.isWithParamValues()) {
9292
parameters = new ArrayList<>();
9393
}
9494
return parameters;

h2/src/main/org/h2/command/CommandList.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class CommandList extends Command {
2222

23-
private CommandContainer command;
23+
private final CommandContainer command;
2424
private final ArrayList<Prepared> commands;
2525
private final ArrayList<Parameter> parameters;
2626
private String remaining;
@@ -42,20 +42,21 @@ public ArrayList<? extends ParameterInterface> getParameters() {
4242

4343
private void executeRemaining() {
4444
for (Prepared prepared : commands) {
45+
CommandContainer commandContainer = new CommandContainer(session, prepared.getSQL(), prepared);
4546
prepared.prepare();
4647
if (prepared.isQuery()) {
47-
prepared.query(0);
48+
executeQuery(0, false);
4849
} else {
49-
prepared.update();
50+
commandContainer.executeUpdate(null);
5051
}
5152
}
5253
if (remaining != null) {
5354
remainingCommand = session.prepareLocal(remaining);
5455
remaining = null;
5556
if (remainingCommand.isQuery()) {
56-
remainingCommand.query(0);
57+
remainingCommand.executeQuery(0, false);
5758
} else {
58-
remainingCommand.update(null);
59+
remainingCommand.executeUpdate(null);
5960
}
6061
}
6162
}

h2/src/main/org/h2/command/CommandRemote.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ public BatchResult executeBatchUpdate(ArrayList<Value[]> batchParameters, Object
286286
}
287287
if (readGeneratedKeys) {
288288
int columnCount = transfer.readInt();
289-
ResultRemote remoteGeneratedKeys = new ResultRemote(session, transfer, objectId, columnCount, Integer.MAX_VALUE);
289+
ResultRemote remoteGeneratedKeys = new ResultRemote(session, transfer, objectId,
290+
columnCount, Integer.MAX_VALUE);
290291
generatedKeys.add(remoteGeneratedKeys);
291292
remoteGeneratedKeys.close();
292293
}
@@ -310,7 +311,8 @@ public BatchResult executeBatchUpdate(ArrayList<Value[]> batchParameters, Object
310311
autoCommit = transfer.readBoolean();
311312
if (readGeneratedKeys) {
312313
int columnCount = transfer.readInt();
313-
ResultRemote remoteGeneratedKeys = new ResultRemote(session, transfer, objectId, columnCount, Integer.MAX_VALUE);
314+
ResultRemote remoteGeneratedKeys = new ResultRemote(session, transfer, objectId,
315+
columnCount, Integer.MAX_VALUE);
314316
generatedKeys.add(remoteGeneratedKeys);
315317
remoteGeneratedKeys.close();
316318
}

h2/src/main/org/h2/command/Parser.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4414,12 +4414,8 @@ private ArrayTableFunction readUnnestFunction() {
44144414
do {
44154415
Expression expr = readExpression();
44164416
TypeInfo columnType = TypeInfo.TYPE_NULL;
4417-
boolean constant = expr.isConstant();
4418-
if (constant || expr instanceof CastSpecification) {
4419-
if (constant) {
4420-
expr = expr.optimize(session);
4421-
}
4422-
TypeInfo exprType = expr.getType();
4417+
TypeInfo exprType = expr.getTypeIfStaticallyKnown(session);
4418+
if (exprType != null) {
44234419
switch (exprType.getValueType()) {
44244420
case Value.JSON:
44254421
columnType = TypeInfo.TYPE_JSON;

h2/src/main/org/h2/command/ddl/Analyze.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public static void analyzeTable(SessionLocal session, Table table, int sample, b
187187
if (columnCount == 0) {
188188
return;
189189
}
190-
Cursor cursor = table.getScanIndex(session).find(session, null, null);
190+
Cursor cursor = table.getScanIndex(session).find(session, null, null, false);
191191
if (cursor.next()) {
192192
SelectivityData[] array = new SelectivityData[columnCount];
193193
for (int i = 0; i < columnCount; i++) {

h2/src/main/org/h2/command/dml/ScriptCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ private static <T extends DbObject> T[] sorted(Collection<T> collection, Class<T
474474
private int generateInsertValues(int count, Table table) throws IOException {
475475
PlanItem plan = table.getBestPlanItem(session, null, null, -1, null, null);
476476
Index index = plan.getIndex();
477-
Cursor cursor = index.find(session, null, null);
477+
Cursor cursor = index.find(session, null, null, false);
478478
Column[] columns = table.getColumns();
479479
boolean withGenerated = false, withGeneratedAlwaysAsIdentity = false;
480480
for (Column c : columns) {

0 commit comments

Comments
 (0)