| 569 | } |
| 570 | |
| 571 | YAttachment* UtilInterface::executeCreateDatabase( |
| 572 | Firebird::CheckStatusWrapper* status, unsigned stmtLength, const char* creatDBstatement, |
| 573 | unsigned dialect, FB_BOOLEAN* stmtIsCreateDb) |
| 574 | { |
| 575 | try |
| 576 | { |
| 577 | bool stmtEaten; |
| 578 | YAttachment* att = NULL; |
| 579 | |
| 580 | if (stmtIsCreateDb) |
| 581 | *stmtIsCreateDb = FB_FALSE; |
| 582 | |
| 583 | string statement(creatDBstatement, |
| 584 | (stmtLength == 0 && creatDBstatement ? strlen(creatDBstatement) : stmtLength)); |
| 585 | |
| 586 | if (!PREPARSE_execute(status, &att, statement, &stmtEaten, dialect)) |
| 587 | return NULL; |
| 588 | |
| 589 | if (stmtIsCreateDb) |
| 590 | *stmtIsCreateDb = FB_TRUE; |
| 591 | |
| 592 | if (status->getState() & Firebird::IStatus::STATE_ERRORS) |
| 593 | return NULL; |
| 594 | |
| 595 | LocalStatus tempStatus; |
| 596 | CheckStatusWrapper tempCheckStatusWrapper(&tempStatus); |
| 597 | |
| 598 | ITransaction* crdbTrans = att->startTransaction(status, 0, NULL); |
| 599 | |
| 600 | if (status->getState() & Firebird::IStatus::STATE_ERRORS) |
| 601 | { |
| 602 | att->dropDatabase(&tempCheckStatusWrapper); |
| 603 | return NULL; |
| 604 | } |
| 605 | |
| 606 | bool v3Error = false; |
| 607 | |
| 608 | if (!stmtEaten) |
| 609 | { |
| 610 | att->execute(status, crdbTrans, statement.length(), statement.c_str(), dialect, NULL, NULL, NULL, NULL); |
| 611 | if (status->getState() & Firebird::IStatus::STATE_ERRORS) |
| 612 | { |
| 613 | crdbTrans->rollback(&tempCheckStatusWrapper); |
| 614 | att->dropDatabase(&tempCheckStatusWrapper); |
| 615 | return NULL; |
| 616 | } |
| 617 | } |
| 618 | |
| 619 | crdbTrans->commit(status); |
| 620 | if (status->getState() & Firebird::IStatus::STATE_ERRORS) |
| 621 | { |
| 622 | crdbTrans->rollback(&tempCheckStatusWrapper); |
| 623 | att->dropDatabase(&tempCheckStatusWrapper); |
| 624 | return NULL; |
| 625 | } |
| 626 | |
| 627 | return att; |
| 628 | } |
no test coverage detected