<commit_before>//! Traits dealing with Postgres data types
pub use self::slice::Slice;

use std::collections::HashMap;
use std::old_io::net::ip::IpAddr;
use std::fmt;

use Result;
use error::Error;

pub use ugh_privacy::Other;

macro_rules! accepts {
    ($($expected:pat),+) => (
        fn accepts(ty: &::types::Type) -> bool {
            match *ty {
                $($expected)|+ => true,
                _ => false
            }
        }
    )
}

macro_rules! check_types {
    ($($expected:pat),+; $actual:ident) => (
        match $actual {
            $(&$expected)|+ => {}
            actual => return Err(::Error::WrongType(actual.clone()))
        }
    )
}

macro_rules! raw_from_impl {
    ($t:ty, $f:ident) => (
        impl RawFromSql for $t {
            fn raw_from_sql<R: Reader>(_: &Type, raw: &mut R) -> Result<$t> {
                Ok(try!(raw.$f()))
            }
        }
    )
}

macro_rules! from_option_impl {
    ($t:ty) => {
        impl ::types::FromSql for $t {
            fn from_sql(ty: &Type, raw: Option<&[u8]>) -> Result<$t> {
                use Error;
                use types::FromSql;

                // FIXME when you can specify Self types properly
                let ret: Result<Option<$t>> = FromSql::from_sql(ty, raw);
                match ret {
                    Ok(Some(val)) => Ok(val),
                    Ok(None) => Err(Error::WasNull),
                    Err(err) => Err(err)
                }
            }
        }
    }
}

macro_rules! from_map_impl {
    ($($expected:pat),+; $t:ty, $blk:expr) => (
        impl ::types::FromSql for Option<$t> {
            fn from_sql(ty: &Type, raw: Option<&[u8]>) -> Result<Option<$t>> {
                check_types!($($expected),+; ty);
                match raw {
                    Some(buf) => ($blk)(ty, buf).map(|ok| Some(ok)),
                    None => Ok(None)
                }
            }
        }

        from_option_impl!($t);
    )
}

macro_rules! from_raw_from_impl {
    ($($expected:pat),+; $t:ty) => (
        from_map_impl!($($expected),+; $t, |ty, mut buf: &[u8]| {
            use types::RawFromSql;

            RawFromSql::raw_from_sql(ty, &mut buf)
        });
    )
}

macro_rules! raw_to_impl {
    ($t:ty, $f:ident) => (
        impl RawToSql for $t {
            fn raw_to_sql<W: Writer>(&self, _: &Type, w: &mut W) -> Result<()> {
                Ok(try!(w.$f(*self)))
            }
        }
    )
}

macro_rules! to_option_impl {
    ($($oid:pat),+; $t:ty) => (
        impl ::types::ToSql for Option<$t> {
            fn to_sql(&self, ty: &Type) -> Result<Option<Vec<u8>>> {
                check_types!($($oid),+; ty);

                match *self {
                    None => Ok(None),
                    Some(ref val) => val.to_sql(ty)
                }
            }
        }
    )
}

macro_rules! to_option_impl_lifetime {
    ($($oid:pat),+; $t:ty) => (
        impl<'a> ToSql for Option<$t> {
            fn to_sql(&self, ty: &Type) -> Result<Option<Vec<u8>>> {
                check_types!($($oid),+; ty);

                match *self {
                    None => Ok(None),
                    Some(ref val) => val.to_sql(ty)
                }
            }
        }
    )
}

macro_rules! to_raw_to_impl {
    ($($oid:pat),+; $t:ty) => (
        impl ::types::ToSql for $t {
            fn to_sql(&self, ty: &Type) -> Result<Option<Vec<u8>>> {
                check_types!($($oid),+; ty);

                let mut writer = vec![];
                try!(self.raw_to_sql(ty, &mut writer));
                Ok(Some(writer))
            }
        }

        to_option_impl!($($oid),+; $t);
    )
}

#[cfg(feature = "uuid")]
mod uuid;
#[cfg(feature = "time")]
mod time;
mod slice;
#[cfg(feature = "rustc-serialize")]
mod json;

/// A Postgres OID
pub type Oid = u32;

/// Represents the kind of a Postgres type.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Kind {
    /// A simple type like `VARCHAR` or `INTEGER`.
    Simple,
    /// An array type along with the type of its elements.
    Array(Type),
    /// A range type along with the type of its elements.
    Range(Type),
}

macro_rules! as_pat {
    ($p:pat) => ($p)
}

macro_rules! as_expr {
    ($e:expr) => ($e)
}

macro_rules! make_postgres_type {
    ($(#[$doc:meta] $oid:tt => $variant:ident: $kind:expr),+) => (
        /// A Postgres type
        #[derive(PartialEq, Eq, Clone)]
        pub enum Type {
            $(
                #[$doc]
                $variant,
            )+
            /// An unknown type
            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::Other(ref u) => return fmt::Debug::fmt(u, fmt),
                };
                fmt.write_str(s)
            }
        }

        impl Type {
            /// Creates a `Type` from an OID.
            ///
            /// If the OID is unknown, `None` is returned.
            pub fn from_oid(oid: Oid) -> Option<Type> {
                match oid {
                    $(as_pat!($oid) => Some(Type::$variant),)+
                    _ => None
                }
            }

            /// Returns the OID of the `Type`.
            pub fn to_oid(&self) -> Oid {
                match *self {
                    $(Type::$variant => as_expr!($oid),)+
                    Type::Other(ref u) => u.oid(),
                }
            }

            /// The kind of this type
            pub fn kind(&self) -> &Kind {
                match *self {
                    $(
                        Type::$variant => {
                            const V: &'static Kind = &$kind;
                            V
                        }
                    )+
                    Type::Other(ref u) => u.kind(),
                }
            }
        }
    )
}

// Values from pg_type.h
make_postgres_type! {
    #[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"]
    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[]"]
    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[]"]
    1000 => BoolArray: Kind::Array(Type::Bool),
    #[doc="BYTEA[]"]
    1001 => ByteaArray: Kind::Array(Type::Bytea),
    #[doc="\"char\"[]"]
    1002 => CharArray: Kind::Array(Type::Char),
    #[doc="NAME[]"]
    1003 => NameArray: Kind::Array(Type::Name),
    #[doc="INT2[]"]
    1005 => Int2Array: Kind::Array(Type::Int2),
    #[doc="INT2VECTOR[]"]
    1006 => Int2VectorArray: Kind::Array(Type::Int2Vector),
    #[doc="INT4[]"]
    1007 => Int4Array: Kind::Array(Type::Int4),
    #[doc="REGPROC[]"]
    1008 => RegprocArray: Kind::Array(Type::Regproc),
    #[doc="TEXT[]"]
    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[]"]
    1015 => VarcharArray: Kind::Array(Type::Varchar),
    #[doc="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[]"]
    1021 => Float4Array: Kind::Array(Type::Float4),
    #[doc="FLOAT8[]"]
    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[]"]
    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,<commit_msg>Fix doc string<commit_after>//! Traits dealing with Postgres data types
pub use self::slice::Slice;

use std::collections::HashMap;
use std::old_io::net::ip::IpAddr;
use std::fmt;

use Result;
use error::Error;

pub use ugh_privacy::Other;

macro_rules! accepts {
    ($($expected:pat),+) => (
        fn accepts(ty: &::types::Type) -> bool {
            match *ty {
                $($expected)|+ => true,
                _ => false
            }
        }
    )
}

macro_rules! check_types {
    ($($expected:pat),+; $actual:ident) => (
        match $actual {
            $(&$expected)|+ => {}
            actual => return Err(::Error::WrongType(actual.clone()))
        }
    )
}

macro_rules! raw_from_impl {
    ($t:ty, $f:ident) => (
        impl RawFromSql for $t {
            fn raw_from_sql<R: Reader>(_: &Type, raw: &mut R) -> Result<$t> {
                Ok(try!(raw.$f()))
            }
        }
    )
}

macro_rules! from_option_impl {
    ($t:ty) => {
        impl ::types::FromSql for $t {
            fn from_sql(ty: &Type, raw: Option<&[u8]>) -> Result<$t> {
                use Error;
                use types::FromSql;

                // FIXME when you can specify Self types properly
                let ret: Result<Option<$t>> = FromSql::from_sql(ty, raw);
                match ret {
                    Ok(Some(val)) => Ok(val),
                    Ok(None) => Err(Error::WasNull),
                    Err(err) => Err(err)
                }
            }
        }
    }
}

macro_rules! from_map_impl {
    ($($expected:pat),+; $t:ty, $blk:expr) => (
        impl ::types::FromSql for Option<$t> {
            fn from_sql(ty: &Type, raw: Option<&[u8]>) -> Result<Option<$t>> {
                check_types!($($expected),+; ty);
                match raw {
                    Some(buf) => ($blk)(ty, buf).map(|ok| Some(ok)),
                    None => Ok(None)
                }
            }
        }

        from_option_impl!($t);
    )
}

macro_rules! from_raw_from_impl {
    ($($expected:pat),+; $t:ty) => (
        from_map_impl!($($expected),+; $t, |ty, mut buf: &[u8]| {
            use types::RawFromSql;

            RawFromSql::raw_from_sql(ty, &mut buf)
        });
    )
}

macro_rules! raw_to_impl {
    ($t:ty, $f:ident) => (
        impl RawToSql for $t {
            fn raw_to_sql<W: Writer>(&self, _: &Type, w: &mut W) -> Result<()> {
                Ok(try!(w.$f(*self)))
            }
        }
    )
}

macro_rules! to_option_impl {
    ($($oid:pat),+; $t:ty) => (
        impl ::types::ToSql for Option<$t> {
            fn to_sql(&self, ty: &Type) -> Result<Option<Vec<u8>>> {
                check_types!($($oid),+; ty);

                match *self {
                    None => Ok(None),
                    Some(ref val) => val.to_sql(ty)
                }
            }
        }
    )
}

macro_rules! to_option_impl_lifetime {
    ($($oid:pat),+; $t:ty) => (
        impl<'a> ToSql for Option<$t> {
            fn to_sql(&self, ty: &Type) -> Result<Option<Vec<u8>>> {
                check_types!($($oid),+; ty);

                match *self {
                    None => Ok(None),
                    Some(ref val) => val.to_sql(ty)
                }
            }
        }
    )
}

macro_rules! to_raw_to_impl {
    ($($oid:pat),+; $t:ty) => (
        impl ::types::ToSql for $t {
            fn to_sql(&self, ty: &Type) -> Result<Option<Vec<u8>>> {
                check_types!($($oid),+; ty);

                let mut writer = vec![];
                try!(self.raw_to_sql(ty, &mut writer));
                Ok(Some(writer))
            }
        }

        to_option_impl!($($oid),+; $t);
    )
}

#[cfg(feature = "uuid")]
mod uuid;
#[cfg(feature = "time")]
mod time;
mod slice;
#[cfg(feature = "rustc-serialize")]
mod json;

/// A Postgres OID
pub type Oid = u32;

/// Represents the kind of a Postgres type.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Kind {
    /// A simple type like `VARCHAR` or `INTEGER`.
    Simple,
    /// An array type along with the type of its elements.
    Array(Type),
    /// A range type along with the type of its elements.
    Range(Type),
}

macro_rules! as_pat {
    ($p:pat) => ($p)
}

macro_rules! as_expr {
    ($e:expr) => ($e)
}

macro_rules! make_postgres_type {
    ($(#[$doc:meta] $oid:tt => $variant:ident: $kind:expr),+) => (
        /// A Postgres type
        #[derive(PartialEq, Eq, Clone)]
        pub enum Type {
            $(
                #[$doc]
                $variant,
            )+
            /// An unknown type
            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::Other(ref u) => return fmt::Debug::fmt(u, fmt),
                };
                fmt.write_str(s)
            }
        }

        impl Type {
            /// Creates a `Type` from an OID.
            ///
            /// If the OID is unknown, `None` is returned.
            pub fn from_oid(oid: Oid) -> Option<Type> {
                match oid {
                    $(as_pat!($oid) => Some(Type::$variant),)+
                    _ => None
                }
            }

            /// Returns the OID of the `Type`.
            pub fn to_oid(&self) -> Oid {
                match *self {
                    $(Type::$variant => as_expr!($oid),)+
                    Type::Other(ref u) => u.oid(),
                }
            }

            /// The kind of this type
            pub fn kind(&self) -> &Kind {
                match *self {
                    $(
                        Type::$variant => {
                            const V: &'static Kind = &$kind;
                            V
                        }
                    )+
                    Type::Other(ref u) => u.kind(),
                }
            }
        }
    )
}

// Values from pg_type.h
make_postgres_type! {
    #[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"]
    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[]"]
    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[]"]
    1000 => BoolArray: Kind::Array(Type::Bool),
    #[doc="BYTEA[]"]
    1001 => ByteaArray: Kind::Array(Type::Bytea),
    #[doc="\"char\"[]"]
    1002 => CharArray: Kind::Array(Type::Char),
    #[doc="NAME[]"]
    1003 => NameArray: Kind::Array(Type::Name),
    #[doc="INT2[]"]
    1005 => Int2Array: Kind::Array(Type::Int2),
    #[doc="INT2VECTOR[]"]
    1006 => Int2VectorArray: Kind::Array(Type::Int2Vector),
    #[doc="INT4[]"]
    1007 => Int4Array: Kind::Array(Type::Int4),
    #[doc="REGPROC[]"]
    1008 => RegprocArray: Kind::Array(Type::Regproc),
    #[doc="TEXT[]"]
    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[]"]
    1015 => VarcharArray: Kind::Array(Type::Varchar),
    #[doc="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[]"]
    1021 => Float4Array: Kind::Array(Type::Float4),
    #[doc="FLOAT8[]"]
    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[]"]
    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 - @ &lt;number&gt; &lt;units&gt;, 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,
{'fraction_non_alphanumeric': 0.1903017924428637, 'fraction_numerical': 0.028383279923935627, 'mean_word_length': 2.3762929497087146, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 355, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4393012', 'n_tokens_mistral': 9962, 'n_tokens_neox': 9580, 'n_words': 2077}