@@ -3,7 +3,7 @@
33------------------------------------------------------------------------------
44-- |
55-- Module: Database.PostgreSQL.Simple.BuiltinTypes
6−-- Copyright: (c) 2011 Leon P Smith
6+-- Copyright: (c) 2011-2012 Leon P Smith
77-- License: BSD3
88-- Maintainer: Leon P Smith <leon@melding-monads.com>
99-- Stability: experimental
@@ -27,13 +27,13 @@ import qualified Database.PostgreSQL.LibPQ as PQ
2727
2828data BuiltinType
2929 = Bool
30− | Bytea
30+ | ByteA
3131 | Char
3232 | Name
3333 | Int8
3434 | Int2
3535 | Int4
36− | Regproc
36+ | RegProc
3737 | Text
3838 | Oid
3939 | Tid
@@ -41,7 +41,7 @@ data BuiltinType
4141 | Cid
4242 | Xml
4343 | Point
44− | Lseg
44+ | LSeg
4545 | Path
4646 | Box
4747 | Polygon
@@ -49,88 +49,88 @@ data BuiltinType
4949 | Cidr
5050 | Float4
5151 | Float8
52− | Abstime
53− | Reltime
54− | Tinterval
52+ | AbsTime
53+ | RelTime
54+ | TInterval
5555 | Unknown
5656 | Circle
5757 | Money
58− | Macaddr
58+ | MacAddr
5959 | Inet
60− | Bpchar
61− | Varchar
60+ | BpChar
61+ | VarChar
6262 | Date
6363 | Time
6464 | Timestamp
65− | TimestampWithTimeZone
65+ | TimestampTZ
6666 | Interval
67− | TimeWithTimeZone
67+ | TimeTZ
6868 | Bit
69− | Varbit
69+ | VarBit
7070 | Numeric
71− | Refcursor
71+ | RefCursor
7272 | Record
7373 | Void
7474 deriving (Eq, Ord, Enum, Bounded, Read, Show, Typeable)
7575
7676builtin2oid :: BuiltinType -> PQ.Oid
7777builtin2oid typ = PQ.Oid $ case typ of
78− Bool -> 16
79− Bytea -> 17
80− Char -> 18
81− Name -> 19
82− Int8 -> 20
83− Int2 -> 21
84− Int4 -> 23
85− Regproc -> 24
86− Text -> 25
87− Oid -> 26
88− Tid -> 27
89− Xid -> 28
90− Cid -> 29
91− Xml -> 142
92− Point -> 600
93− Lseg -> 601
94− Path -> 602
95− Box -> 603
96− Polygon -> 604
97− Line -> 628
98− Cidr -> 650
99− Float4 -> 700
100− Float8 -> 701
101− Abstime -> 702
102− Reltime -> 703
103− Tinterval -> 704
104− Unknown -> 705
105− Circle -> 718
106− Money -> 790
107− Macaddr -> 829
108− Inet -> 869
109− Bpchar -> 1042
110− Varchar -> 1043
111− Date -> 1082
112− Time -> 1083
113− Timestamp -> 1114
114− TimestampWithTimeZone -> 1184
115− Interval -> 1186
116− TimeWithTimeZone -> 1266
117− Bit -> 1560
118− Varbit -> 1562
119− Numeric -> 1700
120− Refcursor -> 1790
121− Record -> 2249
122− Void -> 2278
78+ Bool -> 16
79+ ByteA -> 17
80+ Char -> 18
81+ Name -> 19
82+ Int8 -> 20
83+ Int2 -> 21
84+ Int4 -> 23
85+ RegProc -> 24
86+ Text -> 25
87+ Oid -> 26
88+ Tid -> 27
89+ Xid -> 28
90+ Cid -> 29
91+ Xml -> 142
92+ Point -> 600
93+ LSeg -> 601
94+ Path -> 602
95+ Box -> 603
96+ Polygon -> 604
97+ Line -> 628
98+ Cidr -> 650
99+ Float4 -> 700
100+ Float8 -> 701
101+ AbsTime -> 702
102+ RelTime -> 703
103+ TInterval -> 704
104+ Unknown -> 705
105+ Circle -> 718
106+ Money -> 790
107+ MacAddr -> 829
108+ Inet -> 869
109+ BpChar -> 1042
110+ VarChar -> 1043
111+ Date -> 1082
112+ Time -> 1083
113+ Timestamp -> 1114
114+ TimestampTZ -> 1184
115+ Interval -> 1186
116+ TimeTZ -> 1266
117+ Bit -> 1560
118+ VarBit -> 1562
119+ Numeric -> 1700
120+ RefCursor -> 1790
121+ Record -> 2249
122+ Void -> 2278
123123
124124oid2builtin :: PQ.Oid -> Maybe BuiltinType
125125oid2builtin (PQ.Oid x) = case x of
126126 16 -> Just Bool
127− 17 -> Just Bytea
127+ 17 -> Just ByteA
128128 18 -> Just Char
129129 19 -> Just Name
130130 20 -> Just Int8
131131 21 -> Just Int2
132132 23 -> Just Int4
133− 24 -> Just Regproc
133+ 24 -> Just RegProc
134134 25 -> Just Text
135135 26 -> Just Oid
136136 27 -> Just Tid
@@ -138,7 +138,7 @@ oid2builtin (PQ.Oid x) = case x of
138138 29 -> Just Cid
139139 142 -> Just Xml
140140 600 -> Just Point
141− 601 -> Just Lseg
141+ 601 -> Just LSeg
142142 602 -> Just Path
143143 603 -> Just Box
144144 604 -> Just Polygon
@@ -146,77 +146,77 @@ oid2builtin (PQ.Oid x) = case x of
146146 650 -> Just Cidr
147147 700 -> Just Float4
148148 701 -> Just Float8
149− 702 -> Just Abstime
150− 703 -> Just Reltime
151− 704 -> Just Tinterval
149+ 702 -> Just AbsTime
150+ 703 -> Just RelTime
151+ 704 -> Just TInterval
152152 705 -> Just Unknown
153153 718 -> Just Circle
154154 790 -> Just Money
155− 829 -> Just Macaddr
155+ 829 -> Just MacAddr
156156 869 -> Just Inet
157− 1042 -> Just Bpchar
158− 1043 -> Just Varchar
157+ 1042 -> Just BpChar
158+ 1043 -> Just VarChar
159159 1082 -> Just Date
160160 1083 -> Just Time
161161 1114 -> Just Timestamp
162− 1184 -> Just TimestampWithTimeZone
162+ 1184 -> Just TimestampTZ
163163 1186 -> Just Interval
164− 1266 -> Just TimeWithTimeZone
164+ 1266 -> Just TimeTZ
165165 1560 -> Just Bit
166− 1562 -> Just Varbit
166+ 1562 -> Just VarBit
167167 1700 -> Just Numeric
168− 1790 -> Just Refcursor
168+ 1790 -> Just RefCursor
169169 2249 -> Just Record
170170 2278 -> Just Void
171171 _ -> Nothing
172172
173173builtin2typname :: BuiltinType -> ByteString
174174builtin2typname typ = case typ of
175− Bool -> bool
176− Bytea -> bytea
177− Char -> char
178− Name -> name
179− Int8 -> int8
180− Int2 -> int2
181− Int4 -> int4
182− Regproc -> regproc
183− Text -> text
184− Oid -> oid
185− Tid -> tid
186− Xid -> xid
187− Cid -> cid
188− Xml -> xml
189− Point -> point
190− Lseg -> lseg
191− Path -> path
192− Box -> box
193− Polygon -> polygon
194− Line -> line
195− Cidr -> cidr
196− Float4 -> float4
197− Float8 -> float8
198− Abstime -> abstime
199− Reltime -> reltime
200− Tinterval -> tinterval
201− Unknown -> unknown
202− Circle -> circle
203− Money -> money
204− Macaddr -> macaddr
205− Inet -> inet
206− Bpchar -> bpchar
207− Varchar -> varchar
208− Date -> date
209− Time -> time
210− Timestamp -> timestamp
211− TimestampWithTimeZone -> timestamptz
212− Interval -> interval
213− TimeWithTimeZone -> timetz
214− Bit -> bit
215− Varbit -> varbit
216− Numeric -> numeric
217− Refcursor -> refcursor
218− Record -> record
219− Void -> void
175+ Bool -> bool
176+ ByteA -> bytea
177+ Char -> char
178+ Name -> name
179+ Int8 -> int8
180+ Int2 -> int2
181+ Int4 -> int4
182+ RegProc -> regproc
183+ Text -> text
184+ Oid -> oid
185+ Tid -> tid
186+ Xid -> xid
187+ Cid -> cid
188+ Xml -> xml
189+ Point -> point
190+ LSeg -> lseg
191+ Path -> path
192+ Box -> box
193+ Polygon -> polygon
194+ Line -> line
195+ Cidr -> cidr
196+ Float4 -> float4
197+ Float8 -> float8
198+ AbsTime -> abstime
199+ RelTime -> reltime
200+ TInterval -> tinterval
201+ Unknown -> unknown
202+ Circle -> circle
203+ Money -> money
204+ MacAddr -> macaddr
205+ Inet -> inet
206+ BpChar -> bpchar
207+ VarChar -> varchar
208+ Date -> date
209+ Time -> time
210+ Timestamp -> timestamp
211+ TimestampTZ -> timestamptz
212+ Interval -> interval
213+ TimeTZ -> timetz
214+ Bit -> bit
215+ VarBit -> varbit
216+ Numeric -> numeric
217+ RefCursor -> refcursor
218+ Record -> record
219+ Void -> void
220220
221221oid2typname :: PQ.Oid -> Maybe ByteString
222222oid2typname (PQ.Oid x) = case x of