1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
impl Connection {
pub fn client_encoding(&self) -> crate::Encoding {
unsafe { pq_sys::PQclientEncoding(self.into()) }.into()
}
pub fn set_client_encoding(&self, encoding: crate::Encoding) {
log::debug!("Setting client encoding to '{:?}'", encoding);
unsafe {
pq_sys::PQsetClientEncoding(self.into(), crate::cstr!(&encoding.to_string()));
}
}
pub fn set_error_verbosity(&self, verbosity: crate::Verbosity) -> crate::Verbosity {
log::debug!("Setting client encoding to '{:?}'", verbosity);
unsafe { pq_sys::PQsetErrorVerbosity(self.into(), verbosity.into()) }.into()
}
pub fn trace(&self, file: std::fs::File) {
use std::os::unix::io::IntoRawFd;
log::debug!("Enable trace");
unsafe {
let stream = libc::fdopen(file.into_raw_fd(), crate::cstr!("w"));
pq_sys::PQtrace(self.into(), stream as *mut pq_sys::__sFILE);
}
}
pub fn untrace(&self) {
log::debug!("Disable trace");
unsafe {
pq_sys::PQuntrace(self.into());
}
}
}