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

C++: Use interpolation to avoid a bad join order #16230

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

MathiasVP
Copy link
Contributor

@MathiasVP MathiasVP commented Apr 16, 2024

@nickrolfe highlighted this bad join:

Evaluated relational algebra for predicate #select@4dc5a3gq with tuple counts:
  1125  ~0%    {5} r1 = SCAN globalvariables OUTPUT In.0, _, In.2, _, _
  1125  ~2%    {2}    | REWRITE WITH Tmp.1 := "The variable '", Tmp.3 := "'", Tmp.4 := " is used in this function but may not be initialized when it is called.", Out.1 := (Tmp.1 ++ In.2 ++ Tmp.3 ++ Tmp.4) KEEPING 2
     6  ~0%    {3}    | JOIN WITH `GlobalUseBeforeInit::useFunc/2#81a8e7f2` ON FIRST 1 OUTPUT Lhs.0, Rhs.1, Lhs.1
     1  ~0%    {2}    | JOIN WITH `GlobalUseBeforeInit::uninitialisedBefore/2#8cd27ca7#bf` ON FIRST 2 OUTPUT Lhs.1, Lhs.2
               return r1

This is exactly the same kind of join order issue we've seen in #16089.

This query isn't in any security suite so it doesn't really make sense to run DCA on it

@MathiasVP MathiasVP requested a review from a team as a code owner April 16, 2024 15:25
@github-actions github-actions bot added the C++ label Apr 16, 2024
@MathiasVP MathiasVP added the no-change-note-required This PR does not need a change note label Apr 16, 2024
Copy link
Contributor

@nickrolfe nickrolfe left a comment

Choose a reason for hiding this comment

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

LGTM

select f,
"The variable '" + v.getName() + "'" +
" is used in this function but may not be initialized when it is called."
select f, "The variable $@ is used in this function but may not be initialized when it is called.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need single-quotes around the $@?

Copy link
Contributor Author

@MathiasVP MathiasVP Apr 16, 2024

Choose a reason for hiding this comment

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

We could definitely do that to keep the query message close to what it is now. We don't use '$@' anywhere else in any C/C++ queries, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've merged the PR now. If you prefer a single-quotes around the interpolation I'd be happy to open a follow-up PR

@MathiasVP MathiasVP merged commit 8f82db0 into github:main Apr 16, 2024
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants