FNC_TblControl Function | C Library Functions | Teradata Vantage - FNC_TblControl - Analytics Database - Teradata Vantage

SQL External Routine Programming

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2023-07-11
dita:mapPath
iiv1628111441820.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
B035-1147
lifecycle
latest
Product Category
Teradata Vantage™

Designates a table function as the controlling copy of all other copies of the table function running on other AMP vprocs.

IF the call is … THEN FNC_TblControl returns …
successful and the copy of table function can take the control role of the table function 1.
not successful and the copy of the table function should not assume the role of the control copy 0.

Use this library function when the return value of FNC_GetPhase is TBL_MODE_CONST, indicating that the SELECT statement invoked the table function with constant expression input arguments.

For example:

SELECT *
FROM TABLE (table_function_1('STRING_CONSTANT'))
AS table_1;

Syntax

int
FNC_TblControl(void)

Usage Notes

Setting up a controlling copy of a table function is useful when there is a need to distribute certain external control data among various copies of the table function that run on different AMP vprocs, but the external control data is on a particular node that only one copy of the table function can access.

Only one copy of the table function can successfully call FNC_TblControl.

After calling FNC_TblControl, the controlling copy of a table function can distribute control data to other table function copies by calling FNC_TblAllocCtrlCtx to allocate a control scratchpad.

This function can only be called from within a table function. Calling this function from a scalar function, aggregate function, UDM, or external stored procedure results in an exception on the transaction.

This function can only be called once.

A table function that calls FNC_TblControl cannot also call FNC_TblFirstParticipant.

Calling this function is valid only when the table function calls FNC_GetPhase and gets the following return values:
  • TBL_MODE_CONST for the FNC_Mode result
  • TBL_PRE_INIT for the FNC_Phase output argument

Example Using FNC_TblControl

typedef struct {
   unsigned short cntrl_fnc_AMP
   int            qfd;
   ...
} ctrl_ctx;

ctrl_ctx     *options;
AMP_Info_t   *LocalConfig;
FNC_Phase    Phase;

if (FNC_GetPhase(&Phase) == TBL_MODE_CONST)
{
   switch(Phase)
   {
      case TBL_PRE_INIT:
      {
         LocalConfig = FNC_AMPInfo();
         if ( FNC_TblControl() )             {
                options = FNC_TblAllocCtrlCtx(sizeof(ctrl_ctx));
            options->ctrl_fnc_AMP = LocalConfig->AMPId;
            ...
         }
      }
      ...
   }
}
...