MCPcopy Create free account
hub / github.com/Kitware/VTK / DropDatabase

Method DropDatabase

IO/PostgreSQL/vtkPostgreSQLDatabase.cxx:600–644  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

598
599//------------------------------------------------------------------------------
600bool vtkPostgreSQLDatabase::DropDatabase(const char* dbName)
601{
602 if (!dbName || strlen(dbName) == 0)
603 {
604 vtkErrorMacro("DropDatabase called with an empty database name");
605 return false;
606 }
607
608 if (!strcmp(dbName, this->DatabaseName))
609 {
610 // Can't drop database we're connected to... connect to the default db.
611 this->SetDatabaseName("template1");
612 }
613
614 if (!this->Connection)
615 {
616 bool err = true;
617 if (this->DatabaseName && this->HostName)
618 {
619 err = !this->Open();
620 }
621 if (err)
622 {
623 vtkErrorMacro("Must be connected to a server to create a database.");
624 return false;
625 }
626 }
627
628 std::string qstr("DROP DATABASE IF EXISTS \"");
629 qstr += dbName;
630 qstr += "\"";
631 vtkSQLQuery* query = this->GetQueryInstance();
632 query->SetQuery(qstr.c_str());
633 if (!query->Execute())
634 {
635 this->SetLastErrorText(query->GetLastErrorText());
636 vtkErrorMacro(<< "Could not drop database \"" << dbName << "\". "
637 << query->GetLastErrorText());
638 query->Delete();
639 return false;
640 }
641 this->SetLastErrorText(nullptr);
642 query->Delete();
643 return true;
644}
645
646void vtkPostgreSQLDatabase::NullTrailingWhitespace(char* msg)
647{

Callers 3

CreateDatabaseMethod · 0.95
TestPostgreSQLDatabaseFunction · 0.45

Calls 7

OpenMethod · 0.95
GetQueryInstanceMethod · 0.95
DeleteMethod · 0.65
SetQueryMethod · 0.45
c_strMethod · 0.45
ExecuteMethod · 0.45
GetLastErrorTextMethod · 0.45

Tested by 2

TestPostgreSQLDatabaseFunction · 0.36