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

Method GetRecord

IO/PostgreSQL/vtkPostgreSQLDatabase.cxx:430–467  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

428
429//------------------------------------------------------------------------------
430vtkStringArray* vtkPostgreSQLDatabase::GetRecord(const char* table)
431{
432 // NB: There are *too many* other column names to list. Even the ones
433 // currently in the query below are probably over the top. But there's
434 // just so much peanut-buttery goodness in the table, I couldn't resist.
435 vtkSQLQuery* query = this->GetQueryInstance();
436 std::string text("SELECT "
437 "column_name,column_default,data_type,is_nullable,character_maximum_length,"
438 "numeric_precision,datetime_precision"
439 " FROM information_schema.columns"
440 " WHERE table_name='");
441 text += table;
442 text += "' ORDER BY ordinal_position";
443
444 query->SetQuery(text.c_str());
445 bool status = query->Execute();
446 if (!status)
447 {
448 vtkErrorMacro(<< "GetRecord(" << table
449 << "): Database returned error: " << query->GetLastErrorText());
450 this->SetLastErrorText(query->GetLastErrorText());
451 query->Delete();
452 return nullptr;
453 }
454
455 // Each row in the results that come back from this query
456 // describes a single column in the table.
457 vtkStringArray* results = vtkStringArray::New();
458
459 while (query->NextRow())
460 {
461 results->InsertNextValue(query->DataValue(0).ToString());
462 }
463
464 query->Delete();
465 this->SetLastErrorText(nullptr);
466 return results;
467}
468
469//------------------------------------------------------------------------------
470bool vtkPostgreSQLDatabase::IsSupported(int feature)

Callers

nothing calls this directly

Calls 11

GetQueryInstanceMethod · 0.95
DeleteMethod · 0.65
NewFunction · 0.50
SetQueryMethod · 0.45
c_strMethod · 0.45
ExecuteMethod · 0.45
GetLastErrorTextMethod · 0.45
NextRowMethod · 0.45
InsertNextValueMethod · 0.45
ToStringMethod · 0.45
DataValueMethod · 0.45

Tested by

no test coverage detected