{"action":"opened","issue":{"url":"https://api.github.com/repos/K2InformaticsGmbH/erloci/issues/59","repository_url":"https://api.github.com/repos/K2InformaticsGmbH/erloci","labels_url":"https://api.github.com/repos/K2InformaticsGmbH/erloci/issues/59/labels{/name}","comments_url":"https://api.github.com/repos/K2InformaticsGmbH/erloci/issues/59/comments","events_url":"https://api.github.com/repos/K2InformaticsGmbH/erloci/issues/59/events","html_url":"https://github.com/K2InformaticsGmbH/erloci/issues/59","id":332844238,"node_id":"MDU6SXNzdWUzMzI4NDQyMzg=","number":59,"title":"reading RAW fields is truncating at byte 0","user":{"login":"c-bik","id":913008,"node_id":"MDQ6VXNlcjkxMzAwOA==","avatar_url":"https://avatars0.githubusercontent.com/u/913008?v=4","gravatar_id":"","url":"https://api.github.com/users/c-bik","html_url":"https://github.com/c-bik","followers_url":"https://api.github.com/users/c-bik/followers","following_url":"https://api.github.com/users/c-bik/following{/other_user}","gists_url":"https://api.github.com/users/c-bik/gists{/gist_id}","starred_url":"https://api.github.com/users/c-bik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c-bik/subscriptions","organizations_url":"https://api.github.com/users/c-bik/orgs","repos_url":"https://api.github.com/users/c-bik/repos","events_url":"https://api.github.com/users/c-bik/events{/privacy}","received_events_url":"https://api.github.com/users/c-bik/received_events","type":"User","site_admin":false},"labels":[{"id":40466178,"node_id":"MDU6TGFiZWw0MDQ2NjE3OA==","url":"https://api.github.com/repos/K2InformaticsGmbH/erloci/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":{"login":"c-bik","id":913008,"node_id":"MDQ6VXNlcjkxMzAwOA==","avatar_url":"https://avatars0.githubusercontent.com/u/913008?v=4","gravatar_id":"","url":"https://api.github.com/users/c-bik","html_url":"https://github.com/c-bik","followers_url":"https://api.github.com/users/c-bik/followers","following_url":"https://api.github.com/users/c-bik/following{/other_user}","gists_url":"https://api.github.com/users/c-bik/gists{/gist_id}","starred_url":"https://api.github.com/users/c-bik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c-bik/subscriptions","organizations_url":"https://api.github.com/users/c-bik/orgs","repos_url":"https://api.github.com/users/c-bik/repos","events_url":"https://api.github.com/users/c-bik/events{/privacy}","received_events_url":"https://api.github.com/users/c-bik/received_events","type":"User","site_admin":false},"assignees":[{"login":"c-bik","id":913008,"node_id":"MDQ6VXNlcjkxMzAwOA==","avatar_url":"https://avatars0.githubusercontent.com/u/913008?v=4","gravatar_id":"","url":"https://api.github.com/users/c-bik","html_url":"https://github.com/c-bik","followers_url":"https://api.github.com/users/c-bik/followers","following_url":"https://api.github.com/users/c-bik/following{/other_user}","gists_url":"https://api.github.com/users/c-bik/gists{/gist_id}","starred_url":"https://api.github.com/users/c-bik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c-bik/subscriptions","organizations_url":"https://api.github.com/users/c-bik/orgs","repos_url":"https://api.github.com/users/c-bik/repos","events_url":"https://api.github.com/users/c-bik/events{/privacy}","received_events_url":"https://api.github.com/users/c-bik/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2018-06-15T16:44:16Z","updated_at":"2018-06-15T16:44:16Z","closed_at":null,"author_association":"MEMBER","body":"Create Table:\r\n```sql\r\ncreate table raw_clob(col_raw raw(2000))\r\n```\r\n**Note:** data is corrupted when read through select!\r\n```erlang\r\nStmtInsert = OciSession:prep_sql(<<\"insert into raw_clob (col_raw) values (:col_raw)\">>).\r\nok = StmtInsert:bind_vars([{<<\":col_raw\">>, 'SQLT_BIN'}]).\r\nData = <<1,2,3,4,0,0,0,5,6,7,8>>,\r\n{rowids, [_]} = StmtInsert:exec_stmt([{Data}]).\r\n\r\nSelStmt = OciSession:prep_sql(\"select col_raw from raw_clob\").\r\n> {cols, _} = SelStmt:exec_stmt().\r\n{cols,[{<<\"COL_RAW\">>,'SQLT_BIN',2000,0,0}]}\r\n\r\n> SelStmt:fetch_rows(100).\r\n{{rows,[[<<1,2,3,4>>]]},true}\r\n```\r\n\r\n### Root Cause\r\n1. `cur_clm.dlen + 1`  is used to allocate buffer for RAW which is always (for the `raw_clob` table above) 2000. https://github.com/K2InformaticsGmbH/erloci/blob/49557dbe09fe8541f04bc5d6f899e27c09849f7b/c_src/erloci_lib/ocistmt.cpp#L479-L484 due to incorrect use of `OCIAttrGet(OCI_DTYPE_PARAM, OCI_ATTR_DATA_SIZE)` API to get the value in `cur_clm.dlen` https://github.com/K2InformaticsGmbH/erloci/blob/49557dbe09fe8541f04bc5d6f899e27c09849f7b/c_src/erloci_lib/ocistmt.cpp#L398-L400\r\n1. Eventually hoever, `strlen` is used in https://github.com/K2InformaticsGmbH/erloci/blob/49557dbe09fe8541f04bc5d6f899e27c09849f7b/c_src/erloci_lib/ocistmt.cpp#L974-L982 to determine real data length causing the truncation when binary contains 0 (`\\0` as string termination character)"}}
{"actor":{"display_login":"c-bik"}}