Uploaded image for project: 'Debezium'
  1. Debezium
  2. DBZ-7874

MariaDB target should support 'upsert' for insert.mode

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Done
    • Icon: Major Major
    • 2.7.0.Beta1
    • None
    • jdbc-connector
    • None

      In order to make your issue reports as actionable as possible, please provide the following information, depending on the issue type.

      Bug report

      For bug reports, provide this information, please:

      What Debezium connector do you use and what version?

      debezium-connector-jdbc-2.7.0.Alpha1.jar

      What is the connector configuration?

      {
        "name": "jdbc-upsert-connector",
        "config": {
          "connector.class": "io.debezium.connector.jdbc.JdbcSinkConnector",
          "connection.password": "[my-password]",
          "tasks.max": "1",
          "connection.username": "[my-username]",
          "delete.enabled": "true",
          "auto.create": "false",
          "auto.evolve": "true",
          "driver.class": "org.mariadb.jdbc.Driver",
          "connection.url": "jdbc:mariadb://[host]:[port]/[db]",
          "primary.key.mode": "record_key",  
          "topics": "debezium-server.public.User",
          "schema.evolution": "basic",
          "insert.mode": "upsert",
          "transforms.unwrap.drop.tombstones": "false"

        }}

       

      What is the captured database version and mode of depoyment?

      (E.g. on-premises, with a specific cloud provider, etc.)

      MariaDB 10.6.17 deployed by docker in WSL

      What behaviour do you expect?

      when data is updated, I want the sql statement to be like this.

      ex)

      INSERT INTO `debezium-server_public_User` (id, email, name) VALUES (1, 'test1@test.com', 'name') ON DUPLICATE KEY UPDATE email=VALUES(email),name=VALUES(name)

       

       

       

      What behaviour do you see?

      HOWEVER, due to conditional statement in the source code (MySQLDatabaseDialect.java)

      // code placeholder
      if (getDatabaseVersion().isSameOrAfter(8, 0, 20)) {
          // MySQL 8.0.20 deprecated the use of "VALUES()" in exchange for table aliases
          builder.append("AS new ON DUPLICATE KEY UPDATE ");
          builder.appendList(",", updateColumnNames, (name) -> {
          final String columnName = columnNameFromField(name, record);
          return columnName + "=new." + columnName;
          });
      }
      else {
         builder.append("ON DUPLICATE KEY UPDATE ");
         builder.appendList(",", updateColumnNames, (name) -> {
             final String columnName = columnNameFromField(name, record);
             return columnName + "=VALUES(" + columnName + ")";
         });
      }

      It's using the statement using "AS new" and it's not supported by MariaDB yet.

      Do you see the same behaviour using the latest relesead Debezium version?

      (Ideally, also verify with latest Alpha/Beta/CR version)

      <Your answer>

      Yes( Alpha)

      Do you have the connector logs, ideally from start till finish?

      (You might be asked later to provide DEBUG/TRACE level log)

      <Your answer>

      How to reproduce the issue using our tutorial deployment?

      <Your answer>

      Feature request or enhancement

      For feature requests or enhancements, provide this information, please:

      Which use case/requirement will be addressed by the proposed feature?

      <Your answer>

      Implementation ideas (optional)

      For temporary use, can the hibernate recognize if it's mariadb or mysql, and define its version separately?

            Unassigned Unassigned
            joontube Seongjoon Jeong
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: