LCOV - code coverage report
Current view: top level - monetdb5/optimizer - opt_profiler.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 11 52 21.2 %
Date: 2024-12-19 23:10:26 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             : /*
      14             :  * Collect properties for beautified variable rendering
      15             :  * All variables are tagged with the schema.table.column name if possible.
      16             :  */
      17             : 
      18             : #include "monetdb_config.h"
      19             : #include "mal_instruction.h"
      20             : #include "mal_profiler.h"
      21             : #include "opt_profiler.h"
      22             : 
      23             : str
      24      469773 : OPTprofilerImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
      25             :                                                   InstrPtr pci)
      26             : {
      27      469773 :         int i, actions = 0;
      28      469773 :         InstrPtr p;
      29      469773 :         str msg = MAL_SUCCEED;
      30             : 
      31      469773 :         (void) stk;
      32      469773 :         (void) cntxt;
      33             :         /* we only need the beautified version if we plan to emit events */
      34      469773 :         if (profilerStatus == 0)
      35      469773 :                 goto wrapup;
      36             : 
      37           0 :         for (i = 0; i < mb->stop; i++) {
      38           0 :                 p = getInstrPtr(mb, i);
      39           0 :                 if (p == NULL)
      40           0 :                         continue;
      41           0 :                 if (getModuleId(p) == NULL || getFunctionId(p) == NULL)
      42           0 :                         continue;
      43           0 :                 if (getModuleId(p) == sqlRef
      44           0 :                         && (getFunctionId(p) == bindRef
      45           0 :                                 || getFunctionId(p) == bindidxRef)) {
      46           0 :                         getVarSTC(mb, getArg(p, 0)) = i;
      47           0 :                 } else if (getModuleId(p) == sqlRef && getFunctionId(p) == tidRef) {
      48           0 :                         getVarSTC(mb, getArg(p, 0)) = i;
      49           0 :                 } else if (getModuleId(p) == sqlRef
      50           0 :                                    && (getFunctionId(p) == deltaRef
      51           0 :                                            || getFunctionId(p) == subdeltaRef)) {
      52             :                         // inherit property of first argument
      53           0 :                         getVarSTC(mb, getArg(p, 0)) = getVarSTC(mb, getArg(p, 1));
      54           0 :                 } else if (getModuleId(p) == sqlRef
      55           0 :                                    && getFunctionId(p) == projectdeltaRef) {
      56           0 :                         getVarSTC(mb, getArg(p, 0)) = getVarSTC(mb, getArg(p, 1));
      57           0 :                 } else if (getModuleId(p) == algebraRef
      58           0 :                                    && getFunctionId(p) == projectionRef) {
      59           0 :                         getVarSTC(mb, getArg(p, 0)) = getVarSTC(mb, getArg(p, p->argc - 1));
      60           0 :                 } else if (getModuleId(p) == algebraRef
      61           0 :                                    && (getFunctionId(p) == selectRef
      62           0 :                                            || getFunctionId(p) == thetaselectRef
      63           0 :                                            || getFunctionId(p) == selectNotNilRef)) {
      64           0 :                         getVarSTC(mb, getArg(p, 0)) = getVarSTC(mb, getArg(p, p->retc));
      65           0 :                 } else if (getModuleId(p) == algebraRef
      66           0 :                                    && getFunctionId(p) == likeselectRef) {
      67           0 :                         getVarSTC(mb, getArg(p, 0)) = getVarSTC(mb, getArg(p, p->retc));
      68           0 :                 } else if (getModuleId(p) == algebraRef
      69           0 :                                    && (getFunctionId(p) == joinRef
      70           0 :                                            || getFunctionId(p) == leftjoinRef
      71           0 :                                            || getFunctionId(p) == thetajoinRef
      72           0 :                                            || getFunctionId(p) == bandjoinRef
      73           0 :                                            || getFunctionId(p) == rangejoinRef)) {
      74           0 :                         getVarSTC(mb, getArg(p, 0)) = getVarSTC(mb, getArg(p, p->retc));
      75           0 :                         getVarSTC(mb, getArg(p, 1)) = getVarSTC(mb, getArg(p, p->retc + 1));
      76           0 :                 } else if (getModuleId(p) == matRef
      77           0 :                                    && getFunctionId(p) == packIncrementRef) {
      78           0 :                         getVarSTC(mb, getArg(p, 0)) = getVarSTC(mb, getArg(p, 1));
      79             :                 }
      80             :         }
      81             :         actions = 1;
      82             :         /* Defense line against incorrect plans */
      83             :         /* Plan remains unaffected */
      84             :         // msg = chkTypes(cntxt->usermodule, mb, FALSE);
      85             :         // if (!msg)
      86             :         //      msg = chkFlow(mb);
      87             :         // if (!msg)
      88             :         //      msg = chkDeclarations(mb);
      89      469773 :   wrapup:
      90             :         /* keep actions taken as a fake argument */
      91      469773 :         (void) pushInt(mb, pci, actions);
      92      469799 :         return msg;
      93             : }

Generated by: LCOV version 1.14