| 338 | |
| 339 | |
| 340 | void SHUT_online(thread_db* tdbb, SSHORT flag, Sync* guard) |
| 341 | { |
| 342 | /************************************** |
| 343 | * |
| 344 | * S H U T _ o n l i n e |
| 345 | * |
| 346 | ************************************** |
| 347 | * |
| 348 | * Functional description |
| 349 | * Move database to "more online" state |
| 350 | * |
| 351 | **************************************/ |
| 352 | SET_TDBB(tdbb); |
| 353 | Database* const dbb = tdbb->getDatabase(); |
| 354 | Jrd::Attachment* const attachment = tdbb->getAttachment(); |
| 355 | |
| 356 | // Only platform's user locksmith can shutdown or bring online a database |
| 357 | |
| 358 | if (!attachment->locksmith(tdbb, CHANGE_SHUTDOWN_MODE)) |
| 359 | { |
| 360 | ERR_post_nothrow(Arg::Gds(isc_no_priv) << "bring online" << "database" << dbb->dbb_filename); |
| 361 | if (attachment->att_user && attachment->att_user->testFlag(USR_mapdown)) |
| 362 | ERR_post_nothrow(Arg::Gds(isc_map_down)); |
| 363 | ERR_punt(); |
| 364 | } |
| 365 | |
| 366 | const int shut_mode = flag & isc_dpb_shut_mode_mask; |
| 367 | |
| 368 | // Check if requested shutdown mode is valid |
| 369 | switch (shut_mode) |
| 370 | { |
| 371 | case isc_dpb_shut_normal: |
| 372 | if (!(dbb->dbb_ast_flags & DBB_shutdown)) |
| 373 | { |
| 374 | same_mode(dbb); // normal -> normal |
| 375 | return; |
| 376 | } |
| 377 | break; |
| 378 | case isc_dpb_shut_multi: |
| 379 | if (!(dbb->dbb_ast_flags & DBB_shutdown)) |
| 380 | { |
| 381 | bad_mode(dbb); // normal -> multi |
| 382 | } |
| 383 | if (!(dbb->dbb_ast_flags & DBB_shutdown_full) && !(dbb->dbb_ast_flags & DBB_shutdown_single)) |
| 384 | { |
| 385 | same_mode(dbb); // multi -> multi |
| 386 | return; |
| 387 | } |
| 388 | break; |
| 389 | case isc_dpb_shut_single: |
| 390 | if (dbb->dbb_ast_flags & DBB_shutdown_single) |
| 391 | { |
| 392 | same_mode(dbb); //single -> single |
| 393 | return; |
| 394 | } |
| 395 | if (!(dbb->dbb_ast_flags & DBB_shutdown_full)) |
| 396 | { |
| 397 | bad_mode(dbb); // !full -> single |
no test coverage detected