Skip to content

Commit 880fa0b

Browse files
committed
Merge v2.2.13 fix
2 parents 6303e5a + fa52e95 commit 880fa0b

File tree

3 files changed

+44
-35
lines changed

3 files changed

+44
-35
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
* QueryService is enabled by default
44

5+
## 2.2.13 ##
6+
7+
* Fixed usePrefixPath for preparing of YQL statements
8+
59
## 2.2.12 ##
610

711
* Added option usePrefixPath

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,22 @@ Specify the YDB JDBC driver in the dependencies:
2626
<dependency>
2727
<groupId>tech.ydb.jdbc</groupId>
2828
<artifactId>ydb-jdbc-driver</artifactId>
29+
<<<<<<< HEAD
2930
<version>2.3.0</version>
31+
=======
32+
<version>2.2.13</version>
33+
>>>>>>> bugfix
3034
</dependency>
3135

3236
<!-- Shaded version with included dependencies -->
3337
<dependency>
3438
<groupId>tech.ydb.jdbc</groupId>
3539
<artifactId>ydb-jdbc-driver-shaded</artifactId>
40+
<<<<<<< HEAD
3641
<version>2.3.0</version>
42+
=======
43+
<version>2.2.13</version>
44+
>>>>>>> bugfix
3745
</dependency>
3846
</dependencies>
3947
```

jdbc/src/main/java/tech/ydb/jdbc/context/YdbContext.java

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -437,49 +437,46 @@ public YdbPreparedQuery findOrPrepareParams(YdbQuery query, YdbPrepareMode mode)
437437
}
438438

439439
// try to prepare data query
440-
try {
441-
Map<String, Type> types = queryParamsCache.getIfPresent(query.getOriginQuery());
442-
if (types == null) {
443-
String yql = prefixPragma + query.getPreparedYql();
444-
YdbTracer tracer = config.isTxTracedEnabled() ? YdbTracer.current() : null;
445-
if (tracer != null) {
446-
tracer.trace("--> prepare data query");
447-
tracer.traceRequest(yql);
448-
}
440+
Map<String, Type> types = queryParamsCache.getIfPresent(query.getOriginQuery());
441+
if (types == null) {
442+
String yql = prefixPragma + query.getPreparedYql();
443+
YdbTracer tracer = config.isTxTracedEnabled() ? YdbTracer.current() : null;
444+
if (tracer != null) {
445+
tracer.trace("--> prepare data query");
446+
tracer.traceRequest(yql);
447+
}
449448

450-
PrepareDataQuerySettings settings = withDefaultTimeout(new PrepareDataQuerySettings());
451-
Result<DataQuery> result = retryCtx.supplyResult(
452-
session -> session.prepareDataQuery(yql, settings)
453-
).join();
449+
PrepareDataQuerySettings settings = withDefaultTimeout(new PrepareDataQuerySettings());
450+
Result<DataQuery> result = retryCtx.supplyResult(
451+
session -> session.prepareDataQuery(yql, settings)
452+
).join();
454453

454+
if (tracer != null) {
455+
tracer.trace("<-- " + result.getStatus());
456+
}
457+
if (!result.isSuccess()) {
455458
if (tracer != null) {
456-
tracer.trace("<-- " + result.getStatus());
459+
tracer.close();
457460
}
458-
if (!result.isSuccess()) {
459-
if (tracer != null) {
460-
tracer.close();
461-
}
462-
throw new SQLException(YdbConst.UNABLE_PREPARE_STATEMENT + result.getStatus());
463-
}
464-
465-
types = result.getValue().types();
466-
queryParamsCache.put(query.getOriginQuery(), types);
461+
throw ExceptionFactory.createException("Cannot prepare data query: " + result.getStatus(),
462+
new UnexpectedResultException("Unexpected status", result.getStatus()));
467463
}
468464

469-
boolean requireBatch = mode == YdbPrepareMode.DATA_QUERY_BATCH;
470-
if (requireBatch || (mode == YdbPrepareMode.AUTO && queryOptions.isDetectBatchQueries())) {
471-
BatchedQuery params = BatchedQuery.tryCreateBatched(query, types);
472-
if (params != null) {
473-
return params;
474-
}
465+
types = result.getValue().types();
466+
queryParamsCache.put(query.getOriginQuery(), types);
467+
}
475468

476-
if (requireBatch) {
477-
throw new SQLDataException(YdbConst.STATEMENT_IS_NOT_A_BATCH + query.getOriginQuery());
478-
}
469+
boolean requireBatch = mode == YdbPrepareMode.DATA_QUERY_BATCH;
470+
if (requireBatch || (mode == YdbPrepareMode.AUTO && queryOptions.isDetectBatchQueries())) {
471+
BatchedQuery params = BatchedQuery.tryCreateBatched(query, types);
472+
if (params != null) {
473+
return params;
474+
}
475+
476+
if (requireBatch) {
477+
throw new SQLDataException(YdbConst.STATEMENT_IS_NOT_A_BATCH + query.getOriginQuery());
479478
}
480-
return new PreparedQuery(query, types);
481-
} catch (UnexpectedResultException ex) {
482-
throw ExceptionFactory.createException("Cannot prepare data query: " + ex.getMessage(), ex);
483479
}
480+
return new PreparedQuery(query, types);
484481
}
485482
}

0 commit comments

Comments
 (0)