db: tried async execution with odbc... didn't work

Added note in TODO, my guess why not.
Fixed odbc ffi bindings, added a few more status checks.
This commit is contained in:
Ryan Culpepper 2011-08-29 14:35:02 -06:00
parent f339060e55
commit 281df3221e
2 changed files with 21 additions and 8 deletions

View File

@ -68,6 +68,11 @@ Misc
- how about implicit support only in 'in-query'?
- ODBC: use async execution to avoid blocking all Racket threads
Status: Tried it. Oracle driver doesn't support async. PG, MY drivers don't support async.
DB2 driver does, but gives baffling HY010 function sequence errors, couldn't fix.
(Best theory so far: possible that DB2 requires polling args to be identical to original
call, which means (_ptr o X) args are the problem. Or maybe unixodbc's fault.)
Didn't try SQL Server. All in all, not worth it.
- add evt versions of functions
- for query functions (?)

View File

@ -123,6 +123,10 @@ Docs at http://msdn.microsoft.com/en-us/library/ms712628%28v=VS.85%29.aspx
(define-ffi-definer define-odbc odbc-lib)
(define (ok-status? n)
(or (= n SQL_SUCCESS)
(= n SQL_SUCCESS_WITH_INFO)))
(define-odbc SQLAllocHandle
(_fun (type : _sqlsmallint)
(parent : _sqlhandle/null)
@ -168,7 +172,8 @@ Docs at http://msdn.microsoft.com/en-us/library/ms712628%28v=VS.85%29.aspx
(len : (_ptr o _sqlsmallint))
-> (status : _sqlreturn)
-> (values status
(bytes->string/utf-8 value #f 0 len)))))
(and (ok-status? status)
(bytes->string/utf-8 value #f 0 len))))))
(define-odbc SQLGetFunctions
(_fun (handle : _sqlhdbc)
@ -211,7 +216,7 @@ Docs at http://msdn.microsoft.com/en-us/library/ms712628%28v=VS.85%29.aspx
(out-len : (_ptr o _sqlsmallint))
-> (status : _sqlreturn)
-> (values status
(and (or (= status SQL_SUCCESS) (= status SQL_SUCCESS_WITH_INFO))
(and (ok-status? status)
(bytes->string/utf-8 out-buf #f 0 out-len)))))
(define-odbc SQLDataSources
@ -226,9 +231,9 @@ Docs at http://msdn.microsoft.com/en-us/library/ms712628%28v=VS.85%29.aspx
(descr-length : (_ptr o _sqlsmallint))
-> (status : _sqlreturn)
-> (values status
(and (or (= status SQL_SUCCESS) (= status SQL_SUCCESS_WITH_INFO))
(and (ok-status? status)
(bytes->string/utf-8 server-buf #f 0 server-length))
(and (or (= status SQL_SUCCESS) (= status SQL_SUCCESS_WITH_INFO))
(and (ok-status? status)
(bytes->string/utf-8 descr-buf #f 0 descr-length)))))
(define-odbc SQLDrivers
@ -242,7 +247,7 @@ Docs at http://msdn.microsoft.com/en-us/library/ms712628%28v=VS.85%29.aspx
((if attrs-buf (bytes-length attrs-buf) 0) : _sqlsmallint)
(attrs-length : (_ptr o _sqlsmallint))
-> (status : _sqlreturn)
-> (if (or (= status SQL_SUCCESS) (= status SQL_SUCCESS_WITH_INFO))
-> (if (ok-status? status)
(values status
(bytes->string/utf-8 driver-buf #f 0 driver-length)
attrs-length)
@ -308,7 +313,8 @@ Docs at http://msdn.microsoft.com/en-us/library/ms712628%28v=VS.85%29.aspx
(nullable : (_ptr o _sqlsmallint))
-> (status : _sqlreturn)
-> (values status
(bytes->string/utf-8 column-buf #f 0 column-len)
(and (ok-status? status)
(bytes->string/utf-8 column-buf #f 0 column-len))
data-type size digits nullable)))
(define-odbc SQLFetch
@ -356,9 +362,11 @@ Docs at http://msdn.microsoft.com/en-us/library/ms712628%28v=VS.85%29.aspx
(message-len : (_ptr o _sqlsmallint))
-> (status : _sqlreturn)
-> (values status
(bytes->string/utf-8 sql-state-buf #\? 0 5)
(and (ok-status? status)
(bytes->string/utf-8 sql-state-buf #\? 0 5))
native-errcode
(bytes->string/utf-8 message-buf #\? 0 message-len))))
(and (ok-status? status)
(bytes->string/utf-8 message-buf #\? 0 message-len)))))
(define-odbc SQLEndTran
(_fun (handle completion-type) ::