( cmpOps map[treecmp.ComparisonOperatorSymbol]*CmpOpOverloads, )
| 1475 | } |
| 1476 | |
| 1477 | func cmpOpFixups( |
| 1478 | cmpOps map[treecmp.ComparisonOperatorSymbol]*CmpOpOverloads, |
| 1479 | ) map[treecmp.ComparisonOperatorSymbol]*CmpOpOverloads { |
| 1480 | findVolatility := func(op treecmp.ComparisonOperatorSymbol, t *types.T) volatility.V { |
| 1481 | for _, o := range cmpOps[op].overloads { |
| 1482 | if o.LeftType.Equivalent(t) && o.RightType.Equivalent(t) { |
| 1483 | return o.Volatility |
| 1484 | } |
| 1485 | } |
| 1486 | panic(errors.AssertionFailedf( |
| 1487 | "could not find cmp op %s(%s,%s)", |
| 1488 | redact.Safe(op.String()), t.SQLStringForError(), t.SQLStringForError(), |
| 1489 | )) |
| 1490 | } |
| 1491 | |
| 1492 | // Array equality comparisons. |
| 1493 | for _, t := range append(types.Scalar, types.AnyEnum, types.AnyCollatedString) { |
| 1494 | appendCmpOp := func(sym treecmp.ComparisonOperatorSymbol, cmpOp *CmpOp) { |
| 1495 | s, ok := cmpOps[sym] |
| 1496 | if !ok { |
| 1497 | s = new(CmpOpOverloads) |
| 1498 | cmpOps[sym] = s |
| 1499 | } |
| 1500 | s.overloads = append(s.overloads, cmpOp) |
| 1501 | } |
| 1502 | appendCmpOp(treecmp.EQ, &CmpOp{ |
| 1503 | LeftType: types.MakeArray(t), |
| 1504 | RightType: types.MakeArray(t), |
| 1505 | EvalOp: &CompareScalarOp{treecmp.MakeComparisonOperator(treecmp.EQ)}, |
| 1506 | Volatility: findVolatility(treecmp.EQ, t), |
| 1507 | }) |
| 1508 | appendCmpOp(treecmp.LE, &CmpOp{ |
| 1509 | LeftType: types.MakeArray(t), |
| 1510 | RightType: types.MakeArray(t), |
| 1511 | EvalOp: &CompareScalarOp{treecmp.MakeComparisonOperator(treecmp.LE)}, |
| 1512 | Volatility: findVolatility(treecmp.LE, t), |
| 1513 | }) |
| 1514 | appendCmpOp(treecmp.LT, &CmpOp{ |
| 1515 | LeftType: types.MakeArray(t), |
| 1516 | RightType: types.MakeArray(t), |
| 1517 | EvalOp: &CompareScalarOp{treecmp.MakeComparisonOperator(treecmp.LT)}, |
| 1518 | Volatility: findVolatility(treecmp.LT, t), |
| 1519 | }) |
| 1520 | appendCmpOp(treecmp.IsNotDistinctFrom, &CmpOp{ |
| 1521 | LeftType: types.MakeArray(t), |
| 1522 | RightType: types.MakeArray(t), |
| 1523 | EvalOp: &CompareScalarOp{treecmp.MakeComparisonOperator(treecmp.IsNotDistinctFrom)}, |
| 1524 | CalledOnNullInput: true, |
| 1525 | Volatility: findVolatility(treecmp.IsNotDistinctFrom, t), |
| 1526 | }) |
| 1527 | } |
| 1528 | |
| 1529 | for _, overloads := range cmpOps { |
| 1530 | _ = overloads.ForEachCmpOp(func(op *CmpOp) error { |
| 1531 | op.types = ParamTypes{{"left", op.LeftType}, {"right", op.RightType}} |
| 1532 | return nil |
| 1533 | }) |
| 1534 | } |
no test coverage detected
searching dependent graphs…