Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-40987

MERGE behavior: should UPDATE and DELETE actions be specified on the same time for the same MERGE statement?

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not a Bug
    • Major
    • bug-backlog
    • Cheshire-Cat
    • query
    • None
    • Untriaged
    • 1
    • Unknown

    Description

      For a MERGE statement, UPDATE and DELETE actions can be specified with WHEN MATCHED clause. Current there is no restriction as to whether both UPDATE and DELETE actions can be specified for the same MERGE statement. For example:

      MERGE INTO shellTest t
      USING shellTest s ON t.c21 = s.c11
      WHEN MATCHED THEN UPDATE set t.c22 = t.c23 unset t.c23 WHERE t.type = "target" AND t.c23 IS NOT MISSING
      WHEN MATCHED THEN DELETE WHERE t.type = "target" AND t.inserted = true
      

      This statement is currently supported, i.e. there is no check to forbid such a statement. A potential issue with this is that the same document could potentially go through both the UPDATE and the DELETE action, and thus potentially be returned to the user twice (if a RETURNING clause is used), which is semantically incorrect.

      We need to do a competitive analysis on how MERGE statement is supported in other databases and come up with a recommendation as to how this should be resolved in Couchbase.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              Donald.haggart Donald Haggart
              bingjie.miao Bingjie Miao
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty