[ 
https://issues.apache.org/jira/browse/IGNITE-8550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16755105#comment-16755105
 ] 

Stanislav Lukyanov commented on IGNITE-8550:
--------------------------------------------

[~smoldachev] Big thanks for looking into this! I'm afraid this PR needs some 
changes though.

First, MySQL spec says that valid values are 0, 1 and 2, not just 1 and 2 - see 
the Description of the JIRA. Need to also allow that.

Second, adding a method to a Java interface is an incompatible change. Any 
implementations of `JdbcDialect` that may exist out there will stop working 
with this change.
One way to approach that would be to use a Java 8's `default` method that would 
return 1, and only override it for MySQL.

Third, we need tests. Let's add test cases that would do inserts of new rows, 
updates of existing rows and set the row to the same value (i.e. check all 
three cases for which MySQL return different values). Without the fix some of 
the MySQL test cases will fail, and with the fix they will pass.

Finally, let's add a comment to the MySQL implementation that would explain how 
we can get different values from the `INSERT`.

If you have questions - feel free to ask, I'll be happy to assist.

> CacheAbstractJdbcStore expects merge to always return 1 but MySQL may also 
> return 2 or 0
> ----------------------------------------------------------------------------------------
>
>                 Key: IGNITE-8550
>                 URL: https://issues.apache.org/jira/browse/IGNITE-8550
>             Project: Ignite
>          Issue Type: Bug
>          Components: cache
>            Reporter: Stanislav Lukyanov
>            Assignee: Moldachev Sergey
>            Priority: Minor
>              Labels: newbie
>             Fix For: 2.8
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> CacheAbstractJdbcStore.write attempts to execute a merge update if it is 
> available, and expects the merge to always return 1 (as the number of updated 
> entries is always 1).
> However, MySQL's `INSERT ... ON DUPLICATE KEY UPDATE` 
> (https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html) may return 
> 0 or 2, depending on what was updated:
> {quote}With ON DUPLICATE KEY UPDATE, the affected-rows value per row is 1 if 
> the row is inserted as a new row, 2 if an existing row is updated, and 0 if 
> an existing row is set to its current values.{quote}
> Because of that, CacheAbstractJdbcStore may report a false warning.
> Need to consider either removing the warning or special-case the MySQL 
> dialect to allow to return values other than 1.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to