Copyright | Flipstone Technology Partners 2023 |
---|---|
License | MIT |
Stability | Stable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Since: 1.0.0.0
Documentation
data PgTextFormatValue Source #
A PgTextFormatValue
represents raw bytes that will be passed to PostgreSQL
via LibPQ. These bytes must conform to the TEXT format of values that
PostgreSQL expects. In all cases, PostgreSQL will be allowed to infer the
type of the value based on its usage in the query.
Note that PostgreSQL does not allow NUL bytes in text values, and the LibPQ C
library expects text values to be given as NULL-terminated C Strings, so
'NUL' bytes cannot be included in a PgTextFormatValue
. If fromByteString
is used to construct the PgTextFormatValue
(normally what you should do),
an error will be raised before LibPQ is called to execute the query. If
unsafeFromByteString
is used, the caller is expected to ensure that no
'NUL' bytes are present. If a 'NUL' byte is included with
unsafeFromByteString
, the value passed to the database will be truncated at
the 'NUL' byte because it will be interpreted as the end of the C String by
LibPQ.
Since: 1.0.0.0
Instances
Show PgTextFormatValue Source # | |
Defined in Orville.PostgreSQL.Raw.PgTextFormatValue showsPrec :: Int -> PgTextFormatValue -> ShowS # show :: PgTextFormatValue -> String # showList :: [PgTextFormatValue] -> ShowS # | |
Eq PgTextFormatValue Source # | |
Defined in Orville.PostgreSQL.Raw.PgTextFormatValue (==) :: PgTextFormatValue -> PgTextFormatValue -> Bool # (/=) :: PgTextFormatValue -> PgTextFormatValue -> Bool # |
data NULByteFoundError Source #
Instances
Exception NULByteFoundError Source # | |
Show NULByteFoundError Source # | |
Defined in Orville.PostgreSQL.Raw.PgTextFormatValue showsPrec :: Int -> NULByteFoundError -> ShowS # show :: NULByteFoundError -> String # showList :: [NULByteFoundError] -> ShowS # | |
Eq NULByteFoundError Source # | |
Defined in Orville.PostgreSQL.Raw.PgTextFormatValue (==) :: NULByteFoundError -> NULByteFoundError -> Bool # (/=) :: NULByteFoundError -> NULByteFoundError -> Bool # |
unsafeFromByteString :: ByteString -> PgTextFormatValue Source #
Constructs a PgTextFormatValue
from the given bytes directly, without checking
whether any of the bytes are 'NUL' or not. If a ByteString
containing
a 'NUL' byte is given, the value will be truncated at the 'NUL' when it
is passed to LibPQ.
This function is only safe to use when you have generated the bytestring in a way that guarantees no 'NUL' bytes are present, such as when serializing an integer value to its decimal representation.
Since: 1.0.0.0
fromByteString :: ByteString -> PgTextFormatValue Source #
Constructs a PgTextFormatValue
from the given bytes, which will be checked
to ensure none of them are 'NUL' before being passed to LibPQ. If a 'NUL'
byte is found an error will be raised.
Since: 1.0.0.0
toByteString :: PgTextFormatValue -> ByteString Source #
Converts the PgTextFormatValue
back to the bytes that were used to
construct it, losing the information about whether it would be checked
for 'NUL' bytes or not.
Since: 1.0.0.0
toBytesForLibPQ :: PgTextFormatValue -> Either NULByteFoundError ByteString Source #
Converts the PgTextFormatValue
to bytes intended to be passed to LibPQ.
If any 'NUL' bytes are found, NULByteFoundError
will be returned (unless
unsafeFromByteString
was used to construct the value).
Since: 1.0.0.0