Changeset: c2e7b6cc1dfa for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c2e7b6cc1dfa
Modified Files:
        sql/backends/monet5/sql_time.c
        sql/test/SQLancer/Tests/sqlancer05.sql
        sql/test/SQLancer/Tests/sqlancer05.stable.out
Branch: Oct2020
Log Message:

Making SQLancer happy. Casting a negative second interval to time, means to add 
its complement


diffs (103 lines):

diff --git a/sql/backends/monet5/sql_time.c b/sql/backends/monet5/sql_time.c
--- a/sql/backends/monet5/sql_time.c
+++ b/sql/backends/monet5/sql_time.c
@@ -117,7 +117,10 @@ hge shift, hge divider, hge multiplier
 lng shift, lng divider, lng multiplier
 #endif
 ) {
-       daytime d = daytime_add_usec(daytime_create(0, 0, 0, 0), (next % 
(24*60*60*1000)) * 1000);
+       lng usec = (next % (24*60*60*1000)) * 1000;
+       if (usec < 0) /* for negative intervals add the complement */
+               usec = DAY_USEC - (-usec);
+       daytime d = daytime_add_usec(daytime_create(0, 0, 0, 0), usec);
        assert(!is_daytime_nil(d));
        return daytime_2time_daytime_imp(d, shift, divider, multiplier);
 }
diff --git a/sql/test/SQLancer/Tests/sqlancer05.sql 
b/sql/test/SQLancer/Tests/sqlancer05.sql
--- a/sql/test/SQLancer/Tests/sqlancer05.sql
+++ b/sql/test/SQLancer/Tests/sqlancer05.sql
@@ -365,3 +365,35 @@ SELECT CAST(SUM(count) AS BIGINT) FROM (
 TIME '01:03:49') AS INT)) BETWEEN ASYMMETRIC (t1.c0) AND (t1.c0) AS INT) as 
count FROM t1, t2 NATURAL JOIN t0) as res;
        -- 0
 ROLLBACK;
+
+START TRANSACTION;
+CREATE TABLE "sys"."t0" (
+       "c0" INTERVAL SECOND NOT NULL,
+       "c1" DOUBLE        NOT NULL,
+       CONSTRAINT "t0_c1_c0_pkey" PRIMARY KEY ("c1", "c0"),
+       CONSTRAINT "t0_c0_c1_unique" UNIQUE ("c0", "c1")
+);
+COPY 2 RECORDS INTO "sys"."t0" FROM stdin USING DELIMITERS E'\t',E'\n','"';
+-1209789190.000        879292012
+1924429801.000 0.6708880135477207
+
+CREATE TABLE "sys"."t1" (
+       "c0" TIME,
+       "c1" DECIMAL(18,3),
+       CONSTRAINT "t1_c0_c1_unique" UNIQUE ("c0", "c1")
+);
+COPY 8 RECORDS INTO "sys"."t1" FROM stdin USING DELIMITERS E'\t',E'\n','"';
+04:31:04       0.075
+22:31:37       NULL
+03:24:48       0.588
+NULL   0.808
+05:31:38       0.351
+NULL   0.024
+NULL   0.794
+23:37:32       0.907
+
+select cast(sum(count) as bigint) from (select cast(not (not (true)) as int) 
as count from t1 natural join t0) as res;
+       -- NULL
+select cast(interval '-1' second as time);
+       --23:59:59
+ROLLBACK;
diff --git a/sql/test/SQLancer/Tests/sqlancer05.stable.out 
b/sql/test/SQLancer/Tests/sqlancer05.stable.out
--- a/sql/test/SQLancer/Tests/sqlancer05.stable.out
+++ b/sql/test/SQLancer/Tests/sqlancer05.stable.out
@@ -444,6 +444,45 @@ stdout of test 'sqlancer05` in directory
 % 1 # length
 [ 0    ]
 #ROLLBACK;
+#START TRANSACTION;
+#CREATE TABLE "sys"."t0" (
+#      "c0" INTERVAL SECOND NOT NULL,
+#      "c1" DOUBLE        NOT NULL,
+#      CONSTRAINT "t0_c1_c0_pkey" PRIMARY KEY ("c1", "c0"),
+#      CONSTRAINT "t0_c0_c1_unique" UNIQUE ("c0", "c1")
+#);
+#COPY 2 RECORDS INTO "sys"."t0" FROM stdin USING DELIMITERS E'\t',E'\n','"';
+#-1209789190.000       879292012
+#1924429801.000        0.6708880135477207
+[ 2    ]
+#CREATE TABLE "sys"."t1" (
+#      "c0" TIME,
+#      "c1" DECIMAL(18,3),
+#      CONSTRAINT "t1_c0_c1_unique" UNIQUE ("c0", "c1")
+#);
+#COPY 8 RECORDS INTO "sys"."t1" FROM stdin USING DELIMITERS E'\t',E'\n','"';
+#04:31:04      0.075
+#22:31:37      NULL
+#03:24:48      0.588
+#NULL  0.808
+#05:31:38      0.351
+#NULL  0.024
+#NULL  0.794
+#23:37:32      0.907
+[ 8    ]
+#select cast(sum(count) as bigint) from (select cast(not (not (true)) as int) 
as count from t1 natural join t0) as res;
+% .%5 # table_name
+% %5 # name
+% bigint # type
+% 1 # length
+[ NULL ]
+#select cast(interval '-1' second as time);
+% .%1 # table_name
+% %1 # name
+% time # type
+% 8 # length
+[ 23:59:59     ]
+#ROLLBACK;
 
 # 12:00:38 >  
 # 12:00:38 >  "Done."
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to