271
index container is also updated after this operation is successful. In the update_row()
method defined in Listing 13-9, the old_data field will have the previous row record in it,
while new_data will have the new data.
Listing 13-9. ha_pmdk.cc – Updating existing row data
506 int ha_pmdk::update_row(const uchar *old_data, const uchar *new_data)
507 {
...
540
if (k->verifyKey(key_str))
541
k->updateRow(key_str, field_str);
...
551
if (current)
552
memcpy(current->buf, new_data, table->s->reclength);
...
The index table is also updated using the updateRow() method shown in Listing 13- 10.
Listing 13-10. ha_pmdk.cc – Updating existing row data
1363 bool key::updateRow(const std::string oldStr, const std::string newStr)
1364 {
...
1366
persistent_ptr row_;
1367
bool ret = false;
1368
rowItr matchingEleIt = getCurrent();
1369
1370
if (matchingEleIt->first == oldStr) {
1371
row_ = matchingEleIt->second;
1372
std::pair > r(newStr, row_);
1373
rows.erase(matchingEleIt);
1374
rows.insert(r);
1375
ret = true;
1376
}
1377
DBUG_RETURN(ret);
1378 }
Chapter 13 enabling persistenCe Using a real-World appliCation
Précédent

- 295/457

Suivant