Memory management for DSQL nodes

12 views
Skip to first unread message

Dimitry Sibiryakov

unread,
Dec 25, 2025, 11:56:09 AM (3 days ago) Dec 25
to firebir...@googlegroups.com
Hello All,

Some nodes return `this` from dsqlPass() and some nodes return a new instance
of the same node class. What the reason for this and what happen to the old
instance?
I see one probable reason for the returning of a new instance: to move the
node from the compiler pool to the scratch pool because compiler pool will be
destructed at some point with all existing nodes inside. But if this is true
then returning `this` should cause problem, no?

--
WBR, SD.

Dimitry Sibiryakov

unread,
Dec 26, 2025, 12:05:14 PM (2 days ago) Dec 26
to firebir...@googlegroups.com
Dimitry Sibiryakov wrote 25.12.2025 17:56:
>   Some nodes return `this` from dsqlPass() and some nodes return a new instance
> of the same node class.

A concrete example:

```
BoolExprNode* BinaryBoolNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
{
return FB_NEW_POOL(dsqlScratch->getPool())
BinaryBoolNode(dsqlScratch->getPool(), blrOp,
arg1->dsqlPass(dsqlScratch), arg2->dsqlPass(dsqlScratch));
}
```

will be something wrong if this code is rewritten like this?

```
BoolExprNode* BinaryBoolNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
{
arg1 = arg1->dsqlPass(dsqlScratch);
arg2 = arg2->dsqlPass(dsqlScratch);
return this;
}
```

I tried it and nothing bad happened because in every test I used the
scratch's pool was the same as node's pool.

--
WBR, SD.
Reply all
Reply to author
Forward
0 new messages