diff --git a/README.md b/README.md index b593433..4a4d025 100644 --- a/README.md +++ b/README.md @@ -13,16 +13,24 @@ Meow. PgBouncer rewritten in Rust, with sharding, load balancing and failover su 1. Session mode. 2. Transaction mode (basic). +3. `COPY` protocol support. ## Missing -1. `COPY` support. -2. Query cancellation support. -3. All the features I promised above. Will make them soon, promise :-). -4. Authentication, ehem, this proxy is letting anyone in at the moment. +1. Query cancellation support. +2. All the features I promised above. Will make them soon, promise :-). +3. Authentication, ehem, this proxy is letting anyone in at the moment. ## Benchmarks +You can setup PgBench locally through PgCat: + +``` +pgbench -h 127.0.0.1 -p 5433 -i +``` + +Coincidenly, this uses `COPY` so you can test if that works. + ### PgBouncer ``` diff --git a/src/client.rs b/src/client.rs index c5d9d3e..9298665 100644 --- a/src/client.rs +++ b/src/client.rs @@ -182,6 +182,26 @@ impl Client { } } + // CopyData + 'd' => { + // Forward the data to the server, + // don't buffer it since it can be rather large. + server.send(original).await?; + } + + 'c' | 'f' => { + // Copy is done. + server.send(original).await?; + let response = server.recv().await?; + match write_all_half(&mut self.write, response).await { + Ok(_) => (), + Err(err) => { + server.mark_bad(); + return Err(err); + } + }; + } + _ => { println!(">>> Unexpected code: {}", code); } diff --git a/src/server.rs b/src/server.rs index 6d03a35..098a77e 100644 --- a/src/server.rs +++ b/src/server.rs @@ -205,6 +205,9 @@ impl Server { break; } + // CopyInResponse: copy is starting from client to server + 'G' => break, + _ => { // Keep buffering, }