LCOV - code coverage report
Current view: top level - sql/common - sql_backend.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 38 38 100.0 %
Date: 2024-10-04 20:04:04 Functions: 12 12 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             :  * 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         801 : backend_freecode(const char *mod, int clientid, const char *name)
      36             : {
      37         801 :         if (be_funcs.fcode != NULL)
      38         801 :                 be_funcs.fcode(mod, clientid, name);
      39         801 : }
      40             : 
      41             : char *
      42         355 : 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         355 :         if (be_funcs.fcuser != NULL)
      45         355 :                 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          96 : backend_drop_user(ptr mvc, char *user)
      52             : {
      53          96 :         if (be_funcs.fduser != NULL)
      54          96 :                 return(be_funcs.fduser(mvc,user));
      55             :         return FALSE;
      56             : }
      57             : 
      58             : oid
      59         493 : backend_find_user(ptr m, char *user)
      60             : {
      61         493 :         if (be_funcs.ffuser != NULL)
      62         493 :                 return(be_funcs.ffuser(m, user));
      63             :         return(0);
      64             : }
      65             : 
      66             : void
      67         225 : backend_create_privileges(ptr mvc, sql_schema *s, const char *initpasswd)
      68             : {
      69         225 :         if (be_funcs.fcrpriv != NULL)
      70         225 :                 be_funcs.fcrpriv(mvc, s, initpasswd);
      71         225 : }
      72             : 
      73             : int
      74         170 : backend_schema_has_user(ptr mvc, sql_schema *s)
      75             : {
      76         170 :         if (be_funcs.fshuser != NULL)
      77         170 :                 return(be_funcs.fshuser(mvc, s));
      78             :         return(FALSE);
      79             : }
      80             : 
      81             : int
      82          81 : 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          81 :         if (be_funcs.fauser != NULL)
      86          81 :                 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          17 : backend_schema_user_dependencies(ptr trans, sqlid schema_id)
     100             : {
     101          17 :         if (be_funcs.fschuserdep != NULL)
     102          17 :                 return(be_funcs.fschuserdep(trans, schema_id));
     103             :         return NULL;
     104             : }
     105             : 
     106             : int
     107      419849 : backend_resolve_function(ptr M, sql_func *f, const char *fimp, bool *side_effect)
     108             : {
     109      419849 :         if (be_funcs.fresolve_function != NULL)
     110      419849 :                 return be_funcs.fresolve_function(M, f, fimp, side_effect);
     111             :         return 0;
     112             : }
     113             : 
     114             : int
     115         517 : backend_has_module(ptr M, char *name)
     116             : {
     117         517 :         if (be_funcs.fhas_module_function != NULL)
     118         517 :                 return be_funcs.fhas_module_function(M, name);
     119             :         return 0;
     120             : }
     121             : 
     122             : int
     123          12 : backend_find_role(ptr mvc, char *name, sqlid *role_id)
     124             : {
     125          12 :         if (be_funcs.ffrole != NULL)
     126          12 :                 return be_funcs.ffrole(mvc, name, role_id);
     127             :         return 0;
     128             : }

Generated by: LCOV version 1.14