hasql/library/Hasql/PostgresTypeInfo.hs

231 lines
4.7 KiB
Haskell
Raw Normal View History

2024-04-19 07:34:33 +03:00
module Hasql.PostgresTypeInfo where
2015-11-08 21:09:42 +03:00
2024-04-19 07:38:30 +03:00
import Database.PostgreSQL.LibPQ qualified as LibPQ
import Hasql.Prelude hiding (bool)
2015-11-08 21:09:42 +03:00
-- | A Postgresql type info
2022-06-20 13:54:54 +03:00
data PTI = PTI {ptiOID :: !OID, ptiArrayOID :: !(Maybe OID)}
2015-11-08 21:09:42 +03:00
-- | A Word32 and a LibPQ representation of an OID
2022-06-20 13:54:54 +03:00
data OID = OID {oidWord32 :: !Word32, oidPQ :: !LibPQ.Oid, oidFormat :: !LibPQ.Format}
2015-11-08 21:09:42 +03:00
mkOID :: LibPQ.Format -> Word32 -> OID
mkOID format x =
OID x ((LibPQ.Oid . fromIntegral) x) format
2015-11-08 21:09:42 +03:00
mkPTI :: LibPQ.Format -> Word32 -> Maybe Word32 -> PTI
mkPTI format oid arrayOID =
PTI (mkOID format oid) (fmap (mkOID format) arrayOID)
2015-11-08 21:09:42 +03:00
-- * Constants
2022-06-20 13:54:54 +03:00
2023-10-16 03:54:25 +03:00
abstime :: PTI
2022-06-20 13:54:54 +03:00
abstime = mkPTI LibPQ.Binary 702 (Just 1023)
2023-10-16 03:54:25 +03:00
aclitem :: PTI
2022-06-20 13:54:54 +03:00
aclitem = mkPTI LibPQ.Binary 1033 (Just 1034)
2023-10-16 03:54:25 +03:00
bit :: PTI
2022-06-20 13:54:54 +03:00
bit = mkPTI LibPQ.Binary 1560 (Just 1561)
2023-10-16 03:54:25 +03:00
bool :: PTI
2022-06-20 13:54:54 +03:00
bool = mkPTI LibPQ.Binary 16 (Just 1000)
2023-10-16 03:54:25 +03:00
box :: PTI
2022-06-20 13:54:54 +03:00
box = mkPTI LibPQ.Binary 603 (Just 1020)
2023-10-16 03:54:25 +03:00
bpchar :: PTI
2022-06-20 13:54:54 +03:00
bpchar = mkPTI LibPQ.Binary 1042 (Just 1014)
2023-10-16 03:54:25 +03:00
bytea :: PTI
2022-06-20 13:54:54 +03:00
bytea = mkPTI LibPQ.Binary 17 (Just 1001)
2023-10-16 03:54:25 +03:00
char :: PTI
2022-06-20 13:54:54 +03:00
char = mkPTI LibPQ.Binary 18 (Just 1002)
2023-10-16 03:54:25 +03:00
cid :: PTI
2022-06-20 13:54:54 +03:00
cid = mkPTI LibPQ.Binary 29 (Just 1012)
2023-10-16 03:54:25 +03:00
cidr :: PTI
2022-06-20 13:54:54 +03:00
cidr = mkPTI LibPQ.Binary 650 (Just 651)
2023-10-16 03:54:25 +03:00
circle :: PTI
2022-06-20 13:54:54 +03:00
circle = mkPTI LibPQ.Binary 718 (Just 719)
2023-10-16 03:54:25 +03:00
cstring :: PTI
2022-06-20 13:54:54 +03:00
cstring = mkPTI LibPQ.Binary 2275 (Just 1263)
2023-10-16 03:54:25 +03:00
date :: PTI
2022-06-20 13:54:54 +03:00
date = mkPTI LibPQ.Binary 1082 (Just 1182)
2023-10-16 03:54:25 +03:00
daterange :: PTI
2022-06-20 13:54:54 +03:00
daterange = mkPTI LibPQ.Binary 3912 (Just 3913)
2023-10-16 03:54:25 +03:00
float4 :: PTI
2022-06-20 13:54:54 +03:00
float4 = mkPTI LibPQ.Binary 700 (Just 1021)
2023-10-16 03:54:25 +03:00
float8 :: PTI
2022-06-20 13:54:54 +03:00
float8 = mkPTI LibPQ.Binary 701 (Just 1022)
2023-10-16 03:54:25 +03:00
gtsvector :: PTI
2022-06-20 13:54:54 +03:00
gtsvector = mkPTI LibPQ.Binary 3642 (Just 3644)
2023-10-16 03:54:25 +03:00
inet :: PTI
2022-06-20 13:54:54 +03:00
inet = mkPTI LibPQ.Binary 869 (Just 1041)
2023-10-16 03:54:25 +03:00
int2 :: PTI
2022-06-20 13:54:54 +03:00
int2 = mkPTI LibPQ.Binary 21 (Just 1005)
2023-10-16 03:54:25 +03:00
int2vector :: PTI
2022-06-20 13:54:54 +03:00
int2vector = mkPTI LibPQ.Binary 22 (Just 1006)
2023-10-16 03:54:25 +03:00
int4 :: PTI
2022-06-20 13:54:54 +03:00
int4 = mkPTI LibPQ.Binary 23 (Just 1007)
2023-10-16 03:54:25 +03:00
int4range :: PTI
2022-06-20 13:54:54 +03:00
int4range = mkPTI LibPQ.Binary 3904 (Just 3905)
2023-10-16 03:54:25 +03:00
int8 :: PTI
2022-06-20 13:54:54 +03:00
int8 = mkPTI LibPQ.Binary 20 (Just 1016)
2023-10-16 03:54:25 +03:00
int8range :: PTI
2022-06-20 13:54:54 +03:00
int8range = mkPTI LibPQ.Binary 3926 (Just 3927)
2023-10-16 03:54:25 +03:00
interval :: PTI
2022-06-20 13:54:54 +03:00
interval = mkPTI LibPQ.Binary 1186 (Just 1187)
2023-10-16 03:54:25 +03:00
json :: PTI
2022-06-20 13:54:54 +03:00
json = mkPTI LibPQ.Binary 114 (Just 199)
2023-10-16 03:54:25 +03:00
jsonb :: PTI
2022-06-20 13:54:54 +03:00
jsonb = mkPTI LibPQ.Binary 3802 (Just 3807)
2023-10-16 03:54:25 +03:00
line :: PTI
2022-06-20 13:54:54 +03:00
line = mkPTI LibPQ.Binary 628 (Just 629)
2023-10-16 03:54:25 +03:00
lseg :: PTI
2022-06-20 13:54:54 +03:00
lseg = mkPTI LibPQ.Binary 601 (Just 1018)
2023-10-16 03:54:25 +03:00
macaddr :: PTI
2022-06-20 13:54:54 +03:00
macaddr = mkPTI LibPQ.Binary 829 (Just 1040)
2023-10-16 03:54:25 +03:00
money :: PTI
2022-06-20 13:54:54 +03:00
money = mkPTI LibPQ.Binary 790 (Just 791)
2023-10-16 03:54:25 +03:00
name :: PTI
2022-06-20 13:54:54 +03:00
name = mkPTI LibPQ.Binary 19 (Just 1003)
2023-10-16 03:54:25 +03:00
numeric :: PTI
2022-06-20 13:54:54 +03:00
numeric = mkPTI LibPQ.Binary 1700 (Just 1231)
2023-10-16 03:54:25 +03:00
numrange :: PTI
2022-06-20 13:54:54 +03:00
numrange = mkPTI LibPQ.Binary 3906 (Just 3907)
2023-10-16 03:54:25 +03:00
oid :: PTI
2022-06-20 13:54:54 +03:00
oid = mkPTI LibPQ.Binary 26 (Just 1028)
2023-10-16 03:54:25 +03:00
oidvector :: PTI
2022-06-20 13:54:54 +03:00
oidvector = mkPTI LibPQ.Binary 30 (Just 1013)
2023-10-16 03:54:25 +03:00
path :: PTI
2022-06-20 13:54:54 +03:00
path = mkPTI LibPQ.Binary 602 (Just 1019)
2023-10-16 03:54:25 +03:00
point :: PTI
2022-06-20 13:54:54 +03:00
point = mkPTI LibPQ.Binary 600 (Just 1017)
2023-10-16 03:54:25 +03:00
polygon :: PTI
2022-06-20 13:54:54 +03:00
polygon = mkPTI LibPQ.Binary 604 (Just 1027)
2023-10-16 03:54:25 +03:00
record :: PTI
2022-06-20 13:54:54 +03:00
record = mkPTI LibPQ.Binary 2249 (Just 2287)
2023-10-16 03:54:25 +03:00
refcursor :: PTI
2022-06-20 13:54:54 +03:00
refcursor = mkPTI LibPQ.Binary 1790 (Just 2201)
2023-10-16 03:54:25 +03:00
regclass :: PTI
2022-06-20 13:54:54 +03:00
regclass = mkPTI LibPQ.Binary 2205 (Just 2210)
2023-10-16 03:54:25 +03:00
regconfig :: PTI
2022-06-20 13:54:54 +03:00
regconfig = mkPTI LibPQ.Binary 3734 (Just 3735)
2023-10-16 03:54:25 +03:00
regdictionary :: PTI
2022-06-20 13:54:54 +03:00
regdictionary = mkPTI LibPQ.Binary 3769 (Just 3770)
2023-10-16 03:54:25 +03:00
regoper :: PTI
2022-06-20 13:54:54 +03:00
regoper = mkPTI LibPQ.Binary 2203 (Just 2208)
2023-10-16 03:54:25 +03:00
regoperator :: PTI
2022-06-20 13:54:54 +03:00
regoperator = mkPTI LibPQ.Binary 2204 (Just 2209)
2023-10-16 03:54:25 +03:00
regproc :: PTI
2022-06-20 13:54:54 +03:00
regproc = mkPTI LibPQ.Binary 24 (Just 1008)
2023-10-16 03:54:25 +03:00
regprocedure :: PTI
2022-06-20 13:54:54 +03:00
regprocedure = mkPTI LibPQ.Binary 2202 (Just 2207)
2023-10-16 03:54:25 +03:00
regtype :: PTI
2022-06-20 13:54:54 +03:00
regtype = mkPTI LibPQ.Binary 2206 (Just 2211)
2023-10-16 03:54:25 +03:00
reltime :: PTI
2022-06-20 13:54:54 +03:00
reltime = mkPTI LibPQ.Binary 703 (Just 1024)
2023-10-16 03:54:25 +03:00
text :: PTI
2022-06-20 13:54:54 +03:00
text = mkPTI LibPQ.Binary 25 (Just 1009)
2023-10-16 03:54:25 +03:00
tid :: PTI
2022-06-20 13:54:54 +03:00
tid = mkPTI LibPQ.Binary 27 (Just 1010)
2023-10-16 03:54:25 +03:00
time :: PTI
2022-06-20 13:54:54 +03:00
time = mkPTI LibPQ.Binary 1083 (Just 1183)
2023-10-16 03:54:25 +03:00
timestamp :: PTI
2022-06-20 13:54:54 +03:00
timestamp = mkPTI LibPQ.Binary 1114 (Just 1115)
2023-10-16 03:54:25 +03:00
timestamptz :: PTI
2022-06-20 13:54:54 +03:00
timestamptz = mkPTI LibPQ.Binary 1184 (Just 1185)
2023-10-16 03:54:25 +03:00
timetz :: PTI
2022-06-20 13:54:54 +03:00
timetz = mkPTI LibPQ.Binary 1266 (Just 1270)
2023-10-16 03:54:25 +03:00
tinterval :: PTI
2022-06-20 13:54:54 +03:00
tinterval = mkPTI LibPQ.Binary 704 (Just 1025)
2023-10-16 03:54:25 +03:00
tsquery :: PTI
2022-06-20 13:54:54 +03:00
tsquery = mkPTI LibPQ.Binary 3615 (Just 3645)
2023-10-16 03:54:25 +03:00
tsrange :: PTI
2022-06-20 13:54:54 +03:00
tsrange = mkPTI LibPQ.Binary 3908 (Just 3909)
2023-10-16 03:54:25 +03:00
tstzrange :: PTI
2022-06-20 13:54:54 +03:00
tstzrange = mkPTI LibPQ.Binary 3910 (Just 3911)
2023-10-16 03:54:25 +03:00
tsvector :: PTI
2022-06-20 13:54:54 +03:00
tsvector = mkPTI LibPQ.Binary 3614 (Just 3643)
2023-10-16 03:54:25 +03:00
txid_snapshot :: PTI
2022-06-20 13:54:54 +03:00
txid_snapshot = mkPTI LibPQ.Binary 2970 (Just 2949)
2023-10-16 03:54:25 +03:00
textUnknown :: PTI
textUnknown = mkPTI LibPQ.Text 705 (Just 705)
2023-10-16 03:54:25 +03:00
binaryUnknown :: PTI
binaryUnknown = mkPTI LibPQ.Binary 705 (Just 705)
2022-06-20 13:54:54 +03:00
2023-10-16 03:54:25 +03:00
uuid :: PTI
2022-06-20 13:54:54 +03:00
uuid = mkPTI LibPQ.Binary 2950 (Just 2951)
2023-10-16 03:54:25 +03:00
varbit :: PTI
2022-06-20 13:54:54 +03:00
varbit = mkPTI LibPQ.Binary 1562 (Just 1563)
2023-10-16 03:54:25 +03:00
varchar :: PTI
2022-06-20 13:54:54 +03:00
varchar = mkPTI LibPQ.Binary 1043 (Just 1015)
2023-10-16 03:54:25 +03:00
void :: PTI
2022-06-20 13:54:54 +03:00
void = mkPTI LibPQ.Binary 2278 Nothing
2023-10-16 03:54:25 +03:00
xid :: PTI
2022-06-20 13:54:54 +03:00
xid = mkPTI LibPQ.Binary 28 (Just 1011)
2015-11-08 21:09:42 +03:00
2023-10-16 03:54:25 +03:00
xml :: PTI
2022-06-20 13:54:54 +03:00
xml = mkPTI LibPQ.Binary 142 (Just 143)