272
DELETE Operation
The DELETE operation is implemented using the delete_row() method. Three different
scenarios should be considered:
• Deleting an indexed value from the indexed table
• Deleting a non-indexed value from the indexed table
• Deleting a field from the non-indexed table
For each scenario, different functions are called. When the operation is successful,
the entry is removed from both the index (if the table is an indexed table) and persistent
memory. Listing 13-11 shows the logic to implement the three scenarios.
Listing 13-11. ha_pmdk.cc – Updating existing row data
594 int ha_pmdk::delete_row(const uchar *buf)
595 {
...
602
// Delete the field from non indexed table
603
if (active_index == 64 && table->s->keys ==0 ) {
604
if (current)
605
deleteNodeFromSLL();
606
} else if (active_index == 64 && table->s->keys !=0 ) { // Delete
non indexed column field from indexed table
607
if (current) {
608
deleteRowFromAllIndexedColumns(current);
609
deleteNodeFromSLL();
610
}
611
} else { // Delete indexed column field from indexed table
612
database *db = database::getInstance();
613
table_ *tab;
614
key *k;
615
KEY_PART_INFO *key_part = table->key_info[active_index].key_part;
616
if (db->getTable(table->s->table_name.str, &tab)) {
617
if (tab->getKeys(key_part->field->field_name.str, &k)) {
618
rowItr currNode = k->getCurrent();
619
rowItr prevNode = std::prev(currNode);
Chapter 13 enabling persistenCe Using a real-World appliCation
DELETE Operation
The DELETE operation is implemented using the delete_row() method. Three different
scenarios should be considered:
• Deleting an indexed value from the indexed table
• Deleting a non-indexed value from the indexed table
• Deleting a field from the non-indexed table
For each scenario, different functions are called. When the operation is successful,
the entry is removed from both the index (if the table is an indexed table) and persistent
memory. Listing 13-11 shows the logic to implement the three scenarios.
Listing 13-11. ha_pmdk.cc – Updating existing row data
594 int ha_pmdk::delete_row(const uchar *buf)
595 {
...
602
// Delete the field from non indexed table
603
if (active_index == 64 && table->s->keys ==0 ) {
604
if (current)
605
deleteNodeFromSLL();
606
} else if (active_index == 64 && table->s->keys !=0 ) { // Delete
non indexed column field from indexed table
607
if (current) {
608
deleteRowFromAllIndexedColumns(current);
609
deleteNodeFromSLL();
610
}
611
} else { // Delete indexed column field from indexed table
612
database *db = database::getInstance();
613
table_ *tab;
614
key *k;
615
KEY_PART_INFO *key_part = table->key_info[active_index].key_part;
616
if (db->getTable(table->s->table_name.str, &tab)) {
617
if (tab->getKeys(key_part->field->field_name.str, &k)) {
618
rowItr currNode = k->getCurrent();
619
rowItr prevNode = std::prev(currNode);
Chapter 13 enabling persistenCe Using a real-World appliCation
