Changeset: ec5692ecaf8c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ec5692ecaf8c
Modified Files:
        sql/common/sql_types.c
        sql/test/BugTracker-2012/Tests/date_script_test.Bug-2973.sql
        sql/test/BugTracker-2012/Tests/date_script_test.Bug-2973.stable.out
Branch: Dec2011
Log Message:

fixed bug in function resolution / return type magic..
(transplanted from 70dc90e1de2f5f4fa6beebf4f51521bcccbbe938)


diffs (75 lines):

diff --git a/sql/common/sql_types.c b/sql/common/sql_types.c
--- a/sql/common/sql_types.c
+++ b/sql/common/sql_types.c
@@ -769,13 +769,16 @@ sql_bind_func_(sql_allocator *sa, sql_sc
                                        sql_subfunc *fres = SA_ZNEW(sa, 
sql_subfunc);
 
                                        fres->func = f;
-                                       for (n = ops->h; n; n = n->next) {
-                                               sql_subtype *a = n->data;
+                                       if (f->fix_scale > SCALE_NONE) {
+                                               for (n = ops->h; n; n = 
n->next) {
+                                                       sql_subtype *a = 
n->data;
 
-                                               /* same scale as the input */
-                                               if (a && a->scale > scale)
-                                                       scale = a->scale;
-                                       }
+                                                       /* same scale as the 
input */
+                                                       if (a && a->scale > 
scale)
+                                                               scale = 
a->scale;
+                                               }
+                                       } else if (f->res.scale) 
+                                               scale = f->res.scale;
                                        if (IS_FUNC(f)) {
                                                sql_init_subtype(&fres->res, 
f->res.type, f->res.digits, scale);
                                                if (f->res.comp_type) 
diff --git a/sql/test/BugTracker-2012/Tests/date_script_test.Bug-2973.sql 
b/sql/test/BugTracker-2012/Tests/date_script_test.Bug-2973.sql
--- a/sql/test/BugTracker-2012/Tests/date_script_test.Bug-2973.sql
+++ b/sql/test/BugTracker-2012/Tests/date_script_test.Bug-2973.sql
@@ -1,6 +1,8 @@
 -- We need a proof that these coercions indeed work on all platforms
 
-select str_to_date('2012','%y');
+select str_to_date('12-01-01','%y-%m-%d');
+select str_to_date('2012-01-01','%Y-%m-%d');
 
-select date_to_str(now(),'%y%m');
+select date_to_str('2012-02-11','%y/%m/%d');
+select date_to_str('2012-02-11','%Y/%m/%d');
 -- and a few more
diff --git 
a/sql/test/BugTracker-2012/Tests/date_script_test.Bug-2973.stable.out 
b/sql/test/BugTracker-2012/Tests/date_script_test.Bug-2973.stable.out
--- a/sql/test/BugTracker-2012/Tests/date_script_test.Bug-2973.stable.out
+++ b/sql/test/BugTracker-2012/Tests/date_script_test.Bug-2973.stable.out
@@ -23,7 +23,30 @@ Ready.
 # 14:12:34 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=rome" 
"--port=36122"
 # 14:12:34 >  
 
-! To be checked & approved !
+#select str_to_date('12-01-01','%y-%m-%d');
+% . # table_name
+% str_to_date_single_value # name
+% date # type
+% 10 # length
+[ 2012-01-01   ]
+#select str_to_date('2012-01-01','%Y-%m-%d');
+% . # table_name
+% str_to_date_single_value # name
+% date # type
+% 10 # length
+[ 2012-01-01   ]
+#select date_to_str('2012-02-11','%y/%m/%d');
+% . # table_name
+% date_to_str_single_value # name
+% clob # type
+% 8 # length
+[ "12/02/11"   ]
+#select date_to_str('2012-02-11','%Y/%m/%d');
+% . # table_name
+% date_to_str_single_value # name
+% clob # type
+% 10 # length
+[ "2012/02/11" ]
 
 # 14:12:34 >  
 # 14:12:34 >  "Done."
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to