Changeset: 2417ebe8a393 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2417ebe8a393
Modified Files:
        monetdb5/extras/rapi/rapi.c
        sql/backends/monet5/UDF/pyapi3/pyapi3.c
Branch: Jan2022
Log Message:

Fix some bat leaks.


diffs (60 lines):

diff --git a/monetdb5/extras/rapi/rapi.c b/monetdb5/extras/rapi/rapi.c
--- a/monetdb5/extras/rapi/rapi.c
+++ b/monetdb5/extras/rapi/rapi.c
@@ -119,7 +119,6 @@
                        prev = *p;                                              
                                                        \
                }                                                               
                                                                \
                BATsetcount(b, cnt);                                            
                                        \
-               BATsettrivprop(b);                                              
                                                \
        } while (0)
 
 // DATE epoch differs betwen MonetDB (00-01-01) and R (1970-01-01)
@@ -340,6 +339,7 @@ static BAT* sexp_to_bat(SEXP s, int type
                                }
                        }
                }
+               BATsetcount(b, cnt);
                break;
        }
        default:
@@ -351,10 +351,6 @@ static BAT* sexp_to_bat(SEXP s, int type
                }
        }
 
-       if (b) {
-               BATsetcount(b, cnt);
-               BBPkeepref(b->batCacheid);
-       }
        return b;
 }
 
@@ -821,6 +817,7 @@ static str RAPIeval(Client cntxt, MalBlk
                // bat return
                if (isaBatType(getArgType(mb,pci,i))) {
                        *getArgReference_bat(stk, pci, i) = b->batCacheid;
+                       BBPkeepref(b->batCacheid);
                } else { // single value return, only for non-grouped 
aggregations
                        BATiter li = bat_iterator(b);
                        if (VALinit(&stk->stk[pci->argv[i]], bat_type,
@@ -830,6 +827,7 @@ static str RAPIeval(Client cntxt, MalBlk
                                goto wrapup;
                        }
                        bat_iterator_end(&li);
+                       BBPunfix(b->batCacheid);
                }
                msg = MAL_SUCCEED;
        }
diff --git a/sql/backends/monet5/UDF/pyapi3/pyapi3.c 
b/sql/backends/monet5/UDF/pyapi3/pyapi3.c
--- a/sql/backends/monet5/UDF/pyapi3/pyapi3.c
+++ b/sql/backends/monet5/UDF/pyapi3/pyapi3.c
@@ -1239,6 +1239,10 @@ returnvalues:
                                        msg = createException(MAL, 
"pyapi3.eval", SQLSTATE(HY013) MAL_MALLOC_FAIL);
                        }
                        bat_iterator_end(&li);
+                       BBPunfix(b->batCacheid);
+                       b = NULL;
+                       if (msg != MAL_SUCCEED)
+                               goto wrapup;
                }
                if (argnode) {
                        argnode = argnode->next;
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to