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

sql: fix internal error when trying to parse strings as arrays #52416

Merged
merged 1 commit into from
Aug 10, 2020

Conversation

RaduBerinde
Copy link
Member

The parse-constant-as-type code was allowing a desired type of Array[Any], and
we can't parse elements as Any. This resulted in an internal error, rather
than a normal query error.

Fixes #52134.

Release note (bug fix): Fixed an internal error involving string literals used
as arrays.

@RaduBerinde RaduBerinde requested review from otan and rohany August 5, 2020 17:27
@cockroach-teamcity
Copy link
Member

This change is Reviewable

func typeCheckConstant(
ctx context.Context, semaCtx *SemaContext, c Constant, desired *types.T,
) (ret TypedExpr, err error) {
avail := c.AvailableTypes()
if desired.Family() != types.AnyFamily {
if isDefiniteType(desired) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we have a function typ.IsAmbiguous that does something like this already

The parse-constant-as-type code was allowing a desired type of `Array[Any]`, and
we can't parse elements as `Any`. This resulted in an internal error, rather
than a normal query error.

Fixes cockroachdb#52134.

Release note (bug fix): Fixed an internal error involving string literals used
as arrays.
@RaduBerinde RaduBerinde force-pushed the fix-array-parse-internal-err branch from 4d7b314 to 32522ea Compare August 5, 2020 18:00
Copy link
Member Author

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @otan and @rohany)


pkg/sql/sem/tree/constant.go, line 79 at r1 (raw file):

Previously, rohany (Rohan Yadav) wrote…

I think we have a function typ.IsAmbiguous that does something like this already

Awesome!! Done.

@RaduBerinde
Copy link
Member Author

bors r+

@craig
Copy link
Contributor

craig bot commented Aug 10, 2020

Build failed:

@RaduBerinde
Copy link
Member Author

bors r+

@craig
Copy link
Contributor

craig bot commented Aug 10, 2020

Build succeeded:

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.

sql: v20.2.0-alpha.2: could not parse value as requested type - unknown type
4 participants