Skip to content
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

Adding regex check for handling failure in parsing dump files with specific syntax #279

Merged

Conversation

shreyakhajanchi
Copy link
Collaborator

This regex check filters out the system generated code of the format :
/!50717 SELECT COUNT() INTO @rocksdb_has_p_s_session_variables FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'performance_schema' AND TABLE_NAME = 'session_variables' */;

Such code format fails in parsing, we have added this regex as a workaround and will remove once pingcap provides a permanent fix for this : pingcap/parser#1370

@@ -110,6 +114,10 @@ func readAndParseChunk(conv *internal.Conv, r *internal.Reader) ([]byte, []ast.S
n += copy(s[n:], l[i])
}
chunk := string(s)
matchStatus := regexExp.Match([]byte(chunk))
if matchStatus {
Copy link
Collaborator

Choose a reason for hiding this comment

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

log that this is being skipped

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added log

@@ -94,6 +94,10 @@ func processMySQLDump(conv *internal.Conv, r *internal.Reader) error {
// files containing tens or hundreds of GB of data.
func readAndParseChunk(conv *internal.Conv, r *internal.Reader) ([]byte, []ast.StmtNode, error) {
var l [][]byte

// Regex for ignoring strings of the form /*!50717 SELECT COUNT(*) INTO @rocksdb_has_p_s_session_variables FROM INFORMATION_SCHEMA.TABLES */;
// These system generated SQL statements are currently not supported by parser and return error.
Copy link
Collaborator

Choose a reason for hiding this comment

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

add reference to the bug in the comment

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added bug reference

Copy link
Collaborator

Choose a reason for hiding this comment

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

this check will slow down the parsing, but let's make optimizing the parsing an independent activity

Copy link
Collaborator

@bharadwaj-aditya bharadwaj-aditya left a comment

Choose a reason for hiding this comment

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

LGTM

@shreyakhajanchi shreyakhajanchi merged commit 18c1f74 into GoogleCloudPlatform:master Apr 20, 2022
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.

2 participants