using System;
using Npgsql;
#pragma warning disable CA1720
// ReSharper disable once CheckNamespace
namespace NpgsqlTypes
{
///
/// Represents a PostgreSQL data type that can be written or read to the database.
/// Used in places such as to unambiguously specify
/// how to encode or decode values.
///
/// See http://www.postgresql.org/docs/current/static/datatype.html
public enum NpgsqlDbType
{
// Note that it's important to never change the numeric values of this enum, since user applications
// compile them in.
#region Numeric Types
///
/// Corresponds to the PostgreSQL 8-byte "bigint" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-numeric.html
[BuiltInPostgresType("int8", 20)]
Bigint = 1,
///
/// Corresponds to the PostgreSQL 8-byte floating-point "double" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-numeric.html
[BuiltInPostgresType("float8", 701)]
Double = 8,
///
/// Corresponds to the PostgreSQL 4-byte "integer" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-numeric.html
[BuiltInPostgresType("int4", 23)]
Integer = 9,
///
/// Corresponds to the PostgreSQL arbitrary-precision "numeric" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-numeric.html
[BuiltInPostgresType("numeric", 1700)]
Numeric = 13,
///
/// Corresponds to the PostgreSQL floating-point "real" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-numeric.html
[BuiltInPostgresType("float4", 700)]
Real = 17,
///
/// Corresponds to the PostgreSQL 2-byte "smallint" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-numeric.html
[BuiltInPostgresType("int2", 21)]
Smallint = 18,
///
/// Corresponds to the PostgreSQL "money" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-money.html
[BuiltInPostgresType("money", 790)]
Money = 12,
#endregion
#region Boolean Type
///
/// Corresponds to the PostgreSQL "boolean" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-boolean.html
[BuiltInPostgresType("bool", 16)]
Boolean = 2,
#endregion
#region Geometric types
///
/// Corresponds to the PostgreSQL geometric "box" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-geometric.html
[BuiltInPostgresType("box", 603)]
Box = 3,
///
/// Corresponds to the PostgreSQL geometric "circle" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-geometric.html
[BuiltInPostgresType("circle", 718)]
Circle = 5,
///
/// Corresponds to the PostgreSQL geometric "line" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-geometric.html
[BuiltInPostgresType("line", 628)]
Line = 10,
///
/// Corresponds to the PostgreSQL geometric "lseg" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-geometric.html
[BuiltInPostgresType("lseg", 601)]
LSeg = 11,
///
/// Corresponds to the PostgreSQL geometric "path" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-geometric.html
[BuiltInPostgresType("path", 602)]
Path = 14,
///
/// Corresponds to the PostgreSQL geometric "point" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-geometric.html
[BuiltInPostgresType("point", 600)]
Point = 15,
///
/// Corresponds to the PostgreSQL geometric "polygon" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-geometric.html
[BuiltInPostgresType("polygon", 604)]
Polygon = 16,
#endregion
#region Character Types
///
/// Corresponds to the PostgreSQL "char(n)" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-character.html
[BuiltInPostgresType("bpchar", 1042)]
Char = 6,
///
/// Corresponds to the PostgreSQL "text" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-character.html
[BuiltInPostgresType("text", 25)]
Text = 19,
///
/// Corresponds to the PostgreSQL "varchar" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-character.html
[BuiltInPostgresType("varchar", 1043)]
Varchar = 22,
///
/// Corresponds to the PostgreSQL internal "name" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-character.html
[BuiltInPostgresType("name", 19)]
Name = 32,
///
/// Corresponds to the PostgreSQL "citext" type for the citext module.
///
/// See http://www.postgresql.org/docs/current/static/citext.html
Citext = 51, // Extension type
///
/// Corresponds to the PostgreSQL "char" type.
///
///
/// This is an internal field and should normally not be used for regular applications.
///
/// See http://www.postgresql.org/docs/current/static/datatype-text.html
///
[BuiltInPostgresType("char", 18)]
InternalChar = 38,
#endregion
#region Binary Data Types
///
/// Corresponds to the PostgreSQL "bytea" type, holding a raw byte string.
///
/// See http://www.postgresql.org/docs/current/static/datatype-binary.html
[BuiltInPostgresType("bytea", 17)]
Bytea = 4,
#endregion
#region Date/Time Types
///
/// Corresponds to the PostgreSQL "date" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-datetime.html
[BuiltInPostgresType("date", 1082)]
Date = 7,
///
/// Corresponds to the PostgreSQL "time" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-datetime.html
[BuiltInPostgresType("time", 1083)]
Time = 20,
///
/// Corresponds to the PostgreSQL "timestamp" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-datetime.html
[BuiltInPostgresType("timestamp", 1114)]
Timestamp = 21,
///
/// Corresponds to the PostgreSQL "timestamp with time zone" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-datetime.html
[Obsolete("Use TimestampTz instead")] // NOTE: Don't remove this (see #1694)
TimestampTZ = TimestampTz,
///
/// Corresponds to the PostgreSQL "timestamp with time zone" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-datetime.html
[BuiltInPostgresType("timestamptz", 1184)]
TimestampTz = 26,
///
/// Corresponds to the PostgreSQL "interval" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-datetime.html
[BuiltInPostgresType("interval", 1186)]
Interval = 30,
///
/// Corresponds to the PostgreSQL "time with time zone" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-datetime.html
[Obsolete("Use TimeTz instead")] // NOTE: Don't remove this (see #1694)
TimeTZ = TimeTz,
///
/// Corresponds to the PostgreSQL "time with time zone" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-datetime.html
[BuiltInPostgresType("timetz", 1266)]
TimeTz = 31,
///
/// Corresponds to the obsolete PostgreSQL "abstime" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-datetime.html
[Obsolete("The PostgreSQL abstime time is obsolete.")]
[BuiltInPostgresType("abstime", 702)]
Abstime = 33,
#endregion
#region Network Address Types
///
/// Corresponds to the PostgreSQL "inet" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-net-types.html
[BuiltInPostgresType("inet", 869)]
Inet = 24,
///
/// Corresponds to the PostgreSQL "cidr" type, a field storing an IPv4 or IPv6 network.
///
/// See http://www.postgresql.org/docs/current/static/datatype-net-types.html
[BuiltInPostgresType("cidr", 650)]
Cidr = 44,
///
/// Corresponds to the PostgreSQL "macaddr" type, a field storing a 6-byte physical address.
///
/// See http://www.postgresql.org/docs/current/static/datatype-net-types.html
[BuiltInPostgresType("macaddr", 829)]
MacAddr = 34,
///
/// Corresponds to the PostgreSQL "macaddr8" type, a field storing a 6-byte or 8-byte physical address.
///
/// See http://www.postgresql.org/docs/current/static/datatype-net-types.html
[BuiltInPostgresType("macaddr8", 774)]
MacAddr8 = 54,
#endregion
#region Bit String Types
///
/// Corresponds to the PostgreSQL "bit" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-bit.html
[BuiltInPostgresType("bit", 1560)]
Bit = 25,
///
/// Corresponds to the PostgreSQL "varbit" type, a field storing a variable-length string of bits.
///
/// See http://www.postgresql.org/docs/current/static/datatype-boolean.html
[BuiltInPostgresType("varbit", 1562)]
Varbit = 39,
#endregion
#region Text Search Types
///
/// Corresponds to the PostgreSQL "tsvector" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-textsearch.html
[BuiltInPostgresType("tsvector", 3614)]
TsVector = 45,
///
/// Corresponds to the PostgreSQL "tsquery" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-textsearch.html
[BuiltInPostgresType("tsquery", 3615)]
TsQuery = 46,
///
/// Corresponds to the PostgreSQL "tsquery" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-textsearch.html
[BuiltInPostgresType("regconfig", 3734)]
Regconfig = 56,
#endregion
#region UUID Type
///
/// Corresponds to the PostgreSQL "uuid" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-uuid.html
[BuiltInPostgresType("uuid", 2950)]
Uuid = 27,
#endregion
#region XML Type
///
/// Corresponds to the PostgreSQL "xml" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-xml.html
[BuiltInPostgresType("xml", 142)]
Xml = 28,
#endregion
#region JSON Types
///
/// Corresponds to the PostgreSQL "json" type, a field storing JSON in text format.
///
/// See http://www.postgresql.org/docs/current/static/datatype-json.html
///
[BuiltInPostgresType("json", 114)]
Json = 35,
///
/// Corresponds to the PostgreSQL "jsonb" type, a field storing JSON in an optimized binary
/// format.
///
///
/// Supported since PostgreSQL 9.4.
/// See http://www.postgresql.org/docs/current/static/datatype-json.html
///
[BuiltInPostgresType("jsonb", 3802)]
Jsonb = 36,
#endregion
#region HSTORE Type
///
/// Corresponds to the PostgreSQL "hstore" type, a dictionary of string key-value pairs.
///
/// See http://www.postgresql.org/docs/current/static/hstore.html
Hstore = 37, // Extension type
#endregion
#region Arrays
///
/// Corresponds to the PostgreSQL "array" type, a variable-length multidimensional array of
/// another type. This value must be combined with another value from
/// via a bit OR (e.g. NpgsqlDbType.Array | NpgsqlDbType.Integer)
///
/// See http://www.postgresql.org/docs/current/static/arrays.html
Array = int.MinValue,
#endregion
#region Range Types
///
/// Corresponds to the PostgreSQL "range" type, continuous range of values of specific type.
/// This value must be combined with another value from
/// via a bit OR (e.g. NpgsqlDbType.Range | NpgsqlDbType.Integer)
///
///
/// Supported since PostgreSQL 9.2.
/// See http://www.postgresql.org/docs/9.2/static/rangetypes.html
///
Range = 0x40000000,
#endregion
#region Internal Types
///
/// Corresponds to the PostgreSQL "refcursor" type.
///
[BuiltInPostgresType("refcursor", 1790)]
Refcursor = 23,
///
/// Corresponds to the PostgreSQL internal "oidvector" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-oid.html
[BuiltInPostgresType("oidvector", 30)]
Oidvector = 29,
///
/// Corresponds to the PostgreSQL internal "int2vector" type.
///
[BuiltInPostgresType("int2vector", 22)]
Int2Vector = 52,
///
/// Corresponds to the PostgreSQL "oid" type.
///
/// See http://www.postgresql.org/docs/current/static/datatype-oid.html
[BuiltInPostgresType("oid", 26)]
Oid = 41,
///
/// Corresponds to the PostgreSQL "xid" type, an internal transaction identifier.
///
/// See http://www.postgresql.org/docs/current/static/datatype-oid.html
[BuiltInPostgresType("xid", 28)]
Xid = 42,
///
/// Corresponds to the PostgreSQL "cid" type, an internal command identifier.
///
/// See http://www.postgresql.org/docs/current/static/datatype-oid.html
[BuiltInPostgresType("cid", 29)]
Cid = 43,
///
/// Corresponds to the PostgreSQL "regtype" type, a numeric (OID) ID of a type in the pg_type table.
///
[BuiltInPostgresType("regtype", 2206)]
Regtype = 49,
///
/// Corresponds to the PostgreSQL "tid" type, a tuple id identifying the physical location of a row within its table.
///
[BuiltInPostgresType("tid", 27)]
Tid = 53,
#endregion
#region Special
///
/// A special value that can be used to send parameter values to the database without
/// specifying their type, allowing the database to cast them to another value based on context.
/// The value will be converted to a string and send as text.
///
///
/// This value shouldn't ordinarily be used, and makes sense only when sending a data type
/// unsupported by Npgsql.
///
[BuiltInPostgresType("unknown", 705)]
Unknown = 40,
#endregion
#region PostGIS
///
/// The geometry type for PostgreSQL spatial extension PostGIS.
///
Geometry = 50, // Extension type
///
/// The geography (geodetic) type for PostgreSQL spatial extension PostGIS.
///
Geography = 55 // Extension type
#endregion
}
///
/// Represents a built-in PostgreSQL type as it appears in pg_type, including its name and OID.
/// Extension types with variable OIDs are not represented.
///
class BuiltInPostgresType : Attribute
{
internal string Name { get; }
internal uint OID { get; }
internal BuiltInPostgresType(string name, uint oid)
{
Name = name;
OID = oid;
}
}
}