Skip to content

EvaluationContext inconsistent constant binding dereferencing behavior #3390

Open
@hatyo

Description

@hatyo

The EvaluationContext exhibits inconsistent behavior when attempting to dereference non-existent constant bindings.

public Object dereferenceConstant(@Nonnull final CorrelationIdentifier alias, @Nonnull final String constantId) {
final var constantsMap = (Map<String, ?>)bindings.get(Bindings.Internal.CONSTANT.bindingName(alias.getId()));
if (constantsMap == null) {
throw new RecordCoreException("could not find constant in the evaluation context")
.addLogInfo(LogMessageKeys.KEY, "'" + alias.getId() + "' - '" + constantId + "'");
}
return constantsMap.get(constantId);

If the user attempts to dereference a non-existent constant reference (which is invalid), the following scenarios may occur:

  • If the EvaluationContext is empty or contains no constant bindings, the constantMap will be null, and an exception will be thrown.
  • If the EvaluationContext contains some constant bindings (excluding the one being dereferenced), the constantMap will not be empty. Attempting to retrieve the non-existent item from it at line 154 will return null instead of throwing an exception.

This subtle approach allows certain bugs to be concealed. For instance, there is a bug that prevents the execution of a cached plan containing the like operator (see #3389). However, this bug only manifests when like is the only literal in the query. If the query contains any other literal, no exception will be thrown. Instead, the plan cannot be reused because the plan constraint requiring the type of the like pattern to be String will always fail since it receives null from the evaluation context. Consequently, the query will need to be replanned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingplannerRelated to the query planner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions