The CDC_REC_DISCARD record

Indicates that some operations of the transaction should be discarded.

CDC records for the same transaction that follow this record should be discarded.

The header specific to the CDC_REC_DISCARD record follows the common header. No data follows the headers; the payload size in the common header is 0.

Table 1. Format of the CDC_REC_DISCARD record
Section Size Description
Sequence number 8 bytes The sequence number of the record. Any CDC records that have the same transaction ID value and that have a sequence number greater than or equal to this sequence number should be discarded.
Transaction ID 4 bytes The transaction ID.

Example

The following example creates a savepoint, inserts data, rolls back the transaction to the savepoint, then inserts and commits data:

> begin work;
Started transaction.
> savepoint sp1;
Savepoint set.
> insert into t1(c1) values (2000);
1 row(s) inserted.
> insert into t1(c1) values (2001);
1 row(s) inserted.
> rollback to savepoint sp1;
Transaction rolled back to savepoint.
> insert into t1(c1) values(2);
1 row(s) inserted.> commit;
Data committed.

The following records are generated:

Got Record type   CDC_REC_BEGINTX. Size =    0 LSN = 28:0xaa5018. TXID = 25
    Time = 2016-03-30 11:59:26
Raw Data:  (0/0x0 bytes at address 0xc54420)
bytesread is 58 loreaderr is 0 SQLCODE 0
Got Record type    CDC_REC_INSERT. Size =   22 LSN = 28:0xaa5050. TXID = 25
    TabID = 0
Raw IUD Data:  (22/0x16 bytes at address 0xc54434)
00 00 07 d0 00 20 20 20 20 20 20 20 20 20 80 00 .....         ..
00 00 80 00 00 00                               ......
    Column Value = 2000
    Column Value = 'NULL'
    Column Value = NULL
    Column Value = NULL
bytesread is 58 loreaderr is 0 SQLCODE 0
Got Record type    CDC_REC_INSERT. Size =   22 LSN = 28:0xaa50a8. TXID = 25
    TabID = 0
Raw IUD Data:  (22/0x16 bytes at address 0xc54434)
00 00 07 d1 00 20 20 20 20 20 20 20 20 20 80 00 .....         ..
00 00 80 00 00 00                               ......
    Column Value = 2001
    Column Value = 'NULL'
    Column Value = NULL
    Column Value = NULL
bytesread is 28 loreaderr is 0 SQLCODE 0
Got Record type   CDC_REC_DISCARD. Size =    0     Total record size = 0
    LSN = 28:0xaa5050
    TXID = 25
bytesread is 58 loreaderr is 0 SQLCODE 0
Got Record type    CDC_REC_INSERT. Size =   22 LSN = 28:0xaa5150. TXID = 25
    TabID = 0
Raw IUD Data:  (22/0x16 bytes at address 0xc54434)
00 00 00 02 00 20 20 20 20 20 20 20 20 20 80 00 .....         ..
00 00 80 00 00 00                               ......
    Column Value = 2
    Column Value = 'NULL'
    Column Value = NULL
    Column Value = NULL
bytesread is 36 loreaderr is 0 SQLCODE 0
Got Record type    CDC_REC_COMMTX. Size =    0 LSN = 28:0xaa51a8. TXID = 25
    Time = 2016-03-30 11:59:47
Raw Data:  (0/0x0 bytes at address 0xc54420)

The CDC_REC_DISCARD record indicates that for transaction 25, the records starting from LSN 28:0xaa5050 and until the CDC_REC_DISCARD record are discarded. The insert of the values "2000" and "2001" are discarded because the client rolled back to the savepoint. The records after the CDC_REC_DISCARD record are valid actions in the transaction. For example, the CDC_REC_INSERT at 28:0xaa5150, which corresponds to the insert of the value "2", is committed.