LCOV - code coverage report
Current view: top level - sql/backends/monet5 - sql_assert.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 21 27 77.8 %
Date: 2021-10-13 02:24:04 Functions: 3 5 60.0 %

          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             :  * @f sql_scenario
      11             :  * @t SQL catwalk management
      12             :  * @a N. Nes, M.L. Kersten
      13             :  * @+ SQL scenario
      14             :  * The SQL scenario implementation is a derivative of the MAL session scenario.
      15             :  *
      16             :  * It is also the first version that uses state records attached to
      17             :  * the client record. They are initialized as part of the initialization
      18             :  * phase of the scenario.
      19             :  *
      20             :  */
      21             : /*
      22             :  * @+ Scenario routines
      23             :  * Before we are can process SQL statements the global catalog
      24             :  * should be initialized. Thereafter, each time a client enters
      25             :  * we update its context descriptor to denote an SQL scenario.
      26             :  */
      27             : #include "monetdb_config.h"
      28             : #include "mal_backend.h"
      29             : #include "sql_assert.h"
      30             : #include "sql_scenario.h"
      31             : /*
      32             :  * Assertion errors detected during the execution of a code block
      33             :  * raise an exception. A debugger dump is generated upon request
      34             :  * to ease debugging.
      35             :  */
      36             : static inline str
      37       30277 : do_assert(bool flg, const char *msg)
      38             : {
      39       30277 :         if (flg) {
      40         217 :                 if (strlen(msg) > 6 &&
      41         217 :                     msg[5] == '!' &&
      42         161 :                     (isdigit((unsigned char) msg[0]) ||
      43         161 :                      isupper((unsigned char) msg[0])) &&
      44         161 :                     (isdigit((unsigned char) msg[1]) ||
      45         161 :                      isupper((unsigned char) msg[1])) &&
      46         161 :                     (isdigit((unsigned char) msg[2]) ||
      47         161 :                      isupper((unsigned char) msg[2])) &&
      48         161 :                     (isdigit((unsigned char) msg[3]) ||
      49         161 :                      isupper((unsigned char) msg[3])) &&
      50         161 :                     (isdigit((unsigned char) msg[4]) ||
      51             :                      isupper((unsigned char) msg[4])))
      52         161 :                         throw(SQL, "assert", "%s", msg); /* includes state */
      53          56 :                 throw(SQL, "assert", SQLSTATE(M0M29) "%s", msg);
      54             :         }
      55             :         return MAL_SUCCEED;
      56             : }
      57             : str
      58       20032 : SQLassert(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
      59             : {
      60             :         (void) cntxt;
      61             :         (void) mb;
      62       20032 :         return do_assert((bool) *getArgReference_bit(stk, pci, 1),
      63       20032 :                          *getArgReference_str(stk, pci, 2));
      64             : }
      65             : 
      66             : str
      67           0 : SQLassertInt(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
      68             : {
      69             :         (void) cntxt;
      70             :         (void) mb;
      71           0 :         return do_assert((bool) *getArgReference_int(stk, pci, 1),
      72           0 :                          *getArgReference_str(stk, pci, 2));
      73             : }
      74             : 
      75             : str
      76       10245 : SQLassertLng(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
      77             : {
      78             :         (void) cntxt;
      79             :         (void) mb;
      80       10245 :         return do_assert((bool) *getArgReference_lng(stk, pci, 1),
      81       10245 :                          *getArgReference_str(stk, pci, 2));
      82             : }
      83             : 
      84             : #ifdef HAVE_HGE
      85             : str
      86           0 : SQLassertHge(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
      87             : {
      88             :         (void) cntxt;
      89             :         (void) mb;
      90           0 :         return do_assert((bool) *getArgReference_hge(stk, pci, 1),
      91           0 :                          *getArgReference_str(stk, pci, 2));
      92             : }
      93             : #endif

Generated by: LCOV version 1.14