maF      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRS TUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~         !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~(c) 2013 Leon P SmithBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone $JKeA structure representing some of the metadata regarding a PostgreSQL type, mostly taken from the pg_type table. !"#$%&'( !"#$%&'($" %&'(%&'(#%&'(!%&'((c) 2012 Leon P SmithBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone $+JK*p assumes its input is in the range [0..9].pad2 assumes its input is in the range [0..99]"pad4 assumes its input is positive:)*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQR8)*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQR7)*+,-.10/23456789:;<=>?@ABCDEFGHIJKLMNOPQR(c) 2012 Leon P SmithBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone $JK );<=>?@ABCDEF ;<=>?@CDEF)AB (c) 2011-2012 Leon P SmithBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone $JKSSv is a quasiquoter that eases the syntactic burden of writing big sql statements in Haskell source code. For example: O{-# LANGUAGE QuasiQuotes #-} query conn [sql| SELECT column_a, column_b FROM table1 NATURAL JOIN table2 WHERE ? <= time AND time < ? AND name LIKE ? ORDER BY size DESC LIMIT 100 |] (beginTime,endTime,string)This quasiquoter attempts to mimimize whitespace; otherwise the above query would consist of approximately half whitespace when sent to the database backend. It also recognizes and strips out standard sql comments "--".The implementation of the whitespace reducer is currently incomplete. Thus it can mess up your syntax in cases where whitespace should be preserved as-is. It does preserve whitespace inside standard SQL string literals. But it can get confused by the non-standard PostgreSQL string literal syntax (which is the default setting in PostgreSQL 8 and below), the extended escape string syntax, quoted identifiers, and other similar constructs.Of course, this caveat only applies to text written inside the SQL 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.SSSS(c) 2012 Leon P SmithBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone $JK*+,-./0123456789:GHIJKLMNOPQR.10/*,+-52346:789GJKLHIQNOPMR(c) 2011-2012 Leon P SmithBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone $JK1TUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~> !"#$%&'(TUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~J$" %&'(%&'(#%&'(!%&'(TUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~1TUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ (c) 2011-2012 Leon P SmithBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone $+JKe     5550      (c) 2012 Leon P SmithBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone $FJKDParse one of three primitive field formats: array, quoted and plain.Recognizes a quoted string.sRecognizes a plain string literal, not containing quotes or brackets and not containing the delimiter character.]Format an array format item, using the delimiter character if the item is itself an array.Format a list of array format items, inserting the appropriate delimiter between them. When the items are arrays, they will be delimited with commas; otherwise, they are delimited with the passed-in-delimiter.Format an array format item, using the delimiter character if the item is itself an array, optionally applying quoting rules. Creates copies for safety when used in  FromField instances.BEscape a string according to Postgres double-quoted string format. @(c) 2011 MailRank, Inc. (c) 2011-2012 Leon P SmithBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone  $+-BJK  Represents a VALUES0 table literal, usable as an alternative to  executeMany and  returningM. 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 and some attributes of that thing into another, returning the new id generated by the database: query c [sql| WITH new_thing AS ( INSERT INTO thing (name) VALUES (?) RETURNING id ), new_attributes AS ( INSERT INTO thing_attributes SELECT new_thing.id, attrs.* FROM new_thing JOIN ? attrs ) SELECT * FROM new_thing |] ("foo", Values [ "int4", "text" ] [ ( 1 , "hello" ) , ( 2 , "world" ) ])b(Note this example uses writable common table expressions, which were added in PostgreSQL 9.1)AThe second parameter gets expanded into the following SQL syntax: 0(VALUES (1::"int4",'hello'::"text"),(2,'world'))GWhen 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. This behavior is usually correct given their intended use cases, but would certainly be wrong in the example above.The first argument is a list of postgresql type names. Because this 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, _int8 instead of bigint[] , etcetera.You may omit the type names, however, if you do so the list of values must be non-empty, and postgresql must be able to infer the types of the columns from the surrounding context. If the first condition is not met, postgresql-simple will throw an exception without issuing the query. In the second case, the postgres server will return an error which will be turned into a SqlError exception.See  9http://www.postgresql.org/docs/9.3/static/sql-values.html for more information.rA composite type to parse your custom data structures without having to define dummy newtype wrappers every time. !instance FromRow MyData where ... "instance FromRow MyData2 where ...%then I can do the following for free: Kres <- query' c "..." forM res $ \(MyData{..} :. MyData2{..}) -> do .... *Wrap a list for use as a PostgreSQL array.cWrap text for use as (maybe) qualified identifier, i.e. a table with schema, or column with table.AWrap 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 "?:" character with a parenthesized list of rendered values.Example: Bquery c "select * from whatever where id in ?" (Only (In [3,4,5]))A single-value "collection".vThis is useful if you need to supply a single parameter to a SQL query, or extract a single column from a SQL result.Parameter example: ,query c "select x from scores where x > ?" ( (42::Int))Result example: 3xs <- query_ c "select id from users" forM_ xs $ \( id) -> {- ... -}A query string. This type is intended to make it difficult to construct a SQL query by concatenating string fragments, as that is 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 OverloadedStringsF 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 g, and literal Haskell strings 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 only examines the first period character, and thus cannot be used if the qualifying identifier contains a period for example.%   (c) 2013 Leon P SmithBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone $JK$Returns an expression that has type   -> 1, 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  5. Useful because GHC tends not to fold constants. @(c) 2011 MailRank, Inc. (c) 2011-2012 Leon P SmithBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone  $+-24JK =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.lEscape 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.ZRender without escaping or quoting. Use for non-text types such as numbers, when you are certaind that they will not introduce formatting vulnerabilities via use of characters such as spaces or "'".5Prepare a value for substitution into a query string."Convert a Haskell value to a JSON  using # and convert that to a field using .7This can be used as the default implementation for the J method for Haskell types that have a JSON representation in PostgreSQL.1Surround a string with single-quote characters: "'"This function does not perform any other escaping.: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO 4 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO@(c) 2011 MailRank, Inc. (c) 2011-2012 Leon P SmithBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone $JK?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.ToField a collection of values.PQRSTUVWXYZ[\PQRSTUVWXYZ[\(c) 2012 Leon P SmithBSD3leon@melding-monads.com experimental Safe-Inferred $+-JK;a way to reify a list of exceptions into a single exceptionTwo U cases are considered equal, regardless of what the list of exceptions looks like.  (c) 2011-2012 Leon P SmithBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone  $+BJK  Exception thrown if query is used to perform an INSERT-like operation, or execute is used to perform a SELECT-like operation.4A Field represents metadata about a particular fieldYou don't particularly want to retain these structures for a long period of time, as they will retain the entire query result, not just the field metadata"OThis returns the type oid associated with the column. Analogous to libpq's PQftype.$0Default information for setting up a connection.Defaults are as follows: Server on  localhostPort on 5432User postgres No password Database postgres Use as in the following example: =connect defaultConnectInfo { connectHost = "db.example.com" }%gConnect with the given username to the given database. Will throw an exception if it cannot connect.&HAttempt to make a connection based on a libpq connection string. See  <http://www.postgresql.org/docs/9.3/static/libpq-connect.html` for more information. 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:54326. Omitting the port will normally default to 5432.On systems that provide unix domain sockets, omitting the host parameter will cause libpq to attempt to connect via unix domain sockets. 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.h? header file. Connecting via unix sockets tends to use the peerP authentication method, which is very secure and does not require a password._On Windows and other systems without unix domain sockets, omitting the host will default to  localhost. @... dbname='postgres' user='postgres' password='secret \' \\ pw'-This attempts to connect to a database named postgres with user postgres and password  secret ' \ pwm. Backslash characters will have to be double-quoted in literal Haskell strings, of course. Omitting dbname and userS will both default to the system username that the client process is running as. Omitting password9 will default to an appropriate password found in the pgpassK file, or no password at all if a matching line is not found. See  ;http://www.postgresql.org/docs/9.3/static/libpq-pgpass.html- for more information regarding this file.As all parameters are optional and the defaults are sensible, the empty connection string can be useful for development and exploratory use, assuming your system is set up appropriately.On Unix, such a setup would typically consist of a local postgresql server listening on port 5432, as well as a system user, 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 or production machines, or you will need to use a pgpass file with the password or md5 authentication methods.See  Dhttp://www.postgresql.org/docs/9.3/static/client-authentication.html> for more information regarding the authentication process.(Turns a / data structure into a libpq connection string.+ A version of execute* that does not perform query substitution./GAtomically perform an action with the database handle, if there is one.E      !"#$%&'()*+,-./0123456789:;<=>?@>      !"#$%&'()*+,-./0123456789E !"#@ ?    $%&'()*+,-./0123>=<;:456789'      !"#$%&'()*+,-./0123456789:;<=>?@(c) 2011-2012 Leon P SmithBSD3leon@melding-monads.comNone $JK]ABCDEFGHIJKLM ABCDEFGHIJKLMABCDEFGHIJKLM ]ABCDEFGHIJKLM(c) 2011-2012 Leon P SmithBSD3leon@melding-monads.com experimentalNone  $JKSGReturns a single notification. If no notifications are available, S blocks until one arrives.TNon-blocking variant of S`. Returns a single notification, if available. If no notifications are available, returns ^.UReturns the process _9 of the backend server process handling this connection.The backend PID is useful for debugging purposes and for comparison to NOTIFY messages (which include the PID of the notifying backend process). Note that the PID belongs to a process executing on the database server host, not the local host! NOPQR`STUNOPQRSTUNOPQRSTUNOPQR`STU((c) 2012-2013 Leonid Onokhov, Joey AdamsBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone  $+JKW.Relation name (usually table), constraint nameXName of violated constraintY*Table name and name of violated constraintZThe field is a column name[Tries to convert  to ConstrainViolationC, checks sqlState and succeedes only if able to parse sqlErrorMsg. createUser = catchJust constraintViolation catcher $ execute conn ... where catcher UniqueViolation "user_login_key" = ... catcher _ = ...\;Like constraintViolation, but also packs original SqlError. createUser = catchJust constraintViolationE catcher $ execute conn ... where catcher (_, UniqueViolation "user_login_key") = ... catcher (e, _) = throwIO e]zCatches SqlError, tries to convert to ConstraintViolation, re-throws on fail. Provides alternative interface to catchJust createUser = catchViolation catcher $ execute conn ... where catcher _ (UniqueViolation "user_login_key") = ... catcher e _ = throwIO eVWXYZ[\]abcd^_`ef VWXYZ[\]^_` VZYXW[\]^_` VZYXW[\]abcd^_`efNone $JKgLike h., but backported to base before version 4.3.0.9Note that the restore callback is monomorphic, unlike in h{. This could be fixed by changing the type signature, but it would require us to enable the RankNTypes extension (since h has a rank-3 type). The withTransactionModeT function calls the restore callback only once, so we don't need that polymorphism.gijggNone $JKjIthe read-write mode will be taken from PostgreSQL's per-connection default_transaction_read_onlyi variable, which is initialized according to the server's config. The default configuration is i.kOf the four isolation levels defined by the SQL standard, these are the three levels distinguished by PostgreSQL as of version 9.0. See  >http://www.postgresql.org/docs/9.1/static/transaction-iso.html= for more information. Note that prior to PostgreSQL 9.0, m was equivalent to l.oIthe isolation level will be taken from PostgreSQL's per-connection default_transaction_isolationi variable, which is initialized according to the server's config. The default configuration is n.s+Execute an action inside a SQL transaction..This function initiates a transaction with a "begin transactionr" statement, then executes the supplied action. If the action succeeds, the transaction will be completed with  before this function returns.If the action throws anyj kind of exception (not just a PostgreSQL-related exception), the transaction will be rolled back using x&, then the exception will be rethrown.For nesting transactions, see }.tExecute an action inside of a l transaction. If a serialization failure occurs, roll back the transaction and try again. Be warned that this may execute the IO action multiple times.A l transaction creates the illusion that your program has exclusive access to the database. This means that, even in a concurrent setting, you can perform queries in sequence without having to worry about what might happen between one statement and the next. Think of it as STM, but without retry.uHExecute an action inside a SQL transaction with a given isolation level.vIExecute an action inside a SQL transaction with a given transaction mode.wLike vZ, but also takes a custom callback to determine if a transaction should be retried if an  occurs. 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 t.xRollback a transaction.yCommit a transaction.zBegin a transaction.{0Begin a transaction with a given isolation level|1Begin a transaction with a given transaction mode}Create a savepoint, and roll back to it if an error occurs. This may only be used inside of a transaction, and provides a sort of "nested transaction".See @http://www.postgresql.org/docs/current/static/sql-savepoint.html~GCreate 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 `2 if the transaction is aborted due to an error. y" 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 2, but avoids a round trip to the database server.cdefghijklmnopqrstuvwxyz{|}~#^_`cdefghijklmnopqrstuvwxyz{|}~#suvwtcdefkonmlgjihpqrz{|yx}~^_`cdefgjihkonmlpqrstuvwxyz{|}~(c) 2013 Leon P SmithBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone $JKOReturns the metadata of the type with a particular oid. To find this data, 0 first consults postgresql-simple's built-in TU table, then checks the connection's typeinfo cache. Finally, the database's pg_typej table will be queried only if necessary, and the result will be stored in the connections's cache.kl !"#$%&'($" %&'(%&'(#%&'(!%&'(kl?(c) 2011 MailRank, Inc. (c) 2011-2013 Leon P SmithBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone $+-24FJKM4a-A type that may be converted from a SQL type.'Convert a SQL value to a Haskell value.yReturns a list of exceptions if the conversion fails. In the case of 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.m, to be retained. Thus, implementations of e 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.m before it has been passed to b. This is because for short strings, it's cheaper to copy the string than to set up a finalizer.JException thrown if conversion from a SQL value to a Haskell value fails.The SQL value could not be parsed, or could not be represented as a valid Haskell value, or an 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.Returns the data type name. This is the preferred way of identifying 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, postgresql-simple will check a per-connection cache, and then finally query the database's meta-schema.pReturns 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 table2 associated with the column, if any. Returns ^ when there is no such table; for example a computed column does not have a table associated with it. Analogous to libpq's PQftable.If the column has a table associated with it, this returns the number off the associated table column. Numbering starts from 0. Analogous to libpq's  PQftablecol.bThis returns whether the data was returned in a binary or textual format. Analogous to libpq's  PQfformat.Parse a field to a JSON . and convert that into a Haskell value using n.7This can be used as the default implementation for the J method for Haskell types that have a JSON representation in PostgreSQL.The oT constraint is required to show more informative error messages when parsing fails.#Given one of the constructors from , the field, and an v, this fills in the other fields in the exception value and returns it in a 'Left . SomeException' constructor.p)Compatible with the same set of types as a. Note that modifying the qM does not have any effects outside the local process on the local machine.r)Compatible with the same set of types as a. Note that modifying the sM does not have any effects outside the local process on the local machine.tjsonuuuidv=any postgresql array whose elements are compatible with type aw1Compatible with both types. Conversions to type b+ are preferred, the conversion to type a will be tried after the x conversion fails.ydatez timestamp{ timestamptz| timestamptz}time~date timestamp timestamptz timestamptz#name, text, "char", bpchar, varcharcitextcitext#name, text, "char", bpchar, varchar#name, text, "char", bpchar, varcharbyteabytea3bytea, name, text, "char", bpchar, varchar, unknownoid3bytea, name, text, "char", bpchar, varchar, unknown#int2, int4, float4, float8, numeric#int2, int4, 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, int8int2, int4, int8fint2, int4, and if compiled as 64-bit code, int8 as well. This library was compiled as 64-bit code. int2, int4int2"char"bool:compatible with any data type, but the value must be null[For dealing with null values. Compatible with any postgresql type compatible with type au. Note that the type is not checked if the value is null, although it is inadvisable to rely on this behavior.voidPaprtuvwyz{|}~1  !"#$%&'("45aIa45"$" %&'(%&'(#%&'(!%&'(" Gaprtuvwyz{|}~(c) 2013 Leon P SmithBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone  $+BJKFRepresents escape text, ready to be the key or value to a hstore valueRepresents valid hstore syntax.hstorehstoreAssumed to be UTF-8 encodedAssumed to be UTF-8 encoded'(c) 2013 Leon P SmithBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone $JK(c) 2013 Leon P SmithBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone $JK(c) 2012 Leon P SmithBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone  $24JKbA collection type that can be converted from a sequence of fields. Instances are provided for tuples up to 10 elements and lists of any length.Note that instances can be defined outside of postgresql-simple, which is often useful. For example, here's an instance for a user-defined pair:6@data User = User { name :: String, fileQuota :: Int } instance b$ User where fromRow = User <$>  <*>  @The number of calls to _ must match the number of fields returned in a single row of the query result. Otherwise, a  exception will be thrown. Note that  evaluates it's result to WHNF, so the caveats listed in mysql-simple and very early versions of postgresql-simple no longer apply. Instead, look at the caveats associated with user-defined implementations of .$bbb#b@(c) 2011 MailRank, Inc. (c) 2011-2012 Leon P SmithBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone  $+FJKExecute a multi-row INSERT, UPDATE=, or other SQL query that is not expected to return results.Returns the number of rows affected. If the list of parameters is empty, 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 6 if the query could not be formatted correctly, or a + exception if the backend returns an error.TFor 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's 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 6 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.hWhen processing large results, this function will consume a lot of client-side memory. Consider using  instead.Exceptions that may be thrown:4: the query string could not be formatted correctly. >: the result contains no columns (i.e. you should be using  instead of ).: result conversion failed.t: the postgresql backend returned an error, e.g. a syntax or type error, or an incorrect table or column name.%Number of rows to fetch at a time.  currently defaults to 256 rows, although it might be nice to make this more intelligent based on e.g. the average size of the rows.Exception thrown if a E could not be formatted correctly. This may occur if the number of '?S' characters in the query string does not match the number of parameters provided.Format a query string.mThis function is exposed to help with debugging and logging. Do not use it to prepare queries for execution.LString parameters are escaped according to the character set in use on the .Throws 7 if the query string could not be formatted correctly.5Format a query string with a variable number of rows.mThis 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 7 if the query string could not be formatted correctly.Execute INSERT ... RETURNING, UPDATE ... RETURNING}, or other SQL query that accepts multi-row input and is expected to return results. Note that it is possible to write $ conn "INSERT ... RETURNING ..." ...c 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 []Z without issuing the query to the backend. If this is not desired, consider using the Values constructor instead.Throws / 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 results. Results are streamed incrementally from the server, and consumed via a left fold.PWhen dealing with small results, it may be simpler (and perhaps faster) to use  instead. This fold is notk strict. The stream consumer is responsible for forcing the evaluation of its result to avoid space leaks.This is implemented using a database cursor. As such, this requires a transaction. This function will detect whether or not there is a transaction in progress, and will create a n hn transaction if needed. The cursor is given a unique temporary name, so the consumer may itself call fold.Exceptions that may be thrown:4: the query string could not be formatted correctly. >: the result contains no columns (i.e. you should be using  instead of ).: result conversion failed.t: the postgresql backend returned an error, e.g. a syntax or type error, or an incorrect table or column name. defaults to , and c n h The same as ., but this provides a bit more control over lower-level details. Currently, the number of rows fetched per round-trip to the server and the transaction mode may be adjusted accordingly. If the connection is already in a transaction, then the existing transaction is used and thus the  option is ignored. A version of * that does not perform query substitution. A version of ' that does not transform a state value. 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 template.Query parameters.Result consumer.Query template.Result consumer.R     $%&(+0bsxyz}Xb &0%    $(+s}zyx!(c) 2013 Leon P SmithBSD3&Leon P Smith <leon@melding-monads.com> experimentalNone $+JK<No more rows, and a count of the number of rows returned.lData representing either exactly one row of the result, or header or footer data depending on format.Issue a COPY FROM STDIN or COPY TO STDOUTG query. In the former case, the connection's state will change to CopyIn; in the latter, CopyOutp. 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 STDOUTG query. In the former case, the connection's state will change to CopyIn; in the latter, CopyOutx. The connection must be in the ready state in order to call this function. Does not perform parameter subsitution.Retrieve some data from a COPY TO STDOUT) query. A connection must be in the CopyOut= state in order to call this function. If this returns a  , the connection remains in the CopyOut state, if it returns 9, then the connection has reverted to the ready state.Feed some data to a COPY FROM STDIN query. Note that 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 CopyIn7 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 STDIN1 query. Returns the number of rows processed.A connection must be in the CopyIn7 state in order to call this function, otherwise a j exception will result. The connection's state changes back to ready after this function is called. Aborts a COPY FROM STDINy query. The string parameter is simply an arbitrary error message that may show up in the PostgreSQL server's log.A connection must be in the CopyIn7 state in order to call this function, otherwise a j exception will result. The connection's state changes back to ready after this function is called.     !"#$%&%'%(%)*+,*+-*+.*+/*+/*+0*+1*+2*+3*+4*+5*+6*+7*+8*+9::;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrs tuvwxyz{|}~                K                        / ,            C --                !"#$%%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTTUVWXYZ[\]^_`abcdefghhij#klmnopqrstuvwxyz{|}~y   v w x y z { | } ~                                                 ! " # $%&'()*+,-./0123456789:;<=>?>?@ABCD*+EFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~postgresql-simple-0.4.8.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.Time.InternalDatabase.PostgreSQL.Simple.Time Database.PostgreSQL.Simple.SqlQQ'Database.PostgreSQL.Simple.BuiltinTypes!Database.PostgreSQL.Simple.Arrays)Database.PostgreSQL.Simple.TypeInfo.Macro"Database.PostgreSQL.Simple.ToField Database.PostgreSQL.Simple.ToRowDatabase.PostgreSQL.Simple.Ok#Database.PostgreSQL.Simple.Internal'Database.PostgreSQL.Simple.Notification!Database.PostgreSQL.Simple.Errors"Database.PostgreSQL.Simple.FromRow&Database.PostgreSQL.Simple.Transaction!Database.PostgreSQL.Simple.HStoreDatabase.PostgreSQL.Simple.Copy)Database.PostgreSQL.Simple.TypeInfo.Types.Database.PostgreSQL.Simple.Time.Implementation!Database.PostgreSQL.Simple.CompatBasecommit0Database.PostgreSQL.Simple.HStore.Implementation*Database.PostgreSQL.Simple.HStore.Internalbase GHC.IO.IOModeReadMode WriteMode AppendMode ReadWriteModeIOMode GHC.IO.Device AbsoluteSeek RelativeSeek SeekFromEndSeekModepostgresql-libpq-0.9.0.1Database.PostgreSQL.LibPQTextBinaryFormatOid EmptyQuery CommandOkTuplesOkCopyOutCopyIn BadResponse NonfatalError FatalError ExecStatusLoFd AttributeattnameatttypeTypeInfo Compositetyprelid attributesRange rngsubtypeArraytypelemBasictypoid typcategorytypdelimtypname TimeZoneHMSDateZonedTimestamp UTCTimestampLocalTimestamp Unbounded PosInfinityFinite NegInfinity parseUTCTimeparseZonedTimeparseLocalTimeparseDayparseTimeOfDayparseUTCTimestampparseZonedTimestampparseLocalTimestamp parseDategetDaygetDate getTimeOfDay getLocalTimegetLocalTimestamp getTimeZonegetTimeZoneHMSlocalToUTCTimeOfDayHMS getZonedTimegetZonedTimestamp getUTCTimegetUTCTimestamp dayToBuildertimeOfDayToBuildertimeZoneToBuilderutcTimeToBuilderzonedTimeToBuilderlocalTimeToBuilderunboundedToBuilderutcTimestampToBuilderzonedTimestampToBuilderlocalTimestampToBuilder dateToBuildernominalDiffTimeToBuildersqlstaticTypeInfoboolbyteacharnameint8int2int4regproctextoidtidxidcidxmlpointlsegpathboxpolygonlinecidrfloat4float8abstimereltime tintervalunknowncirclemoneymacaddrinetbpcharvarchardatetime timestamp timestamptzintervaltimetzbitvarbitnumeric refcursorrecordvoiduuidjsonjsonb BuiltinTypeJSONBJSONUUIDVoidRecord RefCursorNumericVarBitBitTimeTZInterval TimestampTZ TimestampTimeVarCharBpCharInetMacAddrMoneyCircleUnknown TIntervalRelTimeAbsTimeFloat8Float4CidrLinePolygonBoxPathLSegPointXmlCidXidTidRegProcInt4Int2Int8NameCharByteABool builtin2oid oid2builtinbuiltin2typname oid2typname ArrayFormatQuotedPlain arrayFormatarrayquotedplainfmtdelimitfmt'escValues Savepoint:.PGArray fromPGArrayQualifiedIdentifier IdentifierfromIdentifier fromBinaryInOnlyfromOnlyQuery fromQueryDefaultNull mkCompats inlineTypoidToFieldActionManyEscapeIdentifier EscapeByteAEscapeToRowtoRowtoField toJSONFieldinQuotes ManyErrorsOkErrors$fExceptionManyErrors $fMonadOk $fMonadPlusOk$fAlternativeOk$fApplicativeOk$fEqOk Conversion runConversion RowParserRPunRPRowrow rowresult ConnectInfo connectHost connectPort connectUserconnectPasswordconnectDatabase QueryError qeMessageqeQuerySqlErrorsqlState sqlExecStatus sqlErrorMsgsqlErrorDetail sqlErrorHint ConnectionconnectionHandleconnectionObjectsconnectionTempNameCounter TypeInfoCacheFieldresultcolumntypeOid fatalErrordefaultConnectInfoconnectconnectPostgreSQL connectdbpostgreSQLConnectionStringoid2intexecexecute_ finishExecutethrowResultErrordisconnectedErrorwithConnectionclosenewNullConnection liftRowParserliftConversion conversionMapconversionError newTempNamefdError libPQErrorthrowLibPQError$fMonadPlusConversion$fMonadConversion$fAlternativeConversion$fApplicativeConversion$fFunctorConversion$fExceptionQueryError$fExceptionSqlErrorloCreatloCreateloImportloImportWithOidloExportloOpenloWriteloReadloSeekloTell loTruncateloCloseloUnlink NotificationnotificationPidnotificationChannelnotificationDatagetNotificationgetNotificationNonBlocking getBackendPIDConstraintViolationCheckViolationUniqueViolationForeignKeyViolationNotNullViolationconstraintViolationconstraintViolationEcatchViolationisSerializationErrorisNoActiveTransactionErrorisFailedTransactionError FromFieldFromRowTransactionModeisolationLevel readWriteModeReadOnly ReadWriteDefaultReadWriteModeIsolationLevel SerializableRepeatableRead ReadCommittedDefaultIsolationLeveldefaultTransactionModedefaultIsolationLeveldefaultReadWriteModewithTransactionwithTransactionSerializablewithTransactionLevelwithTransactionModewithTransactionModeRetryrollbackbegin beginLevel beginMode withSavepoint newSavepointreleaseSavepointrollbackToSavepointrollbackToAndReleaseSavepoint executeManyexecutequery_query getTypeInfo fromField FieldParser ResultErrorConversionFailedUnexpectedNull Incompatible errSQLTypeerrSQLTableOid errSQLFielderrHaskellType errMessagetypenametypeInfo typeInfoByOidtableOid tableColumnformat fromJSONField returnError HStoreMap fromHStoreMap HStoreListfromHStoreList HStoreText ToHStoreText toHStoreText HStoreBuilderToHStoretoHStore toBuildertoLazyByteStringhstoreparseHStoreListfromRow fieldWithfieldnumFieldsRemaining FoldOptions fetchQuantitytransactionMode FetchQuantityFixed Automatic FormatError fmtMessagefmtQuery fmtParams formatQuery formatMany returning queryWith queryWith_folddefaultFoldOptionsfoldWithOptionsfold_foldWithOptions_forEachforEach_ CopyOutResult CopyOutDone CopyOutRowcopycopy_ getCopyData putCopyData putCopyEnd putCopyErrorppad2pad4++ getUnboundeddecimaltoNumdigitdigits showSecondspad6showD6pad3showD3$fReadUnbounded$fShowUnboundedsqlExp minimizeSpace Data.StringIsStringbytestring-0.10.4.0Data.ByteString.Internal ByteString$fIsStringQualifiedIdentifier$fHashableQualifiedIdentifier$fHashableIdentifier $fMonoidQuery$fIsStringQuery $fReadQuery $fShowQuery$fEqNullghc-prim GHC.Types inlineTypoidP getTypoid aeson-0.8.0.2Data.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 $fShowAction $fToRow:. $fToRow[]$fToRow(,,,,,,,,,)$fToRow(,,,,,,,,)$fToRow(,,,,,,,)$fToRow(,,,,,,)$fToRow(,,,,,) $fToRow(,,,,) $fToRow(,,,) $fToRow(,,) $fToRow(,) $fToRowOnly $fToRow()liftPQ Data.MaybeNothingSystem.Posix.TypesCPid convertNotice scanTillQuoteparseQ1parseQ2 parseMaybe isSqlState$fExceptionConstraintViolationmaskGHC.IOunsafeDupablePerformIO Data.Monoid<> getTypeInfo' getAttInfosResultData.Aeson.Types.InstancesfromJSONData.Typeable.InternalTypeable$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.12.1.2 Data.Attoparsec.ByteString.Char8doublescientific-0.3.3.2Data.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$fToHStoreTextByteString0CommaEmpty escapeAppend parseHStoreparseHStoreKeyValskipWhiteSpaceparseHStoreTextparseHStoreTexts$fFromFieldHStoreMap$fToFieldHStoreMap$fToHStoreHStoreMap$fToFieldHStoreList$fToFieldHStoreBuilder$fToHStoreTextText$fToHStoreTextText0$fToHStoreTextHStoreText$fMonoidHStoreBuilder$fToHStoreHStoreBuildergetvaluenfieldsgetTypeInfoByColgetTypenameByColellipsisnull $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 parseTemplateescapeStringConnescapeIdentifierescapeByteaConn escapeWrap checkError buildQuerydoFoldforM' finishQueryfinishQueryWithfmtError$fExceptionFormatErrordoCopydoCopyIngetCopyCommandTagconsumeResults