Changeset: ce8ea7862446 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ce8ea7862446 Modified Files: sql/backends/monet5/sql.mx sql/server/rel_select.c Branch: default Log Message:
Merge with Dec2011 branch. diffs (truncated from 521 to 300 lines): diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -1978,11 +1978,11 @@ str CALCswitchbit(Client cntxt, MalBlkPt str CALCunarybitABS(bit *res, bit *a); str CALCunarybitNEG(bit *res, bit *a); str CALCunarybitNOT(bit *retval, bit *value); -str CALCunarybitSIGN(bit *res, bit *a); +str CALCunarybitSIGN(int *res, bit *a); str CALCunarybteABS(bte *res, bte *a); str CALCunarybteNEG(bte *res, bte *a); str CALCunarybteNOT(bte *res, bte *a); -str CALCunarybteSIGN(bte *res, bte *a); +str CALCunarybteSIGN(int *res, bte *a); str CALCunarycheckbitINV(bit *res, bit *a); str CALCunarycheckbteINV(bte *res, bte *a); str CALCunarycheckchrINV(chr *res, chr *a); @@ -1995,13 +1995,13 @@ str CALCunarycheckwrdINV(wrd *res, wrd * str CALCunarychrABS(chr *res, chr *a); str CALCunarychrNEG(chr *res, chr *a); str CALCunarychrNOT(chr *res, chr *a); -str CALCunarychrSIGN(chr *res, chr *a); +str CALCunarychrSIGN(int *res, chr *a); str CALCunarydblABS(dbl *res, dbl *a); str CALCunarydblNEG(dbl *res, dbl *a); -str CALCunarydblSIGN(dbl *res, dbl *a); +str CALCunarydblSIGN(int *res, dbl *a); str CALCunaryfltABS(flt *res, flt *a); str CALCunaryfltNEG(flt *res, flt *a); -str CALCunaryfltSIGN(flt *res, flt *a); +str CALCunaryfltSIGN(int *res, flt *a); str CALCunaryintABS(int *res, int *a); str CALCunaryintNEG(int *res, int *a); str CALCunaryintNOT(int *res, int *a); @@ -2009,14 +2009,14 @@ str CALCunaryintSIGN(int *res, int *a); str CALCunarylngABS(lng *res, lng *a); str CALCunarylngNEG(lng *res, lng *a); str CALCunarylngNOT(lng *res, lng *a); -str CALCunarylngSIGN(lng *res, lng *a); +str CALCunarylngSIGN(int *res, lng *a); str CALCunaryshtABS(sht *res, sht *a); str CALCunaryshtNEG(sht *res, sht *a); str CALCunaryshtNOT(sht *res, sht *a); -str CALCunaryshtSIGN(sht *res, sht *a); +str CALCunaryshtSIGN(int *res, sht *a); str CALCunarywrdABS(wrd *res, wrd *a); str CALCunarywrdNEG(wrd *res, wrd *a); -str CALCunarywrdSIGN(wrd *res, wrd *a); +str CALCunarywrdSIGN(int *res, wrd *a); str CALCwrd2bit(bit *res, wrd *a); str CALCwrd2bte(bte *res, wrd *a); str CALCwrd2chr(chr *res, wrd *a); @@ -4077,6 +4077,7 @@ str DCYbind(int *ret, str *sch, str *tab str DCYcopy(int *ret_bat, int *ret_id, str *sch, str *tab, str *col, int *kind, int *part, int *fbun, int *lbun); str DCYpin(int *ret, int *bid); str DCYunpin(int *ret, int *bid); +int DFLOWadmission(lng argclaim, lng hotclaim); str DICTbind(int *idx, int *val, str *nme); str DICTcompress(int *idx, str *nme, int *bid); str DICTdecompress(int *ret, str *nme); diff --git a/sql/backends/monet5/sql.mx b/sql/backends/monet5/sql.mx --- a/sql/backends/monet5/sql.mx +++ b/sql/backends/monet5/sql.mx @@ -1355,7 +1355,6 @@ sql5_export str second_interval_@1( lng @:c_interval_export(wrd)@ @:c_interval_export(lng)@ @:c_interval_export(daytime)@ -sql5_export str second_interval_2_daytime( daytime *res, lng *s, int *d); @= simpleupcast_export sql5_export str @2_2_@1( @1 *res, @2 *v ); sql5_export str bat@2_2_@1( int *res, int *v ); @@ -4216,6 +4215,30 @@ str_2time_daytime( daytime *res, str *v, } str +timestamp_2_daytime( daytime *res, timestamp *v, int *digits ) +{ + int d = (*digits)?*digits-1:0; + int msec = v->msecs; + + /* correct fraction */ + if (d < 3 && msec) { + msec /= scales[3-d]; + msec *= scales[3-d]; + } + *res = msec; + return MAL_SUCCEED; +} + +str +date_2_timestamp( timestamp *res, date *v, int *digits ) +{ + (void)digits; /* no precision needed */ + res->days = *v; + res->msecs = 0; + return MAL_SUCCEED; +} + +str timestamp_2time_timestamp( timestamp *res, timestamp *v, int *digits ) { int d = (*digits)?*digits-1:0; @@ -5565,8 +5588,19 @@ comment "cast daytime to a second_interv command calc.daytime( v:lng, d:int) :daytime address second_interval_2_daytime comment "cast second_interval to a daytime and check for overflow"; + +command calc.daytime( v:timestamp, d:int) :daytime +address timestamp_2_daytime +comment "cast timestamp to a daytime and check for overflow"; + +command calc.timestamp( v:date, d:int) :timestamp +address date_2_timestamp +comment "cast date to a timestamp and check for overflow"; @h sql5_export str second_interval_daytime( lng *res, daytime *s, int *ek, int *sk ); +sql5_export str second_interval_2_daytime( daytime *res, lng *s, int *d); +sql5_export str timestamp_2_daytime( daytime *res, timestamp *v, int *d); +sql5_export str date_2_timestamp( timestamp *res, date *v, int *d); @c str second_interval_daytime( lng *res, daytime *s, int *d, int *sk ) 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 @@ -192,6 +192,8 @@ sql_find_numeric(sql_subtype *r, int loc localtype = TYPE_dbl; } else { localtype = TYPE_lng; + if (digits > 64) + digits = 64; } for (n = types->h; n; n = n->next) { diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -3231,6 +3231,9 @@ rel_unop(mvc *sql, sql_rel **rel, symbol } +#define is_addition(fname) (strcmp(fname, "sql_add") == 0) +#define is_substraction(fname) (strcmp(fname, "sql_sub") == 0) + sql_exp * rel_binop_(mvc *sql, sql_exp *l, sql_exp *r, sql_schema *s, char *fname, int card) @@ -3253,7 +3256,18 @@ rel_binop_(mvc *sql, sql_exp *l, sql_exp } if (!t1 || !t2) return sql_error(sql, 01, "Cannot have a parameter (?) on both sides of an expression"); - + + if ((is_addition(fname) || is_substraction(fname)) && t1->type->eclass == EC_NUM && t2->type->eclass == EC_NUM) { + sql_subtype ntp; + + sql_find_numeric(&ntp, t1->type->localtype, t1->digits+1); + l = rel_check_type(sql, &ntp, l, type_equal); + sql_find_numeric(&ntp, t2->type->localtype, t2->digits+1); + r = rel_check_type(sql, &ntp, r, type_equal); + t1 = exp_subtype(l); + t2 = exp_subtype(r); + } + f = sql_bind_func(sql->sa, s, fname, t1, t2, type); if (!f && is_commutative(fname)) { f = sql_bind_func(sql->sa, s, fname, t2, t1, type); diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y --- a/sql/server/sql_parser.y +++ b/sql/server/sql_parser.y @@ -4182,6 +4182,7 @@ interval_expression: YYABORT; } else { /* count the number of digits in the input */ +/* lng cpyval = i, inlen = 1; cpyval /= qualifier2multiplier(ek); @@ -4193,6 +4194,7 @@ interval_expression: $$ = NULL; YYABORT; } +*/ $$ = _newAtomNode( atom_int(SA, &t, i)); } } diff --git a/sql/test/ADT2006/Tests/woud.stable.out b/sql/test/ADT2006/Tests/woud.stable.out --- a/sql/test/ADT2006/Tests/woud.stable.out +++ b/sql/test/ADT2006/Tests/woud.stable.out @@ -62,7 +62,7 @@ Ready. % 0, 0 # length % sys. # table_name % substring_murderdate # name -% int # type +% bigint # type % 1 # length % . # table_name % L5 # name diff --git a/sql/test/BugDay_2005-10-06_2.9.3/Tests/CrashMe_SQL_server_crash-2.SF-921673.stable.out b/sql/test/BugDay_2005-10-06_2.9.3/Tests/CrashMe_SQL_server_crash-2.SF-921673.stable.out --- a/sql/test/BugDay_2005-10-06_2.9.3/Tests/CrashMe_SQL_server_crash-2.SF-921673.stable.out +++ b/sql/test/BugDay_2005-10-06_2.9.3/Tests/CrashMe_SQL_server_crash-2.SF-921673.stable.out @@ -45,7 +45,7 @@ Ready. # null AS SCOPE_TABLE % ., .schemas, .tables, .columns, .columns, .columns, .columns, ., ., ., ., .columns, ., ., ., ., ., ., . # table_name % table_cat, table_schem, table_name, column_name, type_name, column_size, decimal_digits, buffer_length, num_prec_radix, nullable, remarks, column_def, sql_data_type, sql_datetime_sub, char_octet_length, ordinal_position, scope_catalog, scope_schema, scope_table # name -% char, varchar, varchar, varchar, varchar, int, int, tinyint, tinyint, char, char, varchar, tinyint, tinyint, tinyint, int, char, char, char # type +% char, varchar, varchar, varchar, varchar, int, int, tinyint, tinyint, char, char, varchar, tinyint, tinyint, tinyint, bigint, char, char, char # type % 0, 3, 9, 12, 7, 4, 1, 1, 2, 0, 0, 0, 1, 1, 1, 2, 0, 0, 0 # length [ NULL, "sys", "args", "id", "int", 32, 0, 0, 10, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, NULL ] [ NULL, "sys", "args", "func_id", "int", 32, 0, 0, 10, NULL, NULL, NULL, 0, 0, 0, 2, NULL, NULL, NULL ] diff --git a/sql/test/BugDay_2005-10-06_2.9.3/Tests/custom_function_in_where.SF-937859.stable.out b/sql/test/BugDay_2005-10-06_2.9.3/Tests/custom_function_in_where.SF-937859.stable.out --- a/sql/test/BugDay_2005-10-06_2.9.3/Tests/custom_function_in_where.SF-937859.stable.out +++ b/sql/test/BugDay_2005-10-06_2.9.3/Tests/custom_function_in_where.SF-937859.stable.out @@ -21,7 +21,7 @@ Ready. [ 4 ] % sys. # table_name % sql_sub_char_length_s # name -% int # type +% bigint # type % 1 # length [ 0 ] [ 0 ] diff --git a/sql/test/BugDay_2005-10-06_2.9.3/Tests/huge_expression_and_column_name.SF-921173.stable.out b/sql/test/BugDay_2005-10-06_2.9.3/Tests/huge_expression_and_column_name.SF-921173.stable.out --- a/sql/test/BugDay_2005-10-06_2.9.3/Tests/huge_expression_and_column_name.SF-921173.stable.out +++ b/sql/test/BugDay_2005-10-06_2.9.3/Tests/huge_expression_and_column_name.SF-921173.stable.out @@ -28,7 +28,7 @@ Ready. #select 1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1 % . # table_name % sql_add_single_value # name -% int # type +% bigint # type % 4 # length [ 2001 ] diff --git a/sql/test/BugTracker-2008/Tests/auto_coersion_bug.SF-2075157.stable.out b/sql/test/BugTracker-2008/Tests/auto_coersion_bug.SF-2075157.stable.out --- a/sql/test/BugTracker-2008/Tests/auto_coersion_bug.SF-2075157.stable.out +++ b/sql/test/BugTracker-2008/Tests/auto_coersion_bug.SF-2075157.stable.out @@ -38,7 +38,7 @@ Ready. [ 1 ] % sys. # table_name % sql_add_sql_neg_col2 # name -% int # type +% bigint # type % 4 # length [ 3000 ] diff --git a/sql/test/BugTracker-2009/Tests/Division_by_zero_error.SF-2791361.stable.out b/sql/test/BugTracker-2009/Tests/Division_by_zero_error.SF-2791361.stable.out --- a/sql/test/BugTracker-2009/Tests/Division_by_zero_error.SF-2791361.stable.out +++ b/sql/test/BugTracker-2009/Tests/Division_by_zero_error.SF-2791361.stable.out @@ -50,7 +50,7 @@ Ready. #select case when (2 - 2) > 0 then (3 - 2)/(2 - 2) else 0 end as "test"; % . # table_name % test # name -% tinyint # type +% smallint # type % 1 # length [ 0 ] diff --git a/sql/test/BugTracker-2009/Tests/Floating_point_exception.SF-2791356.stable.out b/sql/test/BugTracker-2009/Tests/Floating_point_exception.SF-2791356.stable.out --- a/sql/test/BugTracker-2009/Tests/Floating_point_exception.SF-2791356.stable.out +++ b/sql/test/BugTracker-2009/Tests/Floating_point_exception.SF-2791356.stable.out @@ -27,7 +27,7 @@ Ready. [ 1 ] % sys. # table_name % isnull_>_sql_sub_bla1 # name -% int # type +% bigint # type % 1 # length [ 0 ] diff --git a/sql/test/BugTracker-2009/Tests/count_bug.SF-2604583.stable.out b/sql/test/BugTracker-2009/Tests/count_bug.SF-2604583.stable.out --- a/sql/test/BugTracker-2009/Tests/count_bug.SF-2604583.stable.out +++ b/sql/test/BugTracker-2009/Tests/count_bug.SF-2604583.stable.out @@ -36,7 +36,7 @@ Ready. [ 7, 5 ] % . # table_name % L14 # name -% wrd # type +% bigint # type % 1 # length [ 2 ] [ 3 ] diff --git a/sql/test/BugTracker-2009/Tests/push_select_down_crash.stable.out b/sql/test/BugTracker-2009/Tests/push_select_down_crash.stable.out --- a/sql/test/BugTracker-2009/Tests/push_select_down_crash.stable.out +++ b/sql/test/BugTracker-2009/Tests/push_select_down_crash.stable.out @@ -46,7 +46,7 @@ Ready. # WHEN 'blob' THEN 2 % ., .schemas, .tables, .columns, ., .columns, .columns, .columns, ., ., ., ., .columns, ., ., ., ., ., ., ., ., . # table_name % TABLE_CAT, TABLE_SCHEM, TABLE_NAME, COLUMN_NAME, DATA_TYPE, TYPE_NAME, COLUMN_SIZE, DECIMAL_DIGITS, BUFFER_LENGTH, NUM_PREC_RADIX, NULLABLE, REMARKS, COLUMN_DEF, SQL_DATA_TYPE, SQL_DATETIME_SUB, CHAR_OCTET_LENGTH, ORDINAL_POSITION, SCOPE_CATALOG, SCOPE_SCHEMA, SCOPE_TABLE, SOURCE_DATA_TYPE, IS_NULLABLE # name -% char, varchar, varchar, varchar, smallint, varchar, int, int, tinyint, tinyint, int, varchar, varchar, tinyint, tinyint, tinyint, int, varchar, varchar, varchar, smallint, varchar # type +% char, varchar, varchar, varchar, smallint, varchar, int, int, tinyint, tinyint, int, varchar, varchar, tinyint, tinyint, tinyint, bigint, varchar, varchar, varchar, smallint, varchar # type % 4, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0 # length # 18:36:16 > diff --git a/sql/test/BugTracker-2011/Tests/CASE_division_exception.Bug-2822.sql b/sql/test/BugTracker-2011/Tests/CASE_division_exception.Bug-2822.sql --- a/sql/test/BugTracker-2011/Tests/CASE_division_exception.Bug-2822.sql +++ b/sql/test/BugTracker-2011/Tests/CASE_division_exception.Bug-2822.sql @@ -1,4 +1,4 @@ CREATE TABLE bug_2822 (c INT); INSERT INTO bug_2822 VALUES (0); _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list