The problem here is that xargs will strip single and double quotes from its
inputs, meaning table names with spaces are not correctly dealt with.
I can confirm a preferred fix - use backticks:
I have changed the SELECT line to:
SELECT CONCAT("select count(*) into @discard from `", TABLE_SCHEMA, "`.`",
TABLE_NAME, "`")
And can confirm that works.
xargs does not apparently strip backticks.
There is another potential fix mentioned in the answer below, which is
specify the delimiter to xargs using `-d '\n'` which will also apparently
work.
RE: related answer given here:
https://stackoverflow.com/questions/79812697