fix(agtype): coerce item to agtype in IN operator to support edge/vertex membership - #2543
Open
waterWang wants to merge 1 commit into
Open
fix(agtype): coerce item to agtype in IN operator to support edge/vertex membership#2543waterWang wants to merge 1 commit into
waterWang wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2542
Problem
r0 IN relationships(p0)fails withunknown type of agtype container 1610612736:The same applies to vertex membership:
a IN nodes(p0).Root cause
agtype_in_operatorreads the item argument (an edge or vertex variable) withAG_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), andagtype_iterator_initraisesunknown 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 ofagtype_in_operator. It performs proper type categorization +datum_to_agtypecoercion 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 withunknown type of agtype containera IN nodes(p0)— vertex membership, same class of bugAll existing tests pass (42/43; the
age_loadfailure is a pre-existing environment/path issue unrelated to this change).