------------------------------------------------------------------------------
| 428 | |
| 429 | //------------------------------------------------------------------------------ |
| 430 | vtkStringArray* 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 | //------------------------------------------------------------------------------ |
| 470 | bool vtkPostgreSQLDatabase::IsSupported(int feature) |
nothing calls this directly
no test coverage detected