c      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~   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: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  method of the  class : to perform conversion of each element of the collection. $Render a collection of values. #$#$#$ #$ experimental&Leon P Smith <leon@melding-monads.com> Safe-Infered2%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV2%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV2%RQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&STUV%-RQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&STUVportable experimental&Leon P Smith <leon@melding-monads.com> Safe-Inferedn5A 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 x1Default 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" } yBConnect with the given username to the given database. Will throw & an exception if it cannot connect. zAAttempt 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 [0 data structure into a libpq connection string. HAtomically perform an action with the database handle, if there is one. ,WXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~+WXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~+nopqrstuvwjklmgihbcdef[\]^_`axyz{|}~WXYZWXYZ[\]^_`abcdefgihjklmnopqrstuvwxyz{|}~ Safe-Infered WXYZnrstuvwnrrstuvw WXYZ 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. >Returns an exception if the conversion fails. In the case of , library instances, this will usually be a  , but may  be a UnicodeException. =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. #             portable experimental&Leon P Smith <leon@melding-monads.com> Safe-Infered@A collection type that can be converted from a list of strings. Instances should use the  method of the  class : to perform conversion of each element of the collection. CThis example instance demonstrates how to convert a two-column row C into a Haskell pair. Each field in the metadata is paired up with 4 each value from the row, and the two are passed to .    instance ( a,  b) =>  (a,b) where   [fa,fb] [va,vb] = do  !a <-  fa va  !b <-  fb vb   (a,b)   fs vs =  fs vs 2 @Notice that this instance evaluates each element to WHNF before D constructing the pair. This property is important enough that its  a rule all  QueryResult instances should follow:  Evaluate every # value to WHNF before constructing  the result DDoing so keeps resource usage under local control by preventing the ? construction of potentially long-lived thunks that are forced  (or not) by the consumer. EThis is important to postgresql-simple-0.0.4 because a wayward thunk  causes the entire LibPQ. ! to be retained. This could lead ; to a memory leak, depending on how the thunk is consumed. ANote that instances can be defined outside of postgresql-simple, A which is often useful. For example, here is an attempt at an # instance for a user-defined pair:   > data User = User { firstName :: String, lastName :: String }   instance  User where   [fa,qfb] [va,vb] = User <$> a <*> b  where !a =  fa va  !b =  fb vb   fs vs =  fs vs 2 HIn this example, the bang patterns are not used correctly. They force  the data constructors of the ! type, and are not forcing the  : values we need to force. This gives the consumer of the   QueryResult4 the ability to cause the memory leak, which is an  undesirable state of affairs. 5Convert values from a row into a Haskell collection. This function will return a  if conversion of the  collection fails. Throw a " exception, indicating a mismatch & between the number of columns in the n and row, and the . number in the collection to be converted to. 'Descriptors of fields to be converted. %Contents of the row to be converted. 0Number of columns expected for conversion. For 5 instance, if converting to a 3-tuple, the number to  provide here would be 3. "#$%&'()*+, "#$%&'()*+,leon@melding-monads.com Safe-Infered     experimentalleon@melding-monads.com Safe-Infered portable experimental&Leon P Smith <leon@melding-monads.com> Safe-Infered: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. 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 j. 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 4Query. #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. -.P[\]^_`abcdefjxyz{V[\]^_`ajbcdefyz{x"-./  !"##$$%&&'(()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTU VWXYZ[\]^_`abbcdeefghijkklmnopqrrstuuvwxyz{|}~                                                   ! "#$%& ' ( ) * + , - . / 0 1 2 34postgresql-simple-0.0.4'Database.PostgreSQL.Simple.LargeObjects Database.PostgreSQL.Simple.Field Database.PostgreSQL.Simple.Types Database.PostgreSQL.Simple.SqlQQ Database.PostgreSQL.Simple.Param&Database.PostgreSQL.Simple.QueryParams'Database.PostgreSQL.Simple.BuiltinTypes#Database.PostgreSQL.Simple.Internal!Database.PostgreSQL.Simple.Result'Database.PostgreSQL.Simple.QueryResults'Database.PostgreSQL.Simple.NotificationDatabase.PostgreSQL.SimpleBasecommitbase GHC.IO.Device AbsoluteSeek RelativeSeek SeekFromEndSeekMode GHC.IO.IOModeReadMode WriteMode AppendMode ReadWriteModeIOModepostgresql-libpq-0.6.2Database.PostgreSQL.LibPQTextBinaryFormatOidLoFdsqlInOnlyfromOnlyQuery fromQueryNullParamrenderActionManyEscapePlaininQuotes QueryParams renderParams BuiltinTypeVoidRecord RefcursorNumericVarbitBitTimeWithTimeZoneIntervalTimestampWithTimeZone TimestampTimeDateVarcharBpcharInetMacaddrMoneyCircleUnknown TintervalReltimeAbstimeFloat8Float4CidrLinePolygonBoxPathLsegPointXmlCidXidTidRegprocInt4Int2Int8NameCharByteaBool builtin2oid oid2builtinbuiltin2typname oid2typname RawResultrawFieldrawData ConnectInfo connectHost connectPort connectUserconnectPasswordconnectDatabaseSqlErrorsqlStatesqlNativeError sqlErrorMsgSqlTypeOtherBuiltin ConnectionconnectionHandleconnectionObjectsFieldresultcolumntypenamenametableOid tableColumnformattypeOiddefaultConnectInfoconnectconnectPostgreSQLpostgreSQLConnectionStringoid2intexecdisconnectedErrorwithConnectionclosenewNullConnectionResultconvert ResultErrorConversionFailedUnexpectedNull Incompatible errSQLTypeerrHaskellType errMessage returnError QueryResultsconvertResults convertErrorloCreatloCreateloImportloImportWithOidloExportloOpenloWriteloReadloSeekloTell loTruncateloCloseloUnlink NotificationnotificationPidnotificationChannelnotificationDatagetNotificationTransactionModeisolationLevel readWriteModeReadOnly ReadWriteIsolationLevel SerializableRepeatableRead ReadCommitted 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$fParamTimeOfDay $fParamDay$fParamUTCTime $fParamText $fParam[] $fParamText0$fParamByteString$fParamByteString0 $fParamDouble $fParamFloat $fParamOid $fParamWord64 $fParamWord $fParamWord32 $fParamWord16 $fParamWord8$fParamInteger $fParamInt64 $fParamInt $fParamInt32 $fParamInt16 $fParamInt8 $fParamBool $fParamNull $fParamBinary$fParamBinary0 $fParamIn $fParamMaybe $fParamAction $fShowAction$fQueryParams[]$fQueryParams(,,,,,,,,,)$fQueryParams(,,,,,,,,)$fQueryParams(,,,,,,,)$fQueryParams(,,,,,,)$fQueryParams(,,,,,)$fQueryParams(,,,,)$fQueryParams(,,,)$fQueryParams(,,)$fQueryParams(,)$fQueryParamsOnly$fQueryParams()$fExceptionSqlError$fResultRawResult$fResultEither$fResultTimeOfDay $fResultDay$fResultUTCTime $fResult[] $fResultText $fResultText0$fResultBinary$fResultBinary0$fResultByteString $fResultOid$fResultByteString0 $fResultRatio$fResultDouble $fResultFloat$fResultInteger $fResultInt64 $fResultInt $fResultInt32 $fResultInt16 $fResultBool $fResultNull $fResultMaybe$fExceptionResultErrorGHC.Basereturn Data.EitherEither$fQueryResults[]$fQueryResults(,,,,,,,,,)$fQueryResults(,,,,,,,,)$fQueryResults(,,,,,,,)$fQueryResults(,,,,,,)$fQueryResults(,,,,,)$fQueryResults(,,,,)$fQueryResults(,,,)$fQueryResults(,,)$fQueryResults(,)$fQueryResultsOnly$fExceptionQueryError$fExceptionFormatError