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

fix(spans): Scrub RELEASE SAVEPOINT statements #3091

Merged
merged 7 commits into from
Feb 13, 2024
Merged

Conversation

jjbayer
Copy link
Member

@jjbayer jjbayer commented Feb 12, 2024

sqlparser improved parsing capabilities, which made us rely on the fallback scrubber less. Unfortunately, In the case of savepoints, the fallback scrubber caught more than the parser-based scrubber.

Reverts #3083
Fixes #3085

@@ -492,7 +497,6 @@ impl VisitorMut for NormalizeVisitor {
}
}
}

_ => {}
Copy link
Member

Choose a reason for hiding this comment

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

Can we get rid of this catch all, if in the future the library introduces new values to the enum it won't compile and we know we have to check something?

Copy link
Member Author

Choose a reason for hiding this comment

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

We absolutely should. I already started doing it and then gave up because there are so many match arms. But I guess I'll just power through.

Comment on lines +508 to +671
Statement::CreateExtension { name, .. } => Self::scrub_name(name),
Statement::Flush { channel, .. } => *channel = None,
Statement::Discard { .. } => {}
Statement::SetRole { role_name, .. } => {
if let Some(role_name) = role_name {
Self::scrub_name(role_name);
}
}
Statement::SetVariable { .. } => {}
Statement::SetTimeZone { .. } => {}
Statement::SetNames {
charset_name,
collation_name,
} => {
*charset_name = "%s".into();
*collation_name = None;
}
Statement::SetNamesDefault {} => {}
Statement::ShowFunctions { filter } => Self::scrub_statement_filter(filter),
Statement::ShowVariable { variable } => Self::simplify_compound_identifier(variable),
Statement::ShowVariables { filter, .. } => Self::scrub_statement_filter(filter),
Statement::ShowCreate { .. } => {}
Statement::ShowColumns { filter, .. } => Self::scrub_statement_filter(filter),
Statement::ShowTables {
db_name, filter, ..
} => {
if let Some(db_name) = db_name {
Self::scrub_name(db_name);
}
Self::scrub_statement_filter(filter);
}
Statement::ShowCollation { filter } => Self::scrub_statement_filter(filter),
Statement::Use { db_name } => Self::scrub_name(db_name),
Statement::StartTransaction { .. } => {}
Statement::SetTransaction { .. } => {}
Statement::Comment { comment, .. } => *comment = None,
Statement::Commit { .. } => {}
Statement::Rollback { savepoint, .. } => {
if let Some(savepoint) = savepoint {
Self::erase_name(savepoint);
}
}
Statement::CreateSchema { .. } => {}
Statement::CreateDatabase {
location,
managed_location,
..
} => {
*location = None;
*managed_location = None;
}
Statement::CreateFunction { .. } => {}
Statement::CreateProcedure { .. } => {}
Statement::CreateMacro { .. } => {}
Statement::CreateStage { comment, .. } => *comment = None,
Statement::Assert { .. } => {}
Statement::Grant {
grantees,
granted_by,
..
} => {
Self::simplify_compound_identifier(grantees);
*granted_by = None;
}
Statement::Revoke {
grantees,
granted_by,
..
} => {
Self::simplify_compound_identifier(grantees);
*granted_by = None;
}
Statement::Deallocate { name, .. } => {
Self::scrub_name(name);
}
Statement::Execute { name, .. } => Self::scrub_name(name),
Statement::Prepare { name, .. } => Self::scrub_name(name),
Statement::Kill { id, .. } => *id = 0,
Statement::ExplainTable { .. } => {}
Statement::Explain { .. } => {}
Statement::Merge { .. } => {}
Statement::Cache { .. } => {}
Statement::UNCache { .. } => {}
Statement::CreateSequence { .. } => {}
Statement::CreateType { .. } => {}
Statement::Pragma { .. } => {}
Statement::LockTables { tables } => {
for table in tables {
let LockTable {
table,
alias,
lock_type: _,
} = table;
Self::scrub_name(table);
if let Some(alias) = alias {
Self::scrub_name(alias);
}
}
}
Statement::UnlockTables => {}
Copy link
Member Author

Choose a reason for hiding this comment

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

These have not caused high cardinality in the past, but it's better to list them explicitly in case a new variant is introduced.

@jjbayer jjbayer marked this pull request as ready for review February 12, 2024 14:43
@jjbayer jjbayer requested a review from a team as a code owner February 12, 2024 14:43
@jjbayer jjbayer requested a review from phacops February 12, 2024 14:43
@jjbayer jjbayer merged commit 7069adc into master Feb 13, 2024
21 checks passed
@jjbayer jjbayer deleted the fix/spans-savepoint branch February 13, 2024 10:41
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.

RELEASE SAVEPOINT and ROLLBACK TO SAVEPOINT SQL statements aren't scrubbed
3 participants