| 1462 | |
| 1463 | |
| 1464 | void ExtEngineManager::makeProcedure(thread_db* tdbb, CompilerScratch* csb, jrd_prc* prc, |
| 1465 | const MetaName& engine, const string& entryPoint, const string& body) |
| 1466 | { |
| 1467 | string entryPointTrimmed = entryPoint; |
| 1468 | entryPointTrimmed.trim(); |
| 1469 | |
| 1470 | EngineAttachmentInfo* attInfo = getEngineAttachment(tdbb, engine); |
| 1471 | const MetaString& userName = prc->invoker ? prc->invoker->getUserName() : ""; |
| 1472 | ContextManager<IExternalProcedure> ctxManager(tdbb, attInfo, attInfo->adminCharSet, |
| 1473 | (prc->getName().package.isEmpty() ? |
| 1474 | CallerName(obj_procedure, prc->getName().identifier, userName) : |
| 1475 | CallerName(obj_package_header, prc->getName().package, userName))); |
| 1476 | |
| 1477 | MemoryPool& pool = *tdbb->getAttachment()->att_pool; |
| 1478 | |
| 1479 | AutoPtr<RoutineMetadata> metadata(FB_NEW_POOL(pool) RoutineMetadata(pool)); |
| 1480 | metadata->package = prc->getName().package; |
| 1481 | metadata->name = prc->getName().identifier; |
| 1482 | metadata->entryPoint = entryPointTrimmed; |
| 1483 | metadata->body = body; |
| 1484 | metadata->inputParameters.assignRefNoIncr(Routine::createMetadata(prc->getInputFields(), true)); |
| 1485 | metadata->outputParameters.assignRefNoIncr(Routine::createMetadata(prc->getOutputFields(), true)); |
| 1486 | |
| 1487 | prc->setInputFormat(Routine::createFormat(pool, metadata->inputParameters, false)); |
| 1488 | prc->setOutputFormat(Routine::createFormat(pool, metadata->outputParameters, true)); |
| 1489 | |
| 1490 | FbLocalStatus status; |
| 1491 | |
| 1492 | RefPtr<IMetadataBuilder> inBuilder(REF_NO_INCR, metadata->inputParameters->getBuilder(&status)); |
| 1493 | status.check(); |
| 1494 | |
| 1495 | RefPtr<IMetadataBuilder> outBuilder(REF_NO_INCR, metadata->outputParameters->getBuilder(&status)); |
| 1496 | status.check(); |
| 1497 | |
| 1498 | IExternalProcedure* externalProcedure; |
| 1499 | RefPtr<IMessageMetadata> extInputParameters, extOutputParameters; |
| 1500 | |
| 1501 | { // scope |
| 1502 | EngineCheckout cout(tdbb, FB_FUNCTION, checkoutType(attInfo->engine)); |
| 1503 | |
| 1504 | externalProcedure = attInfo->engine->makeProcedure(&status, attInfo->context, metadata, |
| 1505 | inBuilder, outBuilder); |
| 1506 | |
| 1507 | try |
| 1508 | { |
| 1509 | status.check(); |
| 1510 | |
| 1511 | if (!externalProcedure) |
| 1512 | { |
| 1513 | status_exception::raise( |
| 1514 | Arg::Gds(isc_eem_proc_not_returned) << |
| 1515 | prc->getName().toString() << engine); |
| 1516 | } |
| 1517 | } |
| 1518 | catch (const Exception&) |
| 1519 | { |
| 1520 | if (tdbb->getAttachment()->isGbak()) |
| 1521 | return; |
nothing calls this directly
no test coverage detected