Skip to content

Commit a9515ae

Browse files
committed
Merge branch 'main' into fix_statement_impl
2 parents d4d8613 + d4792b7 commit a9515ae

File tree

61 files changed

+3291
-934
lines changed

Some content is hidden

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

61 files changed

+3291
-934
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,26 @@ assignees: ''
77

88
---
99
<!--
10-
possible labels: bug,client-api-v2,jdbc-v2
10+
High Level Area Labels:
11+
- client-api-v2
12+
- client-v1
13+
- jdbc-v2
14+
15+
Specific Area Labels:
16+
- packaging
17+
- sql-parser
18+
- data-type
19+
- docs
20+
- network
21+
- performance
22+
- jdbc-metadata
23+
- jdbc-insert
24+
- jdbc-read
25+
- client-insert
26+
- client-read
27+
- client-pojo-serde
28+
- format
29+
1130
-->
1231
## Description
1332

.github/workflows/analysis.yml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ on:
2929

3030
env:
3131
PREFERRED_LTS_VERSION: "24.3"
32+
PR_NUMBER: ${{ github.event.pull_request.number || '' }}
3233

3334
jobs:
3435
sonarcloud:
@@ -85,32 +86,30 @@ jobs:
8586
restore-keys: ${{ runner.os }}-sonar
8687
- name: Update sonar config
8788
run: |
88-
sed -i -e 's|^\(.*<sonar.projectKey>\).*\(</sonar.projectKey>\)$|\1ClickHouse_clickhouse-jdbc\2|' \
89+
sed -i -e 's|^\(.*<sonar.projectKey>\).*\(</sonar.projectKey>\)$|\1ClickHouse_clickhouse-java\2|' \
8990
-e 's|^\(.*<sonar.organization>\).*\(</sonar.organization>\)$|\1clickhouse-java\2|' pom.xml
9091
if: github.repository_owner == 'ClickHouse'
9192
- name: Build and install
9293
run: |
9394
find . -type f -name "simplelogger.*" -exec rm -fv '{}' \;
94-
mvn -q --batch-mode -DclickhouseVersion=$PREFERRED_LTS_VERSION \
95+
mvn -q --no-transfer-progress --batch-mode -DclickhouseVersion=$PREFERRED_LTS_VERSION \
9596
-DskipTests install
9697
- name: Analyze
9798
env:
9899
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
99100
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
100101
run: |
101-
mvn --batch-mode -DclickhouseVersion=$PREFERRED_LTS_VERSION \
102-
-Panalysis verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
103-
pwd
104-
ls -l ./client-v2/target/site/jacoco-aggregate/jacoco.xml
102+
mvn -fn --no-transfer-progress --batch-mode -DclickhouseVersion=$PREFERRED_LTS_VERSION \
103+
-Panalysis verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=ClickHouse_clickhouse-java
105104
continue-on-error: true
106105
- name: Generate and post coverage report
107106
env:
108107
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109108
run: |
110-
pwd
111-
ls -la
112-
node jacoco-report-generator.mjs ./client-v2/target/site/jacoco-aggregate/jacoco.csv client-v2-cov.md --pr ${{ github.event.pull_request.number }} --title "Client V2 Coverage"
113-
node jacoco-report-generator.mjs ./jdbc-v2/target/site/jacoco-aggregate/jacoco.csv jdbc-v2-cov.md --pr ${{ github.event.pull_request.number }} --title "JDBC V2 Coverage"
114-
node jacoco-report-generator.mjs ./clickhouse-jdbc/target/site/jacoco-aggregate/jacoco.csv jdbc-v1-cov.md --pr ${{ github.event.pull_request.number }} --title "JDBC V1 Coverage"
115-
node jacoco-report-generator.mjs ./clickhouse-client/target/site/jacoco-aggregate/jacoco.csv client-v1-cov.md --pr ${{ github.event.pull_request.number }} --title "Client V1 Coverage"
116-
cat *-cov.md
109+
PR_ARG=''
110+
if [ ! -z $PR_NUMBER ]; then PR_ARG="--pr $PR_NUMBER"; fi;
111+
node jacoco-report-generator.mjs ./client-v2/target/site/jacoco-aggregate/jacoco.csv client-v2-cov.md --title "Client V2 Coverage" ${PR_ARG}
112+
node jacoco-report-generator.mjs ./jdbc-v2/target/site/jacoco-aggregate/jacoco.csv jdbc-v2-cov.md --title "JDBC V2 Coverage" ${PR_ARG}
113+
node jacoco-report-generator.mjs ./clickhouse-jdbc/target/site/jacoco-aggregate/jacoco.csv jdbc-v1-cov.md --title "JDBC V1 Coverage" ${PR_ARG}
114+
node jacoco-report-generator.mjs ./clickhouse-client/target/site/jacoco-aggregate/jacoco.csv client-v1-cov.md --title "Client V1 Coverage" ${PR_ARG}
115+
cat *-cov.md

.github/workflows/nightly.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212

1313
env:
1414
CHC_BRANCH: "main"
15-
CHC_VERSION: "0.8.6"
15+
# CHC_VERSION: "0.9.0"
1616
CH_VERSION: "24.8"
1717

1818
jobs:
@@ -59,15 +59,16 @@ jobs:
5959
EOF
6060
- name: Update Configuration
6161
run: |
62-
find . -type f -name "pom.xml" -exec sed -i -e 's|${revision}|${{ env.CHC_VERSION }}-SNAPSHOT|g' \
63-
-e 's|^\( <version>\).*\(</version>\)$|\1${{ env.CHC_VERSION }}-SNAPSHOT\2|' \
64-
-e 's|${parent.groupId}|com.clickhouse|g' -e 's|${project.parent.groupId}|com.clickhouse|g' '{}' \;
62+
# find . -type f -name "pom.xml" -exec sed -i -e 's|${revision}|${{ env.CHC_VERSION }}-SNAPSHOT|g' \
63+
# -e 's|^\( <version>\).*\(</version>\)$|\1${{ env.CHC_VERSION }}-SNAPSHOT\2|' \
64+
# -e 's|${parent.groupId}|com.clickhouse|g' -e 's|${project.parent.groupId}|com.clickhouse|g' '{}' \;
6565
find . -type f -name "simplelogger.*" -exec rm -fv '{}' \;
6666
- name: Release Snapshot
6767
uses: samuelmeuli/action-maven-publish@v1
6868
with:
6969
maven_profiles: release
7070
maven_args: -q --batch-mode -DclickhouseVersion=${{ env.CH_VERSION }}
71+
server_id: central
7172
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
7273
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
7374
nexus_username: ${{ secrets.SONATYPE_TOKEN_USER }}
@@ -78,6 +79,7 @@ jobs:
7879
directory: clickhouse-r2dbc
7980
maven_profiles: release
8081
maven_args: -q --batch-mode -Dr2dbc-spi.version=0.9.1.RELEASE -DclickhouseVersion=${{ env.CH_VERSION }}
82+
server_id: central
8183
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
8284
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
8385
nexus_username: ${{ secrets.SONATYPE_TOKEN_USER }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ java.prof
4848
jmh-result.*
4949
profile.html
5050
jdbc-v2/gen
51+
jdbc-v2/src/main/antlr4/com/clickhouse/jdbc/internal/gen
52+
jdbc-v2/src/main/antlr4/com/clickhouse/jdbc/internal/ClickHouseLexer.tokens
5153

5254
# Shell scripts
5355
*.sh

clickhouse-client/src/main/java/com/clickhouse/client/config/ClickHouseClientOption.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,14 @@ public enum ClickHouseClientOption implements ClickHouseOption {
451451
*/
452452
CONNECTION_TTL("connection_ttl", 0L,
453453
"Connection time to live in milliseconds. 0 or negative number means no limit."),
454-
MEASURE_REQUEST_TIME("debug_measure_request_time", false, "Whether to measure request time. If true, the time will be logged in debug mode.");
454+
MEASURE_REQUEST_TIME("debug_measure_request_time", false, "Whether to measure request time. If true, the time will be logged in debug mode."),
455+
456+
/**
457+
* SNI SSL parameter that will be set for each outbound SSL socket.
458+
*/
459+
SSL_SOCKET_SNI("ssl_socket_sni", "", " SNI SSL parameter that will be set for each outbound SSL socket.")
460+
461+
;
455462

456463
private final String key;
457464
private final Serializable defaultValue;

clickhouse-client/src/test/java/com/clickhouse/client/ClickHouseServerForTest.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -370,13 +370,6 @@ public static String getDatabase() {
370370

371371
public static boolean runQuery(String sql) {
372372
LOGGER.info("runQuery: (\"" + sql + "\")");
373-
374-
try {
375-
throw new Exception("test");
376-
} catch (Exception e) {
377-
e.printStackTrace();
378-
}
379-
380373
if (clickhouseContainer != null) {
381374
try {
382375
Container.ExecResult res = clickhouseContainer.execInContainer("clickhouse-client",

clickhouse-http-client/src/main/java/com/clickhouse/client/http/ApacheHttpConnectionImpl.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.clickhouse.client.config.ClickHouseProxyType;
1212
import com.clickhouse.client.config.ClickHouseSslMode;
1313
import com.clickhouse.client.http.config.ClickHouseHttpOption;
14+
import com.clickhouse.config.ClickHouseOption;
1415
import com.clickhouse.data.ClickHouseChecker;
1516
import com.clickhouse.data.ClickHouseExternalTable;
1617
import com.clickhouse.data.ClickHouseFormat;
@@ -54,8 +55,11 @@
5455
import org.apache.hc.core5.util.Timeout;
5556
import org.apache.hc.core5.util.VersionInfo;
5657

58+
import javax.net.ssl.SNIHostName;
5759
import javax.net.ssl.SSLContext;
5860
import javax.net.ssl.SSLException;
61+
import javax.net.ssl.SSLParameters;
62+
import javax.net.ssl.SSLSocket;
5963
import java.io.BufferedReader;
6064
import java.io.ByteArrayInputStream;
6165
import java.io.ByteArrayOutputStream;
@@ -66,10 +70,9 @@
6670
import java.io.UncheckedIOException;
6771
import java.net.ConnectException;
6872
import java.net.HttpURLConnection;
73+
import java.net.InetAddress;
6974
import java.net.InetSocketAddress;
7075
import java.net.Socket;
71-
import java.net.SocketOption;
72-
import java.net.SocketOptions;
7376
import java.nio.charset.StandardCharsets;
7477
import java.util.Collections;
7578
import java.util.List;
@@ -394,6 +397,7 @@ public static SocketFactory create(ClickHouseConfig config) {
394397

395398
static class SSLSocketFactory extends SSLConnectionSocketFactory {
396399
private final ClickHouseConfig config;
400+
private final SNIHostName defaultSNI;
397401

398402
private SSLSocketFactory(ClickHouseConfig config) throws SSLException {
399403
super(ClickHouseSslContextProvider.getProvider().getSslContext(SSLContext.class, config)
@@ -402,13 +406,25 @@ private SSLSocketFactory(ClickHouseConfig config) throws SSLException {
402406
? new DefaultHostnameVerifier()
403407
: (hostname, session) -> true); // NOSONAR
404408
this.config = config;
409+
String sni = config.getStrOption(ClickHouseClientOption.SSL_SOCKET_SNI);
410+
defaultSNI = sni == null || sni.trim().isEmpty() ? null : new SNIHostName(sni);
405411
}
406412

407413
@Override
408414
public Socket createSocket(HttpContext context) throws IOException {
409415
return AbstractSocketClient.setSocketOptions(config, new Socket());
410416
}
411417

418+
@Override
419+
protected void prepareSocket(SSLSocket socket, HttpContext context) throws IOException {
420+
super.prepareSocket(socket, context);
421+
if (defaultSNI != null) {
422+
SSLParameters sslParams = socket.getSSLParameters();
423+
sslParams.setServerNames(Collections.singletonList(defaultSNI));
424+
socket.setSSLParameters(sslParams);
425+
}
426+
}
427+
412428
public static SSLSocketFactory create(ClickHouseConfig config) throws SSLException {
413429
return new SSLSocketFactory(config);
414430
}

client-v2/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@
129129
<version>1.18.36</version>
130130
<scope>test</scope>
131131
</dependency>
132+
<dependency>
133+
<groupId>org.slf4j</groupId>
134+
<artifactId>slf4j-simple</artifactId>
135+
<version>2.0.16</version>
136+
<scope>test</scope>
137+
</dependency>
132138
</dependencies>
133139

134140
<build>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.clickhouse.client.api;
2+
3+
public class ClickHouseException extends RuntimeException {
4+
protected boolean isRetryable = false;
5+
6+
public ClickHouseException(String message) {
7+
super(message);
8+
}
9+
10+
public ClickHouseException(String message, Throwable cause) {
11+
super(message, cause);
12+
}
13+
14+
public ClickHouseException(Throwable cause) {
15+
super(cause);
16+
}
17+
public boolean isRetryable() { return isRetryable; }
18+
}

0 commit comments

Comments
 (0)