The SQL statements are translated into MAL programs, which are optimized and stored away in a user module. The generated code can be inspected with the MAL debugger. Its functionality is modelled after the GNU Debugger.
This feature is only available when MonetDB is compiled from source
with -DCMAKE_BUILD_TYPE=Debug -DASSERT=ON -DSTRICT=ON --verbose
.
sql>DEBUG SELECT count(*) FROM sys.tables;
mdb>#X_0=0@0:void := querylog.define("debug select count(*) from sys.tables;", "default_pipe", 27:int);
mdb>list
function user.main():void; #[0]
X_0:void := querylog.define("debug select count(*) from sys.tables;", "default_pipe", 27:int); #[1] QLOGdefineNaive
barrier X_1:bit := language.dataflow(); #[2] MALstartDataflow
X_2:int := sql.mvc(); #[3] SQLmvc
C_3:bat[:oid] := sql.tid(X_2, "sys", "_tables"); #[4] SQLtid
X_4:bat[:sht] := sql.bind(X_2, "sys", "_tables", "type", 0:int); #[5] mvc_bind_wrap
(X_5:bat[:oid], X_6:bat[:sht]) := sql.bind(X_2, "sys", "_tables", "type", 2:int); #[6] mvc_bind_wrap
C_7:bat[:oid] := algebra.thetaselect(X_4, C_3, 2:sht, "!="); #[7] ALGthetaselect2
C_8:bat[:oid] := algebra.thetaselect(X_6, nil:bat[:oid], 2:sht, "!="); #[8] ALGthetaselect2
C_9:bat[:oid] := sql.subdelta(C_7, C_3, X_5, C_8); #[9] DELTAsub
X_10:lng := aggr.count(C_9); #[10] ALGcount_bat
C_11:bat[:oid] := sql.tid(X_2, "tmp", "_tables"); #[11] SQLtid
X_12:lng := aggr.count(C_11); #[12] ALGcount_bat
X_13:bat[:lng] := bat.single(X_10); #[13] CMDBATsingle
X_14:bat[:lng] := bat.new(nil:lng); #[14] CMDBATnew
X_15:bat[:lng] := bat.append(X_14, X_13, true); #[15] BKCappend_force_wrap
X_16:bat[:lng] := bat.append(X_15, X_12, true); #[16] BKCappend_val_force_wrap
X_17:lng := aggr.sum(X_16); #[17] CMDBATsum
X_18:void := language.pass(C_3); #[18] MALpass
exit X_1:bit; #[19]
X_19:int := sql.resultSet(".%10", "%10", "bigint", 64:int, 0:int, 7:int, X_17); #[20] mvc_scalar_value_wrap
end user.main; #[21]
...
mdb>next
mdb>#barrier X_1=false:bit := language.dataflow();
mdb>next
mdb>#X_2=0:int := sql.mvc();
mdb>next
mdb>#C_3=nil:bat[:oid] := sql.tid(X_2=0, "sys", "_tables");
...
mdb>help
next -- Advance to next statement
continue -- Continue program being debugged
catch -- Catch the next exception
break [<var>] -- set breakpoint on current instruction or <var>
delete [<var>] -- remove break/trace point <var>
debug <int> -- set kernel debugging mask
step -- advance to next MAL instruction
module -- display a module signatures
atom -- show atom list
finish -- finish current call
exit -- terminate executionr
quit -- turn off debugging
list <obj> -- list current program block
list # [+#],-# -- list current program block slice
List <obj> [#] -- list with type information[slice]
list [#] <obj> -- list program block after optimizer <#>
List # [+#],-# -- list current program block slice
var <obj> -- print symbol table for module
optimizer <obj> -- display optimizer steps
print <var> -- display value of a variable
print <var> <cnt>[<first>] -- display BAT chunk
info <var> -- display bat variable properties
run -- restart current procedure
where -- print stack trace
down -- go down the stack
up -- go up the stack
trace <var> -- trace assignment to variables
trap <mod>.<fcn> -- catch MAL function call in debugger
help -- this message
mdb>#C_3=nil:bat[:oid] := sql.tid(X_2=0, "sys", "_tables");