LCOV - code coverage report
Current view: top level - sql/common - sql_backend.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 35 38 92.1 %
Date: 2024-04-25 20:03:45 Functions: 11 12 91.7 %

          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             :  * The back end structure collects the information needed to support
      15             :  * compilation and execution of the SQL code against a back-end engine.
      16             :  * Note that any back-end can be called upon by the front-end
      17             :  * to handle specific tasks, such as catalog management (sql_mvc)
      18             :  * and query execution (sql_qc). For this purpose, the front-end needs
      19             :  * access to operations defined in the back-end, in particular for
      20             :  * freeing the stack and code segment.
      21             :  *
      22             :  * The front-end should not rely on knowledge how the back end handles
      23             :  * the actual query processing. Using the sample back end Monet5
      24             :  * are used to find the common ground here. The structure currently is a
      25             :  * simple functional wrapper. It assumes that a single back-end is used
      26             :  * for the duration of a session.
      27             :  */
      28             : 
      29             : #include "monetdb_config.h"
      30             : #include "sql_backend.h"
      31             : 
      32             : backend_functions be_funcs;
      33             : 
      34             : void
      35         840 : backend_freecode(const char *mod, int clientid, const char *name)
      36             : {
      37         840 :         if (be_funcs.fcode != NULL)
      38         840 :                 be_funcs.fcode(mod, clientid, name);
      39         840 : }
      40             : 
      41             : char *
      42         328 : backend_create_user(ptr mvc, char *user, char *passwd, bool enc, char *fullname, sqlid defschemid, char *schema_path, sqlid grantor, lng max_memory, int max_workers, char *optimizer, sqlid role_id)
      43             : {
      44         328 :         if (be_funcs.fcuser != NULL)
      45         328 :                 return(be_funcs.fcuser(mvc, user, passwd, enc, fullname, defschemid, schema_path, grantor, max_memory,
      46             :                                         max_workers, optimizer, role_id));
      47             :         return(NULL);
      48             : }
      49             : 
      50             : int
      51          93 : backend_drop_user(ptr mvc, char *user)
      52             : {
      53          93 :         if (be_funcs.fduser != NULL)
      54          93 :                 return(be_funcs.fduser(mvc,user));
      55             :         return FALSE;
      56             : }
      57             : 
      58             : oid
      59         455 : backend_find_user(ptr m, char *user)
      60             : {
      61         455 :         if (be_funcs.ffuser != NULL)
      62         455 :                 return(be_funcs.ffuser(m, user));
      63             :         return(0);
      64             : }
      65             : 
      66             : void
      67         223 : backend_create_privileges(ptr mvc, sql_schema *s, const char *initpasswd)
      68             : {
      69         223 :         if (be_funcs.fcrpriv != NULL)
      70         223 :                 be_funcs.fcrpriv(mvc, s, initpasswd);
      71         223 : }
      72             : 
      73             : int
      74         164 : backend_schema_has_user(ptr mvc, sql_schema *s)
      75             : {
      76         164 :         if (be_funcs.fshuser != NULL)
      77         164 :                 return(be_funcs.fshuser(mvc, s));
      78             :         return(FALSE);
      79             : }
      80             : 
      81             : int
      82          74 : backend_alter_user(ptr mvc, str user, str passwd, bool enc,
      83             :                                    sqlid schema_id, char *schema_path, str oldpasswd, sqlid role_id, lng max_memory, int max_workers)
      84             : {
      85          74 :         if (be_funcs.fauser != NULL)
      86          74 :                 return(be_funcs.fauser(mvc, user, passwd, enc, schema_id, schema_path, oldpasswd, role_id, max_memory, max_workers));
      87             :         return(FALSE);
      88             : }
      89             : 
      90             : int
      91           2 : backend_rename_user(ptr mvc, str olduser, str newuser)
      92             : {
      93           2 :         if (be_funcs.fruser != NULL)
      94           2 :                 return(be_funcs.fruser(mvc, olduser, newuser));
      95             :         return(FALSE);
      96             : }
      97             : 
      98             : void*
      99           0 : backend_schema_user_dependencies(ptr trans, sqlid schema_id)
     100             : {
     101           0 :         if (be_funcs.fschuserdep != NULL)
     102           0 :                 return(be_funcs.fschuserdep(trans, schema_id));
     103             :         return NULL;
     104             : }
     105             : 
     106             : int
     107      456837 : backend_resolve_function(ptr M, sql_func *f, const char *fimp, bool *side_effect)
     108             : {
     109      456837 :         if (be_funcs.fresolve_function != NULL)
     110      456837 :                 return be_funcs.fresolve_function(M, f, fimp, side_effect);
     111             :         return 0;
     112             : }
     113             : 
     114             : int
     115         533 : backend_has_module(ptr M, char *name)
     116             : {
     117         533 :         if (be_funcs.fhas_module_function != NULL)
     118         533 :                 return be_funcs.fhas_module_function(M, name);
     119             :         return 0;
     120             : }
     121             : 
     122             : int
     123          10 : backend_find_role(ptr mvc, char *name, sqlid *role_id)
     124             : {
     125          10 :         if (be_funcs.ffrole != NULL)
     126          10 :                 return be_funcs.ffrole(mvc, name, role_id);
     127             :         return 0;
     128             : }

Generated by: LCOV version 1.14