diff --git a/.circleci/config.yml b/.circleci/config.yml index 3af99449..0f23fddc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -28,8 +28,9 @@ jobs: - image: sfackler/rust-postgres-test:5 steps: - checkout - - run: rustup component add rustfmt + - run: rustup component add rustfmt clippy - run: cargo fmt --all -- --check + - run: cargo clippy --all - *RESTORE_REGISTRY - run: cargo generate-lockfile - *SAVE_REGISTRY diff --git a/codegen/src/main.rs b/codegen/src/main.rs index 70e734c7..e6559aca 100644 --- a/codegen/src/main.rs +++ b/codegen/src/main.rs @@ -1,3 +1,5 @@ +#![warn(clippy::all)] + extern crate linked_hash_map; extern crate marksman_escape; extern crate phf_codegen; diff --git a/codegen/src/sqlstate.rs b/codegen/src/sqlstate.rs index a84d523a..c940f016 100644 --- a/codegen/src/sqlstate.rs +++ b/codegen/src/sqlstate.rs @@ -4,7 +4,7 @@ use std::fs::File; use std::io::{BufWriter, Write}; use std::path::Path; -const ERRCODES_TXT: &'static str = include_str!("errcodes.txt"); +const ERRCODES_TXT: &str = include_str!("errcodes.txt"); pub fn build(path: &Path) { let mut file = BufWriter::new(File::create(path.join("error/sqlstate.rs")).unwrap()); @@ -20,7 +20,7 @@ fn parse_codes() -> LinkedHashMap> { let mut codes = LinkedHashMap::new(); for line in ERRCODES_TXT.lines() { - if line.starts_with("#") || line.starts_with("Section") || line.trim().is_empty() { + if line.starts_with('#') || line.starts_with("Section") || line.trim().is_empty() { continue; } @@ -39,7 +39,6 @@ fn make_type(file: &mut BufWriter) { write!( file, "// Autogenerated file - DO NOT EDIT -use phf; use std::borrow::Cow; /// A SQLSTATE error code @@ -96,5 +95,5 @@ static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = " builder.entry(&**code, &format!("SqlState::{}", &names[0])); } builder.build(file).unwrap(); - write!(file, ";\n").unwrap(); + writeln!(file, ";").unwrap(); } diff --git a/codegen/src/type_gen.rs b/codegen/src/type_gen.rs index 5fe0370a..18be4bfc 100644 --- a/codegen/src/type_gen.rs +++ b/codegen/src/type_gen.rs @@ -7,8 +7,8 @@ use std::path::Path; use crate::snake_to_camel; -const PG_TYPE_H: &'static str = include_str!("pg_type.h"); -const PG_RANGE_H: &'static str = include_str!("pg_range.h"); +const PG_TYPE_H: &str = include_str!("pg_type.h"); +const PG_RANGE_H: &str = include_str!("pg_range.h"); struct Type { name: &'static str, @@ -122,7 +122,7 @@ fn make_header(w: &mut BufWriter) { "// Autogenerated file - DO NOT EDIT use std::sync::Arc; -use types::{{Type, Oid, Kind}}; +use crate::types::{{Type, Oid, Kind}}; #[derive(PartialEq, Eq, Debug)] pub struct Other {{ @@ -231,8 +231,7 @@ fn make_impl(w: &mut BufWriter, types: &BTreeMap) { write!( w, " Inner::{} => {{ - const V: &'static Kind = &Kind::{}; - V + &Kind::{} }} ", type_.variant, kind diff --git a/postgres-protocol/src/authentication/sasl.rs b/postgres-protocol/src/authentication/sasl.rs index 8488fa3c..4e34a8c8 100644 --- a/postgres-protocol/src/authentication/sasl.rs +++ b/postgres-protocol/src/authentication/sasl.rs @@ -14,9 +14,9 @@ use std::str; const NONCE_LENGTH: usize = 24; /// The identifier of the SCRAM-SHA-256 SASL authentication mechanism. -pub const SCRAM_SHA_256: &'static str = "SCRAM-SHA-256"; +pub const SCRAM_SHA_256: &str = "SCRAM-SHA-256"; /// The identifier of the SCRAM-SHA-256-PLUS SASL authentication mechanism. -pub const SCRAM_SHA_256_PLUS: &'static str = "SCRAM-SHA-256-PLUS"; +pub const SCRAM_SHA_256_PLUS: &str = "SCRAM-SHA-256-PLUS"; // since postgres passwords are not required to exclude saslprep-prohibited // characters or even be valid UTF8, we run saslprep if possible and otherwise @@ -153,7 +153,7 @@ impl ScramSha256 { state: State::Update { nonce, password: normalize(password), - channel_binding: channel_binding, + channel_binding, }, } } @@ -228,8 +228,8 @@ impl ScramSha256 { write!(&mut self.message, ",p={}", base64::encode(&*client_proof)).unwrap(); self.state = State::Finish { - salted_password: salted_password, - auth_message: auth_message, + salted_password, + auth_message, }; Ok(()) } @@ -288,7 +288,7 @@ struct Parser<'a> { impl<'a> Parser<'a> { fn new(s: &'a str) -> Parser<'a> { Parser { - s: s, + s, it: s.char_indices().peekable(), } } @@ -390,9 +390,9 @@ impl<'a> Parser<'a> { self.eof()?; Ok(ServerFirstMessage { - nonce: nonce, - salt: salt, - iteration_count: iteration_count, + nonce, + salt, + iteration_count, }) } diff --git a/postgres-protocol/src/lib.rs b/postgres-protocol/src/lib.rs index aa815c36..4cdefcd2 100644 --- a/postgres-protocol/src/lib.rs +++ b/postgres-protocol/src/lib.rs @@ -10,7 +10,7 @@ //! This library assumes that the `client_encoding` backend parameter has been //! set to `UTF8`. It will most likely not behave properly if that is not the case. #![doc(html_root_url = "https://docs.rs/postgres-protocol/0.3")] -#![warn(missing_docs, rust_2018_idioms)] +#![warn(missing_docs, rust_2018_idioms, clippy::all)] use byteorder::{BigEndian, ByteOrder}; use std::io; diff --git a/postgres-protocol/src/message/backend.rs b/postgres-protocol/src/message/backend.rs index c11516d1..f9c37b59 100644 --- a/postgres-protocol/src/message/backend.rs +++ b/postgres-protocol/src/message/backend.rs @@ -88,40 +88,37 @@ impl Message { let channel = buf.read_cstr()?; let message = buf.read_cstr()?; Message::NotificationResponse(NotificationResponseBody { - process_id: process_id, - channel: channel, - message: message, + process_id, + channel, + message, }) } b'c' => Message::CopyDone, b'C' => { let tag = buf.read_cstr()?; - Message::CommandComplete(CommandCompleteBody { tag: tag }) + Message::CommandComplete(CommandCompleteBody { tag }) } b'd' => { let storage = buf.read_all(); - Message::CopyData(CopyDataBody { storage: storage }) + Message::CopyData(CopyDataBody { storage }) } b'D' => { let len = buf.read_u16::()?; let storage = buf.read_all(); - Message::DataRow(DataRowBody { - storage: storage, - len: len, - }) + Message::DataRow(DataRowBody { storage, len }) } b'E' => { let storage = buf.read_all(); - Message::ErrorResponse(ErrorResponseBody { storage: storage }) + Message::ErrorResponse(ErrorResponseBody { storage }) } b'G' => { let format = buf.read_u8()?; let len = buf.read_u16::()?; let storage = buf.read_all(); Message::CopyInResponse(CopyInResponseBody { - format: format, - len: len, - storage: storage, + format, + len, + storage, }) } b'H' => { @@ -129,9 +126,9 @@ impl Message { let len = buf.read_u16::()?; let storage = buf.read_all(); Message::CopyOutResponse(CopyOutResponseBody { - format: format, - len: len, - storage: storage, + format, + len, + storage, }) } b'I' => Message::EmptyQueryResponse, @@ -139,14 +136,14 @@ impl Message { let process_id = buf.read_i32::()?; let secret_key = buf.read_i32::()?; Message::BackendKeyData(BackendKeyDataBody { - process_id: process_id, - secret_key: secret_key, + process_id, + secret_key, }) } b'n' => Message::NoData, b'N' => { let storage = buf.read_all(); - Message::NoticeResponse(NoticeResponseBody { storage: storage }) + Message::NoticeResponse(NoticeResponseBody { storage }) } b'R' => match buf.read_i32::()? { 0 => Message::AuthenticationOk, @@ -155,7 +152,7 @@ impl Message { 5 => { let mut salt = [0; 4]; buf.read_exact(&mut salt)?; - Message::AuthenticationMd5Password(AuthenticationMd5PasswordBody { salt: salt }) + Message::AuthenticationMd5Password(AuthenticationMd5PasswordBody { salt }) } 6 => Message::AuthenticationScmCredential, 7 => Message::AuthenticationGss, @@ -187,30 +184,21 @@ impl Message { b'S' => { let name = buf.read_cstr()?; let value = buf.read_cstr()?; - Message::ParameterStatus(ParameterStatusBody { - name: name, - value: value, - }) + Message::ParameterStatus(ParameterStatusBody { name, value }) } b't' => { let len = buf.read_u16::()?; let storage = buf.read_all(); - Message::ParameterDescription(ParameterDescriptionBody { - storage: storage, - len: len, - }) + Message::ParameterDescription(ParameterDescriptionBody { storage, len }) } b'T' => { let len = buf.read_u16::()?; let storage = buf.read_all(); - Message::RowDescription(RowDescriptionBody { - storage: storage, - len: len, - }) + Message::RowDescription(RowDescriptionBody { storage, len }) } b'Z' => { let status = buf.read_u8()?; - Message::ReadyForQuery(ReadyForQueryBody { status: status }) + Message::ReadyForQuery(ReadyForQueryBody { status }) } tag => { return Err(io::Error::new( @@ -305,7 +293,7 @@ pub struct AuthenticationSaslBody(Bytes); impl AuthenticationSaslBody { #[inline] - pub fn mechanisms<'a>(&'a self) -> SaslMechanisms<'a> { + pub fn mechanisms(&self) -> SaslMechanisms<'_> { SaslMechanisms(&self.0) } } @@ -410,7 +398,7 @@ impl CopyInResponseBody { } #[inline] - pub fn column_formats<'a>(&'a self) -> ColumnFormats<'a> { + pub fn column_formats(&self) -> ColumnFormats<'_> { ColumnFormats { remaining: self.len, buf: &self.storage, @@ -464,7 +452,7 @@ impl CopyOutResponseBody { } #[inline] - pub fn column_formats<'a>(&'a self) -> ColumnFormats<'a> { + pub fn column_formats(&self) -> ColumnFormats<'_> { ColumnFormats { remaining: self.len, buf: &self.storage, @@ -479,7 +467,7 @@ pub struct DataRowBody { impl DataRowBody { #[inline] - pub fn ranges<'a>(&'a self) -> DataRowRanges<'a> { + pub fn ranges(&self) -> DataRowRanges<'_> { DataRowRanges { buf: &self.storage, len: self.storage.len(), @@ -547,7 +535,7 @@ pub struct ErrorResponseBody { impl ErrorResponseBody { #[inline] - pub fn fields<'a>(&'a self) -> ErrorFields<'a> { + pub fn fields(&self) -> ErrorFields<'_> { ErrorFields { buf: &self.storage } } } @@ -578,10 +566,7 @@ impl<'a> FallibleIterator for ErrorFields<'a> { let value = get_str(&self.buf[..value_end])?; self.buf = &self.buf[value_end + 1..]; - Ok(Some(ErrorField { - type_: type_, - value: value, - })) + Ok(Some(ErrorField { type_, value })) } } @@ -608,7 +593,7 @@ pub struct NoticeResponseBody { impl NoticeResponseBody { #[inline] - pub fn fields<'a>(&'a self) -> ErrorFields<'a> { + pub fn fields(&self) -> ErrorFields<'_> { ErrorFields { buf: &self.storage } } } @@ -643,7 +628,7 @@ pub struct ParameterDescriptionBody { impl ParameterDescriptionBody { #[inline] - pub fn parameters<'a>(&'a self) -> Parameters<'a> { + pub fn parameters(&self) -> Parameters<'_> { Parameters { buf: &self.storage, remaining: self.len, @@ -719,7 +704,7 @@ pub struct RowDescriptionBody { impl RowDescriptionBody { #[inline] - pub fn fields<'a>(&'a self) -> Fields<'a> { + pub fn fields(&self) -> Fields<'_> { Fields { buf: &self.storage, remaining: self.len, @@ -761,13 +746,13 @@ impl<'a> FallibleIterator for Fields<'a> { let format = self.buf.read_i16::()?; Ok(Some(Field { - name: name, - table_oid: table_oid, - column_id: column_id, - type_oid: type_oid, - type_size: type_size, - type_modifier: type_modifier, - format: format, + name, + table_oid, + column_id, + type_oid, + type_size, + type_modifier, + format, })) } } diff --git a/postgres-protocol/src/message/frontend.rs b/postgres-protocol/src/message/frontend.rs index edb929ef..35bc86be 100644 --- a/postgres-protocol/src/message/frontend.rs +++ b/postgres-protocol/src/message/frontend.rs @@ -102,10 +102,16 @@ impl<'a> Message<'a> { Message::CancelRequest { process_id, secret_key, - } => Ok(cancel_request(process_id, secret_key, buf)), + } => { + cancel_request(process_id, secret_key, buf); + Ok(()) + } Message::Close { variant, name } => close(variant, name, buf), Message::CopyData { data } => copy_data(data, buf), - Message::CopyDone => Ok(copy_done(buf)), + Message::CopyDone => { + copy_done(buf); + Ok(()) + } Message::CopyFail { message } => copy_fail(message, buf), Message::Describe { variant, name } => describe(variant, name, buf), Message::Execute { portal, max_rows } => execute(portal, max_rows, buf), @@ -120,12 +126,21 @@ impl<'a> Message<'a> { sasl_initial_response(mechanism, data, buf) } Message::SaslResponse { data } => sasl_response(data, buf), - Message::SslRequest => Ok(ssl_request(buf)), + Message::SslRequest => { + ssl_request(buf); + Ok(()) + } Message::StartupMessage { parameters } => { startup_message(parameters.iter().map(|&(ref k, ref v)| (&**k, &**v)), buf) } - Message::Sync => Ok(sync(buf)), - Message::Terminate => Ok(terminate(buf)), + Message::Sync => { + sync(buf); + Ok(()) + } + Message::Terminate => { + terminate(buf); + Ok(()) + } Message::__ForExtensibility => unreachable!(), } } @@ -222,7 +237,7 @@ where #[inline] pub fn cancel_request(process_id: i32, secret_key: i32, buf: &mut Vec) { write_body(buf, |buf| { - buf.write_i32::(80877102).unwrap(); + buf.write_i32::(80_877_102).unwrap(); buf.write_i32::(process_id).unwrap(); buf.write_i32::(secret_key) }) @@ -320,12 +335,15 @@ pub fn sasl_initial_response(mechanism: &str, data: &[u8], buf: &mut Vec) -> #[inline] pub fn sasl_response(data: &[u8], buf: &mut Vec) -> io::Result<()> { buf.push(b'p'); - write_body(buf, |buf| Ok(buf.extend_from_slice(data))) + write_body(buf, |buf| { + buf.extend_from_slice(data); + Ok(()) + }) } #[inline] pub fn ssl_request(buf: &mut Vec) { - write_body(buf, |buf| buf.write_i32::(80877103)).unwrap(); + write_body(buf, |buf| buf.write_i32::(80_877_103)).unwrap(); } #[inline] @@ -334,10 +352,10 @@ where I: IntoIterator, { write_body(buf, |buf| { - buf.write_i32::(196608).unwrap(); + buf.write_i32::(196_608).unwrap(); for (key, value) in parameters { - buf.write_cstr(key.as_ref())?; - buf.write_cstr(value.as_ref())?; + buf.write_cstr(key)?; + buf.write_cstr(value)?; } buf.push(0); Ok(()) diff --git a/postgres-protocol/src/types.rs b/postgres-protocol/src/types.rs index 7a764a9d..7fac2b9d 100644 --- a/postgres-protocol/src/types.rs +++ b/postgres-protocol/src/types.rs @@ -216,7 +216,7 @@ pub fn hstore_from_sql<'a>( Ok(HstoreEntries { remaining: count, - buf: buf, + buf, }) } @@ -231,6 +231,7 @@ impl<'a> FallibleIterator for HstoreEntries<'a> { type Error = StdBox; #[inline] + #[allow(clippy::type_complexity)] fn next( &mut self, ) -> Result)>, StdBox> { @@ -324,6 +325,12 @@ impl<'a> Varbit<'a> { self.len } + /// Determines if the value has no bits. + #[inline] + pub fn is_empty(&self) -> bool { + self.len == 0 + } + /// Returns the bits as a slice of bytes. #[inline] pub fn bytes(&self) -> &'a [u8] { @@ -503,11 +510,11 @@ pub fn array_from_sql<'a>(mut buf: &'a [u8]) -> Result, StdBox FallibleIterator for ArrayDimensions<'a> { let len = self.0.read_i32::()?; let lower_bound = self.0.read_i32::()?; - Ok(Some(ArrayDimension { - len: len, - lower_bound: lower_bound, - })) + Ok(Some(ArrayDimension { len, lower_bound })) } #[inline] @@ -783,7 +787,7 @@ pub fn point_from_sql(mut buf: &[u8]) -> Result(mut buf: &'a [u8]) -> Result, StdBox()?; Ok(Path { - closed: closed, - points: points, - buf: buf, + closed, + points, + buf, }) } @@ -940,7 +944,7 @@ impl<'a> FallibleIterator for PathPoints<'a> { let x = self.buf.read_f64::()?; let y = self.buf.read_f64::()?; - Ok(Some(Point { x: x, y: y })) + Ok(Some(Point { x, y })) } #[inline] @@ -979,18 +983,19 @@ mod test { #[test] fn int4() { let mut buf = vec![]; - int4_to_sql(0x01020304, &mut buf); - assert_eq!(int4_from_sql(&buf).unwrap(), 0x01020304); + int4_to_sql(0x0102_0304, &mut buf); + assert_eq!(int4_from_sql(&buf).unwrap(), 0x0102_0304); } #[test] fn int8() { let mut buf = vec![]; - int8_to_sql(0x0102030405060708, &mut buf); - assert_eq!(int8_from_sql(&buf).unwrap(), 0x0102030405060708); + int8_to_sql(0x0102_0304_0506_0708, &mut buf); + assert_eq!(int8_from_sql(&buf).unwrap(), 0x0102_0304_0506_0708); } #[test] + #[allow(clippy::float_cmp)] fn float4() { let mut buf = vec![]; float4_to_sql(10343.95, &mut buf); @@ -998,6 +1003,7 @@ mod test { } #[test] + #[allow(clippy::float_cmp)] fn float8() { let mut buf = vec![]; float8_to_sql(10343.95, &mut buf); diff --git a/tokio-postgres-native-tls/src/lib.rs b/tokio-postgres-native-tls/src/lib.rs index 54923467..db4ecac6 100644 --- a/tokio-postgres-native-tls/src/lib.rs +++ b/tokio-postgres-native-tls/src/lib.rs @@ -1,4 +1,4 @@ -#![warn(rust_2018_idioms)] +#![warn(rust_2018_idioms, clippy::all)] use futures::{try_ready, Async, Future, Poll}; use tokio_io::{AsyncRead, AsyncWrite}; @@ -14,11 +14,6 @@ pub struct TlsConnector { } impl TlsConnector { - pub fn new(domain: &str) -> Result { - let connector = native_tls::TlsConnector::new()?; - Ok(TlsConnector::with_connector(connector, domain)) - } - pub fn with_connector(connector: native_tls::TlsConnector, domain: &str) -> TlsConnector { TlsConnector { connector: tokio_tls::TlsConnector::from(connector), diff --git a/tokio-postgres-openssl/src/lib.rs b/tokio-postgres-openssl/src/lib.rs index 58aabba5..08c482ef 100644 --- a/tokio-postgres-openssl/src/lib.rs +++ b/tokio-postgres-openssl/src/lib.rs @@ -1,4 +1,4 @@ -#![warn(rust_2018_idioms)] +#![warn(rust_2018_idioms, clippy::all)] use futures::{try_ready, Async, Future, Poll}; use openssl::hash::MessageDigest; diff --git a/tokio-postgres/Cargo.toml b/tokio-postgres/Cargo.toml index 00a09630..398580ff 100644 --- a/tokio-postgres/Cargo.toml +++ b/tokio-postgres/Cargo.toml @@ -34,7 +34,7 @@ with-serde_json-1 = ["serde-1", "serde_json-1"] [dependencies] antidote = "1.0" bytes = "0.4" -fallible-iterator = "0.1.3" +fallible-iterator = "0.1.6" futures = "0.1.7" futures-cpupool = "0.1" log = "0.4" diff --git a/tokio-postgres/src/builder.rs b/tokio-postgres/src/builder.rs index 8317522a..de3ec264 100644 --- a/tokio-postgres/src/builder.rs +++ b/tokio-postgres/src/builder.rs @@ -10,6 +10,12 @@ pub struct Builder { password: Option, } +impl Default for Builder { + fn default() -> Builder { + Builder::new() + } +} + impl Builder { pub fn new() -> Builder { let mut params = HashMap::new(); diff --git a/tokio-postgres/src/error/mod.rs b/tokio-postgres/src/error/mod.rs index 20bb95e5..1ff20c37 100644 --- a/tokio-postgres/src/error/mod.rs +++ b/tokio-postgres/src/error/mod.rs @@ -8,6 +8,7 @@ use std::io; pub use self::sqlstate::*; +#[allow(clippy::unreadable_literal)] mod sqlstate; /// The severity of a Postgres error or notice. @@ -85,7 +86,7 @@ pub struct DbError { } impl DbError { - pub(crate) fn new(fields: &mut ErrorFields<'_>) -> io::Result { + pub(crate) fn parse(fields: &mut ErrorFields<'_>) -> io::Result { let mut severity = None; let mut parsed_severity = None; let mut code = None; @@ -160,18 +161,18 @@ impl DbError { Ok(DbError { severity: severity .ok_or_else(|| io::Error::new(io::ErrorKind::InvalidInput, "`S` field missing"))?, - parsed_severity: parsed_severity, + parsed_severity, code: code .ok_or_else(|| io::Error::new(io::ErrorKind::InvalidInput, "`C` field missing"))?, message: message .ok_or_else(|| io::Error::new(io::ErrorKind::InvalidInput, "`M` field missing"))?, - detail: detail, - hint: hint, + detail, + hint, position: match normal_position { Some(position) => Some(ErrorPosition::Original(position)), None => match internal_position { Some(position) => Some(ErrorPosition::Internal { - position: position, + position, query: internal_query.ok_or_else(|| { io::Error::new( io::ErrorKind::InvalidInput, @@ -182,15 +183,15 @@ impl DbError { None => None, }, }, - where_: where_, - schema: schema, - table: table, - column: column, - datatype: datatype, - constraint: constraint, - file: file, - line: line, - routine: routine, + where_, + schema, + table, + column, + datatype, + constraint, + file, + line, + routine, }) } @@ -423,8 +424,9 @@ impl Error { Error::new(Kind::UnexpectedMessage, None) } + #[allow(clippy::needless_pass_by_value)] pub(crate) fn db(error: ErrorResponseBody) -> Error { - match DbError::new(&mut error.fields()) { + match DbError::parse(&mut error.fields()) { Ok(e) => Error::new(Kind::Db, Some(Box::new(e))), Err(e) => Error::new(Kind::Parse, Some(Box::new(e))), } @@ -438,6 +440,7 @@ impl Error { Error::new(Kind::Encode, Some(Box::new(e))) } + #[allow(clippy::wrong_self_convention)] pub(crate) fn to_sql(e: Box) -> Error { Error::new(Kind::ToSql, Some(e)) } diff --git a/tokio-postgres/src/error/sqlstate.rs b/tokio-postgres/src/error/sqlstate.rs index 7dddfc7e..aef7b796 100644 --- a/tokio-postgres/src/error/sqlstate.rs +++ b/tokio-postgres/src/error/sqlstate.rs @@ -1,5 +1,4 @@ // Autogenerated file - DO NOT EDIT -use phf; use std::borrow::Cow; /// A SQLSTATE error code @@ -33,8 +32,7 @@ impl SqlState { pub const WARNING_IMPLICIT_ZERO_BIT_PADDING: SqlState = SqlState(Cow::Borrowed("01008")); /// 01003 - pub const WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION: SqlState = - SqlState(Cow::Borrowed("01003")); + pub const WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION: SqlState = SqlState(Cow::Borrowed("01003")); /// 01007 pub const WARNING_PRIVILEGE_NOT_GRANTED: SqlState = SqlState(Cow::Borrowed("01007")); @@ -52,8 +50,7 @@ impl SqlState { pub const NO_DATA: SqlState = SqlState(Cow::Borrowed("02000")); /// 02001 - pub const NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED: SqlState = - SqlState(Cow::Borrowed("02001")); + pub const NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED: SqlState = SqlState(Cow::Borrowed("02001")); /// 03000 pub const SQL_STATEMENT_NOT_YET_COMPLETE: SqlState = SqlState(Cow::Borrowed("03000")); @@ -68,12 +65,10 @@ impl SqlState { pub const CONNECTION_FAILURE: SqlState = SqlState(Cow::Borrowed("08006")); /// 08001 - pub const SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION: SqlState = - SqlState(Cow::Borrowed("08001")); + pub const SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION: SqlState = SqlState(Cow::Borrowed("08001")); /// 08004 - pub const SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION: SqlState = - SqlState(Cow::Borrowed("08004")); + pub const SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION: SqlState = SqlState(Cow::Borrowed("08004")); /// 08007 pub const TRANSACTION_RESOLUTION_UNKNOWN: SqlState = SqlState(Cow::Borrowed("08007")); @@ -109,8 +104,7 @@ impl SqlState { pub const DIAGNOSTICS_EXCEPTION: SqlState = SqlState(Cow::Borrowed("0Z000")); /// 0Z002 - pub const STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER: SqlState = - SqlState(Cow::Borrowed("0Z002")); + pub const STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER: SqlState = SqlState(Cow::Borrowed("0Z002")); /// 20000 pub const CASE_NOT_FOUND: SqlState = SqlState(Cow::Borrowed("20000")); @@ -164,8 +158,7 @@ impl SqlState { pub const INVALID_ARGUMENT_FOR_POWER_FUNCTION: SqlState = SqlState(Cow::Borrowed("2201F")); /// 2201G - pub const INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION: SqlState = - SqlState(Cow::Borrowed("2201G")); + pub const INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION: SqlState = SqlState(Cow::Borrowed("2201G")); /// 22018 pub const INVALID_CHARACTER_VALUE_FOR_CAST: SqlState = SqlState(Cow::Borrowed("22018")); @@ -198,8 +191,7 @@ impl SqlState { pub const INVALID_ROW_COUNT_IN_LIMIT_CLAUSE: SqlState = SqlState(Cow::Borrowed("2201W")); /// 2201X - pub const INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE: SqlState = - SqlState(Cow::Borrowed("2201X")); + pub const INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE: SqlState = SqlState(Cow::Borrowed("2201X")); /// 2202H pub const INVALID_TABLESAMPLE_ARGUMENT: SqlState = SqlState(Cow::Borrowed("2202H")); @@ -310,27 +302,22 @@ impl SqlState { pub const BRANCH_TRANSACTION_ALREADY_ACTIVE: SqlState = SqlState(Cow::Borrowed("25002")); /// 25008 - pub const HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL: SqlState = - SqlState(Cow::Borrowed("25008")); + pub const HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL: SqlState = SqlState(Cow::Borrowed("25008")); /// 25003 - pub const INAPPROPRIATE_ACCESS_MODE_FOR_BRANCH_TRANSACTION: SqlState = - SqlState(Cow::Borrowed("25003")); + pub const INAPPROPRIATE_ACCESS_MODE_FOR_BRANCH_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25003")); /// 25004 - pub const INAPPROPRIATE_ISOLATION_LEVEL_FOR_BRANCH_TRANSACTION: SqlState = - SqlState(Cow::Borrowed("25004")); + pub const INAPPROPRIATE_ISOLATION_LEVEL_FOR_BRANCH_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25004")); /// 25005 - pub const NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION: SqlState = - SqlState(Cow::Borrowed("25005")); + pub const NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25005")); /// 25006 pub const READ_ONLY_SQL_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25006")); /// 25007 - pub const SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED: SqlState = - SqlState(Cow::Borrowed("25007")); + pub const SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED: SqlState = SqlState(Cow::Borrowed("25007")); /// 25P01 pub const NO_ACTIVE_SQL_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25P01")); @@ -357,8 +344,7 @@ impl SqlState { pub const INVALID_PASSWORD: SqlState = SqlState(Cow::Borrowed("28P01")); /// 2B000 - pub const DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST: SqlState = - SqlState(Cow::Borrowed("2B000")); + pub const DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST: SqlState = SqlState(Cow::Borrowed("2B000")); /// 2BP01 pub const DEPENDENT_OBJECTS_STILL_EXIST: SqlState = SqlState(Cow::Borrowed("2BP01")); @@ -370,8 +356,7 @@ impl SqlState { pub const SQL_ROUTINE_EXCEPTION: SqlState = SqlState(Cow::Borrowed("2F000")); /// 2F005 - pub const S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT: SqlState = - SqlState(Cow::Borrowed("2F005")); + pub const S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT: SqlState = SqlState(Cow::Borrowed("2F005")); /// 2F002 pub const S_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED: SqlState = SqlState(Cow::Borrowed("2F002")); @@ -713,8 +698,7 @@ impl SqlState { pub const FDW_INVALID_OPTION_NAME: SqlState = SqlState(Cow::Borrowed("HV00D")); /// HV090 - pub const FDW_INVALID_STRING_LENGTH_OR_BUFFER_LENGTH: SqlState = - SqlState(Cow::Borrowed("HV090")); + pub const FDW_INVALID_STRING_LENGTH_OR_BUFFER_LENGTH: SqlState = SqlState(Cow::Borrowed("HV090")); /// HV00A pub const FDW_INVALID_STRING_FORMAT: SqlState = SqlState(Cow::Borrowed("HV00A")); @@ -778,299 +762,299 @@ impl SqlState { } #[cfg_attr(rustfmt, rustfmt_skip)] static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = ::phf::Map { - key: 1897749892740154578, + key: 6246114685207409605, disps: ::phf::Slice::Static(&[ - (1, 99), - (0, 0), - (1, 5), - (0, 3), - (0, 110), - (0, 54), - (0, 3), + (1, 77), + (0, 21), + (0, 6), (0, 13), - (0, 0), - (0, 24), - (0, 214), - (0, 52), - (1, 34), - (0, 33), - (0, 44), - (0, 130), - (0, 16), - (0, 187), - (0, 3), - (13, 168), - (0, 4), - (0, 19), - (0, 13), - (0, 87), - (0, 0), - (0, 108), - (0, 123), - (7, 181), - (0, 109), - (0, 32), - (0, 0), - (1, 69), - (1, 81), - (1, 219), - (0, 157), - (2, 41), - (8, 141), + (0, 28), + (0, 30), + (0, 1), + (0, 47), (0, 5), + (0, 5), + (0, 52), + (0, 96), + (0, 66), + (3, 167), + (0, 10), + (0, 56), + (2, 159), + (0, 28), + (0, 11), + (0, 6), (0, 0), + (1, 188), + (7, 122), + (2, 32), (1, 6), - (0, 3), - (1, 146), - (1, 227), - (9, 94), - (10, 158), - (29, 65), - (3, 2), - (0, 33), - (1, 94), + (1, 142), + (1, 0), + (1, 71), + (2, 35), + (0, 1), + (0, 68), + (0, 66), + (5, 43), + (0, 0), + (1, 0), + (2, 123), + (1, 1), + (0, 31), + (3, 7), + (3, 172), + (0, 35), + (0, 107), + (0, 106), + (0, 102), + (17, 207), + (6, 8), + (0, 105), + (26, 87), + (0, 21), ]), entries: ::phf::Slice::Static(&[ - ("23001", SqlState::RESTRICT_VIOLATION), - ("42830", SqlState::INVALID_FOREIGN_KEY), - ("P0000", SqlState::PLPGSQL_ERROR), - ("58000", SqlState::SYSTEM_ERROR), - ("57P01", SqlState::ADMIN_SHUTDOWN), - ("22P04", SqlState::BAD_COPY_FILE_FORMAT), - ("42P05", SqlState::DUPLICATE_PSTATEMENT), - ("28000", SqlState::INVALID_AUTHORIZATION_SPECIFICATION), - ("2202E", SqlState::ARRAY_ELEMENT_ERROR), - ("2F005", SqlState::S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT), - ("53400", SqlState::CONFIGURATION_LIMIT_EXCEEDED), - ("20000", SqlState::CASE_NOT_FOUND), - ("25004", SqlState::INAPPROPRIATE_ISOLATION_LEVEL_FOR_BRANCH_TRANSACTION), - ("09000", SqlState::TRIGGERED_ACTION_EXCEPTION), - ("42P10", SqlState::INVALID_COLUMN_REFERENCE), - ("39P03", SqlState::E_R_I_E_EVENT_TRIGGER_PROTOCOL_VIOLATED), - ("08000", SqlState::CONNECTION_EXCEPTION), - ("08006", SqlState::CONNECTION_FAILURE), - ("2201W", SqlState::INVALID_ROW_COUNT_IN_LIMIT_CLAUSE), - ("03000", SqlState::SQL_STATEMENT_NOT_YET_COMPLETE), - ("22014", SqlState::INVALID_ARGUMENT_FOR_NTILE), - ("42611", SqlState::INVALID_COLUMN_DEFINITION), - ("42P11", SqlState::INVALID_CURSOR_DEFINITION), - ("2200N", SqlState::INVALID_XML_CONTENT), - ("57014", SqlState::QUERY_CANCELED), - ("01003", SqlState::WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION), - ("01000", SqlState::WARNING), - ("55P04", SqlState::UNSAFE_NEW_ENUM_VALUE_USAGE), - ("25003", SqlState::INAPPROPRIATE_ACCESS_MODE_FOR_BRANCH_TRANSACTION), - ("2200L", SqlState::NOT_AN_XML_DOCUMENT), - ("42846", SqlState::CANNOT_COERCE), - ("55P03", SqlState::LOCK_NOT_AVAILABLE), - ("08007", SqlState::TRANSACTION_RESOLUTION_UNKNOWN), - ("XX000", SqlState::INTERNAL_ERROR), - ("22005", SqlState::ERROR_IN_ASSIGNMENT), - ("22P03", SqlState::INVALID_BINARY_REPRESENTATION), - ("2201X", SqlState::INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE), - ("54011", SqlState::TOO_MANY_COLUMNS), - ("HV008", SqlState::FDW_INVALID_COLUMN_NUMBER), - ("HV009", SqlState::FDW_INVALID_USE_OF_NULL_POINTER), - ("0LP01", SqlState::INVALID_GRANT_OPERATION), - ("42704", SqlState::UNDEFINED_OBJECT), - ("25005", SqlState::NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION), - ("25P03", SqlState::IDLE_IN_TRANSACTION_SESSION_TIMEOUT), - ("44000", SqlState::WITH_CHECK_OPTION_VIOLATION), - ("22024", SqlState::UNTERMINATED_C_STRING), - ("0L000", SqlState::INVALID_GRANTOR), - ("40000", SqlState::TRANSACTION_ROLLBACK), - ("42P08", SqlState::AMBIGUOUS_PARAMETER), - ("38000", SqlState::EXTERNAL_ROUTINE_EXCEPTION), - ("42939", SqlState::RESERVED_NAME), - ("40001", SqlState::T_R_SERIALIZATION_FAILURE), - ("HV00K", SqlState::FDW_REPLY_HANDLE), - ("2F002", SqlState::S_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED), - ("HV001", SqlState::FDW_OUT_OF_MEMORY), - ("42P19", SqlState::INVALID_RECURSION), - ("HV002", SqlState::FDW_DYNAMIC_PARAMETER_VALUE_NEEDED), - ("0A000", SqlState::FEATURE_NOT_SUPPORTED), - ("58P02", SqlState::DUPLICATE_FILE), - ("25006", SqlState::READ_ONLY_SQL_TRANSACTION), - ("22009", SqlState::INVALID_TIME_ZONE_DISPLACEMENT_VALUE), - ("0F001", SqlState::L_E_INVALID_SPECIFICATION), - ("P0002", SqlState::NO_DATA_FOUND), - ("2F000", SqlState::SQL_ROUTINE_EXCEPTION), - ("01006", SqlState::WARNING_PRIVILEGE_NOT_REVOKED), - ("22025", SqlState::INVALID_ESCAPE_SEQUENCE), - ("22027", SqlState::TRIM_ERROR), - ("54001", SqlState::STATEMENT_TOO_COMPLEX), - ("42602", SqlState::INVALID_NAME), - ("54023", SqlState::TOO_MANY_ARGUMENTS), - ("2200T", SqlState::INVALID_XML_PROCESSING_INSTRUCTION), - ("01007", SqlState::WARNING_PRIVILEGE_NOT_GRANTED), - ("22000", SqlState::DATA_EXCEPTION), - ("28P01", SqlState::INVALID_PASSWORD), - ("23514", SqlState::CHECK_VIOLATION), - ("39P02", SqlState::E_R_I_E_SRF_PROTOCOL_VIOLATED), - ("57P02", SqlState::CRASH_SHUTDOWN), - ("42P03", SqlState::DUPLICATE_CURSOR), - ("22021", SqlState::CHARACTER_NOT_IN_REPERTOIRE), - ("HV00P", SqlState::FDW_NO_SCHEMAS), - ("42701", SqlState::DUPLICATE_COLUMN), - ("42P15", SqlState::INVALID_SCHEMA_DEFINITION), - ("HV00B", SqlState::FDW_INVALID_HANDLE), - ("34000", SqlState::INVALID_CURSOR_NAME), - ("22P06", SqlState::NONSTANDARD_USE_OF_ESCAPE_CHARACTER), - ("P0001", SqlState::RAISE_EXCEPTION), - ("08P01", SqlState::PROTOCOL_VIOLATION), - ("42723", SqlState::DUPLICATE_FUNCTION), - ("08001", SqlState::SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION), - ("HV006", SqlState::FDW_INVALID_DATA_TYPE_DESCRIPTORS), - ("23000", SqlState::INTEGRITY_CONSTRAINT_VIOLATION), - ("42712", SqlState::DUPLICATE_ALIAS), - ("2201G", SqlState::INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION), - ("2200F", SqlState::ZERO_LENGTH_CHARACTER_STRING), - ("XX002", SqlState::INDEX_CORRUPTED), - ("53300", SqlState::TOO_MANY_CONNECTIONS), - ("38002", SqlState::E_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED), - ("22015", SqlState::INTERVAL_FIELD_OVERFLOW), - ("22P01", SqlState::FLOATING_POINT_EXCEPTION), - ("22012", SqlState::DIVISION_BY_ZERO), - ("XX001", SqlState::DATA_CORRUPTED), - ("0100C", SqlState::WARNING_DYNAMIC_RESULT_SETS_RETURNED), - ("42P01", SqlState::UNDEFINED_TABLE), - ("25002", SqlState::BRANCH_TRANSACTION_ALREADY_ACTIVE), - ("2D000", SqlState::INVALID_TRANSACTION_TERMINATION), - ("P0004", SqlState::ASSERT_FAILURE), - ("2200C", SqlState::INVALID_USE_OF_ESCAPE_CHARACTER), - ("HV00R", SqlState::FDW_TABLE_NOT_FOUND), - ("22016", SqlState::INVALID_ARGUMENT_FOR_NTH_VALUE), - ("01P01", SqlState::WARNING_DEPRECATED_FEATURE), - ("F0000", SqlState::CONFIG_FILE_ERROR), - ("0Z000", SqlState::DIAGNOSTICS_EXCEPTION), - ("42P02", SqlState::UNDEFINED_PARAMETER), - ("2200S", SqlState::INVALID_XML_COMMENT), - ("2200H", SqlState::SEQUENCE_GENERATOR_LIMIT_EXCEEDED), - ("HV00C", SqlState::FDW_INVALID_OPTION_INDEX), - ("38004", SqlState::E_R_E_READING_SQL_DATA_NOT_PERMITTED), - ("42703", SqlState::UNDEFINED_COLUMN), - ("23503", SqlState::FOREIGN_KEY_VIOLATION), - ("42000", SqlState::SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION), - ("22004", SqlState::NULL_VALUE_NOT_ALLOWED), - ("25008", SqlState::HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL), - ("22018", SqlState::INVALID_CHARACTER_VALUE_FOR_CAST), - ("22023", SqlState::INVALID_PARAMETER_VALUE), - ("22011", SqlState::SUBSTRING_ERROR), - ("40002", SqlState::T_R_INTEGRITY_CONSTRAINT_VIOLATION), - ("42803", SqlState::GROUPING_ERROR), - ("72000", SqlState::SNAPSHOT_TOO_OLD), - ("HV010", SqlState::FDW_FUNCTION_SEQUENCE_ERROR), - ("42809", SqlState::WRONG_OBJECT_TYPE), ("42P16", SqlState::INVALID_TABLE_DEFINITION), - ("HV00D", SqlState::FDW_INVALID_OPTION_NAME), - ("39000", SqlState::EXTERNAL_ROUTINE_INVOCATION_EXCEPTION), - ("2202G", SqlState::INVALID_TABLESAMPLE_REPEAT), - ("42601", SqlState::SYNTAX_ERROR), - ("42622", SqlState::NAME_TOO_LONG), - ("HV00L", SqlState::FDW_UNABLE_TO_CREATE_EXECUTION), - ("25000", SqlState::INVALID_TRANSACTION_STATE), - ("3B000", SqlState::SAVEPOINT_EXCEPTION), - ("42P21", SqlState::COLLATION_MISMATCH), - ("23505", SqlState::UNIQUE_VIOLATION), - ("22001", SqlState::STRING_DATA_RIGHT_TRUNCATION), - ("02001", SqlState::NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED), - ("21000", SqlState::CARDINALITY_VIOLATION), - ("58P01", SqlState::UNDEFINED_FILE), - ("HV091", SqlState::FDW_INVALID_DESCRIPTOR_FIELD_IDENTIFIER), - ("25P01", SqlState::NO_ACTIVE_SQL_TRANSACTION), - ("40P01", SqlState::T_R_DEADLOCK_DETECTED), - ("HV021", SqlState::FDW_INCONSISTENT_DESCRIPTOR_INFORMATION), - ("42P09", SqlState::AMBIGUOUS_ALIAS), - ("25007", SqlState::SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED), - ("23P01", SqlState::EXCLUSION_VIOLATION), - ("HV00J", SqlState::FDW_OPTION_NAME_NOT_FOUND), - ("58030", SqlState::IO_ERROR), - ("HV004", SqlState::FDW_INVALID_DATA_TYPE), - ("42710", SqlState::DUPLICATE_OBJECT), - ("HV090", SqlState::FDW_INVALID_STRING_LENGTH_OR_BUFFER_LENGTH), - ("42P18", SqlState::INDETERMINATE_DATATYPE), - ("HV00M", SqlState::FDW_UNABLE_TO_CREATE_REPLY), - ("42804", SqlState::DATATYPE_MISMATCH), - ("24000", SqlState::INVALID_CURSOR_STATE), - ("HV007", SqlState::FDW_INVALID_COLUMN_NAME), - ("2201E", SqlState::INVALID_ARGUMENT_FOR_LOG), - ("42P22", SqlState::INDETERMINATE_COLLATION), - ("22P05", SqlState::UNTRANSLATABLE_CHARACTER), - ("42P07", SqlState::DUPLICATE_TABLE), - ("2F004", SqlState::S_R_E_READING_SQL_DATA_NOT_PERMITTED), - ("23502", SqlState::NOT_NULL_VIOLATION), - ("57000", SqlState::OPERATOR_INTERVENTION), - ("HV000", SqlState::FDW_ERROR), - ("42883", SqlState::UNDEFINED_FUNCTION), - ("2201B", SqlState::INVALID_REGULAR_EXPRESSION), - ("2200D", SqlState::INVALID_ESCAPE_OCTET), - ("42P06", SqlState::DUPLICATE_SCHEMA), - ("38003", SqlState::E_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED), - ("22026", SqlState::STRING_DATA_LENGTH_MISMATCH), - ("P0003", SqlState::TOO_MANY_ROWS), - ("3D000", SqlState::INVALID_CATALOG_NAME), - ("0B000", SqlState::INVALID_TRANSACTION_INITIATION), - ("55006", SqlState::OBJECT_IN_USE), - ("53200", SqlState::OUT_OF_MEMORY), - ("3F000", SqlState::INVALID_SCHEMA_NAME), - ("53100", SqlState::DISK_FULL), - ("2F003", SqlState::S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED), - ("55P02", SqlState::CANT_CHANGE_RUNTIME_PARAM), - ("01004", SqlState::WARNING_STRING_DATA_RIGHT_TRUNCATION), - ("3B001", SqlState::S_E_INVALID_SPECIFICATION), - ("2200G", SqlState::MOST_SPECIFIC_TYPE_MISMATCH), ("428C9", SqlState::GENERATED_ALWAYS), - ("HV005", SqlState::FDW_COLUMN_NAME_NOT_FOUND), - ("2201F", SqlState::INVALID_ARGUMENT_FOR_POWER_FUNCTION), - ("22022", SqlState::INDICATOR_OVERFLOW), - ("HV00Q", SqlState::FDW_SCHEMA_NOT_FOUND), - ("0F000", SqlState::LOCATOR_EXCEPTION), - ("22002", SqlState::NULL_VALUE_NO_INDICATOR_PARAMETER), - ("02000", SqlState::NO_DATA), - ("2202H", SqlState::INVALID_TABLESAMPLE_ARGUMENT), - ("27000", SqlState::TRIGGERED_DATA_CHANGE_VIOLATION), - ("2BP01", SqlState::DEPENDENT_OBJECTS_STILL_EXIST), - ("55000", SqlState::OBJECT_NOT_IN_PREREQUISITE_STATE), - ("39001", SqlState::E_R_I_E_INVALID_SQLSTATE_RETURNED), - ("08004", SqlState::SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION), - ("42P13", SqlState::INVALID_FUNCTION_DEFINITION), - ("HV024", SqlState::FDW_INVALID_ATTRIBUTE_VALUE), - ("22019", SqlState::INVALID_ESCAPE_CHARACTER), - ("54000", SqlState::PROGRAM_LIMIT_EXCEEDED), - ("42501", SqlState::INSUFFICIENT_PRIVILEGE), - ("HV00A", SqlState::FDW_INVALID_STRING_FORMAT), - ("42702", SqlState::AMBIGUOUS_COLUMN), - ("53000", SqlState::INSUFFICIENT_RESOURCES), - ("25P02", SqlState::IN_FAILED_SQL_TRANSACTION), - ("22010", SqlState::INVALID_INDICATOR_PARAMETER_VALUE), - ("01008", SqlState::WARNING_IMPLICIT_ZERO_BIT_PADDING), - ("HV014", SqlState::FDW_TOO_MANY_HANDLES), - ("42P20", SqlState::WINDOWING_ERROR), - ("42725", SqlState::AMBIGUOUS_FUNCTION), - ("F0001", SqlState::LOCK_FILE_EXISTS), - ("08003", SqlState::CONNECTION_DOES_NOT_EXIST), - ("2200M", SqlState::INVALID_XML_DOCUMENT), + ("22015", SqlState::INTERVAL_FIELD_OVERFLOW), + ("42622", SqlState::NAME_TOO_LONG), + ("42804", SqlState::DATATYPE_MISMATCH), ("22003", SqlState::NUMERIC_VALUE_OUT_OF_RANGE), - ("39004", SqlState::E_R_I_E_NULL_VALUE_NOT_ALLOWED), - ("2200B", SqlState::ESCAPE_CHARACTER_CONFLICT), - ("0P000", SqlState::INVALID_ROLE_SPECIFICATION), - ("00000", SqlState::SUCCESSFUL_COMPLETION), - ("22P02", SqlState::INVALID_TEXT_REPRESENTATION), - ("25001", SqlState::ACTIVE_SQL_TRANSACTION), - ("HV00N", SqlState::FDW_UNABLE_TO_ESTABLISH_CONNECTION), - ("39P01", SqlState::E_R_I_E_TRIGGER_PROTOCOL_VIOLATED), - ("2B000", SqlState::DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST), + ("22000", SqlState::DATA_EXCEPTION), + ("22004", SqlState::NULL_VALUE_NOT_ALLOWED), + ("22P05", SqlState::UNTRANSLATABLE_CHARACTER), + ("22016", SqlState::INVALID_ARGUMENT_FOR_NTH_VALUE), + ("2201B", SqlState::INVALID_REGULAR_EXPRESSION), + ("HV001", SqlState::FDW_OUT_OF_MEMORY), + ("42704", SqlState::UNDEFINED_OBJECT), + ("42703", SqlState::UNDEFINED_COLUMN), + ("53300", SqlState::TOO_MANY_CONNECTIONS), + ("23505", SqlState::UNIQUE_VIOLATION), + ("42712", SqlState::DUPLICATE_ALIAS), ("22008", SqlState::DATETIME_FIELD_OVERFLOW), - ("42P14", SqlState::INVALID_PSTATEMENT_DEFINITION), - ("57P04", SqlState::DATABASE_DROPPED), + ("HV024", SqlState::FDW_INVALID_ATTRIBUTE_VALUE), ("26000", SqlState::INVALID_SQL_STATEMENT_NAME), - ("42P17", SqlState::INVALID_OBJECT_DEFINITION), - ("42P04", SqlState::DUPLICATE_DATABASE), - ("38001", SqlState::E_R_E_CONTAINING_SQL_NOT_PERMITTED), - ("0Z002", SqlState::STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER), - ("22007", SqlState::INVALID_DATETIME_FORMAT), - ("40003", SqlState::T_R_STATEMENT_COMPLETION_UNKNOWN), + ("20000", SqlState::CASE_NOT_FOUND), + ("2200L", SqlState::NOT_AN_XML_DOCUMENT), + ("42939", SqlState::RESERVED_NAME), ("42P12", SqlState::INVALID_DATABASE_DEFINITION), + ("42P20", SqlState::WINDOWING_ERROR), + ("25003", SqlState::INAPPROPRIATE_ACCESS_MODE_FOR_BRANCH_TRANSACTION), + ("42P09", SqlState::AMBIGUOUS_ALIAS), + ("HV00B", SqlState::FDW_INVALID_HANDLE), + ("54011", SqlState::TOO_MANY_COLUMNS), + ("42725", SqlState::AMBIGUOUS_FUNCTION), + ("25002", SqlState::BRANCH_TRANSACTION_ALREADY_ACTIVE), + ("42701", SqlState::DUPLICATE_COLUMN), + ("HV009", SqlState::FDW_INVALID_USE_OF_NULL_POINTER), + ("38003", SqlState::E_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED), + ("0P000", SqlState::INVALID_ROLE_SPECIFICATION), + ("39004", SqlState::E_R_I_E_NULL_VALUE_NOT_ALLOWED), + ("HV002", SqlState::FDW_DYNAMIC_PARAMETER_VALUE_NEEDED), + ("39P01", SqlState::E_R_I_E_TRIGGER_PROTOCOL_VIOLATED), + ("08003", SqlState::CONNECTION_DOES_NOT_EXIST), + ("22022", SqlState::INDICATOR_OVERFLOW), + ("02001", SqlState::NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED), + ("01008", SqlState::WARNING_IMPLICIT_ZERO_BIT_PADDING), + ("54000", SqlState::PROGRAM_LIMIT_EXCEEDED), + ("22019", SqlState::INVALID_ESCAPE_CHARACTER), + ("42P19", SqlState::INVALID_RECURSION), + ("XX000", SqlState::INTERNAL_ERROR), + ("HV00K", SqlState::FDW_REPLY_HANDLE), + ("25005", SqlState::NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION), + ("HV004", SqlState::FDW_INVALID_DATA_TYPE), + ("24000", SqlState::INVALID_CURSOR_STATE), + ("42P11", SqlState::INVALID_CURSOR_DEFINITION), + ("0100C", SqlState::WARNING_DYNAMIC_RESULT_SETS_RETURNED), + ("HV014", SqlState::FDW_TOO_MANY_HANDLES), + ("0Z000", SqlState::DIAGNOSTICS_EXCEPTION), + ("57P04", SqlState::DATABASE_DROPPED), + ("38002", SqlState::E_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED), + ("HV00Q", SqlState::FDW_SCHEMA_NOT_FOUND), + ("22P06", SqlState::NONSTANDARD_USE_OF_ESCAPE_CHARACTER), + ("22011", SqlState::SUBSTRING_ERROR), + ("42P21", SqlState::COLLATION_MISMATCH), + ("0F001", SqlState::L_E_INVALID_SPECIFICATION), + ("23502", SqlState::NOT_NULL_VIOLATION), + ("HV00M", SqlState::FDW_UNABLE_TO_CREATE_REPLY), + ("0L000", SqlState::INVALID_GRANTOR), + ("42809", SqlState::WRONG_OBJECT_TYPE), + ("23503", SqlState::FOREIGN_KEY_VIOLATION), + ("HV021", SqlState::FDW_INCONSISTENT_DESCRIPTOR_INFORMATION), + ("25001", SqlState::ACTIVE_SQL_TRANSACTION), + ("44000", SqlState::WITH_CHECK_OPTION_VIOLATION), + ("42P03", SqlState::DUPLICATE_CURSOR), + ("P0004", SqlState::ASSERT_FAILURE), + ("P0003", SqlState::TOO_MANY_ROWS), + ("2F002", SqlState::S_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED), + ("40003", SqlState::T_R_STATEMENT_COMPLETION_UNKNOWN), + ("22014", SqlState::INVALID_ARGUMENT_FOR_NTILE), + ("22010", SqlState::INVALID_INDICATOR_PARAMETER_VALUE), + ("40000", SqlState::TRANSACTION_ROLLBACK), + ("2201G", SqlState::INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION), + ("42000", SqlState::SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION), + ("55P03", SqlState::LOCK_NOT_AVAILABLE), + ("57000", SqlState::OPERATOR_INTERVENTION), + ("42P10", SqlState::INVALID_COLUMN_REFERENCE), + ("HV008", SqlState::FDW_INVALID_COLUMN_NUMBER), + ("22021", SqlState::CHARACTER_NOT_IN_REPERTOIRE), + ("0Z002", SqlState::STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER), + ("39000", SqlState::EXTERNAL_ROUTINE_INVOCATION_EXCEPTION), + ("28000", SqlState::INVALID_AUTHORIZATION_SPECIFICATION), + ("42710", SqlState::DUPLICATE_OBJECT), + ("03000", SqlState::SQL_STATEMENT_NOT_YET_COMPLETE), + ("54023", SqlState::TOO_MANY_ARGUMENTS), + ("72000", SqlState::SNAPSHOT_TOO_OLD), + ("HV00P", SqlState::FDW_NO_SCHEMAS), + ("38001", SqlState::E_R_E_CONTAINING_SQL_NOT_PERMITTED), + ("2200G", SqlState::MOST_SPECIFIC_TYPE_MISMATCH), + ("2201E", SqlState::INVALID_ARGUMENT_FOR_LOG), + ("58000", SqlState::SYSTEM_ERROR), + ("42P07", SqlState::DUPLICATE_TABLE), + ("22025", SqlState::INVALID_ESCAPE_SEQUENCE), + ("2201F", SqlState::INVALID_ARGUMENT_FOR_POWER_FUNCTION), + ("42P22", SqlState::INDETERMINATE_COLLATION), + ("54001", SqlState::STATEMENT_TOO_COMPLEX), + ("HV091", SqlState::FDW_INVALID_DESCRIPTOR_FIELD_IDENTIFIER), + ("HV090", SqlState::FDW_INVALID_STRING_LENGTH_OR_BUFFER_LENGTH), + ("25P01", SqlState::NO_ACTIVE_SQL_TRANSACTION), + ("22005", SqlState::ERROR_IN_ASSIGNMENT), + ("42P02", SqlState::UNDEFINED_PARAMETER), + ("42P08", SqlState::AMBIGUOUS_PARAMETER), + ("22023", SqlState::INVALID_PARAMETER_VALUE), + ("25007", SqlState::SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED), + ("08P01", SqlState::PROTOCOL_VIOLATION), + ("22P01", SqlState::FLOATING_POINT_EXCEPTION), + ("42P01", SqlState::UNDEFINED_TABLE), + ("P0002", SqlState::NO_DATA_FOUND), + ("2F005", SqlState::S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT), + ("F0001", SqlState::LOCK_FILE_EXISTS), + ("2200D", SqlState::INVALID_ESCAPE_OCTET), + ("22P04", SqlState::BAD_COPY_FILE_FORMAT), + ("2200B", SqlState::ESCAPE_CHARACTER_CONFLICT), + ("P0000", SqlState::PLPGSQL_ERROR), + ("2D000", SqlState::INVALID_TRANSACTION_TERMINATION), + ("01007", SqlState::WARNING_PRIVILEGE_NOT_GRANTED), + ("HV00C", SqlState::FDW_INVALID_OPTION_INDEX), + ("3B000", SqlState::SAVEPOINT_EXCEPTION), + ("40001", SqlState::T_R_SERIALIZATION_FAILURE), + ("42P18", SqlState::INDETERMINATE_DATATYPE), + ("HV00A", SqlState::FDW_INVALID_STRING_FORMAT), + ("XX002", SqlState::INDEX_CORRUPTED), + ("39P02", SqlState::E_R_I_E_SRF_PROTOCOL_VIOLATED), + ("HV00D", SqlState::FDW_INVALID_OPTION_NAME), + ("25000", SqlState::INVALID_TRANSACTION_STATE), + ("0B000", SqlState::INVALID_TRANSACTION_INITIATION), + ("2200T", SqlState::INVALID_XML_PROCESSING_INSTRUCTION), + ("HV00J", SqlState::FDW_OPTION_NAME_NOT_FOUND), + ("HV00R", SqlState::FDW_TABLE_NOT_FOUND), + ("2202E", SqlState::ARRAY_ELEMENT_ERROR), + ("22027", SqlState::TRIM_ERROR), + ("22026", SqlState::STRING_DATA_LENGTH_MISMATCH), + ("23514", SqlState::CHECK_VIOLATION), + ("42702", SqlState::AMBIGUOUS_COLUMN), + ("53400", SqlState::CONFIGURATION_LIMIT_EXCEEDED), + ("53000", SqlState::INSUFFICIENT_RESOURCES), + ("HV00N", SqlState::FDW_UNABLE_TO_ESTABLISH_CONNECTION), + ("42P17", SqlState::INVALID_OBJECT_DEFINITION), + ("57P01", SqlState::ADMIN_SHUTDOWN), + ("55P04", SqlState::UNSAFE_NEW_ENUM_VALUE_USAGE), + ("27000", SqlState::TRIGGERED_DATA_CHANGE_VIOLATION), + ("2200N", SqlState::INVALID_XML_CONTENT), + ("23000", SqlState::INTEGRITY_CONSTRAINT_VIOLATION), + ("HV00L", SqlState::FDW_UNABLE_TO_CREATE_EXECUTION), + ("22002", SqlState::NULL_VALUE_NO_INDICATOR_PARAMETER), + ("58P02", SqlState::DUPLICATE_FILE), + ("22018", SqlState::INVALID_CHARACTER_VALUE_FOR_CAST), + ("22009", SqlState::INVALID_TIME_ZONE_DISPLACEMENT_VALUE), + ("2200C", SqlState::INVALID_USE_OF_ESCAPE_CHARACTER), + ("01003", SqlState::WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION), + ("34000", SqlState::INVALID_CURSOR_NAME), + ("F0000", SqlState::CONFIG_FILE_ERROR), + ("28P01", SqlState::INVALID_PASSWORD), + ("08001", SqlState::SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION), + ("57014", SqlState::QUERY_CANCELED), + ("2200M", SqlState::INVALID_XML_DOCUMENT), + ("23P01", SqlState::EXCLUSION_VIOLATION), + ("42602", SqlState::INVALID_NAME), + ("23001", SqlState::RESTRICT_VIOLATION), + ("2201X", SqlState::INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE), + ("39001", SqlState::E_R_I_E_INVALID_SQLSTATE_RETURNED), + ("40002", SqlState::T_R_INTEGRITY_CONSTRAINT_VIOLATION), + ("22P02", SqlState::INVALID_TEXT_REPRESENTATION), + ("HV000", SqlState::FDW_ERROR), + ("42611", SqlState::INVALID_COLUMN_DEFINITION), + ("2200H", SqlState::SEQUENCE_GENERATOR_LIMIT_EXCEEDED), + ("53200", SqlState::OUT_OF_MEMORY), + ("3D000", SqlState::INVALID_CATALOG_NAME), + ("08007", SqlState::TRANSACTION_RESOLUTION_UNKNOWN), + ("2200S", SqlState::INVALID_XML_COMMENT), + ("25006", SqlState::READ_ONLY_SQL_TRANSACTION), + ("0A000", SqlState::FEATURE_NOT_SUPPORTED), + ("00000", SqlState::SUCCESSFUL_COMPLETION), + ("22001", SqlState::STRING_DATA_RIGHT_TRUNCATION), + ("0LP01", SqlState::INVALID_GRANT_OPERATION), + ("22P03", SqlState::INVALID_BINARY_REPRESENTATION), + ("42P06", SqlState::DUPLICATE_SCHEMA), + ("2200F", SqlState::ZERO_LENGTH_CHARACTER_STRING), + ("01004", SqlState::WARNING_STRING_DATA_RIGHT_TRUNCATION), + ("HV010", SqlState::FDW_FUNCTION_SEQUENCE_ERROR), + ("42P05", SqlState::DUPLICATE_PSTATEMENT), + ("2202H", SqlState::INVALID_TABLESAMPLE_ARGUMENT), + ("P0001", SqlState::RAISE_EXCEPTION), + ("58030", SqlState::IO_ERROR), + ("XX001", SqlState::DATA_CORRUPTED), + ("42723", SqlState::DUPLICATE_FUNCTION), + ("2F004", SqlState::S_R_E_READING_SQL_DATA_NOT_PERMITTED), + ("55P02", SqlState::CANT_CHANGE_RUNTIME_PARAM), + ("42P14", SqlState::INVALID_PSTATEMENT_DEFINITION), + ("0F000", SqlState::LOCATOR_EXCEPTION), + ("42P15", SqlState::INVALID_SCHEMA_DEFINITION), + ("42601", SqlState::SYNTAX_ERROR), + ("39P03", SqlState::E_R_I_E_EVENT_TRIGGER_PROTOCOL_VIOLATED), + ("53100", SqlState::DISK_FULL), + ("2F000", SqlState::SQL_ROUTINE_EXCEPTION), + ("55006", SqlState::OBJECT_IN_USE), + ("2BP01", SqlState::DEPENDENT_OBJECTS_STILL_EXIST), + ("57P02", SqlState::CRASH_SHUTDOWN), + ("21000", SqlState::CARDINALITY_VIOLATION), + ("25P02", SqlState::IN_FAILED_SQL_TRANSACTION), + ("55000", SqlState::OBJECT_NOT_IN_PREREQUISITE_STATE), + ("42P13", SqlState::INVALID_FUNCTION_DEFINITION), + ("08000", SqlState::CONNECTION_EXCEPTION), + ("25008", SqlState::HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL), + ("38000", SqlState::EXTERNAL_ROUTINE_EXCEPTION), + ("42883", SqlState::UNDEFINED_FUNCTION), + ("2201W", SqlState::INVALID_ROW_COUNT_IN_LIMIT_CLAUSE), + ("25P03", SqlState::IDLE_IN_TRANSACTION_SESSION_TIMEOUT), + ("42P04", SqlState::DUPLICATE_DATABASE), + ("09000", SqlState::TRIGGERED_ACTION_EXCEPTION), + ("22007", SqlState::INVALID_DATETIME_FORMAT), + ("HV006", SqlState::FDW_INVALID_DATA_TYPE_DESCRIPTORS), + ("01006", SqlState::WARNING_PRIVILEGE_NOT_REVOKED), + ("42846", SqlState::CANNOT_COERCE), + ("08006", SqlState::CONNECTION_FAILURE), + ("42830", SqlState::INVALID_FOREIGN_KEY), ("57P03", SqlState::CANNOT_CONNECT_NOW), + ("HV007", SqlState::FDW_INVALID_COLUMN_NAME), + ("08004", SqlState::SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION), + ("01000", SqlState::WARNING), + ("2202G", SqlState::INVALID_TABLESAMPLE_REPEAT), + ("02000", SqlState::NO_DATA), + ("25004", SqlState::INAPPROPRIATE_ISOLATION_LEVEL_FOR_BRANCH_TRANSACTION), + ("38004", SqlState::E_R_E_READING_SQL_DATA_NOT_PERMITTED), + ("58P01", SqlState::UNDEFINED_FILE), + ("22012", SqlState::DIVISION_BY_ZERO), + ("01P01", SqlState::WARNING_DEPRECATED_FEATURE), + ("2B000", SqlState::DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST), + ("HV005", SqlState::FDW_COLUMN_NAME_NOT_FOUND), + ("3B001", SqlState::S_E_INVALID_SPECIFICATION), + ("42501", SqlState::INSUFFICIENT_PRIVILEGE), + ("40P01", SqlState::T_R_DEADLOCK_DETECTED), + ("22024", SqlState::UNTERMINATED_C_STRING), + ("2F003", SqlState::S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED), + ("42803", SqlState::GROUPING_ERROR), + ("3F000", SqlState::INVALID_SCHEMA_NAME), ]), }; diff --git a/tokio-postgres/src/lib.rs b/tokio-postgres/src/lib.rs index 83bee86a..3c8342e0 100644 --- a/tokio-postgres/src/lib.rs +++ b/tokio-postgres/src/lib.rs @@ -1,4 +1,4 @@ -#![warn(rust_2018_idioms)] +#![warn(rust_2018_idioms, clippy::all)] use bytes::{Bytes, IntoBuf}; use futures::{try_ready, Async, Future, Poll, Stream}; @@ -129,6 +129,7 @@ where } } +#[allow(clippy::large_enum_variant)] pub enum AsyncMessage { Notice(DbError), Notification(Notification), @@ -308,6 +309,10 @@ impl Row { self.0.columns() } + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + pub fn len(&self) -> usize { self.0.len() } diff --git a/tokio-postgres/src/proto/client.rs b/tokio-postgres/src/proto/client.rs index 1931773b..fdc80765 100644 --- a/tokio-postgres/src/proto/client.rs +++ b/tokio-postgres/src/proto/client.rs @@ -236,8 +236,8 @@ impl Client { ); match r { Ok(()) => Ok(buf), - Err(frontend::BindError::Conversion(e)) => return Err(Error::to_sql(e)), - Err(frontend::BindError::Serialization(e)) => return Err(Error::encode(e)), + Err(frontend::BindError::Conversion(e)) => Err(Error::to_sql(e)), + Err(frontend::BindError::Serialization(e)) => Err(Error::encode(e)), } } diff --git a/tokio-postgres/src/proto/connection.rs b/tokio-postgres/src/proto/connection.rs index 4bae09ff..4684b4f3 100644 --- a/tokio-postgres/src/proto/connection.rs +++ b/tokio-postgres/src/proto/connection.rs @@ -103,7 +103,7 @@ where let message = match message { Message::NoticeResponse(body) => { - let error = DbError::new(&mut body.fields()).map_err(Error::parse)?; + let error = DbError::parse(&mut body.fields()).map_err(Error::parse)?; return Ok(Some(AsyncMessage::Notice(error))); } Message::NotificationResponse(body) => { diff --git a/tokio-postgres/src/proto/prepare.rs b/tokio-postgres/src/proto/prepare.rs index 368af574..aa4739ec 100644 --- a/tokio-postgres/src/proto/prepare.rs +++ b/tokio-postgres/src/proto/prepare.rs @@ -1,3 +1,5 @@ +#![allow(clippy::large_enum_variant)] + use fallible_iterator::FallibleIterator; use futures::sync::mpsc; use futures::{try_ready, Future, Poll, Stream}; diff --git a/tokio-postgres/src/proto/query.rs b/tokio-postgres/src/proto/query.rs index 87474eda..e648023c 100644 --- a/tokio-postgres/src/proto/query.rs +++ b/tokio-postgres/src/proto/query.rs @@ -86,7 +86,7 @@ where } Some(Message::ErrorResponse(body)) => break Err(Error::db(body)), Some(Message::DataRow(body)) => { - let row = Row::new(statement.statement().clone(), body)?; + let row = Row::parse(statement.statement().clone(), body)?; self.0 = State::ReadingResponse { receiver, statement, diff --git a/tokio-postgres/src/proto/row.rs b/tokio-postgres/src/proto/row.rs index 5fad4375..ef32b67d 100644 --- a/tokio-postgres/src/proto/row.rs +++ b/tokio-postgres/src/proto/row.rs @@ -12,8 +12,8 @@ pub struct Row { } impl Row { - pub fn new(statement: Statement, data: DataRowBody) -> Result { - let data = RowData::new(data).map_err(Error::parse)?; + pub(crate) fn parse(statement: Statement, data: DataRowBody) -> Result { + let data = RowData::parse(data).map_err(Error::parse)?; Ok(Row { statement, data }) } diff --git a/tokio-postgres/src/proto/transaction.rs b/tokio-postgres/src/proto/transaction.rs index fb828f78..4f5fa387 100644 --- a/tokio-postgres/src/proto/transaction.rs +++ b/tokio-postgres/src/proto/transaction.rs @@ -63,7 +63,7 @@ where state: &'a mut RentToOwn<'a, Running>, ) -> Poll, E> { match state.future.poll() { - Ok(Async::NotReady) => return Ok(Async::NotReady), + Ok(Async::NotReady) => Ok(Async::NotReady), Ok(Async::Ready(t)) => transition!(Finishing { future: state.client.batch_execute("COMMIT"), result: Ok(t), @@ -79,7 +79,7 @@ where state: &'a mut RentToOwn<'a, Finishing>, ) -> Poll, E> { match state.future.poll() { - Ok(Async::NotReady) => return Ok(Async::NotReady), + Ok(Async::NotReady) => Ok(Async::NotReady), Ok(Async::Ready(())) => { let t = state.take().result?; transition!(Finished(t)) diff --git a/tokio-postgres/src/proto/typeinfo.rs b/tokio-postgres/src/proto/typeinfo.rs index 78a62611..416f61d4 100644 --- a/tokio-postgres/src/proto/typeinfo.rs +++ b/tokio-postgres/src/proto/typeinfo.rs @@ -12,7 +12,7 @@ use crate::proto::typeinfo_composite::TypeinfoCompositeFuture; use crate::proto::typeinfo_enum::TypeinfoEnumFuture; use crate::types::{Kind, Oid, Type}; -const TYPEINFO_QUERY: &'static str = " +const TYPEINFO_QUERY: &str = " SELECT t.typname, t.typtype, t.typelem, r.rngsubtype, t.typbasetype, n.nspname, t.typrelid FROM pg_catalog.pg_type t LEFT OUTER JOIN pg_catalog.pg_range r ON r.rngtypid = t.oid @@ -21,7 +21,7 @@ WHERE t.oid = $1 "; // Range types weren't added until Postgres 9.2, so pg_range may not exist -const TYPEINFO_FALLBACK_QUERY: &'static str = " +const TYPEINFO_FALLBACK_QUERY: &str = " SELECT t.typname, t.typtype, t.typelem, NULL::OID, t.typbasetype, n.nspname, t.typrelid FROM pg_catalog.pg_type t INNER JOIN pg_catalog.pg_namespace n ON t.typnamespace = n.oid diff --git a/tokio-postgres/src/proto/typeinfo_composite.rs b/tokio-postgres/src/proto/typeinfo_composite.rs index 9df260a4..ca24f2e0 100644 --- a/tokio-postgres/src/proto/typeinfo_composite.rs +++ b/tokio-postgres/src/proto/typeinfo_composite.rs @@ -13,7 +13,7 @@ use crate::proto::statement::Statement; use crate::proto::typeinfo::TypeinfoFuture; use crate::types::{Field, Oid}; -const TYPEINFO_COMPOSITE_QUERY: &'static str = " +const TYPEINFO_COMPOSITE_QUERY: &str = " SELECT attname, atttypid FROM pg_catalog.pg_attribute WHERE attrelid = $1 diff --git a/tokio-postgres/src/proto/typeinfo_enum.rs b/tokio-postgres/src/proto/typeinfo_enum.rs index 2f676f80..2cf3d7f8 100644 --- a/tokio-postgres/src/proto/typeinfo_enum.rs +++ b/tokio-postgres/src/proto/typeinfo_enum.rs @@ -10,7 +10,7 @@ use crate::proto::query::QueryStream; use crate::proto::statement::Statement; use crate::types::Oid; -const TYPEINFO_ENUM_QUERY: &'static str = " +const TYPEINFO_ENUM_QUERY: &str = " SELECT enumlabel FROM pg_catalog.pg_enum WHERE enumtypid = $1 @@ -18,7 +18,7 @@ ORDER BY enumsortorder "; // Postgres 9.0 didn't have enumsortorder -const TYPEINFO_ENUM_FALLBACK_QUERY: &'static str = " +const TYPEINFO_ENUM_FALLBACK_QUERY: &str = " SELECT enumlabel FROM pg_catalog.pg_enum WHERE enumtypid = $1 diff --git a/tokio-postgres/src/rows.rs b/tokio-postgres/src/rows.rs index 54b934b5..0360dfa5 100644 --- a/tokio-postgres/src/rows.rs +++ b/tokio-postgres/src/rows.rs @@ -61,29 +61,18 @@ where impl<'a, T> RowIndex for &'a T where T: ?Sized + Sealed {} -#[doc(hidden)] -pub struct RowData { +pub(crate) struct RowData { body: DataRowBody, ranges: Vec>>, } impl RowData { - pub fn new(body: DataRowBody) -> io::Result { + pub fn parse(body: DataRowBody) -> io::Result { let ranges = body.ranges().collect()?; - Ok(RowData { - body: body, - ranges: ranges, - }) - } - - pub fn len(&self) -> usize { - self.ranges.len() + Ok(RowData { body, ranges }) } pub fn get(&self, index: usize) -> Option<&[u8]> { - match &self.ranges[index] { - &Some(ref range) => Some(&self.body.buffer()[range.clone()]), - &None => None, - } + self.ranges[index].clone().map(|r| &self.body.buffer()[r]) } } diff --git a/tokio-postgres/src/stmt.rs b/tokio-postgres/src/stmt.rs index 037706d2..be6cc9f4 100644 --- a/tokio-postgres/src/stmt.rs +++ b/tokio-postgres/src/stmt.rs @@ -10,10 +10,7 @@ pub struct Column { impl Column { #[doc(hidden)] pub fn new(name: String, type_: Type) -> Column { - Column { - name: name, - type_: type_, - } + Column { name, type_ } } /// Returns the name of the column. diff --git a/tokio-postgres/src/types/mod.rs b/tokio-postgres/src/types/mod.rs index 6b212ea7..d9580c18 100644 --- a/tokio-postgres/src/types/mod.rs +++ b/tokio-postgres/src/types/mod.rs @@ -7,6 +7,7 @@ use std::borrow::Cow; use std::collections::HashMap; use std::error::Error; use std::fmt; +use std::hash::BuildHasher; use std::sync::Arc; use std::time::{Duration, SystemTime, UNIX_EPOCH}; @@ -18,7 +19,7 @@ pub use postgres_protocol::Oid; pub use crate::types::special::{Date, Timestamp}; // Number of seconds from 1970-01-01 to 2000-01-01 -const TIME_SEC_CONVERSION: u64 = 946684800; +const TIME_SEC_CONVERSION: u64 = 946_684_800; const USEC_PER_SEC: u64 = 1_000_000; const NSEC_PER_USEC: u64 = 1_000; @@ -109,10 +110,10 @@ impl Type { #[doc(hidden)] pub fn _new(name: String, oid: Oid, kind: Kind, schema: String) -> Type { Type(Inner::Other(Arc::new(Other { - name: name, - oid: oid, - kind: kind, - schema: schema, + name, + oid, + kind, + schema, }))) } @@ -189,10 +190,7 @@ impl Field { impl Field { #[doc(hidden)] pub fn new(name: String, type_: Type) -> Field { - Field { - name: name, - type_: type_, - } + Field { name, type_ } } } @@ -440,11 +438,14 @@ simple_from!(i64, int8_from_sql, INT8); simple_from!(f32, float4_from_sql, FLOAT4); simple_from!(f64, float8_from_sql, FLOAT8); -impl<'a> FromSql<'a> for HashMap> { +impl<'a, S> FromSql<'a> for HashMap, S> +where + S: Default + BuildHasher, +{ fn from_sql( _: &Type, raw: &'a [u8], - ) -> Result>, Box> { + ) -> Result, S>, Box> { types::hstore_from_sql(raw)? .map(|(k, v)| (k.to_owned(), v.map(str::to_owned))) .collect() @@ -739,7 +740,10 @@ simple_to!(i64, int8_to_sql, INT8); simple_to!(f32, float4_to_sql, FLOAT4); simple_to!(f64, float8_to_sql, FLOAT8); -impl ToSql for HashMap> { +impl ToSql for HashMap, H> +where + H: BuildHasher, +{ fn to_sql(&self, _: &Type, w: &mut Vec) -> Result> { types::hstore_to_sql( self.iter().map(|(k, v)| (&**k, v.as_ref().map(|v| &**v))), @@ -760,7 +764,7 @@ impl ToSql for SystemTime { let epoch = UNIX_EPOCH + Duration::from_secs(TIME_SEC_CONVERSION); let to_usec = - |d: Duration| d.as_secs() * USEC_PER_SEC + (d.subsec_nanos() as u64) / NSEC_PER_USEC; + |d: Duration| d.as_secs() * USEC_PER_SEC + u64::from(d.subsec_nanos()) / NSEC_PER_USEC; let time = match self.duration_since(epoch) { Ok(duration) => to_usec(duration) as i64, diff --git a/tokio-postgres/src/types/type_gen.rs b/tokio-postgres/src/types/type_gen.rs index 7dd28f42..32fcd241 100644 --- a/tokio-postgres/src/types/type_gen.rs +++ b/tokio-postgres/src/types/type_gen.rs @@ -1,7 +1,7 @@ // Autogenerated file - DO NOT EDIT use std::sync::Arc; -use crate::types::{Kind, Oid, Type}; +use crate::types::{Type, Oid, Kind}; #[derive(PartialEq, Eq, Debug)] pub struct Other { @@ -521,656 +521,493 @@ impl Inner { pub fn kind(&self) -> &Kind { match *self { Inner::Bool => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Bytea => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Char => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Name => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Int8 => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Int2 => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Int2Vector => { - const V: &'static Kind = &Kind::Array(Type(Inner::Int2)); - V + &Kind::Array(Type(Inner::Int2)) } Inner::Int4 => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Regproc => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Text => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Oid => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Tid => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Xid => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Cid => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::OidVector => { - const V: &'static Kind = &Kind::Array(Type(Inner::Oid)); - V + &Kind::Array(Type(Inner::Oid)) } Inner::PgDdlCommand => { - const V: &'static Kind = &Kind::Pseudo; - V + &Kind::Pseudo } Inner::Json => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Xml => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::XmlArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Xml)); - V + &Kind::Array(Type(Inner::Xml)) } Inner::PgNodeTree => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::JsonArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Json)); - V + &Kind::Array(Type(Inner::Json)) } Inner::Smgr => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::IndexAmHandler => { - const V: &'static Kind = &Kind::Pseudo; - V + &Kind::Pseudo } Inner::Point => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Lseg => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Path => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Box => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Polygon => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Line => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::LineArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Line)); - V + &Kind::Array(Type(Inner::Line)) } Inner::Cidr => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::CidrArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Cidr)); - V + &Kind::Array(Type(Inner::Cidr)) } Inner::Float4 => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Float8 => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Abstime => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Reltime => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Tinterval => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Unknown => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Circle => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::CircleArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Circle)); - V + &Kind::Array(Type(Inner::Circle)) } Inner::Macaddr8 => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Macaddr8Array => { - const V: &'static Kind = &Kind::Array(Type(Inner::Macaddr8)); - V + &Kind::Array(Type(Inner::Macaddr8)) } Inner::Money => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::MoneyArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Money)); - V + &Kind::Array(Type(Inner::Money)) } Inner::Macaddr => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Inet => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::BoolArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Bool)); - V + &Kind::Array(Type(Inner::Bool)) } Inner::ByteaArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Bytea)); - V + &Kind::Array(Type(Inner::Bytea)) } Inner::CharArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Char)); - V + &Kind::Array(Type(Inner::Char)) } Inner::NameArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Name)); - V + &Kind::Array(Type(Inner::Name)) } Inner::Int2Array => { - const V: &'static Kind = &Kind::Array(Type(Inner::Int2)); - V + &Kind::Array(Type(Inner::Int2)) } Inner::Int2VectorArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Int2Vector)); - V + &Kind::Array(Type(Inner::Int2Vector)) } Inner::Int4Array => { - const V: &'static Kind = &Kind::Array(Type(Inner::Int4)); - V + &Kind::Array(Type(Inner::Int4)) } Inner::RegprocArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Regproc)); - V + &Kind::Array(Type(Inner::Regproc)) } Inner::TextArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Text)); - V + &Kind::Array(Type(Inner::Text)) } Inner::TidArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Tid)); - V + &Kind::Array(Type(Inner::Tid)) } Inner::XidArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Xid)); - V + &Kind::Array(Type(Inner::Xid)) } Inner::CidArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Cid)); - V + &Kind::Array(Type(Inner::Cid)) } Inner::OidVectorArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::OidVector)); - V + &Kind::Array(Type(Inner::OidVector)) } Inner::BpcharArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Bpchar)); - V + &Kind::Array(Type(Inner::Bpchar)) } Inner::VarcharArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Varchar)); - V + &Kind::Array(Type(Inner::Varchar)) } Inner::Int8Array => { - const V: &'static Kind = &Kind::Array(Type(Inner::Int8)); - V + &Kind::Array(Type(Inner::Int8)) } Inner::PointArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Point)); - V + &Kind::Array(Type(Inner::Point)) } Inner::LsegArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Lseg)); - V + &Kind::Array(Type(Inner::Lseg)) } Inner::PathArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Path)); - V + &Kind::Array(Type(Inner::Path)) } Inner::BoxArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Box)); - V + &Kind::Array(Type(Inner::Box)) } Inner::Float4Array => { - const V: &'static Kind = &Kind::Array(Type(Inner::Float4)); - V + &Kind::Array(Type(Inner::Float4)) } Inner::Float8Array => { - const V: &'static Kind = &Kind::Array(Type(Inner::Float8)); - V + &Kind::Array(Type(Inner::Float8)) } Inner::AbstimeArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Abstime)); - V + &Kind::Array(Type(Inner::Abstime)) } Inner::ReltimeArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Reltime)); - V + &Kind::Array(Type(Inner::Reltime)) } Inner::TintervalArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Tinterval)); - V + &Kind::Array(Type(Inner::Tinterval)) } Inner::PolygonArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Polygon)); - V + &Kind::Array(Type(Inner::Polygon)) } Inner::OidArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Oid)); - V + &Kind::Array(Type(Inner::Oid)) } Inner::Aclitem => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::AclitemArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Aclitem)); - V + &Kind::Array(Type(Inner::Aclitem)) } Inner::MacaddrArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Macaddr)); - V + &Kind::Array(Type(Inner::Macaddr)) } Inner::InetArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Inet)); - V + &Kind::Array(Type(Inner::Inet)) } Inner::Bpchar => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Varchar => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Date => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Time => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Timestamp => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::TimestampArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Timestamp)); - V + &Kind::Array(Type(Inner::Timestamp)) } Inner::DateArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Date)); - V + &Kind::Array(Type(Inner::Date)) } Inner::TimeArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Time)); - V + &Kind::Array(Type(Inner::Time)) } Inner::Timestamptz => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::TimestamptzArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Timestamptz)); - V + &Kind::Array(Type(Inner::Timestamptz)) } Inner::Interval => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::IntervalArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Interval)); - V + &Kind::Array(Type(Inner::Interval)) } Inner::NumericArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Numeric)); - V + &Kind::Array(Type(Inner::Numeric)) } Inner::CstringArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Cstring)); - V + &Kind::Array(Type(Inner::Cstring)) } Inner::Timetz => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::TimetzArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Timetz)); - V + &Kind::Array(Type(Inner::Timetz)) } Inner::Bit => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::BitArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Bit)); - V + &Kind::Array(Type(Inner::Bit)) } Inner::Varbit => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::VarbitArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Varbit)); - V + &Kind::Array(Type(Inner::Varbit)) } Inner::Numeric => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Refcursor => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::RefcursorArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Refcursor)); - V + &Kind::Array(Type(Inner::Refcursor)) } Inner::Regprocedure => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Regoper => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Regoperator => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Regclass => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Regtype => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::RegprocedureArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Regprocedure)); - V + &Kind::Array(Type(Inner::Regprocedure)) } Inner::RegoperArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Regoper)); - V + &Kind::Array(Type(Inner::Regoper)) } Inner::RegoperatorArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Regoperator)); - V + &Kind::Array(Type(Inner::Regoperator)) } Inner::RegclassArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Regclass)); - V + &Kind::Array(Type(Inner::Regclass)) } Inner::RegtypeArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Regtype)); - V + &Kind::Array(Type(Inner::Regtype)) } Inner::Record => { - const V: &'static Kind = &Kind::Pseudo; - V + &Kind::Pseudo } Inner::Cstring => { - const V: &'static Kind = &Kind::Pseudo; - V + &Kind::Pseudo } Inner::Any => { - const V: &'static Kind = &Kind::Pseudo; - V + &Kind::Pseudo } Inner::Anyarray => { - const V: &'static Kind = &Kind::Pseudo; - V + &Kind::Pseudo } Inner::Void => { - const V: &'static Kind = &Kind::Pseudo; - V + &Kind::Pseudo } Inner::Trigger => { - const V: &'static Kind = &Kind::Pseudo; - V + &Kind::Pseudo } Inner::LanguageHandler => { - const V: &'static Kind = &Kind::Pseudo; - V + &Kind::Pseudo } Inner::Internal => { - const V: &'static Kind = &Kind::Pseudo; - V + &Kind::Pseudo } Inner::Opaque => { - const V: &'static Kind = &Kind::Pseudo; - V + &Kind::Pseudo } Inner::Anyelement => { - const V: &'static Kind = &Kind::Pseudo; - V + &Kind::Pseudo } Inner::RecordArray => { - const V: &'static Kind = &Kind::Pseudo; - V + &Kind::Pseudo } Inner::Anynonarray => { - const V: &'static Kind = &Kind::Pseudo; - V + &Kind::Pseudo } Inner::TxidSnapshotArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::TxidSnapshot)); - V + &Kind::Array(Type(Inner::TxidSnapshot)) } Inner::Uuid => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::UuidArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Uuid)); - V + &Kind::Array(Type(Inner::Uuid)) } Inner::TxidSnapshot => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::FdwHandler => { - const V: &'static Kind = &Kind::Pseudo; - V + &Kind::Pseudo } Inner::PgLsn => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::PgLsnArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::PgLsn)); - V + &Kind::Array(Type(Inner::PgLsn)) } Inner::TsmHandler => { - const V: &'static Kind = &Kind::Pseudo; - V + &Kind::Pseudo } Inner::PgNdistinct => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::PgDependencies => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Anyenum => { - const V: &'static Kind = &Kind::Pseudo; - V + &Kind::Pseudo } Inner::TsVector => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::Tsquery => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::GtsVector => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::TsVectorArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::TsVector)); - V + &Kind::Array(Type(Inner::TsVector)) } Inner::GtsVectorArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::GtsVector)); - V + &Kind::Array(Type(Inner::GtsVector)) } Inner::TsqueryArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Tsquery)); - V + &Kind::Array(Type(Inner::Tsquery)) } Inner::Regconfig => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::RegconfigArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Regconfig)); - V + &Kind::Array(Type(Inner::Regconfig)) } Inner::Regdictionary => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::RegdictionaryArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Regdictionary)); - V + &Kind::Array(Type(Inner::Regdictionary)) } Inner::Jsonb => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::JsonbArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Jsonb)); - V + &Kind::Array(Type(Inner::Jsonb)) } Inner::AnyRange => { - const V: &'static Kind = &Kind::Pseudo; - V + &Kind::Pseudo } Inner::EventTrigger => { - const V: &'static Kind = &Kind::Pseudo; - V + &Kind::Pseudo } Inner::Int4Range => { - const V: &'static Kind = &Kind::Range(Type(Inner::Int4)); - V + &Kind::Range(Type(Inner::Int4)) } Inner::Int4RangeArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Int4Range)); - V + &Kind::Array(Type(Inner::Int4Range)) } Inner::NumRange => { - const V: &'static Kind = &Kind::Range(Type(Inner::Numeric)); - V + &Kind::Range(Type(Inner::Numeric)) } Inner::NumRangeArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::NumRange)); - V + &Kind::Array(Type(Inner::NumRange)) } Inner::TsRange => { - const V: &'static Kind = &Kind::Range(Type(Inner::Timestamp)); - V + &Kind::Range(Type(Inner::Timestamp)) } Inner::TsRangeArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::TsRange)); - V + &Kind::Array(Type(Inner::TsRange)) } Inner::TstzRange => { - const V: &'static Kind = &Kind::Range(Type(Inner::Timestamptz)); - V + &Kind::Range(Type(Inner::Timestamptz)) } Inner::TstzRangeArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::TstzRange)); - V + &Kind::Array(Type(Inner::TstzRange)) } Inner::DateRange => { - const V: &'static Kind = &Kind::Range(Type(Inner::Date)); - V + &Kind::Range(Type(Inner::Date)) } Inner::DateRangeArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::DateRange)); - V + &Kind::Array(Type(Inner::DateRange)) } Inner::Int8Range => { - const V: &'static Kind = &Kind::Range(Type(Inner::Int8)); - V + &Kind::Range(Type(Inner::Int8)) } Inner::Int8RangeArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Int8Range)); - V + &Kind::Array(Type(Inner::Int8Range)) } Inner::Regnamespace => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::RegnamespaceArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Regnamespace)); - V + &Kind::Array(Type(Inner::Regnamespace)) } Inner::Regrole => { - const V: &'static Kind = &Kind::Simple; - V + &Kind::Simple } Inner::RegroleArray => { - const V: &'static Kind = &Kind::Array(Type(Inner::Regrole)); - V + &Kind::Array(Type(Inner::Regrole)) } Inner::Other(ref u) => &u.kind, } @@ -1834,4 +1671,4 @@ impl Type { /// REGROLE[] pub const REGROLE_ARRAY: Type = Type(Inner::RegroleArray); -} +} \ No newline at end of file