Changeset: 2a80648779e3 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2a80648779e3
Modified Files:
        clients/Tests/MAL-signatures.stable.out
        clients/Tests/MAL-signatures.stable.out.int128
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql.h
        sql/backends/monet5/sql_rank.mal
        sql/common/sql_types.c
        sql/test/Tests/systemfunctions.stable.out
        sql/test/Tests/systemfunctions.stable.out.int128
Branch: Dec2016
Log Message:

fix bug 6315, ie add missing exists functions.


diffs (130 lines):

diff --git a/clients/Tests/MAL-signatures.stable.out 
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -94,6 +94,8 @@ Ready.
 [ "aggr",      "covar",        "function 
aggr.covar(e1:bat[:lng],e2:bat[:lng]):lng;",  "",     ""      ]
 [ "aggr",      "covar",        "function 
aggr.covar(e1:bat[:sht],e2:bat[:sht]):sht;",  "",     ""      ]
 [ "aggr",      "exist",        "command aggr.exist(b:bat[:any_2],h:any_1):bit 
",       "ALGexist;",    ""      ]
+[ "aggr",      "exist",        "command aggr.exist(b:bat[:any_2]):bit ",       
"SQLexist;",    ""      ]
+[ "aggr",      "exist",        "command aggr.exist(v:any_2):bit ",     
"SQLexist_val;",        ""      ]
 [ "aggr",      "jsonaggr",     "command aggr.jsonaggr(val:bat[:dbl]):str ",    
"JSONgroupStr;",        "Aggregate the double values to array." ]
 [ "aggr",      "jsonaggr",     "command aggr.jsonaggr(val:bat[:str]):str ",    
"JSONgroupStr;",        "Aggregate the string values to array." ]
 [ "aggr",      "max",  "command 
aggr.max(b:bat[:any_1],g:bat[:oid],e:bat[:any_2]):bat[:any_1] ",       
"AGGRmax3;",    ""      ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128 
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -102,6 +102,8 @@ Ready.
 [ "aggr",      "covar",        "function 
aggr.covar(e1:bat[:lng],e2:bat[:lng]):lng;",  "",     ""      ]
 [ "aggr",      "covar",        "function 
aggr.covar(e1:bat[:sht],e2:bat[:sht]):sht;",  "",     ""      ]
 [ "aggr",      "exist",        "command aggr.exist(b:bat[:any_2],h:any_1):bit 
",       "ALGexist;",    ""      ]
+[ "aggr",      "exist",        "command aggr.exist(b:bat[:any_2]):bit ",       
"SQLexist;",    ""      ]
+[ "aggr",      "exist",        "command aggr.exist(v:any_2):bit ",     
"SQLexist_val;",        ""      ]
 [ "aggr",      "jsonaggr",     "command aggr.jsonaggr(val:bat[:dbl]):str ",    
"JSONgroupStr;",        "Aggregate the double values to array." ]
 [ "aggr",      "jsonaggr",     "command aggr.jsonaggr(val:bat[:str]):str ",    
"JSONgroupStr;",        "Aggregate the string values to array." ]
 [ "aggr",      "max",  "command 
aggr.max(b:bat[:any_1],g:bat[:oid],e:bat[:any_2]):bat[:any_1] ",       
"AGGRmax3;",    ""      ]
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
@@ -5555,3 +5555,25 @@ SQLflush_log(void *ret)
        store_flush_log();
        return MAL_SUCCEED;
 }
+
+str
+SQLexist_val(bit *res, void *v)
+{
+       if (v) 
+               *res = TRUE;
+       else
+               *res = FALSE;
+       return MAL_SUCCEED;
+}
+
+str
+SQLexist(bit *res, bat *id)
+{
+       BAT *b;
+
+       if ((b = BATdescriptor(*id)) == NULL)
+               throw(SQL, "aggr.exist", "Cannot access descriptor");
+       *res = BATcount(b);
+       BBPunfix(b->batCacheid);
+       return MAL_SUCCEED;
+}
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
@@ -316,4 +316,7 @@ sql5_export str BATSTRstrings(bat *res, 
 
 sql5_export str SQLflush_log(void *ret);
 
+sql5_export str SQLexist(bit *res, bat *id);
+sql5_export str SQLexist_val(bit *res, void *val);
+
 #endif /* _SQL_H */
diff --git a/sql/backends/monet5/sql_rank.mal b/sql/backends/monet5/sql_rank.mal
--- a/sql/backends/monet5/sql_rank.mal
+++ b/sql/backends/monet5/sql_rank.mal
@@ -50,3 +50,8 @@ comment "return the densely ranked group
 command aggr.exist(b:bat[:any_2], h:any_1):bit 
 address ALGexist;
 
+command aggr.exist(b:bat[:any_2]):bit
+address SQLexist;
+
+command aggr.exist(v:any_2):bit
+address SQLexist_val;
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
@@ -1411,6 +1411,8 @@ sqltypeinit( sql_allocator *sa)
        sql_create_aggr(sa, "all", "sql", "all", ANY, ANY);
        sql_create_aggr(sa, "exist", "aggr", "exist", ANY, BIT);
        sql_create_aggr(sa, "not_exist", "aggr", "not_exist", ANY, BIT);
+       sql_create_func(sa, "sql_exists", "aggr", "exist", ANY, NULL, BIT, 
SCALE_NONE);
+       sql_create_func(sa, "sql_not_exists", "aggr", "not_exist", ANY, NULL, 
BIT, SCALE_NONE);
        /* needed for relational version */
        sql_create_func(sa, "in", "calc", "in", ANY, ANY, BIT, SCALE_NONE);
        sql_create_func(sa, "identity", "calc", "identity", ANY, NULL, OID, 
SCALE_NONE);
diff --git a/sql/test/Tests/systemfunctions.stable.out 
b/sql/test/Tests/systemfunctions.stable.out
--- a/sql/test/Tests/systemfunctions.stable.out
+++ b/sql/test/Tests/systemfunctions.stable.out
@@ -3383,6 +3383,8 @@ Ready.
 [ "sys",       "sql_div",      0,      "sec_interval", "/"     ]
 [ "sys",       "sql_div",      1,      "sec_interval", ""      ]
 [ "sys",       "sql_div",      2,      "sec_interval", ""      ]
+[ "sys",       "sql_exists",   0,      "boolean",      "exist" ]
+[ "sys",       "sql_exists",   1,      "any",  ""      ]
 [ "sys",       "sql_max",      0,      "any",  "max"   ]
 [ "sys",       "sql_max",      1,      "any",  ""      ]
 [ "sys",       "sql_max",      2,      "any",  ""      ]
@@ -3610,6 +3612,8 @@ Ready.
 [ "sys",       "sql_neg",      1,      "month_interval",       ""      ]
 [ "sys",       "sql_neg",      0,      "sec_interval", "-"     ]
 [ "sys",       "sql_neg",      1,      "sec_interval", ""      ]
+[ "sys",       "sql_not_exists",       0,      "boolean",      "not_exist"     
]
+[ "sys",       "sql_not_exists",       1,      "any",  ""      ]
 [ "sys",       "sql_sub",      0,      "oid",  "-"     ]
 [ "sys",       "sql_sub",      1,      "oid",  ""      ]
 [ "sys",       "sql_sub",      2,      "oid",  ""      ]
diff --git a/sql/test/Tests/systemfunctions.stable.out.int128 
b/sql/test/Tests/systemfunctions.stable.out.int128
--- a/sql/test/Tests/systemfunctions.stable.out.int128
+++ b/sql/test/Tests/systemfunctions.stable.out.int128
@@ -3797,6 +3797,8 @@ Ready.
 [ "sys",       "sql_div",      0,      "sec_interval", "/"     ]
 [ "sys",       "sql_div",      1,      "sec_interval", ""      ]
 [ "sys",       "sql_div",      2,      "sec_interval", ""      ]
+[ "sys",       "sql_exists",   0,      "boolean",      "exist" ]
+[ "sys",       "sql_exists",   1,      "any",  ""      ]
 [ "sys",       "sql_max",      0,      "any",  "max"   ]
 [ "sys",       "sql_max",      1,      "any",  ""      ]
 [ "sys",       "sql_max",      2,      "any",  ""      ]
@@ -4106,6 +4108,8 @@ Ready.
 [ "sys",       "sql_neg",      1,      "month_interval",       ""      ]
 [ "sys",       "sql_neg",      0,      "sec_interval", "-"     ]
 [ "sys",       "sql_neg",      1,      "sec_interval", ""      ]
+[ "sys",       "sql_not_exists",       0,      "boolean",      "not_exist"     
]
+[ "sys",       "sql_not_exists",       1,      "any",  ""      ]
 [ "sys",       "sql_sub",      0,      "oid",  "-"     ]
 [ "sys",       "sql_sub",      1,      "oid",  ""      ]
 [ "sys",       "sql_sub",      2,      "oid",  ""      ]
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to