#[derive(Debug)]
pub struct PgType<'a> {
pub oid: u32,
pub typname: &'a str,
pub typnamespace: u32,
pub typowner: u32,
pub typlen: i16,
pub typbyval: bool,
pub typtype: &'a str,
pub typcategory: &'a str,
pub typisprefered: bool,
pub typisdefined: bool,
pub typrelid: u32,
pub typsubscript: &'static str,
pub typelem: u32,
pub typarray: u32,
pub typalign: &'static str,
pub typstorage: &'static str,
pub typbasetype: u32,
pub typreceive: &'static str,
}
macro_rules! define_pg_types {
($($NAME:ident ($OID:expr) { $($KEY:ident: $VALUE:expr,)* },)*) => {
#[allow(clippy::upper_case_acronyms)]
#[derive(Debug, Clone)]
pub enum PgTypeId {
$($NAME = $OID,)*
}
impl<'a> PgType<'a> {
pub fn get_all() -> Vec<&'static PgType<'static>> {
vec![
$($NAME,)*
]
}
}
$(
const $NAME: &PgType = &PgType {
oid: PgTypeId::$NAME as u32,
$($KEY: $VALUE,)*
};
)*
}
}
define_pg_types![
BOOL (16) {
typname: "bool",
typnamespace: 11,
typowner: 10,
typlen: 1,
typbyval: true,
typtype: "b",
typcategory: "B",
typisprefered: true,
typisdefined: true,
typrelid: 0,
typsubscript: "-",
typelem: 0,
typarray: 1000,
typalign: "c",
typstorage: "p",
typbasetype: 0,
typreceive: "boolrecv",
},
BYTEA (17) {
typname: "bytea",
typnamespace: 11,
typowner: 10,
typlen: -1,
typbyval: false,
typtype: "b",
typcategory: "U",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "-",
typelem: 0,
typarray: 1001,
typalign: "i",
typstorage: "x",
typbasetype: 0,
typreceive: "bytearecv",
},
CHAR (18) {
typname: "char",
typnamespace: 11,
typowner: 10,
typlen: 1,
typbyval: false,
typtype: "b",
typcategory: "Z",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "-",
typelem: 0,
typarray: 1002,
typalign: "c",
typstorage: "p",
typbasetype: 0,
typreceive: "charrecv",
},
INT8 (20) {
typname: "int8",
typnamespace: 11,
typowner: 10,
typlen: 8,
typbyval: true,
typtype: "b",
typcategory: "N",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "-",
typelem: 0,
typarray: 1016,
typalign: "d",
typstorage: "p",
typbasetype: 0,
typreceive: "int8recv",
},
INT2 (21) {
typname: "int2",
typnamespace: 11,
typowner: 10,
typlen: 2,
typbyval: true,
typtype: "b",
typcategory: "N",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "-",
typelem: 0,
typarray: 1005,
typalign: "s",
typstorage: "p",
typbasetype: 0,
typreceive: "int2recv",
},
INT4 (23) {
typname: "int4",
typnamespace: 11,
typowner: 10,
typlen: 4,
typbyval: true,
typtype: "b",
typcategory: "N",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "-",
typelem: 0,
typarray: 1007,
typalign: "i",
typstorage: "p",
typbasetype: 0,
typreceive: "int4recv",
},
FLOAT4 (700) {
typname: "float4",
typnamespace: 11,
typowner: 10,
typlen: 4,
typbyval: true,
typtype: "b",
typcategory: "N",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "-",
typelem: 0,
typarray: 1021,
typalign: "i",
typstorage: "p",
typbasetype: 0,
typreceive: "float4recv",
},
FLOAT8 (701) {
typname: "float8",
typnamespace: 11,
typowner: 10,
typlen: 8,
typbyval: true,
typtype: "b",
typcategory: "N",
typisprefered: true,
typisdefined: true,
typrelid: 0,
typsubscript: "-",
typelem: 0,
typarray: 1022,
typalign: "d",
typstorage: "p",
typbasetype: 0,
typreceive: "float8recv",
},
ARRAYBOOL (1000) {
typname: "_bool",
typnamespace: 11,
typowner: 10,
typlen: -1,
typbyval: false,
typtype: "b",
typcategory: "A",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "array_subscript_handler",
typelem: 16,
typarray: 0,
typalign: "i",
typstorage: "x",
typbasetype: 0,
typreceive: "array_recv",
},
ARRAYBYTEA (1001) {
typname: "_bytea",
typnamespace: 11,
typowner: 10,
typlen: -1,
typbyval: false,
typtype: "b",
typcategory: "A",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "array_subscript_handler",
typelem: 17,
typarray: 0,
typalign: "i",
typstorage: "x",
typbasetype: 0,
typreceive: "array_recv",
},
ARRAYCHAR (1002) {
typname: "_char",
typnamespace: 11,
typowner: 10,
typlen: -1,
typbyval: false,
typtype: "b",
typcategory: "A",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "array_subscript_handler",
typelem: 18,
typarray: 0,
typalign: "i",
typstorage: "x",
typbasetype: 0,
typreceive: "array_recv",
},
ARRAYINT2 (1005) {
typname: "_int2",
typnamespace: 11,
typowner: 10,
typlen: -1,
typbyval: false,
typtype: "b",
typcategory: "A",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "array_subscript_handler",
typelem: 21,
typarray: 0,
typalign: "i",
typstorage: "x",
typbasetype: 0,
typreceive: "array_recv",
},
ARRAYINT4 (1007) {
typname: "_int4",
typnamespace: 11,
typowner: 10,
typlen: -1,
typbyval: false,
typtype: "b",
typcategory: "A",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "array_subscript_handler",
typelem: 23,
typarray: 0,
typalign: "i",
typstorage: "x",
typbasetype: 0,
typreceive: "array_recv",
},
ARRAYVARCHAR (1015) {
typname: "_varchar",
typnamespace: 11,
typowner: 10,
typlen: -1,
typbyval: false,
typtype: "b",
typcategory: "A",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "array_subscript_handler",
typelem: 1043,
typarray: 0,
typalign: "i",
typstorage: "x",
typbasetype: 0,
typreceive: "array_recv",
},
ARRAYINT8 (1016) {
typname: "_int8",
typnamespace: 11,
typowner: 10,
typlen: -1,
typbyval: false,
typtype: "b",
typcategory: "A",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "array_subscript_handler",
typelem: 20,
typarray: 0,
typalign: "d",
typstorage: "x",
typbasetype: 0,
typreceive: "array_recv",
},
ARRAYFLOAT4 (1021) {
typname: "_float4",
typnamespace: 11,
typowner: 10,
typlen: -1,
typbyval: false,
typtype: "b",
typcategory: "A",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "array_subscript_handler",
typelem: 700,
typarray: 0,
typalign: "i",
typstorage: "x",
typbasetype: 0,
typreceive: "array_recv",
},
ARRAYFLOAT8 (1022) {
typname: "_float8",
typnamespace: 11,
typowner: 10,
typlen: -1,
typbyval: false,
typtype: "b",
typcategory: "A",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "array_subscript_handler",
typelem: 701,
typarray: 0,
typalign: "d",
typstorage: "x",
typbasetype: 0,
typreceive: "array_recv",
},
VARCHAR (1043) {
typname: "varchar",
typnamespace: 11,
typowner: 10,
typlen: -1,
typbyval: false,
typtype: "b",
typcategory: "S",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "-",
typelem: 0,
typarray: 1015,
typalign: "i",
typstorage: "x",
typbasetype: 0,
typreceive: "varcharrecv",
},
DATE (1082) {
typname: "date",
typnamespace: 11,
typowner: 10,
typlen: 4,
typbyval: true,
typtype: "b",
typcategory: "D",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "-",
typelem: 0,
typarray: 1182,
typalign: "i",
typstorage: "p",
typbasetype: 0,
typreceive: "date_recv",
},
TIME (1083) {
typname: "time",
typnamespace: 11,
typowner: 10,
typlen: 8,
typbyval: true,
typtype: "b",
typcategory: "D",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "-",
typelem: 0,
typarray: 1183,
typalign: "d",
typstorage: "p",
typbasetype: 0,
typreceive: "time_recv",
},
TIMESTAMP (1114) {
typname: "timestamp",
typnamespace: 11,
typowner: 10,
typlen: 8,
typbyval: true,
typtype: "b",
typcategory: "D",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "-",
typelem: 0,
typarray: 1115,
typalign: "d",
typstorage: "p",
typbasetype: 0,
typreceive: "timestamp_recv",
},
ARRAYTIMESTAMP (1115) {
typname: "_timestamp",
typnamespace: 11,
typowner: 10,
typlen: -1,
typbyval: false,
typtype: "b",
typcategory: "A",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "array_subscript_handler",
typelem: 1114,
typarray: 0,
typalign: "d",
typstorage: "x",
typbasetype: 0,
typreceive: "array_recv",
},
ARRAYDATE (1182) {
typname: "_date",
typnamespace: 11,
typowner: 10,
typlen: -1,
typbyval: false,
typtype: "b",
typcategory: "A",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "array_subscript_handler",
typelem: 1082,
typarray: 0,
typalign: "i",
typstorage: "x",
typbasetype: 0,
typreceive: "array_recv",
},
ARRAYTIME (1183) {
typname: "_time",
typnamespace: 11,
typowner: 10,
typlen: -1,
typbyval: false,
typtype: "b",
typcategory: "A",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "array_subscript_handler",
typelem: 1083,
typarray: 0,
typalign: "d",
typstorage: "x",
typbasetype: 0,
typreceive: "array_recv",
},
TIMESTAMPTZ (1184) {
typname: "timestamptz",
typnamespace: 11,
typowner: 10,
typlen: 8,
typbyval: true,
typtype: "b",
typcategory: "D",
typisprefered: true,
typisdefined: true,
typrelid: 0,
typsubscript: "-",
typelem: 0,
typarray: 1185,
typalign: "d",
typstorage: "p",
typbasetype: 0,
typreceive: "timestamptz_recv",
},
ARRAYTIMESTAMPTZ (1185) {
typname: "_timestamptz",
typnamespace: 11,
typowner: 10,
typlen: -1,
typbyval: false,
typtype: "b",
typcategory: "A",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "array_subscript_handler",
typelem: 1184,
typarray: 0,
typalign: "d",
typstorage: "x",
typbasetype: 0,
typreceive: "array_recv",
},
INTERVAL (1186) {
typname: "interval",
typnamespace: 11,
typowner: 10,
typlen: 16,
typbyval: false,
typtype: "b",
typcategory: "T",
typisprefered: true,
typisdefined: true,
typrelid: 0,
typsubscript: "-",
typelem: 0,
typarray: 1187,
typalign: "d",
typstorage: "p",
typbasetype: 0,
typreceive: "interval_recv",
},
ARRAYINTERVAL (1187) {
typname: "_interval",
typnamespace: 11,
typowner: 10,
typlen: -1,
typbyval: false,
typtype: "b",
typcategory: "A",
typisprefered: false,
typisdefined: true,
typrelid: 0,
typsubscript: "array_subscript_handler",
typelem: 1186,
typarray: 0,
typalign: "d",
typstorage: "x",
typbasetype: 0,
typreceive: "array_recv",
},
];