You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2025/10/20 06:59:00 UTC
(shardingsphere) branch master updated: Add BLOB data type support for Firebird Proxy (#36809)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 524036d2c80 Add BLOB data type support for Firebird Proxy (#36809)
524036d2c80 is described below
commit 524036d2c80cd0593647cffc9ef8e9333f9b569a
Author: Maxim Sentyabrskiy <16...@users.noreply.github.com>
AuthorDate: Mon Oct 20 09:58:53 2025 +0300
Add BLOB data type support for Firebird Proxy (#36809)
* add BLOB support to parser
* correct data type definitions in FirebirdBinaryColumnType
* Implement packet splitting logic in FirebirdPacketCodecEngine to avoid command merging
* Add BLOB support to proxy
* Correct and add new tests for BLOB support
* Correct tests and spotless/checkstyle fix
* ci: trigger pipeline
* add tests for Blob Executors and correct PutBlobSegmentCommandPacketTest
* fix empty BLOB segment insertion caused by missing PUT_SEGMENT handling
* fix ci
---
.../firebird/codec/FirebirdPacketCodecEngine.java | 79 +++++++++++++++-----
.../command/FirebirdCommandPacketFactory.java | 53 +++++++++++---
.../command/query/FirebirdBinaryColumnType.java | 11 ++-
.../command/query/blob/FirebirdBlobRegistry.java | 69 ++++++++++++++++++
.../FirebirdCancelBlobCommandPacket.java} | 35 +++++----
.../FirebirdCloseBlobCommandPacket.java} | 35 +++++----
.../blob/FirebirdCreateBlobCommandPacket.java | 83 ++++++++++++++++++++++
.../blob/FirebirdGetBlobSegmentCommandPacket.java | 63 ++++++++++++++++
.../query/blob/FirebirdOpenBlobCommandPacket.java | 82 +++++++++++++++++++++
.../blob/FirebirdPutBlobSegmentCommandPacket.java | 68 ++++++++++++++++++
.../FirebirdSeekBlobCommandPacket.java} | 41 +++++++----
.../execute/FirebirdExecuteStatementPacket.java | 8 ++-
.../FirebirdBinaryProtocolValueFactory.java | 11 +--
.../protocol/FirebirdByteBinaryProtocolValue.java | 6 +-
.../codec/FirebirdPacketCodecEngineTest.java | 48 ++++++++++---
.../command/FirebirdCommandPacketFactoryTest.java | 69 ++++++++++++++++--
.../query/FirebirdBinaryColumnTypeTest.java | 11 ++-
.../FirebirdCancelBlobCommandPacketTest.java} | 29 +++-----
.../FirebirdCloseBlobCommandPacketTest.java} | 29 +++-----
.../blob/FirebirdCreateBlobCommandPacketTest.java | 76 ++++++++++++++++++++
.../FirebirdGetBlobSegmentCommandPacketTest.java} | 35 +++++----
.../blob/FirebirdOpenBlobCommandPacketTest.java | 69 ++++++++++++++++++
.../FirebirdPutBlobSegmentCommandPacketTest.java} | 40 ++++++-----
.../FirebirdSeekBlobCommandPacketTest.java} | 30 +++-----
.../FirebirdBinaryProtocolValueFactoryTest.java | 11 +--
.../FirebirdByteBinaryProtocolValueTest.java | 13 ++--
.../src/main/antlr4/imports/firebird/BaseRule.g4 | 37 +++++++++-
.../antlr4/imports/firebird/FirebirdKeyword.g4 | 50 ++++++++++++-
.../statement/FirebirdStatementVisitor.java | 32 +++++++++
.../command/FirebirdCommandExecutorFactory.java | 34 ++++++++-
.../blob/FirebirdCancelBlobCommandExecutor.java | 47 ++++++++++++
.../blob/FirebirdCloseBlobCommandExecutor.java | 47 ++++++++++++
.../blob/FirebirdCreateBlobCommandExecutor.java | 47 ++++++++++++
.../FirebirdGetBlobSegmentCommandExecutor.java | 47 ++++++++++++
.../blob/FirebirdOpenBlobCommandExecutor.java | 47 ++++++++++++
.../FirebirdPutBlobSegmentCommandExecutor.java | 47 ++++++++++++
.../blob/FirebirdSeekBlobCommandExecutor.java | 47 ++++++++++++
.../FirebirdCommandExecutorFactoryTest.java | 68 ++++++++++++++++++
.../FirebirdCancelBlobCommandExecutorTest.java | 72 +++++++++++++++++++
.../blob/FirebirdCloseBlobCommandExecutorTest.java | 72 +++++++++++++++++++
.../FirebirdCreateBlobCommandExecutorTest.java | 72 +++++++++++++++++++
.../FirebirdGetBlobSegmentCommandExecutorTest.java | 72 +++++++++++++++++++
.../blob/FirebirdOpenBlobCommandExecutorTest.java | 72 +++++++++++++++++++
.../FirebirdPutBlobSegmentCommandExecutorTest.java | 72 +++++++++++++++++++
.../blob/FirebirdSeekBlobCommandExecutorTest.java | 72 +++++++++++++++++++
.../src/main/resources/case/ddl/create-table.xml | 31 ++++++++
.../resources/sql/supported/ddl/create-table.xml | 4 ++
47 files changed, 1975 insertions(+), 218 deletions(-)
diff --git a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/codec/FirebirdPacketCodecEngine.java b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/codec/FirebirdPacketCodecEngine.java
index 14cbab90fcf..3ef7c118dc0 100644
--- a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/codec/FirebirdPacketCodecEngine.java
+++ b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/codec/FirebirdPacketCodecEngine.java
@@ -76,30 +76,71 @@ public final class FirebirdPacketCodecEngine implements DatabasePacketCodecEngin
}
private void addToBuffer(final ChannelHandlerContext context, final ByteBuf in, final List<Object> out) {
- if (in.writerIndex() == in.capacity()) {
- ByteBuf bufferPart = in.readRetainedSlice(in.readableBytes());
- CompositeByteBuf result = context.alloc().compositeBuffer(pendingMessages.size() + 1);
- result.addComponents(true, pendingMessages).addComponent(true, bufferPart);
- FirebirdPacketPayload payload = new FirebirdPacketPayload(result, context.channel().attr(CommonConstants.CHARSET_ATTRIBUTE_KEY).get());
- if (FirebirdCommandPacketFactory.isValidLength(pendingPacketType, payload, result.readableBytes(), context.channel().attr(FirebirdConstant.CONNECTION_PROTOCOL_VERSION).get())) {
- out.add(result);
- pendingMessages.clear();
- } else {
- pendingMessages.add(bufferPart);
+ if (!in.isReadable()) {
+ return;
+ }
+ ByteBuf buffer = mergePendingMessages(context, in);
+ boolean shouldRelease = buffer != in;
+ try {
+ processPackets(context, buffer, out);
+ } finally {
+ if (shouldRelease) {
+ buffer.release();
}
- } else {
- writePendingMessages(context, in, out);
}
}
- private void writePendingMessages(final ChannelHandlerContext context, final ByteBuf in, final List<Object> out) {
+ private ByteBuf mergePendingMessages(final ChannelHandlerContext context, final ByteBuf in) {
if (pendingMessages.isEmpty()) {
- out.add(in.readRetainedSlice(in.readableBytes()));
- } else {
- CompositeByteBuf result = context.alloc().compositeBuffer(pendingMessages.size() + 1);
- result.addComponents(true, pendingMessages).addComponent(true, in.readRetainedSlice(in.readableBytes()));
- out.add(result);
- pendingMessages.clear();
+ return in;
+ }
+ CompositeByteBuf result = context.alloc().compositeBuffer(pendingMessages.size() + 1);
+ result.addComponents(true, pendingMessages);
+ pendingMessages.clear();
+ result.addComponent(true, in.readRetainedSlice(in.readableBytes()));
+ return result;
+ }
+
+ private void processPackets(final ChannelHandlerContext context, final ByteBuf buffer, final List<Object> out) {
+ Charset charset = context.channel().attr(CommonConstants.CHARSET_ATTRIBUTE_KEY).get();
+ while (buffer.isReadable()) {
+ if (!isValidHeader(buffer.readableBytes())) {
+ pendingMessages.add(buffer.readRetainedSlice(buffer.readableBytes()));
+ return;
+ }
+ int readerIndex = buffer.readerIndex();
+ FirebirdCommandPacketType commandType = FirebirdCommandPacketType.valueOf(buffer.getInt(readerIndex));
+ if (FirebirdCommandPacketType.VOID == commandType) {
+ buffer.skipBytes(MESSAGE_TYPE_LENGTH);
+ continue;
+ }
+ int packetLength = findPacketLength(context, buffer, commandType, charset);
+ if (packetLength < 0) {
+ pendingPacketType = commandType;
+ pendingMessages.add(buffer.readRetainedSlice(buffer.readableBytes()));
+ return;
+ }
+ pendingPacketType = null;
+ out.add(buffer.readRetainedSlice(packetLength));
+ }
+ }
+
+ private int findPacketLength(final ChannelHandlerContext context, final ByteBuf buffer, final FirebirdCommandPacketType commandType, final Charset charset) {
+ int readerIndex = buffer.readerIndex();
+ int readableBytes = buffer.readableBytes();
+ ByteBuf slice = buffer.retainedSlice(readerIndex, readableBytes);
+ try {
+ FirebirdPacketPayload payload = new FirebirdPacketPayload(slice, charset);
+ int expectedLength = FirebirdCommandPacketFactory.getExpectedLength(commandType, payload,
+ context.channel().attr(FirebirdConstant.CONNECTION_PROTOCOL_VERSION).get());
+ if (expectedLength <= 0) {
+ return readableBytes;
+ }
+ return readableBytes >= expectedLength ? expectedLength : -1;
+ } catch (final IndexOutOfBoundsException ex) {
+ return -1;
+ } finally {
+ slice.release();
}
}
diff --git a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/FirebirdCommandPacketFactory.java b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/FirebirdCommandPacketFactory.java
index 31015d7bab1..9254ff7f4ab 100644
--- a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/FirebirdCommandPacketFactory.java
+++ b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/FirebirdCommandPacketFactory.java
@@ -21,6 +21,13 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.database.protocol.firebird.constant.protocol.FirebirdProtocolVersion;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.admin.FirebirdUnsupportedCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdGetBlobSegmentCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdOpenBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdPutBlobSegmentCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdSeekBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdCreateBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdCloseBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdCancelBlobCommandPacket;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.info.FirebirdInfoPacket;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.info.type.database.FirebirdDatabaseInfoPacketType;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.info.type.sql.FirebirdSQLInfoPacketType;
@@ -54,6 +61,22 @@ public final class FirebirdCommandPacketFactory {
return FirebirdDatabaseInfoPacketType.createPacket(payload);
case TRANSACTION:
return new FirebirdStartTransactionPacket(payload);
+ case CREATE_BLOB:
+ case CREATE_BLOB2:
+ return new FirebirdCreateBlobCommandPacket(commandPacketType, payload);
+ case OPEN_BLOB:
+ case OPEN_BLOB2:
+ return new FirebirdOpenBlobCommandPacket(commandPacketType, payload);
+ case GET_SEGMENT:
+ return new FirebirdGetBlobSegmentCommandPacket(payload);
+ case PUT_SEGMENT:
+ return new FirebirdPutBlobSegmentCommandPacket(payload);
+ case CANCEL_BLOB:
+ return new FirebirdCancelBlobCommandPacket(payload);
+ case CLOSE_BLOB:
+ return new FirebirdCloseBlobCommandPacket(payload);
+ case SEEK_BLOB:
+ return new FirebirdSeekBlobCommandPacket(payload);
case ALLOCATE_STATEMENT:
return new FirebirdAllocateStatementPacket(payload);
case PREPARE_STATEMENT:
@@ -77,21 +100,15 @@ public final class FirebirdCommandPacketFactory {
}
/**
- * Validate length of command packet.
+ * Get expected length of command packet including message type.
*
* @param commandPacketType command packet type for Firebird
* @param payload packet payload for Firebird
- * @param capacity maximum allowed capacity
* @param protocolVersion protocol version of Firebird
- * @return true if length is valid, false otherwise
+ * @return expected length of packet, or 0 if length is variable
*/
- public static boolean isValidLength(final FirebirdCommandPacketType commandPacketType, final FirebirdPacketPayload payload, final int capacity, final FirebirdProtocolVersion protocolVersion) {
- try {
- return getLength(commandPacketType, payload, protocolVersion) <= capacity;
- } catch (final IndexOutOfBoundsException ignored) {
- payload.getByteBuf().resetReaderIndex();
- return false;
- }
+ public static int getExpectedLength(final FirebirdCommandPacketType commandPacketType, final FirebirdPacketPayload payload, final FirebirdProtocolVersion protocolVersion) {
+ return getLength(commandPacketType, payload, protocolVersion);
}
private static int getLength(final FirebirdCommandPacketType commandPacketType, final FirebirdPacketPayload payload,
@@ -102,6 +119,22 @@ public final class FirebirdCommandPacketFactory {
return FirebirdInfoPacket.getLength(payload);
case TRANSACTION:
return FirebirdStartTransactionPacket.getLength(payload);
+ case CREATE_BLOB:
+ case CREATE_BLOB2:
+ return FirebirdCreateBlobCommandPacket.getLength(commandPacketType, payload);
+ case OPEN_BLOB:
+ case OPEN_BLOB2:
+ return FirebirdOpenBlobCommandPacket.getLength(commandPacketType, payload);
+ case GET_SEGMENT:
+ return FirebirdGetBlobSegmentCommandPacket.getLength(payload);
+ case PUT_SEGMENT:
+ return FirebirdPutBlobSegmentCommandPacket.getLength(payload);
+ case CANCEL_BLOB:
+ return FirebirdCancelBlobCommandPacket.getLength();
+ case CLOSE_BLOB:
+ return FirebirdCloseBlobCommandPacket.getLength();
+ case SEEK_BLOB:
+ return FirebirdSeekBlobCommandPacket.getLength();
case ALLOCATE_STATEMENT:
return FirebirdAllocateStatementPacket.getLength();
case PREPARE_STATEMENT:
diff --git a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/FirebirdBinaryColumnType.java b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/FirebirdBinaryColumnType.java
index 7bad750d4d8..e5db4101480 100644
--- a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/FirebirdBinaryColumnType.java
+++ b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/FirebirdBinaryColumnType.java
@@ -45,7 +45,7 @@ public enum FirebirdBinaryColumnType implements BinaryColumnType {
DOUBLE(480, 8),
D_FLOAT(530, 8),
TIMESTAMP(510, 8),
- BLOB(520, 255),
+ BLOB(520, 8),
ARRAY(540, 255),
QUAD(550, 4),
TIME(560, 4),
@@ -88,18 +88,15 @@ public enum FirebirdBinaryColumnType implements BinaryColumnType {
// replace VARYING with TEXT when add proper length
JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.CHAR, VARYING);
JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.VARCHAR, VARYING);
- // temp fix for blobs
- JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.LONGVARCHAR, VARYING);
+ JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.LONGVARCHAR, BLOB);
JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.DATE, DATE);
JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.TIME, TIME);
JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.TIMESTAMP, TIMESTAMP);
JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.BINARY, TEXT);
JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.VARBINARY, VARYING);
- // temp fix for blobs
- JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.LONGVARBINARY, VARYING);
+ JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.LONGVARBINARY, BLOB);
JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.NULL, NULL);
- // temp fix for blobs
- JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.BLOB, VARYING);
+ JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.BLOB, BLOB);
JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.BOOLEAN, BOOLEAN);
JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.ARRAY, ARRAY);
JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.TIME_WITH_TIMEZONE, TIME_TZ);
diff --git a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdBlobRegistry.java b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdBlobRegistry.java
new file mode 100644
index 00000000000..329826e6c44
--- /dev/null
+++ b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdBlobRegistry.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
+import java.nio.charset.Charset;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
+
+/**
+ * Registry for the BLOB segment.
+ */
+public final class FirebirdBlobRegistry {
+
+ @Getter
+ @Setter
+ private static byte[] segment;
+
+ /**
+ * Clear the stored segment.
+ */
+ public static void clearSegment() {
+ segment = null;
+ }
+
+ /**
+ * Wrap the current {@code segment} into a temporary {@link FirebirdPacketPayload}.
+ * <p>
+ * Layout: {@code [int length][bytes][zero padding to 4-byte alignment]}.
+ * If no segment is stored, this method returns {@code null}.
+ * </p>
+ *
+ * @param alloc byte buffer allocator to create the backing buffer
+ * @param cs character set used by {@link FirebirdPacketPayload}
+ * @return payload containing the length-prefixed segment or {@code null} if segment is absent
+ */
+ public static FirebirdPacketPayload buildSegmentPayload(final ByteBufAllocator alloc, final Charset cs) {
+ if (segment == null) {
+ return null;
+ }
+ int len = segment.length;
+ // Padding to the next multiple of 4 (result is in the range 0..3).
+ int pad = (4 - (len % 4)) & 0x3;
+ ByteBuf buf = alloc.buffer(4 + len + pad);
+ buf.writeInt(len);
+ buf.writeBytes(segment);
+ if (pad > 0) {
+ buf.writeZero(pad);
+ }
+ return new FirebirdPacketPayload(buf, cs);
+ }
+}
diff --git a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValue.java b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCancelBlobCommandPacket.java
similarity index 58%
copy from database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValue.java
copy to database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCancelBlobCommandPacket.java
index 503f50b5be3..08ad748474a 100644
--- a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValue.java
+++ b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCancelBlobCommandPacket.java
@@ -15,31 +15,36 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.statement.execute.protocol;
+package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob;
+import lombok.Getter;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.FirebirdCommandPacket;
import org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
/**
- * Binary protocol value for byte lenenc for Firebird.
+ * Firebird cancel blob command packet.
*/
-public final class FirebirdByteBinaryProtocolValue implements FirebirdBinaryProtocolValue {
+@Getter
+public final class FirebirdCancelBlobCommandPacket extends FirebirdCommandPacket {
- @Override
- public Object read(final FirebirdPacketPayload payload) {
- return payload.readBuffer();
+ private final int blobHandle;
+
+ public FirebirdCancelBlobCommandPacket(final FirebirdPacketPayload payload) {
+ payload.skipReserved(4);
+ blobHandle = payload.readInt4();
}
@Override
- public void write(final FirebirdPacketPayload payload, final Object value) {
- if (value instanceof String) {
- payload.writeString((String) value);
- } else {
- payload.writeBuffer((byte[]) value);
- }
+ protected void write(final FirebirdPacketPayload payload) {
}
- @Override
- public int getLength(final FirebirdPacketPayload payload) {
- return payload.getBufferLength(payload.getByteBuf().readerIndex());
+ /**
+ * Get length of packet.
+ *
+ * @return length of packet
+ */
+ public static int getLength() {
+ // 4 reserved + blobHandle(4)
+ return 8;
}
}
diff --git a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValue.java b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCloseBlobCommandPacket.java
similarity index 58%
copy from database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValue.java
copy to database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCloseBlobCommandPacket.java
index 503f50b5be3..48ce55a9050 100644
--- a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValue.java
+++ b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCloseBlobCommandPacket.java
@@ -15,31 +15,36 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.statement.execute.protocol;
+package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob;
+import lombok.Getter;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.FirebirdCommandPacket;
import org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
/**
- * Binary protocol value for byte lenenc for Firebird.
+ * Firebird close blob command packet.
*/
-public final class FirebirdByteBinaryProtocolValue implements FirebirdBinaryProtocolValue {
+@Getter
+public final class FirebirdCloseBlobCommandPacket extends FirebirdCommandPacket {
- @Override
- public Object read(final FirebirdPacketPayload payload) {
- return payload.readBuffer();
+ private final int blobHandle;
+
+ public FirebirdCloseBlobCommandPacket(final FirebirdPacketPayload payload) {
+ payload.skipReserved(4);
+ blobHandle = payload.readInt4();
}
@Override
- public void write(final FirebirdPacketPayload payload, final Object value) {
- if (value instanceof String) {
- payload.writeString((String) value);
- } else {
- payload.writeBuffer((byte[]) value);
- }
+ protected void write(final FirebirdPacketPayload payload) {
}
- @Override
- public int getLength(final FirebirdPacketPayload payload) {
- return payload.getBufferLength(payload.getByteBuf().readerIndex());
+ /**
+ * Get length of packet.
+ *
+ * @return length of packet
+ */
+ public static int getLength() {
+ // 4 reserved + blobHandle(4)
+ return 8;
}
}
diff --git a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCreateBlobCommandPacket.java b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCreateBlobCommandPacket.java
new file mode 100644
index 00000000000..7e9907a04d5
--- /dev/null
+++ b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCreateBlobCommandPacket.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob;
+
+import com.google.common.base.Preconditions;
+import io.netty.buffer.ByteBuf;
+import lombok.Getter;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.FirebirdCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.FirebirdCommandPacketType;
+import org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
+
+/**
+ * Firebird create blob command packet.
+ */
+@Getter
+public final class FirebirdCreateBlobCommandPacket extends FirebirdCommandPacket {
+
+ private final byte[] blobParameterBuffer;
+
+ private final int transactionId;
+
+ private final long requestedBlobId;
+
+ public FirebirdCreateBlobCommandPacket(final FirebirdCommandPacketType commandType, final FirebirdPacketPayload payload) {
+ Preconditions.checkArgument(FirebirdCommandPacketType.CREATE_BLOB == commandType
+ || FirebirdCommandPacketType.CREATE_BLOB2 == commandType, "Unsupported blob command type: %s", commandType);
+ payload.skipReserved(4);
+ if (FirebirdCommandPacketType.CREATE_BLOB2 == commandType) {
+ ByteBuf buffer = payload.readBuffer();
+ blobParameterBuffer = new byte[buffer.readableBytes()];
+ buffer.readBytes(blobParameterBuffer);
+ } else {
+ blobParameterBuffer = new byte[0];
+ }
+ transactionId = payload.readInt4();
+ requestedBlobId = payload.readInt8();
+ }
+
+ @Override
+ protected void write(final FirebirdPacketPayload payload) {
+ }
+
+ /**
+ * Get length of packet.
+ *
+ * @param commandType command packet type for Firebird
+ * @param payload Firebird packet payload
+ * @return length of packet
+ */
+ public static int getLength(final FirebirdCommandPacketType commandType, final FirebirdPacketPayload payload) {
+ Preconditions.checkArgument(
+ FirebirdCommandPacketType.CREATE_BLOB == commandType
+ || FirebirdCommandPacketType.CREATE_BLOB2 == commandType,
+ "Unsupported blob command type: %s", commandType);
+ // reserved (4)
+ int length = 4;
+ if (FirebirdCommandPacketType.CREATE_BLOB2 == commandType) {
+ // + blob parameter buffer
+ length += payload.getBufferLength(length);
+ }
+ // transactionId (4)
+ length += 4;
+ // requestedBlobId (8)
+ length += 8;
+ return length;
+ }
+
+}
diff --git a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdGetBlobSegmentCommandPacket.java b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdGetBlobSegmentCommandPacket.java
new file mode 100644
index 00000000000..b534d2144fa
--- /dev/null
+++ b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdGetBlobSegmentCommandPacket.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob;
+
+import io.netty.buffer.ByteBuf;
+import lombok.Getter;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.FirebirdCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
+
+/**
+ * Firebird get blob segment command packet.
+ */
+@Getter
+public final class FirebirdGetBlobSegmentCommandPacket extends FirebirdCommandPacket {
+
+ private final int blobHandle;
+
+ private final int segmentLength;
+
+ private final byte[] segment;
+
+ public FirebirdGetBlobSegmentCommandPacket(final FirebirdPacketPayload payload) {
+ payload.skipReserved(4);
+ blobHandle = payload.readInt4();
+ segmentLength = payload.readInt4();
+ ByteBuf buffer = payload.readBuffer();
+ segment = new byte[buffer.readableBytes()];
+ buffer.readBytes(segment);
+ }
+
+ @Override
+ protected void write(final FirebirdPacketPayload payload) {
+ }
+
+ /**
+ * Get length of packet.
+ *
+ * @param payload Firebird packet payload
+ * @return length of packet
+ */
+ public static int getLength(final FirebirdPacketPayload payload) {
+ // reserved (4) + blob handle (4) + segment length (4)
+ int length = 12;
+ // + segment buffer
+ length += payload.getBufferLength(length);
+ return length;
+ }
+}
diff --git a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdOpenBlobCommandPacket.java b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdOpenBlobCommandPacket.java
new file mode 100644
index 00000000000..4443edb5146
--- /dev/null
+++ b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdOpenBlobCommandPacket.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob;
+
+import com.google.common.base.Preconditions;
+import io.netty.buffer.ByteBuf;
+import lombok.Getter;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.FirebirdCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.FirebirdCommandPacketType;
+import org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
+
+/**
+ * Firebird open blob command packet.
+ */
+@Getter
+public final class FirebirdOpenBlobCommandPacket extends FirebirdCommandPacket {
+
+ private final byte[] blobParameterBuffer;
+
+ private final int transactionId;
+
+ private final long blobId;
+
+ public FirebirdOpenBlobCommandPacket(final FirebirdCommandPacketType commandType, final FirebirdPacketPayload payload) {
+ Preconditions.checkArgument(FirebirdCommandPacketType.OPEN_BLOB == commandType
+ || FirebirdCommandPacketType.OPEN_BLOB2 == commandType, "Unsupported blob command type: %s", commandType);
+ payload.skipReserved(4);
+ if (FirebirdCommandPacketType.OPEN_BLOB2 == commandType) {
+ ByteBuf buffer = payload.readBuffer();
+ blobParameterBuffer = new byte[buffer.readableBytes()];
+ buffer.readBytes(blobParameterBuffer);
+ } else {
+ blobParameterBuffer = new byte[0];
+ }
+ transactionId = payload.readInt4();
+ blobId = payload.readInt8();
+ }
+
+ @Override
+ protected void write(final FirebirdPacketPayload payload) {
+ }
+
+ /**
+ * Get length of packet.
+ *
+ * @param commandType command packet type for Firebird
+ * @param payload Firebird packet payload
+ * @return length of packet
+ */
+ public static int getLength(final FirebirdCommandPacketType commandType, final FirebirdPacketPayload payload) {
+ Preconditions.checkArgument(
+ FirebirdCommandPacketType.OPEN_BLOB == commandType
+ || FirebirdCommandPacketType.OPEN_BLOB2 == commandType,
+ "Unsupported blob command type: %s", commandType);
+ // reserved (4)
+ int length = 4;
+ if (FirebirdCommandPacketType.OPEN_BLOB2 == commandType) {
+ // + blob parameter buffer
+ length += payload.getBufferLength(length);
+ }
+ // transactionId (4)
+ length += 4;
+ // blobId (8)
+ length += 8;
+ return length;
+ }
+}
diff --git a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdPutBlobSegmentCommandPacket.java b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdPutBlobSegmentCommandPacket.java
new file mode 100644
index 00000000000..0268cdb65fb
--- /dev/null
+++ b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdPutBlobSegmentCommandPacket.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob;
+
+import com.google.common.base.Preconditions;
+import io.netty.buffer.ByteBuf;
+import lombok.Getter;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.FirebirdCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
+
+/**
+ * Firebird put blob segment command packet.
+ */
+@Getter
+public final class FirebirdPutBlobSegmentCommandPacket extends FirebirdCommandPacket {
+
+ private final int blobHandle;
+
+ private final byte[] segment;
+
+ private final int segmentLength;
+
+ public FirebirdPutBlobSegmentCommandPacket(final FirebirdPacketPayload payload) {
+ FirebirdBlobRegistry.clearSegment();
+ payload.skipReserved(4);
+ blobHandle = payload.readInt4();
+ segmentLength = payload.readInt4();
+ ByteBuf buffer = payload.readBuffer();
+ segment = new byte[buffer.readableBytes()];
+ buffer.readBytes(segment);
+ Preconditions.checkArgument(segmentLength == segment.length,
+ "Segment length mismatch, expected: %s, actual: %s", segmentLength, segment.length);
+ FirebirdBlobRegistry.setSegment(segment);
+ }
+
+ @Override
+ protected void write(final FirebirdPacketPayload payload) {
+ }
+
+ /**
+ * Get length of packet.
+ *
+ * @param payload Firebird packet payload
+ * @return length of packet
+ */
+ public static int getLength(final FirebirdPacketPayload payload) {
+ // reserved (4) + blob handle (4) + segment length (4)
+ int length = 12;
+ // + segment data
+ length += payload.getBufferLength(length);
+ return length;
+ }
+}
diff --git a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValue.java b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdSeekBlobCommandPacket.java
similarity index 53%
copy from database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValue.java
copy to database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdSeekBlobCommandPacket.java
index 503f50b5be3..f9e846e3c5c 100644
--- a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValue.java
+++ b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdSeekBlobCommandPacket.java
@@ -15,31 +15,42 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.statement.execute.protocol;
+package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob;
+import lombok.Getter;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.FirebirdCommandPacket;
import org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
/**
- * Binary protocol value for byte lenenc for Firebird.
+ * Firebird seek blob command packet.
*/
-public final class FirebirdByteBinaryProtocolValue implements FirebirdBinaryProtocolValue {
+@Getter
+public final class FirebirdSeekBlobCommandPacket extends FirebirdCommandPacket {
- @Override
- public Object read(final FirebirdPacketPayload payload) {
- return payload.readBuffer();
+ private final int blobHandle;
+
+ private final int seekMode;
+
+ private final int offset;
+
+ public FirebirdSeekBlobCommandPacket(final FirebirdPacketPayload payload) {
+ payload.skipReserved(4);
+ blobHandle = payload.readInt4();
+ seekMode = payload.readInt4();
+ offset = payload.readInt4();
}
@Override
- public void write(final FirebirdPacketPayload payload, final Object value) {
- if (value instanceof String) {
- payload.writeString((String) value);
- } else {
- payload.writeBuffer((byte[]) value);
- }
+ protected void write(final FirebirdPacketPayload payload) {
}
- @Override
- public int getLength(final FirebirdPacketPayload payload) {
- return payload.getBufferLength(payload.getByteBuf().readerIndex());
+ /**
+ * Get length of packet.
+ *
+ * @return length of packet
+ */
+ public static int getLength() {
+ // reserved (4) + blob handle (4) + seek mode (4) + offset (4)
+ return 16;
}
}
diff --git a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/FirebirdExecuteStatementPacket.java b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/FirebirdExecuteStatementPacket.java
index 9c28c47e011..005a63bb36b 100644
--- a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/FirebirdExecuteStatementPacket.java
+++ b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/FirebirdExecuteStatementPacket.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.database.protocol.firebird.constant.protocol.Fi
import org.apache.shardingsphere.database.protocol.firebird.packet.command.FirebirdCommandPacket;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.FirebirdCommandPacketType;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.FirebirdBinaryColumnType;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdBlobRegistry;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.statement.execute.protocol.FirebirdBinaryProtocolValue;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.statement.execute.protocol.FirebirdBinaryProtocolValueFactory;
import org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
@@ -80,7 +81,12 @@ public final class FirebirdExecuteStatementPacket extends FirebirdCommandPacket
if (((nullBit >> i % 8) & 1) == 0) {
FirebirdBinaryColumnType parameterType = parameterTypes.get(i);
FirebirdBinaryProtocolValue binaryProtocolValue = FirebirdBinaryProtocolValueFactory.getBinaryProtocolValue(parameterType);
- parameterValues.add(binaryProtocolValue.read(payload));
+ if (parameterType == FirebirdBinaryColumnType.BLOB) {
+ FirebirdPacketPayload blobPayload = FirebirdBlobRegistry.buildSegmentPayload(payload.getByteBuf().alloc(), payload.getCharset());
+ parameterValues.add(blobPayload == null ? null : binaryProtocolValue.read(blobPayload));
+ } else {
+ parameterValues.add(binaryProtocolValue.read(payload));
+ }
} else {
parameterValues.add(null);
}
diff --git a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdBinaryProtocolValueFactory.java b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdBinaryProtocolValueFactory.java
index 5da0bc65707..139187692c2 100644
--- a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdBinaryProtocolValueFactory.java
+++ b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdBinaryProtocolValueFactory.java
@@ -37,7 +37,7 @@ public final class FirebirdBinaryProtocolValueFactory {
static {
setStringBinaryProtocolValue();
- setByteBinaryProtocolValue();
+ // setByteBinaryProtocolValue();
setInt16BinaryProtocolValue();
setInt8BinaryProtocolValue();
setInt4BinaryProtocolValue();
@@ -58,13 +58,14 @@ public final class FirebirdBinaryProtocolValueFactory {
BINARY_PROTOCOL_VALUES.put(FirebirdBinaryColumnType.TEXT, binaryProtocolValue);
BINARY_PROTOCOL_VALUES.put(FirebirdBinaryColumnType.LEGACY_VARYING, binaryProtocolValue);
BINARY_PROTOCOL_VALUES.put(FirebirdBinaryColumnType.LEGACY_TEXT, binaryProtocolValue);
- }
-
- private static void setByteBinaryProtocolValue() {
- FirebirdByteBinaryProtocolValue binaryProtocolValue = new FirebirdByteBinaryProtocolValue();
BINARY_PROTOCOL_VALUES.put(FirebirdBinaryColumnType.BLOB, binaryProtocolValue);
}
+ // TODO Uncomment when a specific handler is required; currently BLOB is handled by StringBinaryProtocolValue
+ // private static void setByteBinaryProtocolValue() {
+ // FirebirdByteBinaryProtocolValue binaryProtocolValue = new FirebirdByteBinaryProtocolValue();
+ // }
+
private static void setInt16BinaryProtocolValue() {
FirebirdInt16BinaryProtocolValue binaryProtocolValue = new FirebirdInt16BinaryProtocolValue();
BINARY_PROTOCOL_VALUES.put(FirebirdBinaryColumnType.INT128, binaryProtocolValue);
diff --git a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValue.java b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValue.java
index 503f50b5be3..810a85eb771 100644
--- a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValue.java
+++ b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValue.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.statement.execute.protocol;
+import io.netty.buffer.ByteBuf;
import org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
/**
@@ -26,7 +27,10 @@ public final class FirebirdByteBinaryProtocolValue implements FirebirdBinaryProt
@Override
public Object read(final FirebirdPacketPayload payload) {
- return payload.readBuffer();
+ ByteBuf buffer = payload.readBuffer();
+ byte[] result = new byte[buffer.readableBytes()];
+ buffer.getBytes(buffer.readerIndex(), result);
+ return result;
}
@Override
diff --git a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/codec/FirebirdPacketCodecEngineTest.java b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/codec/FirebirdPacketCodecEngineTest.java
index 28aa36cef38..546001bec90 100644
--- a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/codec/FirebirdPacketCodecEngineTest.java
+++ b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/codec/FirebirdPacketCodecEngineTest.java
@@ -117,11 +117,15 @@ class FirebirdPacketCodecEngineTest {
void assertDecodeWithPartialPacket() {
ByteBuf in = mock(ByteBuf.class);
ByteBuf slice = mock(ByteBuf.class);
- when(in.readableBytes()).thenReturn(8, 8);
+ ByteBuf payloadSlice = mock(ByteBuf.class);
+ when(in.readableBytes()).thenReturn(8, 8, 8);
when(in.readerIndex()).thenReturn(0);
- when(in.getInt(0)).thenReturn(FirebirdCommandPacketType.TRANSACTION.getValue());
+ when(in.getInt(0)).thenReturn(FirebirdCommandPacketType.INFO_REQUEST.getValue());
when(in.writerIndex()).thenReturn(8);
when(in.capacity()).thenReturn(16);
+ when(in.isReadable()).thenReturn(true, true, false);
+ when(in.retainedSlice(anyInt(), anyInt())).thenReturn(payloadSlice);
+ when(payloadSlice.release()).thenReturn(true);
when(in.readRetainedSlice(8)).thenReturn(slice);
List<Object> out = new LinkedList<>();
new FirebirdPacketCodecEngine().decode(context, in, out);
@@ -137,22 +141,36 @@ class FirebirdPacketCodecEngineTest {
CompositeByteBuf firstComposite = mock(CompositeByteBuf.class, org.mockito.Mockito.RETURNS_SELF);
CompositeByteBuf secondComposite = mock(CompositeByteBuf.class, org.mockito.Mockito.RETURNS_SELF);
when(context.alloc().compositeBuffer(anyInt())).thenReturn(firstComposite, secondComposite);
- when(firstPart.readableBytes()).thenReturn(8, 8);
+ ByteBuf firstPayloadSlice = mock(ByteBuf.class);
+ ByteBuf compositePayloadSlice = mock(ByteBuf.class);
+ ByteBuf compositeOutputSlice = mock(ByteBuf.class);
+ when(firstPart.readableBytes()).thenReturn(8, 8, 8, 8);
when(firstPart.readerIndex()).thenReturn(0);
when(firstPart.getInt(0)).thenReturn(FirebirdCommandPacketType.PREPARE_STATEMENT.getValue());
when(firstPart.writerIndex()).thenReturn(8);
when(firstPart.capacity()).thenReturn(8);
+ when(firstPart.isReadable()).thenReturn(true, true, false);
+ when(firstPart.retainedSlice(anyInt(), anyInt())).thenReturn(firstPayloadSlice);
+ when(firstPayloadSlice.release()).thenReturn(true);
when(firstPart.readRetainedSlice(8)).thenReturn(firstSlice);
- when(secondPart.readableBytes()).thenReturn(4);
+ when(secondPart.readableBytes()).thenReturn(4, 0);
+ when(secondPart.isReadable()).thenReturn(true, false);
when(secondPart.writerIndex()).thenReturn(4);
when(secondPart.capacity()).thenReturn(4);
when(secondPart.readRetainedSlice(4)).thenReturn(secondSlice);
- when(firstComposite.readableBytes()).thenReturn(8);
- when(secondComposite.readableBytes()).thenReturn(12);
+ when(firstComposite.isReadable()).thenReturn(true, false);
+ when(firstComposite.readableBytes()).thenReturn(12, 12, 12);
+ when(firstComposite.readerIndex()).thenReturn(0);
+ when(firstComposite.getInt(0)).thenReturn(FirebirdCommandPacketType.PREPARE_STATEMENT.getValue());
+ when(firstComposite.retainedSlice(anyInt(), anyInt())).thenReturn(compositePayloadSlice);
+ when(compositePayloadSlice.release()).thenReturn(true);
+ when(firstComposite.readRetainedSlice(12)).thenReturn(compositeOutputSlice);
+ when(compositeOutputSlice.readableBytes()).thenReturn(12);
+ when(firstComposite.release()).thenReturn(true);
List<Object> out = new LinkedList<>();
FirebirdPacketCodecEngine codecEngine = new FirebirdPacketCodecEngine();
try (MockedStatic<FirebirdCommandPacketFactory> mocked = mockStatic(FirebirdCommandPacketFactory.class)) {
- mocked.when(() -> FirebirdCommandPacketFactory.isValidLength(any(), any(), anyInt(), any())).thenReturn(false, true);
+ mocked.when(() -> FirebirdCommandPacketFactory.getExpectedLength(any(), any(), any())).thenReturn(12, 12);
codecEngine.decode(context, firstPart, out);
assertTrue(out.isEmpty());
codecEngine.decode(context, secondPart, out);
@@ -167,17 +185,27 @@ class FirebirdPacketCodecEngineTest {
ByteBuf slice = mock(ByteBuf.class);
CompositeByteBuf composite = mock(CompositeByteBuf.class, org.mockito.Mockito.RETURNS_SELF);
when(context.alloc().compositeBuffer(anyInt())).thenReturn(composite);
- when(in.readableBytes()).thenReturn(8, 8);
+ ByteBuf payloadSlice = mock(ByteBuf.class);
+ when(in.readableBytes()).thenReturn(8, 8, 8, 8);
when(in.readerIndex()).thenReturn(0);
when(in.getInt(0)).thenReturn(FirebirdCommandPacketType.PREPARE_STATEMENT.getValue());
when(in.writerIndex()).thenReturn(8);
when(in.capacity()).thenReturn(8);
+ when(in.isReadable()).thenReturn(true, true, false);
+ when(in.retainedSlice(anyInt(), anyInt())).thenReturn(payloadSlice);
+ when(payloadSlice.release()).thenReturn(true);
when(in.readRetainedSlice(8)).thenReturn(slice);
- when(composite.readableBytes()).thenReturn(8);
+ when(composite.isReadable()).thenReturn(true, false);
+ when(composite.readableBytes()).thenReturn(8, 8, 8);
+ when(composite.readerIndex()).thenReturn(0);
+ when(composite.getInt(0)).thenReturn(FirebirdCommandPacketType.PREPARE_STATEMENT.getValue());
+ when(composite.retainedSlice(anyInt(), anyInt())).thenReturn(payloadSlice);
when(slice.readableBytes()).thenReturn(8);
+ when(composite.readRetainedSlice(8)).thenReturn(slice);
+ when(composite.release()).thenReturn(true);
List<Object> out = new LinkedList<>();
try (MockedStatic<FirebirdCommandPacketFactory> mocked = mockStatic(FirebirdCommandPacketFactory.class)) {
- mocked.when(() -> FirebirdCommandPacketFactory.isValidLength(any(), any(), anyInt(), any())).thenReturn(true);
+ mocked.when(() -> FirebirdCommandPacketFactory.getExpectedLength(any(), any(), any())).thenReturn(8);
new FirebirdPacketCodecEngine().decode(context, in, out);
assertThat(out.size(), is(1));
assertThat(((ByteBuf) out.get(0)).readableBytes(), is(8));
diff --git a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/FirebirdCommandPacketFactoryTest.java b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/FirebirdCommandPacketFactoryTest.java
index 01eb1e91db5..30ecfddd646 100644
--- a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/FirebirdCommandPacketFactoryTest.java
+++ b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/FirebirdCommandPacketFactoryTest.java
@@ -19,6 +19,13 @@ package org.apache.shardingsphere.database.protocol.firebird.packet.command;
import org.apache.shardingsphere.database.protocol.firebird.constant.protocol.FirebirdProtocolVersion;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.admin.FirebirdUnsupportedCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdGetBlobSegmentCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdOpenBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdPutBlobSegmentCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdSeekBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdCreateBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdCloseBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdCancelBlobCommandPacket;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.info.FirebirdInfoPacket;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.statement.FirebirdAllocateStatementPacket;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.statement.FirebirdFetchStatementPacket;
@@ -37,7 +44,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.isA;
-import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.hamcrest.CoreMatchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.when;
@@ -57,6 +64,59 @@ class FirebirdCommandPacketFactoryTest {
assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.TRANSACTION, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13), isA(FirebirdStartTransactionPacket.class));
}
+ @Test
+ void assertNewInstanceWithCreateBlob() {
+ when(payload.readInt4()).thenReturn(0);
+ when(payload.readInt8()).thenReturn(0L);
+ assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.CREATE_BLOB, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13),
+ isA(FirebirdCreateBlobCommandPacket.class));
+ }
+
+ @Test
+ void assertNewInstanceWithOpenBlob() {
+ when(payload.readInt4()).thenReturn(0);
+ when(payload.readInt8()).thenReturn(0L);
+ assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.OPEN_BLOB, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13),
+ isA(FirebirdOpenBlobCommandPacket.class));
+ }
+
+ @Test
+ void assertNewInstanceWithGetBlobSegment() {
+ when(payload.readInt4()).thenReturn(0, 0);
+ when(payload.readBuffer()).thenReturn(org.mockito.Mockito.mock(io.netty.buffer.ByteBuf.class));
+ assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.GET_SEGMENT, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13),
+ isA(FirebirdGetBlobSegmentCommandPacket.class));
+ }
+
+ @Test
+ void assertNewInstanceWithPutBlobSegment() {
+ when(payload.readInt4()).thenReturn(0, 0);
+ when(payload.readBuffer()).thenReturn(org.mockito.Mockito.mock(io.netty.buffer.ByteBuf.class));
+ assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.PUT_SEGMENT, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13),
+ isA(FirebirdPutBlobSegmentCommandPacket.class));
+ }
+
+ @Test
+ void assertNewInstanceWithCancelBlob() {
+ when(payload.readInt4()).thenReturn(0);
+ assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.CANCEL_BLOB, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13),
+ isA(FirebirdCancelBlobCommandPacket.class));
+ }
+
+ @Test
+ void assertNewInstanceWithCloseBlob() {
+ when(payload.readInt4()).thenReturn(0);
+ assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.CLOSE_BLOB, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13),
+ isA(FirebirdCloseBlobCommandPacket.class));
+ }
+
+ @Test
+ void assertNewInstanceWithSeekBlob() {
+ when(payload.readInt4()).thenReturn(0, 0, 0);
+ assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.SEEK_BLOB, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13),
+ isA(FirebirdSeekBlobCommandPacket.class));
+ }
+
@Test
void assertNewInstanceWithAllocateStatement() {
assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.ALLOCATE_STATEMENT, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13),
@@ -108,8 +168,9 @@ class FirebirdCommandPacketFactoryTest {
}
@Test
- void assertIsValidLength() {
- assertTrue(FirebirdCommandPacketFactory.isValidLength(FirebirdCommandPacketType.ALLOCATE_STATEMENT, payload, 8, FirebirdProtocolVersion.PROTOCOL_VERSION13));
- assertFalse(FirebirdCommandPacketFactory.isValidLength(FirebirdCommandPacketType.ALLOCATE_STATEMENT, payload, 7, FirebirdProtocolVersion.PROTOCOL_VERSION13));
+ void assertGetExpectedLength() {
+ assertThat(FirebirdCommandPacketFactory.getExpectedLength(FirebirdCommandPacketType.ALLOCATE_STATEMENT, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13),
+ is(FirebirdAllocateStatementPacket.getLength()));
+ assertTrue(FirebirdCommandPacketFactory.getExpectedLength(FirebirdCommandPacketType.CANCEL_BLOB, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13) > 0);
}
}
diff --git a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/FirebirdBinaryColumnTypeTest.java b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/FirebirdBinaryColumnTypeTest.java
index f2163c55578..df68ed3c478 100644
--- a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/FirebirdBinaryColumnTypeTest.java
+++ b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/FirebirdBinaryColumnTypeTest.java
@@ -41,15 +41,15 @@ class FirebirdBinaryColumnTypeTest {
assertThat(FirebirdBinaryColumnType.valueOfJDBCType(Types.DECIMAL), is(FirebirdBinaryColumnType.DECIMAL));
assertThat(FirebirdBinaryColumnType.valueOfJDBCType(Types.CHAR), is(FirebirdBinaryColumnType.VARYING));
assertThat(FirebirdBinaryColumnType.valueOfJDBCType(Types.VARCHAR), is(FirebirdBinaryColumnType.VARYING));
- assertThat(FirebirdBinaryColumnType.valueOfJDBCType(Types.LONGVARCHAR), is(FirebirdBinaryColumnType.VARYING));
+ assertThat(FirebirdBinaryColumnType.valueOfJDBCType(Types.LONGVARCHAR), is(FirebirdBinaryColumnType.BLOB));
assertThat(FirebirdBinaryColumnType.valueOfJDBCType(Types.DATE), is(FirebirdBinaryColumnType.DATE));
assertThat(FirebirdBinaryColumnType.valueOfJDBCType(Types.TIME), is(FirebirdBinaryColumnType.TIME));
assertThat(FirebirdBinaryColumnType.valueOfJDBCType(Types.TIMESTAMP), is(FirebirdBinaryColumnType.TIMESTAMP));
assertThat(FirebirdBinaryColumnType.valueOfJDBCType(Types.BINARY), is(FirebirdBinaryColumnType.TEXT));
assertThat(FirebirdBinaryColumnType.valueOfJDBCType(Types.VARBINARY), is(FirebirdBinaryColumnType.VARYING));
- assertThat(FirebirdBinaryColumnType.valueOfJDBCType(Types.LONGVARBINARY), is(FirebirdBinaryColumnType.VARYING));
+ assertThat(FirebirdBinaryColumnType.valueOfJDBCType(Types.LONGVARBINARY), is(FirebirdBinaryColumnType.BLOB));
assertThat(FirebirdBinaryColumnType.valueOfJDBCType(Types.NULL), is(FirebirdBinaryColumnType.NULL));
- assertThat(FirebirdBinaryColumnType.valueOfJDBCType(Types.BLOB), is(FirebirdBinaryColumnType.VARYING));
+ assertThat(FirebirdBinaryColumnType.valueOfJDBCType(Types.BLOB), is(FirebirdBinaryColumnType.BLOB));
assertThat(FirebirdBinaryColumnType.valueOfJDBCType(Types.BOOLEAN), is(FirebirdBinaryColumnType.BOOLEAN));
assertThat(FirebirdBinaryColumnType.valueOfJDBCType(Types.ARRAY), is(FirebirdBinaryColumnType.ARRAY));
assertThat(FirebirdBinaryColumnType.valueOfJDBCType(Types.TIME_WITH_TIMEZONE), is(FirebirdBinaryColumnType.TIME_TZ));
@@ -98,4 +98,9 @@ class FirebirdBinaryColumnTypeTest {
void assertValueOfWithIllegalArgument() {
assertThrows(IllegalArgumentException.class, () -> FirebirdBinaryColumnType.valueOf(-1));
}
+
+ @Test
+ void assertValueOfJDBCType() {
+ assertThat(FirebirdBinaryColumnType.valueOfJDBCType(Types.BLOB), is(FirebirdBinaryColumnType.BLOB));
+ }
}
diff --git a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCancelBlobCommandPacketTest.java
similarity index 67%
copy from database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java
copy to database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCancelBlobCommandPacketTest.java
index 8eed85a5709..e84582f6040 100644
--- a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java
+++ b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCancelBlobCommandPacketTest.java
@@ -15,9 +15,8 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.statement.execute.protocol;
+package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob;
-import io.netty.buffer.ByteBuf;
import org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -30,30 +29,22 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
-class FirebirdByteBinaryProtocolValueTest {
+class FirebirdCancelBlobCommandPacketTest {
@Mock
private FirebirdPacketPayload payload;
- @Mock
- private ByteBuf byteBuf;
-
- @Test
- void assertRead() {
- when(payload.readBuffer()).thenReturn(byteBuf);
- assertThat(new FirebirdByteBinaryProtocolValue().read(payload), is(byteBuf));
- }
-
@Test
- void assertWriteWithString() {
- new FirebirdByteBinaryProtocolValue().write(payload, "foo");
- verify(payload).writeString("foo");
+ void assertCancelBlobPacket() {
+ when(payload.readInt4()).thenReturn(42);
+ FirebirdCancelBlobCommandPacket packet = new FirebirdCancelBlobCommandPacket(payload);
+ verify(payload).skipReserved(4);
+ verify(payload).readInt4();
+ assertThat(packet.getBlobHandle(), is(42));
}
@Test
- void assertWriteWithBytes() {
- byte[] bytes = {1, 2};
- new FirebirdByteBinaryProtocolValue().write(payload, bytes);
- verify(payload).writeBuffer(bytes);
+ void assertGetLength() {
+ assertThat(FirebirdCancelBlobCommandPacket.getLength(), is(8));
}
}
diff --git a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCloseBlobCommandPacketTest.java
similarity index 67%
copy from database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java
copy to database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCloseBlobCommandPacketTest.java
index 8eed85a5709..20b4c7df442 100644
--- a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java
+++ b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCloseBlobCommandPacketTest.java
@@ -15,9 +15,8 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.statement.execute.protocol;
+package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob;
-import io.netty.buffer.ByteBuf;
import org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -30,30 +29,22 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
-class FirebirdByteBinaryProtocolValueTest {
+class FirebirdCloseBlobCommandPacketTest {
@Mock
private FirebirdPacketPayload payload;
- @Mock
- private ByteBuf byteBuf;
-
- @Test
- void assertRead() {
- when(payload.readBuffer()).thenReturn(byteBuf);
- assertThat(new FirebirdByteBinaryProtocolValue().read(payload), is(byteBuf));
- }
-
@Test
- void assertWriteWithString() {
- new FirebirdByteBinaryProtocolValue().write(payload, "foo");
- verify(payload).writeString("foo");
+ void assertCloseBlobPacket() {
+ when(payload.readInt4()).thenReturn(99);
+ FirebirdCloseBlobCommandPacket packet = new FirebirdCloseBlobCommandPacket(payload);
+ verify(payload).skipReserved(4);
+ verify(payload).readInt4();
+ assertThat(packet.getBlobHandle(), is(99));
}
@Test
- void assertWriteWithBytes() {
- byte[] bytes = {1, 2};
- new FirebirdByteBinaryProtocolValue().write(payload, bytes);
- verify(payload).writeBuffer(bytes);
+ void assertGetLength() {
+ assertThat(FirebirdCloseBlobCommandPacket.getLength(), is(8));
}
}
diff --git a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCreateBlobCommandPacketTest.java b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCreateBlobCommandPacketTest.java
new file mode 100644
index 00000000000..de5ee57517d
--- /dev/null
+++ b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCreateBlobCommandPacketTest.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob;
+
+import io.netty.buffer.Unpooled;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.FirebirdCommandPacketType;
+import org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+class FirebirdCreateBlobCommandPacketTest {
+
+ @Mock
+ private FirebirdPacketPayload payload;
+
+ @Test
+ void assertCreateBlobPacketWithoutBpb() {
+ when(payload.readInt4()).thenReturn(42);
+ when(payload.readInt8()).thenReturn(0x0102030405060708L);
+ FirebirdCreateBlobCommandPacket packet = new FirebirdCreateBlobCommandPacket(FirebirdCommandPacketType.CREATE_BLOB, payload);
+ verify(payload).skipReserved(4);
+ verify(payload, never()).readBuffer();
+ assertThat(packet.getTransactionId(), is(42));
+ assertThat(packet.getRequestedBlobId(), is(0x0102030405060708L));
+ assertThat(packet.getBlobParameterBuffer().length, is(0));
+ }
+
+ @Test
+ void assertCreateBlobPacketWithBpb() {
+ when(payload.readBuffer()).thenReturn(Unpooled.wrappedBuffer(new byte[]{1, 2, 3, 4}));
+ when(payload.readInt4()).thenReturn(7);
+ when(payload.readInt8()).thenReturn(11L);
+ FirebirdCreateBlobCommandPacket packet = new FirebirdCreateBlobCommandPacket(FirebirdCommandPacketType.CREATE_BLOB2, payload);
+ verify(payload).skipReserved(4);
+ verify(payload).readBuffer();
+ assertThat(packet.getTransactionId(), is(7));
+ assertThat(packet.getRequestedBlobId(), is(11L));
+ assertThat(packet.getBlobParameterBuffer(), is(new byte[]{1, 2, 3, 4}));
+ }
+
+ @Test
+ void assertGetLengthWithoutBpb() {
+ assertThat(FirebirdCreateBlobCommandPacket.getLength(FirebirdCommandPacketType.CREATE_BLOB, payload), is(16));
+ }
+
+ @Test
+ void assertGetLengthWithBpb() {
+ when(payload.getBufferLength(4)).thenReturn(12);
+ assertThat(FirebirdCreateBlobCommandPacket.getLength(FirebirdCommandPacketType.CREATE_BLOB2, payload), is(28));
+ verify(payload).getBufferLength(4);
+ }
+}
diff --git a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdGetBlobSegmentCommandPacketTest.java
similarity index 62%
copy from database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java
copy to database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdGetBlobSegmentCommandPacketTest.java
index 8eed85a5709..798dd8c8eb1 100644
--- a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java
+++ b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdGetBlobSegmentCommandPacketTest.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.statement.execute.protocol;
+package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob;
-import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -30,30 +30,27 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
-class FirebirdByteBinaryProtocolValueTest {
+class FirebirdGetBlobSegmentCommandPacketTest {
@Mock
private FirebirdPacketPayload payload;
- @Mock
- private ByteBuf byteBuf;
-
- @Test
- void assertRead() {
- when(payload.readBuffer()).thenReturn(byteBuf);
- assertThat(new FirebirdByteBinaryProtocolValue().read(payload), is(byteBuf));
- }
-
@Test
- void assertWriteWithString() {
- new FirebirdByteBinaryProtocolValue().write(payload, "foo");
- verify(payload).writeString("foo");
+ void assertGetBlobSegmentPacket() {
+ when(payload.readInt4()).thenReturn(11, 3);
+ when(payload.readBuffer()).thenReturn(Unpooled.wrappedBuffer(new byte[]{1, 2, 3}));
+ FirebirdGetBlobSegmentCommandPacket packet = new FirebirdGetBlobSegmentCommandPacket(payload);
+ verify(payload).skipReserved(4);
+ verify(payload).readBuffer();
+ assertThat(packet.getBlobHandle(), is(11));
+ assertThat(packet.getSegmentLength(), is(3));
+ assertThat(packet.getSegment(), is(new byte[]{1, 2, 3}));
}
@Test
- void assertWriteWithBytes() {
- byte[] bytes = {1, 2};
- new FirebirdByteBinaryProtocolValue().write(payload, bytes);
- verify(payload).writeBuffer(bytes);
+ void assertGetLength() {
+ when(payload.getBufferLength(12)).thenReturn(5);
+ assertThat(FirebirdGetBlobSegmentCommandPacket.getLength(payload), is(17));
+ verify(payload).getBufferLength(12);
}
}
diff --git a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdOpenBlobCommandPacketTest.java b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdOpenBlobCommandPacketTest.java
new file mode 100644
index 00000000000..79b04b7f77d
--- /dev/null
+++ b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdOpenBlobCommandPacketTest.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob;
+
+import io.netty.buffer.Unpooled;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.FirebirdCommandPacketType;
+import org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+class FirebirdOpenBlobCommandPacketTest {
+
+ @Mock
+ private FirebirdPacketPayload payload;
+
+ @Test
+ void assertOpenBlobPacketWithoutBpb() {
+ when(payload.readInt4()).thenReturn(5);
+ when(payload.readInt8()).thenReturn(7L);
+ FirebirdOpenBlobCommandPacket packet = new FirebirdOpenBlobCommandPacket(FirebirdCommandPacketType.OPEN_BLOB, payload);
+ verify(payload).skipReserved(4);
+ verify(payload, never()).readBuffer();
+ assertThat(packet.getBlobParameterBuffer().length, is(0));
+ assertThat(packet.getTransactionId(), is(5));
+ assertThat(packet.getBlobId(), is(7L));
+ }
+
+ @Test
+ void assertOpenBlobPacketWithBpb() {
+ when(payload.readBuffer()).thenReturn(Unpooled.wrappedBuffer(new byte[]{4, 5, 6}));
+ when(payload.readInt4()).thenReturn(9);
+ when(payload.readInt8()).thenReturn(12L);
+ FirebirdOpenBlobCommandPacket packet = new FirebirdOpenBlobCommandPacket(FirebirdCommandPacketType.OPEN_BLOB2, payload);
+ verify(payload).skipReserved(4);
+ verify(payload).readBuffer();
+ assertThat(packet.getBlobParameterBuffer(), is(new byte[]{4, 5, 6}));
+ assertThat(packet.getTransactionId(), is(9));
+ assertThat(packet.getBlobId(), is(12L));
+ }
+
+ @Test
+ void assertGetLengthWithoutBpb() {
+ assertThat(FirebirdOpenBlobCommandPacket.getLength(FirebirdCommandPacketType.OPEN_BLOB, payload), is(16));
+ }
+}
diff --git a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdPutBlobSegmentCommandPacketTest.java
similarity index 59%
copy from database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java
copy to database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdPutBlobSegmentCommandPacketTest.java
index 8eed85a5709..1d056a829f0 100644
--- a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java
+++ b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdPutBlobSegmentCommandPacketTest.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.statement.execute.protocol;
+package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob;
-import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -26,34 +26,36 @@ import org.mockito.junit.jupiter.MockitoExtension;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
-class FirebirdByteBinaryProtocolValueTest {
+class FirebirdPutBlobSegmentCommandPacketTest {
@Mock
private FirebirdPacketPayload payload;
- @Mock
- private ByteBuf byteBuf;
-
- @Test
- void assertRead() {
- when(payload.readBuffer()).thenReturn(byteBuf);
- assertThat(new FirebirdByteBinaryProtocolValue().read(payload), is(byteBuf));
- }
-
@Test
- void assertWriteWithString() {
- new FirebirdByteBinaryProtocolValue().write(payload, "foo");
- verify(payload).writeString("foo");
+ void assertPutBlobSegmentPacket() {
+ when(payload.readInt4()).thenReturn(15, 3);
+ when(payload.readBuffer()).thenReturn(Unpooled.wrappedBuffer(new byte[]{5, 6, 7}));
+ final FirebirdPutBlobSegmentCommandPacket packet = new FirebirdPutBlobSegmentCommandPacket(payload);
+
+ verify(payload).skipReserved(4);
+ verify(payload, times(2)).readInt4();
+ verify(payload).readBuffer();
+
+ assertThat(packet.getBlobHandle(), is(15));
+ assertThat(packet.getSegmentLength(), is(3));
+ assertThat(packet.getSegment(), is(new byte[]{5, 6, 7}));
+
}
@Test
- void assertWriteWithBytes() {
- byte[] bytes = {1, 2};
- new FirebirdByteBinaryProtocolValue().write(payload, bytes);
- verify(payload).writeBuffer(bytes);
+ void assertGetLength() {
+ when(payload.getBufferLength(12)).thenReturn(20);
+ assertThat(FirebirdPutBlobSegmentCommandPacket.getLength(payload), is(32));
+ verify(payload).getBufferLength(12);
}
}
diff --git a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdSeekBlobCommandPacketTest.java
similarity index 67%
copy from database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java
copy to database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdSeekBlobCommandPacketTest.java
index 8eed85a5709..8a1fec0e3e5 100644
--- a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java
+++ b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdSeekBlobCommandPacketTest.java
@@ -15,9 +15,8 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.statement.execute.protocol;
+package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob;
-import io.netty.buffer.ByteBuf;
import org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -30,30 +29,23 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
-class FirebirdByteBinaryProtocolValueTest {
+class FirebirdSeekBlobCommandPacketTest {
@Mock
private FirebirdPacketPayload payload;
- @Mock
- private ByteBuf byteBuf;
-
- @Test
- void assertRead() {
- when(payload.readBuffer()).thenReturn(byteBuf);
- assertThat(new FirebirdByteBinaryProtocolValue().read(payload), is(byteBuf));
- }
-
@Test
- void assertWriteWithString() {
- new FirebirdByteBinaryProtocolValue().write(payload, "foo");
- verify(payload).writeString("foo");
+ void assertSeekBlobPacket() {
+ when(payload.readInt4()).thenReturn(21, 2, 128);
+ FirebirdSeekBlobCommandPacket packet = new FirebirdSeekBlobCommandPacket(payload);
+ verify(payload).skipReserved(4);
+ assertThat(packet.getBlobHandle(), is(21));
+ assertThat(packet.getSeekMode(), is(2));
+ assertThat(packet.getOffset(), is(128));
}
@Test
- void assertWriteWithBytes() {
- byte[] bytes = {1, 2};
- new FirebirdByteBinaryProtocolValue().write(payload, bytes);
- verify(payload).writeBuffer(bytes);
+ void assertGetLength() {
+ assertThat(FirebirdSeekBlobCommandPacket.getLength(), is(16));
}
}
diff --git a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdBinaryProtocolValueFactoryTest.java b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdBinaryProtocolValueFactoryTest.java
index 98bce03f474..7f2cdad7c82 100644
--- a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdBinaryProtocolValueFactoryTest.java
+++ b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdBinaryProtocolValueFactoryTest.java
@@ -32,11 +32,12 @@ class FirebirdBinaryProtocolValueFactoryTest {
assertThat(actual, isA(FirebirdStringBinaryProtocolValue.class));
}
- @Test
- void assertGetByteBinaryProtocolValue() {
- FirebirdBinaryProtocolValue actual = FirebirdBinaryProtocolValueFactory.getBinaryProtocolValue(FirebirdBinaryColumnType.BLOB);
- assertThat(actual, isA(FirebirdByteBinaryProtocolValue.class));
- }
+ // TODO Uncomment when a specific handler is required; currently BLOB is handled by StringBinaryProtocolValue
+ // @Test
+ // void assertGetByteBinaryProtocolValue() {
+ // FirebirdBinaryProtocolValue actual = FirebirdBinaryProtocolValueFactory.getBinaryProtocolValue(FirebirdBinaryColumnType.BLOB);
+ // assertThat(actual, isA(FirebirdByteBinaryProtocolValue.class));
+ // }
@Test
void assertGetInt16BinaryProtocolValue() {
diff --git a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java
index 8eed85a5709..0019866830f 100644
--- a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java
+++ b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java
@@ -17,15 +17,14 @@
package org.apache.shardingsphere.database.protocol.firebird.packet.command.query.statement.execute.protocol;
-import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -35,13 +34,11 @@ class FirebirdByteBinaryProtocolValueTest {
@Mock
private FirebirdPacketPayload payload;
- @Mock
- private ByteBuf byteBuf;
-
@Test
void assertRead() {
- when(payload.readBuffer()).thenReturn(byteBuf);
- assertThat(new FirebirdByteBinaryProtocolValue().read(payload), is(byteBuf));
+ byte[] expected = {1, 2};
+ when(payload.readBuffer()).thenReturn(Unpooled.wrappedBuffer(expected));
+ assertArrayEquals(expected, (byte[]) new FirebirdByteBinaryProtocolValue().read(payload));
}
@Test
diff --git a/parser/sql/engine/dialect/firebird/src/main/antlr4/imports/firebird/BaseRule.g4 b/parser/sql/engine/dialect/firebird/src/main/antlr4/imports/firebird/BaseRule.g4
index 3be4a9a7e88..602ef184bc1 100644
--- a/parser/sql/engine/dialect/firebird/src/main/antlr4/imports/firebird/BaseRule.g4
+++ b/parser/sql/engine/dialect/firebird/src/main/antlr4/imports/firebird/BaseRule.g4
@@ -431,7 +431,8 @@ optimizeClause
;
dataType
- : dataTypeName dataTypeLength? characterSet? collateClause?
+ : blobDataType
+ | dataTypeName dataTypeLength? characterSet? collateClause?
| dataTypeName LP_ STRING_ (COMMA_ STRING_)* RP_ characterSet? collateClause?
| dataTypeName LBT_ (NUMBER_? COLON_ NUMBER | NUMBER_ (COMMA_ NUMBER_)*) RBT_
;
@@ -439,10 +440,42 @@ dataType
dataTypeName
: CHARACTER | CHARACTER VARYING | CHAR VARYING | NATIONAL CHARACTER | NATIONAL CHARACTER VARYING | CHAR | VARCHAR | NCHAR
| NATIONAL CHAR | NATIONAL CHAR VARYING | BIT | BIT VARYING | NUMERIC | DECIMAL | DEC | INTEGER | SMALLINT | BOOLEAN
- | FLOAT | REAL | DOUBLE PRECISION | DATE | TIME | TIMESTAMP | INTERVAL | TIME WITH TIME ZONE | TIMESTAMP WITH TIME ZONE
+ | FLOAT | REAL | DOUBLE PRECISION | DATE | TIME | TIMESTAMP | INTERVAL | TIME WITH TIME ZONE | TIMESTAMP WITH TIME ZONE | BLOB
| identifier
;
+blobDataType
+ : BLOB blobSubTypeDefinition? blobSegmentSizeClause? characterSet?
+ | BLOB (LP_ blobAbbreviatedAttributes RP_)?
+ ;
+
+blobSubTypeDefinition
+ : SUB_TYPE blobSubType
+ ;
+
+blobSegmentSizeClause
+ : SEGMENT SIZE NUMBER_
+ ;
+
+blobAbbreviatedAttributes
+ : NUMBER_
+ | NUMBER_ COMMA_ blobSubType
+ | COMMA_ blobSubType
+ ;
+
+blobSubType
+ : blobSubTypeName
+ | blobSubTypeNumber
+ ;
+
+blobSubTypeName
+ : BINARY | TEXT | BLR | ACL | RANGES | SUMMARY | FORMAT | TRANSACTION_DESCRIPTION | EXTERNAL_FILE_DESCRIPTION
+ ;
+
+blobSubTypeNumber
+ : NUMBER_
+ ;
+
dataTypeLength
: LP_ NUMBER_ (COMMA_ NUMBER_)? RP_
;
diff --git a/parser/sql/engine/dialect/firebird/src/main/antlr4/imports/firebird/FirebirdKeyword.g4 b/parser/sql/engine/dialect/firebird/src/main/antlr4/imports/firebird/FirebirdKeyword.g4
index e3c6450452c..238b894e458 100644
--- a/parser/sql/engine/dialect/firebird/src/main/antlr4/imports/firebird/FirebirdKeyword.g4
+++ b/parser/sql/engine/dialect/firebird/src/main/antlr4/imports/firebird/FirebirdKeyword.g4
@@ -993,4 +993,52 @@ OPTIMIZE
GEN_ID
: G E N UL_ I D
- ;
\ No newline at end of file
+ ;
+
+BLOB
+ : B L O B
+ ;
+
+SUB_TYPE
+ : S U B UL_ T Y P E
+ ;
+
+SEGMENT
+ : S E G M E N T
+ ;
+
+BINARY
+ : B I N A R Y
+ ;
+
+TEXT
+ : T E X T
+ ;
+
+BLR
+ : B L R
+ ;
+
+ACL
+ : A C L
+ ;
+
+RANGES
+ : R A N G E S
+ ;
+
+SUMMARY
+ : S U M M A R Y
+ ;
+
+FORMAT
+ : F O R M A T
+ ;
+
+TRANSACTION_DESCRIPTION
+ : T R A N S A C T I O N UL_ D E S C R I P T I O N
+ ;
+
+EXTERNAL_FILE_DESCRIPTION
+ : E X T E R N A L UL_ F I L E UL_ D E S C R I P T I O N
+ ;
diff --git a/parser/sql/engine/dialect/firebird/src/main/java/org/apache/shardingsphere/sql/parser/engine/firebird/visitor/statement/FirebirdStatementVisitor.java b/parser/sql/engine/dialect/firebird/src/main/java/org/apache/shardingsphere/sql/parser/engine/firebird/visitor/statement/FirebirdStatementVisitor.java
index 1c1c82759c2..724be9bdbeb 100644
--- a/parser/sql/engine/dialect/firebird/src/main/java/org/apache/shardingsphere/sql/parser/engine/firebird/visitor/statement/FirebirdStatementVisitor.java
+++ b/parser/sql/engine/dialect/firebird/src/main/java/org/apache/shardingsphere/sql/parser/engine/firebird/visitor/statement/FirebirdStatementVisitor.java
@@ -41,6 +41,7 @@ import org.apache.shardingsphere.sql.parser.autogen.FirebirdStatementParser.CteC
import org.apache.shardingsphere.sql.parser.autogen.FirebirdStatementParser.DataTypeContext;
import org.apache.shardingsphere.sql.parser.autogen.FirebirdStatementParser.DataTypeLengthContext;
import org.apache.shardingsphere.sql.parser.autogen.FirebirdStatementParser.DataTypeNameContext;
+import org.apache.shardingsphere.sql.parser.autogen.FirebirdStatementParser.BlobDataTypeContext;
import org.apache.shardingsphere.sql.parser.autogen.FirebirdStatementParser.ExprContext;
import org.apache.shardingsphere.sql.parser.autogen.FirebirdStatementParser.FunctionCallContext;
import org.apache.shardingsphere.sql.parser.autogen.FirebirdStatementParser.GenIdFunctionContext;
@@ -597,6 +598,9 @@ public abstract class FirebirdStatementVisitor extends FirebirdStatementBaseVisi
@Override
public final ASTNode visitDataType(final DataTypeContext ctx) {
+ if (null != ctx.blobDataType()) {
+ return visitBlobDataType(ctx.blobDataType());
+ }
DataTypeSegment result = new DataTypeSegment();
result.setDataTypeName(((KeywordValue) visit(ctx.dataTypeName())).getValue());
result.setStartIndex(ctx.start.getStartIndex());
@@ -608,6 +612,34 @@ public abstract class FirebirdStatementVisitor extends FirebirdStatementBaseVisi
return result;
}
+ @Override
+ public final ASTNode visitBlobDataType(final BlobDataTypeContext ctx) {
+ DataTypeSegment result = new DataTypeSegment();
+ result.setStartIndex(ctx.start.getStartIndex());
+ result.setStopIndex(ctx.stop.getStopIndex());
+ result.setDataTypeName(buildBlobDataTypeName(ctx));
+ return result;
+ }
+
+ private String buildBlobDataTypeName(final BlobDataTypeContext ctx) {
+ StringBuilder result = new StringBuilder(ctx.BLOB().getText());
+ appendClause(result, ctx.blobSubTypeDefinition());
+ appendClause(result, ctx.blobSegmentSizeClause());
+ appendClause(result, ctx.characterSet());
+ if (null != ctx.blobAbbreviatedAttributes()) {
+ result.append(" (")
+ .append(getOriginalText(ctx.blobAbbreviatedAttributes()).trim())
+ .append(')');
+ }
+ return result.toString();
+ }
+
+ private void appendClause(final StringBuilder builder, final ParserRuleContext ctx) {
+ if (null != ctx) {
+ builder.append(' ').append(getOriginalText(ctx).trim());
+ }
+ }
+
@Override
public final ASTNode visitDataTypeLength(final DataTypeLengthContext ctx) {
DataTypeLengthSegment result = new DataTypeLengthSegment();
diff --git a/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/FirebirdCommandExecutorFactory.java b/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/FirebirdCommandExecutorFactory.java
index 13e17fefd6d..1ec5d964c68 100644
--- a/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/FirebirdCommandExecutorFactory.java
+++ b/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/FirebirdCommandExecutorFactory.java
@@ -20,6 +20,13 @@ package org.apache.shardingsphere.proxy.frontend.firebird.command;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.FirebirdCommandPacketType;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdGetBlobSegmentCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdOpenBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdPutBlobSegmentCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdSeekBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdCreateBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdCloseBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdCancelBlobCommandPacket;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.info.FirebirdInfoPacket;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.statement.FirebirdAllocateStatementPacket;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.statement.FirebirdFetchStatementPacket;
@@ -32,6 +39,13 @@ import org.apache.shardingsphere.database.protocol.firebird.packet.command.query
import org.apache.shardingsphere.database.protocol.packet.command.CommandPacket;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob.FirebirdCancelBlobCommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob.FirebirdCloseBlobCommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob.FirebirdCreateBlobCommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob.FirebirdGetBlobSegmentCommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob.FirebirdOpenBlobCommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob.FirebirdPutBlobSegmentCommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob.FirebirdSeekBlobCommandExecutor;
import org.apache.shardingsphere.proxy.frontend.firebird.command.admin.FirebirdUnsupportedCommandExecutor;
import org.apache.shardingsphere.proxy.frontend.firebird.command.query.info.FirebirdDatabaseInfoExecutor;
import org.apache.shardingsphere.proxy.frontend.firebird.command.query.info.FirebirdSQLInfoExecutor;
@@ -55,8 +69,8 @@ public final class FirebirdCommandExecutorFactory {
/**
* Create new instance of command executor.
*
- * @param commandPacketType command packet type for PostgreSQL
- * @param commandPacket command packet for PostgreSQL
+ * @param commandPacketType command packet type for Firebird
+ * @param commandPacket command packet for Firebird
* @param connectionSession connection session
* @return created instance
* @throws SQLException SQL exception
@@ -68,6 +82,22 @@ public final class FirebirdCommandExecutorFactory {
return new FirebirdDatabaseInfoExecutor((FirebirdInfoPacket) commandPacket, connectionSession);
case TRANSACTION:
return new FirebirdStartTransactionCommandExecutor((FirebirdStartTransactionPacket) commandPacket, connectionSession);
+ case CREATE_BLOB:
+ case CREATE_BLOB2:
+ return new FirebirdCreateBlobCommandExecutor((FirebirdCreateBlobCommandPacket) commandPacket, connectionSession);
+ case OPEN_BLOB:
+ case OPEN_BLOB2:
+ return new FirebirdOpenBlobCommandExecutor((FirebirdOpenBlobCommandPacket) commandPacket, connectionSession);
+ case GET_SEGMENT:
+ return new FirebirdGetBlobSegmentCommandExecutor((FirebirdGetBlobSegmentCommandPacket) commandPacket, connectionSession);
+ case PUT_SEGMENT:
+ return new FirebirdPutBlobSegmentCommandExecutor((FirebirdPutBlobSegmentCommandPacket) commandPacket, connectionSession);
+ case CANCEL_BLOB:
+ return new FirebirdCancelBlobCommandExecutor((FirebirdCancelBlobCommandPacket) commandPacket, connectionSession);
+ case CLOSE_BLOB:
+ return new FirebirdCloseBlobCommandExecutor((FirebirdCloseBlobCommandPacket) commandPacket, connectionSession);
+ case SEEK_BLOB:
+ return new FirebirdSeekBlobCommandExecutor((FirebirdSeekBlobCommandPacket) commandPacket, connectionSession);
case ALLOCATE_STATEMENT:
return new FirebirdAllocateStatementCommandExecutor((FirebirdAllocateStatementPacket) commandPacket, connectionSession);
case PREPARE_STATEMENT:
diff --git a/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdCancelBlobCommandExecutor.java b/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdCancelBlobCommandExecutor.java
new file mode 100644
index 00000000000..58d585efd7e
--- /dev/null
+++ b/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdCancelBlobCommandExecutor.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob;
+
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdCancelBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.generic.FirebirdGenericResponsePacket;
+import org.apache.shardingsphere.database.protocol.packet.DatabasePacket;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.statement.FirebirdStatementIdGenerator;
+
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * Cancel blob command executor for Firebird.
+ */
+@RequiredArgsConstructor
+public final class FirebirdCancelBlobCommandExecutor implements CommandExecutor {
+
+ private final FirebirdCancelBlobCommandPacket packet;
+
+ private final ConnectionSession connectionSession;
+
+ @Override
+ public Collection<DatabasePacket> execute() throws SQLException {
+ int statementId = FirebirdStatementIdGenerator.getInstance().nextStatementId(connectionSession.getConnectionId());
+ return Collections.singleton(new FirebirdGenericResponsePacket().setHandle(statementId));
+ }
+}
diff --git a/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdCloseBlobCommandExecutor.java b/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdCloseBlobCommandExecutor.java
new file mode 100644
index 00000000000..22adb74cb1a
--- /dev/null
+++ b/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdCloseBlobCommandExecutor.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob;
+
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdCloseBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.generic.FirebirdGenericResponsePacket;
+import org.apache.shardingsphere.database.protocol.packet.DatabasePacket;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.statement.FirebirdStatementIdGenerator;
+
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * Close blob command executor for Firebird.
+ */
+@RequiredArgsConstructor
+public final class FirebirdCloseBlobCommandExecutor implements CommandExecutor {
+
+ private final FirebirdCloseBlobCommandPacket packet;
+
+ private final ConnectionSession connectionSession;
+
+ @Override
+ public Collection<DatabasePacket> execute() throws SQLException {
+ int statementId = FirebirdStatementIdGenerator.getInstance().nextStatementId(connectionSession.getConnectionId());
+ return Collections.singleton(new FirebirdGenericResponsePacket().setHandle(statementId));
+ }
+}
diff --git a/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdCreateBlobCommandExecutor.java b/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdCreateBlobCommandExecutor.java
new file mode 100644
index 00000000000..3e1797111de
--- /dev/null
+++ b/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdCreateBlobCommandExecutor.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob;
+
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdCreateBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.generic.FirebirdGenericResponsePacket;
+import org.apache.shardingsphere.database.protocol.packet.DatabasePacket;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.statement.FirebirdStatementIdGenerator;
+
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * Create blob command executor for Firebird.
+ */
+@RequiredArgsConstructor
+public final class FirebirdCreateBlobCommandExecutor implements CommandExecutor {
+
+ private final FirebirdCreateBlobCommandPacket packet;
+
+ private final ConnectionSession connectionSession;
+
+ @Override
+ public Collection<DatabasePacket> execute() throws SQLException {
+ int statementId = FirebirdStatementIdGenerator.getInstance().nextStatementId(connectionSession.getConnectionId());
+ return Collections.singleton(new FirebirdGenericResponsePacket().setHandle(statementId));
+ }
+}
diff --git a/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdGetBlobSegmentCommandExecutor.java b/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdGetBlobSegmentCommandExecutor.java
new file mode 100644
index 00000000000..452f3cd2141
--- /dev/null
+++ b/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdGetBlobSegmentCommandExecutor.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob;
+
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdGetBlobSegmentCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.generic.FirebirdGenericResponsePacket;
+import org.apache.shardingsphere.database.protocol.packet.DatabasePacket;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.statement.FirebirdStatementIdGenerator;
+
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * Get blob segment command executor for Firebird.
+ */
+@RequiredArgsConstructor
+public final class FirebirdGetBlobSegmentCommandExecutor implements CommandExecutor {
+
+ private final FirebirdGetBlobSegmentCommandPacket packet;
+
+ private final ConnectionSession connectionSession;
+
+ @Override
+ public Collection<DatabasePacket> execute() throws SQLException {
+ int statementId = FirebirdStatementIdGenerator.getInstance().nextStatementId(connectionSession.getConnectionId());
+ return Collections.singleton(new FirebirdGenericResponsePacket().setHandle(statementId));
+ }
+}
diff --git a/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdOpenBlobCommandExecutor.java b/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdOpenBlobCommandExecutor.java
new file mode 100644
index 00000000000..6a7ebe87cf1
--- /dev/null
+++ b/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdOpenBlobCommandExecutor.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob;
+
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdOpenBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.generic.FirebirdGenericResponsePacket;
+import org.apache.shardingsphere.database.protocol.packet.DatabasePacket;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.statement.FirebirdStatementIdGenerator;
+
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * Open blob command executor for Firebird.
+ */
+@RequiredArgsConstructor
+public final class FirebirdOpenBlobCommandExecutor implements CommandExecutor {
+
+ private final FirebirdOpenBlobCommandPacket packet;
+
+ private final ConnectionSession connectionSession;
+
+ @Override
+ public Collection<DatabasePacket> execute() throws SQLException {
+ int statementId = FirebirdStatementIdGenerator.getInstance().nextStatementId(connectionSession.getConnectionId());
+ return Collections.singleton(new FirebirdGenericResponsePacket().setHandle(statementId));
+ }
+}
diff --git a/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdPutBlobSegmentCommandExecutor.java b/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdPutBlobSegmentCommandExecutor.java
new file mode 100644
index 00000000000..0dd6703524d
--- /dev/null
+++ b/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdPutBlobSegmentCommandExecutor.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob;
+
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdPutBlobSegmentCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.generic.FirebirdGenericResponsePacket;
+import org.apache.shardingsphere.database.protocol.packet.DatabasePacket;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.statement.FirebirdStatementIdGenerator;
+
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * Put blob segment command executor for Firebird.
+ */
+@RequiredArgsConstructor
+public final class FirebirdPutBlobSegmentCommandExecutor implements CommandExecutor {
+
+ private final FirebirdPutBlobSegmentCommandPacket packet;
+
+ private final ConnectionSession connectionSession;
+
+ @Override
+ public Collection<DatabasePacket> execute() throws SQLException {
+ int statementId = FirebirdStatementIdGenerator.getInstance().nextStatementId(connectionSession.getConnectionId());
+ return Collections.singleton(new FirebirdGenericResponsePacket().setHandle(statementId));
+ }
+}
diff --git a/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdSeekBlobCommandExecutor.java b/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdSeekBlobCommandExecutor.java
new file mode 100644
index 00000000000..4c2ac075573
--- /dev/null
+++ b/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdSeekBlobCommandExecutor.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob;
+
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdSeekBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.generic.FirebirdGenericResponsePacket;
+import org.apache.shardingsphere.database.protocol.packet.DatabasePacket;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.statement.FirebirdStatementIdGenerator;
+
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * Seek blob command executor for Firebird.
+ */
+@RequiredArgsConstructor
+public final class FirebirdSeekBlobCommandExecutor implements CommandExecutor {
+
+ private final FirebirdSeekBlobCommandPacket packet;
+
+ private final ConnectionSession connectionSession;
+
+ @Override
+ public Collection<DatabasePacket> execute() throws SQLException {
+ int statementId = FirebirdStatementIdGenerator.getInstance().nextStatementId(connectionSession.getConnectionId());
+ return Collections.singleton(new FirebirdGenericResponsePacket().setHandle(statementId));
+ }
+}
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/FirebirdCommandExecutorFactoryTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/FirebirdCommandExecutorFactoryTest.java
index 1604e31f14e..b3a9ded09d7 100644
--- a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/FirebirdCommandExecutorFactoryTest.java
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/FirebirdCommandExecutorFactoryTest.java
@@ -19,6 +19,13 @@ package org.apache.shardingsphere.proxy.frontend.firebird.command;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.FirebirdCommandPacketType;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.info.FirebirdInfoPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdCancelBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdCloseBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdCreateBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdGetBlobSegmentCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdOpenBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdPutBlobSegmentCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdSeekBlobCommandPacket;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.statement.FirebirdAllocateStatementPacket;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.statement.FirebirdFetchStatementPacket;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.statement.FirebirdFreeStatementPacket;
@@ -32,6 +39,13 @@ import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.firebird.command.admin.FirebirdUnsupportedCommandExecutor;
import org.apache.shardingsphere.proxy.frontend.firebird.command.query.info.FirebirdDatabaseInfoExecutor;
import org.apache.shardingsphere.proxy.frontend.firebird.command.query.info.FirebirdSQLInfoExecutor;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob.FirebirdCancelBlobCommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob.FirebirdCloseBlobCommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob.FirebirdCreateBlobCommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob.FirebirdGetBlobSegmentCommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob.FirebirdOpenBlobCommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob.FirebirdPutBlobSegmentCommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob.FirebirdSeekBlobCommandExecutor;
import org.apache.shardingsphere.proxy.frontend.firebird.command.query.statement.FirebirdAllocateStatementCommandExecutor;
import org.apache.shardingsphere.proxy.frontend.firebird.command.query.statement.FirebirdFetchStatementCommandExecutor;
import org.apache.shardingsphere.proxy.frontend.firebird.command.query.statement.FirebirdFreeStatementCommandExecutor;
@@ -69,6 +83,60 @@ class FirebirdCommandExecutorFactoryTest {
isA(FirebirdStartTransactionCommandExecutor.class));
}
+ @Test
+ void assertNewInstanceWithCreateBlob() throws SQLException {
+ assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.CREATE_BLOB, mock(FirebirdCreateBlobCommandPacket.class), connectionSession),
+ isA(FirebirdCreateBlobCommandExecutor.class));
+ }
+
+ @Test
+ void assertNewInstanceWithCreateBlob2() throws SQLException {
+ assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.CREATE_BLOB2, mock(FirebirdCreateBlobCommandPacket.class), connectionSession),
+ isA(FirebirdCreateBlobCommandExecutor.class));
+ }
+
+ @Test
+ void assertNewInstanceWithOpenBlob() throws SQLException {
+ assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.OPEN_BLOB, mock(FirebirdOpenBlobCommandPacket.class), connectionSession),
+ isA(FirebirdOpenBlobCommandExecutor.class));
+ }
+
+ @Test
+ void assertNewInstanceWithOpenBlob2() throws SQLException {
+ assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.OPEN_BLOB2, mock(FirebirdOpenBlobCommandPacket.class), connectionSession),
+ isA(FirebirdOpenBlobCommandExecutor.class));
+ }
+
+ @Test
+ void assertNewInstanceWithGetBlobSegment() throws SQLException {
+ assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.GET_SEGMENT, mock(FirebirdGetBlobSegmentCommandPacket.class), connectionSession),
+ isA(FirebirdGetBlobSegmentCommandExecutor.class));
+ }
+
+ @Test
+ void assertNewInstanceWithPutBlobSegment() throws SQLException {
+ assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.PUT_SEGMENT, mock(FirebirdPutBlobSegmentCommandPacket.class), connectionSession),
+ isA(FirebirdPutBlobSegmentCommandExecutor.class));
+ }
+
+ @Test
+ void assertNewInstanceWithCancelBlob() throws SQLException {
+ assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.CANCEL_BLOB, mock(FirebirdCancelBlobCommandPacket.class), connectionSession),
+ isA(FirebirdCancelBlobCommandExecutor.class));
+ }
+
+ @Test
+ void assertNewInstanceWithCloseBlob() throws SQLException {
+ assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.CLOSE_BLOB, mock(FirebirdCloseBlobCommandPacket.class), connectionSession),
+ isA(FirebirdCloseBlobCommandExecutor.class));
+ }
+
+ @Test
+ void assertNewInstanceWithSeekBlob() throws SQLException {
+ assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.SEEK_BLOB, mock(FirebirdSeekBlobCommandPacket.class), connectionSession),
+ isA(FirebirdSeekBlobCommandExecutor.class));
+ }
+
@Test
void assertNewInstanceWithAllocateStatement() throws SQLException {
assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.ALLOCATE_STATEMENT, mock(FirebirdAllocateStatementPacket.class), connectionSession),
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdCancelBlobCommandExecutorTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdCancelBlobCommandExecutorTest.java
new file mode 100644
index 00000000000..bbcd09f043a
--- /dev/null
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdCancelBlobCommandExecutorTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob;
+
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdCancelBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.generic.FirebirdGenericResponsePacket;
+import org.apache.shardingsphere.database.protocol.packet.DatabasePacket;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.statement.FirebirdStatementIdGenerator;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.sql.SQLException;
+import java.util.Collection;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+class FirebirdCancelBlobCommandExecutorTest {
+
+ private static final int CONNECTION_ID = 1;
+
+ @Mock
+ private FirebirdCancelBlobCommandPacket packet;
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private ConnectionSession connectionSession;
+
+ @BeforeEach
+ void setup() {
+ FirebirdStatementIdGenerator.getInstance().registerConnection(CONNECTION_ID);
+ when(connectionSession.getConnectionId()).thenReturn(CONNECTION_ID);
+ }
+
+ @AfterEach
+ void tearDown() {
+ FirebirdStatementIdGenerator.getInstance().unregisterConnection(CONNECTION_ID);
+ }
+
+ @Test
+ void assertExecute() throws SQLException {
+ FirebirdCancelBlobCommandExecutor executor = new FirebirdCancelBlobCommandExecutor(packet, connectionSession);
+ Collection<DatabasePacket> actual = executor.execute();
+ assertThat(actual.size(), is(1));
+ DatabasePacket response = actual.iterator().next();
+ assertThat(response, instanceOf(FirebirdGenericResponsePacket.class));
+ assertThat(((FirebirdGenericResponsePacket) response).getHandle(), is(1));
+ }
+}
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdCloseBlobCommandExecutorTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdCloseBlobCommandExecutorTest.java
new file mode 100644
index 00000000000..42e5b4367ff
--- /dev/null
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdCloseBlobCommandExecutorTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob;
+
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdCloseBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.generic.FirebirdGenericResponsePacket;
+import org.apache.shardingsphere.database.protocol.packet.DatabasePacket;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.statement.FirebirdStatementIdGenerator;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.sql.SQLException;
+import java.util.Collection;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+class FirebirdCloseBlobCommandExecutorTest {
+
+ private static final int CONNECTION_ID = 1;
+
+ @Mock
+ private FirebirdCloseBlobCommandPacket packet;
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private ConnectionSession connectionSession;
+
+ @BeforeEach
+ void setup() {
+ FirebirdStatementIdGenerator.getInstance().registerConnection(CONNECTION_ID);
+ when(connectionSession.getConnectionId()).thenReturn(CONNECTION_ID);
+ }
+
+ @AfterEach
+ void tearDown() {
+ FirebirdStatementIdGenerator.getInstance().unregisterConnection(CONNECTION_ID);
+ }
+
+ @Test
+ void assertExecute() throws SQLException {
+ FirebirdCloseBlobCommandExecutor executor = new FirebirdCloseBlobCommandExecutor(packet, connectionSession);
+ Collection<DatabasePacket> actual = executor.execute();
+ assertThat(actual.size(), is(1));
+ DatabasePacket response = actual.iterator().next();
+ assertThat(response, instanceOf(FirebirdGenericResponsePacket.class));
+ assertThat(((FirebirdGenericResponsePacket) response).getHandle(), is(1));
+ }
+}
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdCreateBlobCommandExecutorTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdCreateBlobCommandExecutorTest.java
new file mode 100644
index 00000000000..e9bd9751020
--- /dev/null
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdCreateBlobCommandExecutorTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob;
+
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdCreateBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.generic.FirebirdGenericResponsePacket;
+import org.apache.shardingsphere.database.protocol.packet.DatabasePacket;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.statement.FirebirdStatementIdGenerator;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.sql.SQLException;
+import java.util.Collection;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+class FirebirdCreateBlobCommandExecutorTest {
+
+ private static final int CONNECTION_ID = 1;
+
+ @Mock
+ private FirebirdCreateBlobCommandPacket packet;
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private ConnectionSession connectionSession;
+
+ @BeforeEach
+ void setup() {
+ FirebirdStatementIdGenerator.getInstance().registerConnection(CONNECTION_ID);
+ when(connectionSession.getConnectionId()).thenReturn(CONNECTION_ID);
+ }
+
+ @AfterEach
+ void tearDown() {
+ FirebirdStatementIdGenerator.getInstance().unregisterConnection(CONNECTION_ID);
+ }
+
+ @Test
+ void assertExecute() throws SQLException {
+ FirebirdCreateBlobCommandExecutor executor = new FirebirdCreateBlobCommandExecutor(packet, connectionSession);
+ Collection<DatabasePacket> actual = executor.execute();
+ assertThat(actual.size(), is(1));
+ DatabasePacket response = actual.iterator().next();
+ assertThat(response, instanceOf(FirebirdGenericResponsePacket.class));
+ assertThat(((FirebirdGenericResponsePacket) response).getHandle(), is(1));
+ }
+}
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdGetBlobSegmentCommandExecutorTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdGetBlobSegmentCommandExecutorTest.java
new file mode 100644
index 00000000000..e9416543649
--- /dev/null
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdGetBlobSegmentCommandExecutorTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob;
+
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdGetBlobSegmentCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.generic.FirebirdGenericResponsePacket;
+import org.apache.shardingsphere.database.protocol.packet.DatabasePacket;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.statement.FirebirdStatementIdGenerator;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.sql.SQLException;
+import java.util.Collection;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+class FirebirdGetBlobSegmentCommandExecutorTest {
+
+ private static final int CONNECTION_ID = 1;
+
+ @Mock
+ private FirebirdGetBlobSegmentCommandPacket packet;
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private ConnectionSession connectionSession;
+
+ @BeforeEach
+ void setup() {
+ FirebirdStatementIdGenerator.getInstance().registerConnection(CONNECTION_ID);
+ when(connectionSession.getConnectionId()).thenReturn(CONNECTION_ID);
+ }
+
+ @AfterEach
+ void tearDown() {
+ FirebirdStatementIdGenerator.getInstance().unregisterConnection(CONNECTION_ID);
+ }
+
+ @Test
+ void assertExecute() throws SQLException {
+ FirebirdGetBlobSegmentCommandExecutor executor = new FirebirdGetBlobSegmentCommandExecutor(packet, connectionSession);
+ Collection<DatabasePacket> actual = executor.execute();
+ assertThat(actual.size(), is(1));
+ DatabasePacket response = actual.iterator().next();
+ assertThat(response, instanceOf(FirebirdGenericResponsePacket.class));
+ assertThat(((FirebirdGenericResponsePacket) response).getHandle(), is(1));
+ }
+}
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdOpenBlobCommandExecutorTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdOpenBlobCommandExecutorTest.java
new file mode 100644
index 00000000000..a2eac0f12b3
--- /dev/null
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdOpenBlobCommandExecutorTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob;
+
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdOpenBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.generic.FirebirdGenericResponsePacket;
+import org.apache.shardingsphere.database.protocol.packet.DatabasePacket;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.statement.FirebirdStatementIdGenerator;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.sql.SQLException;
+import java.util.Collection;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+class FirebirdOpenBlobCommandExecutorTest {
+
+ private static final int CONNECTION_ID = 1;
+
+ @Mock
+ private FirebirdOpenBlobCommandPacket packet;
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private ConnectionSession connectionSession;
+
+ @BeforeEach
+ void setup() {
+ FirebirdStatementIdGenerator.getInstance().registerConnection(CONNECTION_ID);
+ when(connectionSession.getConnectionId()).thenReturn(CONNECTION_ID);
+ }
+
+ @AfterEach
+ void tearDown() {
+ FirebirdStatementIdGenerator.getInstance().unregisterConnection(CONNECTION_ID);
+ }
+
+ @Test
+ void assertExecute() throws SQLException {
+ FirebirdOpenBlobCommandExecutor executor = new FirebirdOpenBlobCommandExecutor(packet, connectionSession);
+ Collection<DatabasePacket> actual = executor.execute();
+ assertThat(actual.size(), is(1));
+ DatabasePacket response = actual.iterator().next();
+ assertThat(response, instanceOf(FirebirdGenericResponsePacket.class));
+ assertThat(((FirebirdGenericResponsePacket) response).getHandle(), is(1));
+ }
+}
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdPutBlobSegmentCommandExecutorTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdPutBlobSegmentCommandExecutorTest.java
new file mode 100644
index 00000000000..5fd3cfbe43e
--- /dev/null
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdPutBlobSegmentCommandExecutorTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob;
+
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdPutBlobSegmentCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.generic.FirebirdGenericResponsePacket;
+import org.apache.shardingsphere.database.protocol.packet.DatabasePacket;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.statement.FirebirdStatementIdGenerator;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.sql.SQLException;
+import java.util.Collection;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+class FirebirdPutBlobSegmentCommandExecutorTest {
+
+ private static final int CONNECTION_ID = 1;
+
+ @Mock
+ private FirebirdPutBlobSegmentCommandPacket packet;
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private ConnectionSession connectionSession;
+
+ @BeforeEach
+ void setup() {
+ FirebirdStatementIdGenerator.getInstance().registerConnection(CONNECTION_ID);
+ when(connectionSession.getConnectionId()).thenReturn(CONNECTION_ID);
+ }
+
+ @AfterEach
+ void tearDown() {
+ FirebirdStatementIdGenerator.getInstance().unregisterConnection(CONNECTION_ID);
+ }
+
+ @Test
+ void assertExecute() throws SQLException {
+ FirebirdPutBlobSegmentCommandExecutor executor = new FirebirdPutBlobSegmentCommandExecutor(packet, connectionSession);
+ Collection<DatabasePacket> actual = executor.execute();
+ assertThat(actual.size(), is(1));
+ DatabasePacket response = actual.iterator().next();
+ assertThat(response, instanceOf(FirebirdGenericResponsePacket.class));
+ assertThat(((FirebirdGenericResponsePacket) response).getHandle(), is(1));
+ }
+}
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdSeekBlobCommandExecutorTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdSeekBlobCommandExecutorTest.java
new file mode 100644
index 00000000000..daa79938da7
--- /dev/null
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/blob/FirebirdSeekBlobCommandExecutorTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.proxy.frontend.firebird.command.query.blob;
+
+import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.blob.FirebirdSeekBlobCommandPacket;
+import org.apache.shardingsphere.database.protocol.firebird.packet.generic.FirebirdGenericResponsePacket;
+import org.apache.shardingsphere.database.protocol.packet.DatabasePacket;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.proxy.frontend.firebird.command.query.statement.FirebirdStatementIdGenerator;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.sql.SQLException;
+import java.util.Collection;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+class FirebirdSeekBlobCommandExecutorTest {
+
+ private static final int CONNECTION_ID = 1;
+
+ @Mock
+ private FirebirdSeekBlobCommandPacket packet;
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private ConnectionSession connectionSession;
+
+ @BeforeEach
+ void setup() {
+ FirebirdStatementIdGenerator.getInstance().registerConnection(CONNECTION_ID);
+ when(connectionSession.getConnectionId()).thenReturn(CONNECTION_ID);
+ }
+
+ @AfterEach
+ void tearDown() {
+ FirebirdStatementIdGenerator.getInstance().unregisterConnection(CONNECTION_ID);
+ }
+
+ @Test
+ void assertExecute() throws SQLException {
+ FirebirdSeekBlobCommandExecutor executor = new FirebirdSeekBlobCommandExecutor(packet, connectionSession);
+ Collection<DatabasePacket> actual = executor.execute();
+ assertThat(actual.size(), is(1));
+ DatabasePacket response = actual.iterator().next();
+ assertThat(response, instanceOf(FirebirdGenericResponsePacket.class));
+ assertThat(((FirebirdGenericResponsePacket) response).getHandle(), is(1));
+ }
+}
diff --git a/test/it/parser/src/main/resources/case/ddl/create-table.xml b/test/it/parser/src/main/resources/case/ddl/create-table.xml
index d6324a9ba7d..425836d0ea5 100644
--- a/test/it/parser/src/main/resources/case/ddl/create-table.xml
+++ b/test/it/parser/src/main/resources/case/ddl/create-table.xml
@@ -3672,4 +3672,35 @@
<location path="/user/hive/warehouse/test_db.db/target_table" start-index="85" stop-index="135" />
<tblproperties properties="" start-index="0" stop-index="0" />
</create-table>
+
+ <create-table sql-case-id="create_table_with_blob">
+ <table name="t_blob" start-index="13" stop-index="18" />
+ <column-definition type="INT" start-index="21" stop-index="26">
+ <column name="id" />
+ </column-definition>
+ <column-definition type="BLOB" start-index="29" stop-index="40">
+ <column name="payload" />
+ </column-definition>
+ </create-table>
+
+ <create-table sql-case-id="create_table_with_blob_subtype_numeric">
+ <table name="t_blob_subtype_numeric" start-index="13" stop-index="34" />
+ <column-definition type="BLOB SUB_TYPE 1" start-index="37" stop-index="59">
+ <column name="payload" />
+ </column-definition>
+ </create-table>
+
+ <create-table sql-case-id="create_table_with_blob_subtype_text">
+ <table name="t_blob_subtype_text" start-index="13" stop-index="31" />
+ <column-definition type="BLOB SUB_TYPE TEXT CHARACTER SET UTF8" start-index="34" stop-index="78">
+ <column name="payload" />
+ </column-definition>
+ </create-table>
+
+ <create-table sql-case-id="create_table_with_blob_segment_size">
+ <table name="t_blob_segment" start-index="13" stop-index="26" />
+ <column-definition type="BLOB SUB_TYPE 0 SEGMENT SIZE 80" start-index="29" stop-index="67">
+ <column name="payload" />
+ </column-definition>
+ </create-table>
</sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/sql/supported/ddl/create-table.xml b/test/it/parser/src/main/resources/sql/supported/ddl/create-table.xml
index 728cf1c60f4..4050ae7b96c 100644
--- a/test/it/parser/src/main/resources/sql/supported/ddl/create-table.xml
+++ b/test/it/parser/src/main/resources/sql/supported/ddl/create-table.xml
@@ -509,4 +509,8 @@
JOIN dim_dates ds ON u.date_id = ds.date_id
WHERE u.status = 'active';" db-types="Hive" />
<sql-case id="create_table_like_all_options" value="CREATE TEMPORARY EXTERNAL TABLE IF NOT EXISTS test_db.target_table LIKE source_db.source_table LOCATION '/user/hive/warehouse/test_db.db/target_table';" db-types="Hive" />
+ <sql-case id="create_table_with_blob" value="CREATE TABLE t_blob (id INT, payload BLOB)" db-types="Firebird" />
+ <sql-case id="create_table_with_blob_subtype_numeric" value="CREATE TABLE t_blob_subtype_numeric (payload BLOB SUB_TYPE 1)" db-types="Firebird" />
+ <sql-case id="create_table_with_blob_subtype_text" value="CREATE TABLE t_blob_subtype_text (payload BLOB SUB_TYPE TEXT CHARACTER SET UTF8)" db-types="Firebird" />
+ <sql-case id="create_table_with_blob_segment_size" value="CREATE TABLE t_blob_segment (payload BLOB SUB_TYPE 0 SEGMENT SIZE 80)" db-types="Firebird" />
</sql-cases>