[#603] Assert failure when NOT is used on functions like LEAST, GREATEST, NULLIF etc.
-
The main issue was the placement of
LP_*
type codes inlp_action_types.hd
. Opcodes likeLP_GREATEST
etc. were placed afterLP_ADDITION
and this meant that the(LP_ADDITION > type)
check done in inlp_apply_not()
(inlp_make_normal_disjunctive_form.c
) to filter out a whole class of logical plan types was not doing the correct filtering for a few plan codes that could be seen as operand 0 of aLP_LOGICAL_NOT
plan. And this finally resulted in an assert failure.Those plan types are now moved to BEFORE the
LP_ADDITION
type. And that fixes the assert failure. -
Took this opportunity to also move the aggregate function logical plan types even though they cannot be operand 0 of a
LP_LOGICAL_NOT
plan (because none of them can currently take in boolean typed operands). This is because aggregate functions are in the same class of plan types asLP_FUNCTION_CALL
which can appear as operand 0 of aLP_LOGICAL_NOT
plan. -
Because of this change, an
assert(LP_ADDITION <= plan->type)
inlp_replace_derived_table_references.c
is now fixed to instead beassert(LP_FUNCTION_CALL <= plan->type)
. -
With this change,
lp_apply_not()
does the right thing forLP_GREATEST
etc. as these opcodes now satisfy theLP_ADDITION > type
check. So no more code fix was needed. -
A new
test_not_operator/TNO01
bats subtest verifies this fix by testing for variousLP_
plan types. -
This assert failure seems to show up only in Debug builds of Octo. In Release builds, there is no assert seen and the output is correct for the queries in
tests/fixtures/TNO01.sql
so likely no user-visible impact because of this issue or the fix.