16.20 - FNC_Where_Am_I - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
16.20
Release Date
April 2020
Content Type
Programming Reference
Publication ID
B035-1147-162K
Language
English (United States)

Purpose

Provides information as to the specific node ID, vproc ID, vproc type, and task ID for the currently running external routine. This is useful if an external routine organizes GLOP data according to where it is invoked from.

Syntax

Vproc_Info_t *
FNC_Where_Am_I(void);

Return Value

FNC_Where_Am_I returns a pointer to a Vproc_Info_t structure.

The Vproc_Info_t structure is defined as:

typdedef struct
{
   unsigned short NumAMPs;
   unsigned short NumPEs;
   unsigned short NodeId;
   unsigned short VprocId;
   vproc_type     Vtype;
} Vproc_Info_t;

where:

Member … Specifies the …
NumAMPs total number of online AMPs in the system.
NumPEs total number of PEs in the system.
NodeId unique number of the node.
VprocId unique number of the vproc.
Vtype type of vproc, where the vproc_type enumeration is defined as:
typedef enum
{
   UNK_VPROC = 0    /* vproc type unknown */
   AMP_VPROC = 1,   /* AMP vproc */
   PE_VPROC = 2     /* PE vproc */
} vproc_type;

Usage Notes

FNC_Where_Am_I provides information on the number vprocs of each type (AMP and PE), and what node, vproc, and type of vproc the external routine is running on. An external routine can use FNC_Where_Am_I to help configure GLOP data that might require a different set up when executing on a PE instead of an AMP or data that might need to be divided up based on the number of AMP vprocs for a global copy operation.

Example Using FNC_Where_Am_I

Here is a code excerpt that shows how an external routine might use FNC_Where_Am_I to find out what processor type it is executing on and only process transaction-related GLOP changes if it is running on an AMP.

#define TRAN_MAP  0
Sysinfo_t     SysInfoPtr;
GLOP_Map_t   *MyGLOP;
Vproc_Info_t *MyVproc_info;
int           glop_stat;

   . . .

 MyVproc_info = FNC_Where_Am_I(); 

/* only bother with GLOP map if we are running on an AMP */
if (MyVproc->Vtype == AMP_VPROC)
{
   glop_stat = FNC_Get_GLOP_Map(&MyGLOP);

   if (glop_stat)
      ... process error: Not a member of any GLOP set
   if ( MyGLOP->GLOP[TRAN_MAP].GLOP_Ptr == NULL)
   {
      ... process error: Transaction GLOP does not exist
   };
   SysInfoPtr = MyGLOP->GLOP[TRAN_MAP].GLOP_ptr;

   . . .

}
else
{
   /* do non AMP processing here */
}