Skip to content

Commit

Permalink
Remove wildcard from variable sourcing
Browse files Browse the repository at this point in the history
Resolves the issue where `join_buffer%` matches both `join_buffer_size` and `join_buffer_space_limit`, which in turn results in an error like:

```
./tuning-primer.sh: line 402: export: `2097152': not a valid identifier
```

This was originally necessary because older version of MySQL would use `join_buffer` as the variable instead of `join_buffer_size`.  If you are using a version that old, I apologize for breaking your script, but the good news is, you're probably already broken in dozens of other ways running decade-old code, so I don't feel too bad about piling on.
  • Loading branch information
lint-ai committed Jun 10, 2018
1 parent 651ad16 commit 6b5d866
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tuning-primer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,9 @@ mysql_status () {
#########################################################################

mysql_variable () {
local variable=$($mysql -Bse "show /*!50000 global */ variables like $1" | awk '{ print $2 }')
export "$2"=$variable
local variable=$($mysql -Bse "show /*!50000 global */ variables like $1" | awk '{ print $2 }')
echo "'$1' '$2' '$variable'" >&2
export "$2"=$variable
}
mysql_variableTSV () {
local variable=$($mysql -Bse "show /*!50000 global */ variables like $1" | awk -F \t '{ print $2 }')
Expand Down Expand Up @@ -821,7 +822,7 @@ check_sort_operations () {
mysql_status \'Sort_merge_passes\' sort_merge_passes
mysql_status \'Sort_scan\' sort_scan
mysql_status \'Sort_range\' sort_range
mysql_variable \'sort_buffer%\' sort_buffer_size
mysql_variable \'sort_buffer_size\' sort_buffer_size
mysql_variable \'read_rnd_buffer_size\' read_rnd_buffer_size

total_sorts=$(($sort_scan+$sort_range))
Expand Down Expand Up @@ -879,7 +880,7 @@ check_join_operations () {

mysql_status \'Select_full_join\' select_full_join
mysql_status \'Select_range_check\' select_range_check
mysql_variable \'join_buffer%\' join_buffer_size
mysql_variable \'join_buffer_size\' join_buffer_size

## Some 4K is dropped from join_buffer_size adding it back to make sane ##
## handling of human-readable conversion ##
Expand Down

0 comments on commit 6b5d866

Please sign in to comment.