mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-02-02 10:00:38 +01:00
Fixed CORE-4068 - create package fails on creating header as soon as there is at least 1 procedure name.
This commit is contained in:
parent
28f05f168b
commit
850e529c81
@ -52,8 +52,7 @@ LINK_PLUGIN_SYMBOLS = $(call LIB_LINK_MAPFILE,../$(PLUGIN_VERS))
|
||||
|
||||
.PHONY: all udrcpp_example dc_example kh_example
|
||||
|
||||
#all: udrcpp_example dc_example kh_example
|
||||
all: dc_example kh_example
|
||||
all: udrcpp_example dc_example kh_example
|
||||
|
||||
|
||||
UDR_Objects = $(call makeObjects,../examples/udr,UdrCppExample.cpp)
|
||||
|
@ -439,7 +439,7 @@ ExtEngineManager::Trigger::Trigger(thread_db* tdbb, MemoryPool& pool, ExtEngineM
|
||||
|
||||
if (relation)
|
||||
{
|
||||
format = Routine::createFormat(pool, metadata->triggerFields);
|
||||
format = Routine::createFormat(pool, metadata->triggerFields, false);
|
||||
|
||||
for (unsigned i = 0; i < format->fmt_count / 2; ++i)
|
||||
fieldsPos.add(i);
|
||||
@ -671,8 +671,8 @@ void ExtEngineManager::makeFunction(thread_db* tdbb, Jrd::Function* udf,
|
||||
|
||||
try
|
||||
{
|
||||
udf->setInputFormat(Routine::createFormat(pool, metadata->inputParameters));
|
||||
udf->setOutputFormat(Routine::createFormat(pool, metadata->outputParameters));
|
||||
udf->setInputFormat(Routine::createFormat(pool, metadata->inputParameters, false));
|
||||
udf->setOutputFormat(Routine::createFormat(pool, metadata->outputParameters, false));
|
||||
|
||||
udf->fun_external = FB_NEW(getPool()) Function(tdbb, this, attInfo->engine,
|
||||
metadata.release(), externalFunction, udf);
|
||||
@ -744,8 +744,8 @@ void ExtEngineManager::makeProcedure(thread_db* tdbb, jrd_prc* prc,
|
||||
|
||||
try
|
||||
{
|
||||
prc->setInputFormat(Routine::createFormat(pool, metadata->inputParameters));
|
||||
prc->setOutputFormat(Routine::createFormat(pool, metadata->outputParameters));
|
||||
prc->setInputFormat(Routine::createFormat(pool, metadata->inputParameters, false));
|
||||
prc->setOutputFormat(Routine::createFormat(pool, metadata->outputParameters, false));
|
||||
|
||||
prc->setExternal(FB_NEW(getPool()) Procedure(tdbb, this, attInfo->engine,
|
||||
metadata.release(), externalProcedure, prc));
|
||||
|
@ -374,58 +374,55 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT
|
||||
function->fun_external = NULL;
|
||||
function->setStatement(NULL);
|
||||
|
||||
if (!X.RDB$ENGINE_NAME.NULL || !X.RDB$FUNCTION_BLR.NULL)
|
||||
if (!X.RDB$ENGINE_NAME.NULL)
|
||||
{
|
||||
if (!X.RDB$ENGINE_NAME.NULL)
|
||||
HalfStaticArray<UCHAR, 512> body;
|
||||
|
||||
if (!X.RDB$FUNCTION_SOURCE.NULL)
|
||||
{
|
||||
HalfStaticArray<UCHAR, 512> body;
|
||||
|
||||
if (!X.RDB$FUNCTION_SOURCE.NULL)
|
||||
{
|
||||
blb* const blob = blb::open(tdbb, sysTransaction, &X.RDB$FUNCTION_SOURCE);
|
||||
const ULONG len = blob->BLB_get_data(tdbb,
|
||||
body.getBuffer(blob->blb_length + 1), blob->blb_length + 1);
|
||||
body[MIN(blob->blb_length, len)] = 0;
|
||||
}
|
||||
else
|
||||
body.getBuffer(1)[0] = 0;
|
||||
|
||||
dbb->dbb_extManager.makeFunction(tdbb, function, X.RDB$ENGINE_NAME,
|
||||
(X.RDB$ENTRYPOINT.NULL ? "" : X.RDB$ENTRYPOINT), (char*) body.begin());
|
||||
|
||||
if (!function->fun_external)
|
||||
function->setDefined(false);
|
||||
blb* const blob = blb::open(tdbb, sysTransaction, &X.RDB$FUNCTION_SOURCE);
|
||||
const ULONG len = blob->BLB_get_data(tdbb,
|
||||
body.getBuffer(blob->blb_length + 1), blob->blb_length + 1);
|
||||
body[MIN(blob->blb_length, len)] = 0;
|
||||
}
|
||||
else
|
||||
body.getBuffer(1)[0] = 0;
|
||||
|
||||
dbb->dbb_extManager.makeFunction(tdbb, function, X.RDB$ENGINE_NAME,
|
||||
(X.RDB$ENTRYPOINT.NULL ? "" : X.RDB$ENTRYPOINT), (char*) body.begin());
|
||||
|
||||
if (!function->fun_external)
|
||||
function->setDefined(false);
|
||||
}
|
||||
else if (!X.RDB$FUNCTION_BLR.NULL)
|
||||
{
|
||||
MemoryPool* const csb_pool = attachment->createPool();
|
||||
Jrd::ContextPoolHolder context(tdbb, csb_pool);
|
||||
|
||||
try
|
||||
{
|
||||
MemoryPool* const csb_pool = attachment->createPool();
|
||||
Jrd::ContextPoolHolder context(tdbb, csb_pool);
|
||||
AutoPtr<CompilerScratch> csb(CompilerScratch::newCsb(*csb_pool, 5));
|
||||
|
||||
if (!X.RDB$DEBUG_INFO.NULL)
|
||||
DBG_parse_debug_info(tdbb, &X.RDB$DEBUG_INFO, *csb->csb_dbg_info);
|
||||
|
||||
try
|
||||
{
|
||||
AutoPtr<CompilerScratch> csb(CompilerScratch::newCsb(*csb_pool, 5));
|
||||
|
||||
if (!X.RDB$DEBUG_INFO.NULL)
|
||||
DBG_parse_debug_info(tdbb, &X.RDB$DEBUG_INFO, *csb->csb_dbg_info);
|
||||
|
||||
try
|
||||
{
|
||||
MET_parse_routine_blr(tdbb, function, &X.RDB$FUNCTION_BLR, csb);
|
||||
}
|
||||
catch (const Exception&)
|
||||
{
|
||||
const string name = function->getName().toString();
|
||||
status_exception::raise(Arg::Gds(isc_bad_fun_BLR) << Arg::Str(name));
|
||||
}
|
||||
MET_parse_routine_blr(tdbb, function, &X.RDB$FUNCTION_BLR, csb);
|
||||
}
|
||||
catch (const Exception&)
|
||||
{
|
||||
attachment->deletePool(csb_pool);
|
||||
throw;
|
||||
const string name = function->getName().toString();
|
||||
status_exception::raise(Arg::Gds(isc_bad_fun_BLR) << Arg::Str(name));
|
||||
}
|
||||
|
||||
function->getStatement()->function = function;
|
||||
}
|
||||
catch (const Exception&)
|
||||
{
|
||||
attachment->deletePool(csb_pool);
|
||||
throw;
|
||||
}
|
||||
|
||||
function->getStatement()->function = function;
|
||||
}
|
||||
else if (!X.RDB$MODULE_NAME.NULL && !X.RDB$ENTRYPOINT.NULL)
|
||||
{
|
||||
@ -444,7 +441,17 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT
|
||||
function->setDefined(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
RefPtr<MsgMetadata> inputMetadata(createMetadata(function->getInputFields()));
|
||||
inputMetadata->release();
|
||||
function->setInputFormat(createFormat(function->getPool(), inputMetadata, false));
|
||||
|
||||
RefPtr<MsgMetadata> outputMetadata(createMetadata(function->getOutputFields()));
|
||||
outputMetadata->release();
|
||||
function->setOutputFormat(createFormat(function->getPool(), outputMetadata, true));
|
||||
|
||||
function->setImplemented(false);
|
||||
}
|
||||
|
||||
if (X.RDB$VALID_BLR.NULL || X.RDB$VALID_BLR == FALSE)
|
||||
valid_blr = false;
|
||||
|
@ -48,14 +48,14 @@ MsgMetadata* Routine::createMetadata(const Array<NestConst<Parameter> >& paramet
|
||||
}
|
||||
|
||||
// Create a Format based on an IMessageMetadata.
|
||||
Format* Routine::createFormat(MemoryPool& pool, IMessageMetadata* params)
|
||||
Format* Routine::createFormat(MemoryPool& pool, IMessageMetadata* params, bool addEof)
|
||||
{
|
||||
LocalStatus status;
|
||||
|
||||
unsigned count = params->getCount(&status);
|
||||
status.check();
|
||||
|
||||
Format* format = Format::newFormat(pool, count * 2);
|
||||
Format* format = Format::newFormat(pool, count * 2 + (addEof ? 1 : 0));
|
||||
unsigned runOffset = 0;
|
||||
|
||||
dsc* desc = format->fmt_desc.begin();
|
||||
@ -85,6 +85,13 @@ Format* Routine::createFormat(MemoryPool& pool, IMessageMetadata* params)
|
||||
++desc;
|
||||
}
|
||||
|
||||
if (addEof)
|
||||
{
|
||||
// Next item is aligned on USHORT, so as the previous one.
|
||||
desc->makeShort(0, (SSHORT*)(IPTR) runOffset);
|
||||
runOffset += sizeof(USHORT);
|
||||
}
|
||||
|
||||
format->fmt_length = runOffset;
|
||||
|
||||
return format;
|
||||
|
@ -62,7 +62,7 @@ namespace Jrd
|
||||
public:
|
||||
static Firebird::MsgMetadata* createMetadata(
|
||||
const Firebird::Array<NestConst<Parameter> >& parameters);
|
||||
static Format* createFormat(MemoryPool& pool, Firebird::IMessageMetadata* params);
|
||||
static Format* createFormat(MemoryPool& pool, Firebird::IMessageMetadata* params, bool addEof);
|
||||
|
||||
public:
|
||||
USHORT getId() const
|
||||
|
@ -3062,45 +3062,64 @@ jrd_prc* MET_procedure(thread_db* tdbb, int id, bool noscan, USHORT flags)
|
||||
|
||||
if (!external)
|
||||
{
|
||||
MemoryPool* csb_pool = attachment->createPool();
|
||||
|
||||
Jrd::ContextPoolHolder context(tdbb, csb_pool);
|
||||
CompilerScratch* csb = CompilerScratch::newCsb(*tdbb->getDefaultPool(), 5);
|
||||
|
||||
if (!P.RDB$DEBUG_INFO.NULL)
|
||||
DBG_parse_debug_info(tdbb, &P.RDB$DEBUG_INFO, *csb->csb_dbg_info);
|
||||
|
||||
try
|
||||
if (!P.RDB$PROCEDURE_BLR.NULL)
|
||||
{
|
||||
MET_parse_routine_blr(tdbb, procedure,
|
||||
(P.RDB$PROCEDURE_BLR.NULL ? NULL : &P.RDB$PROCEDURE_BLR), csb);
|
||||
}
|
||||
catch (const Exception&)
|
||||
{
|
||||
delete csb;
|
||||
MemoryPool* csb_pool = attachment->createPool();
|
||||
|
||||
if (procedure->getStatement())
|
||||
procedure->releaseStatement(tdbb);
|
||||
else
|
||||
attachment->deletePool(csb_pool);
|
||||
Jrd::ContextPoolHolder context(tdbb, csb_pool);
|
||||
CompilerScratch* csb = CompilerScratch::newCsb(*tdbb->getDefaultPool(), 5);
|
||||
|
||||
ERR_post(Arg::Gds(isc_bad_proc_BLR) << Arg::Str(procedure->getName().toString()));
|
||||
}
|
||||
if (!P.RDB$DEBUG_INFO.NULL)
|
||||
DBG_parse_debug_info(tdbb, &P.RDB$DEBUG_INFO, *csb->csb_dbg_info);
|
||||
|
||||
procedure->getStatement()->procedure = procedure;
|
||||
for (size_t i = 0; i < csb->csb_rpt.getCount(); i++)
|
||||
{
|
||||
MessageNode* node = csb->csb_rpt[i].csb_message;
|
||||
|
||||
/***
|
||||
if (node)
|
||||
try
|
||||
{
|
||||
if (node->messageNumber == 1)
|
||||
procedure->prc_output_msg = node;
|
||||
MET_parse_routine_blr(tdbb, procedure,
|
||||
(P.RDB$PROCEDURE_BLR.NULL ? NULL : &P.RDB$PROCEDURE_BLR), csb);
|
||||
}
|
||||
***/
|
||||
catch (const Exception&)
|
||||
{
|
||||
delete csb;
|
||||
|
||||
if (procedure->getStatement())
|
||||
procedure->releaseStatement(tdbb);
|
||||
else
|
||||
attachment->deletePool(csb_pool);
|
||||
|
||||
ERR_post(Arg::Gds(isc_bad_proc_BLR) << Arg::Str(procedure->getName().toString()));
|
||||
}
|
||||
|
||||
procedure->getStatement()->procedure = procedure;
|
||||
for (size_t i = 0; i < csb->csb_rpt.getCount(); i++)
|
||||
{
|
||||
MessageNode* node = csb->csb_rpt[i].csb_message;
|
||||
|
||||
/***
|
||||
if (node)
|
||||
{
|
||||
if (node->messageNumber == 1)
|
||||
procedure->prc_output_msg = node;
|
||||
}
|
||||
***/
|
||||
}
|
||||
delete csb;
|
||||
}
|
||||
else
|
||||
{
|
||||
RefPtr<MsgMetadata> inputMetadata(
|
||||
Routine::createMetadata(procedure->getInputFields()));
|
||||
inputMetadata->release();
|
||||
procedure->setInputFormat(
|
||||
Routine::createFormat(procedure->getPool(), inputMetadata, false));
|
||||
|
||||
RefPtr<MsgMetadata> outputMetadata(
|
||||
Routine::createMetadata(procedure->getOutputFields()));
|
||||
outputMetadata->release();
|
||||
procedure->setOutputFormat(
|
||||
Routine::createFormat(procedure->getPool(), outputMetadata, true));
|
||||
|
||||
procedure->setImplemented(false);
|
||||
}
|
||||
delete csb;
|
||||
}
|
||||
|
||||
if (P.RDB$VALID_BLR.NULL || P.RDB$VALID_BLR == FALSE)
|
||||
|
Loading…
Reference in New Issue
Block a user