EXTFNAPIV4_DESCRIBE_COL_MINIMUM_VALUE (Set)

The EXTFNAPIV4_DESCRIBE_COL_MINIMUM_VALUE attribute indicates the minimum value for the column. Used in a describe_column_set scenario.

Data Type

an_extfn_value

Description

The minimum value a column can have, if available. Only valid for argument 0.

Usage

The UDF can set EXTFNAPIV4_DESCRIBE_COL_MINIMUM_VALUE, if it knows what the minimum data value of the column is. The server can use this information during optimization.

The UDF can use EXTFNAPIV4_DESCRIBE_COL_TYPE to determine the data type of the column, and EXTFNAPIV4_DESCRIBE_COL_WIDTH to determine the storage requirements of the column, to provide an equivalently sized buffer to hold the value to set.

Returns

On success, returns the describe_buffer_length, or:
  • EXTFNAPIV4_DESCRIBE_NOT_AVAILABLE – if the attribute cannot be set. Returned if the column was not involved in the query or the minimum value was not available for the requested column.

On failure, returns one of the generic describe_column errors, or:

Query Processing States

Valid in:
  • Optimization state

Example

The PROCEDURE definition and UDF code fragment that implements the _describe_extfn callback API function:

CREATE PROCEDURE my_tpf( col_char char(10), col_table TABLE( c1 INT, c2 INT ) )
	RESULTS ( r1 INT, r2 INT, r3 INT )
	EXTERNAL ‘my_tpf_proc@mylibrary’;

CREATE TABLE T( x INT, y INT, z INT );

select * from my_tpf( 'test', TABLE( select x,y from T ) )

This example shows a TPF where it is useful to the server (or to another TPF that takes the result of this TPF as input) to know the minimum value of result set column one. In this instance, the minimum output value of column one is 27.

my_tpf_describe(a_v4_extfn_proc_context *cntxt)
{
	if( cntxt->current_state == EXTFNAPIV4_STATE_OPTIMIZATION ) {
	a_sql_int32 min_value = 27;
	a_sql_int32 ret = 0;

// Tell the server what the minimum value of the first column
// of our result set will be.

	ret = cntxt->describe_column_set( cntxt, 0, 1 
		EXTFNAPIV4_DESCRIBE_COL_MINIMUM_VALUE,
		&min_value,
		sizeof(a_sql_int32) );

	if( ret < 0 ) {
		// Handle the error.
	}
}
}
Related concepts
Query Processing States
Related reference
EXTFNAPIV4_DESCRIBE_COL_MINIMUM_VALUE (Get)
EXTFNAPIV4_DESCRIBE_COL_TYPE (Set)
EXTFNAPIV4_DESCRIBE_COL_TYPE (Get)
EXTFNAPIV4_DESCRIBE_COL_WIDTH (Set)
EXTFNAPIV4_DESCRIBE_COL_WIDTH (Get)
Generic describe_column Errors