-
Notifications
You must be signed in to change notification settings - Fork 525
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):support portal description #3397
Conversation
Codecov Report
@@ Coverage Diff @@
## main #3397 +/- ##
==========================================
- Coverage 73.73% 73.72% -0.01%
==========================================
Files 761 761
Lines 104467 104506 +39
==========================================
+ Hits 77030 77049 +19
- Misses 27437 27457 +20
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 |
src/utils/pgwire/src/pg_extended.rs
Outdated
let statement = cstr_to_str(&self.query_string).unwrap().to_owned(); | ||
|
||
if params.is_empty() { | ||
return PgPortal { | ||
let row_description = | ||
if statement.starts_with("select") || statement.starts_with("SELECT") { |
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.
I' m not sure whether query can be sElEcT
src/utils/pgwire/src/pg_extended.rs
Outdated
if let Ok(rows) = session.infer_return_type(statement.as_str()).await { | ||
rows | ||
} else { | ||
return Err(()); |
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.
What about use ?
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.
What about use
?
infer_return_type -> Result<-, BoxedError>
We can't covert Result<-, BoxedError> to Result<-,()> when using '?'. Or is there another way can process it more concisely?
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.
try .map_err?
src/utils/pgwire/src/pg_extended.rs
Outdated
let row_description = if instance_query_string.starts_with("select") | ||
|| instance_query_string.starts_with("SELECT") |
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.
This part of code is very similar to above.
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.
We can extract a function inside portal?
fn infer_row_description(sql: &str,session: Arc<SM::Session>,) -> Result<Vec<PgFieldDescriptor>, ()>
src/utils/pgwire/src/pg_protocol.rs
Outdated
// TODO: Error Handle | ||
todo!() |
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.
Link a TODO issue in code. You can check #2366. Investigate whether we can improve Error in the pgwire-crates
src/utils/pgwire/src/pg_protocol.rs
Outdated
let session = self.session.clone().unwrap(); | ||
let portal = statement | ||
.instance::<SM>(session, portal_name.clone(), &m.params) |
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.
directly self.session.clone(). No need for a temporal variable here.
// NOTE Error handle need modify later. | ||
named_statements.get(&name).unwrap() | ||
}; | ||
if m.kind == b'S' { |
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.
Add some comments explain what is 'S' or 'P' ?
src/utils/pgwire/src/pg_extended.rs
Outdated
let statement = cstr_to_str(&self.query_string).unwrap().to_owned(); | ||
|
||
if params.is_empty() { | ||
return PgPortal { | ||
let row_description = | ||
if statement.starts_with("select") || statement.starts_with("SELECT") { |
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.
I guess you should take the first 6 characters and case-insensitively compare them with "select", which means you can convert all characters to lower-case. I don't know if "Select" would work?
eba89d8
to
5d2352d
Compare
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
src/utils/pgwire/src/pg_extended.rs
Outdated
if sql.len() > 6 && sql[0..6].eq_ignore_ascii_case("select") { | ||
session.infer_return_type(sql).await.map_err(|_e| ()) | ||
} else { | ||
Ok(vec![]) | ||
} |
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.
if sql.len() > 6 && sql[0..6].eq_ignore_ascii_case("select") {
return session.infer_return_type(sql).await.map_err(|_e| ());
}
Ok(vec![])
```
Try this?
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.
Would it be more efficient
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.
More clean. We should redcue the if-else pairs. One if is more readable than if-else
5d2352d
to
4759a67
Compare
I hereby agree to the terms of the Singularity Data, Inc. Contributor License Agreement.
What's changed and what's your intention?
Support portal type in describe message. It is required when using JDBC.
PLEASE DO NOT LEAVE THIS EMPTY !!!
Please explain IN DETAIL what the changes are in this PR and why they are needed:
Checklist
./risedev check
(or alias,./risedev c
)Refer to a related PR or issue link (optional)
#3392