Changeset: 22b1b9a8b597 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=22b1b9a8b597
Modified Files:
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql.h
        sql/backends/monet5/sql_round.c
        sql/backends/monet5/sql_round_impl.h
        sql/backends/monet5/sql_statement.c
Branch: clean-candidates
Log Message:

Adding candidate list support to round functions. Floating-point versions still 
missing, so some tests may fail


diffs (truncated from 1037 to 300 lines):

diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -5619,27 +5619,67 @@ static mel_func sql_init_funcs[] = {
  pattern("sql", "copy_rejects", COPYrejects, false, "", args(4,4, 
batarg("rowid",lng),batarg("fldid",int),batarg("msg",str),batarg("inp",str))),
  pattern("sql", "copy_rejects_clear", COPYrejects_clear, true, "", noargs),
  command("sql", "dec_round", bte_dec_round_wrap, false, "round off the value v 
to nearests multiple of r", args(1,3, arg("",bte),arg("v",bte),arg("r",bte))),
- command("batsql", "dec_round", bte_bat_dec_round_wrap, false, "round off the 
value v to nearests multiple of r", args(1,3, 
batarg("",bte),batarg("v",bte),arg("r",bte))),
- command("sql", "round", bte_round_wrap, false, "round off the decimal v(d,s) 
to r digits behind the dot (if r < 0, before the dot)", args(1,5, 
arg("",bte),arg("v",bte),arg("d",int),arg("s",int),arg("r",bte))),
- command("batsql", "round", bte_bat_round_wrap, false, "round off the decimal 
v(d,s) to r digits behind the dot (if r < 0, before the dot)", args(1,5, 
batarg("",bte),batarg("v",bte),arg("d",int),arg("s",int),arg("r",bte))),
+ pattern("batsql", "dec_round", bte_bat_dec_round_wrap, false, "round off the 
value v to nearests multiple of r", args(1,3, 
batarg("",bte),batarg("v",bte),arg("r",bte))),
+ pattern("batsql", "dec_round", bte_bat_dec_round_wrap, false, "round off the 
value v to nearests multiple of r", args(1,4, 
batarg("",bte),batarg("v",bte),arg("r",bte),batarg("s",oid))),
+ pattern("batsql", "dec_round", bte_bat_dec_round_wrap_cst, false, "round off 
the value v to nearests multiple of r", args(1,3, 
batarg("",bte),arg("v",bte),batarg("r",bte))),
+ pattern("batsql", "dec_round", bte_bat_dec_round_wrap_cst, false, "round off 
the value v to nearests multiple of r", args(1,4, 
batarg("",bte),arg("v",bte),batarg("r",bte),batarg("s",oid))),
+ pattern("batsql", "dec_round", bte_bat_dec_round_wrap_nocst, false, "round 
off the value v to nearests multiple of r", args(1,3, 
batarg("",bte),batarg("v",bte),batarg("r",bte))),
+ pattern("batsql", "dec_round", bte_bat_dec_round_wrap_nocst, false, "round 
off the value v to nearests multiple of r", args(1,5, 
batarg("",bte),batarg("v",bte),batarg("r",bte),batarg("s1",oid),batarg("s2",oid))),
+ command("sql", "round", bte_round_wrap, false, "round off the decimal v(d,s) 
to r digits behind the dot (if r < 0, before the dot)", args(1,5, 
arg("",bte),arg("v",bte),arg("r",bte),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", bte_bat_round_wrap, false, "round off the decimal 
v(d,s) to r digits behind the dot (if r < 0, before the dot)", args(1,5, 
batarg("",bte),batarg("v",bte),arg("r",bte),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", bte_bat_round_wrap, false, "round off the decimal 
v(d,s) to r digits behind the dot (if r < 0, before the dot)", args(1,6, 
batarg("",bte),batarg("v",bte),arg("r",bte),batarg("s",oid),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", bte_bat_round_wrap_cst, false, "round off the 
decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)", 
args(1,5, 
batarg("",bte),arg("v",bte),batarg("r",bte),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", bte_bat_round_wrap_cst, false, "round off the 
decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)", 
args(1,6, 
batarg("",bte),arg("v",bte),batarg("r",bte),batarg("s",oid),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", bte_bat_round_wrap_nocst, false, "round off the 
decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)", 
args(1,5, 
batarg("",bte),batarg("v",bte),batarg("r",bte),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", bte_bat_round_wrap_nocst, false, "round off the 
decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)", 
args(1,7, 
batarg("",bte),batarg("v",bte),batarg("r",bte),batarg("s1",oid),batarg("s2",oid),arg("d",int),arg("s",int))),
  command("calc", "second_interval", bte_dec2second_interval, false, "cast bte 
decimal to a second_interval", args(1,5, 
arg("",lng),arg("sc",int),arg("v",bte),arg("ek",int),arg("sk",int))),
  pattern("batcalc", "second_interval", bte_batdec2second_interval, false, 
"cast bte decimal to a second_interval", args(1,6, 
batarg("",lng),arg("sc",int),batarg("v",bte),batarg("s",oid),arg("ek",int),arg("sk",int))),
  command("sql", "dec_round", sht_dec_round_wrap, false, "round off the value v 
to nearests multiple of r", args(1,3, arg("",sht),arg("v",sht),arg("r",sht))),
- command("batsql", "dec_round", sht_bat_dec_round_wrap, false, "round off the 
value v to nearests multiple of r", args(1,3, 
batarg("",sht),batarg("v",sht),arg("r",sht))),
- command("sql", "round", sht_round_wrap, false, "round off the decimal v(d,s) 
to r digits behind the dot (if r < 0, before the dot)", args(1,5, 
arg("",sht),arg("v",sht),arg("d",int),arg("s",int),arg("r",bte))),
- command("batsql", "round", sht_bat_round_wrap, false, "round off the decimal 
v(d,s) to r digits behind the dot (if r < 0, before the dot)", args(1,5, 
batarg("",sht),batarg("v",sht),arg("d",int),arg("s",int),arg("r",bte))),
+ pattern("batsql", "dec_round", sht_bat_dec_round_wrap, false, "round off the 
value v to nearests multiple of r", args(1,3, 
batarg("",sht),batarg("v",sht),arg("r",sht))),
+ pattern("batsql", "dec_round", sht_bat_dec_round_wrap, false, "round off the 
value v to nearests multiple of r", args(1,4, 
batarg("",sht),batarg("v",sht),arg("r",sht),batarg("s",oid))),
+ pattern("batsql", "dec_round", sht_bat_dec_round_wrap_cst, false, "round off 
the value v to nearests multiple of r", args(1,3, 
batarg("",sht),arg("v",sht),batarg("r",sht))),
+ pattern("batsql", "dec_round", sht_bat_dec_round_wrap_cst, false, "round off 
the value v to nearests multiple of r", args(1,4, 
batarg("",sht),arg("v",sht),batarg("r",sht),batarg("s",oid))),
+ pattern("batsql", "dec_round", sht_bat_dec_round_wrap_nocst, false, "round 
off the value v to nearests multiple of r", args(1,3, 
batarg("",sht),batarg("v",sht),batarg("r",sht))),
+ pattern("batsql", "dec_round", sht_bat_dec_round_wrap_nocst, false, "round 
off the value v to nearests multiple of r", args(1,5, 
batarg("",sht),batarg("v",sht),batarg("r",sht),batarg("s1",oid),batarg("s2",oid))),
+ command("sql", "round", sht_round_wrap, false, "round off the decimal v(d,s) 
to r digits behind the dot (if r < 0, before the dot)", args(1,5, 
arg("",sht),arg("v",sht),arg("r",bte),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", sht_bat_round_wrap, false, "round off the decimal 
v(d,s) to r digits behind the dot (if r < 0, before the dot)", args(1,5, 
batarg("",sht),batarg("v",sht),arg("r",bte),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", sht_bat_round_wrap, false, "round off the decimal 
v(d,s) to r digits behind the dot (if r < 0, before the dot)", args(1,6, 
batarg("",sht),batarg("v",sht),arg("r",bte),batarg("s",oid),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", sht_bat_round_wrap_cst, false, "round off the 
decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)", 
args(1,5, 
batarg("",sht),arg("v",sht),batarg("r",bte),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", sht_bat_round_wrap_cst, false, "round off the 
decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)", 
args(1,6, 
batarg("",sht),arg("v",sht),batarg("r",bte),batarg("s",oid),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", sht_bat_round_wrap_nocst, false, "round off the 
decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)", 
args(1,5, 
batarg("",sht),batarg("v",sht),batarg("r",bte),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", sht_bat_round_wrap_nocst, false, "round off the 
decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)", 
args(1,7, 
batarg("",sht),batarg("v",sht),batarg("r",bte),batarg("s1",oid),batarg("s2",oid),arg("d",int),arg("s",int))),
  command("calc", "second_interval", sht_dec2second_interval, false, "cast sht 
decimal to a second_interval", args(1,5, 
arg("",lng),arg("sc",int),arg("v",sht),arg("ek",int),arg("sk",int))),
  pattern("batcalc", "second_interval", sht_batdec2second_interval, false, 
"cast sht decimal to a second_interval", args(1,6, 
batarg("",lng),arg("sc",int),batarg("v",sht),batarg("s",oid),arg("ek",int),arg("sk",int))),
  command("sql", "dec_round", int_dec_round_wrap, false, "round off the value v 
to nearests multiple of r", args(1,3, arg("",int),arg("v",int),arg("r",int))),
- command("batsql", "dec_round", int_bat_dec_round_wrap, false, "round off the 
value v to nearests multiple of r", args(1,3, 
batarg("",int),batarg("v",int),arg("r",int))),
- command("sql", "round", int_round_wrap, false, "round off the decimal v(d,s) 
to r digits behind the dot (if r < 0, before the dot)", args(1,5, 
arg("",int),arg("v",int),arg("d",int),arg("s",int),arg("r",bte))),
- command("batsql", "round", int_bat_round_wrap, false, "round off the decimal 
v(d,s) to r digits behind the dot (if r < 0, before the dot)", args(1,5, 
batarg("",int),batarg("v",int),arg("d",int),arg("s",int),arg("r",bte))),
+ pattern("batsql", "dec_round", int_bat_dec_round_wrap, false, "round off the 
value v to nearests multiple of r", args(1,3, 
batarg("",int),batarg("v",int),arg("r",int))),
+ pattern("batsql", "dec_round", int_bat_dec_round_wrap, false, "round off the 
value v to nearests multiple of r", args(1,4, 
batarg("",int),batarg("v",int),arg("r",int),batarg("s",oid))),
+ pattern("batsql", "dec_round", int_bat_dec_round_wrap_cst, false, "round off 
the value v to nearests multiple of r", args(1,3, 
batarg("",int),arg("v",int),batarg("r",int))),
+ pattern("batsql", "dec_round", int_bat_dec_round_wrap_cst, false, "round off 
the value v to nearests multiple of r", args(1,4, 
batarg("",int),arg("v",int),batarg("r",int),batarg("s",oid))),
+ pattern("batsql", "dec_round", int_bat_dec_round_wrap_nocst, false, "round 
off the value v to nearests multiple of r", args(1,3, 
batarg("",int),batarg("v",int),batarg("r",int))),
+ pattern("batsql", "dec_round", int_bat_dec_round_wrap_nocst, false, "round 
off the value v to nearests multiple of r", args(1,5, 
batarg("",int),batarg("v",int),batarg("r",int),batarg("s1",oid),batarg("s2",oid))),
+ command("sql", "round", int_round_wrap, false, "round off the decimal v(d,s) 
to r digits behind the dot (if r < 0, before the dot)", args(1,5, 
arg("",int),arg("v",int),arg("r",bte),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", int_bat_round_wrap, false, "round off the decimal 
v(d,s) to r digits behind the dot (if r < 0, before the dot)", args(1,5, 
batarg("",int),batarg("v",int),arg("r",bte),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", int_bat_round_wrap, false, "round off the decimal 
v(d,s) to r digits behind the dot (if r < 0, before the dot)", args(1,6, 
batarg("",int),batarg("v",int),arg("r",bte),batarg("s",oid),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", int_bat_round_wrap_cst, false, "round off the 
decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)", 
args(1,5, 
batarg("",int),arg("v",int),batarg("r",bte),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", int_bat_round_wrap_cst, false, "round off the 
decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)", 
args(1,6, 
batarg("",int),arg("v",int),batarg("r",bte),batarg("s",oid),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", int_bat_round_wrap_nocst, false, "round off the 
decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)", 
args(1,5, 
batarg("",int),batarg("v",int),batarg("r",bte),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", int_bat_round_wrap_nocst, false, "round off the 
decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)", 
args(1,7, 
batarg("",int),batarg("v",int),batarg("r",bte),batarg("s1",oid),batarg("s2",oid),arg("d",int),arg("s",int))),
  command("calc", "second_interval", int_dec2second_interval, false, "cast int 
decimal to a second_interval", args(1,5, 
arg("",lng),arg("sc",int),arg("v",int),arg("ek",int),arg("sk",int))),
  pattern("batcalc", "second_interval", int_batdec2second_interval, false, 
"cast int decimal to a second_interval", args(1,6, 
batarg("",lng),arg("sc",int),batarg("v",int),batarg("s",oid),arg("ek",int),arg("sk",int))),
  command("sql", "dec_round", lng_dec_round_wrap, false, "round off the value v 
to nearests multiple of r", args(1,3, arg("",lng),arg("v",lng),arg("r",lng))),
- command("batsql", "dec_round", lng_bat_dec_round_wrap, false, "round off the 
value v to nearests multiple of r", args(1,3, 
batarg("",lng),batarg("v",lng),arg("r",lng))),
- command("sql", "round", lng_round_wrap, false, "round off the decimal v(d,s) 
to r digits behind the dot (if r < 0, before the dot)", args(1,5, 
arg("",lng),arg("v",lng),arg("d",int),arg("s",int),arg("r",bte))),
- command("batsql", "round", lng_bat_round_wrap, false, "round off the decimal 
v(d,s) to r digits behind the dot (if r < 0, before the dot)", args(1,5, 
batarg("",lng),batarg("v",lng),arg("d",int),arg("s",int),arg("r",bte))),
+ pattern("batsql", "dec_round", lng_bat_dec_round_wrap, false, "round off the 
value v to nearests multiple of r", args(1,3, 
batarg("",lng),batarg("v",lng),arg("r",lng))),
+ pattern("batsql", "dec_round", lng_bat_dec_round_wrap, false, "round off the 
value v to nearests multiple of r", args(1,4, 
batarg("",lng),batarg("v",lng),arg("r",lng),batarg("s",oid))),
+ pattern("batsql", "dec_round", lng_bat_dec_round_wrap_cst, false, "round off 
the value v to nearests multiple of r", args(1,3, 
batarg("",lng),arg("v",lng),batarg("r",lng))),
+ pattern("batsql", "dec_round", lng_bat_dec_round_wrap_cst, false, "round off 
the value v to nearests multiple of r", args(1,4, 
batarg("",lng),arg("v",lng),batarg("r",lng),batarg("s",oid))),
+ pattern("batsql", "dec_round", lng_bat_dec_round_wrap_nocst, false, "round 
off the value v to nearests multiple of r", args(1,3, 
batarg("",lng),batarg("v",lng),batarg("r",lng))),
+ pattern("batsql", "dec_round", lng_bat_dec_round_wrap_nocst, false, "round 
off the value v to nearests multiple of r", args(1,5, 
batarg("",lng),batarg("v",lng),batarg("r",lng),batarg("s1",oid),batarg("s2",oid))),
+ command("sql", "round", lng_round_wrap, false, "round off the decimal v(d,s) 
to r digits behind the dot (if r < 0, before the dot)", args(1,5, 
arg("",lng),arg("v",lng),arg("r",bte),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", lng_bat_round_wrap, false, "round off the decimal 
v(d,s) to r digits behind the dot (if r < 0, before the dot)", args(1,5, 
batarg("",lng),batarg("v",lng),arg("r",bte),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", lng_bat_round_wrap, false, "round off the decimal 
v(d,s) to r digits behind the dot (if r < 0, before the dot)", args(1,6, 
batarg("",lng),batarg("v",lng),arg("r",bte),batarg("s",oid),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", lng_bat_round_wrap_cst, false, "round off the 
decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)", 
args(1,5, 
batarg("",lng),arg("v",lng),batarg("r",bte),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", lng_bat_round_wrap_cst, false, "round off the 
decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)", 
args(1,6, 
batarg("",lng),arg("v",lng),batarg("r",bte),batarg("s",oid),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", lng_bat_round_wrap_nocst, false, "round off the 
decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)", 
args(1,5, 
batarg("",lng),batarg("v",lng),batarg("r",bte),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", lng_bat_round_wrap_nocst, false, "round off the 
decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)", 
args(1,7, 
batarg("",lng),batarg("v",lng),batarg("r",bte),batarg("s1",oid),batarg("s2",oid),arg("d",int),arg("s",int))),
  command("calc", "second_interval", lng_dec2second_interval, false, "cast lng 
decimal to a second_interval", args(1,5, 
arg("",lng),arg("sc",int),arg("v",lng),arg("ek",int),arg("sk",int))),
  pattern("batcalc", "second_interval", lng_batdec2second_interval, false, 
"cast lng decimal to a second_interval", args(1,6, 
batarg("",lng),arg("sc",int),batarg("v",lng),batarg("s",oid),arg("ek",int),arg("sk",int))),
  command("sql", "dec_round", flt_dec_round_wrap, false, "round off the value v 
to nearests multiple of r", args(1,3, arg("",flt),arg("v",flt),arg("r",flt))),
@@ -6369,9 +6409,19 @@ static mel_func sql_init_funcs[] = {
 #ifdef HAVE_HGE
  /* sql_hge */
  command("sql", "dec_round", hge_dec_round_wrap, false, "round off the value v 
to nearests multiple of r", args(1,3, arg("",hge),arg("v",hge),arg("r",hge))),
- command("batsql", "dec_round", hge_bat_dec_round_wrap, false, "round off the 
value v to nearests multiple of r", args(1,3, 
batarg("",hge),batarg("v",hge),arg("r",hge))),
- command("sql", "round", hge_round_wrap, false, "round off the decimal v(d,s) 
to r digits behind the dot (if r < 0, before the dot)", args(1,5, 
arg("",hge),arg("v",hge),arg("d",int),arg("s",int),arg("r",bte))),
- command("batsql", "round", hge_bat_round_wrap, false, "round off the decimal 
v(d,s) to r digits behind the dot (if r < 0, before the dot)", args(1,5, 
batarg("",hge),batarg("v",hge),arg("d",int),arg("s",int),arg("r",bte))),
+ pattern("batsql", "dec_round", hge_bat_dec_round_wrap, false, "round off the 
value v to nearests multiple of r", args(1,3, 
batarg("",hge),batarg("v",hge),arg("r",hge))),
+ pattern("batsql", "dec_round", hge_bat_dec_round_wrap, false, "round off the 
value v to nearests multiple of r", args(1,4, 
batarg("",hge),batarg("v",hge),arg("r",hge),batarg("s",oid))),
+ pattern("batsql", "dec_round", hge_bat_dec_round_wrap_cst, false, "round off 
the value v to nearests multiple of r", args(1,3, 
batarg("",hge),arg("v",hge),batarg("r",hge))),
+ pattern("batsql", "dec_round", hge_bat_dec_round_wrap_cst, false, "round off 
the value v to nearests multiple of r", args(1,4, 
batarg("",hge),arg("v",hge),batarg("r",hge),batarg("s",oid))),
+ pattern("batsql", "dec_round", hge_bat_dec_round_wrap_nocst, false, "round 
off the value v to nearests multiple of r", args(1,3, 
batarg("",hge),batarg("v",hge),batarg("r",hge))),
+ pattern("batsql", "dec_round", hge_bat_dec_round_wrap_nocst, false, "round 
off the value v to nearests multiple of r", args(1,5, 
batarg("",hge),batarg("v",hge),batarg("r",hge),batarg("s1",oid),batarg("s2",oid))),
+ command("sql", "round", hge_round_wrap, false, "round off the decimal v(d,s) 
to r digits behind the dot (if r < 0, before the dot)", args(1,5, 
arg("",hge),arg("v",hge),arg("r",bte),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", hge_bat_round_wrap, false, "round off the decimal 
v(d,s) to r digits behind the dot (if r < 0, before the dot)", args(1,5, 
batarg("",hge),batarg("v",hge),arg("r",bte),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", hge_bat_round_wrap, false, "round off the decimal 
v(d,s) to r digits behind the dot (if r < 0, before the dot)", args(1,6, 
batarg("",hge),batarg("v",hge),arg("r",bte),batarg("s",oid),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", hge_bat_round_wrap_cst, false, "round off the 
decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)", 
args(1,5, 
batarg("",hge),arg("v",hge),batarg("r",bte),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", hge_bat_round_wrap_cst, false, "round off the 
decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)", 
args(1,6, 
batarg("",hge),arg("v",hge),batarg("r",bte),batarg("s",oid),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", hge_bat_round_wrap_nocst, false, "round off the 
decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)", 
args(1,5, 
batarg("",hge),batarg("v",hge),batarg("r",bte),arg("d",int),arg("s",int))),
+ pattern("batsql", "round", hge_bat_round_wrap_nocst, false, "round off the 
decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)", 
args(1,7, 
batarg("",hge),batarg("v",hge),batarg("r",bte),batarg("s1",oid),batarg("s2",oid),arg("d",int),arg("s",int))),
  command("calc", "second_interval", hge_dec2second_interval, false, "cast hge 
decimal to a second_interval", args(1,5, 
arg("",lng),arg("sc",int),arg("v",hge),arg("ek",int),arg("sk",int))),
  pattern("batcalc", "second_interval", hge_batdec2second_interval, false, 
"cast hge decimal to a second_interval", args(1,6, 
batarg("",lng),arg("sc",int),batarg("v",hge),batarg("s",oid),arg("ek",int),arg("sk",int))),
  command("calc", "hge", nil_2dec_hge, false, "cast to dec(hge) and check for 
overflow", args(1,4, 
arg("",hge),arg("v",void),arg("digits",int),arg("scale",int))),
diff --git a/sql/backends/monet5/sql.h b/sql/backends/monet5/sql.h
--- a/sql/backends/monet5/sql.h
+++ b/sql/backends/monet5/sql.h
@@ -140,9 +140,15 @@ sql5_export str create_table_from_emit(C
 sql5_export str append_to_table_from_emit(Client cntxt, char *sname, char 
*tname, sql_emit_col *columns, size_t ncols);
 
 sql5_export str bte_dec_round_wrap(bte *res, const bte *v, const bte *r);
-sql5_export str bte_bat_dec_round_wrap(bat *res, const bat *v, const bte *r);
-sql5_export str bte_round_wrap(bte *res, const bte *v, const int *d, const int 
*s, const bte *r);
-sql5_export str bte_bat_round_wrap(bat *res, const bat *v, const int *d, const 
int *s, const bte *r);
+sql5_export str bte_bat_dec_round_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr 
stk, InstrPtr pci);
+sql5_export str bte_bat_dec_round_wrap_cst(Client cntxt, MalBlkPtr mb, 
MalStkPtr stk, InstrPtr pci);
+sql5_export str bte_bat_dec_round_wrap_nocst(Client cntxt, MalBlkPtr mb, 
MalStkPtr stk, InstrPtr pci);
+sql5_export str bte_round_wrap(bte *res, const bte *v, const bte *r, const int 
*d, const int *s);
+sql5_export str bte_bat_round_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+sql5_export str bte_bat_round_wrap_cst(Client cntxt, MalBlkPtr mb, MalStkPtr 
stk, InstrPtr pci);
+sql5_export str bte_bat_round_wrap_nocst(Client cntxt, MalBlkPtr mb, MalStkPtr 
stk, InstrPtr pci);
+
+
 sql5_export str str_2dec_bte(bte *res, const str *val, const int *d, const int 
*sc);
 sql5_export str batstr_2dec_bte(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 sql5_export str bte_dec2second_interval(lng *res, const int *sc, const bte 
*dec, const int *ek, const int *sk);
@@ -152,9 +158,13 @@ sql5_export str nil_2dec_bte(bte *res, c
 sql5_export str batnil_2dec_bte(bat *res, const bat *val, const int *d, const 
int *sc);
 
 sql5_export str sht_dec_round_wrap(sht *res, const sht *v, const sht *r);
-sql5_export str sht_bat_dec_round_wrap(bat *res, const bat *v, const sht *r);
-sql5_export str sht_round_wrap(sht *res, const sht *v, const int *d, const int 
*s, const bte *r);
-sql5_export str sht_bat_round_wrap(bat *res, const bat *v, const int *d, const 
int *s, const bte *r);
+sql5_export str sht_bat_dec_round_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr 
stk, InstrPtr pci);
+sql5_export str sht_bat_dec_round_wrap_cst(Client cntxt, MalBlkPtr mb, 
MalStkPtr stk, InstrPtr pci);
+sql5_export str sht_bat_dec_round_wrap_nocst(Client cntxt, MalBlkPtr mb, 
MalStkPtr stk, InstrPtr pci);
+sql5_export str sht_round_wrap(sht *res, const sht *v, const bte *r, const int 
*d, const int *s);
+sql5_export str sht_bat_round_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+sql5_export str sht_bat_round_wrap_cst(Client cntxt, MalBlkPtr mb, MalStkPtr 
stk, InstrPtr pci);
+sql5_export str sht_bat_round_wrap_nocst(Client cntxt, MalBlkPtr mb, MalStkPtr 
stk, InstrPtr pci);
 sql5_export str str_2dec_sht(sht *res, const str *val, const int *d, const int 
*sc);
 sql5_export str batstr_2dec_sht(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 sql5_export str sht_dec2second_interval(lng *res, const int *sc, const sht 
*dec, const int *ek, const int *sk);
@@ -164,9 +174,13 @@ sql5_export str nil_2dec_sht(sht *res, c
 sql5_export str batnil_2dec_sht(bat *res, const bat *val, const int *d, const 
int *sc);
 
 sql5_export str int_dec_round_wrap(int *res, const int *v, const int *r);
-sql5_export str int_bat_dec_round_wrap(bat *res, const bat *v, const int *r);
-sql5_export str int_round_wrap(int *res, const int *v, const int *d, const int 
*s, const bte *r);
-sql5_export str int_bat_round_wrap(bat *res, const bat *v, const int *d, const 
int *s, const bte *r);
+sql5_export str int_bat_dec_round_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr 
stk, InstrPtr pci);
+sql5_export str int_bat_dec_round_wrap_cst(Client cntxt, MalBlkPtr mb, 
MalStkPtr stk, InstrPtr pci);
+sql5_export str int_bat_dec_round_wrap_nocst(Client cntxt, MalBlkPtr mb, 
MalStkPtr stk, InstrPtr pci);
+sql5_export str int_round_wrap(int *res, const int *v, const bte *r, const int 
*d, const int *s);
+sql5_export str int_bat_round_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+sql5_export str int_bat_round_wrap_cst(Client cntxt, MalBlkPtr mb, MalStkPtr 
stk, InstrPtr pci);
+sql5_export str int_bat_round_wrap_nocst(Client cntxt, MalBlkPtr mb, MalStkPtr 
stk, InstrPtr pci);
 sql5_export str str_2dec_int(int *res, const str *val, const int *d, const int 
*sc);
 sql5_export str batstr_2dec_int(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 sql5_export str int_dec2second_interval(lng *res, const int *sc, const int 
*dec, const int *ek, const int *sk);
@@ -176,9 +190,13 @@ sql5_export str nil_2dec_int(int *res, c
 sql5_export str batnil_2dec_int(bat *res, const bat *val, const int *d, const 
int *sc);
 
 sql5_export str lng_dec_round_wrap(lng *res, const lng *v, const lng *r);
-sql5_export str lng_bat_dec_round_wrap(bat *res, const bat *v, const lng *r);
-sql5_export str lng_round_wrap(lng *res, const lng *v, const int *d, const int 
*s, const bte *r);
-sql5_export str lng_bat_round_wrap(bat *res, const bat *v, const int *d, const 
int *s, const bte *r);
+sql5_export str lng_bat_dec_round_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr 
stk, InstrPtr pci);
+sql5_export str lng_bat_dec_round_wrap_cst(Client cntxt, MalBlkPtr mb, 
MalStkPtr stk, InstrPtr pci);
+sql5_export str lng_bat_dec_round_wrap_nocst(Client cntxt, MalBlkPtr mb, 
MalStkPtr stk, InstrPtr pci);
+sql5_export str lng_round_wrap(lng *res, const lng *v, const bte *r, const int 
*d, const int *s);
+sql5_export str lng_bat_round_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+sql5_export str lng_bat_round_wrap_cst(Client cntxt, MalBlkPtr mb, MalStkPtr 
stk, InstrPtr pci);
+sql5_export str lng_bat_round_wrap_nocst(Client cntxt, MalBlkPtr mb, MalStkPtr 
stk, InstrPtr pci);
 sql5_export str str_2dec_lng(lng *res, const str *val, const int *d, const int 
*sc);
 sql5_export str batstr_2dec_lng(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 sql5_export str lng_dec2second_interval(lng *res, const int *sc, const lng 
*dec, const int *ek, const int *sk);
@@ -189,9 +207,13 @@ sql5_export str batnil_2dec_lng(bat *res
 
 #ifdef HAVE_HGE
 sql5_export str hge_dec_round_wrap(hge *res, const hge *v, const hge *r);
-sql5_export str hge_bat_dec_round_wrap(bat *res, const bat *v, const hge *r);
-sql5_export str hge_round_wrap(hge *res, const hge *v, const int *d, const int 
*s, const bte *r);
-sql5_export str hge_bat_round_wrap(bat *res, const bat *v, const int *d, const 
int *s, const bte *r);
+sql5_export str hge_bat_dec_round_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr 
stk, InstrPtr pci);
+sql5_export str hge_bat_dec_round_wrap_cst(Client cntxt, MalBlkPtr mb, 
MalStkPtr stk, InstrPtr pci);
+sql5_export str hge_bat_dec_round_wrap_nocst(Client cntxt, MalBlkPtr mb, 
MalStkPtr stk, InstrPtr pci);
+sql5_export str hge_round_wrap(hge *res, const hge *v, const bte *r, const int 
*d, const int *s);
+sql5_export str hge_bat_round_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+sql5_export str hge_bat_round_wrap_cst(Client cntxt, MalBlkPtr mb, MalStkPtr 
stk, InstrPtr pci);
+sql5_export str hge_bat_round_wrap_nocst(Client cntxt, MalBlkPtr mb, MalStkPtr 
stk, InstrPtr pci);
 sql5_export str str_2dec_hge(hge *res, const str *val, const int *d, const int 
*sc);
 sql5_export str batstr_2dec_hge(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 sql5_export str hge_dec2second_interval(lng *res, const int *sc, const hge 
*dec, const int *ek, const int *sk);
diff --git a/sql/backends/monet5/sql_round.c b/sql/backends/monet5/sql_round.c
--- a/sql/backends/monet5/sql_round.c
+++ b/sql/backends/monet5/sql_round.c
@@ -35,6 +35,35 @@
 
 #define BIG lng                        /* a larger type */
 
+static void
+finalize_ouput_copy_sorted_property(bat *res, BAT *bn, BAT *b, str msg, bool 
nils, BUN q)
+{
+       if (bn && !msg) {
+               BATsetcount(bn, q);
+               bn->tnil = nils;
+               bn->tnonil = !nils;
+               bn->tkey = BATcount(bn) <= 1;
+               bn->tsorted = !b || b->tsorted;
+               bn->trevsorted = !b || b->trevsorted;
+               BBPkeepref(*res = bn->batCacheid);
+       } else if (bn)
+               BBPreclaim(bn);
+}
+
+static void
+unfix_inputs(int nargs, ...)
+{
+       va_list valist;
+
+       va_start(valist, nargs);
+       for (int i = 0; i < nargs; i++) {
+               BAT *b = va_arg(valist, BAT *);
+               if (b)
+                       BBPunfix(b->batCacheid);
+       }
+       va_end(valist);
+}
+
 #define TYPE bte
 #include "sql_round_impl.h"
 #undef TYPE
diff --git a/sql/backends/monet5/sql_round_impl.h 
b/sql/backends/monet5/sql_round_impl.h
--- a/sql/backends/monet5/sql_round_impl.h
+++ b/sql/backends/monet5/sql_round_impl.h
@@ -6,12 +6,16 @@
  * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V.
  */
 
-#define dec_round_body_nonil   FUN(TYPE, dec_round_body_nonil)
 #define dec_round_body         FUN(TYPE, dec_round_body)
 #define dec_round_wrap         FUN(TYPE, dec_round_wrap)
 #define bat_dec_round_wrap     FUN(TYPE, bat_dec_round_wrap)
+#define bat_dec_round_wrap_cst FUN(TYPE, bat_dec_round_wrap_cst)
+#define bat_dec_round_wrap_nocst       FUN(TYPE, bat_dec_round_wrap_nocst)
+#define round_body             FUN(TYPE, round_body)
 #define round_wrap             FUN(TYPE, round_wrap)
 #define bat_round_wrap         FUN(TYPE, bat_round_wrap)
+#define bat_round_wrap_cst     FUN(TYPE, bat_round_wrap_cst)
+#define bat_round_wrap_nocst   FUN(TYPE, bat_round_wrap_nocst)
 #define nil_2dec               FUN(nil_2dec, TYPE)
 #define str_2dec_body          FUN(str_2dec_body, TYPE)
 #define str_2dec               FUN(str_2dec, TYPE)
@@ -21,7 +25,7 @@
 #define batdec2second_interval FUN(TYPE, batdec2second_interval)
 
 static inline TYPE
-dec_round_body_nonil(TYPE v, TYPE r)
+dec_round_body(TYPE v, TYPE r)
 {
        TYPE add = r >> 1;
 
@@ -33,17 +37,6 @@ dec_round_body_nonil(TYPE v, TYPE r)
        return v / r;
 }
 
-static inline TYPE
-dec_round_body(TYPE v, TYPE r)
-{
-       /* shortcut nil */
-       if (ISNIL(TYPE)(v)) {
-               return NIL(TYPE);
-       } else {
-               return dec_round_body_nonil(v, r);
-       }
-}
-
 str
 dec_round_wrap(TYPE *res, const TYPE *v, const TYPE *r)
 {
@@ -52,248 +45,502 @@ dec_round_wrap(TYPE *res, const TYPE *v,
 
        if (*r <= 0)
                throw(MAL, "round", SQLSTATE(42000) "Argument 2 to round 
function must be positive");
-       *res = dec_round_body(*v, *r);
+
+       *res = ISNIL(TYPE)(*v) ? NIL(TYPE) : dec_round_body(*v, *r);
        return MAL_SUCCEED;
 }
 
 str
-bat_dec_round_wrap(bat *_res, const bat *_v, const TYPE *r)
+bat_dec_round_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
-       BAT *res, *v;
-       TYPE *src, *dst;
-       BUN i, cnt;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to