The fetch_block Method

Use the fetch_block method for underlying data storage.

The fetch_block method is used as an entry point when the consumer does not need the data in a particular format. fetch_block requests that the producer create a data transfer area and provide a pointer to that area. The consumer owns the memory and takes responsibility for copying data from this area.

The fetch_block method is more efficient than fetch_into, if the consumer does not need a specific layout. The fetch_block call provides a row block that can be populated, and this block is passed on the next fetch_block call. This method is part of the a_v4_extfn_table_context structure.

If the underlying data storage does not map easily to the row block structure, the UDF can simply point the row block to addresses in its memory. This prevents unnecessary data copies to satisfy another memory layout scheme.

The API uses a data transfer area that is defined by the structure a_v4_extfn_row_block, which is defined as a set of rows, where each row is defined as a set of columns. The row block creator can allocate enough storage to hold a single row or a set of rows. The producer can fill the rows, but cannot exceed the maximum number of rows allocated for the row block. If the producer has additional rows, the producer informs the consumer by returning the numeric value 1 from the fetch method.

Fetch is executed against a table object, which is either the object produced as the result set of a table UDF or the object consumed as a result set of an input table parameter.

Related concepts
Using a Row Block to Produce Data
Related reference
fetch_block