In trying to create a minimum working example, I have discovered what I believe is the source of my issue.
-
MariaDB stores not only the SQL definition of a view, but also the source code used to create it in the view_name.frm file. It seems HeidiSQL pulls the source code when exporting a database.
-
For built in functions, of which SUBSTR is one, by default MariaDB does not allow white space between the function name and the following '('. However, if the client sets command-line option --ignore-whitespace, it will accept the white space. It seems HeidiSQL runs in default mode and does not allow such white space.
-
In the past I used DBVisualizer, which apparently runs in --ignore-whitespace mode. The SQL formatting feature in that program explicitly introduced the newline and blanks I mentioned in the issue title.
My problem occurred when a view I created in DBVisualizer (that included the offending white space in the source code} was exported and imported in HeidiSQL, where such white space is not permitted.
Having discovered this, my problem is solved. I hope this note helps others who stumble into this situation.