Repository navigation
Fix ? operator crash on an agtype null left operand - #2589
Open
akashchamp wants to merge 1 commit into
Open
akashchamp wants to merge 1 commit into
akashchamp wants to merge 1 commit into
Conversation
For a scalar left operand, agtype_exists_agtype() passes the result of
extract_entity_properties() straight to agtype_value_to_agtype(). For an
agtype null (or an entity whose properties are null) that result is NULL,
so the backend dereferences a NULL pointer and the postmaster restarts:
SELECT 'null'::agtype ? '"a"'::agtype;
Return false when there are no properties to search, the same answer the
operator already gives for other non-container scalars such as '1' or
'"s"'. Add regression cases to jsonb_operators.
Fixes apache#2562
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 #2562.
SELECT 'null'::agtype ? '"a"'::agtype;crashes the backend with SIGSEGV. Inagtype_exists_agtype(),extract_entity_properties(agt, false)returns NULL for an agtype null scalar (and for an entity with null properties), and that NULL goes straight intoagtype_value_to_agtype().The fix checks for NULL and returns false, which is what
?already returns for other non-container scalars like'1'or'"s"'. I left?|/?&alone since they already raise a clean error for this input. I also added two cases toregress/sql/jsonb_operators.sql.Testing, against PostgreSQL 18.6 built from source:
make installcheckcrashes injsonb_operators(17 of 44 failed).f.'1' ? '"a"'still returnsf, and the vertex and object cases still returnt.make installcheck: all 44 tests passed.