SOCI/soci

MySQL BLOB appears to be unsupported

Krzmbrzl opened this issue · 6 comments

I had a look at https://github.com/SOCI/soci/blob/master/src/backends/mysql/blob.cpp and I noticed that the implementation is essentially just a wrapper around throwing an exception stating that BLOB was not supported.

I am wondering why this is the case? At first I thought that this might be due to MySQL not supporting BLOBs, but this doesn't seem to be the case: https://dev.mysql.com/doc/refman/8.0/en/blob.html

Is this just something that nobody has implemented yet?

vadz commented

Yes, BLOB support is not implemented in all backends. Contributing it for MySQL would be welcome, of course.

Alright - Given that I'll need this (unless I am willing to rethink my DB design), chances are that I might give this a shot.

I am wondering though: Why do we even have backend-specific BLOB implementations? My naive assumption was that a BLOB is essentially a wrapper around a std::vector< char > that is used to hold the buffer. But looking at the implementations, this does not seem to be what is done?
Do you happen to know why?

vadz commented

If you look at the existing implementation for e.g. Oracle you can see that using blobs requires using database-specific types. Using vector<byte> or whatever would require copying huge amounts of data, which would rather defeat the purpose of using BLOBs in the first place.

Okay, but if I look at e.g. the implementation for sqlite3, this seems like it is essentially a custom implementation of a std::vector (more or less). Thus, I am wondering why there is no "generic" blob implementation that uses an internal buffer to which the data is written and read from and then provide backend-specific implementations where appropriate 🤔

After having looked at different implementations, it seems like sqlite3 is essentially the exception here, so that explains why it probably doesn't make a lot of sense to have such a standard implementation...

vadz commented

After having looked at different implementations, it seems like sqlite3 is essentially the exception here

Yes.