Changeset: e20eabcc3d0a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e20eabcc3d0a
Modified Files:
        sql/server/sql_atom.c
        sql/test/pg_regress/Tests/timestamp.stable.out
        sql/test/pg_regress/Tests/timestamptz.stable.out
Branch: context
Log Message:

merged with default


diffs (truncated from 1115 to 300 lines):

diff --git a/sql/server/sql_atom.c b/sql/server/sql_atom.c
--- a/sql/server/sql_atom.c
+++ b/sql/server/sql_atom.c
@@ -237,6 +237,72 @@ atom_float(sql_allocator *sa, sql_subtyp
        return a;
 }
 
+#ifdef HAVE_HGE
+hge scales[39] = {
+       (hge) LL_CONSTANT(1),
+       (hge) LL_CONSTANT(10),
+       (hge) LL_CONSTANT(100),
+       (hge) LL_CONSTANT(1000),
+       (hge) LL_CONSTANT(10000),
+       (hge) LL_CONSTANT(100000),
+       (hge) LL_CONSTANT(1000000),
+       (hge) LL_CONSTANT(10000000),
+       (hge) LL_CONSTANT(100000000),
+       (hge) LL_CONSTANT(1000000000),
+       (hge) LL_CONSTANT(10000000000),
+       (hge) LL_CONSTANT(100000000000),
+       (hge) LL_CONSTANT(1000000000000),
+       (hge) LL_CONSTANT(10000000000000),
+       (hge) LL_CONSTANT(100000000000000),
+       (hge) LL_CONSTANT(1000000000000000),
+       (hge) LL_CONSTANT(10000000000000000),
+       (hge) LL_CONSTANT(100000000000000000),
+       (hge) LL_CONSTANT(1000000000000000000),
+       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(1),
+       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(10),
+       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(100),
+       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(1000),
+       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(10000),
+       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(100000),
+       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(1000000),
+       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(10000000),
+       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(100000000),
+       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(1000000000),
+       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(10000000000),
+       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(100000000000),
+       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(1000000000000),
+       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(10000000000000),
+       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(100000000000000),
+       (hge) LL_CONSTANT(10000000000000000000U) * 
LL_CONSTANT(1000000000000000),
+       (hge) LL_CONSTANT(10000000000000000000U) * 
LL_CONSTANT(10000000000000000),
+       (hge) LL_CONSTANT(10000000000000000000U) * 
LL_CONSTANT(100000000000000000),
+       (hge) LL_CONSTANT(10000000000000000000U) * 
LL_CONSTANT(1000000000000000000),
+       (hge) LL_CONSTANT(10000000000000000000U) * 
LL_CONSTANT(10000000000000000000U)
+};
+#else
+lng scales[19] = {
+       LL_CONSTANT(1),
+       LL_CONSTANT(10),
+       LL_CONSTANT(100),
+       LL_CONSTANT(1000),
+       LL_CONSTANT(10000),
+       LL_CONSTANT(100000),
+       LL_CONSTANT(1000000),
+       LL_CONSTANT(10000000),
+       LL_CONSTANT(100000000),
+       LL_CONSTANT(1000000000),
+       LL_CONSTANT(10000000000),
+       LL_CONSTANT(100000000000),
+       LL_CONSTANT(1000000000000),
+       LL_CONSTANT(10000000000000),
+       LL_CONSTANT(100000000000000),
+       LL_CONSTANT(1000000000000000),
+       LL_CONSTANT(10000000000000000),
+       LL_CONSTANT(100000000000000000),
+       LL_CONSTANT(1000000000000000000)
+};
+#endif
+
 atom *
 atom_general(sql_allocator *sa, sql_subtype *tpe, const char *val)
 {
@@ -277,6 +343,17 @@ atom_general(sql_allocator *sa, sql_subt
                        }
                        VALset(&a->data, a->data.vtype, p);
                        SA_VALcopy(sa, &a->data, &a->data);
+                       if (tpe->type->eclass == EC_TIME && tpe->digits <= 7) {
+                               int diff = 6-(tpe->digits-1);
+#ifdef HAVE_HGE
+                               hge d = scales[diff];
+#else
+                               lng d = scales[diff];
+#endif
+
+                               a->data.val.lval /= d;
+                               a->data.val.lval *= d;
+                       }
                        GDKfree(p);
                }
        } else { 
@@ -559,71 +636,6 @@ atom_num_digits( atom *a )
        return inlen;
 }
 
-#ifdef HAVE_HGE
-hge scales[39] = {
-       (hge) LL_CONSTANT(1),
-       (hge) LL_CONSTANT(10),
-       (hge) LL_CONSTANT(100),
-       (hge) LL_CONSTANT(1000),
-       (hge) LL_CONSTANT(10000),
-       (hge) LL_CONSTANT(100000),
-       (hge) LL_CONSTANT(1000000),
-       (hge) LL_CONSTANT(10000000),
-       (hge) LL_CONSTANT(100000000),
-       (hge) LL_CONSTANT(1000000000),
-       (hge) LL_CONSTANT(10000000000),
-       (hge) LL_CONSTANT(100000000000),
-       (hge) LL_CONSTANT(1000000000000),
-       (hge) LL_CONSTANT(10000000000000),
-       (hge) LL_CONSTANT(100000000000000),
-       (hge) LL_CONSTANT(1000000000000000),
-       (hge) LL_CONSTANT(10000000000000000),
-       (hge) LL_CONSTANT(100000000000000000),
-       (hge) LL_CONSTANT(1000000000000000000),
-       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(1),
-       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(10),
-       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(100),
-       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(1000),
-       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(10000),
-       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(100000),
-       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(1000000),
-       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(10000000),
-       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(100000000),
-       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(1000000000),
-       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(10000000000),
-       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(100000000000),
-       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(1000000000000),
-       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(10000000000000),
-       (hge) LL_CONSTANT(10000000000000000000U) * LL_CONSTANT(100000000000000),
-       (hge) LL_CONSTANT(10000000000000000000U) * 
LL_CONSTANT(1000000000000000),
-       (hge) LL_CONSTANT(10000000000000000000U) * 
LL_CONSTANT(10000000000000000),
-       (hge) LL_CONSTANT(10000000000000000000U) * 
LL_CONSTANT(100000000000000000),
-       (hge) LL_CONSTANT(10000000000000000000U) * 
LL_CONSTANT(1000000000000000000),
-       (hge) LL_CONSTANT(10000000000000000000U) * 
LL_CONSTANT(10000000000000000000U)
-};
-#else
-lng scales[19] = {
-       LL_CONSTANT(1),
-       LL_CONSTANT(10),
-       LL_CONSTANT(100),
-       LL_CONSTANT(1000),
-       LL_CONSTANT(10000),
-       LL_CONSTANT(100000),
-       LL_CONSTANT(1000000),
-       LL_CONSTANT(10000000),
-       LL_CONSTANT(100000000),
-       LL_CONSTANT(1000000000),
-       LL_CONSTANT(10000000000),
-       LL_CONSTANT(100000000000),
-       LL_CONSTANT(1000000000000),
-       LL_CONSTANT(10000000000000),
-       LL_CONSTANT(100000000000000),
-       LL_CONSTANT(1000000000000000),
-       LL_CONSTANT(10000000000000000),
-       LL_CONSTANT(100000000000000000),
-       LL_CONSTANT(1000000000000000000)
-};
-#endif
 /* cast atom a to type tp (success == 1, fail == 0) */
 int 
 atom_cast(sql_allocator *sa, atom *a, sql_subtype *tp) 
diff --git a/sql/test/pg_regress/Tests/timestamp.stable.out 
b/sql/test/pg_regress/Tests/timestamp.stable.out
--- a/sql/test/pg_regress/Tests/timestamp.stable.out
+++ b/sql/test/pg_regress/Tests/timestamp.stable.out
@@ -61,30 +61,30 @@ stdout of test 'timestamp` in directory 
 [ 1    ]
 #INSERT INTO TIMESTAMP_TBL VALUES (cast(sql_add(current_date, 24*60*60.0) as 
timestamp));
 [ 1    ]
-#SELECT count(*) AS One FROM TIMESTAMP_TBL WHERE d1 = cast(current_date as 
timestamp);
-% sys.L5 # table_name
+#SELECT count(*) AS One FROM TIMESTAMP_TBL WHERE d1 = cast(test_current_date 
as timestamp);
+% sys.L4 # table_name
 % one # name
 % bigint # type
 % 1 # length
 [ 1 ]
-#SELECT count(*) AS One FROM TIMESTAMP_TBL WHERE d1 = 
cast(sql_add(current_date, 24*60*60.0) as timestamp);
-% sys.L5 # table_name
+#SELECT count(*) AS One FROM TIMESTAMP_TBL WHERE d1 = 
cast(sql_add(test_current_date, 24*60*60.0) as timestamp);
+% sys.L4 # table_name
 % one # name
 % bigint # type
 % 1 # length
 [ 1    ]
-#SELECT count(*) AS One FROM TIMESTAMP_TBL WHERE d1 = 
cast(sql_sub(current_date, 24*60*60.0) as timestamp);
-% sys.L5 # table_name
+#SELECT count(*) AS One FROM TIMESTAMP_TBL WHERE d1 = 
cast(sql_sub(test_current_date, 24*60*60.0) as timestamp);
+% sys.L4 # table_name
 % one # name
 % bigint # type
 % 1 # length
 [ 1 ]
-#SELECT count(*) AS None FROM TIMESTAMP_TBL WHERE d1 = cast(now as timestamp);
-% sys.L5 # table_name
+#SELECT count(*) AS None FROM TIMESTAMP_TBL WHERE d1 = cast(test_now as 
timestamp);
+% sys.L4 # table_name
 % none # name
 % bigint # type
 % 1 # length
-[ 0    ]
+[ 2    ]
 #DELETE FROM TIMESTAMP_TBL;
 [ 5    ]
 #START TRANSACTION;
@@ -92,8 +92,8 @@ stdout of test 'timestamp` in directory 
 [ 1 ]
 #INSERT INTO TIMESTAMP_TBL VALUES ('now');
 [ 1 ]
-#SELECT count(*) AS two FROM TIMESTAMP_TBL WHERE d1 <= cast(now as timestamp);
-% sys.L5 # table_name
+#SELECT count(*) AS two FROM TIMESTAMP_TBL WHERE d1 <= cast(test_now as 
timestamp);
+% sys.L4 # table_name
 % two # name
 % bigint # type
 % 1 # length
@@ -116,7 +116,7 @@ stdout of test 'timestamp` in directory 
 #INSERT INTO TIMESTAMP_TBL VALUES ('1997/02/10 17:32:01-0800');
 [ 1 ]
 #SELECT '' AS "64", d1 FROM TIMESTAMP_TBL; 
-% .L2, sys.timestamp_tbl # table_name
+% .L1, sys.timestamp_tbl # table_name
 % 64,  d1 # name
 % char,        timestamp # type
 % 0,   22 # length
@@ -129,7 +129,7 @@ stdout of test 'timestamp` in directory 
 [ "",  1997-02-11 01:32:01.00  ]
 #SELECT '' AS "48", d1 FROM TIMESTAMP_TBL
 #   WHERE d1 > cast('1997-01-02' as timestamp);
-% .L3, sys.timestamp_tbl # table_name
+% .L2, sys.timestamp_tbl # table_name
 % 48,  d1 # name
 % char,        timestamp # type
 % 0,   22 # length
@@ -141,20 +141,20 @@ stdout of test 'timestamp` in directory 
 [ "",  1997-02-11 01:32:01.00  ]
 #SELECT '' AS "15", d1 FROM TIMESTAMP_TBL
 #   WHERE d1 < cast('1997-01-02' as timestamp);
-% .L3, sys.timestamp_tbl # table_name
+% .L2, sys.timestamp_tbl # table_name
 % 15,  d1 # name
 % char,        timestamp # type
 % 0,   22 # length
 #SELECT '' AS one, d1 FROM TIMESTAMP_TBL
 #   WHERE d1 = cast('1997-01-02' as timestamp);
-% .L3, sys.timestamp_tbl # table_name
+% .L2, sys.timestamp_tbl # table_name
 % one, d1 # name
 % char,        timestamp # type
 % 0,   22 # length
 [ "",  1997-01-02 00:00:00.00  ]
 #SELECT '' AS "63", d1 FROM TIMESTAMP_TBL
 #   WHERE d1 <> cast('1997-01-02' as timestamp);
-% .L3, sys.timestamp_tbl # table_name
+% .L2, sys.timestamp_tbl # table_name
 % 63,  d1 # name
 % char,        timestamp # type
 % 0,   22 # length
@@ -166,14 +166,14 @@ stdout of test 'timestamp` in directory 
 [ "",  1997-02-11 01:32:01.00  ]
 #SELECT '' AS "16", d1 FROM TIMESTAMP_TBL
 #   WHERE d1 <= cast('1997-01-02' as timestamp);
-% .L3, sys.timestamp_tbl # table_name
+% .L2, sys.timestamp_tbl # table_name
 % 16,  d1 # name
 % char,        timestamp # type
 % 0,   22 # length
 [ "",  1997-01-02 00:00:00.00  ]
 #SELECT '' AS "49", d1 FROM TIMESTAMP_TBL
 #   WHERE d1 >= cast('1997-01-02' as timestamp);
-% .L3, sys.timestamp_tbl # table_name
+% .L2, sys.timestamp_tbl # table_name
 % 49,  d1 # name
 % char,        timestamp # type
 % 0,   22 # length
@@ -186,7 +186,7 @@ stdout of test 'timestamp` in directory 
 [ "",  1997-02-11 01:32:01.00  ]
 #SELECT '' AS "54", d1 - cast('1997-01-02' as timestamp) AS diff
 #   FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
-% .L2, sys.L5 # table_name
+% .L1, sys.L3 # table_name
 % 54,  diff # name
 % char,        sec_interval # type
 % 0,   13 # length
@@ -207,7 +207,7 @@ stdout of test 'timestamp` in directory 
 #  FROM TIMESTAMP_TBL
 #  WHERE d1 BETWEEN cast('1902-01-01' as timestamp)
 #   AND cast('2038-01-01' as timestamp);
-% .L4, sys.L7 # table_name
+% .L3, sys.L5 # table_name
 % 54,  diff # name
 % char,        sec_interval # type
 % 0,   13 # length
@@ -221,8 +221,8 @@ stdout of test 'timestamp` in directory 
 #INSERT INTO TIMESTAMP_TBL VALUES (null);
 [ 1    ]
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to