Fix collate and null processing in package constants#9037
Conversation
| jrd_tra* transaction = dsqlScratch->getTransaction(); | ||
| thread_db* tdbb = JRD_get_thread_data(); | ||
| *desc = ConstantValue::getDesc(tdbb, transaction, m_fullName); | ||
| desc->setNullable(true); |
There was a problem hiding this comment.
Why is constant references always marked as nullable?
There was a problem hiding this comment.
To return NULL from the ReferenceNode, the nullable flag is requered. It would be nice to explicitly check the not null state of the field, but as I can see, it does not stored in RDB$FIELD. So I decied to put the nullable flag withou extra checks.
The not null clasue can only be used when the type is a domain:
create domain my_domain int not null;
create or alter package my_package as
begin
constant my_const my_domain = null;
end;But in this case an error will appear instanly:
Statement failed, SQLSTATE = 2F000
validation error for CAST, value "*** null ***"
-Error while parsing BLR value of the constant "PUBLIC"."MY_PACKAGE"."MY_CONST"
So, putting nullable flag in any case is safe
There was a problem hiding this comment.
Every other kind of expressions, include composed ones, do return nullable flag correctly. I see no reason for constants to flag nullable incorrectly.
There was a problem hiding this comment.
It would be nice to explicitly check the
not nullstate of the field, but as I can see, it does not stored in RDB$FIELD
RDB$FIELDS.RDB$NULL_FLAG ?
There was a problem hiding this comment.
It would be nice to explicitly check the
not nullstate of the field, but as I can see, it does not stored in RDB$FIELD
RDB$FIELDS.RDB$NULL_FLAG?
I missed that somehow. Fixed
|
|
||
| const dsc* temp = EVL_expr(tdbb, request, static_cast<ValueExprNode*>(csb->csb_node)); | ||
| EVL_make_value(tdbb, temp, &m_value, &getPool()); | ||
| //! Execute it here, while AutoSetRestore2 is active |
There was a problem hiding this comment.
| //! Execute it here, while AutoSetRestore2 is active | |
| // Execute it here, while AutoSetRestore2 is active |
There was a problem hiding this comment.
I used an exclamation point to highlight the warning. Is this style inappropriate for Firebird?
|
|
||
| void ConstantValue::executeCsbNode(thread_db* tdbb, CompilerScratch* csb) | ||
| { | ||
| ValueExprNode* exprNode = static_cast<ValueExprNode*>(csb->csb_node); |
There was a problem hiding this comment.
Assert csb->csb_node && csb->csb_node->getKind() == DmlNode::KIND_VALUE.
Co-authored-by: Adriano dos Santos Fernandes <529415+asfernandes@users.noreply.github.com>
Also use constant instead of 0 for dtype check
Fix Regression decribed in https://groups.google.com/g/firebird-devel/c/5ehuR18Wemk and https://groups.google.com/g/firebird-devel/c/kze2LTWaeco