FNC_Where_Am_I Function | C Library Functions | Teradata Vantage - 17.10 - FNC_Where_Am_I - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - SQL External Routine Programming

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

Provides information about 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.

Returns a pointer to a Vproc_Info_t structure.


Vproc_Info_t *
FNC_Where_Am_I (void);
typdedef struct
   unsigned short NumAMPs;
   unsigned short NumPEs;
   unsigned short NodeId;
   unsigned short VprocId;
   vproc_type     Vtype;
} Vproc_Info_t;

Syntax Elements

Number of online AMPs in the system.
Number of PEs in the system.
Unique number of the node.
Unique number of the vproc.
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 */