Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue 1329 - agtype_to_int4 crash (#1339) #1346

Merged
merged 1 commit into from
Nov 3, 2023

Conversation

jrgemignani
Copy link
Contributor

Fixed issue 1329 where agtype_to_int<8,4,2> and agtype_to_int4_array crashed due to not properly checking input.

As these functions take "any" input, the input has to be properly checked before casting it to a specific type. The input section assumed it was agtype, which caused crashes for non-agtypes.

The functions agtype_to_int<8,4,2> will convert non-agtypes into agtype. However, there were no regression tests for this.

The functions agtype_to_int<8,4,2> will convert non-agtypes to agtype ints but, did not for their string equivs. Meaning, passing a ('true') or ('3.14') would fail but, passing a (true) or (3.14) would not. This has been corrected for all 3 functions.

TODO -
The function agtype_to_int4_array only takes agtype, currently, and we should consider allowing it to take "any" types.

Added regression tests.
Added missing regression tests.

Conflicts:
regress/expected/agtype.out
regress/expected/expr.out
src/backend/utils/adt/agtype.c

@github-actions github-actions bot added the PG11 PostgreSQL11 label Nov 2, 2023
Fixed issue 1329 where `agtype_to_int`<8,4,2> and `agtype_to_int4_array`
crashed due to not properly checking input.

As these functions take "any" input, the input has to be properly
checked before casting it to a specific type. The input section
assumed it was agtype, which caused crashes for non-agtypes.

The functions `agtype_to_int`<8,4,2> will convert non-agtypes into
agtype. However, there were no regression tests for this.

The functions `agtype_to_int`<8,4,2> will convert non-agtypes to
agtype ints but, did not for their string equivs. Meaning, passing
a ('true') or ('3.14') would fail but, passing a (true) or (3.14)
would not. This has been corrected for all 3 functions.

TODO -
The function `agtype_to_int4_array` only takes agtype, currently,
and we should consider allowing it to take "any" types.

Added regression tests.
Added missing regression tests.

Conflicts:
	regress/expected/agtype.out
	regress/expected/expr.out
	src/backend/utils/adt/agtype.c
@rafsun42
Copy link
Member

rafsun42 commented Nov 3, 2023

What does Conflicts mean in the commit message? Are these merge conflict?

@jrgemignani
Copy link
Contributor Author

What does Conflicts mean in the commit message? Are these merge conflict?

@rafsun42 There were merge conflicts. I wanted to leave it in so that it was known.

@rafsun42 rafsun42 merged commit 6f30d0d into apache:PG11 Nov 3, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PG11 PostgreSQL11
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants