59
59
DT_FIELD_INFO pbms_backup_info[]=
61
{"Id", NULL, NULL, MYSQL_TYPE_LONG, NULL, NOT_NULL_FLAG, "The backup reference ID"},
61
{"Id", NOVAL, NULL, MYSQL_TYPE_LONG, NULL, NOT_NULL_FLAG, "The backup reference ID"},
62
62
{"Database_Name", 64, NULL, MYSQL_TYPE_VARCHAR, &UTF8_CHARSET, NOT_NULL_FLAG, "The database name"},
63
{"Database_Id", NULL, NULL, MYSQL_TYPE_LONG, NULL, 0, "The database ID"},
63
{"Database_Id", NOVAL, NULL, MYSQL_TYPE_LONG, NULL, 0, "The database ID"},
64
64
{"Started", 32, NULL, MYSQL_TYPE_VARCHAR, &UTF8_CHARSET, 0, "The start time"},
65
65
{"Completed", 32, NULL, MYSQL_TYPE_VARCHAR, &UTF8_CHARSET, 0, "The completion time"},
66
66
{"IsRunning", 3, NULL, MYSQL_TYPE_VARCHAR, &UTF8_CHARSET, 0, "Is the backup still running"},
67
67
{"IsDump", 3, NULL, MYSQL_TYPE_VARCHAR, &UTF8_CHARSET, 0, "Is the backup the result of a dump"},
68
68
{"Location", 1024, NULL, MYSQL_TYPE_VARCHAR, &UTF8_CHARSET, 0, "The backup location"},
69
{"Cloud_Ref", NULL, NULL, MYSQL_TYPE_LONG, NULL, 0, "The S3 cloud reference number refering to the pbms.pbms_cloud table."},
70
{"Cloud_Backup_No", NULL, NULL, MYSQL_TYPE_LONG, NULL, 0, "The cloud backup number"},
71
{NULL,NULL, NULL, MYSQL_TYPE_STRING,NULL, 0, NULL}
69
{"Cloud_Ref", NOVAL, NULL, MYSQL_TYPE_LONG, NULL, 0, "The S3 cloud reference number refering to the pbms.pbms_cloud table."},
70
{"Cloud_Backup_No", NOVAL, NULL, MYSQL_TYPE_LONG, NULL, 0, "The cloud backup number"},
71
{NULL,NOVAL, NULL, MYSQL_TYPE_STRING,NULL, 0, NULL}
74
74
DT_KEY_INFO pbms_backup_keys[]=
469
class InsertRowCleanUp : public CSRefObject {
477
InsertRowCleanUp(CSThread *self): CSRefObject(),
478
do_cleanup(true), myself(self){}
483
myself->logException();
485
MSBackupInfo::gBackupInfo->remove(ref_id);
490
void setCleanUp(uint32_t id)
461
502
void MSBackupTable::insertRow(char *data)
463
504
uint32_t ref_id = 0, db_id, cloud_ref, cloud_backup_no;
464
505
String name, start, end, isRunning, isDump, location;
465
506
MSBackupInfo *info = NULL;
466
507
const char *db_name;
467
bool duplicate = true;
508
InsertRowCleanUp *cleanup;
472
getFieldValue(data, 0, &ref_id);
474
// The id must be unique.
475
if (ref_id && MSBackupInfo::gBackupInfo->get(ref_id)) {
476
CSException::throwException(CS_CONTEXT, MS_ERR_DUPLICATE, "Attempt to insert a row with a duplicate key in the "BACKUP_TABLE_NAME" table.");
480
// The 'Database_Id', 'Start', 'Completion' and "IsDump" fields are ignored.
481
// I still need to get the fields though to advance the field position pointer.
482
getFieldValue(data, 1, &name);
483
getFieldValue(data, 2, &db_id);
484
getFieldValue(data, 3, &start);
485
getFieldValue(data, 4, &end);
486
getFieldValue(data, 5, &isRunning);
487
getFieldValue(data, 6, &isDump);
488
getFieldValue(data, 7, &location);
489
getFieldValue(data, 8, &cloud_ref);
490
getFieldValue(data, 9, &cloud_backup_no);
493
ref_id = MSBackupInfo::gMaxInfoRef++;
494
else if (ref_id >= MSBackupInfo::gMaxInfoRef)
495
MSBackupInfo::gMaxInfoRef = ref_id +1;
497
db_name = name.c_ptr();
498
db_id = MSDatabase::getDatabaseID(db_name, false);
500
new_(info, MSBackupInfo(ref_id, db_name, db_id, 0, 0, false, location.c_ptr(), cloud_ref, cloud_backup_no));
501
MSBackupInfo::gBackupInfo->set(ref_id, info);
503
// There is no need to call this now, startBackup() will call it
504
// after the backup is started.
505
// saveTable(RETAIN(myShare->mySysDatabase));
506
info->startBackup(RETAIN(myShare->mySysDatabase));
512
new_(cleanup, InsertRowCleanUp(self));
515
getFieldValue(data, 0, &ref_id);
517
// The id must be unique.
518
if (ref_id && MSBackupInfo::gBackupInfo->get(ref_id)) {
519
CSException::throwException(CS_CONTEXT, MS_ERR_DUPLICATE, "Attempt to insert a row with a duplicate key in the "BACKUP_TABLE_NAME" table.");
510
// It is good to know the details if the backup could not be started.
511
self->logException();
512
if (ref_id && ! duplicate)
513
MSBackupInfo::gBackupInfo->remove(ref_id);
522
// The 'Database_Id', 'Start', 'Completion' and "IsDump" fields are ignored.
523
// I still need to get the fields though to advance the field position pointer.
524
getFieldValue(data, 1, &name);
525
getFieldValue(data, 2, &db_id);
526
getFieldValue(data, 3, &start);
527
getFieldValue(data, 4, &end);
528
getFieldValue(data, 5, &isRunning);
529
getFieldValue(data, 6, &isDump);
530
getFieldValue(data, 7, &location);
531
getFieldValue(data, 8, &cloud_ref);
532
getFieldValue(data, 9, &cloud_backup_no);
535
ref_id = MSBackupInfo::gMaxInfoRef++;
536
else if (ref_id >= MSBackupInfo::gMaxInfoRef)
537
MSBackupInfo::gMaxInfoRef = ref_id +1;
539
db_name = name.c_ptr();
540
db_id = MSDatabase::getDatabaseID(db_name, false);
542
cleanup->setCleanUp(ref_id);
543
new_(info, MSBackupInfo(ref_id, db_name, db_id, 0, 0, false, location.c_ptr(), cloud_ref, cloud_backup_no));
544
MSBackupInfo::gBackupInfo->set(ref_id, info);
546
// There is no need to call this now, startBackup() will call it
547
// after the backup is started.
548
// saveTable(RETAIN(myShare->mySysDatabase));
549
info->startBackup(RETAIN(myShare->mySysDatabase));
551
cleanup->cancelCleanUp();