Virtual methods for recordsets

This section explains how to write virtual methods for the GdaDataSelect subclasses implementations, which should be done when implementing a database provider.

That data model implementation simplifies the implementation of provider's recordsets by having them implement only a few virtual methods.

The data model represents each row as a separate GdaRow object, and virtual methods to retrieve rows have to return new (and correctly initialized) objects of that class. The referencing of these new objects is left up to the implementation which:

Note that the methods mentioned in the 1st and 3rd items should be reserved for random data access mode, and that cursor based access mode should implement the method mentioned in th 2nd item.

fetch_nb_rows()

This method is called when the user calls gda_data_model_get_n_rows ().

Its implementation is mandatory if the data model supports random access.

Note about the the data model's number of rows: it may not be known until the cursor has reached the last row of the recordset, but once known, the number of rows can be stored in the advertized_nrows's member of the GdaDataSelect object.

fetch_random()

This method is called when the user calls gda_data_model_get_value_at (), and is used only when the data access mode for the data model is random (that is not cursor based) (i.e. when data access is cursor based, this method will not be called).

Its implementation is mandatory if the data model supports random access.

Also it is safe to assume that when called, the prow parameter will not be NULL, and that *prow is actually NULL.

store_all()

This method is called when the user sets the "store-all-rows" to TRUE or calls gda_data_select_prepare_for_offline. It has the effect of forcing the creation of a GdaRow object for each row of the data model (thus increasing the memory consumption but reducing further access times). It is available only when the data access mode for the data model is random (that is not cursor based). When random data access is not supported, this method will not be called.

Its implementation is optional.

fetch_next()

This method is called when data access is cursor based and a data model iterator is moved one position forward. The rownum is an indication of what the row number will be once the next row has been fetched (it can safely be discarded if that information is not necessary).

This method is not used when data is accessed in a random way. Also it is safe to assume that when called, the prow parameter will not be NULL, and that *prow is actually NULL.

Its implementation is mandatory if the data model supports forward cursor access.

fetch_prev()

This method is called when data access is cursor based and a data model iterator is moved one position backward. The rownum is an indication of what the row number will be once the previous row has been fetched (it can safely be discarded if that information is not necessary). Implementing this method is not necessary if the data model does not support moving iterators backward.

This method is not used when data is accessed in a random way. Also it is safe to assume that when called, the prow parameter will not be NULL, and that *prow is actually NULL.

Its implementation is mandatory if the data model supports backward cursor access.

fetch_at()

This method can be implemented (but it is not required) when data access is cursor based and there is a shorter way of getting to a specific row than having to call the fetch_next() or fetch_prev() methods several times.

Its implementation is mandatory if the data model supports forward or backward cursor access.