Previous Topic

Next Topic

Adding an existing table under transaction control

An extra level of data integrity may be achieved when you add an existing table to a database under transaction control. When the transaction is committed the database dictionary data for the table is committed to disk. If the transaction is aborted, the dictionary data for the table is automatically removed from the database dictionary.

The code fragment below shows how to add an existing table under transaction control. No error checking is included in the sample code:

/* begin a transaction */
ctdbBegin(hDatabase);

/* add MyTable to the current database */
if (ctdbAddTable(hDatabase, “MyTable”, “”) != CTDBRET_OK) {
   printf(“Add table failed\n”);
   ctdbAbort(hDatabase);
} else {
   printf(“Add table\n”);
   ctdbCommit(hDatabase);
}