Skip to content

Conversation

@jrgemignani
Copy link
Contributor

NOTE: This PR was created with AI tools and a human.

When evaluating 'x IN []' with an empty list, the transform_AEXPR_IN function would return NULL because no expressions were processed. This caused a 'cache lookup failed for type 0' error downstream.

This fix adds an early check for the empty list case:

  • 'x IN []' returns false (nothing can be in an empty list)

Additional NOTE: Cypher does not have 'NOT IN' syntax. To check if a value is NOT in a list, use 'NOT (x IN list)'. The NOT operator will invert the false from an empty list to true as expected.

The fix returns a boolean constant directly, avoiding the NULL result that caused the type lookup failure.

Added regression tests.

modified: regress/expected/expr.out
modified: regress/sql/expr.sql
modified: src/backend/parser/cypher_expr.c

NOTE: This PR was created with AI tools and a human.

When evaluating 'x IN []' with an empty list, the transform_AEXPR_IN
function would return NULL because no expressions were processed.
This caused a 'cache lookup failed for type 0' error downstream.

This fix adds an early check for the empty list case:
- 'x IN []' returns false (nothing can be in an empty list)

Additional NOTE: Cypher does not have 'NOT IN' syntax. To check if
a value is NOT in a list, use 'NOT (x IN list)'. The NOT operator
will invert the false from an empty list to true as expected.

The fix returns a boolean constant directly, avoiding the NULL result
that caused the type lookup failure.

Added regression tests.

modified:   regress/expected/expr.out
modified:   regress/sql/expr.sql
modified:   src/backend/parser/cypher_expr.c
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a "cache lookup failed for type 0" error that occurred when evaluating expressions like x IN [] with an empty list. The root cause was that the transform_AEXPR_IN function would return NULL when processing an empty list, leading to a type lookup failure downstream.

Key Changes:

  • Added an early check for empty lists in transform_AEXPR_IN that returns a boolean constant (false for IN, true for the internal <> operator)
  • Added comprehensive regression tests covering different data types with empty list IN expressions
  • Added test for NOT (x IN []) to verify proper negation behavior

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/backend/parser/cypher_expr.c Added early return for empty list case before processing elements, preventing NULL result that caused the type lookup error
regress/sql/expr.sql Added test cases for x IN [] with various data types (integer, string, null, list) and NOT expressions
regress/expected/expr.out Expected output showing all x IN [] cases return false and NOT (x IN []) cases return true

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

master override-stale To keep issues/PRs untouched from stale action

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant