+(defun date-to-clsql-time (ptr)
+ (declare (type c-date-ptr-type ptr))
+ (clsql-sys:make-time
+ :second 0 :minute 0 :hour 0
+ :day (get-slot-value ptr 'sql-c-timestamp 'day)
+ :month (get-slot-value ptr 'sql-c-timestamp 'month)
+ :year (get-slot-value ptr 'sql-c-timestamp 'year)))
+
+(defun time-to-clsql-time (ptr)
+ (declare (type c-time-ptr-type ptr))
+ (clsql-sys:make-time
+ :second (get-slot-value ptr 'sql-c-timestamp 'second)
+ :minute (get-slot-value ptr 'sql-c-timestamp 'minute)
+ :hour (get-slot-value ptr 'sql-c-timestamp 'hour)))
+
+
+;;; Added by KMR
+
+(defun %set-attr-odbc-version (henv version)
+ (with-error-handling (:henv henv)
+ ;;note that we are passing version as an integer that happens to be
+ ;;stuffed into a pointer.
+ ;;http://msdn.microsoft.com/en-us/library/ms709285%28v=VS.85%29.aspx
+ (SQLSetEnvAttr henv $SQL_ATTR_ODBC_VERSION
+ (make-pointer version :void) 0)))
+
+(defun %list-tables (hstmt)
+ (with-error-handling (:hstmt hstmt)
+ (SQLTables hstmt +null-ptr+ 0 +null-ptr+ 0 +null-ptr+ 0 +null-ptr+ 0)))
+
+(defun %table-statistics (table hstmt &key unique (ensure t)
+ &aux (table (princ-to-string
+ (clsql-sys::unescaped-database-identifier table))))
+ (with-cstrings ((table-cs table))
+ (with-error-handling (:hstmt hstmt)
+ (SQLStatistics
+ hstmt
+ +null-ptr+ 0
+ +null-ptr+ 0
+ table-cs $SQL_NTS
+ (if unique $SQL_INDEX_UNIQUE $SQL_INDEX_ALL)
+ (if ensure $SQL_ENSURE $SQL_QUICK)))))
+
+(defun %list-data-sources (henv)
+ (let ((results nil))
+ (with-foreign-strings ((dsn-ptr (1+ $SQL_MAX_DSN_LENGTH))
+ (desc-ptr 256))
+ (with-foreign-objects ((dsn-len :short)
+ (desc-len :short))
+ (let ((res (with-error-handling (:henv henv)
+ (SQLDataSources henv $SQL_FETCH_FIRST dsn-ptr
+ (1+ $SQL_MAX_DSN_LENGTH)
+ dsn-len desc-ptr 256 desc-len))))
+ (when (or (eql res $SQL_SUCCESS)
+ (eql res $SQL_SUCCESS_WITH_INFO))
+ (push (convert-from-foreign-string dsn-ptr) results))
+
+ (do ((res (with-error-handling (:henv henv)
+ (SQLDataSources henv $SQL_FETCH_NEXT dsn-ptr
+ (1+ $SQL_MAX_DSN_LENGTH)
+ dsn-len desc-ptr 256 desc-len))
+ (with-error-handling (:henv henv)
+ (SQLDataSources henv $SQL_FETCH_NEXT dsn-ptr
+ (1+ $SQL_MAX_DSN_LENGTH)
+ dsn-len desc-ptr 256 desc-len))))
+ ((not (or (eql res $SQL_SUCCESS)
+ (eql res $SQL_SUCCESS_WITH_INFO))))
+ (push (convert-from-foreign-string dsn-ptr) results)))))
+ (nreverse results)))