p      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^ _ ` 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 { | } ~     experimental&Leon P Smith <leon@melding-monads.com> Safe-Infered2 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) AThis quasiquoter attempts to mimimize whitespace; otherwise the F above query would consist of approximately half whitespace when sent  to the database backend. 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), C the extended escape string syntax, 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. portable experimental&Leon P Smith <leon@melding-monads.com>None>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 mostly-binary string to be escaped in hexadecimal. $Wrap a list of values for use in an IN clause. Replaces a  single "?"1 character with a parenthesized list of rendered  values.  Example: = query c "select * from whatever where id in ?" (In [3,4,5]) 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 SQL NULL value.    portable experimental&Leon P Smith <leon@melding-monads.com> Safe-Infered>A type that may be used as a single parameter to a SQL query. 6Prepare a value for substitution into a query string. <How to render an element when substituting it into a query. !+Concatenate a series of rendering actions. ">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 "'". $0Surround a string with single-quote characters: "'" This function does not perform any other escaping. % !"#$ !"#$ #"!$! #"!$portable experimental&Leon P Smith <leon@melding-monads.com> Safe-Infered%>A collection type that can be turned into a list of rendering   s. Instances should use the render method of the Param class : to perform conversion of each element of the collection. & ToField a collection of values. %&     %&%& %&      Safe-Infered '()*+'()*+*+')(')(*+  Safe-InferedLike /, 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> Safe-Infered2,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]2,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]2,YXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-Z[\],-YXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-Z[\] portable experimental&Leon P Smith <leon@melding-monads.com>Noney5A 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 1Default 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" } BConnect with the given username to the given database. Will throw & an exception if it cannot connect. AAttempt to make a connection based on a libpq connection string.  See  <http://www.postgresql.org/docs/9.1/static/libpq-connect.html  for more information. Turns a f0 data structure into a libpq connection string. HAtomically perform an action with the database handle, if there is one. 2^_`abcdefghijklmnopqrstuvwxyz{|}~1^_`abcdefghijklmnopqrstuvwxyz{|}~1yz{|}~uvwxrtsmnopqfghijklabcde^_`^_`abcdefghijklmnopqrtsuvwxyz{|}~portable experimental&Leon P Smith <leon@melding-monads.com> Safe-Infered.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. Implementations of % should not retain any references to  the y nor the  arguments after the result has = been evaluated to WHNF. Such a reference causes the entire  LibPQ. to be retained. For example, the instance for  uses  to avoid @ such a reference, and that using bytestring functions such as    and !+ alone will also trigger this memory leak. =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. #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. ""#$%&'()*+,-./0123456789 y}~y}}~  "#$%&'()*+,-./0123456789 portable experimental&Leon P Smith <leon@melding-monads.com> Safe-InferedCA 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. HNote that instances can defined outside of postgresql-simple, which is " often useful. For example, here''s an instance for a user-defined pair:  6data 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  evaluates it'+s result to WHNF, so the caveats listed in H previous versions of postgresql-simple no longer apply. Instead, look @ at the caveats associated with user-defined implementations of . :;<=>?@ABCDE^^:;<=>?@ABCDEleon@melding-monads.com Safe-Infered     experimentalleon@melding-monads.com Safe-Infered portable experimental&Leon P Smith <leon@melding-monads.com> Safe-Infered'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 . :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  >http://www.postgresql.org/docs/9.1/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 . Exception thrown if  is used to perform an INSERT-like  operation, or  is used to perform a SELECT-like operation. 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. 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 u. 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 an INSERT, UPDATE!, or other SQL query that is not  expected to return results. %Returns the number of rows affected. Throws 0 if the query could not be formatted correctly.  A version of + that does not perform query substitution. Execute a multi-row INSERT, UPDATE!, or other SQL query that is not  expected to return results. %Returns the number of rows affected. Throws 0 if the query could not be formatted correctly.  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.  A version of + that does not perform query substitution.  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. 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.  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. ,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. IExecute an action inside a SQL transaction with a given isolation level. JExecute an action inside a SQL transaction with a given transaction mode. 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 6Query. #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. FGRfghijklmnopquXfghijklumnopq"FGH !!"#$$%%&&'(()**+,-./012344566789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ![\]^_`abcdef g h i j j k l m n n o p q r s t t u v w x y z { { | } ~ ~                                  !"!#$%&'()*+,-./0123456789:;<= > ? @ A B C D E F G H I J KLpostgresql-simple-0.1'Database.PostgreSQL.Simple.LargeObjects$Database.PostgreSQL.Simple.FromField Database.PostgreSQL.Simple.Types Database.PostgreSQL.Simple.SqlQQ"Database.PostgreSQL.Simple.ToField Database.PostgreSQL.Simple.ToRowDatabase.PostgreSQL.Simple.Ok'Database.PostgreSQL.Simple.BuiltinTypes#Database.PostgreSQL.Simple.Internal"Database.PostgreSQL.Simple.FromRow'Database.PostgreSQL.Simple.NotificationDatabase.PostgreSQL.Simple!Database.PostgreSQL.Simple.CompatBasecommitbase GHC.IO.Device AbsoluteSeek RelativeSeek SeekFromEndSeekMode GHC.IO.IOModeReadMode WriteMode AppendMode ReadWriteModeIOModepostgresql-libpq-0.8.1Database.PostgreSQL.LibPQTextBinaryFormatOidLoFdsql:.InOnlyfromOnlyQuery fromQueryNullToFieldtoFieldActionManyEscapePlaininQuotesToRowtoRowOkErrors ManyErrors BuiltinTypeVoidRecord RefcursorNumericVarbitBitTimeWithTimeZoneIntervalTimestampWithTimeZone TimestampTimeDateVarcharBpcharInetMacaddrMoneyCircleUnknown TintervalReltimeAbstimeFloat8Float4CidrLinePolygonBoxPathLsegPointXmlCidXidTidRegprocInt4Int2Int8NameCharByteaBool builtin2oid oid2builtinbuiltin2typname oid2typname RowParserRPunRPRowrow typenames rowresult ConnectInfo connectHost connectPort connectUserconnectPasswordconnectDatabaseSqlErrorsqlStatesqlNativeError sqlErrorMsgSqlTypeOtherBuiltin ConnectionconnectionHandleconnectionObjectsFieldresultcolumntypenamenametableOid tableColumnformattypeOiddefaultConnectInfoconnectconnectPostgreSQLpostgreSQLConnectionStringoid2intexecdisconnectedErrorwithConnectionclosenewNullConnectiongetvaluenfields FromField fromField ResultErrorConversionFailedUnexpectedNull Incompatible errSQLTypeerrHaskellType errMessage returnErrorFromRowfromRowfieldnumFieldsRemainingloCreatloCreateloImportloImportWithOidloExportloOpenloWriteloReadloSeekloTell loTruncateloCloseloUnlink NotificationnotificationPidnotificationChannelnotificationDatagetNotificationTransactionModeisolationLevel readWriteModeReadOnly ReadWriteDefaultReadWriteModeIsolationLevel SerializableRepeatableRead ReadCommittedDefaultIsolationLevel FoldOptions fetchQuantitytransactionMode FetchQuantityFixed Automatic QueryError qeMessageqeQuery FormatError fmtMessagefmtQuery fmtParams formatQuery formatManyexecuteexecute_ executeManyqueryquery_folddefaultFoldOptionsfoldWithOptionsfold_foldWithOptions_forEachforEach_defaultTransactionModedefaultIsolationLeveldefaultReadWriteModewithTransactionwithTransactionLevelwithTransactionModerollbackbegin beginLevel beginMode Data.StringIsStringbytestring-0.9.2.1Data.ByteString.Internal ByteString $fMonoidQuery$fIsStringQuery $fReadQuery $fShowQuery$fEqNull$fToFieldTimeOfDay $fToFieldDay$fToFieldUTCTime $fToFieldText $fToField[]$fToFieldText0$fToFieldByteString$fToFieldByteString0$fToFieldDouble$fToFieldFloat $fToFieldOid$fToFieldWord64 $fToFieldWord$fToFieldWord32$fToFieldWord16$fToFieldWord8$fToFieldInteger$fToFieldInt64 $fToFieldInt$fToFieldInt32$fToFieldInt16 $fToFieldInt8 $fToFieldBool $fToFieldNull$fToFieldBinary$fToFieldBinary0 $fToFieldIn$fToFieldMaybe$fToFieldAction $fShowAction $fToRow[]$fToRow(,,,,,,,,,)$fToRow(,,,,,,,,)$fToRow(,,,,,,,)$fToRow(,,,,,,)$fToRow(,,,,,) $fToRow(,,,,) $fToRow(,,,) $fToRow(,,) $fToRow(,) $fToRowOnly $fToRow() $fMonadOk $fMonadPlusOk$fAlternativeOk$fApplicativeOk$fEqOk$fExceptionManyErrorsmaskGHC.IO$fExceptionSqlErrorResultData.ByteStringcopydropData.ByteString.Char8 takeWhile$fFromFieldEither$fFromFieldTimeOfDay$fFromFieldDay$fFromFieldUTCTime $fFromField[]$fFromFieldText$fFromFieldText0$fFromFieldBinary$fFromFieldBinary0$fFromFieldByteString$fFromFieldOid$fFromFieldByteString0$fFromFieldRatio$fFromFieldDouble$fFromFieldFloat$fFromFieldInteger$fFromFieldInt64$fFromFieldInt$fFromFieldInt32$fFromFieldInt16$fFromFieldBool$fFromFieldNull$fFromFieldMaybe$fExceptionResultError $fFromRow:. $fFromRow[]$fFromRow(,,,,,,,,,)$fFromRow(,,,,,,,,)$fFromRow(,,,,,,,)$fFromRow(,,,,,,)$fFromRow(,,,,,)$fFromRow(,,,,)$fFromRow(,,,) $fFromRow(,,) $fFromRow(,) $fFromRowOnly$fExceptionQueryError$fExceptionFormatError