| 560 | } |
| 561 | |
| 562 | bool vtkMySQLDatabase::CreateDatabase(const char* dbName, bool dropExisting = false) |
| 563 | { |
| 564 | if (dropExisting) |
| 565 | { |
| 566 | this->DropDatabase(dbName); |
| 567 | } |
| 568 | std::string queryStr; |
| 569 | queryStr = "CREATE DATABASE "; |
| 570 | queryStr += dbName; |
| 571 | bool status = false; |
| 572 | char* tmpName = this->DatabaseName; |
| 573 | bool needToReopen = false; |
| 574 | if (!strcmp(dbName, tmpName)) |
| 575 | { |
| 576 | this->Close(); |
| 577 | this->DatabaseName = nullptr; |
| 578 | needToReopen = true; |
| 579 | } |
| 580 | if (this->IsOpen() || this->Open(this->Password)) |
| 581 | { |
| 582 | vtkSQLQuery* query = this->GetQueryInstance(); |
| 583 | query->SetQuery(queryStr.c_str()); |
| 584 | status = query->Execute(); |
| 585 | query->Delete(); |
| 586 | } |
| 587 | if (needToReopen) |
| 588 | { |
| 589 | this->Close(); |
| 590 | this->DatabaseName = tmpName; |
| 591 | this->Open(this->Password); |
| 592 | } |
| 593 | return status; |
| 594 | } |
| 595 | |
| 596 | bool vtkMySQLDatabase::DropDatabase(const char* dbName) |
| 597 | { |
nothing calls this directly
no test coverage detected