-
Notifications
You must be signed in to change notification settings - Fork 482
Fix EXPLAIN around Char and Varchar #31533
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
Conversation
|
There is a problem: The output of to This might be a problem, because maybe some external tools rely on these being exactly what Postgres says. In that case, I'll have to separate the |
|
Will tweak the PR to not change |
3defdae to
a846d48
Compare
mgree
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I like the new, clearer output. There's some risk of using non postgres_compat output in error messages leading people to get confused about type names. Not a huge risk, likely better this way.
| self.fail_on_len | ||
| ) | ||
| } | ||
| None => f.write_str("text_to_char[len=None]"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The None is a Rust-ism:
| None => f.write_str("text_to_char[len=None]"), | |
| None => f.write_str("text_to_char[len=unbounded]"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, unbounded is indeed better!
| Ok(elem_type) => elem_type, | ||
| Err(elem_type) => bail_unsupported!( | ||
| format!("array_fill on {}", ecx.humanize_scalar_type(&elem_type)) | ||
| format!("array_fill on {}", ecx.humanize_scalar_type(&elem_type, false)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| format!("array_fill on {}", ecx.humanize_scalar_type(&elem_type, false)) | |
| // This will be used in error msgs, therefore we call with `postgres_compat` false. | |
| format!("array_fill on {}", ecx.humanize_scalar_type(&elem_type, false)) |
... and probably similar at other uses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed this one. Generally, I didn't add this comment to all call sites, only to those where it was not immediately clear whether it's only used in an error msg.
| # Fixes database-issues#5222 | ||
|
|
||
| query error db error: ERROR: coalesce could not convert type "char" to character | ||
| query error db error: ERROR: coalesce could not convert type "char" to char |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof, tough error message!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, life is just harsh! :D
But one thing we could possibly do here is to print it more verbosely when postgres_compat is off. For example, we could print it as "char" aka PgLegacyChar. See this comment. What do you think @mgree ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to miss this. I think we can let it be confusing for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. We can do it in a follow-up PR if we think so later.
a846d48 to
377a61e
Compare
|
Thanks for the review! Merging. If we decide to do something about the (The Nightly failure is unrelated.) |
Char and Varchar can involve a length. Additionally, the cast functions
text_to_charandtext_to_varcharinvolve afail_on_lenoption. We were not printing these extra fields in EXPLAIN and in error msgs, causing confusion in various situations, e.g.,https://github.com/MaterializeInc/database-issues/issues/8807#issuecomment-2518662460
https://github.com/MaterializeInc/database-issues/issues/1291
#27029
The first commit attends to
text_to_varcharandtext_to_char.The second commit attends to the type names, changing them in EXPLAIN, error msgs, and
pg_typeof.The third commit reverts the change for
pg_typeof, to keep Postgres compatibility.Nightly: https://buildkite.com/materialize/nightly/builds/11207
Motivation
Tips for reviewer
Checklist
$T ⇔ Proto$Tmapping (possibly in a backwards-incompatible way), then it is tagged with aT-protolabel.