Table Context (a_v4_extfn_table_context)

The a_v4_extfn_table_context structure represents an open result set over a table.

Implementation

typedef struct a_v4_extfn_table_context {

//    size_t struct_size;

    /* fetch_into() - fetch into a specified row_block. This entry point
        is used when the consumer has a transfer area with a specific format.
        The fetch_into() function will write the fetched rows into the provided row block.
    */
    short (UDF_CALLBACK *fetch_into)(a_v4_extfn_table_context *cntxt, a_v4_extfn_row_block *);

    /* fetch_block() - fetch a block of rows. This entry point is used
        when the consumer does not need the data in a particular format. For example,
        if the consumer is reading a result set and formatting it as HTML, the consumer
        does not care how the transfer area is layed out. The fetch_block() entry point is
        more efficient if the consumer does not need a specific layout.

        The row_block parameter is in/out. The first call should point to a NULL row block.
        The fetch_block() call sets row_block to a block that can be consumed, and this block
        should be passed on the next fetch_block() call.
    */
    short (UDF_CALLBACK *fetch_block)(a_v4_extfn_table_context *cntxt, a_v4_extfn_row_block **row_block);

    /*  rewind() - this is an optional entry point. If NULL, rewind is not supported. Otherwise,
        the rewind() entry point restarts the result set at the beginning of the table.
    */
    short (UDF_CALLBACK *rewind)(a_v4_extfn_table_context *);

    /* get_blob() - If the specified column has a blob object, return it.  The blob
         is returned as an out parameter and is owned by the caller.  This method should
         only be called on a column that contains a blob.  The helper macro EXTFN_COL_IS_BLOB can
         be used to determine whether a column contains a blob.
    */
    short (UDF_CALLBACK *get_blob)(a_v4_extfn_table_context *cntxt,
				   a_v4_extfn_column_data *col,
				   a_v4_extfn_blob **blob);

    /* The following fields are reserved for future use and must be initialized to NULL. */
    void  *reserved1_must_be_null;
    void  *reserved2_must_be_null;
    void  *reserved3_must_be_null;
    void  *reserved4_must_be_null;
    void  *reserved5_must_be_null;

    a_v4_extfn_proc_context     *proc_context;
    void                        *args_handle;           // use in a_v4_extfn_proc_context::get_value() etc.
    a_v4_extfn_table            *table;
    void                        *user_data;
    void                        *server_internal_use;

    /* The following fields are reserved for future use and must be initialized to NULL. */
    void  *reserved6_must_be_null;
    void  *reserved7_must_be_null;
    void  *reserved8_must_be_null;
    void  *reserved9_must_be_null;
    void  *reserved10_must_be_null;

} a_v4_extfn_table_context;

Method Summary

Data Type Method Description
short fetch_into Fetch into a specified row_block
short fetch_block Fetch a block of rows
short rewind Restarts the result set at the beginning of the table
short get_blob Return a blob object, if the specified column has a blob object

Data Members and Data Types Summary

Data Member Data Type Description
proc_context a_v4_extfn_proc_context * A pointer to the procedure context object. The UDF can use this to set errors, log messages, cancel, and so on.
args_handle void * A handle to the arguments provided by the server.
table a_v4_extfn_table * Points to the open result set table. This is populated after a_v4_extfn_proc_context open_result_set has been called.
user_data void * This data pointer can be filled in by any usage with whatever context data the external routine requires.
server_internal_use void * Internal use only.

Description

The a_v4_extfn_table_context structure acts as a middle layer between the producer and the consumer to help manage the data, when the consumer and producer require separate formats.

A UDF can read rows from an input TABLE parameter using a_v4_extfn_table_context. The server or another UDF can read rows from the result table of a UDF using a_v4_extfn_table_context.

The server implements the methods of a_v4_extfn_table_context, which gives the server an opportunity to resolve impedance mismatches.

Related reference
fetch_into
fetch_block
rewind