NdbDictionary::Dictionary Class Reference

Dictionary for defining and retreiving meta data. More...

#include <NdbDictionary.hpp>

List of all members.

Classes

class  List
 Structure for retrieving lists of object names. More...

Public Member Functions

NdbRecord * createRecord (const Table *table, const RecordSpecification *recSpec, Uint32 length, Uint32 elemSize, Uint32 flags=0)
NdbRecord * createRecord (const Index *index, const Table *table, const RecordSpecification *recSpec, Uint32 length, Uint32 elemSize, Uint32 flags=0)
NdbRecord * createRecord (const Index *index, const RecordSpecification *recSpec, Uint32 length, Uint32 elemSize, Uint32 flags=0)
void releaseRecord (NdbRecord *rec)
General
int listObjects (List &list, Object::Type type=Object::TypeUndefined)
int listObjects (List &list, Object::Type type=Object::TypeUndefined) const
struct NdbErrorgetNdbError () const
Retrieving references to Tables and Indexes
const TablegetTable (const char *name) const
const IndexgetIndex (const char *indexName, const char *tableName) const
int listIndexes (List &list, const char *tableName)
int listIndexes (List &list, const char *tableName) const
Events
int createEvent (const Event &event)
int dropEvent (const char *eventName, int force=0)
const EventgetEvent (const char *eventName)
int listEvents (List &list)
int listEvents (List &list) const
Table creation
These methods should normally not be used in an application as the result will not be visible from the MySQL Server

int createTable (const Table &table)
int optimizeTable (const Table &t, OptimizeTableHandle &h)
int optimizeIndex (const Index &ind, OptimizeIndexHandle &h)
int dropTable (Table &table)
int dropTable (const char *name)
bool supportedAlterTable (const Table &f, const Table &t)
void removeCachedTable (const char *table)
void removeCachedIndex (const char *index, const char *table)
Index creation
These methods should normally not be used in an application as the result will not be visible from the MySQL Server

int createIndex (const Index &index)
int createIndex (const Index &index, const Table &table)
int dropIndex (const char *indexName, const char *tableName)
Disk data objects
int createLogfileGroup (const LogfileGroup &, ObjectId *=0)
int dropLogfileGroup (const LogfileGroup &)
LogfileGroup getLogfileGroup (const char *name)
int createTablespace (const Tablespace &, ObjectId *=0)
int dropTablespace (const Tablespace &)
Tablespace getTablespace (const char *name)
Tablespace getTablespace (Uint32 tablespaceId)
int createDatafile (const Datafile &, bool overwrite_existing=false, ObjectId *=0)
int dropDatafile (const Datafile &)
Datafile getDatafile (Uint32 node, const char *path)
int createUndofile (const Undofile &, bool overwrite_existing=false, ObjectId *=0)
int dropUndofile (const Undofile &)
Undofile getUndofile (Uint32 node, const char *path)
HashMap
int createHashMap (const HashMap &, ObjectId *=0)
int getHashMap (HashMap &dst, const char *name)
int getHashMap (HashMap &dst, const Table *table)
int getDefaultHashMap (HashMap &dst, Uint32 fragments)
int initDefaultHashMap (HashMap &dst, Uint32 fragments)
int prepareHashMap (const Table &oldTable, Table &newTable)

Protected Member Functions

 Dictionary (Ndb &ndb)
 ~Dictionary ()

Private Member Functions

 Dictionary (NdbDictionaryImpl &)
const TablegetIndexTable (const char *indexName, const char *tableName) const

Private Attributes

class NdbDictionaryImpl & m_impl

Schema transactions

Metadata operations are create, alter, and drop of objects of various types. An operation may create additional sub-operations in the kernel.

By default, each user operation is executed separately. That is, a schema transaction is started implicitly, the operation and its suboperations are executed, and the transaction is closed.

The Ndb object and its associated Dictionary support one schema transaction at a time.

Using begin and end transaction explicitly it is possible to execute a set of user defined operations atomically i.e. either all operations succeed or all are aborted (rolled back).

The steps are 1) beginSchemaTrans 2) submit operations such as createTable 3) endSchemaTrans.

Each operation is sent to the kernel which parses and saves it. Parse failure does rollback to previous user operation before returning. The user can continue or abort entire transaction.

After all operations have been submitted, endSchemaTrans with flags 0 (the default) processes and commits them. On error return the transaction is already aborted.

If the user exits before calling endSchemaTrans, the kernel aborts the transaction. If the user exits before the call to endSchemaTrans returns, the kernel continues with the request. Completion status is reported in cluster log.

enum  SchemaTransFlag { SchemaTransAbort = 1, SchemaTransBackground = 2 }
int beginSchemaTrans ()
int endSchemaTrans (Uint32 flags=0)
bool hasSchemaTrans () const


Detailed Description

Dictionary for defining and retreiving meta data.

Member Enumeration Documentation

Flags for endSchemaTrans, or-ed together.

Enumerator:
SchemaTransAbort 
SchemaTransBackground 


Constructor & Destructor Documentation

NdbDictionary::Dictionary::Dictionary ( Ndb ndb  )  [protected]

NdbDictionary::Dictionary::~Dictionary (  )  [protected]

NdbDictionary::Dictionary::Dictionary ( NdbDictionaryImpl &   )  [private]


Member Function Documentation

int NdbDictionary::Dictionary::beginSchemaTrans (  ) 

Begin schema transaction. Returns error if a transaction is already active or if the kernel metadata is locked.

Returns:
0 on success, -1 on error

int NdbDictionary::Dictionary::createDatafile ( const Datafile ,
bool  overwrite_existing = false,
ObjectId = 0 
)

int NdbDictionary::Dictionary::createEvent ( const Event event  ) 

Create event given defined Event instance

Parameters:
event Event to create
Returns:
0 if successful otherwise -1.

int NdbDictionary::Dictionary::createHashMap ( const HashMap ,
ObjectId = 0 
)

Create a HashMap in database

int NdbDictionary::Dictionary::createIndex ( const Index index,
const Table table 
)

int NdbDictionary::Dictionary::createIndex ( const Index index  ) 

Create index given defined Index instance

Parameters:
index Index to create
Returns:
0 if successful otherwise -1.

int NdbDictionary::Dictionary::createLogfileGroup ( const LogfileGroup ,
ObjectId = 0 
)

NdbRecord* NdbDictionary::Dictionary::createRecord ( const Index index,
const RecordSpecification recSpec,
Uint32  length,
Uint32  elemSize,
Uint32  flags = 0 
)

NdbRecord* NdbDictionary::Dictionary::createRecord ( const Index index,
const Table table,
const RecordSpecification recSpec,
Uint32  length,
Uint32  elemSize,
Uint32  flags = 0 
)

NdbRecord* NdbDictionary::Dictionary::createRecord ( const Table table,
const RecordSpecification recSpec,
Uint32  length,
Uint32  elemSize,
Uint32  flags = 0 
)

int NdbDictionary::Dictionary::createTable ( const Table table  ) 

Create defined table given defined Table instance

Parameters:
table Table to create
Returns:
0 if successful otherwise -1.

int NdbDictionary::Dictionary::createTablespace ( const Tablespace ,
ObjectId = 0 
)

int NdbDictionary::Dictionary::createUndofile ( const Undofile ,
bool  overwrite_existing = false,
ObjectId = 0 
)

int NdbDictionary::Dictionary::dropDatafile ( const Datafile  ) 

int NdbDictionary::Dictionary::dropEvent ( const char *  eventName,
int  force = 0 
)

Drop event with given name

Parameters:
eventName Name of event to drop.
Returns:
0 if successful otherwise -1.

int NdbDictionary::Dictionary::dropIndex ( const char *  indexName,
const char *  tableName 
)

Drop index with given name

Parameters:
indexName Name of index to drop.
tableName Name of table that index belongs to.
Returns:
0 if successful otherwise -1.

int NdbDictionary::Dictionary::dropLogfileGroup ( const LogfileGroup  ) 

int NdbDictionary::Dictionary::dropTable ( const char *  name  ) 

Drop table given table name

Parameters:
name Name of table to drop
Returns:
0 if successful otherwise -1.

int NdbDictionary::Dictionary::dropTable ( Table table  ) 

Drop table given retrieved Table instance

Parameters:
table Table to drop
Returns:
0 if successful otherwise -1.

int NdbDictionary::Dictionary::dropTablespace ( const Tablespace  ) 

int NdbDictionary::Dictionary::dropUndofile ( const Undofile  ) 

int NdbDictionary::Dictionary::endSchemaTrans ( Uint32  flags = 0  ) 

End schema transaction, with commit or with abort. Combines execute and close which do not exist separately. May be called and succeeds even if no transaction is active.

Note:
Like any method, may overwrite current error code. First save error code from any failed operation.
Parameters:
flags Bitmask of options. Default 0 commits the transaction. Including option 1 aborts the transaction. See SchemaTransFlag for others.
Returns:
0 on success, -1 on error

Datafile NdbDictionary::Dictionary::getDatafile ( Uint32  node,
const char *  path 
)

int NdbDictionary::Dictionary::getDefaultHashMap ( HashMap dst,
Uint32  fragments 
)

Get default HashMap

const Event* NdbDictionary::Dictionary::getEvent ( const char *  eventName  ) 

Get event with given name.

Parameters:
eventName Name of event to get.
Returns:
an Event if successful, otherwise NULL.

int NdbDictionary::Dictionary::getHashMap ( HashMap dst,
const Table table 
)

Get a HashMap for a table

int NdbDictionary::Dictionary::getHashMap ( HashMap dst,
const char *  name 
)

Get a HashMap by name

const Index* NdbDictionary::Dictionary::getIndex ( const char *  indexName,
const char *  tableName 
) const

Get index with given name, NULL if undefined

Parameters:
indexName Name of index to get.
tableName Name of table that index belongs to.
Returns:
index if successful, otherwise 0.

const Table* NdbDictionary::Dictionary::getIndexTable ( const char *  indexName,
const char *  tableName 
) const [private]

LogfileGroup NdbDictionary::Dictionary::getLogfileGroup ( const char *  name  ) 

struct NdbError& NdbDictionary::Dictionary::getNdbError (  )  const [read]

Get the latest error

Returns:
Error object.

const Table* NdbDictionary::Dictionary::getTable ( const char *  name  )  const

Get table with given name, NULL if undefined

Parameters:
name Name of table to get
Returns:
table if successful otherwise NULL.

Tablespace NdbDictionary::Dictionary::getTablespace ( Uint32  tablespaceId  ) 

Tablespace NdbDictionary::Dictionary::getTablespace ( const char *  name  ) 

Undofile NdbDictionary::Dictionary::getUndofile ( Uint32  node,
const char *  path 
)

bool NdbDictionary::Dictionary::hasSchemaTrans (  )  const

Check if a schema transaction exists currently.

int NdbDictionary::Dictionary::initDefaultHashMap ( HashMap dst,
Uint32  fragments 
)

Init a default HashMap

int NdbDictionary::Dictionary::listEvents ( List list  )  const

int NdbDictionary::Dictionary::listEvents ( List list  ) 

List defined events

Parameters:
list List of events returned in the dictionary
Returns:
0 if successful otherwise -1.

int NdbDictionary::Dictionary::listIndexes ( List list,
const char *  tableName 
) const

int NdbDictionary::Dictionary::listIndexes ( List list,
const char *  tableName 
)

Fetch list of indexes of given table.

Parameters:
list Reference to list where to store the listed indexes
tableName Name of table that index belongs to.
Returns:
0 if successful, otherwise -1

int NdbDictionary::Dictionary::listObjects ( List list,
Object::Type  type = Object::TypeUndefined 
) const

int NdbDictionary::Dictionary::listObjects ( List list,
Object::Type  type = Object::TypeUndefined 
)

Fetch list of all objects, optionally restricted to given type.

Parameters:
list List of objects returned in the dictionary
type Restrict returned list to only contain objects of this type
Returns:
-1 if error.

int NdbDictionary::Dictionary::optimizeIndex ( const Index ind,
OptimizeIndexHandle h 
)

Start index optimization given defined index object

Parameters:
ind Object of index to optimize
Pre-allocated OptimizeIndexHandle
Returns:
0 if successful otherwise -1.

int NdbDictionary::Dictionary::optimizeTable ( const Table t,
OptimizeTableHandle h 
)

Start table optimization given defined table object

Parameters:
t Object of table to optimize
Pre-allocated OptimizeTableHandle
Returns:
0 if successful otherwise -1.

int NdbDictionary::Dictionary::prepareHashMap ( const Table oldTable,
Table newTable 
)

create (or retreive) a HashMap suitable for alter NOTE: Requires a started schema transaction

void NdbDictionary::Dictionary::releaseRecord ( NdbRecord *  rec  ) 

void NdbDictionary::Dictionary::removeCachedIndex ( const char *  index,
const char *  table 
)

Remove index from local cache

void NdbDictionary::Dictionary::removeCachedTable ( const char *  table  ) 

Remove table from local cache

bool NdbDictionary::Dictionary::supportedAlterTable ( const Table f,
const Table t 
)

Check if alter of table given defined Table instance to new definition is supported

Parameters:
f Table to alter
t New definition of table
Returns:
TRUE supported
FALSE not supported


Member Data Documentation

class NdbDictionaryImpl& NdbDictionary::Dictionary::m_impl [private]


The documentation for this class was generated from the following file:

MySQL Cluster Database Blog

Based on MySQL Cluster 7.0.7.

This page is for information only and is not maintained by MySQL or Sun Microsystems - use at your own risk. For an upto date view of the API refer to the header files included with your MySQL Cluster distribution or check the MySQL Cluster API Developer Guide.