{      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMN 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 { | } ~          experimental&Leon P Smith <leon@melding-monads.com> Safe-Infered)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 6 !"#$%&'()*+,-./012344 !"#$%&'()*+,-./012343 !"#$%&'()*+,-./01234 experimental&Leon P Smith <leon@melding-monads.com> Safe-Infered !"#$%&'() !"#$%&'() experimental&Leon P Smith <leon@melding-monads.com> Safe-Infered552 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. 5555 experimental&Leon P Smith <leon@melding-monads.com> Safe-Infered*+,-./01234*-./+,41230portable experimental&Leon P Smith <leon@melding-monads.com>None6>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  .... 8Wrap 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: = 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. BA placeholder for the SQL NULL value. 6789:;<=>?@ABC!"#$% 6789:;<=>?@ABCBC<=>:;89?@A 67 6789:;<=>?@ABC!"#$%portable experimental&Leon P Smith <leon@melding-monads.com> Safe-InferedD>A type that may be used as a single parameter to a SQL query. E6Prepare a value for substitution into a query string. F<How to render an element when substituting it into a query. G+Concatenate a series of rendering actions. H Escape binary data for use as a bytea literal. Include surrounding  quotes. This is used by the 8 newtype wrapper. I>Escape and enclose in quotes before substituting. Use for all < text-like types, and anything else that may contain unsafe  characters when rendered. J;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 "'". K0Surround a string with single-quote characters: "'" This function does not perform any other escaping. ,DEFGHIJK&'()*+,-./0123456789:;<=>?@ABCDEFGHIDEFGHIJKFJIHGDEK'DEFJIHGK&'()*+,-./0123456789:;<=>?@ABCDEFGHIportable experimental&Leon P Smith <leon@melding-monads.com> Safe-InferedL>A collection type that can be turned into a list of rendering  Fs. Instances should use the render method of the Param class : to perform conversion of each element of the collection. M ToField a collection of values. LMJKLMNOPQRSTULMLM LMJKLMNOPQRSTU  experimentalleon@melding-monads.com Safe-InferedN<a way to reify a list of exceptions into a single exception VTwo R4 cases are considered equal, regardless of what the " list of exceptions looks like. NOPQRWXYZ[VNOPQRPRQNONOPRQWXYZ[V Safe-Infered\Like ]/, 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-Infered2STUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~2STUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~2S~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTS-~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUT portable experimental&Leon P Smith <leon@melding-monads.com>NoneException 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 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 0 data structure into a libpq connection string.  A version of execute+ that does not perform query substitution. HAtomically perform an action with the database handle, if there is one. :^_88^_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  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 a to avoid @ such a reference, and that using bytestring functions such as b  and c+ 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. (defghijklmnopqrstuvwxyz{|}~  ! defghijklmnopqrstuvwxyz{|}~ 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 . leon@melding-monads.com Safe-Infered     experimentalleon@melding-monads.com Safe-InferedDReturns a single notification. If no notifications are available,   blocks until one arrives. Non-blocking variant of #. Returns a single notification, = if available. If no notifications are available, returns . 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 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 . 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. 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 1Query. #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.      V6789:;<=>?L     \?L:;89<=>67           ! " # $ $ %&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMM""NNOOPQQRSSTUVWXYZ[\] ^ ^ _ _ ` 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 { | } ~      $ !                                     !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWX Y Z [ \ ] ^_`_ a b c!de!df!ghijklmnopqrstuvwxyz{|}~            postgresql-simple-0.2.0.1'Database.PostgreSQL.Simple.LargeObjects$Database.PostgreSQL.Simple.FromField Database.PostgreSQL.Simple.TypesDatabase.PostgreSQL.Simple.Time(Database.PostgreSQL.Simple.Time.Internal 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.Time.Implementation!Database.PostgreSQL.Simple.CompatBasecommitbase GHC.IO.Device AbsoluteSeek RelativeSeek SeekFromEndSeekMode GHC.IO.IOModeReadMode WriteMode AppendMode ReadWriteModeIOModepostgresql-libpq-0.8.2Database.PostgreSQL.LibPQTextBinaryFormatOidLoFdDateZonedTimestamp UTCTimestampLocalTimestamp Unbounded PosInfinityFinite NegInfinity parseUTCTimeparseZonedTimeparseLocalTimeparseDayparseTimeOfDayparseUTCTimestampparseZonedTimestampparseLocalTimestamp parseDategetDaygetDate getTimeOfDay getLocalTimegetLocalTimestamp getTimeZone getZonedTimegetZonedTimestamp getUTCTimegetUTCTimestamp dayToBuildertimeOfDayToBuildertimeZoneToBuilderutcTimeToBuilderzonedTimeToBuilderlocalTimeToBuilderunboundedToBuilderutcTimestampToBuilderzonedTimestampToBuilderlocalTimestampToBuilder dateToBuildersql:.InOnlyfromOnlyQuery fromQueryNullToFieldtoFieldActionMany EscapeByteAEscapePlaininQuotesToRowtoRow ManyErrorsOkErrors BuiltinTypeVoidRecord RefCursorNumericVarBitBitTimeTZInterval TimestampTZ TimestampTimeVarCharBpCharInetMacAddrMoneyCircleUnknown TIntervalRelTimeAbsTimeFloat8Float4CidrLinePolygonBoxPathLSegPointXmlCidXidTidRegProcInt4Int2Int8NameCharByteABool builtin2oid oid2builtinbuiltin2typname oid2typname RowParserRPunRPRowrow typenames rowresult ConnectInfo connectHost connectPort connectUserconnectPasswordconnectDatabase QueryError qeMessageqeQuerySqlErrorsqlStatesqlNativeError sqlErrorMsgSqlTypeOtherBuiltin ConnectionconnectionHandleconnectionObjectsFieldresultcolumntypenamenametableOid tableColumnformattypeOiddefaultConnectInfoconnectconnectPostgreSQLpostgreSQLConnectionStringoid2intexecexecute_ finishExecutethrowResultErrordisconnectedErrorwithConnectionclosenewNullConnectiongetvaluenfields FromField fromField ResultErrorConversionFailedUnexpectedNull Incompatible errSQLTypeerrHaskellType errMessage returnErrorFromRowfromRowfieldnumFieldsRemainingloCreatloCreateloImportloImportWithOidloExportloOpenloWriteloReadloSeekloTell loTruncateloCloseloUnlink NotificationnotificationPidnotificationChannelnotificationDatagetNotificationgetNotificationNonBlockingTransactionModeisolationLevel readWriteModeReadOnly ReadWriteDefaultReadWriteModeIsolationLevel SerializableRepeatableRead ReadCommittedDefaultIsolationLevel FoldOptions fetchQuantitytransactionMode FetchQuantityFixed Automatic FormatError fmtMessagefmtQuery fmtParams formatQuery formatManyexecute executeManyqueryquery_folddefaultFoldOptionsfoldWithOptionsfold_foldWithOptions_forEachforEach_defaultTransactionModedefaultIsolationLeveldefaultReadWriteModewithTransactionwithTransactionLevelwithTransactionModerollbackbegin beginLevel beginModeppad2pad4++ getUnboundeddecimaltoNumdigitdigits showSecondspad6showD6pad3showD3$fReadUnbounded$fShowUnbounded Data.StringIsStringbytestring-0.9.2.1Data.ByteString.Internal ByteString $fMonoidQuery$fIsStringQuery $fReadQuery $fShowQuery$fEqNull$fToFieldUnbounded$fToFieldUnbounded0$fToFieldUnbounded1$fToFieldUnbounded2$fToFieldTimeOfDay $fToFieldDay$fToFieldLocalTime$fToFieldZonedTime$fToFieldUTCTime $fToFieldText $fToField[]$fToFieldText0$fToFieldByteString$fToFieldByteString0$fToFieldBinary$fToFieldBinary0$fToFieldDouble$fToFieldFloat $fToFieldOid$fToFieldWord64 $fToFieldWord$fToFieldWord32$fToFieldWord16$fToFieldWord8$fToFieldInteger$fToFieldInt64 $fToFieldInt$fToFieldInt32$fToFieldInt16 $fToFieldInt8 $fToFieldBool $fToFieldNull $fToFieldIn$fToFieldMaybe$fToFieldAction $fShowAction $fToRow[]$fToRow(,,,,,,,,,)$fToRow(,,,,,,,,)$fToRow(,,,,,,,)$fToRow(,,,,,,)$fToRow(,,,,,) $fToRow(,,,,) $fToRow(,,,) $fToRow(,,) $fToRow(,) $fToRowOnly $fToRow()$fEqOk$fExceptionManyErrors $fMonadOk $fMonadPlusOk$fAlternativeOk$fApplicativeOkmaskGHC.IO$fExceptionQueryError$fExceptionSqlErrorResultData.ByteStringcopydropData.ByteString.Char8 takeWhile$fFromFieldEither$fFromFieldUnbounded$fFromFieldUnbounded0$fFromFieldUnbounded1$fFromFieldUnbounded2$fFromFieldTimeOfDay$fFromFieldDay$fFromFieldLocalTime$fFromFieldZonedTime$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 Data.MaybeNothing$fExceptionFormatError