# LogicTest: local

statement ok
CREATE TABLE kv (
  k INT PRIMARY KEY,
  v INT
)

query TTT
SELECT tree, field, description FROM [
EXPLAIN (VERBOSE) UPSERT INTO kv TABLE kv ORDER BY v DESC
]
----
count                ·      ·
 └── upsert          ·      ·
      │              into   kv(k, v)
      └── sort       ·      ·
           │         order  -v
           └── scan  ·      ·
·                    table  kv@primary
·                    spans  ALL

# Regression test for #25726.
# UPSERT over tables with column families, on the fast path, use the
# INSERT logic. This has special casing for column families of 1
# column, and another special casing for column families of 2+
# columns. The special casing is only for families that do not include
# the primary key. So we need a table with 3 families: 1 for the PK, 1
# with just 1 col, and 1 with 2+ cols.
statement ok
CREATE TABLE tu (a INT PRIMARY KEY, b INT, c INT, d INT, FAMILY (a), FAMILY (b), FAMILY (c,d));
  INSERT INTO tu VALUES (1, 2, 3, 4)

statement ok
SET tracing = on,kv,results; UPSERT INTO tu VALUES (1, NULL, NULL, NULL); SET tracing = off

query T
SELECT message FROM [SHOW KV TRACE FOR SESSION]
----
Put /Table/54/1/1/0 -> /TUPLE/
Del /Table/54/1/1/1/1
Del /Table/54/1/1/2/1
querying next range at /Table/54/1/1/0
r1: sending batch 1 Put, 2 Del, 1 BeginTxn, 1 EndTxn to (n1,s1):1
fast path completed
rows affected: 1
