SQLBulkOperations does not work with string and length array bind #108

rusabd opened this Issue Nov 21, 2013 · 0 comments

2 participants


I am trying to use SQLBulkOperations for inserts and following pseudo code

(odbc-common:sqlsetstmtattr-encoding hstmt 7 4 nil)
(odbc-common:sqlsetstmtattr-encoding hstmt 6 1 nil)
(odbc-common:sqlsetstmtattr-encoding hstmt 27 10000 nil)

(fli:with-dynamic-foreign-objects ()
  (let* ((visitors (convert-to-dynamic-foreign-array (loop for i upto 10000 collect (gen-guid))))
         (length-array (create-length-array 10000 (length (gen-guid))) :type :int)         
         (names (convert-to-dynamic-foreign-array (loop repeat 100 append (loop for i upto 100 collect (gen-guid)))))
         (values (convert-to-dynamic-foreign-array (loop for i upto 10000 collect (gen-guid))))
         (tss (create-length-array 10000 (random 1000000) :type :int)))

    ; (gen-guid) is always 43 characters long
    (odbc-common:sqlbindcol hstmt 1 odbc-common:sql_c_char visitors 43 length-array)
    (odbc-common:sqlbindcol hstmt 2 odbc-common:sql_c_char names 43 length-array)
    (odbc-common:sqlbindcol hstmt 3 odbc-common:sql_c_char values 43 length-array)
    (odbc-common:sqlbindcol hstmt 4 odbc-common:sql_c_long tss 4 fli:*null-pointer*)
    (odbc-common:sqlexecdirect hstmt "select visitor, name, value, ts from facts" )
    (print `(,visitors ,names ,length-array ,values))
    (time (loop for idx from 0 repeat 1000
                (sql-server::sql-bulk-operations hstmt 4)  (commit)))))

works perfectly fine in SQL Server, but on Virtuoso 7 it tries breaks quite badly:

Exception C0000005 [flags 0] at address 212B9CB
rax      3070A60 rbx       4B8F60 rcx            0 rdx FFFFFFFFFF0EBD6C
rsp      2D2F460 rbp      2D2F560 rsi            0 rdi       4B8850
r8             0 r9       3070E60 r10 70206E6920294D30 r11      3070E68
r12      3D700AB r13      3070A38 r14            0 r15            0
PC 212B9CB
   [Condition of type SYSTEM::EXCEPTION]

when using NULL for the length array in SQLBindCol and arrays contains strings terminated by 0 it works

@iv-an-ru iv-an-ru was assigned by openlink Feb 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment