Details
- 
    
Bug
 - 
    Status: Closed (View Workflow)
 - 
    
Major
 - 
    Resolution: Fixed
 - 
    1.1.7
 - 
    None
 - 
    None
 - 
    Java 8, MariaDB connector 1.1.7 remotely connected to MariaDB server 10.0.11-MariaDB
 
Description
The query below works fine with MySQL Connector/J driver. But it produces IllegalParameterException with mariaDB Java driver. The server is MariaDB in both cases.
The query:
 REPLACE INTO tblCustomerUDf1 (`BestPracticesNotification`,`SLIndex#orBV#`,`Seems:LikeParam?`,`Webinar1-3QuickSteps`,`Webinar10-TM/ProjComp`,`Webinar2-MSSelling`,`Webinar3-ProductSelling`,`Webinar4-TM/ProjSelling`,`Webinar5-MSDelivery`,`Webinar6-ProductDelivery`, `isM&M'sTasty?`) VALUES (?,?,?,?,?,?,?,?,?,?,?).
The relevant part of stack trace:
org.mariadb.jdbc.internal.common.query.IllegalParameterException: No '?' on that position
	at org.mariadb.jdbc.internal.common.query.MySQLParameterizedQuery.setParameter(MySQLParameterizedQuery.java:103)
	at org.mariadb.jdbc.MySQLPreparedStatement.setParameter(MySQLPreparedStatement.java:477)
	... 89 more
Removing columns with '#' or '?' in names solves the problem. But this is the fail of the driver as MariaDB server legally supports such characters in column names.
After some debugging I figured out that PS parser does not distinguish back-ticks enclosing column names. So it interprets '#' in the column name `SLIndex#orBV#` as a start of the comment. When I remove this column the parser detects parameter placeholder '?' inside the column name `Seems:LikeParam?` etc.
So the parser needs to be improved to respect back-ticks around object names.
The problematic method is org.mariadb.jdbc.internal.common.Utils::createQueryParts
The test table:
CREATE TABLE IF NOT EXISTS `tblCustomerUDf1` (
  `customerID1` int(11) NOT NULL,
  `BestPracticesNotification` text,
  `SLIndex#orBV#` text,
  `isM&M'sTasty?` bit(1) DEFAULT NULL,
  `Seems:LikeParam?` bit(1) DEFAULT NULL,
  `Webinar1-3QuickSteps` text,
  `Webinar2-MSSelling` text,
  `Webinar3-ProductSelling` text,
  `Webinar4-TM/ProjSelling` text,
  `Webinar10-TM/ProjComp` text,
  `Webinar5-MSDelivery` text,
  `Webinar6-ProductDelivery` text
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Thank you,
Ivan