16.20 - FNC_Where_Am_I - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL External Routine Programming

Advanced SQL Engine
Teradata Database
Release Number
Release Date
April 2020
Content Type
Programming Reference
Publication ID
English (United States)


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.


Vproc_Info_t *

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;


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
      ... process error: Transaction GLOP does not exist
   SysInfoPtr = MyGLOP->GLOP[TRAN_MAP].GLOP_ptr;

   . . .

   /* do non AMP processing here */