MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / executeCreateDatabase

Method executeCreateDatabase

src/yvalve/utl.cpp:571–634  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

569}
570
571YAttachment* 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 }

Calls 10

PREPARSE_executeFunction · 0.85
getStateMethod · 0.45
startTransactionMethod · 0.45
dropDatabaseMethod · 0.45
executeMethod · 0.45
lengthMethod · 0.45
c_strMethod · 0.45
rollbackMethod · 0.45
commitMethod · 0.45
stuffExceptionMethod · 0.45

Tested by

no test coverage detected