The Immediate Independent Commit Transaction, IICT, permits a thread with an active, pending transaction to also execute immediate commit transactions, even on the same physical file that may have been updated by the still pending (regular) transaction. An IICT is essentially an auto commit ISAM update, but with the added characteristic that an IICT can be executed even while a transaction is pending for the same user (thread).
It is important to note that the IICT is independent of the existing transaction: it is as if another user/thread is executing the IICT. The following pseudo code example demonstrates this independence:
Example
If we did not switch to IICT mode, the second add would have failed with a KDUP_ERR (2); however, the IICT mode made the second add use a separate transaction and the second add found a pending add for key U, hence the TPND_ERR. Just as if another thread had a key U add pending.
A data file and it's associated indices are put into IICT mode with a call
PUTHDR(datno,1,ctIICThdr)
and are restored to regular mode with a call
PUTHDR(datno,0,ctIICThdr)
It is possible in c-tree for a thread to open the same file in shared mode more than once, each open using a different user file number. And it is possible to put one or more of these files in IICT mode while the remaining files stay in regular mode.
Note: If a file has been opened more than once by the same thread, then the updates within a (regular) transaction made to the different file numbers are treated the same as if only one open had occurred.
These special filno values enable specific IICT operations:
IICT File Create Example
TRANBEG(ctTRNLOG|ctENABLE);
if ((rc = PUTHDR(ctIICTbegin, ctTRNLOG, ctIICThdr))) {
printf("Error: Failed to switch into IICT mode: %d\n", rc);
goto err_ret;
}
if ((rc = CREIFILX8(&vcustomer, NULL, NULL, 0L, NULL, NULL, xcreblk))) {
printf("Error: Failed to create files: %d\n", rc);
goto err_ret;
}
if ((rc = PUTDODA(vcustomer.tfilno, doda, 7))) {
printf("Error: Failed to add DODA to file: %d\n", rc);
goto err_ret;
}
CLIFIL(&vcustomer);
if ((rc = PUTHDR(ctIICTcommit, 0, ctIICThdr))) {
printf("Error: Failed to switch out of IICT mode: %d\n", rc);
goto err_ret;
}
if ((rc = TRANABT())) {
printf("Error: Failed to abort transaction: %d\n", rc);
goto err_ret;
}
if ((rc = OPNIFIL(&vcustomer))) {
printf("Error: Failed to open files after committing IICT and aborting tran: %d sysiocod=%d\n", rc, sysiocod);
goto err_ret;
}
printf("Sucessfully opened files after committing IICT and aborting tran.\n");
IICT Record Add Example
if ((rc = OPNIFIL(&vcustomer))) {
printf("Error: Failed to open files: %d\n",
rc);
goto err_ret;
}
datno2 = vcustomer.tfilno;
if ((rc = PUTHDR(datno2, 1, ctIICThdr))) {
printf("Error: Failed to switch into IICT mode for file: %d\n",
rc);
goto err_ret;
}
/* start general IICT */
if ((rc = PUTHDR(ctIICTbegin, ctTRNLOG, ctIICThdr))) {
printf("Error: Failed to switch into IICT mode: %d\n",
rc);
goto err_ret;
}
/* add record to file with file-specific IICT enabled */
memset(recbuf, 'c', reclen);
if ((rc = ADDVREC(datno2, recbuf, reclen))) {
printf("Error: Failed to add record: %d\n",
rc);
goto err_ret;
}
/* complete the IICT */
if ((rc = PUTHDR(ctIICTcommit, 0, ctIICThdr))) {
printf("Error: Failed to switch out of IICT mode: %d\n",
rc);
goto err_ret;
}
if ((rc = TRANABT())) {
printf("Error: Failed to abort transaction: %d\n",
rc);
goto err_ret;
}
if ((rc = FRSVREC(datno2, recbuf, &reclen))) {
printf("Error: Failed to read record: %d\n",
rc);
goto err_ret;
}