Skip to content

Cached plan containing like throws upon execution #3389

Open
@hatyo

Description

@hatyo

The following SQL statement fails with an exception com.apple.foundationdb.record.RecordCoreException: Missing binding for __const_CONSTANT:

select * from t1 where a like ‘a’
— now, the above statement is cached
— so the execution of the same statement
— should be pulled from the plan cache …
select * from t1 where a like ‘a’
— THROWS: Missing binding for __const_CONSTANT

There is a bug in the way the LIKE clause is handled during query normalization. When normalizing the query, the LIKE clause is not visited, so the literal like pattern is not extracted and left in the normalized form. This is acceptable, as long as the same behavior is applied during plan generation. However, this is the root cause of the problem: the plan generator extracts the pattern into a ConstantObjectValue. This mismatch causes the above error when we attempt to execute the cached physical plan. Since the plan expects a COV, but the AST normalizer did not extract it away from the query, the execution of the cached query fails with the missing reference: Missing binding for __const_CONSTANT.

We should either avoid pulling the pattern in both the AST normalizer and the plan generator, or avoid extracting it in both, i.e., the behavior should be aligned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingrelationalissues related to relational FDB

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions