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 ca7160e
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion 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,6 +109,17 @@ std::size_t oracle_blob_backend::write_from_start(char const *buf, std::size_t t

ub4 amt = static_cast<ub4>(toWrite);

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 before writing: " << std::boolalpha << (is_temporary == TRUE) << std::endl;
std::cout << lobp_ << std::endl;

sword res = OCILobWrite(session_.svchp_, session_.errhp_, lobp_, &amt,
static_cast<ub4>(offset + 1),
reinterpret_cast<dvoid*>(const_cast<char*>(buf)),
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 ca7160e

Please sign in to comment.