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

Method NextRow

IO/MySQL/vtkMySQLQuery.cxx:748–797  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

746//------------------------------------------------------------------------------
747
748bool vtkMySQLQuery::NextRow()
749{
750 if (!this->IsActive())
751 {
752 vtkErrorMacro(<< "NextRow(): Query is not active!");
753 return false;
754 }
755
756 MYSQL_ROW row = mysql_fetch_row(this->Internals->Result);
757 this->Internals->CurrentRow = row;
758 this->Internals->CurrentLengths = mysql_fetch_lengths(this->Internals->Result);
759
760 if (!row)
761 {
762 // A null row will come back in one of two situations. The first
763 // is when there's an error, in which case mysql_errno will return
764 // some nonzero error code. The second is when there are no more
765 // rows to fetch. Discriminate between the two by checking the
766 // errno.
767 this->Active = false;
768 vtkMySQLDatabase* dbContainer = static_cast<vtkMySQLDatabase*>(this->Database);
769 assert(dbContainer != nullptr);
770 if (!dbContainer->IsOpen())
771 {
772 vtkErrorMacro(<< "Cannot get field type. Database is closed.");
773 this->SetLastErrorText("Database is closed.");
774 return VTK_VOID;
775 }
776 MYSQL* db = dbContainer->Private->Connection;
777 assert(db != nullptr);
778
779 if (mysql_errno(db) != 0)
780 {
781 this->SetLastErrorText(mysql_error(db));
782 vtkErrorMacro(<< "NextRow(): MySQL returned error message " << this->GetLastErrorText());
783 }
784 else
785 {
786 // Nothing's wrong. We're just out of results.
787 this->SetLastErrorText(nullptr);
788 }
789
790 return false;
791 }
792 else
793 {
794 this->SetLastErrorText(nullptr);
795 return true;
796 }
797}
798
799//------------------------------------------------------------------------------
800

Callers 2

RequestDataMethod · 0.45
TestMySQLDatabaseFunction · 0.45

Calls 3

GetLastErrorTextMethod · 0.95
assertFunction · 0.50
IsOpenMethod · 0.45

Tested by 1

TestMySQLDatabaseFunction · 0.36