LCOV - code coverage report
Current view: top level - sql/server - rel_trans.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 37 39 94.9 %
Date: 2021-10-13 02:24:04 Functions: 2 2 100.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             : #include "monetdb_config.h"
      10             : #include "rel_trans.h"
      11             : #include "rel_select.h"
      12             : #include "rel_rel.h"
      13             : #include "rel_exp.h"
      14             : #include "sql_parser.h"
      15             : 
      16             : static sql_rel *
      17        2687 : rel_trans(mvc *sql, int trans_type, int nr, char *name)
      18             : {
      19        2687 :         sql_rel *rel = rel_create(sql->sa);
      20        2687 :         list *exps = new_exp_list(sql->sa);
      21        2687 :         if(!rel || !exps)
      22             :                 return NULL;
      23             : 
      24        2687 :         append(exps, exp_atom_int(sql->sa, nr));
      25        2687 :         if (name)
      26          61 :                 append(exps, exp_atom_clob(sql->sa, name));
      27        2687 :         rel->l = NULL;
      28        2687 :         rel->r = NULL;
      29        2687 :         rel->op = op_ddl;
      30        2687 :         rel->flag = trans_type;
      31        2687 :         rel->exps = exps;
      32        2687 :         rel->card = 0;
      33        2687 :         rel->nrcols = 0;
      34        2687 :         return rel;
      35             : }
      36             : 
      37             : sql_rel *
      38        2687 : rel_transactions(sql_query *query, symbol *s)
      39             : {
      40        2687 :         mvc *sql = query->sql;
      41             :         sql_rel *ret = NULL;
      42             : 
      43        2687 :         switch (s->token) {
      44          13 :         case TR_RELEASE:
      45          13 :                 ret = rel_trans(sql, ddl_release, 0, s->data.sval);
      46          13 :                 break;
      47         384 :         case TR_COMMIT:
      48         384 :                 assert(s->type == type_int);
      49         384 :                 ret = rel_trans(sql, ddl_commit, s->data.i_val, NULL);
      50         384 :                 break;
      51          39 :         case TR_SAVEPOINT:
      52          39 :                 ret = rel_trans(sql, ddl_commit, 0, s->data.sval);
      53          39 :                 break;
      54         974 :         case TR_ROLLBACK: {
      55         974 :                 dnode *n = s->data.lval->h;
      56         974 :                 assert(n->type == type_int);
      57         974 :                 ret= rel_trans(sql, ddl_rollback, n->data.i_val, n->next->data.sval);
      58         974 :         }       break;
      59        1277 :         case TR_START:
      60             :         case TR_MODE:
      61        1277 :                 assert(s->type == type_int);
      62        1277 :                 ret = rel_trans(sql, ddl_trans, s->data.i_val, NULL);
      63        1277 :                 break;
      64           0 :         default:
      65           0 :                 return sql_error(sql, 01, SQLSTATE(42000) "Transaction unknown Symbol(%p)->token = %s", s, token2string(s->token));
      66             :         }
      67             :         return ret;
      68             : }

Generated by: LCOV version 1.14