Binary large objects (BLOBs)

Binary large objects (BLOBs) are potentially very big (several GigaBytes) pieces of binary data which databases can store. Because of their potential size, they are not manipulated like any other data, and are usually not transfered to the database engine at the same time as the SQL text is transfered: first a reference to a blob is created for an existing or a new blob, and then that reference is used, before or after the statement is being executed, depending on the database engine accessed, to get or set some parts of the blob.

Libgda makes its best to hide the complexity of this and most of the time blobs can be used like any other type of values with the following limitations:

  • When getting a blob through a SELECT statement, a transaction will automatically be started if it's not already started, and usually the transaction (implicitly or explicitly) will be locked untill all the ressources associated to the fetched blobs are liberated (by calling g_object_unref() on the model).

  • When fetching a blob value (using gda_data_model_get_value_at() for example), the blob itself is not fetched, only a reference to the blob is fetched, and one has to use the GdaBlobOp object embedded in a blob value to get the blob's contents.

Please consult each database provider's notes and limitations for database specific rules regarding BLOBs. Also have a look at the Blobs manipulation source code example.