Changeset: a8db8647c99e for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a8db8647c99e
Added Files:
monetdb5/modules/mal/Tests/callfunction.mal
monetdb5/modules/mal/Tests/callfunction.stable.err
monetdb5/modules/mal/Tests/callfunction.stable.out
monetdb5/modules/mal/Tests/callstring.mal
monetdb5/modules/mal/Tests/callstring.stable.err
monetdb5/modules/mal/Tests/callstring.stable.out
Modified Files:
monetdb5/modules/mal/Tests/All
monetdb5/modules/mal/language.c
monetdb5/modules/mal/language.h
monetdb5/modules/mal/language.mal
Branch: default
Log Message:
Add simple tests for MAL evaluate calls
diffs (272 lines):
diff --git a/monetdb5/modules/mal/Tests/All b/monetdb5/modules/mal/Tests/All
--- a/monetdb5/modules/mal/Tests/All
+++ b/monetdb5/modules/mal/Tests/All
@@ -22,6 +22,8 @@ qgram
#statistics01
call00
+callstring
+callfunction
#radix
diff --git a/monetdb5/modules/mal/Tests/callfunction.mal
b/monetdb5/modules/mal/Tests/callfunction.mal
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mal/Tests/callfunction.mal
@@ -0,0 +1,14 @@
+function f1();
+ io.print("hello");
+end f1;
+
+function f2();
+ io.print("world");
+end f2;
+
+function q();
+ language.call("user","f1");
+ language.call("user","f2");
+end q;
+
+q();
diff --git a/monetdb5/modules/mal/Tests/callfunction.stable.err
b/monetdb5/modules/mal/Tests/callfunction.stable.err
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mal/Tests/callfunction.stable.err
@@ -0,0 +1,29 @@
+stderr of test 'callfunction` in directory 'monetdb5/modules/mal` itself:
+
+
+# 09:25:34 >
+# 09:25:34 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=33022" "--set"
"mapi_usock=/var/tmp/mtest-31772/.s.monetdb.33022" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/export/scratch1/mk/current//Linux/var/MonetDB/mTests_monetdb5_modules_mal"
"callfunction.mal"
+# 09:25:34 >
+
+# builtin opt gdk_dbpath =
/export/scratch1/mk/current//Linux/var/monetdb5/dbfarm/demo
+# builtin opt gdk_debug = 0
+# builtin opt gdk_vmtrim = yes
+# builtin opt monet_prompt = >
+# builtin opt monet_daemon = no
+# builtin opt mapi_port = 50000
+# builtin opt mapi_open = false
+# builtin opt mapi_autosense = false
+# builtin opt sql_optimizer = default_pipe
+# builtin opt sql_debug = 0
+# cmdline opt gdk_nr_threads = 0
+# cmdline opt mapi_open = true
+# cmdline opt mapi_port = 33022
+# cmdline opt mapi_usock = /var/tmp/mtest-31772/.s.monetdb.33022
+# cmdline opt monet_prompt =
+# cmdline opt mal_listing = 2
+# cmdline opt gdk_dbpath =
/export/scratch1/mk/current//Linux/var/MonetDB/mTests_monetdb5_modules_mal
+
+# 09:25:34 >
+# 09:25:34 > "Done."
+# 09:25:34 >
+
diff --git a/monetdb5/modules/mal/Tests/callfunction.stable.out
b/monetdb5/modules/mal/Tests/callfunction.stable.out
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mal/Tests/callfunction.stable.out
@@ -0,0 +1,46 @@
+stdout of test 'callfunction` in directory 'monetdb5/modules/mal` itself:
+
+
+# 09:25:34 >
+# 09:25:34 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=33022" "--set"
"mapi_usock=/var/tmp/mtest-31772/.s.monetdb.33022" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/export/scratch1/mk/current//Linux/var/MonetDB/mTests_monetdb5_modules_mal"
"callfunction.mal"
+# 09:25:34 >
+
+# MonetDB 5 server v11.16.0
+# This is an unreleased version
+# Serving database 'mTests_monetdb5_modules_mal', using 8 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically
linked
+# Found 15.629 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2013 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://vienna.ins.cwi.nl:33022/
+# Listening for UNIX domain connection requests on
mapi:monetdb:///var/tmp/mtest-31772/.s.monetdb.33022
+# MonetDB/GIS module loaded
+# MonetDB/JAQL module loaded
+# MonetDB/SQL module loaded
+function user.f1():void;
+ io.print("hello");
+end f1;
+function user.f2():void;
+ io.print("world");
+end f2;
+function user.q():void;
+ language.call("user","f1");
+ language.call("user","f2");
+end q;
+function user.main():void;
+ user.q();
+end main;
+function user.main():void;
+ user.f1();
+end main;
+[ "hello" ]
+function user.main():void;
+ user.f2();
+end main;
+[ "world" ]
+
+# 09:25:34 >
+# 09:25:34 > "Done."
+# 09:25:34 >
+
diff --git a/monetdb5/modules/mal/Tests/callstring.mal
b/monetdb5/modules/mal/Tests/callstring.mal
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mal/Tests/callstring.mal
@@ -0,0 +1,14 @@
+function f1();
+ io.print("hello");
+end f1;
+
+function f2();
+ io.print("world");
+end f2;
+
+function q();
+ language.call("user.f1();");
+ language.call("user.f2();");
+end q;
+
+q();
diff --git a/monetdb5/modules/mal/Tests/callstring.stable.err
b/monetdb5/modules/mal/Tests/callstring.stable.err
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mal/Tests/callstring.stable.err
@@ -0,0 +1,29 @@
+stderr of test 'callstring` in directory 'monetdb5/modules/mal` itself:
+
+
+# 09:25:34 >
+# 09:25:34 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=33022" "--set"
"mapi_usock=/var/tmp/mtest-31772/.s.monetdb.33022" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/export/scratch1/mk/current//Linux/var/MonetDB/mTests_monetdb5_modules_mal"
"callstring.mal"
+# 09:25:34 >
+
+# builtin opt gdk_dbpath =
/export/scratch1/mk/current//Linux/var/monetdb5/dbfarm/demo
+# builtin opt gdk_debug = 0
+# builtin opt gdk_vmtrim = yes
+# builtin opt monet_prompt = >
+# builtin opt monet_daemon = no
+# builtin opt mapi_port = 50000
+# builtin opt mapi_open = false
+# builtin opt mapi_autosense = false
+# builtin opt sql_optimizer = default_pipe
+# builtin opt sql_debug = 0
+# cmdline opt gdk_nr_threads = 0
+# cmdline opt mapi_open = true
+# cmdline opt mapi_port = 33022
+# cmdline opt mapi_usock = /var/tmp/mtest-31772/.s.monetdb.33022
+# cmdline opt monet_prompt =
+# cmdline opt mal_listing = 2
+# cmdline opt gdk_dbpath =
/export/scratch1/mk/current//Linux/var/MonetDB/mTests_monetdb5_modules_mal
+
+# 09:25:34 >
+# 09:25:34 > "Done."
+# 09:25:34 >
+
diff --git a/monetdb5/modules/mal/Tests/callstring.stable.out
b/monetdb5/modules/mal/Tests/callstring.stable.out
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mal/Tests/callstring.stable.out
@@ -0,0 +1,46 @@
+stdout of test 'callstring` in directory 'monetdb5/modules/mal` itself:
+
+
+# 09:25:34 >
+# 09:25:34 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=33022" "--set"
"mapi_usock=/var/tmp/mtest-31772/.s.monetdb.33022" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/export/scratch1/mk/current//Linux/var/MonetDB/mTests_monetdb5_modules_mal"
"callstring.mal"
+# 09:25:34 >
+
+# MonetDB 5 server v11.16.0
+# This is an unreleased version
+# Serving database 'mTests_monetdb5_modules_mal', using 8 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically
linked
+# Found 15.629 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2013 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://vienna.ins.cwi.nl:33022/
+# Listening for UNIX domain connection requests on
mapi:monetdb:///var/tmp/mtest-31772/.s.monetdb.33022
+# MonetDB/GIS module loaded
+# MonetDB/JAQL module loaded
+# MonetDB/SQL module loaded
+function user.f1():void;
+ io.print("hello");
+end f1;
+function user.f2():void;
+ io.print("world");
+end f2;
+function user.q():void;
+ language.call("user.f1();");
+ language.call("user.f2();");
+end q;
+function user.main():void;
+ user.q();
+end main;
+function user.main():void;
+ user.f1();
+end main;
+[ "hello" ]
+function user.main():void;
+ user.f2();
+end main;
+[ "world" ]
+
+# 09:25:34 >
+# 09:25:34 > "Done."
+# 09:25:34 >
+
diff --git a/monetdb5/modules/mal/language.c b/monetdb5/modules/mal/language.c
--- a/monetdb5/modules/mal/language.c
+++ b/monetdb5/modules/mal/language.c
@@ -121,6 +121,22 @@ CMDcallString(Client cntxt, MalBlkPtr mb
}
str
+CMDcallFunction(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+ str mod = *(str*) getArgReference(stk,pci,1);
+ str fcn = *(str*) getArgReference(stk,pci,2);
+ char buf[BUFSIZ];
+
+ (void) mb; /* fool compiler */
+ if (strlen(mod) == 0 || strlen(fcn) ==0)
+ return MAL_SUCCEED;
+ // lazy implementation of the call
+ snprintf(buf,BUFSIZ,"%s.%s();",mod,fcn);
+ callString(cntxt, buf, FALSE);
+ return MAL_SUCCEED;
+}
+
+str
MALstartDataflow( Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
str msg= MAL_SUCCEED;
diff --git a/monetdb5/modules/mal/language.h b/monetdb5/modules/mal/language.h
--- a/monetdb5/modules/mal/language.h
+++ b/monetdb5/modules/mal/language.h
@@ -51,8 +51,9 @@ language_export str MALpass( Client cntx
language_export str MALgarbagesink( Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
language_export str CMDregisterFunction(Client cntxt, MalBlkPtr mb, MalStkPtr
stk, InstrPtr pci);
language_export str CMDcallString(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
+language_export str CMDcallFunction(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
+language_export str CMDcallBAT(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
language_export str CMDevalFile(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
-language_export str CMDcallBAT(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
language_export str CMDincludeFile(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
language_export str CMDdebug(int *ret, int *flg);
language_export str MALassertTriple(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
diff --git a/monetdb5/modules/mal/language.mal
b/monetdb5/modules/mal/language.mal
--- a/monetdb5/modules/mal/language.mal
+++ b/monetdb5/modules/mal/language.mal
@@ -3,6 +3,8 @@ module language;
pattern call(s:str):void
address CMDcallString
comment "Evaluate a MAL string program.";
+pattern call(m:str,f:str):void
+address CMDcallFunction;
pattern call(s:bat[:oid,:str]):void
address CMDcallBAT
comment "Evaluate a program stored in a BAT.";
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list