FAILURE MAP
← Case archive

FA-45411 / Data systems / Open access

MERGE updates matched rows but drops new source keys · case 01

MERGE updates matched rows but drops new source keys.

Verified by executionVariant 1 · 7 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

merge-statement-preflight: MERGE updates matched rows but drops new source keys.

THE FAILURE

merge-statement-preflight: MERGE updates matched rows but drops new source keys.

Unsuccessful approach: Checking whether any target exists still drops inserts into an empty table.

Case contract

Merge source [key,value] into a target unique-key table. Any repeated source key is CARDINALITY and leaves target unchanged; otherwise matched keys replace payloads and unmatched keys insert. Return status and sorted final rows. Source null keys are ordinary distinct keys in this stipulated integer-key model only (inputs here are integer keys).

Why this case matters

A bounded deterministic data engine model makes representation and changelog faults reproducible.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        target,source=d
        state=dict(target)
        keys=[k for k,v in source]
        if len(set(keys))!=len(keys): return ['CARDINALITY',sorted(target)]
        for key,value in source:
            if key in state: state[key]=value
        return ['OK',sorted([[k,v] for k,v in state.items()])]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('matched update', solve([[[10, 1]], [[10, 2]]]), ['OK', [[10, 2]]])
    check('unmatched insert', solve([[[10, 1]], [[11, 2]]]), ['OK', [[10, 1], [11, 2]]])
    check('new duplicate keys', solve([[], [[10, 1], [10, 2]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 1]], [[10, 2], [10, 3]]]), ['CARDINALITY', [[10, 1]]])
    check('duplicate payload not key', solve([[], [[10, 1], [11, 1]]]), ['OK', [[10, 1], [11, 1]]])
    check('empty source', solve([[[10, 1]], []]), ['OK', [[10, 1]]])
    check('empty target', solve([[], [[10, 1]]]), ['OK', [[10, 1]]])
elif N == 2:
    check('matched update', solve([[[10, 2]], [[10, 3]]]), ['OK', [[10, 3]]])
    check('unmatched insert', solve([[[10, 2]], [[11, 3]]]), ['OK', [[10, 2], [11, 3]]])
    check('new duplicate keys', solve([[], [[10, 2], [10, 3]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 2]], [[10, 3], [10, 4]]]), ['CARDINALITY', [[10, 2]]])
    check('duplicate payload not key', solve([[], [[10, 2], [11, 2]]]), ['OK', [[10, 2], [11, 2]]])
    check('empty source', solve([[[10, 2]], []]), ['OK', [[10, 2]]])
    check('empty target', solve([[], [[10, 2]]]), ['OK', [[10, 2]]])
elif N == 3:
    check('matched update', solve([[[10, 3]], [[10, 4]]]), ['OK', [[10, 4]]])
    check('unmatched insert', solve([[[10, 3]], [[11, 4]]]), ['OK', [[10, 3], [11, 4]]])
    check('new duplicate keys', solve([[], [[10, 3], [10, 4]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 3]], [[10, 4], [10, 5]]]), ['CARDINALITY', [[10, 3]]])
    check('duplicate payload not key', solve([[], [[10, 3], [11, 3]]]), ['OK', [[10, 3], [11, 3]]])
    check('empty source', solve([[[10, 3]], []]), ['OK', [[10, 3]]])
    check('empty target', solve([[], [[10, 3]]]), ['OK', [[10, 3]]])
elif N == 4:
    check('matched update', solve([[[10, 4]], [[10, 5]]]), ['OK', [[10, 5]]])
    check('unmatched insert', solve([[[10, 4]], [[11, 5]]]), ['OK', [[10, 4], [11, 5]]])
    check('new duplicate keys', solve([[], [[10, 4], [10, 5]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 4]], [[10, 5], [10, 6]]]), ['CARDINALITY', [[10, 4]]])
    check('duplicate payload not key', solve([[], [[10, 4], [11, 4]]]), ['OK', [[10, 4], [11, 4]]])
    check('empty source', solve([[[10, 4]], []]), ['OK', [[10, 4]]])
    check('empty target', solve([[], [[10, 4]]]), ['OK', [[10, 4]]])
elif N == 5:
    check('matched update', solve([[[10, 5]], [[10, 6]]]), ['OK', [[10, 6]]])
    check('unmatched insert', solve([[[10, 5]], [[11, 6]]]), ['OK', [[10, 5], [11, 6]]])
    check('new duplicate keys', solve([[], [[10, 5], [10, 6]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 5]], [[10, 6], [10, 7]]]), ['CARDINALITY', [[10, 5]]])
    check('duplicate payload not key', solve([[], [[10, 5], [11, 5]]]), ['OK', [[10, 5], [11, 5]]])
    check('empty source', solve([[[10, 5]], []]), ['OK', [[10, 5]]])
    check('empty target', solve([[], [[10, 5]]]), ['OK', [[10, 5]]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
matched update['OK', [[10, 2]]]['OK', [[10, 2]]]Passed
unmatched insert['OK', [[10, 1]]]['OK', [[10, 1], [11, 2]]]Failed
new duplicate keys['CARDINALITY', []]['CARDINALITY', []]Passed
existing duplicate keys['CARDINALITY', [[10, 1]]]['CARDINALITY', [[10, 1]]]Passed
duplicate payload not key['OK', []]['OK', [[10, 1], [11, 1]]]Failed
empty source['OK', [[10, 1]]]['OK', [[10, 1]]]Passed
empty target['OK', []]['OK', [[10, 1]]]Failed

SHA-256 / 8b636708e71faa688ec0dd45a97229346235f64f08bec2ef6c0ac62faa47602f

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        target,source=d
        state=dict(target)
        keys=[k for k,v in source]
        if len(set(keys))!=len(keys): return ['CARDINALITY',sorted(target)]
        for key,value in source:
            if state: state[key]=value
        return ['OK',sorted([[k,v] for k,v in state.items()])]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('matched update', solve([[[10, 1]], [[10, 2]]]), ['OK', [[10, 2]]])
    check('unmatched insert', solve([[[10, 1]], [[11, 2]]]), ['OK', [[10, 1], [11, 2]]])
    check('new duplicate keys', solve([[], [[10, 1], [10, 2]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 1]], [[10, 2], [10, 3]]]), ['CARDINALITY', [[10, 1]]])
    check('duplicate payload not key', solve([[], [[10, 1], [11, 1]]]), ['OK', [[10, 1], [11, 1]]])
    check('empty source', solve([[[10, 1]], []]), ['OK', [[10, 1]]])
    check('empty target', solve([[], [[10, 1]]]), ['OK', [[10, 1]]])
elif N == 2:
    check('matched update', solve([[[10, 2]], [[10, 3]]]), ['OK', [[10, 3]]])
    check('unmatched insert', solve([[[10, 2]], [[11, 3]]]), ['OK', [[10, 2], [11, 3]]])
    check('new duplicate keys', solve([[], [[10, 2], [10, 3]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 2]], [[10, 3], [10, 4]]]), ['CARDINALITY', [[10, 2]]])
    check('duplicate payload not key', solve([[], [[10, 2], [11, 2]]]), ['OK', [[10, 2], [11, 2]]])
    check('empty source', solve([[[10, 2]], []]), ['OK', [[10, 2]]])
    check('empty target', solve([[], [[10, 2]]]), ['OK', [[10, 2]]])
elif N == 3:
    check('matched update', solve([[[10, 3]], [[10, 4]]]), ['OK', [[10, 4]]])
    check('unmatched insert', solve([[[10, 3]], [[11, 4]]]), ['OK', [[10, 3], [11, 4]]])
    check('new duplicate keys', solve([[], [[10, 3], [10, 4]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 3]], [[10, 4], [10, 5]]]), ['CARDINALITY', [[10, 3]]])
    check('duplicate payload not key', solve([[], [[10, 3], [11, 3]]]), ['OK', [[10, 3], [11, 3]]])
    check('empty source', solve([[[10, 3]], []]), ['OK', [[10, 3]]])
    check('empty target', solve([[], [[10, 3]]]), ['OK', [[10, 3]]])
elif N == 4:
    check('matched update', solve([[[10, 4]], [[10, 5]]]), ['OK', [[10, 5]]])
    check('unmatched insert', solve([[[10, 4]], [[11, 5]]]), ['OK', [[10, 4], [11, 5]]])
    check('new duplicate keys', solve([[], [[10, 4], [10, 5]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 4]], [[10, 5], [10, 6]]]), ['CARDINALITY', [[10, 4]]])
    check('duplicate payload not key', solve([[], [[10, 4], [11, 4]]]), ['OK', [[10, 4], [11, 4]]])
    check('empty source', solve([[[10, 4]], []]), ['OK', [[10, 4]]])
    check('empty target', solve([[], [[10, 4]]]), ['OK', [[10, 4]]])
elif N == 5:
    check('matched update', solve([[[10, 5]], [[10, 6]]]), ['OK', [[10, 6]]])
    check('unmatched insert', solve([[[10, 5]], [[11, 6]]]), ['OK', [[10, 5], [11, 6]]])
    check('new duplicate keys', solve([[], [[10, 5], [10, 6]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 5]], [[10, 6], [10, 7]]]), ['CARDINALITY', [[10, 5]]])
    check('duplicate payload not key', solve([[], [[10, 5], [11, 5]]]), ['OK', [[10, 5], [11, 5]]])
    check('empty source', solve([[[10, 5]], []]), ['OK', [[10, 5]]])
    check('empty target', solve([[], [[10, 5]]]), ['OK', [[10, 5]]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
matched update['OK', [[10, 2]]]['OK', [[10, 2]]]Passed
unmatched insert['OK', [[10, 1], [11, 2]]]['OK', [[10, 1], [11, 2]]]Passed
new duplicate keys['CARDINALITY', []]['CARDINALITY', []]Passed
existing duplicate keys['CARDINALITY', [[10, 1]]]['CARDINALITY', [[10, 1]]]Passed
duplicate payload not key['OK', []]['OK', [[10, 1], [11, 1]]]Failed
empty source['OK', [[10, 1]]]['OK', [[10, 1]]]Passed
empty target['OK', []]['OK', [[10, 1]]]Failed

SHA-256 / 1af72b9bfacabd4afb2502d6f0f84bed8ed50ba49aebaf7790743c6e84b696ef

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 7 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

Verification & scope

Offline stipulated semantics over valid small inputs; no performance, concurrency, or production-engine conformance claim. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:44:21.988749+00:00.

Case digest / 8caba3e2458bcdd4a1046041e55482579e93d68fbaefa7b13a78d3298387e2c0