(Context<?> ctx)
| 1538 | |
| 1539 | |
| 1540 | @SuppressWarnings("unchecked") |
| 1541 | @Override |
| 1542 | public final void accept(Context<?> ctx) { |
| 1543 | Table<?> dmlTable; |
| 1544 | Table<?> dcdTable; |
| 1545 | List<Table<?>> dmlTables; |
| 1546 | |
| 1547 | // [#6583] [#8609] [#14742] Work around MySQL's self-reference-in-DML-subquery restriction |
| 1548 | if (ctx.subqueryLevel() == 1 |
| 1549 | && REQUIRES_DERIVED_TABLE_DML.contains(ctx.dialect()) |
| 1550 | && !TRUE.equals(ctx.data(DATA_INSERT_SELECT)) |
| 1551 | && (dmlTable = (Table<?>) ctx.data(DATA_DML_TARGET_TABLE)) != null |
| 1552 | && containsUnaliasedTable(getFrom(), dmlTable)) { |
| 1553 | ctx.visit(DSL.select(asterisk()).from(asTable("t"))); |
| 1554 | } |
| 1555 | |
| 1556 | // [#14742] MariaDB still has this bug: https://jira.mariadb.org/browse/MDEV-17954 |
| 1557 | else if (ctx.subqueryLevel() == 1 |
| 1558 | && ctx.family() == MARIADB |
| 1559 | && !TRUE.equals(ctx.data(DATA_INSERT_SELECT)) |
| 1560 | && ( |
| 1561 | |
| 1562 | // A USING clause can be generated when the target table is aliased |
| 1563 | (dmlTable = (Table<?>) ctx.data(DATA_DML_TARGET_TABLE)) != null |
| 1564 | && Tools.aliased(dmlTable) != null |
| 1565 | && containsUnaliasedTable(getFrom(), dmlTable) |
| 1566 | |
| 1567 | // Or, explicitly |
| 1568 | || (dmlTables = (List<Table<?>>) ctx.data(DATA_DML_USING_TABLES)) != null |
| 1569 | && Tools.anyMatch(dmlTables, t -> containsUnaliasedTable(getFrom(), t)))) { |
| 1570 | ctx.visit(DSL.select(asterisk()).from(asTable("t"))); |
| 1571 | } |
| 1572 | |
| 1573 | // [#5810] Emulate the Teradata QUALIFY clause |
| 1574 | else if (qualify.hasWhere() && transformQualify(ctx.configuration())) { |
| 1575 | |
| 1576 | |
| 1577 | |
| 1578 | } |
| 1579 | |
| 1580 | // [#3564] Emulate DISTINCT ON queries at the top level |
| 1581 | else if (Tools.isNotEmpty(distinctOn) && EMULATE_DISTINCT_ON.contains(ctx.dialect())) { |
| 1582 | ctx.visit(distinctOnEmulation()); |
| 1583 | } |
| 1584 | |
| 1585 | |
| 1586 | |
| 1587 | |
| 1588 | |
| 1589 | |
| 1590 | |
| 1591 | |
| 1592 | |
| 1593 | |
| 1594 | |
| 1595 | |
| 1596 | |
| 1597 |
nothing calls this directly
no test coverage detected