Skip to content

opt: memo cycle detection does not work in some cases in opt tests #83996

@mgartner

Description

@mgartner

Before #83875 was merged, the opt test below creates a memo cycle, but the cycle is not detected as it should be. The cycel is detected when running the same SQL statements in cockroach demo, so perhaps there is something in opttester or the test catalog that prevents cycle detection from working. We may be able to remove the memo-cycles opttester option once we fix this issue, because it would be superfluous - a cycle should result in an error so there is no need to print memo cycles in the memo output.

exec-ddl
CREATE TABLE table80901_1 (
  col1_5  DECIMAL,
  col1_7  BOOL,
  col1_9  OID,
  col1_11 STRING,
  col1_12 STRING,
  col1_14 STRING,
  col1_15 STRING,
  col1_16 STRING,
  col1_17 STRING
);
----

exec-ddl
CREATE TABLE table80901_3 (col3_2 OID, col3_4 FLOAT8, col3_9 STRING);
----

memo
SELECT (
  SELECT NULL
  FROM table80901_1 AS tab_42924
  JOIN table80901_1 AS tab_42927
    LEFT JOIN table80901_3 AS tab_42928 ON tab_42921.col1_7
  JOIN table80901_3 AS tab_42929
  ON tab_42927.col1_9 = tab_42929.col3_2
  ON tab_42924.col1_17 = tab_42927.col1_15
    AND tab_42924.col1_12 = tab_42929.col3_9
    AND tab_42924.col1_14 = tab_42928.col3_9
    AND tab_42924.col1_14 = tab_42929.col3_9
    AND tab_42924.col1_11 = tab_42927.col1_17
    AND tab_42924.col1_11 = tab_42927.col1_16
    AND tab_42924.col1_15 = tab_42929.col3_9
    AND tab_42924.col1_5 = tab_42929.crdb_internal_mvcc_timestamp
)
  FROM table80901_1 AS tab_42921;
----

Jira issue: CRDB-17396

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-queriesSQL Queries Team

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions