Skip to content

Commit 02bf9ad

Browse files
committed
iproto: add PREPARE operation
Tarantool introduced a new PREPARE protocol operation to be able to create a prepared statement on the server side. This can be used by JDBC SQLPreparedStatement implementation that will prepare its query in advance to get meta data as well as reuse it multiple times. These JDBC features will be introduced in future commits. This commit add all the required protocol constants and allow TarantoolClient to abstract from concrete operation codes related to SQL. Because the native client does not provide API to perform PREPARE it does not handle it in completeSql() as a completely unexpected operation here. Follows on: #198
1 parent fb2e568 commit 02bf9ad

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

src/main/java/org/tarantool/Code.java

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public enum Code {
1313
UPSERT(9),
1414
CALL(10),
1515
EXECUTE(11),
16+
PREPARE(13),
17+
DEALLOCATE(13),
1618
PING(64),
1719
SUBSCRIBE(66);
1820

src/main/java/org/tarantool/Key.java

+3
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ public enum Key implements Callable<Integer> {
2929
SQL_FIELD_TYPE(0x1),
3030

3131
SQL_METADATA(0x32),
32+
SQL_BIND_METADATA(0x33),
33+
SQL_BIND_COUNT(0x34),
3234
SQL_TEXT(0x40),
3335
SQL_BIND(0x41),
3436
SQL_OPTIONS(0x42),
3537
SQL_INFO(0x42),
38+
SQL_STATEMENT_ID(0x43),
3639
SQL_ROW_COUNT(0x00),
3740
SQL_INFO_AUTOINCREMENT_IDS(0x01);
3841

src/main/java/org/tarantool/TarantoolClientImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ protected void complete(TarantoolPacket packet, TarantoolOperation operation) {
554554
} catch (TarantoolSchemaException cause) {
555555
fail(target, cause);
556556
}
557-
} else if (operation.getCode() == Code.EXECUTE) {
557+
} else if (operation.isSqlRelated()) {
558558
completeSql(operation, packet);
559559
} else {
560560
((CompletableFuture) result).complete(packet.getData());

src/main/java/org/tarantool/TarantoolOperation.java

+4
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ public Code getCode() {
113113
return code;
114114
}
115115

116+
public boolean isSqlRelated() {
117+
return code == Code.EXECUTE || code == Code.PREPARE;
118+
}
119+
116120
public TarantoolOperation getDependedOperation() {
117121
return dependedOperation;
118122
}

0 commit comments

Comments
 (0)