Skip to content

Bug Report: Cascading a Set Null constraint on a multicol foreign key fails #13987

@GuptaManan100

Description

@GuptaManan100

Overview of the Issue

This bug was found by the fuzzer that is added in #13980.

=== RUN   TestFkFuzzTest/Unsharded_-_Single_Thread_-_Balanced_Inserts_and_Updates
    mysql.go:228: Vitess and MySQL are not erroring the same way.
        Vitess error: target: uks.0.primary: vttablet: rpc error: code = FailedPrecondition desc = Operand should contain 2 column(s) (errno 1241) (sqlstate 21000) (CallerID: userData1): Sql: "select cola, colb, cola, colb from fk_multicol_t17 where (cola, colb) in ::fkc_vals and (cola, colb) not in (:cola /* INT64 */, :colb /* INT64 */) for update", BindVars: {#maxLimit: "type:INT64 value:\"10001\""cola: "type:INT64 value:\"5\""colb: "type:INT64 value:\"2\""fkc_vals: "type:TUPLE values:{type:TUPLE values:{} values:{}}"id: "type:INT64 value:\"3\""} (errno 1241) (sqlstate 21000) during query: update fk_multicol_t16 set cola = 5, colb = 2 where id = 3
        MySQL error: <nil>
E0914 17:57:47.272051   65012 fk_fuzz_test.go:380] Failing query - update fk_multicol_t16 set cola = 5, colb = 2 where id = 3

We see that the SELECT query that the planner creates is failing.
The schema of the tables are as follows

/*        fk_multicol_t16
 *                    │
 * On Delete Set Null │
 * On Update Set Null │
 *                    │
 *                    ▼
 *        fk_multicol_t17──────────────────┐
 *                    │                    │
 *                    │                    │ On Delete Set Null
 *  On Delete Cascade │                    │ On Update Set Null
 *  On Update Cascade │                    │
 *                    │                    │
 *                    ▼                    ▼
 *        fk_multicol_t18      fk_multicol_t19
 */

Reproduction Steps

Create the tables with the given schema
Then, try running an update query as listed above

Binary Version

main

Operating System and Environment details

main

Log Fragments

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions