Y      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~Safe 09:;<=AOQRTAs the semantic of System.Locale.iso8601DateFormat has changed with old-locale-1.0.0.2 in a non-compatible way, we now define our own (compatible) version of it.Safe /09:;<=AOQRTA is the main type for expressing Haskell values to SQL databases.INTRODUCTION TO SQLVALUEThis type is used to marshall Haskell data to and from database APIs. HDBC driver interfaces will do their best to use the most accurate and efficient way to send a particular value to the database server.KValues read back from the server are constructed with the most appropriate  constructor.  or S can then be used to convert them into whatever type is needed locally in Haskell.Most people will use  and  instead of manipulating  s directly.&EASY CONVERSIONS BETWEEN HASKELL TYPES5Conversions are powerful; for instance, you can call  on a SqlInt32 and get a String or a Double out of it. This class attempts to Do The Right Thing whenever possible, and will raise an error when asked to do something incorrect. In particular, when converting to any type except a Maybe, / as the input will cause an error to be raised.,Conversions are implemented in terms of the Data.Convertible module, part of the convertible package. You can refer to its documentation, and import that module, if you wish to parse the Left result from 2 yourself, or write your own conversion instances.%Here are some notes about conversion:6Fractions of a second are not preserved on time values There is no  safeToSql because  never fails. See also , , , , , .ERROR CONDITIONSPThere may sometimes be an error during conversion. For instance, if you have a  and are attempting to convert it to an Integer, but it doesn't parse as an Integer, you will get an error. This will be indicated as an exception if using , or a Left result if using .SPECIAL NOTE ON POSIXTIME Note that a  or  is converted to  by %. HDBC cannot differentiate between  and > since they are the same underlying type. You must construct  manually or via  , or use .DETAILS ON SQL TYPESHDBC database backends are expected to marshal date and time data back and forth using the appropriate representation for the underlying database engine. Databases such as PostgreSQL with builtin date and time types should see automatic conversion between these Haskell types to database types. Other databases will be presented with an integer or a string. Care should be taken to use the same type on the Haskell side as you use on the database side. For instance, if your database type lacks timezone information, you ought not to use ZonedTime, but instead LocalTime or UTCTime. Database type systems are not always as rich as Haskell. For instance, for data stored in a TIMESTAMP WITHOUT TIME ZONE column, HDBC may not be able to tell if it is intended as UTCTime or LocalTime data, and will happily convert it to both, upon your request. It is your responsibility to ensure that you treat timezone issues with due care.This behavior also exists for other types. For instance, many databases do not have a Rational type, so they will just use the show function and store a Rational as a string.The conversion between Haskell types and database types is complex, and generic code in HDBC or its backends cannot possibly accomodate every possible situation. In some cases, you may be best served by converting your Haskell type to a String, and passing that to the database.UNICODE AND BYTESTRINGSVBeginning with HDBC v2.0, interactions with a database are presumed to occur in UTF-8.?To accomplish this, whenever a ByteString must be converted to or from a String, the ByteString is assumed to be in UTF-8 encoding, and will be decoded or encoded as appropriate. Database drivers will generally present text or string data they have received from the database as a SqlValue holding a ByteString, which  will automatically convert to a String, and thus automatically decode UTF-8, when you need it. In the other direction, database drivers will generally convert a L to a ByteString in UTF-8 encoding before passing it to the database engine.If you are handling some sort of binary data that is not in UTF-8, you can of course work with the ByteString directly, which will bypass any conversion.oDue to lack of support by database engines, lazy ByteStrings are not passed to database drivers. When you use \ on a lazy ByteString, it will be converted to a strict ByteString for storage. Similarly, H will convert a strict ByteString to a lazy ByteString if you demand it.EQUALITY OF SQLVALUETwo SqlValues are considered to be equal if one of these hold. The first comparison that can be made is controlling; if none of these comparisons can be made, then they are not equal: Both are NULLiBoth represent the same type and the encapsulated values are considered equal by applying (==) to them9The values of each, when converted to a string, are equalSTRING VERSIONS OF TIMESjDefault string representations are given as comments below where such are non-obvious. These are used for  when a , is desired. They are also defaults for representing data to SQL backends, though individual backends may override them when a different format is demanded by the underlying database. Date and time formats use ISO8601 date format, with HH:MM:SS added for time, and -HHMM added for timezone offsets.DEPRECATED CONSTRUCTORS and , are no longer created automatically by any  or M functions or database backends. They may still be manually constructed, but are expected to be removed in a future version. Although these two constructures will be removed, support for marshalling to and from the old System.Time data will be maintained as long as System.Time is, simply using the newer data types for conversion.Local YYYY-MM-DD (no timezone).Local HH:MM:SS (no timezone).BLocal HH:MM:SS -HHMM. Converts to and from (TimeOfDay, TimeZone).(Local YYYY-MM-DD HH:MM:SS (no timezone).XLocal YYYY-MM-DD HH:MM:SS -HHMM. Considered equal if both convert to the same UTC time.UTC YYYY-MM-DD HH:MM:SS.Calendar diff between seconds. Rendered as Integer when converted to String, but greater precision may be preserved for other types or to underlying database.ITime as seconds since midnight Jan 1 1970 UTC. Integer rendering as for .RDEPRECATED Representation of ClockTime or CalendarTime. Use SqlPOSIXTime instead.@DEPRECATED Representation of TimeDiff. Use SqlDiffTime instead."NULL in SQL or Nothing in Haskell.Convert a value to an <. This function is simply a restricted-type wrapper around . See extended notes on . Conversions to and from s and standard Haskell types.This function converts from an : to a Haskell value. Many people will use the simpler G instead. This function is simply a restricted-type wrapper around . Convert from an = to a Haskell value. Any problem is indicated by calling ?. This function is simply a restricted-type wrapper around . See extended notes on .  Converts any Integral type to a  by using toInteger. AConvenience function for using numeric literals in your program. $Convenience function for converting  to a  , because / cannot do the correct thing in this instance. KRead a value from a string, and give an informative message if it fails.]  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV   G  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV$Copyright (C) 2006-2011 John GoerzenBSD3$John Goerzen <jgoerzen@complete.org> provisionalportableSafe 09:;<=AOQRT1X)The different types of intervals in SQL. YDifference in monthsZDifference in years[Difference in years+months\Difference in days]Difference in hours^Difference in minutes_Difference in seconds`Difference in days+hoursaDifference in days+minutesbDifference in days+secondscDifference in hours+minutesdDifference in hours+secondseDifference in minutes+secondsf(The type identifier for a given column. This represents the type of data stored in the column in the underlying SQL engine. It does not form the entire column type; see  for that.8These types correspond mainly to those defined by ODBC. gFixed-width character stringsh Variable-width character stringsiEVariable-width character strings, max length implementation dependantjFixed-width Unicode stringskVariable-width Unicode stringslCVariable-width Unicode strings, max length implementation dependantmSigned exact valuesnSigned exact integer valueso16-bit integer valuesp32-bit integer valuesr$Signed inexact floating-point valuess&Signed inexact double-precision valuest A single bitu8-bit integer valuesv64-bit integer valueswFixed-length binary dataxVariable-length binary datay@Variable-length binary data, max length implementation dependantzA date{A time, no timezone|A time, with timezone}#Combined date and time, no timezone~%Combined date and time, with timezone UTC date/timeUTC timeA time or date differenceGlobal unique identifierNA type not represented here; implementation-specific information in the StringThe description of a column.SFields are Nothing if the database backend cannot supply the requested information."The colSize field works like this:For character types, the maximum width of the column. For numeric types, the total number of digits allowed. See the ODBC manual for more.The colOctetLength field is defined for character and binary types, and gives the number of bytes the column requires, regardless of encoding.Type of data stored hereThe size of a columnThe maximum size in octets!Digits to the right of the periodWhether NULL is acceptable3XYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~3XYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~3fghijklmnopqrstuvwxyz{|}~XYZ[\]^_`abcdeX YZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~Safe 09:;<=AOQRT The main HDBC exception object. As much information as possible is passed from the database through to the application through this object.HErrors generated in the Haskell layer will have seNativeError set to -1.Execute the prepared statement, passing in the given positional parameters (that should take the place of the question marks in the call to prepare).For non-SELECT queries, the return value is the number of rows modified, if known. If no rows were modified, you get 0. If the value is unknown, you get -1. All current HDBC drivers support this function and should never return -1.*For SELECT queries, you will always get 0.hThis function should automatically call finish() to finish the previous execution, if necessary. Execute the statement as-is, without supplying any positional parameters. This is intended for statements for which the results aren't interesting or present (e.g., DDL or DML commands). If your query contains placeholders, this will certainly fail; use  instead. Execute the query with many rows. The return value is the return value from the final row as if you had called  on it.Due to optimizations that are possible due to different databases and driver designs, this can often be significantly faster than using D multiple times since queries need to be compiled only once./This is most useful for non-SELECT statements. 1Abort a query in progress -- usually not needed. &Fetches one row from the DB. Returns = if there are no more rows. Will automatically call $ when the last row is read. Returns a list of the column names in the result. For maximum portability, you should not assume that information is available until after an  function has been run.Information is returned here directly as returned by the underlying database layer. Note that different databases have different rules about capitalization of return values and about representation of names of columns that are not simple columns. For this reason, it is suggested that you treat this information for display purposes only. Failing that, you should convert to lower (or upper) case, and use AS8 clauses for anything other than simple columns.BA simple getColumnNames implementation could simply apply map fst to the return value of .The original query that this  was prepared with. YObtain information about the columns in the result set. Must be run only after =. The String in the result set is the column name.TYou should expect this to be returned in the same manner as a result from .SAll results should be converted to lowercase for you before you see them.Please see caveats under 9 for information on the column name field here.,  ,  $Copyright (C) 2005-2011 John GoerzenBSD3$John Goerzen <jgoerzen@complete.org> provisionalportableSafe 09:;<=AOQRTSometimes, it is annoying to use typeclasses with Haskell's type system. In those situations, you can use a ConnWrapper. You can create one with: let wrapped = ConnWrapper iconn?You can then use this directly, since a ConnWrapper is also an I. However, you will not be able to use private database functions on it.Or, you can use .Main database handle object.An  object is created by specific functions in the module for an individual database. That is, the connect function -- which creates this object -- is not standardized through the HDBC interface.$A connection is closed by a call to . A call to e is required to make sure that your changes get committed to the database. In other words, HDBC has no support for autocommit', which we consider an outdated notion.$Disconnect from the remote database.You do not need to explicitly close an IConnection object, but you may do so if you so desire. If you don't, the object will disconnect from the database in a sane way when it is garbage-collected. However, a disconnection may raise an error, so you are encouraged to explicitly call {. Also, garbage collection may not run when the program terminates, and some databases really like an explicit disconnect.,So, bottom line is, you're best off calling 1 directly, but the world won't end if you forget.nThis function discards any data not committed already. Database driver implementators should explicitly call > if their databases don't do this automatically on disconnect.=Bad Things (TM) could happen if you call this while you have ys active. In more precise language, the results in such situations are undefined and vary by database. So don't do it.(Commit any pending data to the database.*Required to make any changes take effect. PRoll back to the state the database was in prior to the last  or . Execute an SQL string, which may contain multiple queries. This is intended for situations where you need to run DML or DDL queries and aren't interested in results. YExecute a single SQL query. Returns the number of rows modified (see s for details). The second parameter is a list of replacement values, if any. $Prepares a statement for execution. pQuestion marks in the statement will be replaced by positional parameters in a later call to .Please note that, depending on the database and the driver, errors in your SQL may be raised either here or by P. Make sure you handle exceptions both places if necessary.  Create a new  Connection object, pointed at the same server as this object is. This will generally establish a separate physical connection.When you wish to establish multiple connections to a single server, the correct way to do so is to establish the first connection with the driver-specific connection function, and then clone it for each additional connection.This can be important when a database doesn't provide much thread support itself, and the HDBC driver module must serialize access to a particular database.This can also be a handy utility function whenever you need a separate connection to whatever database you are connected to already. 1The name of the HDBC driver module for this connection. Ideally would be the same as the database name portion of the Cabal package name. For instance, "sqlite3" or "odbc". This is the layer that is bound most tightly to HDBC. LThe version of the C (or whatever) client library that the HDBC driver module is bound to. The meaning of this is driver-specific. For an ODBC or similar proxying driver, this should be the version of the ODBC library, not the eventual DB client driver. In the case of a system such as ODBC, the name of the database client/server in use, if available. For others, identical to . In the case of a system such as ODBC, the version of the database client in use, if available. For others, identical to F. This is the next layer out past the HDBC driver. 2The version of the database server, if available. ]Whether or not the current database supports transactions. If False, then  and 7 should be expected to raise errors.MySQL is the only commonly-used database that is known to not support transactions entirely. Please see the MySQL notes in the ODBC driver for more information. The names of all tables accessible by the current connection, excluding special meta-tables (system tables).]You should expect this to be returned in the same manner as a result from .\All results should be converted to lowercase for you before you see them.Obtain information about the columns in a specific table. The String in the result set is the column name.]You should expect this to be returned in the same manner as a result from .\All results should be converted to lowercase for you before you see them. Unwrap a  and pass the embedded  to a function. Example: <withWConn wrapped run $ "SELECT * from foo where bar = 1" []?  ? Copyright (C) 2006 John GoerzenBSD3$John Goerzen <jgoerzen@complete.org> provisionalportableSafe 09:;<=AOQRT2Close all children. Intended to be called by the  function in  Connection. There may be a potential race condition wherein a call to newSth at the same time as a call to this function may result in the new child not being closed.Adds 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.OIt is simply a filter that removes any finalized weak pointers from the parent.qIf the MVar is locked at the start, does nothing to avoid deadlock. Future runs would probably catch it anyway.  $Copyright (C) 2005-2011 John GoerzenBSD3$John Goerzen <jgoerzen@complete.org> provisionalportableNone 09:;<=AOQRTExecute the given IO action.If it raises a `, then execute the supplied handler and return its return value. Otherwise, proceed as normal. Like (, with the order of arguments reversed. |Given an Exception, return Just SqlError if it was an SqlError, or Nothing otherwise. Useful with functions like catchJust. Catches s, and re-raises them as IO errors with fail. Useful if you don't care to catch SQL errors, but want to see a sane error message if one happens. One would often use this as a high-level wrapper around SQL calls. Like ., but take a list of Maybe Strings instead of s. Like 1, but take a list of Maybe Strings instead of s. Like 1, but take a list of Maybe Strings instead of s. Like 3, but return a list of Maybe Strings instead of s. :Execute some code. If any uncaught exception occurs, run " and re-raise it. Otherwise, run  and return.lThis function, therefore, encapsulates the logical property that a transaction is all about: all or nothing.The P object passed in is passed directly to the specified function as a convenience.This function traps all uncaught exceptions, not just SqlErrors. Therefore, you will get a rollback for any exception that you don't handle. That's probably what you want anyway.Since all operations in HDBC are done in a transaction, this function doesn't issue an explicit "begin" to the server. You should ideally have called   or   before calling this function. If you haven't, this function will commit or rollback more than just the changes made in the included action.$If there was an error while running , this error will not be reported since the original exception will be propogated back. (You'd probably like to know about the root cause for all of this anyway.) Feedback on this behavior is solicited.'Lazily fetch all rows from an executed .GYou can think of this as hGetContents applied to a database result set.uThe result of this is a lazy list, and each new row will be read, lazily, from the database as the list is processed.&When you have exhausted the list, the  will be ed.Please note that the careless use of this function can lead to some unpleasant behavior. In particular, if you have not consumed the entire list, then attempt to  or re-execute the statement, and then attempt to consume more elements from the list, the result will almost certainly not be what you want.2But then, similar caveats apply with hGetContents.BBottom line: this is a very convenient abstraction; use it wisely.Use A if you need something that is strict, without all these caveats.Strict version of %. Does not have the side-effects of =, but forces the entire result set to be buffered in memory. Like &, but return Maybe Strings instead of s. Strict version of . Like X, but instead of returning a list, return an association list from column name to value.LThe keys of the column names are lowercase versions of the data returned by ~. Please heed the warnings there. Additionally, results are undefined if multiple columns are returned with identical names.Strict version of .  Similar to 2, but return a Map instead of an association list.Strict version of . Like s, but instead of returning a list for each row, return an association list for each row, from column name to value.See  for more details. Strict version of  Like D, but return a list of Maps instead of a list of association lists. Strict version of  NA quick way to do a query. Similar to preparing, executing, and then calling  on a statement. See also . Strict version of . A utility function to throw a . The mechanics of throwing such a thing differ between GHC 6.8.x, Hugs, and GHC 6.10. This function takes care of the special cases to make it simpler.{With GHC 6.10, it is a type-restricted alias for throw. On all other systems, it is a type-restricted alias for throwDyn. $Copyright (C) 2005-2011 John GoerzenBSD3$John Goerzen <jgoerzen@complete.org> provisionalportableNone 09:;<=AOQRT  XYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~k   !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      #HDBC-2.4.0.2-1zqEg4HcqMV1kQtguZUFwODatabase.HDBC.LocaleDatabase.HDBC.SqlValueDatabase.HDBC.ColTypesDatabase.HDBC.StatementDatabase.HDBC.TypesDatabase.HDBC.DriverUtils Database.HDBC fetchAllRows'Database.HDBC.Utilscommitrollback time-1.6.0.1Data.Time.Format.LocaledefaultTimeLocaleiso8601DateFormatSqlValue SqlString SqlByteString SqlWord32 SqlWord64SqlInt32SqlInt64 SqlIntegerSqlCharSqlBool SqlDouble SqlRational SqlLocalDateSqlLocalTimeOfDaySqlZonedLocalTimeOfDay SqlLocalTime SqlZonedTime SqlUTCTime SqlDiffTime SqlPOSIXTime SqlEpochTime SqlTimeDiffSqlNulltoSql safeFromSqlfromSqlnToSqliToSql posixToSql$fConvertibleSqlValueMaybe$fConvertibleMaybeSqlValue!$fConvertibleSqlValueCalendarTime!$fConvertibleCalendarTimeSqlValue$fConvertibleSqlValueDiffTime$fConvertibleDiffTimeSqlValue$fConvertibleSqlValueTimeDiff$fConvertibleTimeDiffSqlValue$fConvertibleSqlValueClockTime$fConvertibleClockTimeSqlValue$$fConvertibleSqlValueNominalDiffTime$$fConvertibleNominalDiffTimeSqlValue$fConvertibleSqlValueUTCTime$fConvertibleUTCTimeSqlValue$fConvertibleSqlValueZonedTime$fConvertibleZonedTimeSqlValue$fConvertibleSqlValueLocalTime$fConvertibleLocalTimeSqlValue$fConvertibleSqlValue(,)$fConvertible(,)SqlValue$fConvertibleSqlValueTimeOfDay$fConvertibleTimeOfDaySqlValue$fConvertibleSqlValueDay$fConvertibleDaySqlValue$fConvertibleSqlValueRatio$fConvertibleRatioSqlValue$fConvertibleSqlValueDouble$fConvertibleDoubleSqlValue$fConvertibleSqlValueChar$fConvertibleCharSqlValue$fConvertibleSqlValueBool$fConvertibleBoolSqlValue$fConvertibleSqlValueInteger$fConvertibleIntegerSqlValue$fConvertibleSqlValueWord64$fConvertibleWord64SqlValue$fConvertibleSqlValueWord32$fConvertibleWord32SqlValue$fConvertibleSqlValueInt64$fConvertibleInt64SqlValue$fConvertibleSqlValueInt32$fConvertibleInt32SqlValue$fConvertibleSqlValueInt$fConvertibleIntSqlValue$fConvertibleSqlValueByteString$fConvertibleByteStringSqlValue $fConvertibleSqlValueByteString0 $fConvertibleByteStringSqlValue0$fConvertibleSqlValueText$fConvertibleTextSqlValue$fConvertibleSqlValueText0$fConvertibleTextSqlValue0$fConvertibleSqlValue[]$fConvertible[]SqlValue$fConvertibleSqlValueSqlValue $fEqSqlValue$fShowSqlValue SqlIntervalSqlIntervalMonthTSqlIntervalYearTSqlIntervalYearToMonthTSqlIntervalDayTSqlIntervalHourTSqlIntervalMinuteTSqlIntervalSecondTSqlIntervalDayToHourTSqlIntervalDayToMinuteTSqlIntervalDayToSecondTSqlIntervalHourToMinuteTSqlIntervalHourToSecondTSqlIntervalMinuteToSecondT SqlTypeIdSqlCharT SqlVarCharTSqlLongVarCharT SqlWCharT SqlWVarCharTSqlWLongVarCharT SqlDecimalT SqlNumericT SqlSmallIntT SqlIntegerTSqlRealT SqlFloatT SqlDoubleTSqlBitT SqlTinyIntT SqlBigIntT SqlBinaryT SqlVarBinaryTSqlLongVarBinaryTSqlDateTSqlTimeTSqlTimeWithZoneT SqlTimestampTSqlTimestampWithZoneTSqlUTCDateTimeT SqlUTCTimeT SqlIntervalTSqlGUIDT SqlUnknownT SqlColDesccolTypecolSizecolOctetLength colDecDigits colNullable$fEqSqlInterval$fShowSqlInterval$fReadSqlInterval $fEqSqlTypeId$fShowSqlTypeId$fReadSqlTypeId$fEqSqlColDesc$fReadSqlColDesc$fShowSqlColDescSqlErrorseState seNativeError seErrorMsg Statementexecute executeRaw executeManyfinishfetchRowgetColumnNames originalQuerydescribeResult$fExceptionSqlError $fEqSqlError$fShowSqlError$fReadSqlError ConnWrapper IConnection disconnectrunRawrunprepareclonehdbcDriverName hdbcClientVerproxiedClientNameproxiedClientVer dbServerVerdbTransactionSupport getTables describeTable withWConn$fIConnectionConnWrapper ChildListcloseAllChildrenaddChildcatchSql handleSql sqlExceptionshandleSqlErrorsRunsExecute sExecuteMany sFetchRowwithTransaction fetchAllRows sFetchAllRowssFetchAllRows' fetchRowAL fetchRowMapfetchAllRowsALfetchAllRowsAL'fetchAllRowsMapfetchAllRowsMap' quickQuery quickQuery' throwSqlErrorData.Time.Clock.UTCNominalDiffTimeData.Time.Clock.POSIX POSIXTimebaseGHC.BaseString*convertible-1.1.1.0-2huR7S7QXmPJFQt2mlnJqBData.Convertible.Baseconvert safeConvertGHC.Errerrorread' quickError numToBool stringToPico viaInteger' viaIntegersecs2td parseTime'NothingchildFinalizer fetchRowAL' fetchRowMap'evalAll