ilovejs / h2database

Automatically exported from code.google.com/p/h2database
0 stars 1 forks source link

"default" keyword generates "Syntax error in SQL statement" on MySQL mode #486

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Please send a question to the H2 Google Group or StackOverflow first,
and only then, once you are completely sure it is an issue, submit it here.
The reason is that only very few people actively monitor the issue tracker.

Before submitting a bug, please also check the FAQ:
http://www.h2database.com/html/faq.html

What steps will reproduce the problem?
(simple SQL scripts or simple standalone applications are preferred)
1.Start h2 with MODE=MySQL 
2.create table employee(
    empid BIGINT,
    first_name varchar(50),
    last_name varchar(50)
    ) engine=InnoDB default charset=utf8;
3.

What is the expected output? What do you see instead?
Expected output is a created table, however H2 throws the error :
Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "CREATE 
TABLE EMPLOYEE( EMPID BIGINT, FIRST_NAME VARCHAR(50), LAST_NAME VARCHAR(50) ) 
ENGINE=INNODB DEFAULT[*] CHARSET=UTF8 "; SQL statement:
create table employee( empid BIGINT, first_name varchar(50), last_name 
varchar(50) ) engine=InnoDB default charset=utf8 [42000-172]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
    at org.h2.message.DbException.get(DbException.java:169)
    at org.h2.message.DbException.get(DbException.java:146)
    at org.h2.message.DbException.getSyntaxError(DbException.java:181)
    at org.h2.command.Parser.getSyntaxError(Parser.java:484)
    at org.h2.command.Parser.prepareCommand(Parser.java:233)
    at org.h2.engine.Session.prepareLocal(Session.java:425)
    at org.h2.engine.Session.prepareCommand(Session.java:374)
    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1138)
    at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:167)
    at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:155)
    at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.executeSqlScript(ResourceDatabasePopulator.java:186)
    ... 51 more

What version of the product are you using? On what operating system, file
system, and virtual machine?

- H2 v1.2.132
- Windows 7 64bit
- java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)

Do you know a workaround?
Remove the "default" keyword

What is your use case, meaning why do you need this feature?
We deploy to MySQL in integration environment & etc but want to run unit tests 
using H2.

How important/urgent is the problem for you?

Please provide any additional information below.

Original issue reported on code.google.com by queeq...@gmail.com on 12 Jul 2013 at 3:22

GoogleCodeExporter commented 9 years ago
I've made a mistake. The H2 version is 1.3.172

Original comment by queeq...@gmail.com on 12 Jul 2013 at 3:24

GoogleCodeExporter commented 9 years ago
Just remove the "DEFAULT" keyword. It's optional in MySQL anyway.

Original comment by noelgrandin on 15 Jul 2013 at 6:37

GoogleCodeExporter commented 9 years ago
This turned out to be pretty trivial to support, so I've added it.
Fixed in SVN.

Original comment by noelgrandin on 15 Jul 2013 at 6:56