LCOV - code coverage report
Current view: top level - sql/server - rel_rewriter.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 8 8 100.0 %
Date: 2024-04-26 00:35:57 Functions: 1 1 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             : #ifndef _REL_REWRITER_H_
      14             : #define _REL_REWRITER_H_
      15             : 
      16             : #include "sql_relation.h"
      17             : #include "rel_rel.h"
      18             : 
      19             : #define is_ifthenelse_func(sf) (strcmp((sf)->func->base.name, "ifthenelse") == 0)
      20             : #define is_isnull_func(sf) (strcmp((sf)->func->base.name, "isnull") == 0)
      21             : #define is_not_func(sf) (strcmp((sf)->func->base.name, "not") == 0)
      22             : #define is_caselike_func(sf) (strcmp((sf)->func->base.name, "case") == 0 || \
      23             :                                                           strcmp((sf)->func->base.name, "casewhen") == 0 || \
      24             :                                                           strcmp((sf)->func->base.name, "coalesce") == 0 || \
      25             :                                                           strcmp((sf)->func->base.name, "nullif") == 0)
      26             : #define is_case_func(sf) (strcmp((sf)->func->base.name, "case") == 0)
      27             : #define is_casewhen_func(sf) (strcmp((sf)->func->base.name, "casewhen") == 0)
      28             : 
      29             : extern sql_exp *rewrite_simplify_exp(visitor *v, sql_rel *rel, sql_exp *e, int depth);
      30             : extern sql_rel *rewrite_simplify(visitor *v, uint8_t cycle, bool value_based_opt, sql_rel *rel);
      31             : 
      32             : static inline sql_rel *
      33    13020261 : try_remove_empty_select(visitor *v, sql_rel *rel)
      34             : {
      35    13020261 :         if (is_select(rel->op) && !(rel_is_ref(rel)) && list_empty(rel->exps)) {
      36       42322 :                 sql_rel *l = rel->l;
      37       42322 :                 rel->l = NULL;
      38       42322 :                 rel_destroy(rel);
      39       42322 :                 v->changes++;
      40       42322 :                 rel = l;
      41             :         }
      42    13020261 :         return rel;
      43             : }
      44             : 
      45             : extern int find_member_pos(list *l, sql_table *t);
      46             : extern sql_column *name_find_column(sql_rel *rel, const char *rname, const char *name, int pnr, sql_rel **bt);
      47             : 
      48             : extern int exp_joins_rels(sql_exp *e, list *rels);
      49             : /* WARNING exps_unique doesn't check for duplicate NULL values */
      50             : extern int kc_column_cmp(sql_kc *kc, sql_column *c);
      51             : extern int exps_unique(mvc *sql, sql_rel *rel, list *exps);
      52             : 
      53             : extern sql_column *exp_find_column(sql_rel *rel, sql_exp *exp, int pnr);
      54             : 
      55             : extern BUN get_rel_count(sql_rel *rel);
      56             : extern void set_count_prop(allocator *sa, sql_rel *rel, BUN val);
      57             : 
      58             : #endif /*_REL_REWRITER_H_*/

Generated by: LCOV version 1.14