-
Notifications
You must be signed in to change notification settings - Fork 472
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 row::move_as
behavior breaking reusability
#1145
base: master
Are you sure you want to change the base?
Conversation
src/core/row.cpp
Outdated
// Re-initialize blob object so it can be used in further queries | ||
baseVal.initialize(session); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vadz any idea how I could access a session
object in this place? I need one as it is the only object that can create blob backend objects, which is required to get a fully functioning blob
again.
An alternative I have considered is to write a clone()
or duplicate()
function for the blob_backend
interface that can be used here (via some interface from the blob
object) but that seems rather inconsistent with how things work for all other backend objects. Besides, that would essentially require duplicating the functionality of session::make_blob_backend()
and code duplication is never a good thing...
Yet another alternative I was thinking of was to keep track of moved-from objects at the row
level in order to re-initialize them only when the object is actually used again, but I don't think there currently exists a (nice) way of executing code before new data is bound to the row's holders (as they are simply referenced as into
holders in the respective statement.
I'd appreciate thoughts from your side on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would require storing a back-pointer (or reference) to the session in each row object. It should probably be possible, but I wonder if we can avoid moving out of the blob here to avoid having to do this. Could you please remind me why was it necessary to add move_as()
in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because blob objects are not copyable, which the standard get
API requires
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but couldn't we just provide access to their data instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would require copying data into some sort of buffer (plus getting the type conversion magic in SOCI's internals right), which might not be what the user wants. Just imagine the scenario in which I want to fetch a blob just to write it into a different table. That'd then require copying the data into my temp buffer just to yet again copy the data into a new blob
object that I can then use
in my insertion query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the simplest would be to add blob_impl::clone()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible for the writable blob received from the select after insert ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible for the writable blob received from the select after insert ?
Sorry, I can't quite follow - there seems to be a verb missing in your sentence (that's important for your meaning) 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible for the writable blob received from the select after insert ?
Sorry, I can't quite follow - there seems to be a verb missing in your sentence (that's important for your meaning) 👀
Sorry, I mean blob_impl::clone. Is it possible to clone the blob? Who will own the blob locator ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cloning is not a good idea, I think. We don't want to duplicate the stored data. But we can create a new, empty blob from an existing one.
@avpalienko could you debug where the SegFault for Oracle is coming from? You seem to have good access to an Oracle installation, whereas for me it is always super tedious to get something to work. |
I've debugged on windows and have no segfault. But test fails: BLOB
|
For the time being, this is merely a sketch of how I think the fix has to work. The current implementation fails at the unavailability of a
session
object at therow
scope...Once this is finished, this PR fixes #1144