|
23 | 23 | import io.r2dbc.postgresql.PostgresqlConnectionFactory;
|
24 | 24 | import io.r2dbc.postgresql.api.PostgresqlConnection;
|
25 | 25 | import io.r2dbc.postgresql.authentication.PasswordAuthenticationHandler;
|
| 26 | +import io.r2dbc.postgresql.message.Format; |
26 | 27 | import io.r2dbc.postgresql.message.backend.BackendMessage;
|
| 28 | +import io.r2dbc.postgresql.message.backend.BindComplete; |
27 | 29 | import io.r2dbc.postgresql.message.backend.CommandComplete;
|
28 | 30 | import io.r2dbc.postgresql.message.backend.DataRow;
|
29 | 31 | import io.r2dbc.postgresql.message.backend.NotificationResponse;
|
30 | 32 | import io.r2dbc.postgresql.message.backend.RowDescription;
|
| 33 | +import io.r2dbc.postgresql.message.frontend.Bind; |
| 34 | +import io.r2dbc.postgresql.message.frontend.Describe; |
| 35 | +import io.r2dbc.postgresql.message.frontend.Execute; |
| 36 | +import io.r2dbc.postgresql.message.frontend.ExecutionType; |
31 | 37 | import io.r2dbc.postgresql.message.frontend.FrontendMessage;
|
32 | 38 | import io.r2dbc.postgresql.message.frontend.Query;
|
| 39 | +import io.r2dbc.postgresql.message.frontend.Sync; |
33 | 40 | import io.r2dbc.postgresql.util.PostgresqlServerExtension;
|
34 | 41 | import io.r2dbc.spi.R2dbcNonTransientResourceException;
|
35 | 42 | import io.r2dbc.spi.R2dbcPermissionDeniedException;
|
|
62 | 69 | import java.util.function.Function;
|
63 | 70 | import java.util.stream.IntStream;
|
64 | 71 |
|
| 72 | +import static io.r2dbc.postgresql.type.PostgresqlObjectId.INT4; |
65 | 73 | import static org.assertj.core.api.Assertions.assertThat;
|
66 | 74 | import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
67 | 75 | import static org.assertj.core.api.Assertions.fail;
|
@@ -274,6 +282,54 @@ void parallelExchange() {
|
274 | 282 | .verifyComplete();
|
275 | 283 | }
|
276 | 284 |
|
| 285 | + @Test |
| 286 | + void parallelExchangeExtendedFlow() { |
| 287 | + ExtendedQueryMessageFlow.parse(this.client, "S_1", "SELECT $1", Arrays.asList(INT4.getObjectId())) |
| 288 | + .as(StepVerifier::create) |
| 289 | + .verifyComplete(); |
| 290 | + |
| 291 | + this.client.exchange(Mono.just(Sync.INSTANCE)) |
| 292 | + .as(StepVerifier::create) |
| 293 | + .verifyComplete(); |
| 294 | + |
| 295 | + FrontendMessage bind1 = new Bind( |
| 296 | + "P_1", |
| 297 | + Collections.singletonList(Format.FORMAT_BINARY), |
| 298 | + Collections.singletonList(this.client.getByteBufAllocator().buffer(4).writeInt(42)), |
| 299 | + Collections.singletonList(Format.FORMAT_BINARY), |
| 300 | + "S_1" |
| 301 | + ); |
| 302 | + Describe describe1 = new Describe("P_1", ExecutionType.PORTAL); |
| 303 | + Execute execute1 = new Execute("P_1", Integer.MAX_VALUE); |
| 304 | + FrontendMessage bind2 = new Bind( |
| 305 | + "P_2", |
| 306 | + Collections.singletonList(Format.FORMAT_BINARY), |
| 307 | + Collections.singletonList(this.client.getByteBufAllocator().buffer(4).writeInt(42)), |
| 308 | + Collections.singletonList(Format.FORMAT_BINARY), |
| 309 | + "S_1" |
| 310 | + ); |
| 311 | + Describe describe2 = new Describe("P_2", ExecutionType.PORTAL); |
| 312 | + Execute execute2 = new Execute("P_2", Integer.MAX_VALUE); |
| 313 | + |
| 314 | + |
| 315 | + Flux<FrontendMessage> flow1 = Flux.just(bind1, describe1, execute1, Sync.INSTANCE).delayElements(Duration.ofMillis(10)); |
| 316 | + Flux<FrontendMessage> flow2 = Flux.just(bind2, describe2, execute2, Sync.INSTANCE).delayElements(Duration.ofMillis(20)); |
| 317 | + |
| 318 | + this.datarowCleanup(Flux.zip(this.client.exchange(flow1), this.client.exchange(flow2)) |
| 319 | + .flatMapIterable(t -> Arrays.asList(t.getT1(), t.getT2())) |
| 320 | + ) |
| 321 | + .as(StepVerifier::create) |
| 322 | + .assertNext(message -> assertThat(message).isInstanceOf(BindComplete.class)) |
| 323 | + .assertNext(message -> assertThat(message).isInstanceOf(BindComplete.class)) |
| 324 | + .assertNext(message -> assertThat(message).isInstanceOf(RowDescription.class)) |
| 325 | + .assertNext(message -> assertThat(message).isInstanceOf(RowDescription.class)) |
| 326 | + .assertNext(message -> assertThat(message).isInstanceOf(DataRow.class)) |
| 327 | + .assertNext(message -> assertThat(message).isInstanceOf(DataRow.class)) |
| 328 | + .expectNext(new CommandComplete("SELECT", null, 1)) |
| 329 | + .expectNext(new CommandComplete("SELECT", null, 1)) |
| 330 | + .verifyComplete(); |
| 331 | + } |
| 332 | + |
277 | 333 | @Test
|
278 | 334 | void timeoutTest() {
|
279 | 335 | PostgresqlConnectionFactory postgresqlConnectionFactory = new PostgresqlConnectionFactory(PostgresqlConnectionConfiguration.builder()
|
|
0 commit comments