LCOV - code coverage report
Current view: top level - monetdb5/modules/mal - bbp.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 30 268 11.2 %
Date: 2021-01-13 20:07:21 Functions: 4 19 21.1 %

          Line data    Source code
       1             : /*
       2             :  * This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0.  If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       5             :  *
       6             :  * Copyright 1997 - July 2008 CWI, August 2008 - 2021 MonetDB B.V.
       7             :  */
       8             : 
       9             : /*
      10             :  * (c) M.L.Kersten, P. Boncz
      11             :  * BAT Buffer Pool
      12             :  * It is primarilly meant to ease inspection of the BAT collection managed
      13             :  * by the server.
      14             :  */
      15             : #include "monetdb_config.h"
      16             : #include "bbp.h"
      17             : 
      18             : static int
      19           0 : pseudo(bat *ret, BAT *b, str X1,str X2) {
      20             :         char buf[BUFSIZ];
      21           0 :         snprintf(buf,BUFSIZ,"%s_%s", X1,X2);
      22           0 :         if ((BBPindex(buf) <= 0 && BBPrename(b->batCacheid, buf) != 0) || BATroles(b,X2) != GDK_SUCCEED) {
      23           0 :                 BBPunfix(b->batCacheid);
      24           0 :                 return -1;
      25             :         }
      26           0 :         *ret = b->batCacheid;
      27           0 :         BBPkeepref(*ret);
      28           0 :         return -0;
      29             : }
      30             : 
      31             : str
      32           4 : CMDbbpbind(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
      33             : {
      34             :         str name;
      35             :         ValPtr lhs;
      36             :         bat i;
      37             :         int tt;
      38             :         BAT *b;
      39             : 
      40             :         (void) cntxt;
      41             :         (void) mb;              /* fool compiler */
      42           4 :         lhs = &stk->stk[pci->argv[0]];
      43           4 :         name = *getArgReference_str(stk, pci, 1);
      44           4 :         if (name == NULL || isIdentifier(name) < 0)
      45           0 :                 throw(MAL, "bbp.bind", IDENTIFIER_EXPECTED);
      46           4 :         i = BBPindex(name);
      47           4 :         if (i == 0)
      48           1 :                 throw(MAL, "bbp.bind", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
      49             :         /* make sure you load the descriptors and heaps */
      50           3 :         b = (BAT *) BATdescriptor(i);
      51           3 :         if (b == 0)
      52             :                 /* Simple ignore the binding if you can't find the bat */
      53           0 :                 throw(MAL, "bbp.bind", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
      54             : 
      55             :         /* check conformity of the actual type and the one requested */
      56           3 :         tt= getBatType(getArgType(mb,pci,0));
      57           3 :         if( b->ttype == TYPE_void && tt== TYPE_oid) tt= TYPE_void;
      58             : 
      59           3 :         if( tt != b->ttype){
      60           0 :                 BBPunfix(i);
      61           0 :                 throw(MAL, "bbp.bind", SEMANTIC_TYPE_MISMATCH );
      62             :         }
      63             :         /* make sure we are not dealing with an about to be deleted bat */
      64           3 :         if( BBP_refs(b->batCacheid) == 1 &&
      65           3 :                 BBP_lrefs(b->batCacheid) == 0){
      66           0 :                 BBPunfix(i);
      67           0 :                 throw(MAL, "bbp.bind", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
      68             :         }
      69             : 
      70           3 :         BBPkeepref(b->batCacheid);
      71           3 :         lhs->vtype = TYPE_bat;
      72           3 :         lhs->val.bval = i;
      73           3 :         return MAL_SUCCEED;
      74             : }
      75             : /*
      76             :  * BBP status
      77             :  * The BAT buffer pool datastructures describe the memory resident information
      78             :  * on the whereabouts of the BATs. The three predominant tables are made accessible
      79             :  * for inspection.
      80             :  *
      81             :  * The most interesting system bat for end-users is the BID-> NAME mapping,
      82             :  * because it provides access to the system guaranteed persistent BAT identifier.
      83             :  * It may be the case that the user already introduced a BAT with this name,
      84             :  * it is simply removed first
      85             :  */
      86             : 
      87             : str
      88           0 : CMDbbpNames(bat *ret)
      89             : {
      90             :         BAT *b;
      91             :         int i;
      92             : 
      93           0 :         b = COLnew(0, TYPE_str, getBBPsize(), TRANSIENT);
      94           0 :         if (b == 0)
      95           0 :                 throw(MAL, "catalog.bbpNames", SQLSTATE(HY013) MAL_MALLOC_FAIL);
      96             : 
      97           0 :         BBPlock();
      98           0 :         for (i = 1; i < getBBPsize(); i++)
      99           0 :                 if (i != b->batCacheid) {
     100           0 :                         if (BBP_logical(i) && (BBP_refs(i) || BBP_lrefs(i)) ) {
     101           0 :                                 if (BUNappend(b, BBP_logical(i), false) != GDK_SUCCEED) {
     102           0 :                                         BBPunlock();
     103           0 :                                         BBPreclaim(b);
     104           0 :                                         throw(MAL, "catalog.bbpNames", SQLSTATE(HY013) MAL_MALLOC_FAIL);
     105             :                                 }
     106             :                         }
     107             :                 }
     108           0 :         BBPunlock();
     109           0 :         if (pseudo(ret,b,"bbp","name"))
     110           0 :                 throw(MAL, "catalog.bbpNames", GDK_EXCEPTION);
     111             :         return MAL_SUCCEED;
     112             : }
     113             : str
     114           0 : CMDbbpDiskSpace(lng *ret)
     115             : {
     116           0 :         *ret=  getDiskSpace();
     117           0 :         return MAL_SUCCEED;
     118             : }
     119             : str
     120           0 : CMDgetPageSize(int *ret)
     121             : {
     122           0 :         *ret= (int)  MT_pagesize();
     123           0 :         return MAL_SUCCEED;
     124             : }
     125             : 
     126             : str
     127           0 : CMDbbpName(str *ret, bat *bid)
     128             : {
     129           0 :         *ret = (str) GDKstrdup(BBP_logical(*bid));
     130           0 :         if (*ret == NULL)
     131           0 :                 throw(MAL, "catalog.bbpName", SQLSTATE(HY013) MAL_MALLOC_FAIL);
     132             :         return MAL_SUCCEED;
     133             : }
     134             : 
     135             : str
     136           0 : CMDbbpCount(bat *ret)
     137             : {
     138             :         BAT *b, *bn;
     139             :         int i;
     140             :         lng l;
     141             : 
     142           0 :         b = COLnew(0, TYPE_lng, getBBPsize(), TRANSIENT);
     143           0 :         if (b == 0)
     144           0 :                 throw(MAL, "catalog.bbpCount", SQLSTATE(HY013) MAL_MALLOC_FAIL);
     145             : 
     146           0 :         for (i = 1; i < getBBPsize(); i++)
     147           0 :                 if (i != b->batCacheid) {
     148           0 :                         if (BBP_logical(i) && (BBP_refs(i) || BBP_lrefs(i))) {
     149           0 :                                 bn = BATdescriptor(i);
     150           0 :                                 if (bn) {
     151           0 :                                         l = BATcount(bn);
     152           0 :                                         BBPunfix(bn->batCacheid);
     153           0 :                                         if (BUNappend(b,  &l, false) != GDK_SUCCEED) {
     154           0 :                                                 BBPreclaim(b);
     155           0 :                                                 throw(MAL, "catalog.bbpCount", SQLSTATE(HY013) MAL_MALLOC_FAIL);
     156             :                                         }
     157             :                                 }
     158             :                         }
     159             :                 }
     160           0 :         if (pseudo(ret,b,"bbp","count"))
     161           0 :                 throw(MAL, "catalog.bbpCount", GDK_EXCEPTION);
     162             :         return MAL_SUCCEED;
     163             : }
     164             : 
     165             : /*
     166             :  * The BAT status is redundantly stored in CMDbat_info.
     167             :  */
     168             : str
     169           0 : CMDbbpLocation(bat *ret)
     170             : {
     171             :         BAT *b;
     172             :         int i;
     173             :         char buf[FILENAME_MAX];
     174             :         char cwd[FILENAME_MAX];
     175             : 
     176           0 :         if (getcwd(cwd, FILENAME_MAX) == NULL)
     177           0 :                 throw(MAL, "catalog.bbpLocation", RUNTIME_DIR_ERROR);
     178             : 
     179           0 :         b = COLnew(0, TYPE_str, getBBPsize(), TRANSIENT);
     180           0 :         if (b == 0)
     181           0 :                 throw(MAL, "catalog.bbpLocation", SQLSTATE(HY013) MAL_MALLOC_FAIL);
     182             : 
     183           0 :         BBPlock();
     184           0 :         for (i = 1; i < getBBPsize(); i++)
     185           0 :                 if (i != b->batCacheid) {
     186           0 :                         if (BBP_logical(i) && (BBP_refs(i) || BBP_lrefs(i))) {
     187           0 :                                 int len = snprintf(buf,FILENAME_MAX,"%s/bat/%s",cwd,BBP_physical(i));
     188           0 :                                 if (len == -1 || len >= FILENAME_MAX) {
     189           0 :                                         BBPunlock();
     190           0 :                                         BBPreclaim(b);
     191           0 :                                         throw(MAL, "catalog.bbpLocation", SQLSTATE(HY013) "Could not write bpp filename path is too large");
     192             :                                 }
     193           0 :                                 if (BUNappend(b, buf, false) != GDK_SUCCEED) {
     194           0 :                                         BBPunlock();
     195           0 :                                         BBPreclaim(b);
     196           0 :                                         throw(MAL, "catalog.bbpLocation", SQLSTATE(HY013) MAL_MALLOC_FAIL);
     197             :                                 }
     198             :                         }
     199             :                 }
     200           0 :         BBPunlock();
     201           0 :         if (pseudo(ret,b,"bbp","location"))
     202           0 :                 throw(MAL, "catalog.bbpLocation", GDK_EXCEPTION);
     203             :         return MAL_SUCCEED;
     204             : }
     205             : 
     206             : /*
     207             :  * The BAT dirty status:dirty => (mem != disk); diffs = not-committed
     208             :  */
     209             : str
     210           0 : CMDbbpDirty(bat *ret)
     211             : {
     212             :         BAT *b;
     213             :         int i;
     214             : 
     215           0 :         b = COLnew(0, TYPE_str, getBBPsize(), TRANSIENT);
     216           0 :         if (b == 0)
     217           0 :                 throw(MAL, "catalog.bbpDirty", SQLSTATE(HY013) MAL_MALLOC_FAIL);
     218             : 
     219           0 :         BBPlock();
     220           0 :         for (i = 1; i < getBBPsize(); i++)
     221           0 :                 if (i != b->batCacheid)
     222           0 :                         if (BBP_logical(i) && (BBP_refs(i) || BBP_lrefs(i))) {
     223           0 :                                 BAT *bn = BBP_cache(i);
     224             : 
     225           0 :                                 if (BUNappend(b, bn ? BATdirty(bn) ? "dirty" : DELTAdirty(bn) ? "diffs" : "clean" : (BBP_status(i) & BBPSWAPPED) ? "diffs" : "clean", false) != GDK_SUCCEED) {
     226           0 :                                         BBPunlock();
     227           0 :                                         BBPreclaim(b);
     228           0 :                                         throw(MAL, "catalog.bbpDirty", SQLSTATE(HY013) MAL_MALLOC_FAIL);
     229             :                                 }
     230             :                         }
     231           0 :         BBPunlock();
     232           0 :         if (pseudo(ret,b,"bbp","status"))
     233           0 :                 throw(MAL, "catalog.bbpDirty", GDK_EXCEPTION);
     234             :         return MAL_SUCCEED;
     235             : }
     236             : 
     237             : /*
     238             :  * The BAT status is redundantly stored in CMDbat_info.
     239             :  */
     240             : str
     241           0 : CMDbbpStatus(bat *ret)
     242             : {
     243             :         BAT *b;
     244             :         int i;
     245             : 
     246           0 :         b = COLnew(0, TYPE_str, getBBPsize(), TRANSIENT);
     247           0 :         if (b == 0)
     248           0 :                 throw(MAL, "catalog.bbpStatus", SQLSTATE(HY013) MAL_MALLOC_FAIL);
     249             : 
     250           0 :         BBPlock();
     251           0 :         for (i = 1; i < getBBPsize(); i++)
     252           0 :                 if (i != b->batCacheid)
     253           0 :                         if (BBP_logical(i) && (BBP_refs(i) || BBP_lrefs(i))) {
     254           0 :                                 char *loc = BBP_cache(i) ? "load" : "disk";
     255             : 
     256           0 :                                 if (BUNappend(b, loc, false) != GDK_SUCCEED) {
     257           0 :                                         BBPunlock();
     258           0 :                                         BBPreclaim(b);
     259           0 :                                         throw(MAL, "catalog.bbpStatus", SQLSTATE(HY013) MAL_MALLOC_FAIL);
     260             :                                 }
     261             :                         }
     262           0 :         BBPunlock();
     263           0 :         if (pseudo(ret,b,"bbp","status"))
     264           0 :                 throw(MAL, "catalog.bbpStatus", GDK_EXCEPTION);
     265             :         return MAL_SUCCEED;
     266             : }
     267             : 
     268             : str
     269           0 : CMDbbpKind(bat *ret)
     270             : {
     271             :         BAT *b;
     272             :         int i;
     273             : 
     274           0 :         b = COLnew(0, TYPE_str, getBBPsize(), TRANSIENT);
     275           0 :         if (b == 0)
     276           0 :                 throw(MAL, "catalog.bbpKind", SQLSTATE(HY013) MAL_MALLOC_FAIL);
     277             : 
     278           0 :         BBPlock();
     279           0 :         for (i = 1; i < getBBPsize(); i++)
     280           0 :                 if (i != b->batCacheid && BBP_logical(i) && (BBP_refs(i) || BBP_lrefs(i))) {
     281             :                         const char *mode;
     282             : 
     283           0 :                         if ((BBP_status(i) & BBPDELETED) || !(BBP_status(i) & BBPPERSISTENT))
     284             :                                 mode = "transient";
     285             :                         else
     286             :                                 mode = "persistent";
     287           0 :                         if (BUNappend(b, mode, false) != GDK_SUCCEED) {
     288           0 :                                 BBPunlock();
     289           0 :                                 BBPreclaim(b);
     290           0 :                                         throw(MAL, "catalog.bbpKind", SQLSTATE(HY013) MAL_MALLOC_FAIL);
     291             :                         }
     292             :                 }
     293           0 :         BBPunlock();
     294           0 :         if (pseudo(ret,b,"bbp","kind"))
     295           0 :                 throw(MAL, "catalog.bbpKind", GDK_EXCEPTION);
     296             :         return MAL_SUCCEED;
     297             : }
     298             : 
     299             : str
     300           0 : CMDbbpRefCount(bat *ret)
     301             : {
     302             :         BAT *b;
     303             :         int i;
     304             : 
     305           0 :         b = COLnew(0, TYPE_int, getBBPsize(), TRANSIENT);
     306           0 :         if (b == 0)
     307           0 :                 throw(MAL, "catalog.bbpRefCount", SQLSTATE(HY013) MAL_MALLOC_FAIL);
     308             : 
     309           0 :         BBPlock();
     310           0 :         for (i = 1; i < getBBPsize(); i++)
     311           0 :                 if (i != b->batCacheid && BBP_logical(i) && (BBP_refs(i) || BBP_lrefs(i))) {
     312           0 :                         int refs = BBP_refs(i);
     313             : 
     314           0 :                         if (BUNappend(b, &refs, false) != GDK_SUCCEED) {
     315           0 :                                 BBPunlock();
     316           0 :                                 BBPreclaim(b);
     317           0 :                                 throw(MAL, "catalog.bbpRefCount", SQLSTATE(HY013) MAL_MALLOC_FAIL);
     318             :                         }
     319             :                 }
     320           0 :         BBPunlock();
     321           0 :         if (pseudo(ret,b,"bbp","refcnt"))
     322           0 :                 throw(MAL, "catalog.bbpRefCount", GDK_EXCEPTION);
     323             :         return MAL_SUCCEED;
     324             : }
     325             : 
     326             : str
     327           0 : CMDbbpLRefCount(bat *ret)
     328             : {
     329             :         BAT *b;
     330             :         int i;
     331             : 
     332           0 :         b = COLnew(0, TYPE_int, getBBPsize(), TRANSIENT);
     333           0 :         if (b == 0)
     334           0 :                 throw(MAL, "catalog.bbpLRefCount", SQLSTATE(HY013) MAL_MALLOC_FAIL);
     335             : 
     336           0 :         BBPlock();
     337           0 :         for (i = 1; i < getBBPsize(); i++)
     338           0 :                 if (i != b->batCacheid && BBP_logical(i) && (BBP_refs(i) || BBP_lrefs(i))) {
     339           0 :                         int refs = BBP_lrefs(i);
     340             : 
     341           0 :                         if (BUNappend(b, &refs, false) != GDK_SUCCEED) {
     342           0 :                                 BBPunlock();
     343           0 :                                 BBPreclaim(b);
     344           0 :                                 throw(MAL, "catalog.bbpLRefCount", SQLSTATE(HY013) MAL_MALLOC_FAIL);
     345             :                         }
     346             :                 }
     347           0 :         BBPunlock();
     348           0 :         if (pseudo(ret,b,"bbp","lrefcnt"))
     349           0 :                 throw(MAL, "catalog.bbpLRefCount", GDK_EXCEPTION);
     350             :         return MAL_SUCCEED;
     351             : }
     352             : 
     353             : str
     354           0 : CMDbbpgetIndex(int *res, bat *bid)
     355             : {
     356           0 :         *res= *bid;
     357           0 :         return MAL_SUCCEED;
     358             : }
     359             : 
     360             : str
     361           7 : CMDgetBATrefcnt(int *res, bat *bid)
     362             : {
     363             :         BAT *b;
     364             : 
     365           7 :         if ((b = BATdescriptor(*bid)) == NULL) {
     366           0 :                 throw(MAL, "bbp.getRefCount", INTERNAL_BAT_ACCESS);
     367             :         }
     368           7 :         *res = BBP_refs(b->batCacheid);
     369           7 :         BBPunfix(b->batCacheid);
     370           7 :         return MAL_SUCCEED;
     371             : }
     372             : 
     373             : str
     374          35 : CMDgetBATlrefcnt(int *res, bat *bid)
     375             : {
     376             :         BAT *b;
     377             : 
     378          35 :         if ((b = BATdescriptor(*bid)) == NULL) {
     379           0 :                 throw(MAL, "bbp.getLRefCount", INTERNAL_BAT_ACCESS);
     380             :         }
     381          35 :         *res = BBP_lrefs(b->batCacheid);
     382          35 :         BBPunfix(b->batCacheid);
     383          35 :         return MAL_SUCCEED;
     384             : }
     385             : 
     386           0 : str CMDbbp(bat *ID, bat *NS, bat *TT, bat *CNT, bat *REFCNT, bat *LREFCNT, bat *LOCATION, bat *HEAT, bat *DIRTY, bat *STATUS, bat *KIND)
     387             : {
     388             :         BAT *id, *ns, *tt, *cnt, *refcnt, *lrefcnt, *location, *heat, *dirty, *status, *kind, *bn;
     389             :         bat     i;
     390             :         char buf[FILENAME_MAX];
     391           0 :         bat sz = getBBPsize();
     392             :         str msg = MAL_SUCCEED;
     393             : 
     394           0 :         id = COLnew(0, TYPE_int, (BUN) sz, TRANSIENT);
     395           0 :         ns = COLnew(0, TYPE_str, (BUN) sz, TRANSIENT);
     396           0 :         tt = COLnew(0, TYPE_str, (BUN) sz, TRANSIENT);
     397           0 :         cnt = COLnew(0, TYPE_lng, (BUN) sz, TRANSIENT);
     398           0 :         refcnt = COLnew(0, TYPE_int, (BUN) sz, TRANSIENT);
     399           0 :         lrefcnt = COLnew(0, TYPE_int, (BUN) sz, TRANSIENT);
     400           0 :         location = COLnew(0, TYPE_str, (BUN) sz, TRANSIENT);
     401           0 :         heat = COLnew(0, TYPE_int, (BUN) sz, TRANSIENT);
     402           0 :         dirty = COLnew(0, TYPE_str, (BUN) sz, TRANSIENT);
     403           0 :         status = COLnew(0, TYPE_str, (BUN) sz, TRANSIENT);
     404           0 :         kind = COLnew(0, TYPE_str, (BUN) sz, TRANSIENT);
     405             : 
     406           0 :         if (!id || !ns || !tt || !cnt || !refcnt || !lrefcnt || !location || !heat || !dirty || !status || !kind) {
     407           0 :                 goto bailout;
     408             :         }
     409           0 :         for (i = 1; i < sz; i++) {
     410           0 :                 if (BBP_logical(i) && (BBP_refs(i) || BBP_lrefs(i))) {
     411           0 :                         bn = BATdescriptor(i);
     412           0 :                         if (bn) {
     413           0 :                                 lng l = BATcount(bn);
     414           0 :                                 int heat_ = 0, len;
     415           0 :                                 char *loc = BBP_cache(i) ? "load" : "disk";
     416             :                                 char *mode = "persistent";
     417           0 :                                 int refs = BBP_refs(i);
     418           0 :                                 int lrefs = BBP_lrefs(i);
     419             : 
     420           0 :                                 if ((BBP_status(i) & BBPDELETED) || !(BBP_status(i) & BBPPERSISTENT))
     421             :                                         mode = "transient";
     422           0 :                                 len = snprintf(buf, FILENAME_MAX, "%s", BBP_physical(i));
     423           0 :                                 if (len == -1 || len >= FILENAME_MAX) {
     424           0 :                                         msg = createException(MAL, "catalog.bbp", SQLSTATE(HY013) "Could not bpp filename path is too large");
     425           0 :                                         goto bailout;
     426             :                                 }
     427           0 :                                 if (BUNappend(id, &i, false) != GDK_SUCCEED ||
     428           0 :                                         BUNappend(ns, BBP_logical(i), false) != GDK_SUCCEED ||
     429           0 :                                         BUNappend(tt, BATatoms[BATttype(bn)].name, false) != GDK_SUCCEED ||
     430           0 :                                         BUNappend(cnt, &l, false) != GDK_SUCCEED ||
     431           0 :                                         BUNappend(refcnt, &refs, false) != GDK_SUCCEED ||
     432           0 :                                         BUNappend(lrefcnt, &lrefs, false) != GDK_SUCCEED ||
     433           0 :                                         BUNappend(location, buf, false) != GDK_SUCCEED ||
     434           0 :                                         BUNappend(heat, &heat_, false) != GDK_SUCCEED ||
     435           0 :                                         BUNappend(dirty, bn ? BATdirty(bn) ? "dirty" : DELTAdirty(bn) ? "diffs" : "clean" : (BBP_status(i) & BBPSWAPPED) ? "diffs" : "clean", false) != GDK_SUCCEED ||
     436           0 :                                         BUNappend(status, loc, false) != GDK_SUCCEED ||
     437           0 :                                         BUNappend(kind, mode, false) != GDK_SUCCEED) {
     438           0 :                                         BBPunfix(bn->batCacheid);
     439           0 :                                         msg = createException(MAL, "catalog.bbp", SQLSTATE(HY013) MAL_MALLOC_FAIL);
     440           0 :                                         goto bailout;
     441             :                                 }
     442           0 :                                 BBPunfix(bn->batCacheid);
     443             :                         }
     444             :                 }
     445             :         }
     446           0 :         BBPkeepref(*ID = id->batCacheid);
     447           0 :         BBPkeepref(*NS = ns->batCacheid);
     448           0 :         BBPkeepref(*TT = tt->batCacheid);
     449           0 :         BBPkeepref(*CNT = cnt->batCacheid);
     450           0 :         BBPkeepref(*REFCNT = refcnt->batCacheid);
     451           0 :         BBPkeepref(*LREFCNT = lrefcnt->batCacheid);
     452           0 :         BBPkeepref(*LOCATION = location->batCacheid);
     453           0 :         BBPkeepref(*HEAT = heat->batCacheid);
     454           0 :         BBPkeepref(*DIRTY = dirty->batCacheid);
     455           0 :         BBPkeepref(*STATUS = status->batCacheid);
     456           0 :         BBPkeepref(*KIND = kind->batCacheid);
     457           0 :         return MAL_SUCCEED;
     458             : 
     459           0 :   bailout:
     460           0 :         BBPreclaim(id);
     461           0 :         BBPreclaim(ns);
     462           0 :         BBPreclaim(tt);
     463           0 :         BBPreclaim(cnt);
     464           0 :         BBPreclaim(refcnt);
     465           0 :         BBPreclaim(lrefcnt);
     466           0 :         BBPreclaim(location);
     467           0 :         BBPreclaim(heat);
     468           0 :         BBPreclaim(dirty);
     469           0 :         BBPreclaim(status);
     470           0 :         BBPreclaim(kind);
     471           0 :         return msg;
     472             : }
     473             : 
     474             : str
     475           0 : CMDsetName(str *rname, const bat *bid, str *name)
     476             : {
     477             :         BAT *b;
     478           0 :         if ((b = BATdescriptor(*bid)) == NULL) {
     479           0 :                 throw(MAL, "bbp.setName", INTERNAL_BAT_ACCESS);
     480             :         }
     481           0 :         if (BBPrename(b->batCacheid, *name) != 0) {
     482           0 :                 BBPunfix(b->batCacheid);
     483           0 :                 throw(MAL, "bbp.setName", GDK_EXCEPTION);
     484             :         }
     485           0 :         *rname = GDKstrdup(*name);
     486           0 :         BBPunfix(b->batCacheid);
     487           0 :         if (*rname == NULL)
     488           0 :                 throw(MAL, "bbp.setName", SQLSTATE(HY013) MAL_MALLOC_FAIL);
     489             :         return MAL_SUCCEED;
     490             : }
     491             : 
     492             : #include "mel.h"
     493             : mel_func bbp_init_funcs[] = {
     494             :  pattern("bbp", "bind", CMDbbpbind, false, "Locate the BAT using its logical name", args(1,2, batargany("",2),arg("name",str))),
     495             :  command("bbp", "getIndex", CMDbbpgetIndex, false, "Retrieve the index in the BBP", args(1,2, arg("",int),batargany("b",2))),
     496             :  command("bbp", "getNames", CMDbbpNames, false, "Map BAT into its bbp name", args(1,1, batarg("",str))),
     497             :  command("bbp", "get", CMDbbp, false, "bpp", args(11,11, batarg("id",int),batarg("ns",str),batarg("tt",str),batarg("cnt",lng),batarg("refcnt",int),batarg("lrefcnt",int),batarg("location",str),batarg("heat",int),batarg("dirty",str),batarg("status",str),batarg("kind",str))),
     498             :  command("bbp", "getName", CMDbbpName, false, "Map a BAT into its internal name", args(1,2, arg("",str),batargany("b",1))),
     499             :  command("bbp", "setName", CMDsetName, false, "Rename a BAT", args(1,3, arg("",str),batargany("b",1),arg("n",str))),
     500             :  command("bbp", "getCount", CMDbbpCount, false, "Create a BAT with the cardinalities of all known BATs", args(1,1, batarg("",lng))),
     501             :  command("bbp", "getRefCount", CMDbbpRefCount, false, "Create a BAT with the (hard) reference counts", args(1,1, batarg("",int))),
     502             :  command("bbp", "getLRefCount", CMDbbpLRefCount, false, "Create a BAT with the logical reference counts", args(1,1, batarg("",int))),
     503             :  command("bbp", "getLocation", CMDbbpLocation, false, "Create a BAT with their disk locations", args(1,1, batarg("",str))),
     504             :  command("bbp", "getDirty", CMDbbpDirty, false, "Create a BAT with the dirty/ diffs/clean status", args(1,1, batarg("",str))),
     505             :  command("bbp", "getStatus", CMDbbpStatus, false, "Create a BAT with the disk/load status", args(1,1, batarg("",str))),
     506             :  command("bbp", "getKind", CMDbbpKind, false, "Create a BAT with the persistency status", args(1,1, batarg("",str))),
     507             :  command("bbp", "getRefCount", CMDgetBATrefcnt, false, "Utility for debugging MAL interpreter", args(1,2, arg("",int),batargany("b",1))),
     508             :  command("bbp", "getLRefCount", CMDgetBATlrefcnt, false, "Utility for debugging MAL interpreter", args(1,2, arg("",int),batargany("b",1))),
     509             :  command("bbp", "getDiskSpace", CMDbbpDiskSpace, false, "Estimate the amount of disk space occupied by dbpath", args(1,1, arg("",lng))),
     510             :  command("bbp", "getPageSize", CMDgetPageSize, false, "Obtain the memory page size", args(1,1, arg("",int))),
     511             :  { .imp=NULL }
     512             : };
     513             : #include "mal_import.h"
     514             : #ifdef _MSC_VER
     515             : #undef read
     516             : #pragma section(".CRT$XCU",read)
     517             : #endif
     518         255 : LIB_STARTUP_FUNC(init_bbp_mal)
     519         255 : { mal_module("bbp", NULL, bbp_init_funcs); }

Generated by: LCOV version 1.14