PostgreSQLCommandExecuteEngine implements CommandExecuteEngine { @Override public void writeQueryData(final ChannelHandlerContext context, final BackendConnection backendConnection, final QueryCommandExecutor queryCommandExecutor, final int headerPackagesCount) throws SQLException { if (ResponseType.QUERY == queryCommandExecutor.getResponseType() && !context.channel().isActive()) { context.write(new PostgreSQLCommandCompletePacket()); context.write(new PostgreSQLReadyForQueryPacket()); return; } if (ResponseType.UPDATE == queryCommandExecutor.getResponseType()) { context.write(new PostgreSQLReadyForQueryPacket()); return; } int count = 0; int proxyFrontendFlushThreshold = ProxyContext.getInstance().getSchemaContexts().getProps().<Integer>getValue(ConfigurationPropertyKey.PROXY_FRONTEND_FLUSH_THRESHOLD); while (queryCommandExecutor.next()) { count++; while (!context.channel().isWritable() && context.channel().isActive()) { context.flush(); backendConnection.getResourceLock().doAwait(); } DatabasePacket<?> resultValue = queryCommandExecutor.getQueryData(); context.write(resultValue); if (proxyFrontendFlushThreshold == count) { context.flush(); count = 0; } } context.write(new PostgreSQLCommandCompletePacket()); context.write(new PostgreSQLReadyForQueryPacket()); }  @Override PostgreSQLCommandPacketType getCommandPacketType(final PacketPayload payload); @Override PostgreSQLCommandPacket getCommandPacket(final PacketPayload payload, final CommandPacketType type, final BackendConnection backendConnection); @Override CommandExecutor getCommandExecutor(final CommandPacketType type, final CommandPacket packet, final BackendConnection backendConnection); @Override DatabasePacket<?> getErrorPacket(final Exception cause); @Override Optional<DatabasePacket<?>> getOtherPacket(); @Override void writeQueryData(final ChannelHandlerContext context,
                               final BackendConnection backendConnection, final QueryCommandExecutor queryCommandExecutor, final int headerPackagesCount);  }
@Test public void assertWriteQueryDataWithUpdate() throws SQLException { PostgreSQLCommandExecuteEngine postgreSQLCommandExecuteEngine = new PostgreSQLCommandExecuteEngine(); when(queryCommandExecutor.getResponseType()).thenReturn(ResponseType.UPDATE); postgreSQLCommandExecuteEngine.writeQueryData(channelHandlerContext, null, queryCommandExecutor, 0); verify(channelHandlerContext, times(1)).write(isA(PostgreSQLReadyForQueryPacket.class)); }