Function sql_support::debug_tools::define_debug_functions
source · pub fn define_debug_functions(c: &Connection) -> Result<()>
Expand description
You can call this function to add all sql functions provided by this module to your connection. The list of supported functions is described below.
Note: you must enable the debug-tools
feature for these functions to perform
as described. If this feature is not enabled, functions of the same name will still
exist, but will be no-ops.
dbg
dbg()
is a simple sql function that prints all args to stderr and returns the last argument.
It’s useful for instrumenting existing WHERE statements - eg, changing a statement
WHERE a.bar = foo
to
WHERE dbg("a bar", a.bar) = foo
will print the literal a bar
followed by the value of a.bar
, then return a.bar
,
so the semantics of the WHERE
statement do not change.
If you have a series of statements being executed (ie, statements separated by a ;
),
adding a new statement like SELECT dbg("hello");
is also possible.