Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzmbrzl committed Oct 26, 2023
1 parent 2c95e8a commit 8a5e213
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions src/backends/oracle/blob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ oracle_blob_backend::oracle_blob_backend(oracle_session_backend &session)
throw soci_error("Cannot allocate the LOB locator");
}
std::cout << "Created Oracle Blob obj\n";
std::cout << lobp_ << std::endl;
}

oracle_blob_backend::~oracle_blob_backend()
Expand Down Expand Up @@ -108,7 +109,18 @@ std::size_t oracle_blob_backend::write_from_start(char const *buf, std::size_t t

ub4 amt = static_cast<ub4>(toWrite);

sword res = OCILobWrite(session_.svchp_, session_.errhp_, lobp_, &amt,
boolean is_temporary = FALSE;
sword res = OCILobIsTemporary(session_.envhp_, session_.errhp_, lobp_, &is_temporary);

if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}

std::cout << "Is temporary before writing: " << std::boolalpha << (is_temporary == TRUE) << std::endl;
std::cout << lobp_ << std::endl;

res = OCILobWrite(session_.svchp_, session_.errhp_, lobp_, &amt,
static_cast<ub4>(offset + 1),
reinterpret_cast<dvoid*>(const_cast<char*>(buf)),
amt, OCI_ONE_PIECE, 0, 0, 0, 0);
Expand All @@ -117,6 +129,16 @@ std::size_t oracle_blob_backend::write_from_start(char const *buf, std::size_t t
throw_oracle_soci_error(res, session_.errhp_);
}

res = OCILobIsTemporary(session_.envhp_, session_.errhp_, lobp_, &is_temporary);

if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}

std::cout << "Is temporary after writing: " << std::boolalpha << (is_temporary == TRUE) << std::endl;
std::cout << lobp_ << std::endl;

return static_cast<std::size_t>(amt);
}

Expand Down Expand Up @@ -191,6 +213,9 @@ void oracle_blob_backend::reset()
throw_oracle_soci_error(res, session_.errhp_);
}

std::cout << "Is temporary when resetting: " << std::boolalpha << (is_temporary == TRUE) << std::endl;
std::cout << lobp_ << std::endl;

if (is_temporary) {
res = OCILobFreeTemporary(session_.svchp_, session_.errhp_, lobp_);
} else {
Expand All @@ -199,7 +224,7 @@ void oracle_blob_backend::reset()

if (res != OCI_SUCCESS)
{
std::cout << "Can't free/close LOB (is temporary: " << std::boolalpha << is_temporary << ") res: " << res << "\n";
std::cout << "Can't free/close LOB (is temporary: " << is_temporary << ") res: " << res << "\n";
throw_oracle_soci_error(res, session_.errhp_);
}

Expand All @@ -222,13 +247,33 @@ void oracle_blob_backend::ensure_initialized()
throw_oracle_soci_error(res, session_.errhp_);
}

boolean is_temporary = FALSE;
res = OCILobIsTemporary(session_.envhp_, session_.errhp_, lobp_, &is_temporary);

if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}

std::cout << "Is temporary immediately after creation as temporary: " << std::boolalpha << (is_temporary == TRUE) << std::endl;

res = OCILobOpen(session_.svchp_, session_.errhp_, lobp_, OCI_LOB_READWRITE);

if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}

res = OCILobIsTemporary(session_.envhp_, session_.errhp_, lobp_, &is_temporary);

if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}

std::cout << "Is temporary immediately after opening: " << std::boolalpha << (is_temporary == TRUE) << std::endl;
std::cout << lobp_ << std::endl;

initialized_ = true;
}
}

0 comments on commit 8a5e213

Please sign in to comment.