[CONJ-760] Cannot insert into a table named "position" Created: 2020-02-12 Updated: 2022-08-16 Resolved: 2022-08-16 |
|
| Status: | Closed |
| Project: | MariaDB Connector/J |
| Component/s: | MySQL compatibility |
| Affects Version/s: | 2.5.4 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Minor |
| Reporter: | Sebastian Brandt | Assignee: | Diego Dupin |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Linux, Java 11, Spring/JPA/Hibernate |
||
| Description |
|
We are using a MySQL 5.6 compatible DB (AWS Aurora Serverless 5.6.10a) and have a table named "position". While selecting from or updating that table works fine using MariaDB Connector/J, inserting into the "position" table raises the error: java.sql.SQLSyntaxErrorException: (conn=106) 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 'position (asset_name, [...] The issue is that the table is named "position", though "position" does not seem to be a reserved keyword in either MariaDB or MySQL (according to online docs). Also it's weird that selecting and updating works but not inserting... We could of course work around this by putting position in ticks (`position`) or by renaming the table but it struck us as weird and maybe it's a bug in MariaDB Connector/J. |
| Comments |
| Comment by Diego Dupin [ 2020-02-17 ] |
|
position is a reserved word, and is now added to https://mariadb.com/kb/en/reserved-words/ . Problem is that i don't see why this would have work with MySQL connector. C/J does some parsing of query, but i've never seen any quote added automagically. I've tryed to make it work with MySQL connector without success. Could you indicate the connection string you use with MySQL, ? Me might have to change something in order to be compatible. |
| Comment by Sebastian Brandt [ 2020-02-18 ] |
|
I replayed the operations on a local test MySQL 5.6 instance to highlight the issue: MySQL connector connection string is: jdbc:mysql://localhost:3306/TEST?characterEncoding=UTF-8 The table was created using the MySQL Connector: DMLs using MySQL Connector: TEST> COMMIT TEST> SELECT * FROM position TEST> UPDATE position SET asset_name = 'NEWTESTVAL' where id = 1 TEST> COMMIT DMLs using MariaDB Connector TEST> UPDATE position SET asset_name = 'NEWTESTVAL2' where id = 1 TEST> COMMIT TEST> SELECT * FROM position TEST> INSERT INTO position (asset_name) values ('TESTVAL2') |
| Comment by Diego Dupin [ 2020-03-04 ] |
|
ahh, i missed the hibernate part. hibernate construct the query according to dialect configuration. Either the dialect configured (org.hibernate.dialect.MySQL55Dialect ?) is incorrect or more probably hibernate automatic resolver has an issue . Could you indicate how this part is configured, and hibernate version you use ? I've just check latest version of resolver, but this seems ok (https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/dialect/Database.java#L275) |
| Comment by Sebastian Brandt [ 2020-03-30 ] |
|
In my comment from 2020-02-17 9:20 I was able to reproduce the issue without Hibernate, with just plan JDBC. Therefore I have some doubts it is related to Hibenate... |
| Comment by Diego Dupin [ 2022-08-16 ] |
|
closing since never reproduced |