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

Method RollbackTransaction

IO/PostgreSQL/vtkPostgreSQLQuery.cxx:529–572  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

527
528//------------------------------------------------------------------------------
529bool vtkPostgreSQLQuery::RollbackTransaction()
530{
531 if (!this->TransactionInProgress)
532 {
533 vtkErrorMacro(<< "Cannot rollback: no transaction is in progress.");
534 return false;
535 }
536
537 vtkPostgreSQLDatabase* db = vtkPostgreSQLDatabase::SafeDownCast(this->Database);
538 assert(db);
539
540 PGresult* result = PQexec(db->Connection->Connection, ROLLBACK_TRANSACTION);
541 bool status;
542 switch (PQresultStatus(result))
543 {
544 case PGRES_COMMAND_OK:
545 {
546 this->SetLastErrorText(nullptr);
547 this->TransactionInProgress = false;
548 status = true;
549 };
550 break;
551 case PGRES_FATAL_ERROR:
552 {
553 this->SetLastErrorText(PQresultErrorMessage(result));
554 vtkErrorMacro(<< "Error in RollbackTransaction: " << this->GetLastErrorText());
555 this->TransactionInProgress = false;
556 status = false;
557 };
558 break;
559 default:
560 {
561 this->SetLastErrorText(PQresultErrorMessage(result));
562 vtkWarningMacro(<< "Unexpected return code " << PQresultStatus(result) << " ("
563 << PQresStatus(PQresultStatus(result)) << ") with error message "
564 << (this->LastErrorText ? this->LastErrorText : "(null)"));
565 this->TransactionInProgress = false;
566 status = false;
567 };
568 break;
569 }
570 PQclear(result);
571 return status;
572}
573
574//------------------------------------------------------------------------------
575

Callers

nothing calls this directly

Calls 2

GetLastErrorTextMethod · 0.95
assertFunction · 0.50

Tested by

no test coverage detected