-
Notifications
You must be signed in to change notification settings - Fork 526
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
feat(pgwire): add infer_return_type interface in session trait #3161
Conversation
src/utils/pgwire/src/pg_protocol.rs
Outdated
let rows: Vec<PgFieldDescriptor> = query | ||
.split(&[' ', ',', ';']) | ||
.skip(1) | ||
.into_iter() | ||
.map(|x| { | ||
if let Some(str) = x.strip_prefix('$') { | ||
if let Ok(i) = str.parse() { | ||
i | ||
} else { | ||
-1 | ||
} | ||
} else { | ||
-1 | ||
} | ||
}) | ||
.take_while(|x: &i32| x.is_positive()) | ||
.map(|x| { | ||
// NOTE Make sure the type_description include all generic parametre | ||
// description we needed. | ||
assert!((x.sub(1) as usize) < types.len()); | ||
PgFieldDescriptor::new(String::new(), types[x.sub(1) as usize].to_owned()) | ||
}) | ||
.collect(); |
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.
Why these part of logic looks so complicated while the impl in Session is so short...
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.
Because the original implement needs to infer the row description from the types descriptions. Now, We just simply get the row description from the infer_return_type. The complicated parts are left to the implementation of infer_return_type.
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.
Rest LGTM
Codecov Report
@@ Coverage Diff @@
## main #3161 +/- ##
==========================================
- Coverage 73.50% 73.49% -0.01%
==========================================
Files 746 746
Lines 101925 101981 +56
==========================================
+ Hits 74916 74951 +35
- Misses 27009 27030 +21
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
5bf3193
to
486945e
Compare
What's changed and what's your intention?
Checklist
./risedev check
(or alias,./risedev c
)Refer to a related PR or issue link (optional)
#3131