statement ok
CREATE TABLE table1
(
    col1_0 INT NULL,
    col1_1 BYTES[] NOT NULL,
    col1_2 INT NULL,
    col1_3 INT NOT NULL,
    col1_4 INT NOT NULL,
    col1_5 FLOAT8,
    col1_6 TIMETZ NOT NULL,
    col1_7 UUID,
    col1_8 int NOT NULL,
    col2 int as (col1_0 + 1) virtual,
    col3 int as (col1_2 + 1) virtual,
    PRIMARY KEY (col1_3 DESC, col1_6),
    INVERTED INDEX (col1_5 ASC, col1_1 ASC),
    UNIQUE (col1_4 DESC, col1_3 ASC, col1_7, col1_8 ASC, col1_6) STORING (col1_1),
    INDEX (col1_0 ASC, col1_2 ASC) WHERE ((((table1.col1_6 = '24:00:00-15:59:00':::TIMETZ) AND (table1.col1_5 <= '-Inf':::FLOAT8)) OR (table1.col1_4 < 0)) AND (table1.col1_3 >= 0)),
    INDEX table1_col1_2_col1_8_col1_0_expr_col1_4_idx (col1_2 DESC, col1_8, col1_0 DESC, col2 ASC, col1_4 DESC) STORING (col1_1, col1_5, col1_7) WHERE table1.col1_3 = 1,
    INDEX table1_expr_idx (col3 DESC) STORING (col1_1, col1_2, col1_4, col1_5, col1_7) WHERE table1.col1_5 < '+Inf':::FLOAT8
);

# The following query takes on the order of 1s to optimize, so we set the
# timeout to a much shorter duration and verify that the optimization is
# canceled accordingly.
statement ok
SET statement_timeout='0.1s';

statement error pq: query execution canceled due to statement timeout
SELECT
  tab_124176.col1_4 AS col_298240, tab_124184.col1_8 AS col_298241
FROM
  table1@[0] AS tab_124176,
  table1@[0] AS tab_124177
  JOIN table1 AS tab_124178
    JOIN table1 AS tab_124179
      JOIN table1 AS tab_124180
        JOIN table1 AS tab_124181 ON
            (tab_124180.col1_0) = (tab_124181.col1_0)
            AND (tab_124180.col1_6) = (tab_124181.col1_6)
            AND (tab_124180.col1_3) = (tab_124181.col1_3)
            AND (tab_124180.col1_2) = (tab_124181.col1_2)
        JOIN table1@[0] AS tab_124182 ON (tab_124181.col1_2) = (tab_124182.col1_8) AND (tab_124180.col1_2) = (tab_124182.tableoid) ON
          (tab_124179.col1_2) = (tab_124180.col1_2)
      JOIN table1@[0] AS tab_124183 ON (tab_124182.col3) = (tab_124183.col1_4) AND (tab_124182.col1_3) = (tab_124183.col3)
      JOIN table1 AS tab_124184
        JOIN table1 AS tab_124185 ON
            (tab_124184.col1_2) = (tab_124185.col1_2)
            AND (tab_124184.col1_6) = (tab_124185.col1_6)
            AND (tab_124184.col1_3) = (tab_124185.col1_3)
            AND (tab_124184.col1_4) = (tab_124185.col1_4) ON (tab_124183.col1_8) = (tab_124184.col1_8) ON
        (tab_124178.col1_2) = (tab_124180.col1_2) AND (tab_124178.col1_2) = (tab_124185.col1_8) AND (tab_124178.col2) = (tab_124182.col3) ON
      (tab_124177.col1_8) = (tab_124181.col1_2) AND (tab_124177.col3) = (tab_124178.col2) AND (tab_124177.col3) = (tab_124183.col1_3);

statement ok
RESET statement_timeout
