Changeset: c634b1a38e99 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c634b1a38e99
Modified Files:
        sql/backends/monet5/sql_subquery.c
Branch: Jul2021
Log Message:

Making SQLsubzero_or_one less buggy and confusing


diffs (52 lines):

diff --git a/sql/backends/monet5/sql_subquery.c 
b/sql/backends/monet5/sql_subquery.c
--- a/sql/backends/monet5/sql_subquery.c
+++ b/sql/backends/monet5/sql_subquery.c
@@ -88,33 +88,27 @@ str
 SQLsubzero_or_one(bat *ret, const bat *bid, const bat *gid, const bat *eid, 
bit *no_nil)
 {
        gdk_return r;
-       BAT *ng = NULL, *h = NULL, *g, *b;
+       BAT *ng = NULL, *h = NULL, *g = NULL;
+       lng max = 0;
 
        (void)no_nil;
        (void)eid;
 
-       g = gid ? BATdescriptor(*gid) : NULL;
-       if (g == NULL) {
-               if (g)
-                       BBPunfix(g->batCacheid);
+       if (!(g = BATdescriptor(*gid)))
                throw(MAL, "sql.subzero_or_one", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
-       }
-
-       if ((r = BATgroup(&ng, NULL, &h, g, NULL, NULL, NULL, NULL)) == 
GDK_SUCCEED) {
-               lng max = 0;
+       r = BATgroup(&ng, NULL, &h, g, NULL, NULL, NULL, NULL);
+       BBPunfix(g->batCacheid);
+       if (r != GDK_SUCCEED)
+               throw(MAL, "sql.subzero_or_one", GDK_EXCEPTION);
 
-               if (ng)
-                       BBPunfix(ng->batCacheid);
-               BATmax(h, &max);
-               BBPunfix(h->batCacheid);
-               if (max != lng_nil && max > 1)
-                       throw(SQL, "sql.subzero_or_one", SQLSTATE(M0M29) 
"zero_or_one: cardinality violation, scalar expression expected");
-       }
-       BBPunfix(g->batCacheid);
-       if (r == GDK_SUCCEED) {
-               b = bid ? BATdescriptor(*bid) : NULL;
-               BBPkeepref(*ret = b->batCacheid);
-       }
+       if (ng)
+               BBPunfix(ng->batCacheid);
+       BATmax(h, &max);
+       BBPunfix(h->batCacheid);
+
+       if (max != lng_nil && max > 1)
+               throw(SQL, "sql.subzero_or_one", SQLSTATE(M0M29) "zero_or_one: 
cardinality violation, scalar expression expected");
+       BBPretain(*ret = *bid);
        return MAL_SUCCEED;
 }
 
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to