Skip to content

fix(agtype): coerce item to agtype in IN operator to support edge/vertex membership - #2543

Open
waterWang wants to merge 1 commit into
apache:masterfrom
waterWang:fix/in-operator-edge-coercion
Open

fix(agtype): coerce item to agtype in IN operator to support edge/vertex membership#2543
waterWang wants to merge 1 commit into
apache:masterfrom
waterWang:fix/in-operator-edge-coercion

Conversation

@waterWang

Copy link
Copy Markdown

Fixes #2542

Problem

r0 IN relationships(p0) fails with unknown type of agtype container 1610612736:

MATCH ()-[r0]->()
MATCH p0 = (:L)-[:R]->()
RETURN r0 IN relationships(p0) AS member

The same applies to vertex membership: a IN nodes(p0).

Root cause

agtype_in_operator reads the item argument (an edge or vertex variable) with AG_GET_ARG_AGTYPE_P(1), which assumes the argument is already a well-formed agtype varlena. A matched edge/vertex variable is not passed as a self-contained agtype datum here, so reading its root container header yields garbage (e.g. 0x60000000 — both array and object flags set), and agtype_iterator_init raises unknown type of agtype container.

Fix

Use get_one_agtype_from_variadic_args(fcinfo, 1, 1) for the item argument in both the VLE-path branch and the plain-array branch of agtype_in_operator. It performs proper type categorization + datum_to_agtype coercion when the argument is not already an agtype, so an edge/vertex item is wrapped into a valid agtype raw-scalar array before iterator initialization. NULL handling is preserved (returns NULL for both SQL NULL and agtype null).

Tests

Added regression tests in regress/sql/expr.sql:

  • r0 IN relationships(p0) — edge membership, previously crashed with unknown type of agtype container
  • a IN nodes(p0) — vertex membership, same class of bug

All existing tests pass (42/43; the age_load failure is a pre-existing environment/path issue unrelated to this change).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

r IN relationships(path) fails with unknown type of agtype container 1610612736

1 participant