śĪēīŻņo      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnportable experimental$Aleksey Uymanov <s9gf4ult@gmail.com>None"Parse bit field literal in format ''b'00101011'''. Takes just last 64 bits " of input, other bits are ignored ooportable experimental$Aleksey Uymanov <s9gf4ult@gmail.com>None    portable experimental$Aleksey Uymanov <s9gf4ult@gmail.com>None  B is the main type for expressing Haskell values to SQL databases. WHAT IS SQLVALUE )SqlValue is an intermediate type to storerecevie data to from the *database. Every database driver will do it's best to properly convert any SqlValue to the database record'(s field, and properly convert the record's field to SqlValue back. The   has predefined  and   instances for many Haskell's types. Any Haskell's type can be converted to the   with ! 1function. There is no safeToSql function because ! never fails. Also, any  , type can be converted to almost any Haskell's type as well. Not any  ! can be converted back to Haskell's type, so there is  1function to do that safely. There is also unsafe ! function of caurse. You can sure, that fromSql . toSql == id SQLVALUE CONSTRUCTORS  > constructors is the MINIMAL set of constructors, required to 8represent the most wide range of native database types. PFor example, there is FLOAT native database type and DOUBLE, but any DOUBLE can 5carry any FLOAT value, so there is no need to create   constructor to Nrepresent FLOAT type, we can do it with Double. But there is DECIMAL database Jtype, representing arbitrary precision value which can be carried just by p Haskell')s type, so we need a constructor for it. NThere is no SqlRational any more, because there is no one database which have Pnative Rational type. This is the key idea: if database can not store this type natively we will not create   clause for it. Each  A constructor is documented or self-explaining to understand what it is needed for. 'ToSql' and 'FromSql' INSTANCES NThe key idea is to do the most obvious conversion between types only if it is ;not ambiguous. For example, the most obvious conversion of q to r is just truncate the q+, the most obvious conversion of String to s is to try read the t+ as date and time. But there is no obvious way to convert r to s!, so if you will try to convert ( K44) to date you will fail. User must handle this cases properly converting Pvalues with right way. It is not very good idea to silently perform strange and ?ambiguous convertions between absolutely different data types. ERROR CONDITIONS QThere may be sometimes an error during conversion. For instance, if you have an $ and attempting to convert it to an u, but it doesn' t parse as an uA, you will get an error. This will be indicated as an exception using , or a Left result using . STORING SQLVALUE TO DATABASE Any   can be converted to Text and then readed from Text back. This .is guaranteed by tests, so the database driver'!s author can use it to store and read data through Text2 for types which is not supported by the database  natively. TEXT AND BYTESTRINGS <We are using lazy Text everywhere because it is faster than t and has Jbuilders. Strict text can be converted to one-chanked lazy text with O(1) Ocomplexity, but lazy to strict converts with O(n) complexity, so it is logical to use lazy Text. KWe are not using ByteString as text encoded in UTF-8, ByteStrings are just Nsequences of bytes. We are using strict ByteStrings because HDBI drivers uses 0them to pass the ByteString to the C library as CString, so it must be strict. We are not using t7 as data of query or as query itself because it is not effective in memory and cpu.  DATE AND TIME NWe are not using time with timezone, because there is no one database working Nwith it natively except PostgreSQL, but the documentations of PostgreSQL says 6To address these difficulties, we recommend using datetime types that contain Mboth date and time when using time zones. We do not recommend using the type Etime with time zone (though it is supported by PostgreSQL for legacy Papplications and for compliance with the SQL standard). PostgreSQL assumes your :local time zone for any type containing only date or time./ 2This is not recomended to use time with timezone.  We are using s instead of TimeWithTimezone because no one database Kactually save timezone information. All databases just convert datetime to sG when save data and convert UTCTime back to LOCAL SERVER TIMEZONE when Qreturning the data. So it is logical to work with timezones on the haskell side. ITime intervals are not widely supported, actually just in PostgreSQL and 6Oracle. So, if you need them you can serialize throgh  by hands, or write your own   and ' instances to do that more convenient. EQUALITY OF SQLVALUE DTwo SqlValues are considered to be equal if one of these hold. The Cfirst comparison that can be made is controlling; if none of these 2comparisons can be made, then they are not equal:  Both are NULL O Both represent the same type and the encapsulated values are considered equal  by applying (==) to them ) The values of each, when converted to a t , are equal. "NULL in SQL or Nothing in Haskell (Local YYYY-MM-DD HH:MM:SS (no timezone) Local HH:MM:SS (no timezone) Local YYYY-MM-DD (no timezone) UTC YYYY-MM-DD HH:MM:SS UUID value http:en.wikipedia.orgwikiUUID !Represent bit field with 64 bits GBlob field in the database. This field can not be implicitly converted F to any other type because it is just an array of bytes, not an UTF-8  encoded string. /Any Integer, including Int32, Int64 and Words. "Arbitrary precision DECIMAL value Unsafe method, throws %# if convertion failed. Has default  implementation. AAll types must convert to SqlValue safely and unambiguously. That's why  there is no  ''safeToSql'' method ":Auxiliary type to represent bit field outside of SqlValue %&Convertion error description. Used in  typeclass. &:Type names must unique. Expecting names are generated by (v . w)  function 'name of type trying to convert  from. (name of target type. *)Detailed description of convertion error xShow parser detail error y*create converting from Null error message f  !"#$%&'()*zgiven list of SqlValues expected length of list xList of contexts of parser Error message {y|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ”¢£¤„¦§Ø©Ŗ«¬­®Æ°±²³“µ¶·ø¹ŗ»¼!  !"#$%&'()*! !%)&*'("#$  L   !"#$%)&*'(zx{y|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ”¢£¤„¦§Ø©Ŗ«¬­®Æ°±²³“µ¶·ø¹ŗ»¼portable experimental$Aleksey Uymanov <s9gf4ult@gmail.com>None3+Wrapper around some specific - instance to write  database-independent code -6Statement prepared on database side or just in memory .FExecute single query with parameters. In query each parameter must be  replaced with ''?''9 placeholder. This rule is true for every database, even - for PostgreSQL which uses placeholders like ''$1''. Application must ensure M that the count of placeholders is equal to count of parameter, it is likely  cause an error if it is not. /DExecute single query without parameters. Has default implementation  through .. 0CExecute one query many times with a list of paramters. Has default  implementation through .. 1Return the current statement' s status. 2JFinish statement and remove database-specific pointer. No any actions may 2 be proceeded after closing the statement, excpet 1 which  will return : and 3. 3Reset statement to it'!s initial state, just like after H. 4IFetch next row from the executed statement. Return Nothing when there is H no more results acceptable. Each call return next row from the result. =UPDATE INSERT and DELETE queries will likely return Nothing. HNOTE: You still need to explicitly finish the statement after receiving * Nothing, unlike with old HDBC interface. 5GOptional method to strictly fetch all rows from statement. Has default  implementation through 4. 6+Return list of column names of the result. 7BReturn the number of columns representing the result. Has default  implementation through 6 8;Return the original query the statement was prepared from. 9 Statement's status returning by function 1. :.Finished, no more actions with this statement ;.Fetching is done, no more rows can be queried <0Expression executed, now you can fetch the rows - =Newly created statement >HWrapps the specific connection. You can write database-independent code ) mixing it with database-dependent using [ function to cast 3 Wrapper to specific connection type, if you need. @3Typeclass to abstract the working with connection. A+Specific statement for specific connection BIDisconnection from the database. Every opened statement must be finished  after this method executed. CGExplicitly start the transaction. Without starting the transaction you K can not commit or rollback it. HDBI does not check if transaction started  or not, this is the application's resposibility. This is not recomended to use start by hands, use ]  instead D0Explicitly commit started transaction. You must start the transaction  before D This is not recomended to use D by hands, use ]  instead ERollback the transaction's state. You must start the transaction before  E This is not recomended to use E by hands, use ]  instead FDCheck if current connection is in transaction state. Return True if : transaction is started. Each driver implements it with it's own way: some I RDBMS has API to check transaction state (like PostgreSQL), some has no  (like Sqlite3). G(Return the current status of connection HBPrepare the statement. Some databases has no feature of preparing K statements (PostgreSQL can just prepare named statements), so each driver  behaves it' s own way. I@Run query and safely finalize statement after that. Has default  implementation through .. JDRun raw query without parameters and safely finalize statement. Has  default implementation through /. KIExecute query with set of parameters. Has default implementation through  0. LCClone the database connection. Return new connection with the same  settings MIThe name of the HDBI driver module for this connection. Ideally would be G the same as the database name portion of the Cabal package name. For  instance, "sqlite3" or " postgresql"(. This is the layer that is bound most  tightly to HDBI NJWhether or not the current database supports transactions. If False, then  D and E% should be expected to raise errors. OConnection status P Connection is in some bad state QSuccessfully disconnected, all ) statements must be closed at this state RSuccessfully connected S9safe newtype wrapper for queries. Just lazy Text inside. UUnwrap query to lazy Text V7Error throwing by driver when database operation fails W"Driver-specific operational error XInternal database error Y'Low level database-specific error code ZError description 3Error description from the database client library [>Cast wrapped connection to the specific connection type using ½ of  ¾>. You can write database-specific code safely casting wrapped * connection to specific type dynamically. \JCast wrapped statement to specific type. You can write database-specific E code safely casting wrapped statement to specific type dynamically. ]:Execute some code. If any uncaught exception occurs, run E" and re-raise it. Otherwise, run D and return. OThis function, therefore, encapsulates the logical property that a transaction is all about: all or nothing. The @? object passed in is passed directly to the specified function as a convenience. This function traps all uncaught exceptions, not just V. Therefore, 6you will get a rollback for any exception that you don't handle. That's probably what you want anyway. $If there was an error while running E, this error will not be Dreported since the original exception will be propogated back. (You' d probably Elike to know about the root cause for all of this anyway.) Feedback on this behavior is solicited. ^2Create statement and execute monadic action using 4it. Safely finalize Statement after action is done. _same as I but uses  instance `same as K but uses  =+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^ Connection  Query string Action at the statement _`abcdæĄĮ:+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcd;@ABCDEFGHIJKLMN-./012345678STUORQP>?9=<;:+,VXWYZZ[\]^_`abcd+,- ./0123456789=<;:>?@ABCDEFGHIJKLMNORQPSTUVXWYZZ[\]^_`abcdæĄĮportable experimental$Aleksey Uymanov <s9gf4ult@gmail.com>Nonee7List of weak pointers to childs with concurrent access hLittle hackish child counter,  need to wait all child  finalizers in k jnew empty child list k2Close all children. Intended to be called by the  disconnect function in  Connection. MThere may be a potential race condition wherein a call to newSth at the same Ntime as a call to this function may result in the new child not being closed. lGAdds a new child to the existing list. Also takes care of registering ?a finalizer for it, to remove it from the list when possible. Ā#The general finalizer for a child. PIt is simply a filter that removes any finalized weak pointers from the parent. LIf the MVar is locked at the start, does nothing to avoid deadlock. Future &runs would probably catch it anyway. efghijklĀefghijklefghikljefghijklĀNoneĆLreturn constructor name and fields count, or Nothing if data constructor is  infix mDerive ; instance for any data with one constructor or for newtype ĆmnmnmnĆmnportable experimental$Aleksey Uymanov <s9gf4ult@gmail.com>None[  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdÄ      !"#$%&'()**+,-./,01123456789:;<=>?@ABCCDEFGHIJKLMNOPQRSTUVWWXYZY[\]^_`abcdefgghijklmnopqrstuvwxyz{|w}~€w‚ƒw„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ”¢£¤„¦§Ø©Ŗ«¬­®Æ°±²³“µ¶·ø¹ŗ»¼½¾æĄĮĀĆÄÅĘĒČÉŹwĖĢw„ĶĪĻŠŃŅÓ hdbi-1.2.0Database.HDBI.ParsersDatabase.HDBI.FormatersDatabase.HDBI.SqlValueDatabase.HDBI.TypesDatabase.HDBI.DriverUtilsLanguage.Haskell.TH.HDBI Database.HDBI parseBitFieldparseIsoZonedTime parseIsoDayparseIsoTimeOfDayparseIsoLocalTimeformatBitFieldformatIsoUTCTime formatIsoDayformatIsoTimeOfDayformatIsoLocalTimeSqlValueSqlNull SqlLocalTimeSqlLocalTimeOfDay SqlLocalDate SqlUTCTimeSqlUUID SqlBitFieldSqlBoolSqlBlobSqlText SqlDouble SqlInteger SqlDecimalFromRow safeFromRowfromRowToRowtoRowFromSql safeFromSqlfromSqlToSqltoSqlBitField unBitField ConvertErrorIncompatibleTypes ceFromTypeceToTypeceReason StmtWrapper Statementexecute executeRaw executeManystatementStatusfinishresetfetchfetchAllgetColumnNamesgetColumnsCount originalQueryStatementStatusStatementFinishedStatementFetchedStatementExecuted StatementNew ConnWrapper Connection ConnStatement disconnectbegincommitrollback inTransaction connStatuspreparerunrunRawrunManyclonehdbiDriverNamedbTransactionSupport ConnStatusConnBadConnDisconnectedConnOKQueryunQuerySqlErrorSqlDriverError seErrorCode seErrorMsgcastConnection castStatementwithTransaction withStatementrunRow runManyRows executeRowexecuteManyRowsfetchRow fetchAllRows ChildListclList clCounter clNextKey newChildListcloseAllChildrenaddChild deriveToRow deriveFromRowspaces Decimal-0.3.1 Data.DecimalDecimalghc-prim GHC.TypesDoublebaseGHC.IntInt32 time-1.4.0.1Data.Time.Clock.UTCUTCTimeGHC.BaseString integer-gmpGHC.Integer.TypeIntegerGHC.ShowshowData.Typeable.InternaltypeOfshowFailnullConvertError wrongSqlListincompatibleTypesconvertToBoundedtryParse$fFromSqlSqlValue$fToSqlSqlValue$fFromSqlMaybe $fToSqlMaybe$fFromSqlLocalTime$fToSqlLocalTime$fFromSqlTimeOfDay$fToSqlTimeOfDay $fFromSqlDay $fToSqlDay$fFromSqlUTCTime$fToSqlUTCTime $fFromSqlUUID $fToSqlUUID$fFromSqlBitField$fToSqlBitField $fFromSqlBool $fToSqlBool$fFromSqlByteString$fToSqlByteString$fFromSqlByteString0$fToSqlByteString0 $fFromSqlText $fToSqlText$fFromSqlText0 $fToSqlText0 $fFromSql[] $fToSql[]$fFromSqlDouble $fToSqlDouble $fFromSqlWord $fToSqlWord$fFromSqlWord64 $fToSqlWord64$fFromSqlWord32 $fToSqlWord32$fFromSqlInteger$fToSqlInteger$fFromSqlInt64 $fToSqlInt64$fFromSqlInt32 $fToSqlInt32 $fFromSqlInt $fToSqlInt$fFromSqlDecimalRaw$fToSqlDecimalRaw $fEqSqlValue$fFromRow(,,,,,,)$fToRow(,,,,,,)$fFromRow(,,,,,)$fToRow(,,,,,)$fFromRow(,,,,) $fToRow(,,,,)$fFromRow(,,,) $fToRow(,,,) $fFromRow(,,) $fToRow(,,) $fFromRow(,) $fToRow(,) $fFromRow[] $fToRow[]$fShowBitField$fExceptionConvertError Data.TypeablecastTypeable$fStatementStmtWrapper$fConnectionConnWrapper$fExceptionSqlErrorchildFinalizer getTParams