planner: add protection to avoid setting tot_col_size to negative numbers (#55327) #57142
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an automated cherry-pick of #55327
What problem does this PR solve?
Issue Number: close #55126
Problem Summary: planner: add protection to avoid setting
tot_col_size
to negative numbersWhat changed and how does it work?
See more details and analysis in the issue.
When updating
tot_col_size
, useGREATEST
to protect it from becoming a negative number.Hard to use UT to test it, so I tested it manually locally:
First I hacked the code below to simulate all positive updates on

tot_col_size
are lost:Then execute those SQLs:
Then we can see the
tot_col_size
becomes a negative number:After this PR, this case won't happen, at least we can ensure it's equal or larger than
0
:Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.