Manages the schema for a workload management table. If the table does not exist, it is created. If it does exist, but is not on the schema version specified via the command line flag, it is altered to bring it up to the new version.
| 460 | /// created. If it does exist, but is not on the schema version specified via the command |
| 461 | /// line flag, it is altered to bring it up to the new version. |
| 462 | static Status _tableSchemaManagement(Catalog* catalog, CatalogServiceIf* svc, |
| 463 | const string& ip_addr, const string& table_name, const Version& target_schema_version, |
| 464 | const bool is_system_table) { |
| 465 | Version parsed_actual_schema_version; |
| 466 | |
| 467 | // Create and/or update the table if needed. |
| 468 | RETURN_IF_ERROR(_getTableSchemaVersion( |
| 469 | catalog, svc, ip_addr, WM_DB, table_name, &parsed_actual_schema_version)); |
| 470 | |
| 471 | const string full_table_name = _fullTableName(WM_DB, table_name); |
| 472 | |
| 473 | if (parsed_actual_schema_version == target_schema_version) { |
| 474 | LOG(INFO) << "Target schema version '" << target_schema_version.ToString() |
| 475 | << "' matches actual schema version '" |
| 476 | << parsed_actual_schema_version.ToString() << "' for the '" |
| 477 | << full_table_name << "' table"; |
| 478 | } else if (parsed_actual_schema_version == NO_TABLE_EXISTS) { |
| 479 | LOG(INFO) << "Creating table '" << full_table_name << "' on schema version '" |
| 480 | << target_schema_version.ToString() << "'"; |
| 481 | RETURN_IF_ERROR( |
| 482 | _createTable(svc, ip_addr, table_name, target_schema_version, is_system_table)); |
| 483 | } else if (parsed_actual_schema_version > target_schema_version) { |
| 484 | // Actual schema version is greater than the target schema version. |
| 485 | LOG(WARNING) << "Target schema version '" << target_schema_version.ToString() |
| 486 | << "' of the '" << full_table_name |
| 487 | << "' table is lower than the actual schema " |
| 488 | << "version '" << parsed_actual_schema_version.ToString() << "'"; |
| 489 | } else { |
| 490 | // Target schema version is greater than the actual schema version. Upgrade the table. |
| 491 | LOG(INFO) << "Workload management table '" << full_table_name << "' is at version '" |
| 492 | << parsed_actual_schema_version.ToString() << "' and will be upgraded"; |
| 493 | RETURN_IF_ERROR(_upgradeTable( |
| 494 | svc, ip_addr, table_name, parsed_actual_schema_version, target_schema_version)); |
| 495 | } |
| 496 | |
| 497 | return Status::OK(); |
| 498 | } // function _logTableSchemaManagement |
| 499 | |
| 500 | inline bool CatalogServer::IsCatalogInitialized() { |
| 501 | lock_guard<mutex> l(catalog_lock_); |
no test coverage detected