LCOV - code coverage report
Current view: top level - monetdb5/modules/mal - projectionpath.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 27 36 75.0 %
Date: 2024-04-25 20:03:45 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :  * SPDX-License-Identifier: MPL-2.0
       3             :  *
       4             :  * This Source Code Form is subject to the terms of the Mozilla Public
       5             :  * License, v. 2.0.  If a copy of the MPL was not distributed with this
       6             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       7             :  *
       8             :  * Copyright 2024 MonetDB Foundation;
       9             :  * Copyright August 2008 - 2023 MonetDB B.V.;
      10             :  * Copyright 1997 - July 2008 CWI.
      11             :  */
      12             : 
      13             : #include "monetdb_config.h"
      14             : #include "mal_client.h"
      15             : #include "mal_interpreter.h"
      16             : #include "mal_exception.h"
      17             : 
      18             : static str
      19      306866 : ALGprojectionpath(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
      20             : {
      21      306866 :         int i;
      22      306866 :         bat bid;
      23      306866 :         bat *r = getArgReference_bat(stk, pci, 0);
      24      306866 :         BAT *b, **joins = NULL;
      25             : 
      26      306866 :         (void) mb;
      27      306866 :         (void) cntxt;
      28             : 
      29      306866 :         if (pci->argc <= 1)
      30           0 :                 throw(MAL, "algebra.projectionpath", SQLSTATE(HY013) "INTERNAL ERROR");
      31      306866 :         joins = (BAT **) GDKzalloc(pci->argc * sizeof(BAT *));
      32      306845 :         if (joins == NULL)
      33           0 :                 throw(MAL, "algebra.projectionpath", SQLSTATE(HY013) MAL_MALLOC_FAIL);
      34     3275550 :         for (i = pci->retc; i < pci->argc; i++) {
      35     2968798 :                 bid = *getArgReference_bat(stk, pci, i);
      36     2968798 :                 b = BATdescriptor(bid);
      37     2968705 :                 if (b == NULL
      38     2968705 :                         || (i + 1 < pci->argc && ATOMtype(b->ttype) != TYPE_oid
      39           0 :                                 && b->ttype != TYPE_msk)) {
      40           0 :                         while (--i >= pci->retc)
      41           0 :                                 BBPunfix(joins[i - pci->retc]->batCacheid);
      42           0 :                         GDKfree(joins);
      43           0 :                         BBPreclaim(b);
      44           0 :                         throw(MAL, "algebra.projectionpath", "%s",
      45             :                                   b ? SEMANTIC_TYPE_MISMATCH : INTERNAL_BAT_ACCESS);
      46             :                 }
      47     2968705 :                 joins[i - pci->retc] = b;
      48             :         }
      49      306752 :         joins[pci->argc - pci->retc] = NULL;
      50      306752 :         b = BATprojectchain(joins);
      51     3276899 :         for (i = pci->retc; i < pci->argc; i++)
      52     2970105 :                 BBPunfix(joins[i - pci->retc]->batCacheid);
      53      306794 :         GDKfree(joins);
      54      306869 :         if (b) {
      55      306869 :                 *r = b->batCacheid;
      56      306869 :                 BBPkeepref(b);
      57             :         } else
      58           0 :                 throw(MAL, "algebra.projectionpath", GDK_EXCEPTION);
      59      306869 :         return MAL_SUCCEED;
      60             : }
      61             : 
      62             : #include "mel.h"
      63             : mel_func projectionpath_init_funcs[] = {
      64             :  pattern("algebra", "projectionpath", ALGprojectionpath, false, "Routine to handle join paths.  The type analysis is rather tricky.", args(1,2, batargany("",0),batvarargany("l",0))),
      65             :  { .imp=NULL }
      66             : };
      67             : #include "mal_import.h"
      68             : #ifdef _MSC_VER
      69             : #undef read
      70             : #pragma section(".CRT$XCU",read)
      71             : #endif
      72         329 : LIB_STARTUP_FUNC(init_projectionpath_mal)
      73         329 : { mal_module("projectionpath", NULL, projectionpath_init_funcs); }

Generated by: LCOV version 1.14