export adds newline and blanks between function name and opening parenthesis

wheelerwjx9's profile image wheelerwjx9 posted 2 months ago in General Permalink

I have a MariaDB database that uses the SUBSTR function. Running the export database function on this database, the output text file shows that a newline, tab and spaces have been inserted between the Function name 'SUBSTR' and the immediately following open parenthesis '('. This causes the import process to fail with a SQL Error (1630): Function database.SUBSTR dows not exist.

Is there a work-around or fix, short of hand editing the exported SQL file?

ansgar's profile image ansgar posted 2 months ago Permalink

Can you please provide a sample of that exported SQL? Please remove sensitive information if any.

wheelerwjx9's profile image wheelerwjx9 posted 2 months ago Permalink

In trying to create a minimum working example, I have discovered what I believe is the source of my issue.

  1. 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.

  2. 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.

  3. 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.

Please login to leave a reply, or register at first.