Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix support for non-ASCII characters in Oracle CLOBs #1184

Merged
merged 5 commits into from
Jan 24, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove unused offset from OCILobRead() calls
On "streaming mode" the offset is ignored, except for the first call, so
don't bother updating it.

Also restructure the code in a slightly simpler way.
vadz committed Nov 20, 2024
commit ba202d03f4894043057457c84ab1d5e37c1e4f68
24 changes: 14 additions & 10 deletions src/backends/oracle/standard-into-type.cpp
Original file line number Diff line number Diff line change
@@ -254,29 +254,33 @@ void oracle::read_from_lob(oracle_session_backend& session,

// Read the LOB in chunks into the buffer while anything remains to be read.
std::vector<char> buf(len);
ub4 offset = 1;
do
for (bool done = false; !done; )
{
// By setting the input length to 0, we tell Oracle to read as many
// bytes as possible (so called "streaming" mode).
ub4 lenChunk = 0;
res = OCILobRead(session.svchp_, session.errhp_, lobp,
&lenChunk, offset,
&lenChunk,
1, // Only used for the first chunk, ignored later.
&buf[0], len,
0, 0, 0, 0);

if (res == OCI_NEED_DATA)
switch (res)
{
offset += lenChunk;
}
else if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session.errhp_);
case OCI_NEED_DATA:
// Nothing to do, just continue reading.
break;

case OCI_SUCCESS:
done = true;
break;

default:
throw_oracle_soci_error(res, session.errhp_);
}

value.append(buf.begin(), buf.begin() + lenChunk);
}
while (res == OCI_NEED_DATA);
}

void oracle_standard_into_type_backend::post_fetch(