Passing Input Table Columns to the Result Set

A tpf_blob illustrating how a TPF can pass the rows from an input table to the result table, and how to use the row_status flag to indicate if a row is present.

This allows the TPF to filter out unwanted rows.

  1. During the describe phase, ensure the TPF uses the describe_column_set method of EXTFNAPIV4_DESCRIBE_COL_VALUES_SUBSET_OF_INPUT to inform the server that specific result-set rows are a subset of rows from an input table.
    This code snippet from the describe_extfn method illustrates filtering:
    else if( ctx->current_state == EXTFNAPIV4_STATE_OPTIMIZATION ) {
    	
    	// The output columns of this TPF are the same as the first
    	// argument's input table columns.  The following describe
    	// informs the consumer of this fact.
    	a_v4_extfn_col_subset_of_input colMap;
    
    	for( short i = 1; i <= 2; i++ ) {
    	    colMap.source_table_parameter_arg_num = 1;
    	    colMap.source_column_number = i;
    
    	    desc_rc = ctx->describe_column_set( ctx, 
    		    0, i, 
    		    EXTFNAPIV4_DESCRIBE_COL_VALUES_SUBSET_OF_INPUT, 
    		    &colMap, sizeof(a_v4_extfn_col_subset_of_input) );
    
    	    UDF_CHECK_DESCRIBE( ctx, desc_rc );
    	}
    }
    
  2. Pass the call to fetch_into for the input table the same rowblock structure that was passed into the fetch_into_extfn method. This ensures that the rowblock structure for the result set is the same as for the input tables.
Related reference
EXTFNAPIV4_DESCRIBE_COL_VALUES_SUBSET_OF_INPUT (Set)
fetch_into
_fetch_into_extfn