Skip to content

sql: change checkResultDatum to use a separate error for DValArg#4162

Merged
kkaneda merged 2 commits intomasterfrom
kaneda/check_result
Feb 6, 2016
Merged

sql: change checkResultDatum to use a separate error for DValArg#4162
kkaneda merged 2 commits intomasterfrom
kaneda/check_result

Conversation

@kkaneda
Copy link
Copy Markdown
Contributor

@kkaneda kkaneda commented Feb 5, 2016

Change other cases to return util.Errorf().

@tamird , does this look good?

Review on Reviewable

sql/executor.go Outdated
case parser.DTimestamp:
case parser.DInterval:
case parser.DValArg:
return fmt.Errorf("could not infer %s", datum.Type())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this should be return fmt.Errorf("could not determine data type of parameter %s", d.name) with switch d := datum.(type) { at the top. This matches postgres' error message.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, I see. Fixed. (Used just d as it seems d.String() is what we want.)

@kkaneda kkaneda force-pushed the kaneda/check_result branch from ac9022f to 16548dd Compare February 5, 2016 15:40
sql/executor.go Outdated
case parser.DTimestamp:
case parser.DInterval:
case parser.DValArg:
return fmt.Errorf("could not determine data type of parameter %s", d)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah, nice. If you wanted to golf a bit more, you could even get rid of d and just use datum here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, fixed!

@tamird
Copy link
Copy Markdown
Contributor

tamird commented Feb 5, 2016

LGTM

@kkaneda kkaneda force-pushed the kaneda/check_result branch from 16548dd to 037dbab Compare February 5, 2016 15:48
"SELECT $1 > 0 AND NOT $1": "pq: incompatible NOT argument type: int",
"SELECT $1": "pq: unsupported result type: valarg",
"SELECT $1": "pq: could not determine data type of parameter $1",
"SELECT $1 + $1": "pq: unsupported binary operator: <valarg> + <valarg>",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I mentioned this in another PR, but it would be nice to replace all the uses of valarg in error messages with something more user friendly, like parameter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see. Pushed another commit to change DValArg.Type() to return "parameter". Does this look fine?

Change other cases to return util.Errorf().
@kkaneda kkaneda force-pushed the kaneda/check_result branch from 037dbab to 4c6b873 Compare February 6, 2016 02:50
sql/executor.go Outdated
case parser.DTimestamp:
case parser.DInterval:
case parser.DValArg:
return fmt.Errorf("could not determine data type of parameter %s", datum)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you can use Type() instead of literally parameter now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done!

@kkaneda kkaneda force-pushed the kaneda/check_result branch from 4c6b873 to defbbd9 Compare February 6, 2016 03:14
@tamird
Copy link
Copy Markdown
Contributor

tamird commented Feb 6, 2016

🚢

"parameter" would be more user-friendly than "valarg".
@kkaneda kkaneda force-pushed the kaneda/check_result branch from defbbd9 to c5bddd7 Compare February 6, 2016 16:53
kkaneda added a commit that referenced this pull request Feb 6, 2016
sql: change checkResultDatum to use a separate error for DValArg
@kkaneda kkaneda merged commit 20e68e7 into master Feb 6, 2016
@kkaneda kkaneda deleted the kaneda/check_result branch February 6, 2016 17:40
hueypark added a commit to hueypark/cockroach that referenced this pull request Oct 27, 2019
Most of these commits are from [engine: Add ExportToSst method with all logic moved to C++](cockroachdb@75f1314). It is not currently testable (PASS on my local) and can be checked when [roachtest: add flag (or env var) to request pebble cockroachdb#4162](cockroachdb#41620) is completed.

Fixes cockroachdb#41739

Release note: None
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.

3 participants