-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | PostgreSQL interface with compile-time SQL type checking, optional HDBC backend -- -- Automatically type-check SQL statements at compile time. Uses Template -- Haskell and the raw PostgreSQL protocol to describe SQL statements at -- compile time and provide appropriate type marshalling for both -- parameters and results. Allows not only syntax verification of your -- SQL but also full type safety between your SQL and Haskell. Supports -- many built-in PostgreSQL types already, including arrays and ranges, -- and can be easily extended in user code to support any other types. -- -- Also includes an optional HDBC backend that, since it uses the raw -- PostgreSQL protocol, may be more efficient than the normal libpq -- backend in some cases (though provides no more type safety than -- HDBC-postgresql when used without templates). -- -- Originally based on Chris Forno's templatepg library. @package postgresql-typed @version 0.5.2 -- | Classes to support type inference, value encoding/decoding, and -- instances to support built-in PostgreSQL types. module Database.PostgreSQL.Typed.Types type OID = Word32 -- | A value passed to or from PostgreSQL in raw format. data PGValue PGNullValue :: PGValue -- | The standard text encoding format (also used for unknown formats) PGTextValue :: PGTextValue -> PGValue [pgTextValue] :: PGValue -> PGTextValue -- | Special binary-encoded data. Not supported in all cases. PGBinaryValue :: PGBinaryValue -> PGValue [pgBinaryValue] :: PGValue -> PGBinaryValue -- | A list of (nullable) data values, e.g. a single row or query -- parameters. type PGValues = [PGValue] -- | A proxy type for PostgreSQL types. The type argument should be an -- (internal) name of a database type, as per format_type(OID) -- (usually the same as \dT+). When the type's namespace -- (schema) is not in search_path, this will be explicitly -- qualified, so you should be sure to have a consistent -- search_path for all database connections. The underlying -- Symbol should be considered a lifted PGName. data PGTypeID (t :: Symbol) PGTypeProxy :: PGTypeID -- | Parameters that affect how marshalling happens. Currenly we force all -- other relevant parameters at connect time. Nothing values represent -- unknown. data PGTypeEnv PGTypeEnv :: Maybe Bool -> PGTypeEnv -- | If integer_datetimes is on; only relevant for binary -- encoding. [pgIntegerDatetimes] :: PGTypeEnv -> Maybe Bool unknownPGTypeEnv :: PGTypeEnv -- | A PostgreSQL literal identifier, generally corresponding to the "name" -- type (63-byte strings), but as it would be entered in a query, so may -- include double-quoting for special characters or schema-qualification. newtype PGName PGName :: [Word8] -> PGName -- | Raw bytes of the identifier (should really be a ByteString, but -- we need a working Data instance for annotations). [pgNameBytes] :: PGName -> [Word8] -- | The literal identifier as used in a query. pgNameBS :: PGName -> ByteString -- | Reverses the IsString instantce. pgNameString :: PGName -> String -- | Generic class of composite (row or record) types. newtype PGRecord PGRecord :: [Maybe PGTextValue] -> PGRecord -- | A valid PostgreSQL type, its metadata, and corresponding Haskell -- representation. For conversion the other way (from Haskell type to -- PostgreSQL), see PGRep. Unfortunately any instances of this -- will be orphans. class (KnownSymbol t, PGParameter t (PGVal t), PGColumn t (PGVal t)) => PGType t where type PGVal t :: * pgTypeName = fromString . symbolVal pgBinaryColumn _ _ = False where { type family PGVal t :: *; } -- | The string name of this type: specialized version of symbolVal. pgTypeName :: PGType t => PGTypeID t -> PGName -- | Does this type support binary decoding? If so, pgDecodeBinary -- must be implemented for every PGColumn instance of this type. pgBinaryColumn :: PGType t => PGTypeEnv -> PGTypeID t -> Bool -- | A PGParameter t a instance describes how to encode a -- PostgreSQL type t from a. class PGType t => PGParameter t a where pgLiteral t = pgQuote . pgEncode t pgEncodeValue _ t = PGTextValue . pgEncode t -- | Encode a value to a PostgreSQL text representation. pgEncode :: PGParameter t a => PGTypeID t -> a -> PGTextValue -- | Encode a value to a (quoted) literal value for use in SQL statements. -- Defaults to a quoted version of pgEncode pgLiteral :: PGParameter t a => PGTypeID t -> a -> ByteString -- | Encode a value to a PostgreSQL representation. Defaults to the text -- representation by pgEncode pgEncodeValue :: PGParameter t a => PGTypeEnv -> PGTypeID t -> a -> PGValue -- | A PGColumn t a instance describes how te decode a PostgreSQL -- type t to a. class PGType t => PGColumn t a where pgDecodeBinary _ t _ = error $ "pgDecodeBinary " ++ show (pgTypeName t) ++ ": not supported" pgDecodeValue _ t (PGTextValue v) = pgDecode t v pgDecodeValue e t (PGBinaryValue v) = pgDecodeBinary e t v pgDecodeValue _ t PGNullValue = error $ "NULL in " ++ show (pgTypeName t) ++ " column (use Maybe or COALESCE)" -- | Decode the PostgreSQL text representation into a value. pgDecode :: PGColumn t a => PGTypeID t -> PGTextValue -> a -- | Decode the PostgreSQL binary representation into a value. Only needs -- to be implemented if pgBinaryColumn is true. pgDecodeBinary :: PGColumn t a => PGTypeEnv -> PGTypeID t -> PGBinaryValue -> a pgDecodeValue :: PGColumn t a => PGTypeEnv -> PGTypeID t -> PGValue -> a class PGType t => PGStringType t class PGType t => PGRecordType t -- | Final parameter encoding function used when a (nullable) parameter is -- passed to a prepared query. pgEncodeParameter :: PGParameter t a => PGTypeEnv -> PGTypeID t -> a -> PGValue -- | Final parameter escaping function used when a (nullable) parameter is -- passed to be substituted into a simple query. pgEscapeParameter :: PGParameter t a => PGTypeEnv -> PGTypeID t -> a -> ByteString -- | Final column decoding function used for a nullable result value. pgDecodeColumn :: PGColumn t (Maybe a) => PGTypeEnv -> PGTypeID t -> PGValue -> Maybe a -- | Final column decoding function used for a non-nullable result value. pgDecodeColumnNotNull :: PGColumn t a => PGTypeEnv -> PGTypeID t -> PGValue -> a -- | Produce a SQL string literal by wrapping (and escaping) a string with -- single quotes. pgQuote :: ByteString -> ByteString -- | Double-quote a value if it's "", "null", or contains any whitespace, -- '"', '\', or the characters given in the first argument. Checking all -- these things may not be worth it. We could just double-quote -- everything. pgDQuote :: [Char] -> ByteString -> Builder -- | Parse double-quoted values ala pgDQuote. parsePGDQuote :: Bool -> [Char] -> (ByteString -> Bool) -> Parser (Maybe ByteString) -- | Shorthand for toStrict . toLazyByteString buildPGValue :: Builder -> ByteString instance Data.Data.Data Database.PostgreSQL.Typed.Types.PGName instance GHC.Classes.Ord Database.PostgreSQL.Typed.Types.PGName instance GHC.Classes.Eq Database.PostgreSQL.Typed.Types.PGName instance GHC.Show.Show Database.PostgreSQL.Typed.Types.PGTypeEnv instance GHC.Classes.Eq Database.PostgreSQL.Typed.Types.PGValue instance GHC.Show.Show Database.PostgreSQL.Typed.Types.PGValue instance Data.String.IsString Database.PostgreSQL.Typed.Types.PGName instance GHC.Show.Show Database.PostgreSQL.Typed.Types.PGName instance Database.PostgreSQL.Typed.Types.PGParameter t a => Database.PostgreSQL.Typed.Types.PGParameter t (GHC.Base.Maybe a) instance Database.PostgreSQL.Typed.Types.PGColumn t a => Database.PostgreSQL.Typed.Types.PGColumn t (GHC.Base.Maybe a) instance Database.PostgreSQL.Typed.Types.PGType "any" instance Database.PostgreSQL.Typed.Types.PGType t => Database.PostgreSQL.Typed.Types.PGColumn t Database.PostgreSQL.Typed.Types.PGValue instance Database.PostgreSQL.Typed.Types.PGParameter "any" Database.PostgreSQL.Typed.Types.PGValue instance Database.PostgreSQL.Typed.Types.PGType "void" instance Database.PostgreSQL.Typed.Types.PGParameter "void" () instance Database.PostgreSQL.Typed.Types.PGColumn "void" () instance Database.PostgreSQL.Typed.Types.PGType "boolean" instance Database.PostgreSQL.Typed.Types.PGParameter "boolean" GHC.Types.Bool instance Database.PostgreSQL.Typed.Types.PGColumn "boolean" GHC.Types.Bool instance Database.PostgreSQL.Typed.Types.PGType "oid" instance Database.PostgreSQL.Typed.Types.PGParameter "oid" Database.PostgreSQL.Typed.Types.OID instance Database.PostgreSQL.Typed.Types.PGColumn "oid" Database.PostgreSQL.Typed.Types.OID instance Database.PostgreSQL.Typed.Types.PGType "smallint" instance Database.PostgreSQL.Typed.Types.PGParameter "smallint" GHC.Int.Int16 instance Database.PostgreSQL.Typed.Types.PGColumn "smallint" GHC.Int.Int16 instance Database.PostgreSQL.Typed.Types.PGType "integer" instance Database.PostgreSQL.Typed.Types.PGParameter "integer" GHC.Int.Int32 instance Database.PostgreSQL.Typed.Types.PGColumn "integer" GHC.Int.Int32 instance Database.PostgreSQL.Typed.Types.PGType "bigint" instance Database.PostgreSQL.Typed.Types.PGParameter "bigint" GHC.Int.Int64 instance Database.PostgreSQL.Typed.Types.PGColumn "bigint" GHC.Int.Int64 instance Database.PostgreSQL.Typed.Types.PGType "real" instance Database.PostgreSQL.Typed.Types.PGParameter "real" GHC.Types.Float instance Database.PostgreSQL.Typed.Types.PGColumn "real" GHC.Types.Float instance Database.PostgreSQL.Typed.Types.PGColumn "real" GHC.Types.Double instance Database.PostgreSQL.Typed.Types.PGType "double precision" instance Database.PostgreSQL.Typed.Types.PGParameter "double precision" GHC.Types.Double instance Database.PostgreSQL.Typed.Types.PGParameter "double precision" GHC.Types.Float instance Database.PostgreSQL.Typed.Types.PGColumn "double precision" GHC.Types.Double instance Database.PostgreSQL.Typed.Types.PGType "\"char\"" instance Database.PostgreSQL.Typed.Types.PGParameter "\"char\"" GHC.Word.Word8 instance Database.PostgreSQL.Typed.Types.PGColumn "\"char\"" GHC.Word.Word8 instance Database.PostgreSQL.Typed.Types.PGParameter "\"char\"" GHC.Types.Char instance Database.PostgreSQL.Typed.Types.PGColumn "\"char\"" GHC.Types.Char instance Database.PostgreSQL.Typed.Types.PGStringType t => Database.PostgreSQL.Typed.Types.PGParameter t GHC.Base.String instance Database.PostgreSQL.Typed.Types.PGStringType t => Database.PostgreSQL.Typed.Types.PGColumn t GHC.Base.String instance Database.PostgreSQL.Typed.Types.PGStringType t => Database.PostgreSQL.Typed.Types.PGParameter t Data.ByteString.Internal.ByteString instance Database.PostgreSQL.Typed.Types.PGStringType t => Database.PostgreSQL.Typed.Types.PGColumn t Data.ByteString.Internal.ByteString instance Database.PostgreSQL.Typed.Types.PGStringType t => Database.PostgreSQL.Typed.Types.PGParameter t Database.PostgreSQL.Typed.Types.PGName instance Database.PostgreSQL.Typed.Types.PGStringType t => Database.PostgreSQL.Typed.Types.PGColumn t Database.PostgreSQL.Typed.Types.PGName instance Database.PostgreSQL.Typed.Types.PGStringType t => Database.PostgreSQL.Typed.Types.PGParameter t Data.ByteString.Lazy.Internal.ByteString instance Database.PostgreSQL.Typed.Types.PGStringType t => Database.PostgreSQL.Typed.Types.PGColumn t Data.ByteString.Lazy.Internal.ByteString instance Database.PostgreSQL.Typed.Types.PGStringType t => Database.PostgreSQL.Typed.Types.PGParameter t Data.Text.Internal.Text instance Database.PostgreSQL.Typed.Types.PGStringType t => Database.PostgreSQL.Typed.Types.PGColumn t Data.Text.Internal.Text instance Database.PostgreSQL.Typed.Types.PGStringType t => Database.PostgreSQL.Typed.Types.PGParameter t Data.Text.Internal.Lazy.Text instance Database.PostgreSQL.Typed.Types.PGStringType t => Database.PostgreSQL.Typed.Types.PGColumn t Data.Text.Internal.Lazy.Text instance Database.PostgreSQL.Typed.Types.PGType "text" instance Database.PostgreSQL.Typed.Types.PGType "character varying" instance Database.PostgreSQL.Typed.Types.PGType "name" instance Database.PostgreSQL.Typed.Types.PGType "bpchar" instance Database.PostgreSQL.Typed.Types.PGStringType "text" instance Database.PostgreSQL.Typed.Types.PGStringType "character varying" instance Database.PostgreSQL.Typed.Types.PGStringType "name" instance Database.PostgreSQL.Typed.Types.PGStringType "bpchar" instance Database.PostgreSQL.Typed.Types.PGType "bytea" instance Database.PostgreSQL.Typed.Types.PGParameter "bytea" Data.ByteString.Lazy.Internal.ByteString instance Database.PostgreSQL.Typed.Types.PGColumn "bytea" Data.ByteString.Lazy.Internal.ByteString instance Database.PostgreSQL.Typed.Types.PGParameter "bytea" Data.ByteString.Internal.ByteString instance Database.PostgreSQL.Typed.Types.PGColumn "bytea" Data.ByteString.Internal.ByteString instance Database.PostgreSQL.Typed.Types.PGType "date" instance Database.PostgreSQL.Typed.Types.PGParameter "date" Data.Time.Calendar.Days.Day instance Database.PostgreSQL.Typed.Types.PGColumn "date" Data.Time.Calendar.Days.Day instance Database.PostgreSQL.Typed.Types.PGType "time without time zone" instance Database.PostgreSQL.Typed.Types.PGParameter "time without time zone" Data.Time.LocalTime.TimeOfDay.TimeOfDay instance Database.PostgreSQL.Typed.Types.PGColumn "time without time zone" Data.Time.LocalTime.TimeOfDay.TimeOfDay instance Database.PostgreSQL.Typed.Types.PGType "time with time zone" instance Database.PostgreSQL.Typed.Types.PGParameter "time with time zone" (Data.Time.LocalTime.TimeOfDay.TimeOfDay, Data.Time.LocalTime.TimeZone.TimeZone) instance Database.PostgreSQL.Typed.Types.PGColumn "time with time zone" (Data.Time.LocalTime.TimeOfDay.TimeOfDay, Data.Time.LocalTime.TimeZone.TimeZone) instance Database.PostgreSQL.Typed.Types.PGType "timestamp without time zone" instance Database.PostgreSQL.Typed.Types.PGParameter "timestamp without time zone" Data.Time.LocalTime.LocalTime.LocalTime instance Database.PostgreSQL.Typed.Types.PGColumn "timestamp without time zone" Data.Time.LocalTime.LocalTime.LocalTime instance Database.PostgreSQL.Typed.Types.PGType "timestamp with time zone" instance Database.PostgreSQL.Typed.Types.PGParameter "timestamp with time zone" Data.Time.Clock.UTC.UTCTime instance Database.PostgreSQL.Typed.Types.PGColumn "timestamp with time zone" Data.Time.Clock.UTC.UTCTime instance Database.PostgreSQL.Typed.Types.PGType "interval" instance Database.PostgreSQL.Typed.Types.PGParameter "interval" Data.Time.Clock.Scale.DiffTime instance Database.PostgreSQL.Typed.Types.PGColumn "interval" Data.Time.Clock.Scale.DiffTime instance Database.PostgreSQL.Typed.Types.PGType "numeric" instance Database.PostgreSQL.Typed.Types.PGParameter "numeric" GHC.Real.Rational instance Database.PostgreSQL.Typed.Types.PGColumn "numeric" GHC.Real.Rational instance Database.PostgreSQL.Typed.Types.PGParameter "numeric" Data.Scientific.Scientific instance Database.PostgreSQL.Typed.Types.PGColumn "numeric" Data.Scientific.Scientific instance Database.PostgreSQL.Typed.Types.PGType "uuid" instance Database.PostgreSQL.Typed.Types.PGParameter "uuid" Data.UUID.Types.Internal.UUID instance Database.PostgreSQL.Typed.Types.PGColumn "uuid" Data.UUID.Types.Internal.UUID instance Database.PostgreSQL.Typed.Types.PGRecordType t => Database.PostgreSQL.Typed.Types.PGParameter t Database.PostgreSQL.Typed.Types.PGRecord instance Database.PostgreSQL.Typed.Types.PGRecordType t => Database.PostgreSQL.Typed.Types.PGColumn t Database.PostgreSQL.Typed.Types.PGRecord instance Database.PostgreSQL.Typed.Types.PGType "record" instance Database.PostgreSQL.Typed.Types.PGRecordType "record" instance Database.PostgreSQL.Typed.Types.PGType "json" instance Database.PostgreSQL.Typed.Types.PGParameter "json" Data.Aeson.Types.Internal.Value instance Database.PostgreSQL.Typed.Types.PGColumn "json" Data.Aeson.Types.Internal.Value instance Database.PostgreSQL.Typed.Types.PGType "jsonb" instance Database.PostgreSQL.Typed.Types.PGParameter "jsonb" Data.Aeson.Types.Internal.Value instance Database.PostgreSQL.Typed.Types.PGColumn "jsonb" Data.Aeson.Types.Internal.Value -- | Parsing of SQL statements to safely identify placeholders. Supports -- both dollar-placeholders and question marks for HDBC. module Database.PostgreSQL.Typed.SQLToken -- | A parsed SQL token. data SQLToken -- | Raw (non-markup) SQL string SQLToken :: String -> SQLToken -- | A "$N" parameter placeholder (this is the only non-string-preserving -- token: "$012" becomes "$12") SQLParam :: Int -> SQLToken -- | A "${expr}" expression placeholder SQLExpr :: String -> SQLToken -- | A possibly-escaped question-mark: False for "?" or True for "\?" SQLQMark :: Bool -> SQLToken -- | Parse a SQL string into a series of tokens. The showList -- implementation for SQLToken inverts this sequence back to a SQL -- string. sqlTokens :: String -> [SQLToken] instance GHC.Classes.Eq Database.PostgreSQL.Typed.SQLToken.SQLToken instance GHC.Show.Show Database.PostgreSQL.Typed.SQLToken.SQLToken instance Data.String.IsString Database.PostgreSQL.Typed.SQLToken.SQLToken -- | Representaion of PostgreSQL's range type. There are a number of -- existing range data types, but PostgreSQL's is rather particular. This -- tries to provide a one-to-one mapping. module Database.PostgreSQL.Typed.Range -- | A end-point for a range, which may be nothing (infinity, NULL in -- PostgreSQL), open (inclusive), or closed (exclusive) data Bound a -- | Equivalent to Bounded False ±Infinity Unbounded :: Bound a Bounded :: Bool -> a -> Bound a -- | True if the range includes this bound [_boundClosed] :: Bound a -> Bool [_bound] :: Bound a -> a newtype LowerBound a Lower :: Bound a -> LowerBound a [boundLower] :: LowerBound a -> Bound a -- | Takes into account open vs. closed (but does not understand equivalent -- discrete bounds) -- | The constraint is only necessary for maxBound, unfortunately newtype UpperBound a Upper :: Bound a -> UpperBound a [boundUpper] :: UpperBound a -> Bound a -- | Takes into account open vs. closed (but does not understand equivalent -- discrete bounds) -- | The constraint is only necessary for minBound, unfortunately compareBounds :: Ord a => LowerBound a -> UpperBound a -> Bound Bool data Range a Empty :: Range a Range :: LowerBound a -> UpperBound a -> Range a [lower] :: Range a -> LowerBound a [upper] :: Range a -> UpperBound a bound :: Bound a -> Maybe a -- | Unbounded endpoints are always open. boundClosed :: Bound a -> Bool -- | Construct from parts: makeBound (boundClosed b) (bound b) == -- b makeBound :: Bool -> Maybe a -> Bound a -- | Empty ranges treated as Unbounded lowerBound :: Range a -> Bound a -- | Empty ranges treated as Unbounded upperBound :: Range a -> Bound a -- | Equivalent to boundClosed . lowerBound lowerClosed :: Range a -> Bool -- | Equivalent to boundClosed . upperBound upperClosed :: Range a -> Bool empty :: Range a isEmpty :: Ord a => Range a -> Bool full :: Range a isFull :: Range a -> Bool -- | Create a point range [x,x] point :: a -> Range a -- | Extract a point: getPoint (point x) == Just x getPoint :: Eq a => Range a -> Maybe a range :: Ord a => Bound a -> Bound a -> Range a normal :: Ord a => Maybe a -> Maybe a -> Range a bounded :: Ord a => a -> a -> Range a normalize :: Ord a => Range a -> Range a -- | normalize for discrete (non-continuous) range types, using the -- Enum instance normalize' :: (Ord a, Enum a) => Range a -> Range a -- | Contains range (@>) :: Ord a => Range a -> Range a -> Bool -- | Contains range (<@) :: Ord a => Range a -> Range a -> Bool -- | Contains element (@>.) :: Ord a => Range a -> a -> Bool overlaps :: Ord a => Range a -> Range a -> Bool intersect :: Ord a => Range a -> Range a -> Range a -- | Class indicating that the first PostgreSQL type is a range of the -- second. This implies PGParameter and PGColumn instances -- that will work for any type. class (PGType t, PGType (PGSubType t)) => PGRangeType t where type PGSubType t :: Symbol pgRangeElementType PGTypeProxy = PGTypeProxy where { type family PGSubType t :: Symbol; } pgRangeElementType :: PGRangeType t => PGTypeID t -> PGTypeID (PGSubType t) instance GHC.Classes.Ord a => GHC.Classes.Ord (Database.PostgreSQL.Typed.Range.Range a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Database.PostgreSQL.Typed.Range.Range a) instance GHC.Base.Functor Database.PostgreSQL.Typed.Range.UpperBound instance GHC.Classes.Eq a => GHC.Classes.Eq (Database.PostgreSQL.Typed.Range.UpperBound a) instance GHC.Base.Functor Database.PostgreSQL.Typed.Range.LowerBound instance GHC.Classes.Eq a => GHC.Classes.Eq (Database.PostgreSQL.Typed.Range.LowerBound a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Database.PostgreSQL.Typed.Range.Bound a) instance GHC.Base.Functor Database.PostgreSQL.Typed.Range.Bound instance GHC.Classes.Ord a => GHC.Classes.Ord (Database.PostgreSQL.Typed.Range.LowerBound a) instance GHC.Enum.Bounded a => GHC.Enum.Bounded (Database.PostgreSQL.Typed.Range.LowerBound a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Database.PostgreSQL.Typed.Range.UpperBound a) instance GHC.Enum.Bounded a => GHC.Enum.Bounded (Database.PostgreSQL.Typed.Range.UpperBound a) instance GHC.Base.Functor Database.PostgreSQL.Typed.Range.Range instance GHC.Show.Show a => GHC.Show.Show (Database.PostgreSQL.Typed.Range.Range a) instance GHC.Classes.Ord a => GHC.Base.Monoid (Database.PostgreSQL.Typed.Range.Range a) instance (Database.PostgreSQL.Typed.Range.PGRangeType t, Database.PostgreSQL.Typed.Types.PGParameter (Database.PostgreSQL.Typed.Range.PGSubType t) a) => Database.PostgreSQL.Typed.Types.PGParameter t (Database.PostgreSQL.Typed.Range.Range a) instance (Database.PostgreSQL.Typed.Range.PGRangeType t, Database.PostgreSQL.Typed.Types.PGColumn (Database.PostgreSQL.Typed.Range.PGSubType t) a) => Database.PostgreSQL.Typed.Types.PGColumn t (Database.PostgreSQL.Typed.Range.Range a) instance Database.PostgreSQL.Typed.Types.PGType "int4range" instance Database.PostgreSQL.Typed.Range.PGRangeType "int4range" instance Database.PostgreSQL.Typed.Types.PGType "numrange" instance Database.PostgreSQL.Typed.Range.PGRangeType "numrange" instance Database.PostgreSQL.Typed.Types.PGType "tsrange" instance Database.PostgreSQL.Typed.Range.PGRangeType "tsrange" instance Database.PostgreSQL.Typed.Types.PGType "tstzrange" instance Database.PostgreSQL.Typed.Range.PGRangeType "tstzrange" instance Database.PostgreSQL.Typed.Types.PGType "daterange" instance Database.PostgreSQL.Typed.Range.PGRangeType "daterange" instance Database.PostgreSQL.Typed.Types.PGType "int8range" instance Database.PostgreSQL.Typed.Range.PGRangeType "int8range" -- | Representaion of PostgreSQL's inet/cidr types using -- Network.Socket. We don't (yet) supply PGColumn (parsing) -- instances. module Database.PostgreSQL.Typed.Inet data PGInet PGInet :: !HostAddress -> !Word8 -> PGInet [pgInetAddr] :: PGInet -> !HostAddress [pgInetMask] :: PGInet -> !Word8 PGInet6 :: !HostAddress6 -> !Word8 -> PGInet [pgInetAddr6] :: PGInet -> !HostAddress6 [pgInetMask] :: PGInet -> !Word8 sockAddrPGInet :: SockAddr -> Maybe PGInet -- | Convert four bytes to network byte order, using unsafe casting. -- byteSwap32 would be better, but I couldn't find a good way to -- determine host byte order. bton32 :: (Word8, Word8, Word8, Word8) -> Word32 instance GHC.Classes.Eq Database.PostgreSQL.Typed.Inet.PGInet instance GHC.Show.Show Database.PostgreSQL.Typed.Inet.PGInet instance GHC.Read.Read Database.PostgreSQL.Typed.Inet.PGInet instance Database.PostgreSQL.Typed.Types.PGType "inet" instance Database.PostgreSQL.Typed.Types.PGType "cidr" instance Database.PostgreSQL.Typed.Types.PGParameter "inet" Database.PostgreSQL.Typed.Inet.PGInet instance Database.PostgreSQL.Typed.Types.PGParameter "cidr" Database.PostgreSQL.Typed.Inet.PGInet instance Database.PostgreSQL.Typed.Types.PGColumn "inet" Database.PostgreSQL.Typed.Inet.PGInet instance Database.PostgreSQL.Typed.Types.PGColumn "cidr" Database.PostgreSQL.Typed.Inet.PGInet -- | PostgreSQL error codes. module Database.PostgreSQL.Typed.ErrCodes -- | All known error code names by code. names :: Map ByteString String -- | SUCCESSFUL_COMPLETION: 00000 (Success) successful_completion :: ByteString -- | WARNING: 01000 (Warning) warning :: ByteString -- | WARNING_DYNAMIC_RESULT_SETS_RETURNED: 0100C (Warning) warning_dynamic_result_sets_returned :: ByteString -- | WARNING_IMPLICIT_ZERO_BIT_PADDING: 01008 (Warning) warning_implicit_zero_bit_padding :: ByteString -- | WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION: 01003 -- (Warning) warning_null_value_eliminated_in_set_function :: ByteString -- | WARNING_PRIVILEGE_NOT_GRANTED: 01007 (Warning) warning_privilege_not_granted :: ByteString -- | WARNING_PRIVILEGE_NOT_REVOKED: 01006 (Warning) warning_privilege_not_revoked :: ByteString -- | WARNING_STRING_DATA_RIGHT_TRUNCATION: 01004 (Warning) warning_string_data_right_truncation :: ByteString -- | WARNING_DEPRECATED_FEATURE: 01P01 (Warning) warning_deprecated_feature :: ByteString -- | NO_DATA: 02000 (Warning) no_data :: ByteString -- | NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED: 02001 (Warning) no_additional_dynamic_result_sets_returned :: ByteString -- | SQL_STATEMENT_NOT_YET_COMPLETE: 03000 (Error) sql_statement_not_yet_complete :: ByteString -- | CONNECTION_EXCEPTION: 08000 (Error) connection_exception :: ByteString -- | CONNECTION_DOES_NOT_EXIST: 08003 (Error) connection_does_not_exist :: ByteString -- | CONNECTION_FAILURE: 08006 (Error) connection_failure :: ByteString -- | SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION: 08001 (Error) sqlclient_unable_to_establish_sqlconnection :: ByteString -- | SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION: 08004 -- (Error) sqlserver_rejected_establishment_of_sqlconnection :: ByteString -- | TRANSACTION_RESOLUTION_UNKNOWN: 08007 (Error) transaction_resolution_unknown :: ByteString -- | PROTOCOL_VIOLATION: 08P01 (Error) protocol_violation :: ByteString -- | TRIGGERED_ACTION_EXCEPTION: 09000 (Error) triggered_action_exception :: ByteString -- | FEATURE_NOT_SUPPORTED: 0A000 (Error) feature_not_supported :: ByteString -- | INVALID_TRANSACTION_INITIATION: 0B000 (Error) invalid_transaction_initiation :: ByteString -- | LOCATOR_EXCEPTION: 0F000 (Error) locator_exception :: ByteString -- | L_E_INVALID_SPECIFICATION: 0F001 (Error) invalid_locator_specification :: ByteString -- | INVALID_GRANTOR: 0L000 (Error) invalid_grantor :: ByteString -- | INVALID_GRANT_OPERATION: 0LP01 (Error) invalid_grant_operation :: ByteString -- | INVALID_ROLE_SPECIFICATION: 0P000 (Error) invalid_role_specification :: ByteString -- | DIAGNOSTICS_EXCEPTION: 0Z000 (Error) diagnostics_exception :: ByteString -- | STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER: 0Z002 -- (Error) stacked_diagnostics_accessed_without_active_handler :: ByteString -- | CASE_NOT_FOUND: 20000 (Error) case_not_found :: ByteString -- | CARDINALITY_VIOLATION: 21000 (Error) cardinality_violation :: ByteString -- | DATA_EXCEPTION: 22000 (Error) data_exception :: ByteString -- | ARRAY_ELEMENT_ERROR: 2202E (Error) _ARRAY_ELEMENT_ERROR :: ByteString -- | ARRAY_SUBSCRIPT_ERROR: 2202E (Error) array_subscript_error :: ByteString -- | CHARACTER_NOT_IN_REPERTOIRE: 22021 (Error) character_not_in_repertoire :: ByteString -- | DATETIME_FIELD_OVERFLOW: 22008 (Error) datetime_field_overflow :: ByteString -- | DATETIME_VALUE_OUT_OF_RANGE: 22008 (Error) _DATETIME_VALUE_OUT_OF_RANGE :: ByteString -- | DIVISION_BY_ZERO: 22012 (Error) division_by_zero :: ByteString -- | ERROR_IN_ASSIGNMENT: 22005 (Error) error_in_assignment :: ByteString -- | ESCAPE_CHARACTER_CONFLICT: 2200B (Error) escape_character_conflict :: ByteString -- | INDICATOR_OVERFLOW: 22022 (Error) indicator_overflow :: ByteString -- | INTERVAL_FIELD_OVERFLOW: 22015 (Error) interval_field_overflow :: ByteString -- | INVALID_ARGUMENT_FOR_LOG: 2201E (Error) invalid_argument_for_logarithm :: ByteString -- | INVALID_ARGUMENT_FOR_NTILE: 22014 (Error) invalid_argument_for_ntile_function :: ByteString -- | INVALID_ARGUMENT_FOR_NTH_VALUE: 22016 (Error) invalid_argument_for_nth_value_function :: ByteString -- | INVALID_ARGUMENT_FOR_POWER_FUNCTION: 2201F (Error) invalid_argument_for_power_function :: ByteString -- | INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION: 2201G (Error) invalid_argument_for_width_bucket_function :: ByteString -- | INVALID_CHARACTER_VALUE_FOR_CAST: 22018 (Error) invalid_character_value_for_cast :: ByteString -- | INVALID_DATETIME_FORMAT: 22007 (Error) invalid_datetime_format :: ByteString -- | INVALID_ESCAPE_CHARACTER: 22019 (Error) invalid_escape_character :: ByteString -- | INVALID_ESCAPE_OCTET: 2200D (Error) invalid_escape_octet :: ByteString -- | INVALID_ESCAPE_SEQUENCE: 22025 (Error) invalid_escape_sequence :: ByteString -- | NONSTANDARD_USE_OF_ESCAPE_CHARACTER: 22P06 (Error) nonstandard_use_of_escape_character :: ByteString -- | INVALID_INDICATOR_PARAMETER_VALUE: 22010 (Error) invalid_indicator_parameter_value :: ByteString -- | INVALID_PARAMETER_VALUE: 22023 (Error) invalid_parameter_value :: ByteString -- | INVALID_REGULAR_EXPRESSION: 2201B (Error) invalid_regular_expression :: ByteString -- | INVALID_ROW_COUNT_IN_LIMIT_CLAUSE: 2201W (Error) invalid_row_count_in_limit_clause :: ByteString -- | INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE: 2201X (Error) invalid_row_count_in_result_offset_clause :: ByteString -- | INVALID_TABLESAMPLE_ARGUMENT: 2202H (Error) invalid_tablesample_argument :: ByteString -- | INVALID_TABLESAMPLE_REPEAT: 2202G (Error) invalid_tablesample_repeat :: ByteString -- | INVALID_TIME_ZONE_DISPLACEMENT_VALUE: 22009 (Error) invalid_time_zone_displacement_value :: ByteString -- | INVALID_USE_OF_ESCAPE_CHARACTER: 2200C (Error) invalid_use_of_escape_character :: ByteString -- | MOST_SPECIFIC_TYPE_MISMATCH: 2200G (Error) most_specific_type_mismatch :: ByteString -- | NULL_VALUE_NOT_ALLOWED: 22004 (Error) null_value_not_allowed :: ByteString -- | NULL_VALUE_NO_INDICATOR_PARAMETER: 22002 (Error) null_value_no_indicator_parameter :: ByteString -- | NUMERIC_VALUE_OUT_OF_RANGE: 22003 (Error) numeric_value_out_of_range :: ByteString -- | STRING_DATA_LENGTH_MISMATCH: 22026 (Error) string_data_length_mismatch :: ByteString -- | STRING_DATA_RIGHT_TRUNCATION: 22001 (Error) string_data_right_truncation :: ByteString -- | SUBSTRING_ERROR: 22011 (Error) substring_error :: ByteString -- | TRIM_ERROR: 22027 (Error) trim_error :: ByteString -- | UNTERMINATED_C_STRING: 22024 (Error) unterminated_c_string :: ByteString -- | ZERO_LENGTH_CHARACTER_STRING: 2200F (Error) zero_length_character_string :: ByteString -- | FLOATING_POINT_EXCEPTION: 22P01 (Error) floating_point_exception :: ByteString -- | INVALID_TEXT_REPRESENTATION: 22P02 (Error) invalid_text_representation :: ByteString -- | INVALID_BINARY_REPRESENTATION: 22P03 (Error) invalid_binary_representation :: ByteString -- | BAD_COPY_FILE_FORMAT: 22P04 (Error) bad_copy_file_format :: ByteString -- | UNTRANSLATABLE_CHARACTER: 22P05 (Error) untranslatable_character :: ByteString -- | NOT_AN_XML_DOCUMENT: 2200L (Error) not_an_xml_document :: ByteString -- | INVALID_XML_DOCUMENT: 2200M (Error) invalid_xml_document :: ByteString -- | INVALID_XML_CONTENT: 2200N (Error) invalid_xml_content :: ByteString -- | INVALID_XML_COMMENT: 2200S (Error) invalid_xml_comment :: ByteString -- | INVALID_XML_PROCESSING_INSTRUCTION: 2200T (Error) invalid_xml_processing_instruction :: ByteString -- | INTEGRITY_CONSTRAINT_VIOLATION: 23000 (Error) integrity_constraint_violation :: ByteString -- | RESTRICT_VIOLATION: 23001 (Error) restrict_violation :: ByteString -- | NOT_NULL_VIOLATION: 23502 (Error) not_null_violation :: ByteString -- | FOREIGN_KEY_VIOLATION: 23503 (Error) foreign_key_violation :: ByteString -- | UNIQUE_VIOLATION: 23505 (Error) unique_violation :: ByteString -- | CHECK_VIOLATION: 23514 (Error) check_violation :: ByteString -- | EXCLUSION_VIOLATION: 23P01 (Error) exclusion_violation :: ByteString -- | INVALID_CURSOR_STATE: 24000 (Error) invalid_cursor_state :: ByteString -- | INVALID_TRANSACTION_STATE: 25000 (Error) invalid_transaction_state :: ByteString -- | ACTIVE_SQL_TRANSACTION: 25001 (Error) active_sql_transaction :: ByteString -- | BRANCH_TRANSACTION_ALREADY_ACTIVE: 25002 (Error) branch_transaction_already_active :: ByteString -- | HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL: 25008 (Error) held_cursor_requires_same_isolation_level :: ByteString -- | INAPPROPRIATE_ACCESS_MODE_FOR_BRANCH_TRANSACTION: 25003 -- (Error) inappropriate_access_mode_for_branch_transaction :: ByteString -- | INAPPROPRIATE_ISOLATION_LEVEL_FOR_BRANCH_TRANSACTION: 25004 -- (Error) inappropriate_isolation_level_for_branch_transaction :: ByteString -- | NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION: 25005 -- (Error) no_active_sql_transaction_for_branch_transaction :: ByteString -- | READ_ONLY_SQL_TRANSACTION: 25006 (Error) read_only_sql_transaction :: ByteString -- | SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED: 25007 (Error) schema_and_data_statement_mixing_not_supported :: ByteString -- | NO_ACTIVE_SQL_TRANSACTION: 25P01 (Error) no_active_sql_transaction :: ByteString -- | IN_FAILED_SQL_TRANSACTION: 25P02 (Error) in_failed_sql_transaction :: ByteString -- | INVALID_SQL_STATEMENT_NAME: 26000 (Error) invalid_sql_statement_name :: ByteString -- | TRIGGERED_DATA_CHANGE_VIOLATION: 27000 (Error) triggered_data_change_violation :: ByteString -- | INVALID_AUTHORIZATION_SPECIFICATION: 28000 (Error) invalid_authorization_specification :: ByteString -- | INVALID_PASSWORD: 28P01 (Error) invalid_password :: ByteString -- | DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST: 2B000 (Error) dependent_privilege_descriptors_still_exist :: ByteString -- | DEPENDENT_OBJECTS_STILL_EXIST: 2BP01 (Error) dependent_objects_still_exist :: ByteString -- | INVALID_TRANSACTION_TERMINATION: 2D000 (Error) invalid_transaction_termination :: ByteString -- | SQL_ROUTINE_EXCEPTION: 2F000 (Error) sql_routine_exception :: ByteString -- | S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT: 2F005 (Error) s_r_e_function_executed_no_return_statement :: ByteString -- | S_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED: 2F002 (Error) s_r_e_modifying_sql_data_not_permitted :: ByteString -- | S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED: 2F003 (Error) s_r_e_prohibited_sql_statement_attempted :: ByteString -- | S_R_E_READING_SQL_DATA_NOT_PERMITTED: 2F004 (Error) s_r_e_reading_sql_data_not_permitted :: ByteString -- | INVALID_CURSOR_NAME: 34000 (Error) invalid_cursor_name :: ByteString -- | EXTERNAL_ROUTINE_EXCEPTION: 38000 (Error) external_routine_exception :: ByteString -- | E_R_E_CONTAINING_SQL_NOT_PERMITTED: 38001 (Error) e_r_e_containing_sql_not_permitted :: ByteString -- | E_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED: 38002 (Error) e_r_e_modifying_sql_data_not_permitted :: ByteString -- | E_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED: 38003 (Error) e_r_e_prohibited_sql_statement_attempted :: ByteString -- | E_R_E_READING_SQL_DATA_NOT_PERMITTED: 38004 (Error) e_r_e_reading_sql_data_not_permitted :: ByteString -- | EXTERNAL_ROUTINE_INVOCATION_EXCEPTION: 39000 (Error) external_routine_invocation_exception :: ByteString -- | E_R_I_E_INVALID_SQLSTATE_RETURNED: 39001 (Error) e_r_i_e_invalid_sqlstate_returned :: ByteString -- | E_R_I_E_NULL_VALUE_NOT_ALLOWED: 39004 (Error) e_r_i_e_null_value_not_allowed :: ByteString -- | E_R_I_E_TRIGGER_PROTOCOL_VIOLATED: 39P01 (Error) e_r_i_e_trigger_protocol_violated :: ByteString -- | E_R_I_E_SRF_PROTOCOL_VIOLATED: 39P02 (Error) e_r_i_e_srf_protocol_violated :: ByteString -- | E_R_I_E_EVENT_TRIGGER_PROTOCOL_VIOLATED: 39P03 (Error) e_r_i_e_event_trigger_protocol_violated :: ByteString -- | SAVEPOINT_EXCEPTION: 3B000 (Error) savepoint_exception :: ByteString -- | S_E_INVALID_SPECIFICATION: 3B001 (Error) invalid_savepoint_specification :: ByteString -- | INVALID_CATALOG_NAME: 3D000 (Error) invalid_catalog_name :: ByteString -- | INVALID_SCHEMA_NAME: 3F000 (Error) invalid_schema_name :: ByteString -- | TRANSACTION_ROLLBACK: 40000 (Error) transaction_rollback :: ByteString -- | T_R_INTEGRITY_CONSTRAINT_VIOLATION: 40002 (Error) transaction_integrity_constraint_violation :: ByteString -- | T_R_SERIALIZATION_FAILURE: 40001 (Error) serialization_failure :: ByteString -- | T_R_STATEMENT_COMPLETION_UNKNOWN: 40003 (Error) statement_completion_unknown :: ByteString -- | T_R_DEADLOCK_DETECTED: 40P01 (Error) deadlock_detected :: ByteString -- | SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION: 42000 (Error) syntax_error_or_access_rule_violation :: ByteString -- | SYNTAX_ERROR: 42601 (Error) syntax_error :: ByteString -- | INSUFFICIENT_PRIVILEGE: 42501 (Error) insufficient_privilege :: ByteString -- | CANNOT_COERCE: 42846 (Error) cannot_coerce :: ByteString -- | GROUPING_ERROR: 42803 (Error) grouping_error :: ByteString -- | WINDOWING_ERROR: 42P20 (Error) windowing_error :: ByteString -- | INVALID_RECURSION: 42P19 (Error) invalid_recursion :: ByteString -- | INVALID_FOREIGN_KEY: 42830 (Error) invalid_foreign_key :: ByteString -- | INVALID_NAME: 42602 (Error) invalid_name :: ByteString -- | NAME_TOO_LONG: 42622 (Error) name_too_long :: ByteString -- | RESERVED_NAME: 42939 (Error) reserved_name :: ByteString -- | DATATYPE_MISMATCH: 42804 (Error) datatype_mismatch :: ByteString -- | INDETERMINATE_DATATYPE: 42P18 (Error) indeterminate_datatype :: ByteString -- | COLLATION_MISMATCH: 42P21 (Error) collation_mismatch :: ByteString -- | INDETERMINATE_COLLATION: 42P22 (Error) indeterminate_collation :: ByteString -- | WRONG_OBJECT_TYPE: 42809 (Error) wrong_object_type :: ByteString -- | UNDEFINED_COLUMN: 42703 (Error) undefined_column :: ByteString -- | UNDEFINED_CURSOR: 34000 (Error) _UNDEFINED_CURSOR :: ByteString -- | UNDEFINED_DATABASE: 3D000 (Error) _UNDEFINED_DATABASE :: ByteString -- | UNDEFINED_FUNCTION: 42883 (Error) undefined_function :: ByteString -- | UNDEFINED_PSTATEMENT: 26000 (Error) _UNDEFINED_PSTATEMENT :: ByteString -- | UNDEFINED_SCHEMA: 3F000 (Error) _UNDEFINED_SCHEMA :: ByteString -- | UNDEFINED_TABLE: 42P01 (Error) undefined_table :: ByteString -- | UNDEFINED_PARAMETER: 42P02 (Error) undefined_parameter :: ByteString -- | UNDEFINED_OBJECT: 42704 (Error) undefined_object :: ByteString -- | DUPLICATE_COLUMN: 42701 (Error) duplicate_column :: ByteString -- | DUPLICATE_CURSOR: 42P03 (Error) duplicate_cursor :: ByteString -- | DUPLICATE_DATABASE: 42P04 (Error) duplicate_database :: ByteString -- | DUPLICATE_FUNCTION: 42723 (Error) duplicate_function :: ByteString -- | DUPLICATE_PSTATEMENT: 42P05 (Error) duplicate_prepared_statement :: ByteString -- | DUPLICATE_SCHEMA: 42P06 (Error) duplicate_schema :: ByteString -- | DUPLICATE_TABLE: 42P07 (Error) duplicate_table :: ByteString -- | DUPLICATE_ALIAS: 42712 (Error) duplicate_alias :: ByteString -- | DUPLICATE_OBJECT: 42710 (Error) duplicate_object :: ByteString -- | AMBIGUOUS_COLUMN: 42702 (Error) ambiguous_column :: ByteString -- | AMBIGUOUS_FUNCTION: 42725 (Error) ambiguous_function :: ByteString -- | AMBIGUOUS_PARAMETER: 42P08 (Error) ambiguous_parameter :: ByteString -- | AMBIGUOUS_ALIAS: 42P09 (Error) ambiguous_alias :: ByteString -- | INVALID_COLUMN_REFERENCE: 42P10 (Error) invalid_column_reference :: ByteString -- | INVALID_COLUMN_DEFINITION: 42611 (Error) invalid_column_definition :: ByteString -- | INVALID_CURSOR_DEFINITION: 42P11 (Error) invalid_cursor_definition :: ByteString -- | INVALID_DATABASE_DEFINITION: 42P12 (Error) invalid_database_definition :: ByteString -- | INVALID_FUNCTION_DEFINITION: 42P13 (Error) invalid_function_definition :: ByteString -- | INVALID_PSTATEMENT_DEFINITION: 42P14 (Error) invalid_prepared_statement_definition :: ByteString -- | INVALID_SCHEMA_DEFINITION: 42P15 (Error) invalid_schema_definition :: ByteString -- | INVALID_TABLE_DEFINITION: 42P16 (Error) invalid_table_definition :: ByteString -- | INVALID_OBJECT_DEFINITION: 42P17 (Error) invalid_object_definition :: ByteString -- | WITH_CHECK_OPTION_VIOLATION: 44000 (Error) with_check_option_violation :: ByteString -- | INSUFFICIENT_RESOURCES: 53000 (Error) insufficient_resources :: ByteString -- | DISK_FULL: 53100 (Error) disk_full :: ByteString -- | OUT_OF_MEMORY: 53200 (Error) out_of_memory :: ByteString -- | TOO_MANY_CONNECTIONS: 53300 (Error) too_many_connections :: ByteString -- | CONFIGURATION_LIMIT_EXCEEDED: 53400 (Error) configuration_limit_exceeded :: ByteString -- | PROGRAM_LIMIT_EXCEEDED: 54000 (Error) program_limit_exceeded :: ByteString -- | STATEMENT_TOO_COMPLEX: 54001 (Error) statement_too_complex :: ByteString -- | TOO_MANY_COLUMNS: 54011 (Error) too_many_columns :: ByteString -- | TOO_MANY_ARGUMENTS: 54023 (Error) too_many_arguments :: ByteString -- | OBJECT_NOT_IN_PREREQUISITE_STATE: 55000 (Error) object_not_in_prerequisite_state :: ByteString -- | OBJECT_IN_USE: 55006 (Error) object_in_use :: ByteString -- | CANT_CHANGE_RUNTIME_PARAM: 55P02 (Error) cant_change_runtime_param :: ByteString -- | LOCK_NOT_AVAILABLE: 55P03 (Error) lock_not_available :: ByteString -- | OPERATOR_INTERVENTION: 57000 (Error) operator_intervention :: ByteString -- | QUERY_CANCELED: 57014 (Error) query_canceled :: ByteString -- | ADMIN_SHUTDOWN: 57P01 (Error) admin_shutdown :: ByteString -- | CRASH_SHUTDOWN: 57P02 (Error) crash_shutdown :: ByteString -- | CANNOT_CONNECT_NOW: 57P03 (Error) cannot_connect_now :: ByteString -- | DATABASE_DROPPED: 57P04 (Error) database_dropped :: ByteString -- | SYSTEM_ERROR: 58000 (Error) system_error :: ByteString -- | IO_ERROR: 58030 (Error) io_error :: ByteString -- | UNDEFINED_FILE: 58P01 (Error) undefined_file :: ByteString -- | DUPLICATE_FILE: 58P02 (Error) duplicate_file :: ByteString -- | CONFIG_FILE_ERROR: F0000 (Error) config_file_error :: ByteString -- | LOCK_FILE_EXISTS: F0001 (Error) lock_file_exists :: ByteString -- | FDW_ERROR: HV000 (Error) fdw_error :: ByteString -- | FDW_COLUMN_NAME_NOT_FOUND: HV005 (Error) fdw_column_name_not_found :: ByteString -- | FDW_DYNAMIC_PARAMETER_VALUE_NEEDED: HV002 (Error) fdw_dynamic_parameter_value_needed :: ByteString -- | FDW_FUNCTION_SEQUENCE_ERROR: HV010 (Error) fdw_function_sequence_error :: ByteString -- | FDW_INCONSISTENT_DESCRIPTOR_INFORMATION: HV021 (Error) fdw_inconsistent_descriptor_information :: ByteString -- | FDW_INVALID_ATTRIBUTE_VALUE: HV024 (Error) fdw_invalid_attribute_value :: ByteString -- | FDW_INVALID_COLUMN_NAME: HV007 (Error) fdw_invalid_column_name :: ByteString -- | FDW_INVALID_COLUMN_NUMBER: HV008 (Error) fdw_invalid_column_number :: ByteString -- | FDW_INVALID_DATA_TYPE: HV004 (Error) fdw_invalid_data_type :: ByteString -- | FDW_INVALID_DATA_TYPE_DESCRIPTORS: HV006 (Error) fdw_invalid_data_type_descriptors :: ByteString -- | FDW_INVALID_DESCRIPTOR_FIELD_IDENTIFIER: HV091 (Error) fdw_invalid_descriptor_field_identifier :: ByteString -- | FDW_INVALID_HANDLE: HV00B (Error) fdw_invalid_handle :: ByteString -- | FDW_INVALID_OPTION_INDEX: HV00C (Error) fdw_invalid_option_index :: ByteString -- | FDW_INVALID_OPTION_NAME: HV00D (Error) fdw_invalid_option_name :: ByteString -- | FDW_INVALID_STRING_LENGTH_OR_BUFFER_LENGTH: HV090 (Error) fdw_invalid_string_length_or_buffer_length :: ByteString -- | FDW_INVALID_STRING_FORMAT: HV00A (Error) fdw_invalid_string_format :: ByteString -- | FDW_INVALID_USE_OF_NULL_POINTER: HV009 (Error) fdw_invalid_use_of_null_pointer :: ByteString -- | FDW_TOO_MANY_HANDLES: HV014 (Error) fdw_too_many_handles :: ByteString -- | FDW_OUT_OF_MEMORY: HV001 (Error) fdw_out_of_memory :: ByteString -- | FDW_NO_SCHEMAS: HV00P (Error) fdw_no_schemas :: ByteString -- | FDW_OPTION_NAME_NOT_FOUND: HV00J (Error) fdw_option_name_not_found :: ByteString -- | FDW_REPLY_HANDLE: HV00K (Error) fdw_reply_handle :: ByteString -- | FDW_SCHEMA_NOT_FOUND: HV00Q (Error) fdw_schema_not_found :: ByteString -- | FDW_TABLE_NOT_FOUND: HV00R (Error) fdw_table_not_found :: ByteString -- | FDW_UNABLE_TO_CREATE_EXECUTION: HV00L (Error) fdw_unable_to_create_execution :: ByteString -- | FDW_UNABLE_TO_CREATE_REPLY: HV00M (Error) fdw_unable_to_create_reply :: ByteString -- | FDW_UNABLE_TO_ESTABLISH_CONNECTION: HV00N (Error) fdw_unable_to_establish_connection :: ByteString -- | PLPGSQL_ERROR: P0000 (Error) plpgsql_error :: ByteString -- | RAISE_EXCEPTION: P0001 (Error) raise_exception :: ByteString -- | NO_DATA_FOUND: P0002 (Error) no_data_found :: ByteString -- | TOO_MANY_ROWS: P0003 (Error) too_many_rows :: ByteString -- | ASSERT_FAILURE: P0004 (Error) assert_failure :: ByteString -- | INTERNAL_ERROR: XX000 (Error) internal_error :: ByteString -- | DATA_CORRUPTED: XX001 (Error) data_corrupted :: ByteString -- | INDEX_CORRUPTED: XX002 (Error) index_corrupted :: ByteString -- | Automatic (dynamic) marshalling of PostgreSQL values based on Haskell -- types (not SQL statements). This is intended for direct construction -- of queries and query data, bypassing the normal SQL type inference. module Database.PostgreSQL.Typed.Dynamic -- | Represents canonical/default PostgreSQL representation for various -- Haskell types, allowing convenient type-driven marshalling. class (PGParameter (PGRepType a) a, PGColumn (PGRepType a) a) => PGRep a where type PGRepType a :: Symbol where { type family PGRepType a :: Symbol; } pgTypeOf :: a -> PGTypeID (PGRepType a) pgTypeOfProxy :: Proxy a -> PGTypeID (PGRepType a) -- | Encode a value using pgEncodeValue. pgEncodeRep :: PGRep a => a -> PGValue -- | Decode a value using pgDecodeValue. pgDecodeRep :: forall a. PGRep a => PGValue -> a -- | Produce a literal value for interpolation in a SQL statement using -- pgLiteral. Using pgSafeLiteral is usually safer as it -- includes type cast. pgLiteralRep :: PGRep a => a -> ByteString -- | Produce a raw SQL literal from a value. Using pgSafeLiteral is -- usually safer when interpolating in a SQL statement. pgLiteralString :: PGRep a => a -> String -- | Produce a safely type-cast literal value for interpolation in a SQL -- statement, e.g., "'123'::integer". pgSafeLiteral :: PGRep a => a -> ByteString -- | Identical to unpack . pgSafeLiteral but more -- efficient. pgSafeLiteralString :: PGRep a => a -> String -- | Create an expression that literally substitutes each instance of -- ${expr} for the result of pgSafeLiteral expr, -- producing a lazy ByteString. This lets you do safe, type-driven -- literal substitution into SQL fragments without needing a full query, -- bypassing placeholder inference and any prepared queries, for example -- when using pgSimpleQuery or pgSimpleQueries_. Unlike -- most other TH functions, this does not require any database -- connection. pgSubstituteLiterals :: String -> ExpQ instance Database.PostgreSQL.Typed.Dynamic.PGRep a => Database.PostgreSQL.Typed.Dynamic.PGRep (GHC.Base.Maybe a) instance Database.PostgreSQL.Typed.Dynamic.PGRep () instance Database.PostgreSQL.Typed.Dynamic.PGRep GHC.Types.Bool instance Database.PostgreSQL.Typed.Dynamic.PGRep Database.PostgreSQL.Typed.Types.OID instance Database.PostgreSQL.Typed.Dynamic.PGRep GHC.Int.Int16 instance Database.PostgreSQL.Typed.Dynamic.PGRep GHC.Int.Int32 instance Database.PostgreSQL.Typed.Dynamic.PGRep GHC.Int.Int64 instance Database.PostgreSQL.Typed.Dynamic.PGRep GHC.Types.Float instance Database.PostgreSQL.Typed.Dynamic.PGRep GHC.Types.Double instance Database.PostgreSQL.Typed.Dynamic.PGRep GHC.Types.Char instance Database.PostgreSQL.Typed.Dynamic.PGRep GHC.Base.String instance Database.PostgreSQL.Typed.Dynamic.PGRep Data.ByteString.Internal.ByteString instance Database.PostgreSQL.Typed.Dynamic.PGRep Database.PostgreSQL.Typed.Types.PGName instance Database.PostgreSQL.Typed.Dynamic.PGRep Data.Text.Internal.Text instance Database.PostgreSQL.Typed.Dynamic.PGRep Data.Time.Calendar.Days.Day instance Database.PostgreSQL.Typed.Dynamic.PGRep Data.Time.LocalTime.TimeOfDay.TimeOfDay instance Database.PostgreSQL.Typed.Dynamic.PGRep (Data.Time.LocalTime.TimeOfDay.TimeOfDay, Data.Time.LocalTime.TimeZone.TimeZone) instance Database.PostgreSQL.Typed.Dynamic.PGRep Data.Time.LocalTime.LocalTime.LocalTime instance Database.PostgreSQL.Typed.Dynamic.PGRep Data.Time.Clock.UTC.UTCTime instance Database.PostgreSQL.Typed.Dynamic.PGRep Data.Time.Clock.Scale.DiffTime instance Database.PostgreSQL.Typed.Dynamic.PGRep GHC.Real.Rational instance Database.PostgreSQL.Typed.Dynamic.PGRep Data.Scientific.Scientific instance Database.PostgreSQL.Typed.Dynamic.PGRep Data.UUID.Types.Internal.UUID instance Database.PostgreSQL.Typed.Dynamic.PGRep Data.Aeson.Types.Internal.Value -- | The Protocol module allows for direct, low-level communication with a -- PostgreSQL server over TCP/IP. You probably don't want to use this -- module directly. module Database.PostgreSQL.Typed.Protocol -- | Information for how to connect to a database, to be passed to -- pgConnect. data PGDatabase PGDatabase :: HostName -> PortID -> ByteString -> ByteString -> [(ByteString, ByteString)] -> Bool -> (MessageFields -> IO ()) -> PGDatabase -- | The hostname (ignored if pgDBPort is UnixSocket) [pgDBHost] :: PGDatabase -> HostName -- | The port, likely either PortNumber 5432 or UnixSocket -- "/tmp/.s.PGSQL.5432" [pgDBPort] :: PGDatabase -> PortID -- | The name of the database [pgDBName] :: PGDatabase -> ByteString [pgDBUser, pgDBPass] :: PGDatabase -> ByteString -- | Extra parameters to set for the connection (e.g., (TimeZone, -- UTC)) [pgDBParams] :: PGDatabase -> [(ByteString, ByteString)] -- | Log all low-level server messages [pgDBDebug] :: PGDatabase -> Bool -- | How to log server notice messages (e.g., print . PGError) [pgDBLogMessage] :: PGDatabase -> MessageFields -> IO () -- | A database connection with sane defaults: localhost:5432:postgres defaultPGDatabase :: PGDatabase -- | An established connection to the PostgreSQL server. These objects are -- not thread-safe and must only be used for a single request at a time. data PGConnection -- | PGException is thrown upon encountering an ErrorResponse with -- severity of ERROR, FATAL, or PANIC. It holds the message of the error. data PGError PGError :: MessageFields -> PGError [pgErrorFields] :: PGError -> MessageFields -- | Message SQLState code. See -- http://www.postgresql.org/docs/current/static/errcodes-appendix.html. pgErrorCode :: PGError -> ByteString -- | The database information for this connection. pgConnectionDatabase :: PGConnection -> PGDatabase -- | The type environment for this connection. pgTypeEnv :: PGConnection -> PGTypeEnv -- | Retrieve the "server_version" parameter from the connection, if any. pgServerVersion :: PGConnection -> Maybe ByteString -- | Connect to a PostgreSQL server. pgConnect :: PGDatabase -> IO PGConnection -- | Disconnect cleanly from the PostgreSQL server. pgDisconnect :: PGConnection -> IO () -- | Possibly re-open a connection to a different database, either reusing -- the connection if the given database is already connected or closing -- it and opening a new one. Regardless, the input connection must not be -- used afterwards. pgReconnect :: PGConnection -> PGDatabase -> IO PGConnection -- | Describe a SQL statement/query. A statement description consists of 0 -- or more parameter descriptions (a PostgreSQL type) and zero or more -- result field descriptions (for queries) (consist of the name of the -- field, the type of the field, and a nullability indicator). pgDescribe :: PGConnection -> ByteString -> [OID] -> Bool -> IO ([OID], [(ByteString, OID, Bool)]) -- | A simple query is one which requires sending only a single -- SimpleQuery message to the PostgreSQL server. The query is sent -- as a single string; you cannot bind parameters. Note that queries can -- return 0 results (an empty list). pgSimpleQuery :: PGConnection -> ByteString -> IO (Int, [PGValues]) -- | A simple query which may contain multiple queries (separated by -- semi-colons) whose results are all ignored. This function can also be -- used for "SET" parameter queries if necessary, but it's safer better -- to use pgDBParams. pgSimpleQueries_ :: PGConnection -> ByteString -> IO () -- | Prepare a statement, bind it, and execute it. If the given statement -- has already been prepared (and not yet closed) on this connection, it -- will be re-used. pgPreparedQuery :: PGConnection -> ByteString -> [OID] -> PGValues -> [Bool] -> IO (Int, [PGValues]) -- | Like pgPreparedQuery but requests results lazily in chunks of -- the given size. Does not use a named portal, so other requests may not -- intervene. pgPreparedLazyQuery :: PGConnection -> ByteString -> [OID] -> PGValues -> [Bool] -> Word32 -> IO [PGValues] -- | Close a previously prepared query (if necessary). pgCloseStatement :: PGConnection -> ByteString -> [OID] -> IO () -- | Begin a new transaction. If there is already a transaction in progress -- (created with pgBegin or pgTransaction) instead creates -- a savepoint. pgBegin :: PGConnection -> IO () -- | Commit the most recent pgBegin. pgCommit :: PGConnection -> IO () -- | Rollback to the most recent pgBegin. pgRollback :: PGConnection -> IO () -- | Commit all active pgBegins. pgCommitAll :: PGConnection -> IO () -- | Rollback all active pgBegins. pgRollbackAll :: PGConnection -> IO () -- | Wrap a computation in a pgBegin, pgCommit block, or -- pgRollback on exception. pgTransaction :: PGConnection -> IO a -> IO a -- | Disconnect cleanly from the PostgreSQL server, but only if it's still -- connected. pgDisconnectOnce :: PGConnection -> IO () -- | Prepare, bind, execute, and close a single (unnamed) query, and return -- the number of rows affected, or Nothing if there are (ignored) result -- rows. pgRun :: PGConnection -> ByteString -> [OID] -> PGValues -> IO (Maybe Integer) data PGPreparedStatement -- | Prepare a single query and return its handle. pgPrepare :: PGConnection -> ByteString -> [OID] -> IO PGPreparedStatement -- | Close a previously prepared query. pgClose :: PGConnection -> PGPreparedStatement -> IO () data PGColDescription PGColDescription :: ByteString -> !OID -> !Int16 -> !OID -> !Int16 -> !Int32 -> !Bool -> PGColDescription [colName] :: PGColDescription -> ByteString [colTable] :: PGColDescription -> !OID [colNumber] :: PGColDescription -> !Int16 [colType] :: PGColDescription -> !OID [colSize] :: PGColDescription -> !Int16 [colModifier] :: PGColDescription -> !Int32 [colBinary] :: PGColDescription -> !Bool type PGRowDescription = [PGColDescription] -- | Bind a prepared statement, and return the row description. After -- pgBind, you must either call pgFetch until it completes -- (returns (_, Just _)) or pgFinish before -- calling pgBind again on the same prepared statement. pgBind :: PGConnection -> PGPreparedStatement -> PGValues -> IO PGRowDescription -- | Fetch a single row from an executed prepared statement, returning the -- next N result rows (if any) and number of affected rows when complete. pgFetch :: PGConnection -> PGPreparedStatement -> Word32 -> IO ([PGValues], Maybe Integer) instance GHC.Show.Show Database.PostgreSQL.Typed.Protocol.PGBackendMessage instance GHC.Show.Show Database.PostgreSQL.Typed.Protocol.PGFrontendMessage instance GHC.Show.Show Database.PostgreSQL.Typed.Protocol.PGColDescription instance GHC.Show.Show Database.PostgreSQL.Typed.Protocol.PGPreparedStatement instance GHC.Classes.Eq Database.PostgreSQL.Typed.Protocol.PGPreparedStatement instance GHC.Classes.Eq Database.PostgreSQL.Typed.Protocol.PGState instance GHC.Show.Show Database.PostgreSQL.Typed.Protocol.PGState instance GHC.Classes.Eq Database.PostgreSQL.Typed.Protocol.PGDatabase instance GHC.Show.Show Database.PostgreSQL.Typed.Protocol.PGError instance GHC.Exception.Exception Database.PostgreSQL.Typed.Protocol.PGError -- | Use postgresql-typed as a backend for HDBC. module Database.PostgreSQL.Typed.HDBC -- | A wrapped PGConnection. This differs from a bare -- PGConnection in a few ways: -- --
    --
  1. It always has exactly one active transaction (with -- pgBegin)
  2. --
  3. It automatically disconnects on GC
  4. --
  5. It provides a mutex around the underlying PGConnection for -- thread-safety
  6. --
data Connection -- | Connect to a database for HDBC use (equivalent to pgConnect and -- pgBegin). connect :: PGDatabase -> IO Connection -- | Convert an existing PGConnection to an HDBC-compatible -- Connection. The caveats under connectionPG apply if you -- plan to continue using the original PGConnection. fromPGConnection :: PGConnection -> IO Connection -- | Use the underlying PGConnection directly. You must be careful -- to ensure that the first invariant is preserved: you should not call -- pgBegin, pgCommit, or pgRollback on it. All other -- operations should be safe. withPGConnection :: Connection -> (PGConnection -> IO a) -> IO a -- | Reload the table of all types from the database. This may be needed if -- you make structural changes to the database. reloadTypes :: Connection -> IO Connection -- | Number of rows to fetch (and cache) with execute and each time -- fetchRow requires more rows. A higher value will result in -- fewer round-trips to the database but potentially more wasted data. -- Defaults to 1. 0 means fetch all rows. connectionFetchSize :: Connection -> Word32 -- | Change the connectionFetchSize for new Statements -- created with prepare. Ideally this could be set with each call -- to execute and fetchRow, but the HDBC interface provides -- no way to do this. setFetchSize :: Word32 -> Connection -> Connection instance Database.HDBC.Types.IConnection Database.PostgreSQL.Typed.HDBC.Connection -- | Support functions for compile-time PostgreSQL connection and state -- management. You can use these to build your own Template Haskell -- functions using the PostgreSQL connection. module Database.PostgreSQL.Typed.TH -- | Generate a PGDatabase based on the environment variables: -- TPG_HOST (localhost); TPG_SOCK or TPG_PORT -- (5432); TPG_DB or user; TPG_USER or USER -- (postgres); TPG_PASS () getTPGDatabase :: IO PGDatabase -- | Run an action using the Template Haskell state. withTPGTypeConnection :: (PGTypeConnection -> IO a) -> IO a -- | Run an action using the Template Haskell PostgreSQL connection. withTPGConnection :: (PGConnection -> IO a) -> IO a -- | Specify an alternative database to use during compilation. This lets -- you override the default connection parameters that are based on TPG -- environment variables. This should be called as a top-level -- declaration and produces no code. It uses pgReconnect so is -- safe to call multiple times with the same database. useTPGDatabase :: PGDatabase -> DecsQ -- | Force reloading of all types from the database. This may be needed if -- you make structural changes to the database during compile-time. reloadTPGTypes :: DecsQ data TPGValueInfo TPGValueInfo :: ByteString -> !OID -> PGName -> Bool -> TPGValueInfo [tpgValueName] :: TPGValueInfo -> ByteString [tpgValueTypeOID] :: TPGValueInfo -> !OID [tpgValueType] :: TPGValueInfo -> PGName [tpgValueNullable] :: TPGValueInfo -> Bool -- | A type-aware wrapper to pgDescribe tpgDescribe :: ByteString -> [String] -> Bool -> IO ([TPGValueInfo], [TPGValueInfo]) -- | TH expression to encode a PGParameter value to a Maybe -- ByteString. tpgTypeEncoder :: Bool -> TPGValueInfo -> Name -> Exp -- | TH expression to decode a Maybe ByteString to a -- (Maybe) PGColumn value. tpgTypeDecoder :: Bool -> TPGValueInfo -> Name -> Exp -- | TH expression calling pgBinaryColumn. tpgTypeBinary :: TPGValueInfo -> Name -> Exp -- | Support for PostgreSQL enums. module Database.PostgreSQL.Typed.Enum -- | A type based on a PostgreSQL enum. Automatically instantiated by -- dataPGEnum. class (Eq a, Ord a, Enum a, Bounded a, PGRep a) => PGEnum a where pgEnumName a = fromJust $ lookup a pgEnumValues pgEnumValue n = lookup n $ map swap pgEnumValues pgEnumValues = map (id &&& pgEnumName) $ enumFromTo minBound maxBound -- | The database name of a value. pgEnumName :: PGEnum a => a -> PGName -- | Lookup a value matching the given database name. pgEnumValue :: PGEnum a => PGName -> Maybe a -- | List of all the values in the enum along with their database names. pgEnumValues :: PGEnum a => [(a, PGName)] -- | Create a new enum type corresponding to the given PostgreSQL enum -- type. For example, if you have CREATE TYPE foo AS ENUM ('abc', -- 'DEF'), then dataPGEnum "Foo" "foo" ("Foo_"++) will be -- equivalent to: -- --
--   data Foo = Foo_abc | Foo_DEF deriving (Eq, Ord, Enum, Bounded, Typeable)
--   instance PGType "foo" where PGVal "foo" = Foo
--   instance PGParameter "foo" Foo where ...
--   instance PGColumn "foo" Foo where ...
--   instance PGRep Foo where PGRepType = "foo"
--   instance PGEnum Foo where pgEnumValues = [(Foo_abc, "abc"), (Foo_DEF, "DEF")]
--   
-- -- Requires language extensions: TemplateHaskell, FlexibleInstances, -- MultiParamTypeClasses, DeriveDataTypeable, DataKinds, TypeFamilies dataPGEnum :: String -> PGName -> (String -> String) -> DecsQ module Database.PostgreSQL.Typed.Query class PGQuery q a | q -> a -- | Execute a query and return the number of rows affected (or -1 if not -- known) and a list of results. pgRunQuery :: PGQuery q a => PGConnection -> q -> IO (Int, [a]) -- | Change the raw SQL query stored within this query. This is unsafe -- because the query has already been type-checked, so any change must -- not change the number or type of results or placeholders (so adding -- additional static WHERE or ORDER BY clauses is generally safe). This -- is useful in cases where you need to construct some part of the query -- dynamically, but still want to infer the result types. If you want to -- add dynamic values to the query, it's best to use -- pgSafeLiteral. For example: -- --
--   [pgSQL|SELECT a FROM t|] `unsafeModifyQuery` (<> (" WHERE a = " <> pgSafeLiteral x))
--   
unsafeModifyQuery :: PGQuery q a => q -> (ByteString -> ByteString) -> q -- | A simple one-shot query that simply substitutes literal -- representations of parameters for placeholders. type PGSimpleQuery = QueryParser SimpleQuery -- | A prepared query that automatically is prepared in the database the -- first time it is run and bound with new parameters each subsequent -- time. type PGPreparedQuery = QueryParser PreparedQuery -- | Make a simple query directly from a query string, with no type -- inference rawPGSimpleQuery :: ByteString -> PGSimpleQuery PGValues -- | Make a prepared query directly from a query string and bind -- parameters, with no type inference rawPGPreparedQuery :: ByteString -> PGValues -> PGPreparedQuery PGValues -- | Flags affecting how and what type of query to build with -- makePGQuery. data QueryFlags QueryFlags :: Bool -> Maybe Bool -> Maybe [String] -> QueryFlags -- | Create a query -- otherwise just call pgSubstituteLiterals to -- create a string (SQL fragment). [flagQuery] :: QueryFlags -> Bool -- | Disable nullability inference, treating all values as nullable (if -- True) or not (if False). [flagNullable] :: QueryFlags -> Maybe Bool -- | Prepare and re-use query, binding parameters of the given types -- (inferring the rest, like PREPARE). [flagPrepare] :: QueryFlags -> Maybe [String] -- | QueryFlags for a default (simple) query. simpleQueryFlags :: QueryFlags -- | Parse flags off the beginning of a query string, returning the flags -- and the remaining string. parseQueryFlags :: String -> (QueryFlags, String) -- | Construct a PGQuery from a SQL string. This is the underlying -- template function for pgSQL which you can use in largely the -- same way when you want to construct query strings from other -- variables. For example: -- --
--   selectQuery = "SELECT * FROM"
--   selectFoo = $(makePGQuery simpleQueryFlags (selectQuery ++ " foo"))
--   
-- -- The only caveat is that variables or functions like -- selectQuery need to be defined in a different module (due to -- TH stage restrictions). makePGQuery :: QueryFlags -> String -> ExpQ -- | A quasi-quoter for PGSQL queries. -- -- Used in expression context, it may contain any SQL statement -- [pgSQL|SELECT ...|]. The statement may contain -- PostgreSQL-style placeholders ($1, $2, ...) or -- in-line placeholders (${1+1}) containing any valid Haskell -- expression (except {}). It will be replaced by a -- PGQuery object that can be used to perform the SQL statement. -- If there are more $N placeholders than expressions, it will -- instead be a function accepting the additional parameters and -- returning a PGQuery. -- -- Ideally, this mimics postgres' SQL parsing, so that placeholders and -- expressions will only be expanded when they are in valid positions -- (i.e., not inside quoted strings). Since ${ is not valid SQL -- otherwise, there should be no need to escape it. -- -- The statement may start with one of more special flags affecting the -- interpretation: -- -- -- -- pgSQL can also be used at the top-level to execute SQL -- statements at compile-time (without any parameters and ignoring -- results). Here the query can only be prefixed with ! to make -- errors non-fatal. -- -- If you want to construct queries out of string variables rather than -- quasi-quoted strings, you can use the lower-level makePGQuery -- instead. pgSQL :: QuasiQuoter -- | Execute a query that does not return results. Return the number of -- rows affected (or -1 if not known). pgExecute :: PGQuery q () => PGConnection -> q -> IO Int -- | Run a query and return a list of row results. pgQuery :: PGQuery q a => PGConnection -> q -> IO [a] -- | Run a prepared query in lazy mode, where only chunk size rows are -- requested at a time. If you eventually retrieve all the rows this way, -- it will be far less efficient than using pgQuery, since every -- chunk requires an additional round-trip. Although you may safely stop -- consuming rows early, currently you may not interleave any other -- database operation while reading rows. (This limitation could -- theoretically be lifted if required.) pgLazyQuery :: PGConnection -> PGPreparedQuery a -> Word32 -> IO [a] instance GHC.Show.Show Database.PostgreSQL.Typed.Query.PreparedQuery instance GHC.Show.Show Database.PostgreSQL.Typed.Query.SimpleQuery instance Database.PostgreSQL.Typed.Query.PGQuery Data.ByteString.Internal.ByteString Database.PostgreSQL.Typed.Types.PGValues instance Database.PostgreSQL.Typed.Query.PGQuery Database.PostgreSQL.Typed.Query.SimpleQuery Database.PostgreSQL.Typed.Types.PGValues instance Database.PostgreSQL.Typed.Query.PGRawQuery Database.PostgreSQL.Typed.Query.SimpleQuery instance Database.PostgreSQL.Typed.Query.PGQuery Database.PostgreSQL.Typed.Query.PreparedQuery Database.PostgreSQL.Typed.Types.PGValues instance Database.PostgreSQL.Typed.Query.PGRawQuery Database.PostgreSQL.Typed.Query.PreparedQuery instance Database.PostgreSQL.Typed.Query.PGRawQuery q => Database.PostgreSQL.Typed.Query.PGQuery (Database.PostgreSQL.Typed.Query.QueryParser q a) a instance GHC.Base.Functor (Database.PostgreSQL.Typed.Query.QueryParser q) instance GHC.Show.Show q => GHC.Show.Show (Database.PostgreSQL.Typed.Query.QueryParser q a) instance Data.String.IsString (Database.PostgreSQL.Typed.Query.PGSimpleQuery Database.PostgreSQL.Typed.Types.PGValues) instance Data.String.IsString (Database.PostgreSQL.Typed.Query.PGSimpleQuery ()) -- | This module exposes the high-level Template Haskell interface for -- querying and manipulating the PostgreSQL server. -- -- All SQL string arguments support expression interpolation. Just -- enclose your expression in {} in the SQL string. -- -- Note that transactions are messy and untested. Attempt to use them at -- your own risk. module Database.PostgreSQL.Typed.TemplatePG -- |
--   queryTuples :: String -> (PGConnection -> IO [(column1, column2, ...)])
--   
-- -- Query a PostgreSQL server and return the results as a list of tuples. -- -- Example (where h is a handle from pgConnect): -- --
--   $(queryTuples "SELECT usesysid, usename FROM pg_user") h :: IO [(Maybe String, Maybe Integer)]
--   
queryTuples :: String -> ExpQ -- |
--   queryTuple :: String -> (PGConnection -> IO (Maybe (column1, column2, ...)))
--   
-- -- Convenience function to query a PostgreSQL server and return the first -- result as a tuple. If the query produces no results, return -- Nothing. -- -- Example (where h is a handle from pgConnect): -- --
--   let sysid = 10::Integer;
--   $(queryTuple "SELECT usesysid, usename FROM pg_user WHERE usesysid = {sysid}") h :: IO (Maybe (Maybe String, Maybe Integer))
--   
queryTuple :: String -> ExpQ -- |
--   execute :: String -> (PGConnection -> IO ())
--   
-- -- Convenience function to execute a statement on the PostgreSQL server. -- -- Example (where h is a handle from pgConnect): execute :: String -> ExpQ -- | Ignore duplicate key errors. This is also limited to the IO -- Monad. insertIgnore :: IO () -> IO () -- | Run a sequence of IO actions (presumably SQL statements) wrapped in a -- transaction. Unfortunately you're restricted to using this in the -- IO Monad for now due to the use of onException. I'm -- debating adding a MonadPeelIO version. withTransaction :: PGConnection -> IO a -> IO a -- | Roll back a transaction. rollback :: PGConnection -> IO () type PGException = PGError pgConnect :: HostName -> PortID -> ByteString -> ByteString -> ByteString -> IO PGConnection -- | Disconnect cleanly from the PostgreSQL server. pgDisconnect :: PGConnection -> IO () -- | Automatically create data types based on tables and other relations. module Database.PostgreSQL.Typed.Relation -- | Create a new data type corresponding to the given PostgreSQL relation. -- For example, if you have CREATE TABLE foo (abc integer NOT NULL, -- def text), then dataPGRelation "Foo" "foo" ("foo_"++) -- will be equivalent to: -- --
--   data Foo = Foo{ foo_abc :: PGVal "integer", foo_def :: Maybe (PGVal "text") }
--   instance PGType "foo" where PGVal "foo" = Foo
--   instance PGParameter "foo" Foo where ...
--   instance PGColumn "foo" Foo where ...
--   instance PGColumn "foo" (Maybe Foo) where ... -- to handle NULL in not null columns
--   instance PGRep Foo where PGRepType = "foo"
--   instance PGRecordType "foo"
--   instance PGRelation Foo where pgColumnNames _ = ["abc", "def"]
--   uncurryFoo :: (PGVal "integer", Maybe (PGVal "text")) -> Foo
--   
-- -- (Note that PGVal "integer" = Int32 and PGVal "text" = -- Text by default.) This provides instances for marshalling the -- corresponding composite/record types, e.g., using SELECT -- foo.*::foo FROM foo. If you want any derived instances, you'll -- need to create them yourself using StandaloneDeriving. -- -- Requires language extensions: TemplateHaskell, FlexibleInstances, -- MultiParamTypeClasses, DataKinds, TypeFamilies, PatternGuards dataPGRelation :: String -> PGName -> (String -> String) -> DecsQ -- | Representaion of PostgreSQL's array type. Currently this only supports -- one-dimensional arrays. PostgreSQL arrays in theory can dynamically be -- any (rectangular) shape. module Database.PostgreSQL.Typed.Array -- | The cannonical representation of a PostgreSQL array of any type, which -- may always contain NULLs. Currenly only one-dimetional arrays are -- supported, although in PostgreSQL, any array may be of any -- dimentionality. type PGArray a = [Maybe a] -- | Class indicating that the first PostgreSQL type is an array of the -- second. This implies PGParameter and PGColumn instances -- that will work for any type using comma as a delimiter (i.e., anything -- but box). This will only work with 1-dimensional arrays. class (PGType t, PGType (PGElemType t)) => PGArrayType t where type PGElemType t :: Symbol pgArrayElementType PGTypeProxy = PGTypeProxy pgArrayDelim _ = ',' where { type family PGElemType t :: Symbol; } pgArrayElementType :: PGArrayType t => PGTypeID t -> PGTypeID (PGElemType t) -- | The character used as a delimeter. The default , is correct -- for all standard types (except box). pgArrayDelim :: PGArrayType t => PGTypeID t -> Char -- | Allow entirely non-null arrays as parameter inputs only. (Only -- supported on ghc >= 7.10 due to instance overlap.) instance (Database.PostgreSQL.Typed.Array.PGArrayType t, Database.PostgreSQL.Typed.Types.PGParameter (Database.PostgreSQL.Typed.Array.PGElemType t) a) => Database.PostgreSQL.Typed.Types.PGParameter t (Database.PostgreSQL.Typed.Array.PGArray a) instance (Database.PostgreSQL.Typed.Array.PGArrayType t, Database.PostgreSQL.Typed.Types.PGParameter (Database.PostgreSQL.Typed.Array.PGElemType t) a) => Database.PostgreSQL.Typed.Types.PGParameter t [a] instance (Database.PostgreSQL.Typed.Array.PGArrayType t, Database.PostgreSQL.Typed.Types.PGColumn (Database.PostgreSQL.Typed.Array.PGElemType t) a) => Database.PostgreSQL.Typed.Types.PGColumn t (Database.PostgreSQL.Typed.Array.PGArray a) instance Database.PostgreSQL.Typed.Types.PGType "boolean" => Database.PostgreSQL.Typed.Types.PGType "boolean[]" instance Database.PostgreSQL.Typed.Types.PGType "boolean" => Database.PostgreSQL.Typed.Array.PGArrayType "boolean[]" instance Database.PostgreSQL.Typed.Types.PGType "bytea" => Database.PostgreSQL.Typed.Types.PGType "bytea[]" instance Database.PostgreSQL.Typed.Types.PGType "bytea" => Database.PostgreSQL.Typed.Array.PGArrayType "bytea[]" instance Database.PostgreSQL.Typed.Types.PGType "\"char\"" => Database.PostgreSQL.Typed.Types.PGType "\"char\"[]" instance Database.PostgreSQL.Typed.Types.PGType "\"char\"" => Database.PostgreSQL.Typed.Array.PGArrayType "\"char\"[]" instance Database.PostgreSQL.Typed.Types.PGType "name" => Database.PostgreSQL.Typed.Types.PGType "name[]" instance Database.PostgreSQL.Typed.Types.PGType "name" => Database.PostgreSQL.Typed.Array.PGArrayType "name[]" instance Database.PostgreSQL.Typed.Types.PGType "bigint" => Database.PostgreSQL.Typed.Types.PGType "bigint[]" instance Database.PostgreSQL.Typed.Types.PGType "bigint" => Database.PostgreSQL.Typed.Array.PGArrayType "bigint[]" instance Database.PostgreSQL.Typed.Types.PGType "smallint" => Database.PostgreSQL.Typed.Types.PGType "smallint[]" instance Database.PostgreSQL.Typed.Types.PGType "smallint" => Database.PostgreSQL.Typed.Array.PGArrayType "smallint[]" instance Database.PostgreSQL.Typed.Types.PGType "int2vector" => Database.PostgreSQL.Typed.Types.PGType "int2vector[]" instance Database.PostgreSQL.Typed.Types.PGType "int2vector" => Database.PostgreSQL.Typed.Array.PGArrayType "int2vector[]" instance Database.PostgreSQL.Typed.Types.PGType "integer" => Database.PostgreSQL.Typed.Types.PGType "integer[]" instance Database.PostgreSQL.Typed.Types.PGType "integer" => Database.PostgreSQL.Typed.Array.PGArrayType "integer[]" instance Database.PostgreSQL.Typed.Types.PGType "regproc" => Database.PostgreSQL.Typed.Types.PGType "regproc[]" instance Database.PostgreSQL.Typed.Types.PGType "regproc" => Database.PostgreSQL.Typed.Array.PGArrayType "regproc[]" instance Database.PostgreSQL.Typed.Types.PGType "text" => Database.PostgreSQL.Typed.Types.PGType "text[]" instance Database.PostgreSQL.Typed.Types.PGType "text" => Database.PostgreSQL.Typed.Array.PGArrayType "text[]" instance Database.PostgreSQL.Typed.Types.PGType "oid" => Database.PostgreSQL.Typed.Types.PGType "oid[]" instance Database.PostgreSQL.Typed.Types.PGType "oid" => Database.PostgreSQL.Typed.Array.PGArrayType "oid[]" instance Database.PostgreSQL.Typed.Types.PGType "tid" => Database.PostgreSQL.Typed.Types.PGType "tid[]" instance Database.PostgreSQL.Typed.Types.PGType "tid" => Database.PostgreSQL.Typed.Array.PGArrayType "tid[]" instance Database.PostgreSQL.Typed.Types.PGType "xid" => Database.PostgreSQL.Typed.Types.PGType "xid[]" instance Database.PostgreSQL.Typed.Types.PGType "xid" => Database.PostgreSQL.Typed.Array.PGArrayType "xid[]" instance Database.PostgreSQL.Typed.Types.PGType "cid" => Database.PostgreSQL.Typed.Types.PGType "cid[]" instance Database.PostgreSQL.Typed.Types.PGType "cid" => Database.PostgreSQL.Typed.Array.PGArrayType "cid[]" instance Database.PostgreSQL.Typed.Types.PGType "oidvector" => Database.PostgreSQL.Typed.Types.PGType "oidvector[]" instance Database.PostgreSQL.Typed.Types.PGType "oidvector" => Database.PostgreSQL.Typed.Array.PGArrayType "oidvector[]" instance Database.PostgreSQL.Typed.Types.PGType "json" => Database.PostgreSQL.Typed.Types.PGType "json[]" instance Database.PostgreSQL.Typed.Types.PGType "json" => Database.PostgreSQL.Typed.Array.PGArrayType "json[]" instance Database.PostgreSQL.Typed.Types.PGType "xml" => Database.PostgreSQL.Typed.Types.PGType "xml[]" instance Database.PostgreSQL.Typed.Types.PGType "xml" => Database.PostgreSQL.Typed.Array.PGArrayType "xml[]" instance Database.PostgreSQL.Typed.Types.PGType "point" => Database.PostgreSQL.Typed.Types.PGType "point[]" instance Database.PostgreSQL.Typed.Types.PGType "point" => Database.PostgreSQL.Typed.Array.PGArrayType "point[]" instance Database.PostgreSQL.Typed.Types.PGType "lseg" => Database.PostgreSQL.Typed.Types.PGType "lseg[]" instance Database.PostgreSQL.Typed.Types.PGType "lseg" => Database.PostgreSQL.Typed.Array.PGArrayType "lseg[]" instance Database.PostgreSQL.Typed.Types.PGType "path" => Database.PostgreSQL.Typed.Types.PGType "path[]" instance Database.PostgreSQL.Typed.Types.PGType "path" => Database.PostgreSQL.Typed.Array.PGArrayType "path[]" instance Database.PostgreSQL.Typed.Types.PGType "box" => Database.PostgreSQL.Typed.Types.PGType "box[]" instance Database.PostgreSQL.Typed.Types.PGType "box" => Database.PostgreSQL.Typed.Array.PGArrayType "box[]" instance Database.PostgreSQL.Typed.Types.PGType "polygon" => Database.PostgreSQL.Typed.Types.PGType "polygon[]" instance Database.PostgreSQL.Typed.Types.PGType "polygon" => Database.PostgreSQL.Typed.Array.PGArrayType "polygon[]" instance Database.PostgreSQL.Typed.Types.PGType "line" => Database.PostgreSQL.Typed.Types.PGType "line[]" instance Database.PostgreSQL.Typed.Types.PGType "line" => Database.PostgreSQL.Typed.Array.PGArrayType "line[]" instance Database.PostgreSQL.Typed.Types.PGType "cidr" => Database.PostgreSQL.Typed.Types.PGType "cidr[]" instance Database.PostgreSQL.Typed.Types.PGType "cidr" => Database.PostgreSQL.Typed.Array.PGArrayType "cidr[]" instance Database.PostgreSQL.Typed.Types.PGType "real" => Database.PostgreSQL.Typed.Types.PGType "real[]" instance Database.PostgreSQL.Typed.Types.PGType "real" => Database.PostgreSQL.Typed.Array.PGArrayType "real[]" instance Database.PostgreSQL.Typed.Types.PGType "double precision" => Database.PostgreSQL.Typed.Types.PGType "double precision[]" instance Database.PostgreSQL.Typed.Types.PGType "double precision" => Database.PostgreSQL.Typed.Array.PGArrayType "double precision[]" instance Database.PostgreSQL.Typed.Types.PGType "abstime" => Database.PostgreSQL.Typed.Types.PGType "abstime[]" instance Database.PostgreSQL.Typed.Types.PGType "abstime" => Database.PostgreSQL.Typed.Array.PGArrayType "abstime[]" instance Database.PostgreSQL.Typed.Types.PGType "reltime" => Database.PostgreSQL.Typed.Types.PGType "reltime[]" instance Database.PostgreSQL.Typed.Types.PGType "reltime" => Database.PostgreSQL.Typed.Array.PGArrayType "reltime[]" instance Database.PostgreSQL.Typed.Types.PGType "tinterval" => Database.PostgreSQL.Typed.Types.PGType "tinterval[]" instance Database.PostgreSQL.Typed.Types.PGType "tinterval" => Database.PostgreSQL.Typed.Array.PGArrayType "tinterval[]" instance Database.PostgreSQL.Typed.Types.PGType "circle" => Database.PostgreSQL.Typed.Types.PGType "circle[]" instance Database.PostgreSQL.Typed.Types.PGType "circle" => Database.PostgreSQL.Typed.Array.PGArrayType "circle[]" instance Database.PostgreSQL.Typed.Types.PGType "money" => Database.PostgreSQL.Typed.Types.PGType "money[]" instance Database.PostgreSQL.Typed.Types.PGType "money" => Database.PostgreSQL.Typed.Array.PGArrayType "money[]" instance Database.PostgreSQL.Typed.Types.PGType "macaddr" => Database.PostgreSQL.Typed.Types.PGType "macaddr[]" instance Database.PostgreSQL.Typed.Types.PGType "macaddr" => Database.PostgreSQL.Typed.Array.PGArrayType "macaddr[]" instance Database.PostgreSQL.Typed.Types.PGType "inet" => Database.PostgreSQL.Typed.Types.PGType "inet[]" instance Database.PostgreSQL.Typed.Types.PGType "inet" => Database.PostgreSQL.Typed.Array.PGArrayType "inet[]" instance Database.PostgreSQL.Typed.Types.PGType "aclitem" => Database.PostgreSQL.Typed.Types.PGType "aclitem[]" instance Database.PostgreSQL.Typed.Types.PGType "aclitem" => Database.PostgreSQL.Typed.Array.PGArrayType "aclitem[]" instance Database.PostgreSQL.Typed.Types.PGType "bpchar" => Database.PostgreSQL.Typed.Types.PGType "bpchar[]" instance Database.PostgreSQL.Typed.Types.PGType "bpchar" => Database.PostgreSQL.Typed.Array.PGArrayType "bpchar[]" instance Database.PostgreSQL.Typed.Types.PGType "character varying" => Database.PostgreSQL.Typed.Types.PGType "character varying[]" instance Database.PostgreSQL.Typed.Types.PGType "character varying" => Database.PostgreSQL.Typed.Array.PGArrayType "character varying[]" instance Database.PostgreSQL.Typed.Types.PGType "date" => Database.PostgreSQL.Typed.Types.PGType "date[]" instance Database.PostgreSQL.Typed.Types.PGType "date" => Database.PostgreSQL.Typed.Array.PGArrayType "date[]" instance Database.PostgreSQL.Typed.Types.PGType "time without time zone" => Database.PostgreSQL.Typed.Types.PGType "time without time zone[]" instance Database.PostgreSQL.Typed.Types.PGType "time without time zone" => Database.PostgreSQL.Typed.Array.PGArrayType "time without time zone[]" instance Database.PostgreSQL.Typed.Types.PGType "timestamp without time zone" => Database.PostgreSQL.Typed.Types.PGType "timestamp without time zone[]" instance Database.PostgreSQL.Typed.Types.PGType "timestamp without time zone" => Database.PostgreSQL.Typed.Array.PGArrayType "timestamp without time zone[]" instance Database.PostgreSQL.Typed.Types.PGType "timestamp with time zone" => Database.PostgreSQL.Typed.Types.PGType "timestamp with time zone[]" instance Database.PostgreSQL.Typed.Types.PGType "timestamp with time zone" => Database.PostgreSQL.Typed.Array.PGArrayType "timestamp with time zone[]" instance Database.PostgreSQL.Typed.Types.PGType "interval" => Database.PostgreSQL.Typed.Types.PGType "interval[]" instance Database.PostgreSQL.Typed.Types.PGType "interval" => Database.PostgreSQL.Typed.Array.PGArrayType "interval[]" instance Database.PostgreSQL.Typed.Types.PGType "time with time zone" => Database.PostgreSQL.Typed.Types.PGType "time with time zone[]" instance Database.PostgreSQL.Typed.Types.PGType "time with time zone" => Database.PostgreSQL.Typed.Array.PGArrayType "time with time zone[]" instance Database.PostgreSQL.Typed.Types.PGType "bit" => Database.PostgreSQL.Typed.Types.PGType "bit[]" instance Database.PostgreSQL.Typed.Types.PGType "bit" => Database.PostgreSQL.Typed.Array.PGArrayType "bit[]" instance Database.PostgreSQL.Typed.Types.PGType "varbit" => Database.PostgreSQL.Typed.Types.PGType "varbit[]" instance Database.PostgreSQL.Typed.Types.PGType "varbit" => Database.PostgreSQL.Typed.Array.PGArrayType "varbit[]" instance Database.PostgreSQL.Typed.Types.PGType "numeric" => Database.PostgreSQL.Typed.Types.PGType "numeric[]" instance Database.PostgreSQL.Typed.Types.PGType "numeric" => Database.PostgreSQL.Typed.Array.PGArrayType "numeric[]" instance Database.PostgreSQL.Typed.Types.PGType "refcursor" => Database.PostgreSQL.Typed.Types.PGType "refcursor[]" instance Database.PostgreSQL.Typed.Types.PGType "refcursor" => Database.PostgreSQL.Typed.Array.PGArrayType "refcursor[]" instance Database.PostgreSQL.Typed.Types.PGType "regprocedure" => Database.PostgreSQL.Typed.Types.PGType "regprocedure[]" instance Database.PostgreSQL.Typed.Types.PGType "regprocedure" => Database.PostgreSQL.Typed.Array.PGArrayType "regprocedure[]" instance Database.PostgreSQL.Typed.Types.PGType "regoper" => Database.PostgreSQL.Typed.Types.PGType "regoper[]" instance Database.PostgreSQL.Typed.Types.PGType "regoper" => Database.PostgreSQL.Typed.Array.PGArrayType "regoper[]" instance Database.PostgreSQL.Typed.Types.PGType "regoperator" => Database.PostgreSQL.Typed.Types.PGType "regoperator[]" instance Database.PostgreSQL.Typed.Types.PGType "regoperator" => Database.PostgreSQL.Typed.Array.PGArrayType "regoperator[]" instance Database.PostgreSQL.Typed.Types.PGType "regclass" => Database.PostgreSQL.Typed.Types.PGType "regclass[]" instance Database.PostgreSQL.Typed.Types.PGType "regclass" => Database.PostgreSQL.Typed.Array.PGArrayType "regclass[]" instance Database.PostgreSQL.Typed.Types.PGType "regtype" => Database.PostgreSQL.Typed.Types.PGType "regtype[]" instance Database.PostgreSQL.Typed.Types.PGType "regtype" => Database.PostgreSQL.Typed.Array.PGArrayType "regtype[]" instance Database.PostgreSQL.Typed.Types.PGType "record" => Database.PostgreSQL.Typed.Types.PGType "record[]" instance Database.PostgreSQL.Typed.Types.PGType "record" => Database.PostgreSQL.Typed.Array.PGArrayType "record[]" instance Database.PostgreSQL.Typed.Types.PGType "cstring" => Database.PostgreSQL.Typed.Types.PGType "cstring[]" instance Database.PostgreSQL.Typed.Types.PGType "cstring" => Database.PostgreSQL.Typed.Array.PGArrayType "cstring[]" instance Database.PostgreSQL.Typed.Types.PGType "uuid" => Database.PostgreSQL.Typed.Types.PGType "uuid[]" instance Database.PostgreSQL.Typed.Types.PGType "uuid" => Database.PostgreSQL.Typed.Array.PGArrayType "uuid[]" instance Database.PostgreSQL.Typed.Types.PGType "txid_snapshot" => Database.PostgreSQL.Typed.Types.PGType "txid_snapshot[]" instance Database.PostgreSQL.Typed.Types.PGType "txid_snapshot" => Database.PostgreSQL.Typed.Array.PGArrayType "txid_snapshot[]" instance Database.PostgreSQL.Typed.Types.PGType "tsvector" => Database.PostgreSQL.Typed.Types.PGType "tsvector[]" instance Database.PostgreSQL.Typed.Types.PGType "tsvector" => Database.PostgreSQL.Typed.Array.PGArrayType "tsvector[]" instance Database.PostgreSQL.Typed.Types.PGType "tsquery" => Database.PostgreSQL.Typed.Types.PGType "tsquery[]" instance Database.PostgreSQL.Typed.Types.PGType "tsquery" => Database.PostgreSQL.Typed.Array.PGArrayType "tsquery[]" instance Database.PostgreSQL.Typed.Types.PGType "gtsvector" => Database.PostgreSQL.Typed.Types.PGType "gtsvector[]" instance Database.PostgreSQL.Typed.Types.PGType "gtsvector" => Database.PostgreSQL.Typed.Array.PGArrayType "gtsvector[]" instance Database.PostgreSQL.Typed.Types.PGType "regconfig" => Database.PostgreSQL.Typed.Types.PGType "regconfig[]" instance Database.PostgreSQL.Typed.Types.PGType "regconfig" => Database.PostgreSQL.Typed.Array.PGArrayType "regconfig[]" instance Database.PostgreSQL.Typed.Types.PGType "regdictionary" => Database.PostgreSQL.Typed.Types.PGType "regdictionary[]" instance Database.PostgreSQL.Typed.Types.PGType "regdictionary" => Database.PostgreSQL.Typed.Array.PGArrayType "regdictionary[]" instance Database.PostgreSQL.Typed.Types.PGType "int4range" => Database.PostgreSQL.Typed.Types.PGType "int4range[]" instance Database.PostgreSQL.Typed.Types.PGType "int4range" => Database.PostgreSQL.Typed.Array.PGArrayType "int4range[]" instance Database.PostgreSQL.Typed.Types.PGType "numrange" => Database.PostgreSQL.Typed.Types.PGType "numrange[]" instance Database.PostgreSQL.Typed.Types.PGType "numrange" => Database.PostgreSQL.Typed.Array.PGArrayType "numrange[]" instance Database.PostgreSQL.Typed.Types.PGType "tsrange" => Database.PostgreSQL.Typed.Types.PGType "tsrange[]" instance Database.PostgreSQL.Typed.Types.PGType "tsrange" => Database.PostgreSQL.Typed.Array.PGArrayType "tsrange[]" instance Database.PostgreSQL.Typed.Types.PGType "tstzrange" => Database.PostgreSQL.Typed.Types.PGType "tstzrange[]" instance Database.PostgreSQL.Typed.Types.PGType "tstzrange" => Database.PostgreSQL.Typed.Array.PGArrayType "tstzrange[]" instance Database.PostgreSQL.Typed.Types.PGType "daterange" => Database.PostgreSQL.Typed.Types.PGType "daterange[]" instance Database.PostgreSQL.Typed.Types.PGType "daterange" => Database.PostgreSQL.Typed.Array.PGArrayType "daterange[]" instance Database.PostgreSQL.Typed.Types.PGType "int8range" => Database.PostgreSQL.Typed.Types.PGType "int8range[]" instance Database.PostgreSQL.Typed.Types.PGType "int8range" => Database.PostgreSQL.Typed.Array.PGArrayType "int8range[]" module Database.PostgreSQL.Typed -- | PGException is thrown upon encountering an ErrorResponse with -- severity of ERROR, FATAL, or PANIC. It holds the message of the error. data PGError PGError :: MessageFields -> PGError [pgErrorFields] :: PGError -> MessageFields -- | Information for how to connect to a database, to be passed to -- pgConnect. data PGDatabase PGDatabase :: HostName -> PortID -> ByteString -> ByteString -> [(ByteString, ByteString)] -> Bool -> (MessageFields -> IO ()) -> PGDatabase -- | The hostname (ignored if pgDBPort is UnixSocket) [pgDBHost] :: PGDatabase -> HostName -- | The port, likely either PortNumber 5432 or UnixSocket -- "/tmp/.s.PGSQL.5432" [pgDBPort] :: PGDatabase -> PortID -- | The name of the database [pgDBName] :: PGDatabase -> ByteString [pgDBUser, pgDBPass] :: PGDatabase -> ByteString -- | Extra parameters to set for the connection (e.g., (TimeZone, -- UTC)) [pgDBParams] :: PGDatabase -> [(ByteString, ByteString)] -- | Log all low-level server messages [pgDBDebug] :: PGDatabase -> Bool -- | How to log server notice messages (e.g., print . PGError) [pgDBLogMessage] :: PGDatabase -> MessageFields -> IO () -- | A database connection with sane defaults: localhost:5432:postgres defaultPGDatabase :: PGDatabase -- | An established connection to the PostgreSQL server. These objects are -- not thread-safe and must only be used for a single request at a time. data PGConnection -- | Connect to a PostgreSQL server. pgConnect :: PGDatabase -> IO PGConnection -- | Disconnect cleanly from the PostgreSQL server. pgDisconnect :: PGConnection -> IO () -- | Specify an alternative database to use during compilation. This lets -- you override the default connection parameters that are based on TPG -- environment variables. This should be called as a top-level -- declaration and produces no code. It uses pgReconnect so is -- safe to call multiple times with the same database. useTPGDatabase :: PGDatabase -> DecsQ -- | A quasi-quoter for PGSQL queries. -- -- Used in expression context, it may contain any SQL statement -- [pgSQL|SELECT ...|]. The statement may contain -- PostgreSQL-style placeholders ($1, $2, ...) or -- in-line placeholders (${1+1}) containing any valid Haskell -- expression (except {}). It will be replaced by a -- PGQuery object that can be used to perform the SQL statement. -- If there are more $N placeholders than expressions, it will -- instead be a function accepting the additional parameters and -- returning a PGQuery. -- -- Ideally, this mimics postgres' SQL parsing, so that placeholders and -- expressions will only be expanded when they are in valid positions -- (i.e., not inside quoted strings). Since ${ is not valid SQL -- otherwise, there should be no need to escape it. -- -- The statement may start with one of more special flags affecting the -- interpretation: -- -- -- -- pgSQL can also be used at the top-level to execute SQL -- statements at compile-time (without any parameters and ignoring -- results). Here the query can only be prefixed with ! to make -- errors non-fatal. -- -- If you want to construct queries out of string variables rather than -- quasi-quoted strings, you can use the lower-level makePGQuery -- instead. pgSQL :: QuasiQuoter -- | Run a query and return a list of row results. pgQuery :: PGQuery q a => PGConnection -> q -> IO [a] -- | Execute a query that does not return results. Return the number of -- rows affected (or -1 if not known). pgExecute :: PGQuery q () => PGConnection -> q -> IO Int -- | Wrap a computation in a pgBegin, pgCommit block, or -- pgRollback on exception. pgTransaction :: PGConnection -> IO a -> IO a