Fill out remaining postgres types
This commit is contained in:
parent
89f00b38e4
commit
c30bfed857
@ -780,7 +780,7 @@ impl InnerConnection {
|
||||
}
|
||||
};
|
||||
|
||||
let type_ = Type::Unknown(Box::new(ugh_privacy::new_unknown(name, oid, kind)));
|
||||
let type_ = Type::Other(Box::new(ugh_privacy::new_other(name, oid, kind)));
|
||||
self.unknown_types.insert(oid, type_.clone());
|
||||
Ok(type_)
|
||||
}
|
||||
|
450
src/types/mod.rs
450
src/types/mod.rs
@ -8,7 +8,7 @@ use std::fmt;
|
||||
use Result;
|
||||
use error::Error;
|
||||
|
||||
pub use ugh_privacy::Unknown;
|
||||
pub use ugh_privacy::Other;
|
||||
|
||||
macro_rules! accepts {
|
||||
($($expected:pat),+) => (
|
||||
@ -152,53 +152,6 @@ mod json;
|
||||
/// A Postgres OID
|
||||
pub type Oid = u32;
|
||||
|
||||
// Values from pg_type.h
|
||||
const BOOLOID: Oid = 16;
|
||||
const BYTEAOID: Oid = 17;
|
||||
const CHAROID: Oid = 18;
|
||||
const NAMEOID: Oid = 19;
|
||||
const INT8OID: Oid = 20;
|
||||
const INT2OID: Oid = 21;
|
||||
const INT4OID: Oid = 23;
|
||||
const TEXTOID: Oid = 25;
|
||||
const OIDOID: Oid = 26;
|
||||
const JSONOID: Oid = 114;
|
||||
const JSONARRAYOID: Oid = 199;
|
||||
const CIDROID: Oid = 650;
|
||||
const FLOAT4OID: Oid = 700;
|
||||
const FLOAT8OID: Oid = 701;
|
||||
const INETOID: Oid = 869;
|
||||
const BOOLARRAYOID: Oid = 1000;
|
||||
const BYTEAARRAYOID: Oid = 1001;
|
||||
const CHARARRAYOID: Oid = 1002;
|
||||
const NAMEARRAYOID: Oid = 1003;
|
||||
const INT2ARRAYOID: Oid = 1005;
|
||||
const INT4ARRAYOID: Oid = 1007;
|
||||
const TEXTARRAYOID: Oid = 1009;
|
||||
const BPCHARARRAYOID: Oid = 1014;
|
||||
const VARCHARARRAYOID: Oid = 1015;
|
||||
const INT8ARRAYOID: Oid = 1016;
|
||||
const FLOAT4ARRAYOID: Oid = 1021;
|
||||
const FLAOT8ARRAYOID: Oid = 1022;
|
||||
const BPCHAROID: Oid = 1042;
|
||||
const VARCHAROID: Oid = 1043;
|
||||
const TIMESTAMPOID: Oid = 1114;
|
||||
const TIMESTAMPARRAYOID: Oid = 1115;
|
||||
const TIMESTAMPZOID: Oid = 1184;
|
||||
const TIMESTAMPZARRAYOID: Oid = 1185;
|
||||
const UUIDOID: Oid = 2950;
|
||||
const UUIDARRAYOID: Oid = 2951;
|
||||
const JSONBOID: Oid = 3802;
|
||||
const JSONBARRAYOID: Oid = 3807;
|
||||
const INT4RANGEOID: Oid = 3904;
|
||||
const INT4RANGEARRAYOID: Oid = 3905;
|
||||
const TSRANGEOID: Oid = 3908;
|
||||
const TSRANGEARRAYOID: Oid = 3909;
|
||||
const TSTZRANGEOID: Oid = 3910;
|
||||
const TSTZRANGEARRAYOID: Oid = 3911;
|
||||
const INT8RANGEOID: Oid = 3926;
|
||||
const INT8RANGEARRAYOID: Oid = 3927;
|
||||
|
||||
/// Represents the kind of a Postgres type.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Kind {
|
||||
@ -210,8 +163,16 @@ pub enum Kind {
|
||||
Range(Type),
|
||||
}
|
||||
|
||||
macro_rules! as_pat {
|
||||
($p:pat) => ($p)
|
||||
}
|
||||
|
||||
macro_rules! as_expr {
|
||||
($e:expr) => ($e)
|
||||
}
|
||||
|
||||
macro_rules! make_postgres_type {
|
||||
($(#[$doc:meta] $oid:ident => $variant:ident: $kind:expr),+) => (
|
||||
($(#[$doc:meta] $oid:tt => $variant:ident: $kind:expr),+) => (
|
||||
/// A Postgres type
|
||||
#[derive(PartialEq, Eq, Clone)]
|
||||
pub enum Type {
|
||||
@ -220,14 +181,14 @@ macro_rules! make_postgres_type {
|
||||
$variant,
|
||||
)+
|
||||
/// An unknown type
|
||||
Unknown(Box<Unknown>),
|
||||
Other(Box<Other>),
|
||||
}
|
||||
|
||||
impl fmt::Debug for Type {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
let s = match *self {
|
||||
$(Type::$variant => stringify!($variant),)+
|
||||
Type::Unknown(ref u) => return fmt::Debug::fmt(u, fmt),
|
||||
Type::Other(ref u) => return fmt::Debug::fmt(u, fmt),
|
||||
};
|
||||
fmt.write_str(s)
|
||||
}
|
||||
@ -239,7 +200,7 @@ macro_rules! make_postgres_type {
|
||||
/// If the OID is unknown, `None` is returned.
|
||||
pub fn from_oid(oid: Oid) -> Option<Type> {
|
||||
match oid {
|
||||
$($oid => Some(Type::$variant),)+
|
||||
$(as_pat!($oid) => Some(Type::$variant),)+
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
@ -247,8 +208,8 @@ macro_rules! make_postgres_type {
|
||||
/// Returns the OID of the `Type`.
|
||||
pub fn to_oid(&self) -> Oid {
|
||||
match *self {
|
||||
$(Type::$variant => $oid,)+
|
||||
Type::Unknown(ref u) => u.oid(),
|
||||
$(Type::$variant => as_expr!($oid),)+
|
||||
Type::Other(ref u) => u.oid(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,104 +222,327 @@ macro_rules! make_postgres_type {
|
||||
V
|
||||
}
|
||||
)+
|
||||
Type::Unknown(ref u) => u.kind(),
|
||||
Type::Other(ref u) => u.kind(),
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// Values from pg_type.h
|
||||
make_postgres_type! {
|
||||
#[doc="BOOL"]
|
||||
BOOLOID => Bool: Kind::Simple,
|
||||
#[doc="BYTEA"]
|
||||
BYTEAOID => ByteA: Kind::Simple,
|
||||
#[doc="\"char\""]
|
||||
CHAROID => Char: Kind::Simple,
|
||||
#[doc="NAME"]
|
||||
NAMEOID => Name: Kind::Simple,
|
||||
#[doc="INT8/BIGINT"]
|
||||
INT8OID => Int8: Kind::Simple,
|
||||
#[doc="INT2/SMALLINT"]
|
||||
INT2OID => Int2: Kind::Simple,
|
||||
#[doc="INT4/INT"]
|
||||
INT4OID => Int4: Kind::Simple,
|
||||
#[doc="TEXT"]
|
||||
TEXTOID => Text: Kind::Simple,
|
||||
#[doc="OID"]
|
||||
OIDOID => Oid: Kind::Simple,
|
||||
#[doc="BOOL - boolean, 'true'/'false'"]
|
||||
16 => Bool: Kind::Simple,
|
||||
#[doc="BYTEA - variable-length string, binary values escaped"]
|
||||
17 => ByteA: Kind::Simple,
|
||||
#[doc="\"char\" - single character"]
|
||||
18 => Char: Kind::Simple,
|
||||
#[doc="NAME - 63-byte type for storing system identifiers"]
|
||||
19 => Name: Kind::Simple,
|
||||
#[doc="INT8/BIGINT - ~18 digit integer, 8-byte storage"]
|
||||
20 => Int8: Kind::Simple,
|
||||
#[doc="INT2/SMALLINT - -32 thousand to 32 thousand, 2-byte storage"]
|
||||
21 => Int2: Kind::Simple,
|
||||
#[doc="INT2VECTOR - array of int2, used in system tables"]
|
||||
22 => Int2Vector: Kind::Array(Type::Int2),
|
||||
#[doc="INT4/INT - -2 billion to 2 billion integer, 4-byte storage"]
|
||||
23 => Int4: Kind::Simple,
|
||||
#[doc="REGPROC - registered procedure"]
|
||||
24 => Regproc: Kind::Simple,
|
||||
#[doc="TEXT - variable-length string, no limit specified"]
|
||||
25 => Text: Kind::Simple,
|
||||
#[doc="OID - object identifier(oid), maximum 4 billion"]
|
||||
26 => Oid: Kind::Simple,
|
||||
#[doc="TID - (block, offset), physical location of tuple"]
|
||||
27 => Tid: Kind::Simple,
|
||||
#[doc="XID - transaction id"]
|
||||
28 => Xid: Kind::Simple,
|
||||
#[doc="CID - command identifier type, sequence in transaction id"]
|
||||
29 => Cid: Kind::Simple,
|
||||
#[doc="OIDVECTOR - array of oids, used in system tables"]
|
||||
30 => OidVector: Kind::Array(Type::Oid),
|
||||
#[doc="PG_TYPE"]
|
||||
71 => PgType: Kind::Simple,
|
||||
#[doc="PG_ATTRIBUTE"]
|
||||
75 => PgAttribute: Kind::Simple,
|
||||
#[doc="PG_PROC"]
|
||||
81 => PgProc: Kind::Simple,
|
||||
#[doc="PG_CLASS"]
|
||||
83 => PgClass: Kind::Simple,
|
||||
#[doc="JSON"]
|
||||
JSONOID => Json: Kind::Simple,
|
||||
#[doc="CIDR"]
|
||||
CIDROID => Cidr: Kind::Simple,
|
||||
114 => Json: Kind::Simple,
|
||||
#[doc="XML - XML content"]
|
||||
142 => Xml: Kind::Simple,
|
||||
#[doc="XML[]"]
|
||||
143 => XmlArray: Kind::Array(Type::Xml),
|
||||
#[doc="PG_NODE_TREE - string representing an internal node tree"]
|
||||
194 => PgNodeTree: Kind::Simple,
|
||||
#[doc="JSON[]"]
|
||||
JSONARRAYOID => JsonArray: Kind::Array(Type::Json),
|
||||
#[doc="FLOAT4/REAL"]
|
||||
FLOAT4OID => Float4: Kind::Simple,
|
||||
#[doc="FLOAT8/DOUBLE PRECISION"]
|
||||
FLOAT8OID => Float8: Kind::Simple,
|
||||
#[doc="INET"]
|
||||
INETOID => Inet: Kind::Simple,
|
||||
199 => JsonArray: Kind::Array(Type::Json),
|
||||
#[doc="SMGR - storage manager"]
|
||||
210 => Smgr: Kind::Simple,
|
||||
#[doc="POINT - geometric point '(x, y)'"]
|
||||
600 => Point: Kind::Simple,
|
||||
#[doc="LSEG - geometric line segment '(pt1,pt2)'"]
|
||||
601 => Lseg: Kind::Simple,
|
||||
#[doc="PATH - geometric path '(pt1,...)'"]
|
||||
602 => Path: Kind::Simple,
|
||||
#[doc="BOX - geometric box '(lower left,upper right)'"]
|
||||
603 => Box: Kind::Simple,
|
||||
#[doc="POLYGON - geometric polygon '(pt1,...)'"]
|
||||
604 => Polygon: Kind::Simple,
|
||||
#[doc="LINE - geometric line"]
|
||||
628 => Line: Kind::Simple,
|
||||
#[doc="LINE[]"]
|
||||
629 => LineArray: Kind::Array(Type::Line),
|
||||
#[doc="CIDR - network IP address/netmask, network address"]
|
||||
650 => Cidr: Kind::Simple,
|
||||
#[doc="CIDR[]"]
|
||||
651 => CidrArray: Kind::Array(Type::Cidr),
|
||||
#[doc="FLOAT4/REAL - single-precision floating point number, 4-byte storage"]
|
||||
700 => Float4: Kind::Simple,
|
||||
#[doc="FLOAT8/DOUBLE PRECISION - double-precision floating point number, 8-byte storage"]
|
||||
701 => Float8: Kind::Simple,
|
||||
#[doc="ABSTIME - absolute, limited-range date and time (Unix system time)"]
|
||||
702 => Abstime: Kind::Simple,
|
||||
#[doc="RELTIME - relative, limited-range date and time (Unix delta time)"]
|
||||
703 => Reltime: Kind::Simple,
|
||||
#[doc="TINTERVAL - (abstime,abstime), time interval"]
|
||||
704 => Tinterval: Kind::Simple,
|
||||
#[doc="UNKNOWN"]
|
||||
705 => Unknown: Kind::Simple,
|
||||
#[doc="CIRCLE - geometric circle '(center,radius)'"]
|
||||
718 => Circle: Kind::Simple,
|
||||
#[doc="CIRCLE[]"]
|
||||
719 => CircleArray: Kind::Array(Type::Circle),
|
||||
#[doc="MONEY - monetary amounts, $d,ddd.cc"]
|
||||
790 => Money: Kind::Simple,
|
||||
#[doc="MONEY[]"]
|
||||
791 => MoneyArray: Kind::Array(Type::Money),
|
||||
#[doc="MACADDR - XX:XX:XX:XX:XX:XX, MAC address"]
|
||||
829 => Macaddr: Kind::Simple,
|
||||
#[doc="INET - IP address/netmask, host address, netmask optional"]
|
||||
869 => Inet: Kind::Simple,
|
||||
#[doc="BOOL[]"]
|
||||
BOOLARRAYOID => BoolArray: Kind::Array(Type::Bool),
|
||||
1000 => BoolArray: Kind::Array(Type::Bool),
|
||||
#[doc="BYTEA[]"]
|
||||
BYTEAARRAYOID => ByteAArray: Kind::Array(Type::ByteA),
|
||||
1001 => ByteAArray: Kind::Array(Type::ByteA),
|
||||
#[doc="\"char\"[]"]
|
||||
CHARARRAYOID => CharArray: Kind::Array(Type::Char),
|
||||
1002 => CharArray: Kind::Array(Type::Char),
|
||||
#[doc="NAME[]"]
|
||||
NAMEARRAYOID => NameArray: Kind::Array(Type::Name),
|
||||
1003 => NameArray: Kind::Array(Type::Name),
|
||||
#[doc="INT2[]"]
|
||||
INT2ARRAYOID => Int2Array: Kind::Array(Type::Int2),
|
||||
1005 => Int2Array: Kind::Array(Type::Int2),
|
||||
#[doc="INT2VECTOR[]"]
|
||||
1006 => Int2VectorArray: Kind::Array(Type::Int2Vector),
|
||||
#[doc="INT4[]"]
|
||||
INT4ARRAYOID => Int4Array: Kind::Array(Type::Int4),
|
||||
1007 => Int4Array: Kind::Array(Type::Int4),
|
||||
#[doc="REGPROC[]"]
|
||||
1008 => RegprocArray: Kind::Array(Type::Regproc),
|
||||
#[doc="TEXT[]"]
|
||||
TEXTARRAYOID => TextArray: Kind::Array(Type::Text),
|
||||
#[doc="CHAR(n)[]"]
|
||||
BPCHARARRAYOID => CharNArray: Kind::Array(Type::CharN),
|
||||
1009 => TextArray: Kind::Array(Type::Text),
|
||||
#[doc="TID[]"]
|
||||
1010 => TidArray: Kind::Array(Type::Tid),
|
||||
#[doc="XID[]"]
|
||||
1011 => XidArray: Kind::Array(Type::Xid),
|
||||
#[doc="CID[]"]
|
||||
1012 => CidArray: Kind::Array(Type::Cid),
|
||||
#[doc="OIDVECTOR[]"]
|
||||
1013 => OidVectorArray: Kind::Array(Type::OidVector),
|
||||
#[doc="BPCHAR[]"]
|
||||
1014 => BpcharArray: Kind::Array(Type::Bpchar),
|
||||
#[doc="VARCHAR[]"]
|
||||
VARCHARARRAYOID => VarcharArray: Kind::Array(Type::Varchar),
|
||||
1015 => VarcharArray: Kind::Array(Type::Varchar),
|
||||
#[doc="INT8[]"]
|
||||
INT8ARRAYOID => Int8Array: Kind::Array(Type::Int8),
|
||||
1016 => Int8Array: Kind::Array(Type::Int8),
|
||||
#[doc="POINT[]"]
|
||||
1017 => PointArray: Kind::Array(Type::Point),
|
||||
#[doc="LSEG[]"]
|
||||
1018 => LsegArray: Kind::Array(Type::Lseg),
|
||||
#[doc="PATH[]"]
|
||||
1019 => PathArray: Kind::Array(Type::Path),
|
||||
#[doc="BOX[]"]
|
||||
1020 => BoxArray: Kind::Array(Type::Box),
|
||||
#[doc="FLOAT4[]"]
|
||||
FLOAT4ARRAYOID => Float4Array: Kind::Array(Type::Float4),
|
||||
1021 => Float4Array: Kind::Array(Type::Float4),
|
||||
#[doc="FLOAT8[]"]
|
||||
FLAOT8ARRAYOID => Float8Array: Kind::Array(Type::Float8),
|
||||
#[doc="TIMESTAMP"]
|
||||
TIMESTAMPOID => Timestamp: Kind::Simple,
|
||||
1022 => Float8Array: Kind::Array(Type::Float8),
|
||||
#[doc="ABSTIME[]"]
|
||||
1023 => AbstimeArray: Kind::Array(Type::Abstime),
|
||||
#[doc="RELTIME[]"]
|
||||
1024 => ReltimeArray: Kind::Array(Type::Reltime),
|
||||
#[doc="TINTERVAL[]"]
|
||||
1025 => TintervalArray: Kind::Array(Type::Tinterval),
|
||||
#[doc="POLYGON[]"]
|
||||
1027 => PolygonArray: Kind::Array(Type::Polygon),
|
||||
#[doc="OID[]"]
|
||||
1028 => OidArray: Kind::Array(Type::Oid),
|
||||
#[doc="ACLITEM - access control list"]
|
||||
1033 => Aclitem: Kind::Simple,
|
||||
#[doc="ACLITEM[]"]
|
||||
1034 => AclitemArray: Kind::Array(Type::Aclitem),
|
||||
#[doc="MACADDR[]"]
|
||||
1040 => MacaddrArray: Kind::Array(Type::Macaddr),
|
||||
#[doc="INET[]"]
|
||||
1041 => InetArray: Kind::Array(Type::Inet),
|
||||
#[doc="BPCHAR - char(length), blank-padded string, fixed storage length"]
|
||||
1042 => Bpchar: Kind::Simple,
|
||||
#[doc="VARCHAR - varchar(length), non-blank-padded string, variable storage length"]
|
||||
1043 => Varchar: Kind::Simple,
|
||||
#[doc="DATE - date"]
|
||||
1082 => Date: Kind::Simple,
|
||||
#[doc="TIME - time of day"]
|
||||
1083 => Time: Kind::Simple,
|
||||
#[doc="TIMESTAMP - date and time"]
|
||||
1114 => Timestamp: Kind::Simple,
|
||||
#[doc="TIMESTAMP[]"]
|
||||
TIMESTAMPARRAYOID => TimestampArray: Kind::Array(Type::Timestamp),
|
||||
#[doc="TIMESTAMP WITH TIME ZONE"]
|
||||
TIMESTAMPZOID => TimestampTZ: Kind::Simple,
|
||||
#[doc="TIMESTAMP WITH TIME ZONE[]"]
|
||||
TIMESTAMPZARRAYOID => TimestampTZArray: Kind::Array(Type::TimestampTZ),
|
||||
#[doc="UUID"]
|
||||
UUIDOID => Uuid: Kind::Simple,
|
||||
1115 => TimestampArray: Kind::Array(Type::Timestamp),
|
||||
#[doc="DATE[]"]
|
||||
1182 => DateArray: Kind::Array(Type::Date),
|
||||
#[doc="TIME[]"]
|
||||
1183 => TimeArray: Kind::Array(Type::Time),
|
||||
#[doc="TIMESTAMPTZ - date and time with time zone"]
|
||||
1184 => TimestampTZ: Kind::Simple,
|
||||
#[doc="TIMESTAMPTZ[]"]
|
||||
1185 => TimestampTZArray: Kind::Array(Type::TimestampTZ),
|
||||
#[doc="INTERVAL - @ <number> <units>, time interval"]
|
||||
1186 => Interval: Kind::Simple,
|
||||
#[doc="INTERVAL[]"]
|
||||
1187 => IntervalArray: Kind::Array(Type::Interval),
|
||||
#[doc="NUMERIC[]"]
|
||||
1231 => NumericArray: Kind::Array(Type::Numeric),
|
||||
#[doc="CSTRING[]"]
|
||||
1263 => CstringArray: Kind::Array(Type::Cstring),
|
||||
#[doc="TIMETZ - time of day with time zone"]
|
||||
1266 => Timetz: Kind::Simple,
|
||||
#[doc="TIMETZ[]"]
|
||||
1270 => TimetzArray: Kind::Array(Type::Timetz),
|
||||
#[doc="BIT - fixed-length bit string"]
|
||||
1560 => Bit: Kind::Simple,
|
||||
#[doc="BIT[]"]
|
||||
1561 => BitArray: Kind::Array(Type::Bit),
|
||||
#[doc="VARBIT - variable-length bit string"]
|
||||
1562 => Varbit: Kind::Simple,
|
||||
#[doc="VARBIT[]"]
|
||||
1563 => VarbitArray: Kind::Array(Type::Varbit),
|
||||
#[doc="NUMERIC - numeric(precision, decimal), arbitrary precision number"]
|
||||
1700 => Numeric: Kind::Simple,
|
||||
#[doc="REFCURSOR - reference to cursor (portal name)"]
|
||||
1790 => Refcursor: Kind::Simple,
|
||||
#[doc="REFCURSOR[]"]
|
||||
2201 => RefcursorArray: Kind::Array(Type::Refcursor),
|
||||
#[doc="REGPROCEDURE - registered procedure (with args)"]
|
||||
2202 => Regprocedure: Kind::Simple,
|
||||
#[doc="REGOPER - registered operator"]
|
||||
2203 => Regoper: Kind::Simple,
|
||||
#[doc="REGOPERATOR - registered operator (with args)"]
|
||||
2204 => Regoperator: Kind::Simple,
|
||||
#[doc="REGCLASS - registered class"]
|
||||
2205 => Regclass: Kind::Simple,
|
||||
#[doc="REGTYPE - registered type"]
|
||||
2206 => Regtype: Kind::Simple,
|
||||
#[doc="REGPROCEDURE[]"]
|
||||
2207 => RegprocedureArray: Kind::Array(Type::Regprocedure),
|
||||
#[doc="REGOPER[]"]
|
||||
2208 => RegoperArray: Kind::Array(Type::Regoper),
|
||||
#[doc="REGOPERATOR[]"]
|
||||
2209 => RegoperatorArray: Kind::Array(Type::Regoperator),
|
||||
#[doc="REGCLASS[]"]
|
||||
2210 => RegclassArray: Kind::Array(Type::Regclass),
|
||||
#[doc="REGTYPE[]"]
|
||||
2211 => RegtypeArray: Kind::Array(Type::Regtype),
|
||||
#[doc="RECORD"]
|
||||
2249 => Record: Kind::Simple,
|
||||
#[doc="CSTRING"]
|
||||
2275 => Cstring: Kind::Simple,
|
||||
#[doc="ANY"]
|
||||
2276 => Any: Kind::Simple,
|
||||
#[doc="ANY[]"]
|
||||
2277 => AnyArray: Kind::Array(Type::Any),
|
||||
#[doc="VOID"]
|
||||
2278 => Void: Kind::Simple,
|
||||
#[doc="TRIGGER"]
|
||||
2279 => Trigger: Kind::Simple,
|
||||
#[doc="LANGUAGE_HANDLER"]
|
||||
2280 => LanguageHandler: Kind::Simple,
|
||||
#[doc="INTERNAL"]
|
||||
2281 => Internal: Kind::Simple,
|
||||
#[doc="OPAQUE"]
|
||||
2282 => Opaque: Kind::Simple,
|
||||
#[doc="ANYELEMENT"]
|
||||
2283 => Anyelement: Kind::Simple,
|
||||
#[doc="RECORD[]"]
|
||||
2287 => RecordArray: Kind::Array(Type::Record),
|
||||
#[doc="ANYNONARRAY"]
|
||||
2776 => Anynonarray: Kind::Simple,
|
||||
#[doc="TXID_SNAPSHOT[]"]
|
||||
2949 => TxidSnapshotArray: Kind::Array(Type::TxidSnapshot),
|
||||
#[doc="UUID - UUID datatype"]
|
||||
2950 => Uuid: Kind::Simple,
|
||||
#[doc="TXID_SNAPSHOT - txid snapshot"]
|
||||
2970 => TxidSnapshot: Kind::Simple,
|
||||
#[doc="UUID[]"]
|
||||
UUIDARRAYOID => UuidArray: Kind::Array(Type::Uuid),
|
||||
2951 => UuidArray: Kind::Array(Type::Uuid),
|
||||
#[doc="FDW_HANDLER"]
|
||||
3115 => FdwHandler: Kind::Simple,
|
||||
#[doc="PG_LSN - PostgreSQL LSN datatype"]
|
||||
3320 => PgLsn: Kind::Simple,
|
||||
#[doc="PG_LSN[]"]
|
||||
3321 => PgLsnArray: Kind::Array(Type::PgLsn),
|
||||
#[doc="ANYENUM"]
|
||||
3500 => Anyenum: Kind::Simple,
|
||||
#[doc="TSVECTOR - text representation for text search"]
|
||||
3614 => Tsvector: Kind::Simple,
|
||||
#[doc="TSQUERY - query representation for text search"]
|
||||
3615 => Tsquery: Kind::Simple,
|
||||
#[doc="GTSVECTOR - GiST index internal text representation for text search"]
|
||||
3642 => Gtsvector: Kind::Simple,
|
||||
#[doc="TSVECTOR[]"]
|
||||
3643 => TsvectorArray: Kind::Array(Type::Tsvector),
|
||||
#[doc="GTSVECTOR[]"]
|
||||
3644 => GtsvectorArray: Kind::Array(Type::Gtsvector),
|
||||
#[doc="TSQUERY[]"]
|
||||
3645 => TsqueryArray: Kind::Array(Type::Tsquery),
|
||||
#[doc="REGCONFIG - registered text search configuration"]
|
||||
3734 => Regconfig: Kind::Simple,
|
||||
#[doc="REGCONFIG[]"]
|
||||
3735 => RegconfigArray: Kind::Array(Type::Regconfig),
|
||||
#[doc="REGDICTIONARY - registered text search dictionary"]
|
||||
3769 => Regdictionary: Kind::Simple,
|
||||
#[doc="REGDICTIONARY[]"]
|
||||
3770 => RegdictionaryArray: Kind::Array(Type::Regdictionary),
|
||||
#[doc="JSONB"]
|
||||
JSONBOID => Jsonb: Kind::Simple,
|
||||
3802 => Jsonb: Kind::Simple,
|
||||
#[doc="ANYRANGE"]
|
||||
3831 => Anyrange: Kind::Simple,
|
||||
#[doc="JSONB[]"]
|
||||
JSONBARRAYOID => JsonbArray: Kind::Array(Type::Jsonb),
|
||||
#[doc="CHAR(n)/CHARACTER(n)"]
|
||||
BPCHAROID => CharN: Kind::Simple,
|
||||
#[doc="VARCHAR/CHARACTER VARYING"]
|
||||
VARCHAROID => Varchar: Kind::Simple,
|
||||
#[doc="INT4RANGE"]
|
||||
INT4RANGEOID => Int4Range: Kind::Range(Type::Int4),
|
||||
3807 => JsonbArray: Kind::Array(Type::Jsonb),
|
||||
#[doc="INT4RANGE - range of integers"]
|
||||
3904 => Int4Range: Kind::Range(Type::Int4),
|
||||
#[doc="INT4RANGE[]"]
|
||||
INT4RANGEARRAYOID => Int4RangeArray: Kind::Array(Type::Int4Range),
|
||||
#[doc="TSRANGE"]
|
||||
TSRANGEOID => TsRange: Kind::Range(Type::Timestamp),
|
||||
3905 => Int4RangeArray: Kind::Array(Type::Int4Range),
|
||||
#[doc="NUMRANGE - range of numerics"]
|
||||
3906 => NumRange: Kind::Range(Type::Numeric),
|
||||
#[doc="NUMRANGE[]"]
|
||||
3907 => NumRangeArray: Kind::Array(Type::NumRange),
|
||||
#[doc="TSRANGE - range of timestamps without time zone"]
|
||||
3908 => TsRange: Kind::Range(Type::Timestamp),
|
||||
#[doc="TSRANGE[]"]
|
||||
TSRANGEARRAYOID => TsRangeArray: Kind::Array(Type::TsRange),
|
||||
#[doc="TSTZRANGE"]
|
||||
TSTZRANGEOID => TstzRange: Kind::Range(Type::TimestampTZ),
|
||||
3909 => TsRangeArray: Kind::Array(Type::TsRange),
|
||||
#[doc="TSTZRANGE - range of timestamps with time zone"]
|
||||
3910 => TstzRange: Kind::Range(Type::TimestampTZ),
|
||||
#[doc="TSTZRANGE[]"]
|
||||
TSTZRANGEARRAYOID => TstzRangeArray: Kind::Array(Type::TstzRange),
|
||||
#[doc="INT8RANGE"]
|
||||
INT8RANGEOID => Int8Range: Kind::Range(Type::Int8),
|
||||
3911 => TstzRangeArray: Kind::Array(Type::TstzRange),
|
||||
#[doc="DATERANGE - range of dates"]
|
||||
3912 => DateRange: Kind::Range(Type::Date),
|
||||
#[doc="DATERANGE[]"]
|
||||
3913 => DateRangeArray: Kind::Array(Type::DateRange),
|
||||
#[doc="INT8RANGE - range of bigints"]
|
||||
3926 => Int8Range: Kind::Range(Type::Int8),
|
||||
#[doc="INT8RANGE[]"]
|
||||
INT8RANGEARRAYOID => Int8RangeArray: Kind::Array(Type::Int8Range)
|
||||
3927 => Int8RangeArray: Kind::Array(Type::Int8Range),
|
||||
#[doc="EVENT_TRIGGER"]
|
||||
3838 => EventTrigger: Kind::Simple
|
||||
}
|
||||
|
||||
/// A trait for types that can be created from a Postgres value.
|
||||
@ -431,8 +615,8 @@ impl FromSql for String {
|
||||
|
||||
fn accepts(ty: &Type) -> bool {
|
||||
match *ty {
|
||||
Type::Varchar | Type::Text | Type::CharN | Type::Name => true,
|
||||
Type::Unknown(ref u) if u.name() == "citext" => true,
|
||||
Type::Varchar | Type::Text | Type::Bpchar | Type::Name => true,
|
||||
Type::Other(ref u) if u.name() == "citext" => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@ -522,7 +706,7 @@ impl FromSql for HashMap<String, Option<String>> {
|
||||
|
||||
fn accepts(ty: &Type) -> bool {
|
||||
match *ty {
|
||||
Type::Unknown(ref u) if u.name() == "hstore" => true,
|
||||
Type::Other(ref u) if u.name() == "hstore" => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
@ -628,8 +812,8 @@ impl ToSql for Option<String> {
|
||||
impl<'a> ToSql for &'a str {
|
||||
fn to_sql(&self, ty: &Type) -> Result<Option<Vec<u8>>> {
|
||||
match *ty {
|
||||
Type::Varchar | Type::Text | Type::CharN | Type::Name => {}
|
||||
Type::Unknown(ref u) if u.name() == "citext" => {}
|
||||
Type::Varchar | Type::Text | Type::Bpchar | Type::Name => {}
|
||||
Type::Other(ref u) if u.name() == "citext" => {}
|
||||
_ => return Err(Error::WrongType(ty.clone()))
|
||||
}
|
||||
Ok(Some(self.as_bytes().to_vec()))
|
||||
@ -639,8 +823,8 @@ impl<'a> ToSql for &'a str {
|
||||
impl<'a> ToSql for Option<&'a str> {
|
||||
fn to_sql(&self, ty: &Type) -> Result<Option<Vec<u8>>> {
|
||||
match *ty {
|
||||
Type::Varchar | Type::Text | Type::CharN | Type::Name => {}
|
||||
Type::Unknown(ref u) if u.name() == "citext" => {}
|
||||
Type::Varchar | Type::Text | Type::Bpchar | Type::Name => {}
|
||||
Type::Other(ref u) if u.name() == "citext" => {}
|
||||
_ => return Err(Error::WrongType(ty.clone()))
|
||||
}
|
||||
match *self {
|
||||
@ -662,7 +846,7 @@ to_option_impl_lifetime!(Type::ByteA; &'a [u8]);
|
||||
impl ToSql for HashMap<String, Option<String>> {
|
||||
fn to_sql(&self, ty: &Type) -> Result<Option<Vec<u8>>> {
|
||||
match *ty {
|
||||
Type::Unknown(ref u) if u.name() == "hstore" => {}
|
||||
Type::Other(ref u) if u.name() == "hstore" => {}
|
||||
_ => return Err(Error::WrongType(ty.clone()))
|
||||
}
|
||||
|
||||
@ -690,7 +874,7 @@ impl ToSql for HashMap<String, Option<String>> {
|
||||
impl ToSql for Option<HashMap<String, Option<String>>> {
|
||||
fn to_sql(&self, ty: &Type) -> Result<Option<Vec<u8>>> {
|
||||
match *ty {
|
||||
Type::Unknown(ref u) if u.name() == "hstore" => {}
|
||||
Type::Other(ref u) if u.name() == "hstore" => {}
|
||||
_ => return Err(Error::WrongType(ty.clone()))
|
||||
}
|
||||
|
||||
|
@ -9,21 +9,21 @@ use error::{SqlState, ErrorPosition, ConnectError, Error};
|
||||
|
||||
/// Information about an unknown type.
|
||||
#[derive(PartialEq, Eq, Clone, Debug)]
|
||||
pub struct Unknown {
|
||||
pub struct Other {
|
||||
name: String,
|
||||
oid: Oid,
|
||||
kind: Kind,
|
||||
}
|
||||
|
||||
pub fn new_unknown(name: String, oid: Oid, kind: Kind) -> Unknown {
|
||||
Unknown {
|
||||
pub fn new_other(name: String, oid: Oid, kind: Kind) -> Other {
|
||||
Other {
|
||||
name: name,
|
||||
oid: oid,
|
||||
kind: kind,
|
||||
}
|
||||
}
|
||||
|
||||
impl Unknown {
|
||||
impl Other {
|
||||
/// The name of the type.
|
||||
pub fn name(&self) -> &str {
|
||||
&self.name
|
||||
|
@ -865,7 +865,7 @@ fn test_custom_range_element_type() {
|
||||
)", &[]));
|
||||
let stmt = or_panic!(trans.prepare("SELECT $1::floatrange"));
|
||||
match &stmt.param_types()[0] {
|
||||
&Type::Unknown(ref u) => {
|
||||
&Type::Other(ref u) => {
|
||||
assert_eq!("floatrange", u.name());
|
||||
assert_eq!(&Kind::Range(Type::Float8), u.kind());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user