(
server: &PgliteServer,
endpoint: PglitePreparedEndpoint,
)
| 3031 | } |
| 3032 | |
| 3033 | fn pglite_prepared_update_connection( |
| 3034 | server: &PgliteServer, |
| 3035 | endpoint: PglitePreparedEndpoint, |
| 3036 | ) -> Result<PreparedPgliteConnection> { |
| 3037 | match endpoint { |
| 3038 | PglitePreparedEndpoint::Tcp => { |
| 3039 | let addr = server |
| 3040 | .tcp_addr() |
| 3041 | .ok_or_else(|| anyhow!("prepared-update PgliteServer did not bind TCP"))?; |
| 3042 | Ok(PreparedPgliteConnection::Tcp(addr)) |
| 3043 | } |
| 3044 | #[cfg(unix)] |
| 3045 | PglitePreparedEndpoint::Unix => { |
| 3046 | let socket_path = server |
| 3047 | .socket_path() |
| 3048 | .ok_or_else(|| anyhow!("prepared-update PgliteServer did not bind Unix socket"))?; |
| 3049 | let socket_dir = socket_path |
| 3050 | .parent() |
| 3051 | .ok_or_else(|| anyhow!("prepared-update Unix socket has no parent directory"))? |
| 3052 | .to_path_buf(); |
| 3053 | let port = socket_path |
| 3054 | .file_name() |
| 3055 | .and_then(|name| name.to_str()) |
| 3056 | .and_then(|name| name.strip_prefix(".s.PGSQL.")) |
| 3057 | .ok_or_else(|| { |
| 3058 | anyhow!( |
| 3059 | "prepared-update Unix socket path is not libpq-shaped: {}", |
| 3060 | socket_path.display() |
| 3061 | ) |
| 3062 | })? |
| 3063 | .parse() |
| 3064 | .context("parse prepared-update Unix socket port")?; |
| 3065 | Ok(PreparedPgliteConnection::Unix { socket_dir, port }) |
| 3066 | } |
| 3067 | } |
| 3068 | } |
| 3069 | |
| 3070 | fn run_native_prepared_update_tests( |
| 3071 | postgres_bin: &Path, |
no test coverage detected