From 955a32f18735b845147e7045ca72fc31f390eee7 Mon Sep 17 00:00:00 2001 From: Alexandr Gorshenin Date: Fri, 29 Sep 2023 15:31:55 +0100 Subject: [PATCH 1/4] Fix typos --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64b6039..dff66d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ ## 2.0.1 ## -* Added column types to getTables() method +* Added column tables to getTables() method * Added parameter `forceQueryMode` to use for specifying the type of query -* Execution of scan or scheme query inside active transaction will raise exception +* Execution of scan or scheme query inside active transaction will throw exception ## 2.0.0 ## From 4fc47d36be830c0c55382529b2cef52927e251aa Mon Sep 17 00:00:00 2001 From: Alexandr Gorshenin Date: Fri, 29 Sep 2023 15:33:31 +0100 Subject: [PATCH 2/4] New snapshot version 2.0.2 --- jdbc-shaded/pom.xml | 2 +- jdbc/pom.xml | 2 +- pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jdbc-shaded/pom.xml b/jdbc-shaded/pom.xml index 4f66ae4..39f5acd 100644 --- a/jdbc-shaded/pom.xml +++ b/jdbc-shaded/pom.xml @@ -6,7 +6,7 @@ tech.ydb.jdbc ydb-jdbc-driver-parent - 2.0.1 + 2.0.2-SNAPSHOT ydb-jdbc-driver-shaded diff --git a/jdbc/pom.xml b/jdbc/pom.xml index 90bbeb1..1d324ff 100644 --- a/jdbc/pom.xml +++ b/jdbc/pom.xml @@ -6,7 +6,7 @@ tech.ydb.jdbc ydb-jdbc-driver-parent - 2.0.1 + 2.0.2-SNAPSHOT ydb-jdbc-driver diff --git a/pom.xml b/pom.xml index 97d1984..d31c141 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ tech.ydb.jdbc ydb-jdbc-driver-parent - 2.0.1 + 2.0.2-SNAPSHOT YDB JDBC Module JDBC Driver over YDB Java SDK From 8a3a9c13dbbcefe1a45f65a2e2b15bdecea29eb1 Mon Sep 17 00:00:00 2001 From: Alexandr Gorshenin Date: Fri, 29 Sep 2023 15:38:08 +0100 Subject: [PATCH 3/4] Removed obsolete options --- CHANGELOG.md | 4 +++ .../src/main/java/tech/ydb/jdbc/YdbConst.java | 4 --- .../java/tech/ydb/jdbc/query/YdbQuery.java | 7 ----- .../tech/ydb/jdbc/query/YdbQueryOptions.java | 26 ++++--------------- .../jdbc/settings/YdbOperationProperties.java | 8 ------ .../jdbc/settings/YdbOperationProperty.java | 15 ----------- .../ydb/jdbc/YdbDriverProperitesTest.java | 10 ------- .../tech/ydb/jdbc/query/QueryLexerTest.java | 18 +++---------- 8 files changed, 12 insertions(+), 80 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dff66d3..6c48351 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.2 ## + +* Removed obsolete options + ## 2.0.1 ## * Added column tables to getTables() method diff --git a/jdbc/src/main/java/tech/ydb/jdbc/YdbConst.java b/jdbc/src/main/java/tech/ydb/jdbc/YdbConst.java index 29f7f3f..8cb31b8 100644 --- a/jdbc/src/main/java/tech/ydb/jdbc/YdbConst.java +++ b/jdbc/src/main/java/tech/ydb/jdbc/YdbConst.java @@ -135,11 +135,7 @@ public final class YdbConst { */ public static final int STALE_CONSISTENT_READ_ONLY = 3; // TODO: verify if we can do that - public static final int DEFAULT_JDBC_SUPPORT_LEVEL = 5; - // Processing queries - public static final String PREFIX_SYNTAX_V1 = "--!syntax_v1"; - public static final String EXPLAIN_COLUMN_AST = "AST"; public static final String EXPLAIN_COLUMN_PLAN = "PLAN"; diff --git a/jdbc/src/main/java/tech/ydb/jdbc/query/YdbQuery.java b/jdbc/src/main/java/tech/ydb/jdbc/query/YdbQuery.java index 13cdec2..d9274b9 100644 --- a/jdbc/src/main/java/tech/ydb/jdbc/query/YdbQuery.java +++ b/jdbc/src/main/java/tech/ydb/jdbc/query/YdbQuery.java @@ -46,13 +46,6 @@ public List getIndexesParameters() { public String getYqlQuery(Params params) throws SQLException { StringBuilder yql = new StringBuilder(); - if (opts.isEnforceSyntaxV1()) { - if (!yqlQuery.startsWith(YdbConst.PREFIX_SYNTAX_V1)) { - yql.append(YdbConst.PREFIX_SYNTAX_V1); - yql.append("\n"); - } - } - if (indexesArgsNames != null) { if (params != null) { Map> values = params.values(); diff --git a/jdbc/src/main/java/tech/ydb/jdbc/query/YdbQueryOptions.java b/jdbc/src/main/java/tech/ydb/jdbc/query/YdbQueryOptions.java index cb522e9..47220f5 100644 --- a/jdbc/src/main/java/tech/ydb/jdbc/query/YdbQueryOptions.java +++ b/jdbc/src/main/java/tech/ydb/jdbc/query/YdbQueryOptions.java @@ -14,8 +14,6 @@ * @author Aleksandr Gorshenin */ public class YdbQueryOptions { - private final boolean isEnforceSyntaxV1; - private final boolean isDetectQueryType; private final boolean isDetectJdbcParameters; private final boolean isDeclareJdbcParameters; @@ -27,7 +25,6 @@ public class YdbQueryOptions { @VisibleForTesting YdbQueryOptions( - boolean enforceV1, boolean detectQueryType, boolean detectJbdcParams, boolean declareJdbcParams, @@ -35,8 +32,6 @@ public class YdbQueryOptions { boolean detectBatchQuery, QueryType forcedType ) { - this.isEnforceSyntaxV1 = enforceV1; - this.isDetectQueryType = detectQueryType; this.isDetectJdbcParameters = detectJbdcParams; this.isDeclareJdbcParameters = declareJdbcParams; @@ -47,10 +42,6 @@ public class YdbQueryOptions { this.forcedType = forcedType; } - public boolean isEnforceSyntaxV1() { - return isEnforceSyntaxV1; - } - public boolean isDetectQueryType() { return isDetectQueryType; } @@ -76,20 +67,14 @@ public QueryType getForcedQueryType() { } public static YdbQueryOptions createFrom(YdbOperationProperties props) { - int level = props.getJdbcSupportLevel(); - - boolean enforceV1 = level > 5; - boolean declareJdbcParams = level > 4; - boolean detectJbdcParams = level > 3; - boolean detectBatchQuery = level > 2; - boolean prepareDataQuery = level > 1; - boolean detectQueryType = level > 0; + boolean declareJdbcParams = true; + boolean detectJbdcParams = true; + boolean detectBatchQuery = true; + boolean prepareDataQuery = true; + boolean detectQueryType = true; // forced properies Map, ParsedProperty> params = props.getParams(); - if (params.containsKey(YdbOperationProperty.ENFORCE_SQL_V1)) { - enforceV1 = params.get(YdbOperationProperty.ENFORCE_SQL_V1).getParsedValue(); - } if (params.containsKey(YdbOperationProperty.DISABLE_AUTO_PREPARED_BATCHES)) { boolean v = params.get(YdbOperationProperty.DISABLE_AUTO_PREPARED_BATCHES).getParsedValue(); @@ -123,7 +108,6 @@ public static YdbQueryOptions createFrom(YdbOperationProperties props) { QueryType forcedQueryType = props.getForcedQueryType(); return new YdbQueryOptions( - enforceV1, detectQueryType, detectJbdcParams, declareJdbcParams, diff --git a/jdbc/src/main/java/tech/ydb/jdbc/settings/YdbOperationProperties.java b/jdbc/src/main/java/tech/ydb/jdbc/settings/YdbOperationProperties.java index 61ae6b8..87ce018 100644 --- a/jdbc/src/main/java/tech/ydb/jdbc/settings/YdbOperationProperties.java +++ b/jdbc/src/main/java/tech/ydb/jdbc/settings/YdbOperationProperties.java @@ -21,8 +21,6 @@ public class YdbOperationProperties { private final int maxRows; private final boolean cacheConnectionsInDriver; - private final int jdbcSupportLevel; - private final FakeTxMode scanQueryTxMode; private final FakeTxMode schemeQueryTxMode; private final QueryType forcedQueryType; @@ -41,8 +39,6 @@ public YdbOperationProperties(Map, ParsedProperty> param this.maxRows = MAX_ROWS; this.cacheConnectionsInDriver = params.get(YdbOperationProperty.CACHE_CONNECTIONS_IN_DRIVER).getParsedValue(); - this.jdbcSupportLevel = params.get(YdbOperationProperty.JDBC_SUPPORT_LEVEL).getParsedValue(); - this.scanQueryTxMode = params.get(YdbOperationProperty.SCAN_QUERY_TX_MODE).getParsedValue(); this.schemeQueryTxMode = params.get(YdbOperationProperty.SCHEME_QUERY_TX_MODE).getParsedValue(); @@ -105,8 +101,4 @@ public int getMaxRows() { public boolean isCacheConnectionsInDriver() { return cacheConnectionsInDriver; } - - public int getJdbcSupportLevel() { - return jdbcSupportLevel; - } } diff --git a/jdbc/src/main/java/tech/ydb/jdbc/settings/YdbOperationProperty.java b/jdbc/src/main/java/tech/ydb/jdbc/settings/YdbOperationProperty.java index 87d7186..8aef66c 100644 --- a/jdbc/src/main/java/tech/ydb/jdbc/settings/YdbOperationProperty.java +++ b/jdbc/src/main/java/tech/ydb/jdbc/settings/YdbOperationProperty.java @@ -6,7 +6,6 @@ import javax.annotation.Nullable; -import tech.ydb.jdbc.YdbConst; import tech.ydb.jdbc.query.QueryType; @@ -89,13 +88,6 @@ public class YdbOperationProperty extends AbstractYdbProperty { PropertyConverter.booleanValue()); - public static final YdbOperationProperty ENFORCE_SQL_V1 = - new YdbOperationProperty<>("enforceSqlV1", - "Enforce SQL v1 grammar by adding --!syntax_v1 in the beginning of each SQL statement", - "false", - Boolean.class, - PropertyConverter.booleanValue()); - public static final YdbOperationProperty DISABLE_DETECT_SQL_OPERATIONS = new YdbOperationProperty<>("disableDetectSqlOperations", "Disable detecting SQL operation based on SQL keywords", @@ -132,13 +124,6 @@ public class YdbOperationProperty extends AbstractYdbProperty { Boolean.class, PropertyConverter.booleanValue()); - public static final YdbOperationProperty JDBC_SUPPORT_LEVEL = - new YdbOperationProperty<>("jdbcSupportLevel", - "Disable auto detect JDBC standart parameters '?'", - "" + YdbConst.DEFAULT_JDBC_SUPPORT_LEVEL, - Integer.class, - PropertyConverter.integerValue()); - public static final YdbOperationProperty SCAN_QUERY_TX_MODE = new YdbOperationProperty<>("scanQueryTxMode", "Mode of execution scan query inside transaction. " diff --git a/jdbc/src/test/java/tech/ydb/jdbc/YdbDriverProperitesTest.java b/jdbc/src/test/java/tech/ydb/jdbc/YdbDriverProperitesTest.java index 86f6aa1..ca7a8a3 100644 --- a/jdbc/src/test/java/tech/ydb/jdbc/YdbDriverProperitesTest.java +++ b/jdbc/src/test/java/tech/ydb/jdbc/YdbDriverProperitesTest.java @@ -324,16 +324,12 @@ static DriverPropertyInfo[] defaultPropertyInfo(@Nullable String localDatacenter YdbOperationProperty.CACHE_CONNECTIONS_IN_DRIVER.toDriverPropertyInfo("true"), - YdbOperationProperty.ENFORCE_SQL_V1.toDriverPropertyInfo("false"), - YdbOperationProperty.DISABLE_DETECT_SQL_OPERATIONS.toDriverPropertyInfo("false"), YdbOperationProperty.DISABLE_PREPARE_DATAQUERY.toDriverPropertyInfo("false"), YdbOperationProperty.DISABLE_AUTO_PREPARED_BATCHES.toDriverPropertyInfo("false"), YdbOperationProperty.DISABLE_JDBC_PARAMETERS.toDriverPropertyInfo("false"), YdbOperationProperty.DISABLE_JDBC_PARAMETERS_DECLARE.toDriverPropertyInfo("false"), - YdbOperationProperty.JDBC_SUPPORT_LEVEL.toDriverPropertyInfo("" + YdbConst.DEFAULT_JDBC_SUPPORT_LEVEL), - YdbOperationProperty.SCAN_QUERY_TX_MODE.toDriverPropertyInfo("ERROR"), YdbOperationProperty.SCHEME_QUERY_TX_MODE.toDriverPropertyInfo("ERROR"), YdbOperationProperty.FORCE_QUERY_MODE.toDriverPropertyInfo(null), @@ -368,13 +364,11 @@ static Properties customizedProperties() { properties.setProperty("cacheConnectionsInDriver", "false"); - properties.setProperty("enforceSqlV1", "true"); properties.setProperty("disablePrepareDataQuery", "true"); properties.setProperty("disableAutoPreparedBatches", "true"); properties.setProperty("disableDetectSqlOperations", "true"); properties.setProperty("disableJdbcParameters", "true"); properties.setProperty("disableJdbcParameterDeclare", "true"); - properties.setProperty("jdbcSupportLevel", "0"); properties.setProperty("scanQueryTxMode", "FAKE_TX"); properties.setProperty("schemeQueryTxMode", "SHADOW_COMMIT"); @@ -410,15 +404,12 @@ static DriverPropertyInfo[] customizedPropertyInfo() { YdbOperationProperty.CACHE_CONNECTIONS_IN_DRIVER.toDriverPropertyInfo("false"), - YdbOperationProperty.ENFORCE_SQL_V1.toDriverPropertyInfo("true"), YdbOperationProperty.DISABLE_DETECT_SQL_OPERATIONS.toDriverPropertyInfo("true"), YdbOperationProperty.DISABLE_PREPARE_DATAQUERY.toDriverPropertyInfo("true"), YdbOperationProperty.DISABLE_AUTO_PREPARED_BATCHES.toDriverPropertyInfo("true"), YdbOperationProperty.DISABLE_JDBC_PARAMETERS.toDriverPropertyInfo("true"), YdbOperationProperty.DISABLE_JDBC_PARAMETERS_DECLARE.toDriverPropertyInfo("true"), - YdbOperationProperty.JDBC_SUPPORT_LEVEL.toDriverPropertyInfo("0"), - YdbOperationProperty.SCAN_QUERY_TX_MODE.toDriverPropertyInfo("FAKE_TX"), YdbOperationProperty.SCHEME_QUERY_TX_MODE.toDriverPropertyInfo("SHADOW_COMMIT"), YdbOperationProperty.FORCE_QUERY_MODE.toDriverPropertyInfo("SCAN_QUERY"), @@ -439,7 +430,6 @@ static void checkCustomizedProperties(YdbProperties properties) { Assertions.assertTrue(ops.isAutoCommit()); Assertions.assertEquals(YdbConst.ONLINE_CONSISTENT_READ_ONLY, ops.getTransactionLevel()); Assertions.assertFalse(ops.isCacheConnectionsInDriver()); - Assertions.assertEquals(0, ops.getJdbcSupportLevel()); } static String asString(DriverPropertyInfo info) { diff --git a/jdbc/src/test/java/tech/ydb/jdbc/query/QueryLexerTest.java b/jdbc/src/test/java/tech/ydb/jdbc/query/QueryLexerTest.java index 6eefd20..d3c2acc 100644 --- a/jdbc/src/test/java/tech/ydb/jdbc/query/QueryLexerTest.java +++ b/jdbc/src/test/java/tech/ydb/jdbc/query/QueryLexerTest.java @@ -29,21 +29,9 @@ private void assertMixType(YdbQueryOptions opts, String types, String sql) { Assertions.assertEquals("Query cannot contain expressions with different types: " + types, ex.getMessage()); } - @Test - public void enforceV1Test() throws SQLException { - YdbQueryOptions disabled = new YdbQueryOptions(false, true, true, true, true, true, null); - YdbQueryOptions enabled = new YdbQueryOptions(true, true, true, true, true, true, null); - - Assertions.assertEquals("CREATE TABLE test_table (id int, value text)", - parseQuery(disabled, "CREATE TABLE test_table (id int, value text)")); - - Assertions.assertEquals("--!syntax_v1\nCREATE TABLE test_table (id int, value text)", - parseQuery(enabled, "CREATE TABLE test_table (id int, value text)")); - } - @Test public void queryTypesTest() throws SQLException { - YdbQueryOptions opts = new YdbQueryOptions(false, true, false, false, false, false, null); + YdbQueryOptions opts = new YdbQueryOptions(true, false, false, false, false, null); Assertions.assertEquals(QueryType.SCHEME_QUERY, parseQueryType(opts, "CREATE TABLE test_table (id int, value text)" @@ -89,7 +77,7 @@ public void queryTypesTest() throws SQLException { @Test public void mixQueryExceptionTest() throws SQLException { - YdbQueryOptions opts = new YdbQueryOptions(false, true, false, false, false, false, null); + YdbQueryOptions opts = new YdbQueryOptions(true, false, false, false, false, null); assertMixType(opts, "SCHEME_QUERY, DATA_QUERY", "CREATE TABLE test_table (id int, value text);" + @@ -111,7 +99,7 @@ public void mixQueryExceptionTest() throws SQLException { @Test public void forsedTypeTest() throws SQLException { - YdbQueryOptions opts = new YdbQueryOptions(false, true, false, false, false, false, QueryType.SCHEME_QUERY); + YdbQueryOptions opts = new YdbQueryOptions(true, false, false, false, false, QueryType.SCHEME_QUERY); Assertions.assertEquals(QueryType.SCHEME_QUERY, parseQueryType(opts, "CREATE TABLE test_table (id int, value text)" From 33646aed0e2a4e8ff633555d5324f0079f813818 Mon Sep 17 00:00:00 2001 From: Alexandr Gorshenin Date: Fri, 29 Sep 2023 15:38:43 +0100 Subject: [PATCH 4/4] New release version 2.0.2 --- jdbc-shaded/pom.xml | 2 +- jdbc/pom.xml | 2 +- pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jdbc-shaded/pom.xml b/jdbc-shaded/pom.xml index 39f5acd..7f15645 100644 --- a/jdbc-shaded/pom.xml +++ b/jdbc-shaded/pom.xml @@ -6,7 +6,7 @@ tech.ydb.jdbc ydb-jdbc-driver-parent - 2.0.2-SNAPSHOT + 2.0.2 ydb-jdbc-driver-shaded diff --git a/jdbc/pom.xml b/jdbc/pom.xml index 1d324ff..1ce204c 100644 --- a/jdbc/pom.xml +++ b/jdbc/pom.xml @@ -6,7 +6,7 @@ tech.ydb.jdbc ydb-jdbc-driver-parent - 2.0.2-SNAPSHOT + 2.0.2 ydb-jdbc-driver diff --git a/pom.xml b/pom.xml index d31c141..b83b6d9 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ tech.ydb.jdbc ydb-jdbc-driver-parent - 2.0.2-SNAPSHOT + 2.0.2 YDB JDBC Module JDBC Driver over YDB Java SDK