Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of external (UDR) functions #7989

Merged
merged 2 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions examples/udr/Functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ FB_UDR_BEGIN_FUNCTION(sum_args)
// Get a reference to the return value.
ISC_LONG& ret = *(ISC_LONG*) (out + outOffset);

// The return value is automatically initialized to 0.
///ret = 0;
ret = 0;

for (unsigned i = 0; i < inCount; ++i)
{
Expand Down
18 changes: 13 additions & 5 deletions src/dsql/ExprNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13051,7 +13051,7 @@ DmlNode* UdfCallNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch*
if (argCount > node->function->fun_inputs)
mismatchStatus << Arg::Gds(isc_wronumarg);

for (auto pos = 0; pos < positionalArgCount; ++pos)
for (auto pos = 0u; pos < positionalArgCount; ++pos)
{
if (pos < node->function->fun_inputs)
{
Expand Down Expand Up @@ -13505,12 +13505,20 @@ dsc* UdfCallNode::execute(thread_db* tdbb, Request* request) const

funcRequest->setGmtTimeStamp(request->getGmtTimeStamp());

EXE_start(tdbb, funcRequest, transaction);
if (function->fun_external)
{
function->fun_external->execute(
tdbb, funcRequest, transaction, inMsgLength, inMsg, outMsgLength, outMsg);
}
else
{
EXE_start(tdbb, funcRequest, transaction);

if (inMsgLength != 0)
EXE_send(tdbb, funcRequest, 0, inMsgLength, inMsg);
if (inMsgLength != 0)
EXE_send(tdbb, funcRequest, 0, inMsgLength, inMsg);

EXE_receive(tdbb, funcRequest, 1, outMsgLength, outMsg);
EXE_receive(tdbb, funcRequest, 1, outMsgLength, outMsg);
}

// Clean up all savepoints started during execution of the function

Expand Down
2 changes: 1 addition & 1 deletion src/dsql/Nodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,7 @@ class StmtNode : public DmlNode
TYPE_TRUNCATE_LOCAL_TABLE,
TYPE_UPDATE_OR_INSERT,

TYPE_EXT_INIT_PARAMETER,
TYPE_EXT_INIT_PARAMETERS,
TYPE_EXT_TRIGGER
};

Expand Down
Loading
Loading