webmcp

annotate framework/env/trace/sql.lua @ 295:1fbdccf4f8e9

Always enable SQL tracer (within framework/env/__init.lua); Record execution time of SQL statements
author jbe
date Sun Mar 22 18:40:07 2015 +0100 (2015-03-22)
parents 0bbfee4d4aed
children fe9ea7a03364
rev   line source
jbe/bsw@0 1 --[[--
jbe/bsw@0 2 trace.sql{
jbe@295 3 command = command, -- executed SQL command as string
jbe@295 4 execution_time = execution_time, -- execution time of the statement in seconds
jbe@295 5 error_position = error_position -- optional position in bytes where an error occurred
jbe/bsw@0 6 }
jbe/bsw@0 7
jbe/bsw@0 8 This command can be used to log SQL command execution. It is currently not invoked automatically.
jbe/bsw@0 9
jbe/bsw@0 10 --]]--
jbe/bsw@0 11
jbe/bsw@0 12 -- TODO: automatic use of this function?
jbe/bsw@0 13
jbe/bsw@0 14 function trace.sql(args)
jbe@41 15 if not trace._disabled then
jbe@41 16 local command = args.command
jbe@295 17 local execution_time = args.execution_time
jbe@41 18 local error_position = args.error_position
jbe@41 19 if type(command) ~= "string" then
jbe@41 20 error("No command string passed to trace.sql{...}.")
jbe@41 21 end
jbe@295 22 if type(execution_time) ~= "number" then
jbe@295 23 error("No execution time number passed to trace.sql{...}.")
jbe@295 24 end
jbe@41 25 if error_position and type(error_position) ~= "number" then
jbe@41 26 error("error_position must be a number.")
jbe@41 27 end
jbe@41 28 trace._new_entry{
jbe@41 29 type = "sql",
jbe@41 30 command = command,
jbe@41 31 error_position = error_position
jbe@41 32 }
jbe/bsw@0 33 end
jbe/bsw@0 34 end

Impressum / About Us