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