File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
jdbc-v2/src/test/java/com/clickhouse/jdbc Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 44
55import com .clickhouse .client .BaseIntegrationTest ;
66import com .clickhouse .client .ClickHouseProtocol ;
7+ import com .clickhouse .client .api .query .GenericRecord ;
78import com .clickhouse .logging .Logger ;
89import com .clickhouse .logging .LoggerFactory ;
910
@@ -47,4 +48,35 @@ protected boolean runQuery(String query) {
4748 return false ;
4849 }
4950 }
51+
52+
53+ protected boolean earlierThan (int major , int minor ) {
54+ String serverVersion = getServerVersion ();
55+ if (serverVersion == null ) {
56+ return false ;
57+ }
58+
59+ String [] parts = serverVersion .split ("\\ ." );
60+ if (parts .length < 2 ) {
61+ return false ;
62+ }
63+
64+ try {
65+ int serverMajor = Integer .parseInt (parts [0 ]);
66+ int serverMinor = Integer .parseInt (parts [1 ]);
67+ return serverMajor < major || (serverMajor == major && serverMinor < minor );
68+ } catch (NumberFormatException e ) {
69+ return false ;
70+ }
71+ }
72+
73+ protected String getServerVersion () {
74+ try (ConnectionImpl connection = (ConnectionImpl ) getJdbcConnection ()) {
75+ GenericRecord result = connection .client .queryAll ("SELECT version() as server_version" ).stream ()
76+ .findFirst ().orElseThrow (() -> new SQLException ("Failed to retrieve server version." ));
77+ return result .getString ("server_version" );
78+ } catch (SQLException e ) {
79+ return null ;
80+ }
81+ }
5082}
Original file line number Diff line number Diff line change @@ -333,6 +333,10 @@ public void testExecuteQueryTimeout() throws Exception {
333333
334334 @ Test (groups = { "integration" })
335335 private void testSettingRole () throws SQLException {
336+ if (earlierThan (24 , 4 )) {//Min version is 24.4
337+ return ;
338+ }
339+
336340 List <String > roles = Arrays .asList ("role1" , "role2" );
337341
338342 try (ConnectionImpl conn = (ConnectionImpl ) getJdbcConnection ()) {
You can’t perform that action at this time.
0 commit comments