Skip to content

Commit c10fdf0

Browse files
authored
Merge pull request #24 from alex268/develop
Remove obsolete parameters
2 parents be33be2 + 33646ae commit c10fdf0

File tree

11 files changed

+17
-85
lines changed

11 files changed

+17
-85
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
## 2.0.2 ##
2+
3+
* Removed obsolete options
4+
15
## 2.0.1 ##
26

3-
* Added column types to getTables() method
7+
* Added column tables to getTables() method
48
* Added parameter `forceQueryMode` to use for specifying the type of query
5-
* Execution of scan or scheme query inside active transaction will raise exception
9+
* Execution of scan or scheme query inside active transaction will throw exception
610

711
## 2.0.0 ##
812

jdbc-shaded/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>tech.ydb.jdbc</groupId>
88
<artifactId>ydb-jdbc-driver-parent</artifactId>
9-
<version>2.0.1</version>
9+
<version>2.0.2</version>
1010
</parent>
1111

1212
<artifactId>ydb-jdbc-driver-shaded</artifactId>

jdbc/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>tech.ydb.jdbc</groupId>
88
<artifactId>ydb-jdbc-driver-parent</artifactId>
9-
<version>2.0.1</version>
9+
<version>2.0.2</version>
1010
</parent>
1111

1212
<artifactId>ydb-jdbc-driver</artifactId>

jdbc/src/main/java/tech/ydb/jdbc/YdbConst.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,7 @@ public final class YdbConst {
135135
*/
136136
public static final int STALE_CONSISTENT_READ_ONLY = 3; // TODO: verify if we can do that
137137

138-
public static final int DEFAULT_JDBC_SUPPORT_LEVEL = 5;
139-
140138
// Processing queries
141-
public static final String PREFIX_SYNTAX_V1 = "--!syntax_v1";
142-
143139
public static final String EXPLAIN_COLUMN_AST = "AST";
144140
public static final String EXPLAIN_COLUMN_PLAN = "PLAN";
145141

jdbc/src/main/java/tech/ydb/jdbc/query/YdbQuery.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@ public List<String> getIndexesParameters() {
4646
public String getYqlQuery(Params params) throws SQLException {
4747
StringBuilder yql = new StringBuilder();
4848

49-
if (opts.isEnforceSyntaxV1()) {
50-
if (!yqlQuery.startsWith(YdbConst.PREFIX_SYNTAX_V1)) {
51-
yql.append(YdbConst.PREFIX_SYNTAX_V1);
52-
yql.append("\n");
53-
}
54-
}
55-
5649
if (indexesArgsNames != null) {
5750
if (params != null) {
5851
Map<String, Value<?>> values = params.values();

jdbc/src/main/java/tech/ydb/jdbc/query/YdbQueryOptions.java

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
* @author Aleksandr Gorshenin
1515
*/
1616
public class YdbQueryOptions {
17-
private final boolean isEnforceSyntaxV1;
18-
1917
private final boolean isDetectQueryType;
2018
private final boolean isDetectJdbcParameters;
2119
private final boolean isDeclareJdbcParameters;
@@ -27,16 +25,13 @@ public class YdbQueryOptions {
2725

2826
@VisibleForTesting
2927
YdbQueryOptions(
30-
boolean enforceV1,
3128
boolean detectQueryType,
3229
boolean detectJbdcParams,
3330
boolean declareJdbcParams,
3431
boolean prepareDataQuery,
3532
boolean detectBatchQuery,
3633
QueryType forcedType
3734
) {
38-
this.isEnforceSyntaxV1 = enforceV1;
39-
4035
this.isDetectQueryType = detectQueryType;
4136
this.isDetectJdbcParameters = detectJbdcParams;
4237
this.isDeclareJdbcParameters = declareJdbcParams;
@@ -47,10 +42,6 @@ public class YdbQueryOptions {
4742
this.forcedType = forcedType;
4843
}
4944

50-
public boolean isEnforceSyntaxV1() {
51-
return isEnforceSyntaxV1;
52-
}
53-
5445
public boolean isDetectQueryType() {
5546
return isDetectQueryType;
5647
}
@@ -76,20 +67,14 @@ public QueryType getForcedQueryType() {
7667
}
7768

7869
public static YdbQueryOptions createFrom(YdbOperationProperties props) {
79-
int level = props.getJdbcSupportLevel();
80-
81-
boolean enforceV1 = level > 5;
82-
boolean declareJdbcParams = level > 4;
83-
boolean detectJbdcParams = level > 3;
84-
boolean detectBatchQuery = level > 2;
85-
boolean prepareDataQuery = level > 1;
86-
boolean detectQueryType = level > 0;
70+
boolean declareJdbcParams = true;
71+
boolean detectJbdcParams = true;
72+
boolean detectBatchQuery = true;
73+
boolean prepareDataQuery = true;
74+
boolean detectQueryType = true;
8775

8876
// forced properies
8977
Map<YdbOperationProperty<?>, ParsedProperty> params = props.getParams();
90-
if (params.containsKey(YdbOperationProperty.ENFORCE_SQL_V1)) {
91-
enforceV1 = params.get(YdbOperationProperty.ENFORCE_SQL_V1).getParsedValue();
92-
}
9378

9479
if (params.containsKey(YdbOperationProperty.DISABLE_AUTO_PREPARED_BATCHES)) {
9580
boolean v = params.get(YdbOperationProperty.DISABLE_AUTO_PREPARED_BATCHES).getParsedValue();
@@ -123,7 +108,6 @@ public static YdbQueryOptions createFrom(YdbOperationProperties props) {
123108
QueryType forcedQueryType = props.getForcedQueryType();
124109

125110
return new YdbQueryOptions(
126-
enforceV1,
127111
detectQueryType,
128112
detectJbdcParams,
129113
declareJdbcParams,

jdbc/src/main/java/tech/ydb/jdbc/settings/YdbOperationProperties.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ public class YdbOperationProperties {
2121
private final int maxRows;
2222
private final boolean cacheConnectionsInDriver;
2323

24-
private final int jdbcSupportLevel;
25-
2624
private final FakeTxMode scanQueryTxMode;
2725
private final FakeTxMode schemeQueryTxMode;
2826
private final QueryType forcedQueryType;
@@ -41,8 +39,6 @@ public YdbOperationProperties(Map<YdbOperationProperty<?>, ParsedProperty> param
4139
this.maxRows = MAX_ROWS;
4240
this.cacheConnectionsInDriver = params.get(YdbOperationProperty.CACHE_CONNECTIONS_IN_DRIVER).getParsedValue();
4341

44-
this.jdbcSupportLevel = params.get(YdbOperationProperty.JDBC_SUPPORT_LEVEL).getParsedValue();
45-
4642
this.scanQueryTxMode = params.get(YdbOperationProperty.SCAN_QUERY_TX_MODE).getParsedValue();
4743
this.schemeQueryTxMode = params.get(YdbOperationProperty.SCHEME_QUERY_TX_MODE).getParsedValue();
4844

@@ -105,8 +101,4 @@ public int getMaxRows() {
105101
public boolean isCacheConnectionsInDriver() {
106102
return cacheConnectionsInDriver;
107103
}
108-
109-
public int getJdbcSupportLevel() {
110-
return jdbcSupportLevel;
111-
}
112104
}

jdbc/src/main/java/tech/ydb/jdbc/settings/YdbOperationProperty.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import javax.annotation.Nullable;
88

9-
import tech.ydb.jdbc.YdbConst;
109
import tech.ydb.jdbc.query.QueryType;
1110

1211

@@ -89,13 +88,6 @@ public class YdbOperationProperty<T> extends AbstractYdbProperty<T, Void> {
8988
PropertyConverter.booleanValue());
9089

9190

92-
public static final YdbOperationProperty<Boolean> ENFORCE_SQL_V1 =
93-
new YdbOperationProperty<>("enforceSqlV1",
94-
"Enforce SQL v1 grammar by adding --!syntax_v1 in the beginning of each SQL statement",
95-
"false",
96-
Boolean.class,
97-
PropertyConverter.booleanValue());
98-
9991
public static final YdbOperationProperty<Boolean> DISABLE_DETECT_SQL_OPERATIONS =
10092
new YdbOperationProperty<>("disableDetectSqlOperations",
10193
"Disable detecting SQL operation based on SQL keywords",
@@ -132,13 +124,6 @@ public class YdbOperationProperty<T> extends AbstractYdbProperty<T, Void> {
132124
Boolean.class,
133125
PropertyConverter.booleanValue());
134126

135-
public static final YdbOperationProperty<Integer> JDBC_SUPPORT_LEVEL =
136-
new YdbOperationProperty<>("jdbcSupportLevel",
137-
"Disable auto detect JDBC standart parameters '?'",
138-
"" + YdbConst.DEFAULT_JDBC_SUPPORT_LEVEL,
139-
Integer.class,
140-
PropertyConverter.integerValue());
141-
142127
public static final YdbOperationProperty<FakeTxMode> SCAN_QUERY_TX_MODE =
143128
new YdbOperationProperty<>("scanQueryTxMode",
144129
"Mode of execution scan query inside transaction. "

jdbc/src/test/java/tech/ydb/jdbc/YdbDriverProperitesTest.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -324,16 +324,12 @@ static DriverPropertyInfo[] defaultPropertyInfo(@Nullable String localDatacenter
324324

325325
YdbOperationProperty.CACHE_CONNECTIONS_IN_DRIVER.toDriverPropertyInfo("true"),
326326

327-
YdbOperationProperty.ENFORCE_SQL_V1.toDriverPropertyInfo("false"),
328-
329327
YdbOperationProperty.DISABLE_DETECT_SQL_OPERATIONS.toDriverPropertyInfo("false"),
330328
YdbOperationProperty.DISABLE_PREPARE_DATAQUERY.toDriverPropertyInfo("false"),
331329
YdbOperationProperty.DISABLE_AUTO_PREPARED_BATCHES.toDriverPropertyInfo("false"),
332330
YdbOperationProperty.DISABLE_JDBC_PARAMETERS.toDriverPropertyInfo("false"),
333331
YdbOperationProperty.DISABLE_JDBC_PARAMETERS_DECLARE.toDriverPropertyInfo("false"),
334332

335-
YdbOperationProperty.JDBC_SUPPORT_LEVEL.toDriverPropertyInfo("" + YdbConst.DEFAULT_JDBC_SUPPORT_LEVEL),
336-
337333
YdbOperationProperty.SCAN_QUERY_TX_MODE.toDriverPropertyInfo("ERROR"),
338334
YdbOperationProperty.SCHEME_QUERY_TX_MODE.toDriverPropertyInfo("ERROR"),
339335
YdbOperationProperty.FORCE_QUERY_MODE.toDriverPropertyInfo(null),
@@ -368,13 +364,11 @@ static Properties customizedProperties() {
368364

369365
properties.setProperty("cacheConnectionsInDriver", "false");
370366

371-
properties.setProperty("enforceSqlV1", "true");
372367
properties.setProperty("disablePrepareDataQuery", "true");
373368
properties.setProperty("disableAutoPreparedBatches", "true");
374369
properties.setProperty("disableDetectSqlOperations", "true");
375370
properties.setProperty("disableJdbcParameters", "true");
376371
properties.setProperty("disableJdbcParameterDeclare", "true");
377-
properties.setProperty("jdbcSupportLevel", "0");
378372

379373
properties.setProperty("scanQueryTxMode", "FAKE_TX");
380374
properties.setProperty("schemeQueryTxMode", "SHADOW_COMMIT");
@@ -410,15 +404,12 @@ static DriverPropertyInfo[] customizedPropertyInfo() {
410404

411405
YdbOperationProperty.CACHE_CONNECTIONS_IN_DRIVER.toDriverPropertyInfo("false"),
412406

413-
YdbOperationProperty.ENFORCE_SQL_V1.toDriverPropertyInfo("true"),
414407
YdbOperationProperty.DISABLE_DETECT_SQL_OPERATIONS.toDriverPropertyInfo("true"),
415408
YdbOperationProperty.DISABLE_PREPARE_DATAQUERY.toDriverPropertyInfo("true"),
416409
YdbOperationProperty.DISABLE_AUTO_PREPARED_BATCHES.toDriverPropertyInfo("true"),
417410
YdbOperationProperty.DISABLE_JDBC_PARAMETERS.toDriverPropertyInfo("true"),
418411
YdbOperationProperty.DISABLE_JDBC_PARAMETERS_DECLARE.toDriverPropertyInfo("true"),
419412

420-
YdbOperationProperty.JDBC_SUPPORT_LEVEL.toDriverPropertyInfo("0"),
421-
422413
YdbOperationProperty.SCAN_QUERY_TX_MODE.toDriverPropertyInfo("FAKE_TX"),
423414
YdbOperationProperty.SCHEME_QUERY_TX_MODE.toDriverPropertyInfo("SHADOW_COMMIT"),
424415
YdbOperationProperty.FORCE_QUERY_MODE.toDriverPropertyInfo("SCAN_QUERY"),
@@ -439,7 +430,6 @@ static void checkCustomizedProperties(YdbProperties properties) {
439430
Assertions.assertTrue(ops.isAutoCommit());
440431
Assertions.assertEquals(YdbConst.ONLINE_CONSISTENT_READ_ONLY, ops.getTransactionLevel());
441432
Assertions.assertFalse(ops.isCacheConnectionsInDriver());
442-
Assertions.assertEquals(0, ops.getJdbcSupportLevel());
443433
}
444434

445435
static String asString(DriverPropertyInfo info) {

jdbc/src/test/java/tech/ydb/jdbc/query/QueryLexerTest.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,9 @@ private void assertMixType(YdbQueryOptions opts, String types, String sql) {
2929
Assertions.assertEquals("Query cannot contain expressions with different types: " + types, ex.getMessage());
3030
}
3131

32-
@Test
33-
public void enforceV1Test() throws SQLException {
34-
YdbQueryOptions disabled = new YdbQueryOptions(false, true, true, true, true, true, null);
35-
YdbQueryOptions enabled = new YdbQueryOptions(true, true, true, true, true, true, null);
36-
37-
Assertions.assertEquals("CREATE TABLE test_table (id int, value text)",
38-
parseQuery(disabled, "CREATE TABLE test_table (id int, value text)"));
39-
40-
Assertions.assertEquals("--!syntax_v1\nCREATE TABLE test_table (id int, value text)",
41-
parseQuery(enabled, "CREATE TABLE test_table (id int, value text)"));
42-
}
43-
4432
@Test
4533
public void queryTypesTest() throws SQLException {
46-
YdbQueryOptions opts = new YdbQueryOptions(false, true, false, false, false, false, null);
34+
YdbQueryOptions opts = new YdbQueryOptions(true, false, false, false, false, null);
4735

4836
Assertions.assertEquals(QueryType.SCHEME_QUERY, parseQueryType(opts,
4937
"CREATE TABLE test_table (id int, value text)"
@@ -89,7 +77,7 @@ public void queryTypesTest() throws SQLException {
8977

9078
@Test
9179
public void mixQueryExceptionTest() throws SQLException {
92-
YdbQueryOptions opts = new YdbQueryOptions(false, true, false, false, false, false, null);
80+
YdbQueryOptions opts = new YdbQueryOptions(true, false, false, false, false, null);
9381

9482
assertMixType(opts, "SCHEME_QUERY, DATA_QUERY",
9583
"CREATE TABLE test_table (id int, value text);" +
@@ -111,7 +99,7 @@ public void mixQueryExceptionTest() throws SQLException {
11199

112100
@Test
113101
public void forsedTypeTest() throws SQLException {
114-
YdbQueryOptions opts = new YdbQueryOptions(false, true, false, false, false, false, QueryType.SCHEME_QUERY);
102+
YdbQueryOptions opts = new YdbQueryOptions(true, false, false, false, false, QueryType.SCHEME_QUERY);
115103

116104
Assertions.assertEquals(QueryType.SCHEME_QUERY, parseQueryType(opts,
117105
"CREATE TABLE test_table (id int, value text)"

0 commit comments

Comments
 (0)