LCOV - code coverage report
Current view: top level - sql/backends/monet5 - mal_backend.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 22 25 88.0 %
Date: 2024-04-26 00:35:57 Functions: 4 4 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 "sql.h"
      15             : #include "mal_backend.h"
      16             : 
      17             : backend *
      18       49729 : backend_reset(backend *b)
      19             : {
      20       49729 :         if (b->subbackend)
      21           0 :                 b->subbackend->reset(b->subbackend);
      22       49729 :         *b = (backend) {
      23       49729 :                 .mvc = b->mvc,
      24             :                 .client = b->client,
      25       49729 :                 .out = b->client->fdout,
      26             :                 .output_format = OFMT_CSV,
      27             :                 .rowcnt = -1,
      28             :                 .last_id = -1,
      29       49729 :                 .subbackend = b->subbackend,
      30             :         };
      31       49729 :         return b;
      32             : }
      33             : 
      34             : backend *
      35       48943 : backend_create(mvc *m, Client c)
      36             : {
      37       48943 :         backend *b = MNEW(backend);
      38             : 
      39       48943 :         if (!b)
      40             :                 return NULL;
      41       48943 :         *b = (backend) {
      42             :                 .mvc = m,
      43             :                 .client = c,
      44             :         };
      45       48943 :         if (b && be_funcs.sub_backend)
      46           0 :                 b->subbackend = be_funcs.sub_backend(m, c);
      47       48943 :         return backend_reset(b);
      48             : }
      49             : 
      50             : void
      51       48943 : backend_destroy(backend *b)
      52             : {
      53       48943 :         if (b->subbackend)
      54           0 :                 b->subbackend->destroy(b->subbackend);
      55       48943 :         _DELETE(b);
      56       48943 : }
      57             : 
      58             : /* for recursive functions, if the implementation is not set yet, take it from the current compilation */
      59             : str
      60      641487 : backend_function_imp(backend *b, sql_func *f)
      61             : {
      62      641487 :         str res = sql_func_imp(f);
      63             : 
      64      641796 :         if (b->mvc->forward && strcmp(res, "") == 0 && b->mvc->forward->base.id == f->base.id)
      65           6 :                 res = b->fimp;
      66      641796 :         return res;
      67             : }

Generated by: LCOV version 1.14