-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
lightning: not set pos to end if fail to ReadUntil
#40232
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
/run-integration-br-test |
/component lightning |
a057b07
to
db98061
Compare
/run-integration-br-test |
@@ -341,7 +342,7 @@ func (parser *CSVParser) readUntil(chars *byteSet) ([]byte, byte, error) { | |||
if err == nil { | |||
err = io.EOF | |||
} | |||
parser.pos += int64(len(buf)) | |||
// parser.pos += int64(len(buf)) |
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 changed the semantics of pos
. pos
means the current file offset. Since we have read to the end, the pos should be set to the end offset.
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.
just a test. I didn't change it here.
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 demand is from import on cloud. We are trying to use the offset reported in the syntax error to show the content in users' files. However, in an unterminated quote error, the offset always exceeds the range of the file. So I am about to return the position to the previous one.
If we meet an error, setting back the pos
seems safe because we will never use it again.
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.
However, in an unterminated quote error, the offset always exceeds the range of the file.
Why does offset exceed the range of the file? The end offset is also a valid offset.
It's hard to tell which pos is the starting point of syntax error. Suppose we have a line of data: a,b,c,"xxxxx
It's obvious that it has an unterminated quote error. But what is the right pos of syntax error? Is it the start pos of "xxxx
or the end pos of this line? In my opinion, the end pos is not a wrong answer, because everything is still valid until the end.
I'm not sure how you use the syntax error pos. If you just want to print content near the error, you can print the content around the pos. e.g. When pos is 1000, print content[800:1200].
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 tend to present the starting point of the unterminated quote (i.e., the first quote). Because users should fix the data files and import them again, informing them of the starting point would be better than telling them the end offset of the whole file, which is a bit meaningless
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 does offset exceed the range of the file? The end offset is also a valid offset.
It is the position of EOF (e.g., the size of the file is 35 bytes, then the final offset is 35).
ReadUntil
ReadUntil
/run-unit-test |
/run-integration-br-test |
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.
/run-integration-br-test |
lgtm wait the result of BR CI |
/run-integration-br-test |
/run-integration-br-test |
/test check-dev2 |
@buchuitoudegou please fix CI (lightning exit code not zero) |
/run-integration-br-test |
aborted... |
/run-integration-br-test |
/retest |
@lance6716 @gozssky PTAL again. The CI has passed. |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 2a49047
|
* fix: not set pos to end * add it * fix: return to prevPos * fix: return err * fix * fix * fix it * fix * fix: not exit when err Co-authored-by: Zak Zhao <57036248+joccau@users.noreply.github.com>
What problem does this PR solve?
Issue Number: close #40034
Problem Summary:
What is changed and how it works?
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.