Documentation Home
MySQL NDB Cluster API Developer Guide
Download this Manual Dictionary::beginSchemaTrans()

Description.  Starts a schema transaction. An error occurs if a transaction is already active, or if the kernel metadata is locked. You can determine whether a schema transaction already exists using the hasSchemaTrans() method.

A metadata operation occurs whenever data objects are created, altered, or dropped; such an operation can create additional suboperations in the NDB kernel.

The Ndb object and its associated Dictionary support one schema transaction at a time. By default, each metadata operation is executed separately; that is, for each operation, a schema transaction is started implicitly, the operation (including any suboperations) is executed, and the transaction is closed.

It is also possible to begin and end a schema transaction explicitly, and execute a set of user-defined operations atomically within its boundaries. In this case, all operations within the schema transaction either succeed, or are aborted and rolled back, as a unit. This is done by following the steps listed here:

  1. To begin the schema transaction, call beginSchemaTrans().

  2. Execute the desired operations (such as createTable()).

  3. End the schema transaction by calling endSchemaTrans.

Each operation is sent to the NDB kernel, which parses and saves it. A parse failure results in a rollback to the previous user operation before returning, at which point the user can either continue with or abort the entire transaction.

After all operations have been submitted, endSchemaTrans() processes and commits them. In the event of an error, the transaction is immediately aborted.

If the user exits before calling endSchemaTrans(), the NDB kernel aborts the transaction. If the user exits before the call to endSchemaTrans() returns, the kernel continues with the request, and its completion status is reported in the cluster log.


int beginSchemaTrans

Parameters.  None.

Return value.  Returns 0 on success, -1 on error.