DB2 Version 9.7 for Linux, UNIX, and Windows

db2GetDistMap API - Get distribution map

Allows an application to obtain the distribution information for a table. The distribution information includes the distribution map and the column definitions of the distribution key.

Information returned by this API can be passed to the db2GetRowPartNum API to determine the database partition number and the database partition server number for any row in the table.

To use this API, the application must be connected to the database that contains the table for which distribution information is being requested.

Scope

This API can be executed on any database partition server defined in the db2nodes.cfg file.

Authorization

For the table being referenced, a user must have at least one of the following authorities or privileges:
  • DATAACCESS authority
  • CONTROL privilege
  • SELECT privilege

Required connection

Database

API include file

db2ApiDf.h

API and data structure syntax

db2GetDistMap (
   sqluint32 db2VersionNumber,                    /* Database version number   */
   void * pParmStruct,                            /* In/out parameters         */
   struct sqlca * pSqlca);                        /* SQLCA                     */

where
SQL_STRUCTURE db2DistMapStruct
{
   unsigned char                       *tname;    /* Fully qualified table     */
                                                  /* name                      */
   struct db2PartitioningInfo          *partinfo; /* Partitioning              */
                                                  /* Information               */
};

SQL_STRUCTURE db2PartitioningInfo
{
   sqluint32                           pmaplen;   /* Length of partitioning    */
                                                  /* map                       */
   SQL_PDB_NODE_TYPE                   *pmap;     /* Partitioning map          */
   unsigned short                      sqld;      /* # of used                 */
                                                  /* db2PartitioningKey        */
                                                  /* elements                  */
   struct db2PartitioningKey           sqlpartkey[SQL_MAX_NUM_PART_KEYS]; /*   */
                                                  /* KEYS                      */
};

SQL_STRUCTURE db2PartitioningKey
{
   unsigned short                      sqltype;   /* Date Type of Key          */
   unsigned short                      sqllen;    /* Data Length of Key        */
};

db2GetDistMap API parameters

tname
The fully qualified name of the table.
pmaplen
The length of the distribution map.
pmap
The name of the distribution map.
sqld
The number of elements used in the sqlpartkey structure.
sqlpartkey
Distribution keys used for the table.

Usage notes

The pmap in db2PartitioningInfo structure must point to an array of SQL_PDB_MAP_SIZE_32K entries.