Skip to content

Commit 874d367

Browse files
committed
Add GraalVM Reachability Metadata and corresponding nativeTest for Firebird
1 parent 211337b commit 874d367

File tree

49 files changed

+1267
-459
lines changed

Some content is hidden

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

49 files changed

+1267
-459
lines changed

RELEASE-NOTES.md

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
1. Agent: Simplify the use of Agent's Docker Image - [#33356](https://github.com/apache/shardingsphere/pull/33356)
5656
1. Mode: Support modifying Hikari-CP configurations via props in standalone mode [#34185](https://github.com/apache/shardingsphere/pull/34185)
5757
1. Encrypt: Support insert statement rewrite use quote [#34259](https://github.com/apache/shardingsphere/pull/34259)
58+
1. Proxy Native: Add GraalVM Reachability Metadata and corresponding nativeTest for Firebird - [#34307](https://github.com/apache/shardingsphere/pull/34307)
5859

5960
### Bug Fixes
6061

docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.cn.md

+2
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ Args=--initialize-at-run-time=\
322322
io.grpc.netty.shaded.io.netty.util.AttributeKey
323323
```
324324

325+
ShardingSphere 的单元测试仅使用 Maven 模块 `io.github.linghengqian:hive-server2-jdbc-driver-thin` 来在 GraalVM Native Image 下验证可用性。
326+
325327
8. 由于 https://github.com/oracle/graal/issues/7979 的影响,
326328
对应 `com.oracle.database.jdbc:ojdbc8` Maven 模块的 Oracle JDBC Driver 无法在 GraalVM Native Image 下使用。
327329

docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.en.md

+2
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,8 @@ Args=--initialize-at-run-time=\
336336
io.grpc.netty.shaded.io.netty.util.AttributeKey
337337
```
338338

339+
ShardingSphere's unit test only uses the Maven module `io.github.linghengqian:hive-server2-jdbc-driver-thin` to verify the availability under GraalVM Native Image.
340+
339341
8. Due to https://github.com/oracle/graal/issues/7979 ,
340342
the Oracle JDBC Driver corresponding to the `com.oracle.database.jdbc:ojdbc8` Maven module cannot be used under GraalVM Native Image.
341343

docs/document/content/user-manual/shardingsphere-jdbc/unsupported/p6spy/_index.cn.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public class ExampleUtils {
143143
Statement statement = connection.createStatement()) {
144144
statement.execute("INSERT INTO t_order (user_id, order_type, address_id, status) VALUES (1, 1, 1, 'INSERT_TEST')");
145145
statement.executeQuery("SELECT * FROM t_order");
146-
statement.execute("alter table t_order delete where order_id=1");
146+
statement.execute("DELETE FROM t_order WHERE order_id=1");
147147
}
148148
}
149149
}

docs/document/content/user-manual/shardingsphere-jdbc/unsupported/p6spy/_index.en.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public class ExampleUtils {
145145
Statement statement = connection.createStatement()) {
146146
statement.execute("INSERT INTO t_order (user_id, order_type, address_id, status) VALUES (1, 1, 1, 'INSERT_TEST')");
147147
statement.executeQuery("SELECT * FROM t_order");
148-
statement.execute("alter table t_order delete where order_id=1");
148+
statement.execute("DELETE FROM t_order WHERE order_id=1");
149149
}
150150
}
151151
}

docs/document/content/user-manual/shardingsphere-proxy/optional-plugins/seata-at/_index.cn.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ sdk install java 23-open
4040
sdk use java 23-open
4141
sdk install maven 3.9.9
4242
sdk use maven 3.9.9
43-
mvn clean dependency:get -Dartifact=org.apache.seata:seata-all:2.2.0
43+
mvn dependency:get -Dartifact=org.apache.seata:seata-all:2.2.0
4444
mvn -f ~/.m2/repository/org/apache/seata/seata-all/2.2.0/seata-all-2.2.0.pom dependency:tree | grep -v ':provided' | grep -v ':runtime'
4545
```
4646

docs/document/content/user-manual/shardingsphere-proxy/optional-plugins/seata-at/_index.en.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ sdk install java 23-open
4141
sdk use java 23-open
4242
sdk install maven 3.9.9
4343
sdk use maven 3.9.9
44-
mvn clean dependency:get -Dartifact=org.apache.seata:seata-all:2.2.0
44+
mvn dependency:get -Dartifact=org.apache.seata:seata-all:2.2.0
4545
mvn -f ~/.m2/repository/org/apache/seata/seata-all/2.2.0/seata-all-2.2.0.pom dependency:tree | grep -v ':provided' | grep -v ':runtime'
4646
```
4747

infra/database/type/firebird/pom.xml

+7
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@
3333
<version>${project.version}</version>
3434
</dependency>
3535

36+
<dependency>
37+
<groupId>org.firebirdsql.jdbc</groupId>
38+
<artifactId>jaybird</artifactId>
39+
<scope>provided</scope>
40+
<optional>true</optional>
41+
</dependency>
42+
3643
<dependency>
3744
<groupId>org.apache.shardingsphere</groupId>
3845
<artifactId>shardingsphere-test-util</artifactId>

infra/database/type/firebird/src/main/java/org/apache/shardingsphere/infra/database/firebird/connector/FirebirdConnectionPropertiesParser.java

+15-6
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@
1717

1818
package org.apache.shardingsphere.infra.database.firebird.connector;
1919

20+
import lombok.SneakyThrows;
2021
import org.apache.shardingsphere.infra.database.core.connector.ConnectionProperties;
2122
import org.apache.shardingsphere.infra.database.core.connector.ConnectionPropertiesParser;
2223
import org.apache.shardingsphere.infra.database.core.connector.StandardConnectionProperties;
23-
import org.apache.shardingsphere.infra.database.core.connector.url.JdbcUrl;
24-
import org.apache.shardingsphere.infra.database.core.connector.url.StandardJdbcUrlParser;
24+
import org.firebirdsql.gds.impl.DbAttachInfo;
25+
import org.firebirdsql.gds.impl.GDSFactory;
26+
import org.firebirdsql.gds.impl.GDSType;
27+
import org.firebirdsql.jdbc.FBDriver;
2528

2629
import java.util.Properties;
2730

@@ -30,12 +33,18 @@
3033
*/
3134
public final class FirebirdConnectionPropertiesParser implements ConnectionPropertiesParser {
3235

33-
private static final int DEFAULT_PORT = 3050;
34-
36+
@SneakyThrows(Exception.class)
3537
@Override
3638
public ConnectionProperties parse(final String url, final String username, final String catalog) {
37-
JdbcUrl jdbcUrl = new StandardJdbcUrlParser().parse(url);
38-
return new StandardConnectionProperties(jdbcUrl.getHostname(), jdbcUrl.getPort(DEFAULT_PORT), jdbcUrl.getDatabase(), null, jdbcUrl.getQueryProperties(), new Properties());
39+
GDSType type = GDSFactory.getTypeForProtocol(url);
40+
String databaseURL = GDSFactory.getDatabasePath(type, url);
41+
DbAttachInfo dbAttachInfo = DbAttachInfo.parseConnectString(databaseURL);
42+
String attachObjectName = dbAttachInfo.getAttachObjectName();
43+
String databaseName = attachObjectName.contains("?") ? attachObjectName.split("\\?")[0] : attachObjectName;
44+
Properties queryProperties = new Properties();
45+
queryProperties.putAll(FBDriver.normalizeProperties(url, new Properties()));
46+
return new StandardConnectionProperties(dbAttachInfo.getServerName(), dbAttachInfo.getPortNumber(),
47+
databaseName, null, queryProperties, new Properties());
3948
}
4049

4150
@Override

infra/database/type/firebird/src/test/java/org/apache/shardingsphere/infra/database/firebird/connector/FirebirdConnectionPropertiesParserTest.java

+20-3
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,24 @@
1919

2020
import org.apache.shardingsphere.infra.database.core.connector.ConnectionProperties;
2121
import org.apache.shardingsphere.infra.database.core.connector.ConnectionPropertiesParser;
22-
import org.apache.shardingsphere.infra.database.core.exception.UnrecognizedDatabaseURLException;
2322
import org.apache.shardingsphere.infra.database.core.spi.DatabaseTypedSPILoader;
2423
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
2524
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
25+
import org.apache.shardingsphere.test.util.PropertiesBuilder;
2626
import org.junit.jupiter.api.Test;
2727
import org.junit.jupiter.api.extension.ExtensionContext;
2828
import org.junit.jupiter.params.ParameterizedTest;
2929
import org.junit.jupiter.params.provider.Arguments;
3030
import org.junit.jupiter.params.provider.ArgumentsProvider;
3131
import org.junit.jupiter.params.provider.ArgumentsSource;
3232

33+
import java.sql.SQLNonTransientConnectionException;
3334
import java.util.Properties;
3435
import java.util.stream.Stream;
3536

3637
import static org.hamcrest.CoreMatchers.is;
3738
import static org.hamcrest.MatcherAssert.assertThat;
39+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
3840
import static org.junit.jupiter.api.Assertions.assertThrows;
3941

4042
class FirebirdConnectionPropertiesParserTest {
@@ -54,14 +56,29 @@ void assertNewConstructor(final String name, final String url, final String host
5456

5557
@Test
5658
void assertNewConstructorFailure() {
57-
assertThrows(UnrecognizedDatabaseURLException.class, () -> parser.parse("jdbc:firebirdsql:xxxxxxxx", null, null));
59+
assertDoesNotThrow(() -> parser.parse("jdbc:firebirdsql:xxxxxxxx", null, null));
60+
assertThrows(SQLNonTransientConnectionException.class, () -> parser.parse("jdbc:firebirdsql://localhost:c:/data/db/test.fdb", null, null));
5861
}
5962

6063
private static class NewConstructorTestCaseArgumentsProvider implements ArgumentsProvider {
6164

6265
@Override
6366
public Stream<? extends Arguments> provideArguments(final ExtensionContext extensionContext) {
64-
return Stream.of(Arguments.of("simple", "jdbc:firebirdsql://127.0.0.1/foo_ds", "127.0.0.1", 3050, "foo_ds", null, new Properties()));
67+
return Stream.of(
68+
Arguments.of("simple_first", "jdbc:firebirdsql://127.0.0.1/foo_ds", "127.0.0.1", 3050, "foo_ds", null, new Properties()),
69+
Arguments.of("simple_second", "jdbc:firebird://localhost:32783//var/lib/firebird/data/demo_ds_2.fdb",
70+
"localhost", 32783, "/var/lib/firebird/data/demo_ds_2.fdb", null, new Properties()),
71+
Arguments.of("simple_third", "jdbc:firebirdsql://localhost/database?socket_buffer_size=32767", "localhost", 3050, "database", null, PropertiesBuilder.build(
72+
new PropertiesBuilder.Property("socketBufferSize", "32767"))),
73+
Arguments.of("complex",
74+
"jdbc:firebirdsql://localhost/database?socket_buffer_size=32767"
75+
+ "&TRANSACTION_REPEATABLE_READ=concurrency,write,no_wait&columnLabelForName&soTimeout=1000&nonStandard2=value2",
76+
"localhost", 3050, "database", null, PropertiesBuilder.build(
77+
new PropertiesBuilder.Property("socketBufferSize", "32767"),
78+
new PropertiesBuilder.Property("TRANSACTION_REPEATABLE_READ", "concurrency,write,no_wait"),
79+
new PropertiesBuilder.Property("columnLabelForName", ""),
80+
new PropertiesBuilder.Property("soTimeout", "1000"),
81+
new PropertiesBuilder.Property("nonStandard2", "value2"))));
6582
}
6683
}
6784
}

0 commit comments

Comments
 (0)