Line data Source code
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 - 2021 MonetDB B.V.
7 : */
8 :
9 : /*
10 : * (c) Martin Kersten
11 : * The factory infrastructure can be inspected and steered with
12 : * the commands provided here. to-be-completed-when-needed
13 : */
14 : #include "monetdb_config.h"
15 : #include "mal.h"
16 : #include "mal_interpreter.h"
17 : #include "mal_namespace.h"
18 :
19 : static str
20 0 : FCTgetPlants(bat *ret, bat *ret2)
21 : {
22 : (void) ret;
23 : (void) ret2;
24 0 : throw(MAL, "factories.getPlants", SQLSTATE(0A000) PROGRAM_NYI);
25 : }
26 :
27 : static str
28 0 : FCTgetCaller(int *ret)
29 : {
30 : (void) ret;
31 0 : throw(MAL, "factories.getCaller", SQLSTATE(0A000) PROGRAM_NYI);
32 : }
33 :
34 : static str
35 0 : FCTgetOwners(bat *ret)
36 : {
37 : (void) ret;
38 0 : throw(MAL, "factories.getOwner", SQLSTATE(0A000) PROGRAM_NYI);
39 : }
40 :
41 : static str
42 0 : FCTgetArrival(bat *ret)
43 : {
44 : (void) ret;
45 0 : throw(MAL, "factories.getArrival", SQLSTATE(0A000) PROGRAM_NYI);
46 : }
47 :
48 : static str
49 0 : FCTgetDeparture(bat *ret)
50 : {
51 : (void) ret;
52 0 : throw(MAL, "factories.getDeparture", SQLSTATE(0A000) PROGRAM_NYI);
53 : }
54 :
55 : static str
56 6 : FCTshutdown(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
57 : {
58 6 : str mod = *getArgReference_str(stk, pci, 1);
59 6 : str fcn = *getArgReference_str(stk, pci, 2);
60 : Symbol s;
61 : (void) mb;
62 :
63 6 : s = findSymbol(cntxt->usermodule, putName(mod), putName(fcn));
64 6 : if (s == NULL)
65 0 : throw(MAL, "factories.shutdown", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
66 6 : shutdownFactory(cntxt,s->def);
67 6 : return MAL_SUCCEED;
68 : }
69 :
70 : #include "mel.h"
71 : mel_func factories_init_funcs[] = {
72 : command("factories", "getPlants", FCTgetPlants, false, "Retrieve the names for all active factories.", args(2,2, batarg("mod",str),batarg("fcn",str))),
73 : command("factories", "getCaller", FCTgetCaller, false, "Retrieve the unique identity of the factory caller.", args(1,1, arg("",int))),
74 : command("factories", "getOwners", FCTgetOwners, false, "Retrieve the factory owners table.", args(1,1, batarg("",str))),
75 : command("factories", "getArrival", FCTgetArrival, false, "Retrieve the time stamp the last call was made.", args(1,1, batarg("",timestamp))),
76 : command("factories", "getDeparture", FCTgetDeparture, false, "Retrieve the time stamp the last answer was returned.", args(1,1, batarg("",timestamp))),
77 : pattern("factories", "shutdown", FCTshutdown, false, "Close a factory.", args(1,3, arg("",void),arg("m",str),arg("f",str))),
78 : { .imp=NULL }
79 : };
80 : #include "mal_import.h"
81 : #ifdef _MSC_VER
82 : #undef read
83 : #pragma section(".CRT$XCU",read)
84 : #endif
85 255 : LIB_STARTUP_FUNC(init_factories_mal)
86 255 : { mal_module("factories", NULL, factories_init_funcs); }
|