Skip to content

Per-db file parsing support #1158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
chb0github opened this issue Dec 16, 2017 · 1 comment
Open

Per-db file parsing support #1158

chb0github opened this issue Dec 16, 2017 · 1 comment

Comments

@chb0github
Copy link

MyBatis version

3.3.1

Database vendor and version

mysql 5.6

Test case or example project

https://github.com/chb0github/mybatis-example

Steps to reproduce

docker run -d --rm -p 3306:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw mysql:5.6
sleep 15
migrate up

Expected result

success

Actual result

ERROR: Error executing command. Cause: org.apache.ibatis.jdbc.RuntimeSqlException: Error executing: DELIMITER ||
CREATE FUNCTION format_time( picoseconds BIGINT UNSIGNED )
RETURNS varchar(16) CHARSET utf8
DETERMINISTIC
BEGIN
IF picoseconds IS NULL THEN
RETURN NULL
. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER ||
CREATE FUNCTION format_time( picoseconds BIGINT UNSIGNED )
RETURN' at line 1


I am Proposing a change to support a fix for this as referenced here and here

The problem is because ScriptRunner doesn't parse the file correctly.

I propose the following changes which will allow anyone to be able to implement their own runner:

  1. Change ScriptRunner to be an interface
  2. The current implementation implements this interface as the default
  3. Use the ServiceLoader mechanism in Java to discover other implementations on the class path
  4. Add a method to ScriptRunner to allow to it declare what DB versions it supports in support of step 3
  5. Define the current implementation in the META-inf/services directory

This would also allow fixing of OutOfMemoryError when parsing large scripts (300+mb)

@chb0github
Copy link
Author

Hello?

chb0github added a commit to chb0github/mybatis-3 that referenced this issue Aug 27, 2018
…ybatisGH-1158

* 'mybatisGH-1158' of github.com:chb0github/mybatis-3:
  MySQLSqlParser skip empty statements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant