!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~          !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~     experimental&Leon P Smith <leon@melding-monads.com>NoneEA structure representing some of the metadata regarding a PostgreSQL  type, mostly taken from the pg_type table.  !"#$%&'( !"#$%&'($" %&'(%&'(#%&'(!%&'( experimental&Leon P Smith <leon@melding-monads.com>Nones)*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~$" %&'(%&'(#%&'(!%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~s)*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ experimental&Leon P Smith <leon@melding-monads.com> Safe-InferredEParse one of three primitive field formats: array, quoted and plain. Recognizes a quoted string. IRecognizes a plain string literal, not containing quotes or brackets and + not containing the delimiter character. JFormat an array format item, using the delimiter character if the item is  itself an array. IFormat a list of array format items, inserting the appropriate delimiter H between them. When the items are arrays, they will be delimited with G commas; otherwise, they are delimited with the passed-in-delimiter. JFormat an array format item, using the delimiter character if the item is J itself an array, optionally applying quoting rules. Creates copies for  safety when used in  FromField instances. CEscape a string according to Postgres double-quoted string format.  experimentalleon@melding-monads.com Safe-Inferred<a way to reify a list of exceptions into a single exception Two 4 cases are considered equal, regardless of what the " list of exceptions looks like. NoneLike /, but backported to base before version 4.3.0. 9Note that the restore callback is monomorphic, unlike in . This K could be fixed by changing the type signature, but it would require us to ( enable the RankNTypes extension (since  has a rank-3 type). The  withTransactionMode6 function calls the restore callback only once, so we  don't need that polymorphism.  experimental&Leon P Smith <leon@melding-monads.com>None  Represents a VALUES- table literal, usable as an alternative to   and  . The main advantage is that / you can parametrize more than just a single VALUES expression.  For example, here'+s a query to insert a thing into one table C and some attributes of that thing into another, returning the % new id generated by the database:   query c [sql|  WITH new_thing AS ( 8 INSERT INTO thing (name) VALUES (?) RETURNING id  ), new_attributes AS ( $ INSERT INTO thing_attributes ' SELECT new_thing.id, attrs.* 0 FROM new_thing JOIN ? attrs ON TRUE  ) SELECT * FROM new_thing + |] ("foo", Values [ "int4", "text" ] ) [ ( 1 , "hello" ) , , ( 2 , "world" ) ]) ;(Note this example uses writable common table expressions, ( which were added in PostgreSQL 9.1) BThe second parameter gets expanded into the following SQL syntax:  2 (VALUES (1::"int4",'hello'::"text"),(2,'world')) HWhen the list of attributes is empty, the second parameter expands to:  . (VALUES (null::"int4",null::"text") LIMIT 0)  By contrast,  executeMany and  returning don't issue the query ( in the empty case, and simply return 0 and [] respectively. D This behavior is usually correct given their intended use cases, 6 but would certainly be wrong in the example above. EThe first argument is a list of postgresql type names. Because this G is turned into a properly quoted identifier, the type name is case . sensitive and must be as it appears in the pg_type table. Thus,  you must write  timestamptz instead of timestamp with time zone,  int4 instead of integer or serial, _int8 instead of bigint[],  etcetera. >You may omit the type names, however, if you do so the list F of values must be non-empty, and postgresql must be able to infer I the types of the columns from the surrounding context. If the first D condition is not met, postgresql-simple will throw an exception I without issuing the query. In the second case, the postgres server 4 will return an error which will be turned into a SqlError exception. See  :https://www.postgresql.org/docs/9.5/static/sql-values.html for  more information. >A composite type to parse your custom data structures without 5 having to define dummy newtype wrappers every time.  # instance FromRow MyData where ...  $ instance FromRow MyData2 where ... &then I can do the following for free:   res <- query' c ...  forM res $ \"(MyData{..} :. MyData2{..}) -> do  .... +Wrap a list for use as a PostgreSQL array. @Wrap text for use as (maybe) qualified identifier, i.e. a table $ with schema, or column with table. BWrap text for use as sql identifier, i.e. a table or column name. Wrap binary data for use as a bytea value. $Wrap a list of values for use in an IN clause. Replaces a  single "?"1 character with a parenthesized list of rendered  values.  Example:  D query c "select * from whatever where id in ?" (Only (In [3,4,5]))  Note that In [] expands to (null), which works as expected in C the query above, but evaluates to the logical null value on every  row instead of TRUE,. This means that changing the query above  to ... id NOT in ?/ and supplying the empty list as the parameter @ returns zero rows, instead of all of them as one would expect. Since postgresql doesn'3t seem to provide a syntax for actually specifying C an empty list, which could solve this completely, there are two 5 workarounds particularly worth mentioning, namely:   Use postgresql-simple's % type instead, which can handle the C empty case correctly. Note however that while specifying the  postgresql type int4- is mandatory in the empty case, specifying  the haskell type Values (Only Int)! would not normally be needed in  realistic use cases.  4 query c "select * from whatever where id not in ?" : (Only (Values ["int4"] [] :: Values (Only Int)))   Use sql's COALESCE operator to turn a logical null into the correct H boolean. Note however that the correct boolean depends on the use  case:  D query c "select * from whatever where coalesce(id NOT in ?, TRUE)" $ (Only (In [] :: In [Int]))  A query c "select * from whatever where coalesce(id IN ?, FALSE)" $ (Only (In [] :: In [Int])) HNote that at as of PostgreSQL 9.4, the query planner cannot see inside  the COALESCE' operator, so if you have an index on id then you  probably don'&t want to write the last example with COALESCE , which B would result in a table scan. There are further caveats if id can A be null or you want null treated sensibly as a component of IN or  NOT IN. A single-value " collection". AThis is useful if you need to supply a single parameter to a SQL 6 query, or extract a single column from a SQL result. Parameter example:  query c " select x from scores where x > ?" ( (42::Int))Result example: xs < - query_ c "select id from users"  forM_ xs $ \( id) -> {- ... -}>A query string. This type is intended to make it difficult to E construct a SQL query by concatenating string fragments, as that is A an extremely common way to accidentally introduce SQL injection & vulnerabilities into an application. This type is an instance of , so the easiest way to $ construct a query is to enable the OverloadedStrings language = extension and then simply write the query in double quotes.  $ {-# LANGUAGE OverloadedStrings #-}  # import Database.PostgreSQL.Simple   q :: Query  q = "select ?" The underlying type is a , and literal Haskell strings B that contain Unicode characters will be correctly transformed to  UTF-8. !A placeholder for the PostgreSQL DEFAULT value. A placeholder for the SQL NULL value. "foo.bar" will get turned into  QualifiedIdentifier (Just "foo") "bar" , while "foo" will get  turned into QualifiedIdentifier Nothing "foo". Note this instance ? is for convenience, and does not match postgres syntax. It K only examines the first period character, and thus cannot be used if the 6 qualifying identifier contains a period for example. %           experimental&Leon P Smith <leon@melding-monads.com>None$Returns an expression that has type   ->  , true if the " oid is equal to any one of the %s of the given s. Literally substitute the % of a  expression. ! Returns an expression of type  . Useful because GHC tends  not to fold constants.   experimental&Leon P Smith <leon@melding-monads.com>None2 is a quasiquoter that eases the syntactic burden E of writing big sql statements in Haskell source code. For example:   {-# LANGUAGE QuasiQuotes #-}  , query conn [sql| SELECT column_a, column_b 4 FROM table1 NATURAL JOIN table2 0 WHERE ? <= time AND time < ? % AND name LIKE ? & ORDER BY size DESC 7 LIMIT 100 |] ' (beginTime,endTime,string) =This quasiquoter returns a literal string expression of type , G and attempts to mimimize whitespace; otherwise the above query would D consist of approximately half whitespace when sent to the database C backend. It also recognizes and strips out standard sql comments --. FThe implementation of the whitespace reducer is currently incomplete. E Thus it can mess up your syntax in cases where whitespace should be J preserved as-is. It does preserve whitespace inside standard SQL string J literals. But it can get confused by the non-standard PostgreSQL string J literal syntax (which is the default setting in PostgreSQL 8 and below), L the extended escape string syntax, quoted identifiers, and other similar  constructs. COf course, this caveat only applies to text written inside the SQL E quasiquoter; whitespace reduction is a compile-time computation and  thus will not touch the string' parameter above, which is a run-time  value. 3Also note that this will not work if the substring |] is contained  in the query.  experimental&Leon P Smith <leon@melding-monads.com>None Parse a date of the form  YYYY-MM-DD. 5Parse a two-digit integer (e.g. day of month, hour). Parse a time of the form HH:MM[:SS[.SSS]]. AParse a count of seconds, with the integer part being two digits  long. Parse a time zone, and return  if the offset from UTC is , zero. (This makes some speedups possible.) Parse a time zone, and return  if the offset from UTC is , zero. (This makes some speedups possible.) #Parse a date and time, of the form YYYY-MM-DD HH:MM:SS. " The space may be replaced with a T . The number of seconds may be % followed by a fractional component.  Behaves as +, but converts any time zone offset into a  UTC time. 6Parse a date with time zone info. Acceptable formats:  YYYY-MM-DD HH:MM:SS Z!The first space may instead be a T, and the second space is  optional. The Z represents UTC. The Z may be replaced with a  time zone offset of the form +0000 or -08:00, where the first  two digits are hours, the :' is optional and the second two digits  (also optional) are minutes.   None !"#$%&'()*+,-'()*+,- !"#$%&'()*+,- experimental&Leon P Smith <leon@melding-monads.com>None-./0+.*./0 experimental&Leon P Smith <leon@melding-monads.com>None  experimental&Leon P Smith <leon@melding-monads.com>None >A type that may be used as a single parameter to a SQL query. <How to render an element when substituting it into a query. +Concatenate a series of rendering actions. =Escape before substituting. Use for all sql identifiers like / table, column names, etc. This is used by the  newtype  wrapper.  Escape binary data for use as a bytea literal. Include surrounding  quotes. This is used by the  newtype wrapper. >Escape and enclose in quotes before substituting. Use for all < text-like types, and anything else that may contain unsafe  characters when rendered. ;Render without escaping or quoting. Use for non-text types  such as numbers, when you are certain that they will not A introduce formatting vulnerabilities via use of characters such  as spaces or "'". 6Prepare a value for substitution into a query string. "Convert a Haskell value to a JSON 1 using  2# and convert that to a field using . 7This can be used as the default implementation for the  = method for Haskell types that have a JSON representation in  PostgreSQL. 0Surround a string with single-quote characters: "'" This function does not perform any other escaping. :3456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ab  43456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ab  experimental&Leon P Smith <leon@melding-monads.com>None>A collection type that can be turned into a list of rendering  s. Instances should use the  method of the  class : to perform conversion of each element of the collection. cdefghijklmnopqrstucdefghijklmnopqrstu experimental&Leon P Smith <leon@melding-monads.com>None Exception thrown if a # could not be formatted correctly. ! This may occur if the number of '?' characters in the query : string does not match the number of parameters provided. Exception thrown if query is used to perform an INSERT-like  operation, or execute is used to perform a SELECT-like operation. ,5A Field represents metadata about a particular field You don':t particularly want to retain these structures for a long D period of time, as they will retain the entire query result, not  just the field metadata 0AThis returns the type oid associated with the column. Analogous  to libpq's PQftype. 21Default information for setting up a connection. Defaults are as follows:  Server on  localhost  Port on 5432  User postgres  No password  Database postgres !Use as in the following example: ? connect defaultConnectInfo { connectHost = "db.example.com" } 3BConnect with the given username to the given database. Will throw & an exception if it cannot connect. 4AAttempt to make a connection based on a libpq connection string.  See  Nhttps://www.postgresql.org/docs/9.5/static/libpq-connect.html#LIBPQ-CONNSTRING K for more information. Also note that environment variables also affect K parameters not provided, parameters provided as the empty string, and a  few other things; see   <https://www.postgresql.org/docs/9.5/static/libpq-envars.html H for details. Here is an example with some of the most commonly used  parameters:  ( host='db.somedomain.com' port=5432 ... This attempts to connect to db.somedomain.com:5432. Omitting the port " will normally default to 5432. JOn systems that provide unix domain sockets, omitting the host parameter C will cause libpq to attempt to connect via unix domain sockets. E The default filesystem path to the socket is constructed from the  port number and the DEFAULT_PGSOCKET_DIR constant defined in the  pg_config_manual.h1 header file. Connecting via unix sockets tends  to use the peer1 authentication method, which is very secure and  does not require a password. COn Windows and other systems without unix domain sockets, omitting  the host will default to  localhost.  B ... dbname='postgres' user='postgres' password='secret \' \\ pw' -This attempts to connect to a database named postgres with  user postgres and password secret ' \ pw . Backslash H characters will have to be double-quoted in literal Haskell strings,  of course. Omitting dbname and user will both default to the : system username that the client process is running as.  Omitting password/ will default to an appropriate password found  in the pgpass4 file, or no password at all if a matching line is  not found. See   <https://www.postgresql.org/docs/9.5/static/libpq-pgpass.html for ) more information regarding this file. CAs all parameters are optional and the defaults are sensible, the = empty connection string can be useful for development and C exploratory use, assuming your system is set up appropriately. :On Unix, such a setup would typically consist of a local H postgresql server listening on port 5432, as well as a system user, H database user, and database sharing a common name, with permissions ( granted to the user on the database. .On Windows, in addition you will either need  pg_hba.conf  to specify the use of the trust authentication method for ? the connection, which may not be appropriate for multiuser 5 or production machines, or you will need to use a pgpass file  with the password or md5 authentication methods. See  Ehttps://www.postgresql.org/docs/9.5/static/client-authentication.html > for more information regarding the authentication process. SSL/TLS will typically  just work' if your postgresql server supports or M requires it. However, note that libpq is trivially vulnerable to a MITM D attack without setting additional SSL connection parameters. In  particular, sslmode needs to be set to require,  verify-ca, or   verify-full3 in order to perform certificate validation. When sslmode  is require(, then you will also need to specify a  sslrootcert file, ( otherwise no validation of the server's identity will be performed. C Client authentication via certificates is also possible via the  sslcert and sslkey parameters. See   9https://www.postgresql.org/docs/9.5/static/libpq-ssl.html 5 for detailed information regarding libpq and SSL. 6Turns a 0 data structure into a libpq connection string. 9 A version of execute+ that does not perform query substitution. =HAtomically perform an action with the database handle, if there is one. JQuote bytestring or throw  U      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKConnection for string escaping Query for message error %List of parameters for message error Action to build LMNOPvwxyz{|}~L      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPL,-./0+&'()* !"#$%123456789:;<=>?     @ABCDEFGHIJKLMNOP3      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPvwxyz{|}~leon@melding-monads.comNoneQRSTUVWXYZ[\] QRSTUVWXYZ[\]QRSTUVWXYZ[\] QRSTUVWXYZ[\] experimentalleon@melding-monads.comNonecDReturns a single notification. If no notifications are available,  c blocks until one arrives. It is safe to call c& on a connection that is concurrently J being used for other purposes, note however that PostgreSQL does not E deliver notifications while a connection is inside a transaction. dNon-blocking variant of c#. Returns a single notification, = if available. If no notifications are available, returns . eReturns the process  of the backend server process  handling this connection. DThe backend PID is useful for debugging purposes and for comparison D to NOTIFY messages (which include the PID of the notifying backend C process). Note that the PID belongs to a process executing on the + database server host, not the local host! ^_`abcde^_`abcde^_`abcde^_`abcde experimental&Leon P Smith <leon@melding-monads.com>Noneg+Name of the exclusion violation constraint h/Relation name (usually table), constraint name iName of violated constraint j+Table name and name of violated constraint kThe field is a column name lTries to convert  to ConstrainViolation, checks sqlState and . succeedes only if able to parse sqlErrorMsg. G createUser = catchJust constraintViolation catcher $ execute conn ...  where 4 catcher UniqueViolation "user_login_key" = ...  catcher _ = ... m<Like constraintViolation, but also packs original SqlError. H createUser = catchJust constraintViolationE catcher $ execute conn ...  where 9 catcher (_, UniqueViolation "user_login_key") = ...  catcher (e, _) = throwIO e nECatches SqlError, tries to convert to ConstraintViolation, re-throws 6 on fail. Provides alternative interface to catchJust 8 createUser = catchViolation catcher $ execute conn ...  where 8 catcher _ (UniqueViolation "user_login_key") = ...  catcher e _ = throwIO e fghijklmnopq fghijklmnopq fkjihglmnopq fkjihglmnopqNoney'the read-write mode will be taken from  PostgreSQL's per-connection  default_transaction_read_only variable, ) which is initialized according to the  server'%s config. The default configuration  is x. z:Of the four isolation levels defined by the SQL standard, K these are the three levels distinguished by PostgreSQL as of version 9.0.  See  ?https://www.postgresql.org/docs/9.5/static/transaction-iso.html < for more information. Note that prior to PostgreSQL 9.0, |  was equivalent to {. ~'the isolation level will be taken from  PostgreSQL's per-connection  default_transaction_isolation variable, ) which is initialized according to the  server'%s config. The default configuration  is }. ,Execute an action inside a SQL transaction. -This function initiates a transaction with a "begin  transaction"3 statement, then executes the supplied action. If = the action succeeds, the transaction will be completed with    before this function returns. If the action throws any kind of exception (not just a J PostgreSQL-related exception), the transaction will be rolled back using  ', then the exception will be rethrown. For nesting transactions, see . Execute an action inside of a { transaction. If a H serialization failure occurs, roll back the transaction and try again. ? Be warned that this may execute the IO action multiple times. A {8 transaction creates the illusion that your program has J exclusive access to the database. This means that, even in a concurrent L setting, you can perform queries in sequence without having to worry about 7 what might happen between one statement and the next.  Think of it as STM, but without retry. IExecute an action inside a SQL transaction with a given isolation level. JExecute an action inside a SQL transaction with a given transaction mode. Like &, but also takes a custom callback to 4 determine if a transaction should be retried if an  occurs. E If the callback returns True, then the transaction will be retried. > If the callback returns False, or an exception other than an  M occurs then the transaction will be rolled back and the exception rethrown. This is used to implement . Rollback a transaction. Commit a transaction. Begin a transaction. 1Begin a transaction with a given isolation level 2Begin a transaction with a given transaction mode KCreate a savepoint, and roll back to it if an error occurs. This may only 9 be used inside of a transaction, and provides a sort of  "nested transaction". See  =https://www.postgresql.org/docs/9.5/static/sql-savepoint.html HCreate a new savepoint. This may only be used inside of a transaction. -Destroy a savepoint, but retain its effects. Warning: this will throw a  matching q if . the transaction is aborted due to an error.  would merely warn and  roll back. @Roll back to a savepoint. This will not release the savepoint. ?Roll back to a savepoint and release it. This is like calling   followed by , but avoids a $ round trip to the database server. rstuvwxyz{|}~#opqrstuvwxyz{|}~#rstuz~}|{vyxwopqrstuvyxwz~}|{ experimental&Leon P Smith <leon@melding-monads.com>None  experimental&Leon P Smith <leon@melding-monads.com>NoneAReturns the metadata of the type with a particular oid. To find  this data, ! first consults postgresql-simple's  built-in )$ table, then checks the connection's + typeinfo cache. Finally, the database's pg_type table will @ be queried only if necessary, and the result will be stored  in the connections' s cache.  !"#$%&'($" %&'(%&'(#%&'(!%&'( experimental&Leon P Smith <leon@melding-monads.com>None5.A type that may be converted from a SQL type. (Convert a SQL value to a Haskell value. FReturns a list of exceptions if the conversion fails. In the case of 3 library instances, this will usually be a single , but  may be a UnicodeException. )Note that retaining any reference to the , argument causes  the entire LibPQ.( to be retained. Thus, implementations  of 7 should return results that do not refer to this value / after the result have been evaluated to WHNF. Note that as of postgresql-simple-0.4.0.0, the  value $ has already been copied out of the LibPQ. before it has  been passed to (. This is because for short strings, it's 8 cheaper to copy the string than to set up a finalizer. =Exception thrown if conversion from a SQL value to a Haskell  value fails. 0The SQL value could not be parsed, or could not 0 be represented as a valid Haskell value, or an 4 unexpected low-level error occurred (e.g. mismatch - between metadata and actual data in a row). A SQL NULL" was encountered when the Haskell  type did not permit it. .The SQL and Haskell types are not compatible. FReturns the data type name. This is the preferred way of identifying G types that do not have a stable type oid, such as types provided by  extensions to PostgreSQL. !More concretely, it returns the typname column associated with the  type oid in the pg_type- table. First, postgresql-simple will check ? the built-in, static table. If the type oid is not there, B postgresql-simple will check a per-connection cache, and then  finally query the database's meta-schema. EReturns the name of the column. This is often determined by a table + definition, but it can be set using an as clause. )Returns the name of the object id of the table associated with the  column, if any. Returns  when there is no such table; K for example a computed column does not have a table associated with it.  Analogous to libpq's PQftable. GIf the column has a table associated with it, this returns the number J off the associated table column. Numbering starts from 0. Analogous  to libpq's  PQftablecol. JThis returns whether the data was returned in a binary or textual format.  Analogous to libpq's  PQfformat. For dealing with SQL null values outside of the  class.  Alternatively, one could use !" , but that . also turns type and conversion errors into , whereas this is  more specific and turns only null values into . Parse a field to a JSON 1 and convert that into a  Haskell value using . 7This can be used as the default implementation for the  = method for Haskell types that have a JSON representation in  PostgreSQL. The 1 constraint is required to show more informative $ error messages when parsing fails.  Note that fromJSONField :: FieldParser ( Foo) will return   on the json null' value, and return an exception on SQL null ) value. Alternatively, one could write  fromJSONField  that will return Nothing on SQL null, and otherwise will call   fromJSONField :: FieldParser Foo and then return  the 7 result value, or return its exception. If one would  like to return Nothing on both the SQL null and json null values, $ one way to do it would be to write  \f mv -> #$ ! optionalField fromJSONField f mv #Given one of the constructors from , the field,  and an ), this fills in the other fields in the ' exception value and returns it in a 'Left . SomeException'  constructor. )Compatible with the same set of types as a . Note that  modifying the # does not have any effects outside + the local process on the local machine. )Compatible with the same set of types as a . Note that  modifying the # does not have any effects outside + the local process on the local machine. json uuid =any postgresql array whose elements are compatible with type a 1Compatible with both types. Conversions to type b are & preferred, the conversion to type a will be tried after  the  conversion fails. date  timestamp  timestamptz  timestamptz time date  timestamp  timestamptz  timestamptz  name, text, "char", bpchar, varchar citext citext  name, text, "char", bpchar, varchar  name, text, "char", bpchar, varchar bytea bytea bytea, name, text, "char", bpchar, varchar, unknown oid bytea, name, text, "char", bpchar, varchar, unknown *int2, int4, int8, float4, float8, numeric *int2, int4, int8, float4, float8, numeric ,int2, int4, float4, float8 (Uses attoparsec's  routine, for  better accuracy convert to  or  first)  int2, float4 (Uses attoparsec's  routine, for  better accuracy convert to  or  first) int2, int4, int8 int2, int4, int8 <int2, int4, and if compiled as 64-bit code, int8 as well. + This library was compiled as 64-bit code.  int2, int4 int2 "char" bool ;compatible with any data type, but the value must be null CFor dealing with null values. Compatible with any postgresql type  compatible with type a(. Note that the type is not checked if A the value is null, although it is inadvisable to rely on this  behavior. void R3  !"#$%&'(,0BCKBC,0$" %&'(%&'(#%&'(!%&'(0 I% experimental&Leon P Smith <leon@melding-monads.com>NoneGRepresents escape text, ready to be the key or value to a hstore value  Represents valid hstore syntax. hstore hstore Assumed to be UTF-8 encoded Assumed to be UTF-8 encoded ' experimental&Leon P Smith <leon@melding-monads.com>None experimental&Leon P Smith <leon@melding-monads.com>None&Leon P Smith <leon@melding-monads.com>NoneGeneric range type Represents boundary of a range $Is a range empty? If this returns  , then the   predicate will always return . However, if this returns  ;, it is not necessarily true that there exists a point for  which  returns .  Consider  (Excludes 2) (Excludes 3) :: PGRange Int,  for example. HDoes a range contain a given point? Note that in some cases, this may C not correspond exactly with a server-side computation. Consider UTCTime I for example, which has a resolution of a picosecond, whereas postgresql's   timestamptz9 types have a resolution of a microsecond. Putting such K Haskell values into the database will result in them being rounded, which 4 can change the value of the containment predicate. Generic range parser "Simple double quoted value parser *Generic range to builder for plain values /  *  experimental&Leon P Smith <leon@melding-monads.com>NoneCA collection type that can be converted from a sequence of fields. N Instances are provided for tuples up to 10 elements and lists of any length. KNote that instances can be defined outside of postgresql-simple, which is " often useful. For example, here''s an instance for a user-defined pair:   7 data User = User { name :: String, fileQuota :: Int }   instance  User where  fromRow = User <$>  <*>  The number of calls to * must match the number of fields returned 5 in a single row of the query result. Otherwise, a   exception will be thrown.  Note that 8 evaluates its result to WHNF, so the caveats listed in L mysql-simple and very early versions of postgresql-simple no longer apply. K Instead, look at the caveats associated with user-defined implementations  of . *      !"#$%&'()*+(      !"#$%&'()*+ experimental&Leon P Smith <leon@melding-monads.com>NoneExecute a multi-row INSERT, UPDATE!, or other SQL query that is not  expected to return results. KReturns the number of rows affected. If the list of parameters is empty, N this function will simply return 0 without issuing the query to the backend. , If this is not desired, consider using the Values constructor instead. Throws 3 if the query could not be formatted correctly, or  a , exception if the backend returns an error. For example, here'/s a command that inserts two rows into a table  with two columns:    executeMany c [sql| ( INSERT INTO sometable VALUES (?,?)  |] [(1, "hello"),(2, "world")] Here'6s an canonical example of a multi-row update command:   executeMany c [sql|  UPDATE sometable  SET sometable.y = upd.y ' FROM (VALUES (?,?)) as upd(x,y)  WHERE sometable.x = upd.x  |] [(1, "hello"),(2, "world")]  Execute an INSERT, UPDATE!, or other SQL query that is not  expected to return results. %Returns the number of rows affected. Throws 3 if the query could not be formatted correctly, or  a , exception if the backend returns an error.  A version of + that does not perform query substitution.  Perform a SELECT/ or other SQL query that is expected to return > results. All results are retrieved and converted before this  function returns. CWhen processing large results, this function will consume a lot of % client-side memory. Consider using  instead. Exceptions that may be thrown:  5: the query string could not be formatted correctly.  5: the result contains no columns (i.e. you should be  using  instead of ).  : result conversion failed.  3: the postgresql backend returned an error, e.g. B a syntax or type error, or an incorrect table or column name. %Number of rows to fetch at a time.  currently defaults I to 256 rows, although it might be nice to make this more intelligent / based on e.g. the average size of the rows. Format a query string. DThis function is exposed to help with debugging and logging. Do not * use it to prepare queries for execution. DString parameters are escaped according to the character set in use  on the &. Throws , if the query string could not be formatted  correctly. 6Format a query string with a variable number of rows. DThis function is exposed to help with debugging and logging. Do not * use it to prepare queries for execution. >The query string must contain exactly one substitution group,  identified by the SQL keyword "VALUES" (case insensitive)  followed by an "("$ character, a series of one or more "?" ' characters separated by commas, and a ")" character. White - space in a substitution group is permitted. Throws , if the query string could not be formatted  correctly. Execute INSERT ... RETURNING, UPDATE ... RETURNING, or other SQL G query that accepts multi-row input and is expected to return results. # Note that it is possible to write   conn INSERT ... RETURNING ... ... F in cases where you are only inserting a single row, and do not need  functionality analogous to . FIf the list of parameters is empty, this function will simply return [] E without issuing the query to the backend. If this is not desired,  consider using the Values constructor instead. Throws 0 if the query could not be formatted correctly.  A version of  taking parser as argument  A version of  taking parser as argument  Perform a SELECT/ or other SQL query that is expected to return B results. Results are streamed incrementally from the server, and  consumed via a left fold. @When dealing with small results, it may be simpler (and perhaps  faster) to use  instead.  This fold is not0 strict. The stream consumer is responsible for < forcing the evaluation of its result to avoid space leaks. HThis is implemented using a database cursor. As such, this requires F a transaction. This function will detect whether or not there is a - transaction in progress, and will create a } w G transaction if needed. The cursor is given a unique temporary name, ' so the consumer may itself call fold. Exceptions that may be thrown:  5: the query string could not be formatted correctly.  5: the result contains no columns (i.e. you should be  using  instead of ).  : result conversion failed.  3: the postgresql backend returned an error, e.g. B a syntax or type error, or an incorrect table or column name.  A version of  taking a parser as an argument  defaults to , and r } w  The same as -, but this provides a bit more control over D lower-level details. Currently, the number of rows fetched per E round-trip to the server and the transaction mode may be adjusted B accordingly. If the connection is already in a transaction, 6 then the existing transaction is used and thus the   option is ignored.  A version of  taking a parser as an argument  A version of + that does not perform query substitution.  A version of  taking a parser as an argument  A version of  taking a parser as an argument  A version of ( that does not transform a state value.  A version of  taking a parser as an argument  A version of + that does not perform query substitution. &,-Query. #Initial state for result consumer. Result consumer. Query. #Initial state for result consumer. Result consumer. Query. #Initial state for result consumer. Result consumer. .Query template. Query parameters. Result consumer. Query template. Result consumer. /0123` !"#$%&23469>j& !"#$%4>3269!,-./0123 experimental&Leon P Smith <leon@melding-monads.com>None!No more rows, and a count of the  number of rows returned. !Data representing either exactly % one row of the result, or header ' or footer data depending on format. Issue a COPY FROM STDIN or COPY TO STDOUT query. In the former  case, the connection's state will change to CopyIn; in the latter,  CopyOut6. The connection must be in the ready state in order ; to call this function. Performs parameter subsitution. Issue a COPY FROM STDIN or COPY TO STDOUT query. In the former  case, the connection's state will change to CopyIn; in the latter,  CopyOut6. The connection must be in the ready state in order C to call this function. Does not perform parameter subsitution. Retrieve some data from a COPY TO STDOUT query. A connection  must be in the CopyOut0 state in order to call this function. If this  returns a  , the connection remains in the CopyOut state,  if it returns *, then the connection has reverted to the  ready state. Feed some data to a COPY FROM STDIN query. Note that A the data does not need to represent a single row, or even an / integral number of rows. The net result of  (putCopyData conn a >> putCopyData conn b  is the same as putCopyData conn c whenever c == BS.append a b. A connection must be in the CopyIn state in order to call this  function, otherwise a  exception will result. The  connection remains in the CopyIn state after this function  is called.  Completes a COPY FROM STDIN$ query. Returns the number of rows  processed. A connection must be in the CopyIn state in order to call this  function, otherwise a  exception will result. The  connection'2s state changes back to ready after this function  is called.  Aborts a COPY FROM STDIN( query. The string parameter is simply A an arbitrary error message that may show up in the PostgreSQL  server's log. A connection must be in the CopyIn state in order to call this  function, otherwise a  exception will result. The  connection'2s state changes back to ready after this function  is called. 4567   45678&'(&')&'*&'+&,-&,.&,/&,0&,123423523623723723823923:23;23<23=23>23?23@23ABBCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~K55                   !""#$%%&'()*++,-.//012234567889:;<==>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnnopqrstuvwxyz{|}~0 V%%%%%%%%%%%%%%%%%%%%%%    &&&&          &!"#$%&'' ()*+,-./ %$&0123456478 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z {|}~&234&&!&!&&&&&%%%%%%%%%%%%%%%%%               ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; <=>?@ABCDEFGHpostgresql-simple-0.5.2.0'Database.PostgreSQL.Simple.LargeObjects$Database.PostgreSQL.Simple.FromField Database.PostgreSQL.Simple.TypesDatabase.PostgreSQL.Simple#Database.PostgreSQL.Simple.TypeInfo*Database.PostgreSQL.Simple.TypeInfo.Static!Database.PostgreSQL.Simple.ArraysDatabase.PostgreSQL.Simple.Ok"Database.PostgreSQL.Simple.FromRow"Database.PostgreSQL.Simple.ToField Database.PostgreSQL.Simple.ToRow)Database.PostgreSQL.Simple.TypeInfo.Macro Database.PostgreSQL.Simple.SqlQQ(Database.PostgreSQL.Simple.Time.InternalDatabase.PostgreSQL.Simple.Time#Database.PostgreSQL.Simple.Internal'Database.PostgreSQL.Simple.Notification!Database.PostgreSQL.Simple.Errors&Database.PostgreSQL.Simple.Transaction!Database.PostgreSQL.Simple.HStore*Database.PostgreSQL.Simple.HStore.Internal Database.PostgreSQL.Simple.RangeDatabase.PostgreSQL.Simple.Copy)Database.PostgreSQL.Simple.TypeInfo.Types!Database.PostgreSQL.Simple.Compat executeMany returning/Database.PostgreSQL.Simple.Time.Internal.Parser0Database.PostgreSQL.Simple.Time.Internal.Printer.Database.PostgreSQL.Simple.Time.ImplementationBasecommitControl.Applicativeoptional Control.Monadjoin0Database.PostgreSQL.Simple.HStore.Implementationbase GHC.IO.Device AbsoluteSeek RelativeSeek SeekFromEndSeekMode GHC.IO.IOModeReadMode WriteMode AppendMode ReadWriteModeIOModepostgresql-libpq-0.9.1.1Database.PostgreSQL.LibPQTextBinaryFormatOid EmptyQuery CommandOkTuplesOkCopyOutCopyIn BadResponse NonfatalError FatalError ExecStatusLoFd AttributeattnameatttypeTypeInfo Compositetyprelid attributesRange rngsubtypeArraytypelemBasictypoid typcategorytypdelimtypnamestaticTypeInfoboolbyteacharnameint8int2int4regproctextoidtidxidcidxmlpointlsegpathboxpolygonlinecidrfloat4float8unknowncirclemoneymacaddrinetbpcharvarchardatetime timestamp timestamptzintervaltimetzbitvarbitnumeric refcursorrecordvoid array_record regprocedureregoper regoperatorregclassregtypeuuidjsonjsonb int2vector oidvector array_xml array_json array_line array_cidr array_circle array_money array_bool array_bytea array_char array_name array_int2array_int2vector array_int4 array_regproc array_text array_tid array_xid array_cidarray_oidvector array_bpchar array_varchar array_int8 array_point array_lseg array_path array_box array_float4 array_float8 array_polygon array_oid array_macaddr array_inetarray_timestamp array_date array_timearray_timestamptzarray_interval array_numeric array_timetz array_bit array_varbitarray_refcursorarray_regprocedure array_regoperarray_regoperatorarray_regclass array_regtype array_uuid array_jsonb int4range _int4rangenumrange _numrangetsrange_tsrange tstzrange _tstzrange daterange _daterange int8range _int8range ArrayFormatQuotedPlain arrayFormatarrayquotedplainfmtdelimitfmt'esc ManyErrorsOkErrorsValues Savepoint:.PGArray fromPGArrayQualifiedIdentifier IdentifierfromIdentifier fromBinaryInOnlyfromOnlyQuery fromQueryDefaultNull FromFieldFromRowToFieldActionManyEscapeIdentifier EscapeByteAEscapeToRowtoRow mkCompats inlineTypoidsql TimeZoneHMSDateZonedTimestamp UTCTimestampLocalTimestamp Unbounded PosInfinityFinite NegInfinity parseUTCTimeparseZonedTimeparseLocalTimeparseDayparseTimeOfDayparseUTCTimestampparseZonedTimestampparseLocalTimestamp parseDategetDaygetDate getTimeOfDay getLocalTimegetLocalTimestamp getTimeZonegetTimeZoneHMSlocalToUTCTimeOfDayHMS getZonedTimegetZonedTimestamp getUTCTimegetUTCTimestamp dayToBuildertimeOfDayToBuildertimeZoneToBuilderutcTimeToBuilderzonedTimeToBuilderlocalTimeToBuilderunboundedToBuilderutcTimestampToBuilderzonedTimestampToBuilderlocalTimestampToBuilder dateToBuildernominalDiffTimeToBuildertoField toJSONFieldinQuotes Conversion runConversion RowParserRPunRPRowrow rowresult ConnectInfo connectHost connectPort connectUserconnectPasswordconnectDatabase FormatError fmtMessagefmtQuery fmtParams QueryError qeMessageqeQuerySqlErrorsqlState sqlExecStatus sqlErrorMsgsqlErrorDetail sqlErrorHint ConnectionconnectionHandleconnectionObjectsconnectionTempNameCounter TypeInfoCacheFieldresultcolumntypeOid fatalErrordefaultConnectInfoconnectconnectPostgreSQL connectdbpostgreSQLConnectionStringoid2intexecexecute_ finishExecutethrowResultErrordisconnectedErrorwithConnectionclosenewNullConnection liftRowParserliftConversion conversionMapconversionError newTempNamefdError libPQErrorthrowLibPQErrorfmtError fmtErrorBsquote buildAction checkError escapeWrapescapeStringConnescapeIdentifierescapeByteaConnloCreatloCreateloImportloImportWithOidloExportloOpenloWriteloReadloSeekloTell loTruncateloCloseloUnlink NotificationnotificationPidnotificationChannelnotificationDatagetNotificationgetNotificationNonBlocking getBackendPIDConstraintViolationExclusionViolationCheckViolationUniqueViolationForeignKeyViolationNotNullViolationconstraintViolationconstraintViolationEcatchViolationisSerializationErrorisNoActiveTransactionErrorisFailedTransactionErrorTransactionModeisolationLevel readWriteModeReadOnly ReadWriteDefaultReadWriteModeIsolationLevel SerializableRepeatableRead ReadCommittedDefaultIsolationLeveldefaultTransactionModedefaultIsolationLeveldefaultReadWriteModewithTransactionwithTransactionSerializablewithTransactionLevelwithTransactionModewithTransactionModeRetryrollbackbegin beginLevel beginMode withSavepoint newSavepointreleaseSavepointrollbackToSavepointrollbackToAndReleaseSavepointexecutequery_query getTypeInfo fromField FieldParser ResultErrorConversionFailedUnexpectedNull Incompatible errSQLTypeerrSQLTableOid errSQLFielderrHaskellType errMessagetypenametypeInfo typeInfoByOidtableOid tableColumnformat optionalFieldpgArrayFieldParser fromJSONField returnError HStoreMap fromHStoreMap HStoreListfromHStoreList HStoreText ToHStoreText toHStoreText HStoreBuilderCommaEmptyToHStoretoHStore toBuildertoLazyByteStringhstoreparseHStoreList parseHStoreparseHStoreKeyValparseHStoreTextPGRange RangeBound Exclusive Inclusiveempty isEmptyByisEmptycontains containsByfromRow fieldWithfieldnumFieldsRemaining FoldOptions fetchQuantitytransactionMode FetchQuantityFixed Automatic formatQuery formatMany returningWith queryWith queryWith_foldfoldWithdefaultFoldOptionsfoldWithOptionsfoldWithOptionsAndParserfold_ foldWith_foldWithOptions_foldWithOptionsAndParser_forEach forEachWithforEach_ forEachWith_ CopyOutResult CopyOutDone CopyOutRowcopycopy_ getCopyData putCopyData putCopyEnd putCopyError$fEqOk$fExceptionManyErrors $fMonadOk $fMonadPlusOk$fAlternativeOk$fApplicativeOkmaskGHC.IO toByteStringtoPicofromPico Data.Monoid<>unsafeDupablePerformIOscientific-0.3.3.8!Data.Text.Lazy.Builder.ScientificscientificBuilder Data.StringIsStringbytestring-0.10.0.2Data.ByteString.Internal ByteString$fIsStringQualifiedIdentifier$fHashableQualifiedIdentifier$fHashableIdentifier $fMonoidQuery$fIsStringQuery $fReadQuery $fShowQuery$fEqNullghc-prim GHC.TypesBool inlineTypoidP getTypoidsqlExp minimizeSpaceday twoDigits timeOfDaysecondstimeZone Data.MaybeNothing timeZoneHMS localTimeutcTime zonedTime UTCOffsetHMSutcliftBdigitdigits2digits3digits4fracyearnominalDiffTime getUnbounded$fReadUnbounded$fShowUnbounded aeson-0.7.0.6Data.Aeson.Types.InternalValueData.Aeson.Types.ClasstoJSON renderNullinterleaveFoldr$fToFieldValues$fToFieldValue $fToFieldUUID$fToFieldVector$fToFieldPGArray$fToFieldNominalDiffTime$fToFieldUnbounded$fToFieldUnbounded0$fToFieldUnbounded1$fToFieldUnbounded2$fToFieldTimeOfDay $fToFieldDay$fToFieldLocalTime$fToFieldZonedTime$fToFieldUTCTime $fToFieldText $fToField[]$fToFieldText0$fToFieldByteString$fToFieldByteString0$fToFieldQualifiedIdentifier$fToFieldIdentifier$fToFieldBinary$fToFieldBinary0$fToFieldScientific$fToFieldDouble$fToFieldFloat $fToFieldOid$fToFieldWord64 $fToFieldWord$fToFieldWord32$fToFieldWord16$fToFieldWord8$fToFieldInteger$fToFieldInt64 $fToFieldInt$fToFieldInt32$fToFieldInt16 $fToFieldInt8 $fToFieldBool$fToFieldDefault $fToFieldNull $fToFieldIn$fToFieldMaybe$fToFieldAction $fShowActionGToRowgtoRow $fGToRowU1 $fGToRowK1 $fGToRow:*: $fGToRowM1 $fToRow:. $fToRow[]$fToRow(,,,,,,,,,)$fToRow(,,,,,,,,)$fToRow(,,,,,,,)$fToRow(,,,,,,)$fToRow(,,,,,) $fToRow(,,,,) $fToRow(,,,) $fToRow(,,) $fToRow(,) $fToRowOnly $fToRow()$fMonadPlusConversion$fMonadConversion$fAlternativeConversion$fApplicativeConversion$fFunctorConversion$fExceptionFormatError$fExceptionQueryError$fExceptionSqlError$fEqConnectionliftPQSystem.Posix.TypesCPid convertNotice scanTillQuoteparseQ1parseQ2 parseMaybe isSqlState$fExceptionConstraintViolation getTypeInfo' getAttInfosResultData.Aeson.Types.InstancesfromJSONData.Typeable.InternalTypeableMaybeJust Data.Functor<$>$fFromFieldMVarGHC.MVarMVar$fFromFieldIORef GHC.IORefIORef$fFromFieldValue$fFromFieldUUID$fFromFieldPGArray$fFromFieldEither Data.EitherRight$fFromFieldUnbounded$fFromFieldUnbounded0$fFromFieldUnbounded1$fFromFieldUnbounded2$fFromFieldTimeOfDay$fFromFieldDay$fFromFieldLocalTime$fFromFieldZonedTime$fFromFieldUTCTime $fFromField[] $fFromFieldCI$fFromFieldCI0$fFromFieldText$fFromFieldText0$fFromFieldBinary$fFromFieldBinary0$fFromFieldByteString$fFromFieldOid$fFromFieldByteString0$fFromFieldScientific$fFromFieldRatio$fFromFieldDoubleattoparsec-0.13.0.1 Data.Attoparsec.ByteString.Char8doubleData.Scientific ScientificGHC.RealRational$fFromFieldFloat$fFromFieldInteger$fFromFieldInt64$fFromFieldInt$fFromFieldInt32$fFromFieldInt16$fFromFieldChar$fFromFieldBool$fFromFieldNull$fFromFieldMaybe $fFromField()CompatleftunBinary pg_double pg_rational unescapeByteaff fromArrayokTextokText'okBinaryok16ok32ok64okInt doFromFieldatto$fFromFieldMVector$fFromFieldVector$fExceptionResultError$fFromFieldHStoreList$fToHStoreHStoreList$fToHStoreTextByteString$fToHStoreTextByteString0 escapeAppendskipWhiteSpaceparseHStoreTexts$fFromFieldHStoreMap$fToFieldHStoreMap$fToHStoreHStoreMap$fToFieldHStoreList$fToFieldHStoreBuilder$fToHStoreTextText$fToHStoreTextText0$fToHStoreTextHStoreText$fMonoidHStoreBuilder$fToHStoreHStoreBuilderTrueFalsepgrange doubleQuotedrangeToBuilderBy lowerBound upperBound rangeElemrangeToBuilder cmpZonedTimecmpZonedTimestamp$fToFieldPGRange$fToFieldPGRange0$fToFieldPGRange1$fToFieldPGRange2$fToFieldPGRange3$fToFieldPGRange4$fToFieldPGRange5$fToFieldPGRange6$fToFieldPGRange7$fToFieldPGRange8$fToFieldPGRange9$fToFieldPGRange10$fToFieldPGRange11$fToFieldPGRange12$fToFieldPGRange13$fToFieldPGRange14$fToFieldPGRange15$fToFieldPGRange16$fToFieldPGRange17$fToFieldPGRange18$fToFieldPGRange19$fToFieldPGRange20$fToFieldPGRange21$fToFieldPGRange22$fFromFieldPGRange $fEqPGRangeGFromRowgfromRowgetvaluenfieldsgetTypeInfoByColgetTypenameByColellipsisnull $fGFromRowU1 $fGFromRowK1 $fGFromRow:*: $fGFromRowM1 $fFromRow:.$fFromRowMaybe$fFromRowVector$fFromRowMaybe0 $fFromRow[]$fFromRowMaybe1$fFromRow(,,,,,,,,,)$fFromRowMaybe2$fFromRow(,,,,,,,,)$fFromRowMaybe3$fFromRow(,,,,,,,)$fFromRowMaybe4$fFromRow(,,,,,,)$fFromRowMaybe5$fFromRow(,,,,,)$fFromRowMaybe6$fFromRow(,,,,)$fFromRowMaybe7$fFromRow(,,,)$fFromRowMaybe8 $fFromRow(,,)$fFromRowMaybe9 $fFromRow(,)$fFromRowMaybe10 $fFromRowOnly parseTemplate buildQuerydoFoldforM'foldM'finishQueryWith getRowWithdoCopydoCopyIngetCopyCommandTagconsumeResults