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 2a765623ab9 Add more test cases on 
FirebirdExecuteStatementCommandExecutorTest (#37947)
2a765623ab9 is described below

commit 2a765623ab98dfce31121b19e9dbced53cea82a7
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Feb 3 22:30:23 2026 +0800

    Add more test cases on FirebirdExecuteStatementCommandExecutorTest (#37947)
---
 .../FirebirdExecuteStatementCommandExecutor.java   |   4 -
 ...irebirdExecuteStatementCommandExecutorTest.java | 103 +++++++++++++++++++--
 2 files changed, 94 insertions(+), 13 deletions(-)

diff --git 
a/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/execute/FirebirdExecuteStatementCommandExecutor.java
 
b/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/execute/FirebirdExecuteStatementCommandExecutor.java
index d0857efeba2..21b7410dbbd 100644
--- 
a/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/execute/FirebirdExecuteStatementCommandExecutor.java
+++ 
b/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/execute/FirebirdExecuteStatementCommandExecutor.java
@@ -122,10 +122,6 @@ public final class FirebirdExecuteStatementCommandExecutor 
implements CommandExe
                 continue;
             }
             Optional<byte[]> blobData = 
FirebirdBlobUploadCache.getInstance().getBlobData(connectionSession.getConnectionId(),
 blobId);
-            if (!blobData.isPresent()) {
-                params.set(i, null);
-                continue;
-            }
             byte[] bytes = blobData.get();
             params.set(i, bytes);
             blobIds.add(blobId);
diff --git 
a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/execute/FirebirdExecuteStatementCommandExecutorTest.java
 
b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/execute/FirebirdExecuteStatementCommandExecutorTest.java
index e13b8d45f56..b8ceb350199 100644
--- 
a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/execute/FirebirdExecuteStatementCommandExecutorTest.java
+++ 
b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/execute/FirebirdExecuteStatementCommandExecutorTest.java
@@ -111,6 +111,8 @@ class FirebirdExecuteStatementCommandExecutorTest {
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private SelectStatementContext selectContext;
     
+    private FirebirdExecuteStatementCommandExecutor executor;
+    
     @BeforeEach
     void setUp() {
         
FirebirdFetchStatementCache.getInstance().registerConnection(CONNECTION_ID);
@@ -139,11 +141,11 @@ class FirebirdExecuteStatementCommandExecutorTest {
     void assertIsQueryResponse() throws SQLException {
         when(packet.getStatementId()).thenReturn(1);
         when(packet.getParameterTypes()).thenReturn(Collections.emptyList());
-        when(packet.getParameterValues()).thenReturn(new ArrayList<>());
+        when(packet.getParameterValues()).thenReturn(Collections.emptyList());
         when(packet.isStoredProcedure()).thenReturn(true);
-        FirebirdExecuteStatementCommandExecutor executor = new 
FirebirdExecuteStatementCommandExecutor(packet, connectionSession);
+        executor = new FirebirdExecuteStatementCommandExecutor(packet, 
connectionSession);
         when(proxyBackendHandler.execute()).thenReturn(new 
QueryResponseHeader(Collections.singletonList(queryHeader)));
-        when(proxyBackendHandler.next()).thenReturn(true, true);
+        when(proxyBackendHandler.next()).thenReturn(true);
         QueryResponseRow row = new 
QueryResponseRow(Collections.singletonList(new QueryResponseCell(Types.INTEGER, 
1)));
         when(proxyBackendHandler.getRowData()).thenReturn(row, row);
         when(ProxyBackendHandlerFactory.newInstance(eq(DATABASE_TYPE), 
any(QueryContext.class), eq(connectionSession), 
eq(true))).thenReturn(proxyBackendHandler);
@@ -160,8 +162,8 @@ class FirebirdExecuteStatementCommandExecutorTest {
     void assertIsUpdateResponse() throws SQLException {
         when(packet.getStatementId()).thenReturn(2);
         when(packet.getParameterTypes()).thenReturn(Collections.emptyList());
-        when(packet.getParameterValues()).thenReturn(new ArrayList<>());
-        FirebirdExecuteStatementCommandExecutor executor = new 
FirebirdExecuteStatementCommandExecutor(packet, connectionSession);
+        when(packet.getParameterValues()).thenReturn(Collections.emptyList());
+        executor = new FirebirdExecuteStatementCommandExecutor(packet, 
connectionSession);
         when(proxyBackendHandler.execute()).thenReturn(new 
UpdateResponseHeader(new UpdateStatement(DATABASE_TYPE)));
         when(ProxyBackendHandlerFactory.newInstance(eq(DATABASE_TYPE), 
any(QueryContext.class), eq(connectionSession), 
eq(true))).thenReturn(proxyBackendHandler);
         Collection<DatabasePacket> actual = executor.execute();
@@ -176,18 +178,101 @@ class FirebirdExecuteStatementCommandExecutorTest {
         long blobId = 11L;
         FirebirdBlobUploadCache.getInstance().registerBlob(CONNECTION_ID, 
blobHandle, blobId);
         FirebirdBlobUploadCache.getInstance().appendSegment(CONNECTION_ID, 
blobHandle, new byte[]{1, 2});
-        List<Object> params = new ArrayList<>();
-        params.add(blobId);
         when(packet.getStatementId()).thenReturn(2);
         
when(packet.getParameterTypes()).thenReturn(Collections.singletonList(FirebirdBinaryColumnType.BLOB));
-        when(packet.getParameterValues()).thenReturn(params);
-        FirebirdExecuteStatementCommandExecutor executor = new 
FirebirdExecuteStatementCommandExecutor(packet, connectionSession);
+        when(packet.getParameterValues()).thenReturn(new 
ArrayList<>(Collections.singletonList(blobId)));
+        executor = new FirebirdExecuteStatementCommandExecutor(packet, 
connectionSession);
+        when(proxyBackendHandler.execute()).thenReturn(new 
UpdateResponseHeader(new UpdateStatement(DATABASE_TYPE)));
+        ArgumentCaptor<QueryContext> queryContextCaptor = 
ArgumentCaptor.forClass(QueryContext.class);
+        when(ProxyBackendHandlerFactory.newInstance(eq(DATABASE_TYPE), 
queryContextCaptor.capture(), eq(connectionSession), 
eq(true))).thenReturn(proxyBackendHandler);
+        executor.execute();
+        List<Object> actualParams = 
queryContextCaptor.getValue().getParameters();
+        assertThat(actualParams.size(), is(1));
+        assertThat(actualParams.get(0), nullValue());
+    }
+    
+    @Test
+    void assertSkipNonBlobParameter() throws SQLException {
+        when(packet.getStatementId()).thenReturn(2);
+        
when(packet.getParameterTypes()).thenReturn(Collections.singletonList(FirebirdBinaryColumnType.LONG));
+        when(packet.getParameterValues()).thenReturn(new 
ArrayList<>(Collections.singletonList(9)));
+        executor = new FirebirdExecuteStatementCommandExecutor(packet, 
connectionSession);
+        ArgumentCaptor<QueryContext> queryContextCaptor = 
ArgumentCaptor.forClass(QueryContext.class);
         when(proxyBackendHandler.execute()).thenReturn(new 
UpdateResponseHeader(new UpdateStatement(DATABASE_TYPE)));
+        when(ProxyBackendHandlerFactory.newInstance(eq(DATABASE_TYPE), 
queryContextCaptor.capture(), eq(connectionSession), 
eq(true))).thenReturn(proxyBackendHandler);
+        executor.execute();
+        List<Object> actualParams = 
queryContextCaptor.getValue().getParameters();
+        assertThat(actualParams.size(), is(1));
+        assertThat(actualParams.get(0), is(9));
+    }
+    
+    @Test
+    void assertSkipBlobParameterWhenNotLong() throws SQLException {
+        when(packet.getStatementId()).thenReturn(2);
+        
when(packet.getParameterTypes()).thenReturn(Collections.singletonList(FirebirdBinaryColumnType.BLOB));
+        when(packet.getParameterValues()).thenReturn(new 
ArrayList<>(Collections.singletonList("text")));
+        executor = new FirebirdExecuteStatementCommandExecutor(packet, 
connectionSession);
         ArgumentCaptor<QueryContext> queryContextCaptor = 
ArgumentCaptor.forClass(QueryContext.class);
+        when(proxyBackendHandler.execute()).thenReturn(new 
UpdateResponseHeader(new UpdateStatement(DATABASE_TYPE)));
         when(ProxyBackendHandlerFactory.newInstance(eq(DATABASE_TYPE), 
queryContextCaptor.capture(), eq(connectionSession), 
eq(true))).thenReturn(proxyBackendHandler);
         executor.execute();
         List<Object> actualParams = 
queryContextCaptor.getValue().getParameters();
         assertThat(actualParams.size(), is(1));
         assertThat(actualParams.get(0), nullValue());
     }
+    
+    @Test
+    void assertSkipBlobParameterWhenNonPositive() throws SQLException {
+        when(packet.getStatementId()).thenReturn(2);
+        
when(packet.getParameterTypes()).thenReturn(Collections.singletonList(FirebirdBinaryColumnType.BLOB));
+        when(packet.getParameterValues()).thenReturn(new 
ArrayList<>(Collections.singletonList(0L)));
+        executor = new FirebirdExecuteStatementCommandExecutor(packet, 
connectionSession);
+        ArgumentCaptor<QueryContext> queryContextCaptor = 
ArgumentCaptor.forClass(QueryContext.class);
+        when(proxyBackendHandler.execute()).thenReturn(new 
UpdateResponseHeader(new UpdateStatement(DATABASE_TYPE)));
+        when(ProxyBackendHandlerFactory.newInstance(eq(DATABASE_TYPE), 
queryContextCaptor.capture(), eq(connectionSession), 
eq(true))).thenReturn(proxyBackendHandler);
+        executor.execute();
+        List<Object> actualParams = 
queryContextCaptor.getValue().getParameters();
+        assertThat(actualParams.size(), is(1));
+        assertThat(actualParams.get(0), nullValue());
+    }
+    
+    @Test
+    void assertBindBlobParameterAndClearUpload() throws SQLException {
+        int blobHandle = 13;
+        long blobId = 17L;
+        byte[] expectedBytes = new byte[]{3, 4};
+        FirebirdBlobUploadCache.getInstance().registerBlob(CONNECTION_ID, 
blobHandle, blobId);
+        FirebirdBlobUploadCache.getInstance().appendSegment(CONNECTION_ID, 
blobHandle, expectedBytes);
+        FirebirdBlobUploadCache.getInstance().closeUpload(CONNECTION_ID, 
blobHandle);
+        List<Object> params = new 
ArrayList<>(Collections.singletonList(blobId));
+        when(packet.getStatementId()).thenReturn(2);
+        
when(packet.getParameterTypes()).thenReturn(Collections.singletonList(FirebirdBinaryColumnType.BLOB));
+        when(packet.getParameterValues()).thenReturn(params);
+        executor = new FirebirdExecuteStatementCommandExecutor(packet, 
connectionSession);
+        ArgumentCaptor<QueryContext> queryContextCaptor = 
ArgumentCaptor.forClass(QueryContext.class);
+        when(proxyBackendHandler.execute()).thenReturn(new 
UpdateResponseHeader(new UpdateStatement(DATABASE_TYPE)));
+        when(ProxyBackendHandlerFactory.newInstance(eq(DATABASE_TYPE), 
queryContextCaptor.capture(), eq(connectionSession), 
eq(true))).thenReturn(proxyBackendHandler);
+        executor.execute();
+        List<Object> actualParams = 
queryContextCaptor.getValue().getParameters();
+        assertThat(actualParams.size(), is(1));
+        assertThat(actualParams.get(0), is(expectedBytes));
+        
assertFalse(FirebirdBlobUploadCache.getInstance().getBlobData(CONNECTION_ID, 
blobId).isPresent());
+    }
+    
+    @Test
+    void assertStoredProcedureWithoutResult() throws SQLException {
+        when(packet.getStatementId()).thenReturn(1);
+        when(packet.getParameterTypes()).thenReturn(Collections.emptyList());
+        when(packet.getParameterValues()).thenReturn(Collections.emptyList());
+        when(packet.isStoredProcedure()).thenReturn(true);
+        executor = new FirebirdExecuteStatementCommandExecutor(packet, 
connectionSession);
+        when(proxyBackendHandler.execute()).thenReturn(new 
QueryResponseHeader(Collections.singletonList(queryHeader)));
+        when(ProxyBackendHandlerFactory.newInstance(eq(DATABASE_TYPE), 
any(QueryContext.class), eq(connectionSession), 
eq(true))).thenReturn(proxyBackendHandler);
+        Collection<DatabasePacket> actual = executor.execute();
+        Iterator<DatabasePacket> iterator = actual.iterator();
+        assertThat(executor.getResponseType(), is(ResponseType.QUERY));
+        assertThat(iterator.next(), isA(FirebirdGenericResponsePacket.class));
+        assertFalse(iterator.hasNext());
+        
assertThat(FirebirdFetchStatementCache.getInstance().getFetchBackendHandler(CONNECTION_ID,
 STATEMENT_ID), is(proxyBackendHandler));
+    }
 }

Reply via email to