|
4 | 4 | //! |
5 | 5 | //! ```rust,no_run |
6 | 6 | //! extern crate postgres; |
7 | | -//! # #[cfg(feature = "time")] |
8 | 7 | //! extern crate time; |
9 | 8 | //! |
10 | | -//! # #[cfg(not(feature = "time"))] fn main() {} |
11 | | -//! # #[cfg(feature = "time")] fn main() { |
12 | 9 | //! use time::Timespec; |
13 | 10 | //! |
14 | 11 | //! use postgres::{Connection, SslMode}; |
|
36 | 33 | //! time_created: time::get_time(), |
37 | 34 | //! data: None |
38 | 35 | //! }; |
39 | | -//! conn.execute("INSERT INTO person (name, time_created, data) |
40 | | -//! VALUES ($1, $2, $3)", |
| 36 | +//! conn.execute("INSERT INTO person (name, time_created, data) VALUES ($1, $2, $3)", |
41 | 37 | //! &[&me.name, &me.time_created, &me.data]).unwrap(); |
42 | 38 | //! |
43 | 39 | //! let stmt = conn.prepare("SELECT id, name, time_created, data FROM person") |
|
52 | 48 | //! println!("Found person {}", person.name); |
53 | 49 | //! } |
54 | 50 | //! } |
55 | | -//! # } |
56 | 51 | //! ``` |
57 | 52 | #![doc(html_root_url="https://sfackler.github.io/doc")] |
58 | 53 | #![feature(globs, macro_rules, phase, unsafe_destructor, slicing_syntax, default_type_params)] |
59 | 54 | #![warn(missing_docs)] |
60 | 55 |
|
| 56 | +#[phase(plugin, link)] |
| 57 | +extern crate log; |
61 | 58 | extern crate openssl; |
62 | | -extern crate serialize; |
63 | 59 | extern crate phf; |
64 | 60 | #[phase(plugin)] |
65 | 61 | extern crate phf_mac; |
66 | | -#[phase(plugin, link)] |
67 | | -extern crate log; |
| 62 | +extern crate serialize; |
68 | 63 | extern crate time; |
69 | 64 |
|
70 | | -use url::Url; |
71 | 65 | use openssl::crypto::hash::{HashType, Hasher}; |
72 | 66 | use openssl::ssl::{SslContext, MaybeSslStream}; |
73 | 67 | use serialize::hex::ToHex; |
74 | 68 | use std::cell::{Cell, RefCell}; |
75 | 69 | use std::cmp::max; |
76 | 70 | use std::collections::{RingBuf, HashMap}; |
| 71 | +use std::fmt; |
77 | 72 | use std::io::{BufferedStream, IoResult, IoError, IoErrorKind}; |
78 | 73 | use std::io::net::ip::Port; |
79 | 74 | use std::iter::IteratorCloneExt; |
80 | | -use std::time::Duration; |
81 | 75 | use std::mem; |
82 | | -use std::fmt; |
83 | 76 | use std::result; |
| 77 | +use std::time::Duration; |
| 78 | +use url::Url; |
84 | 79 |
|
| 80 | +pub use error::{Error, ConnectError, SqlState, DbError, ErrorPosition}; |
| 81 | +#[doc(inline)] |
| 82 | +pub use types::{Oid, Type, ToSql, FromSql}; |
85 | 83 | use io::{InternalStream, Timeout}; |
86 | | -use message::{FrontendMessage, BackendMessage, RowDescriptionEntry}; |
87 | | -use message::FrontendMessage::*; |
88 | 84 | use message::BackendMessage::*; |
| 85 | +use message::FrontendMessage::*; |
| 86 | +use message::{FrontendMessage, BackendMessage, RowDescriptionEntry}; |
89 | 87 | use message::{WriteMessage, ReadMessage}; |
90 | | -#[doc(inline)] |
91 | | -pub use types::{Oid, Type, ToSql, FromSql}; |
92 | | -pub use error::{Error, ConnectError, SqlState, DbError, ErrorPosition}; |
93 | 88 |
|
94 | 89 | #[macro_escape] |
95 | 90 | mod macros; |
96 | 91 |
|
| 92 | +mod error; |
97 | 93 | mod io; |
98 | 94 | mod message; |
99 | 95 | mod url; |
100 | 96 | mod util; |
101 | | -mod error; |
102 | 97 | pub mod types; |
103 | 98 |
|
104 | 99 | const CANARY: u32 = 0xdeadbeef; |
@@ -319,7 +314,6 @@ impl<'conn> Notifications<'conn> { |
319 | 314 | } |
320 | 315 | Err(e) => return Err(Error::IoError(e)), |
321 | 316 | } |
322 | | - |
323 | 317 | } |
324 | 318 | } |
325 | 319 | } |
@@ -669,8 +663,8 @@ impl InnerConnection { |
669 | 663 | if let Some(name) = self.unknown_types.get(&oid) { |
670 | 664 | return Ok(name.clone()); |
671 | 665 | } |
672 | | - let name = try!(self.quick_query(&*format!("SELECT typname FROM pg_type \ |
673 | | - WHERE oid={}", oid))) |
| 666 | + let name = try!(self.quick_query(&*format!("SELECT typname FROM pg_type WHERE oid={}", |
| 667 | + oid))) |
674 | 668 | .into_iter().next().unwrap().into_iter().next().unwrap().unwrap(); |
675 | 669 | self.unknown_types.insert(oid, name.clone()); |
676 | 670 | Ok(name) |
|
0 commit comments