From d7f0758e21b5111b5327f3839c5c9f49a04d272b Mon Sep 17 00:00:00 2001
From: Daniel Baumann <daniel.baumann@progress-linux.org>
Date: Wed, 4 Oct 2023 14:14:40 +0200
Subject: Adding upstream version 18.11.2.

Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
---
 tests/fixtures/optimizer/simplify.sql | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

(limited to 'tests/fixtures/optimizer/simplify.sql')

diff --git a/tests/fixtures/optimizer/simplify.sql b/tests/fixtures/optimizer/simplify.sql
index 584e9d6..a9ae192 100644
--- a/tests/fixtures/optimizer/simplify.sql
+++ b/tests/fixtures/optimizer/simplify.sql
@@ -444,6 +444,9 @@ CAST('1998-09-02 00:00:00' AS DATETIME);
 CAST(x AS DATETIME) + interval '1' week;
 CAST(x AS DATETIME) + INTERVAL '1' week;
 
+TS_OR_DS_TO_DATE('1998-12-01 00:00:01') - interval '90' day;
+CAST('1998-09-02' AS DATE);
+
 --------------------------------------
 -- Comparisons
 --------------------------------------
@@ -681,6 +684,9 @@ CONCAT('a', x, y, 'bc');
 'a' || 'b' || x;
 CONCAT('ab', x);
 
+CONCAT(a, b) IN (SELECT * FROM foo WHERE cond);
+CONCAT(a, b) IN (SELECT * FROM foo WHERE cond);
+
 --------------------------------------
 -- DATE_TRUNC
 --------------------------------------
@@ -740,6 +746,9 @@ x >= CAST('2022-01-01' AS DATE);
 DATE_TRUNC('year', x) > CAST('2021-01-02' AS DATE);
 x >= CAST('2022-01-01' AS DATE);
 
+DATE_TRUNC('year', x) > TS_OR_DS_TO_DATE(TS_OR_DS_TO_DATE('2021-01-02'));
+x >= CAST('2022-01-01' AS DATE);
+
 -- right is not a date
 DATE_TRUNC('year', x) <> '2021-01-02';
 DATE_TRUNC('year', x) <> '2021-01-02';
@@ -758,6 +767,17 @@ x < CAST('2022-01-01' AS DATE) AND x >= CAST('2021-01-01' AS DATE);
 TIMESTAMP_TRUNC(x, YEAR) = CAST('2021-01-01' AS DATETIME);
 x < CAST('2022-01-01 00:00:00' AS DATETIME) AND x >= CAST('2021-01-01 00:00:00' AS DATETIME);
 
+-- right side is not a date literal
+DATE_TRUNC('day', x) = CAST(y AS DATE);
+DATE_TRUNC('day', x) = CAST(y AS DATE);
+
+-- nested cast
+DATE_TRUNC('day', x) = CAST(CAST('2021-01-01 01:02:03' AS DATETIME) AS DATE);
+x < CAST('2021-01-02' AS DATE) AND x >= CAST('2021-01-01' AS DATE);
+
+TIMESTAMP_TRUNC(x, YEAR) = CAST(CAST('2021-01-01 01:02:03' AS DATE) AS DATETIME);
+x < CAST('2022-01-01 00:00:00' AS DATETIME) AND x >= CAST('2021-01-01 00:00:00' AS DATETIME);
+
 --------------------------------------
 -- EQUALITY
 --------------------------------------
@@ -794,6 +814,9 @@ x = 2;
 x - INTERVAL 1 DAY = CAST('2021-01-01' AS DATE);
 x = CAST('2021-01-02' AS DATE);
 
+x - INTERVAL 1 DAY = TS_OR_DS_TO_DATE('2021-01-01 00:00:01');
+x = CAST('2021-01-02' AS DATE);
+
 x - INTERVAL 1 HOUR > CAST('2021-01-01' AS DATETIME);
 x > CAST('2021-01-01 01:00:00' AS DATETIME);
 
-- 
cgit v1.2.3

